Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: Added AddMarker presenter/view/fragment. Fixed crash bug wit…
…h notification bar for Android 4.0.3. Related to issue #406.
- Loading branch information
1 parent
48517e0
commit 60e5b32
Showing
20 changed files
with
942 additions
and
617 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
MPfm/MPfm.Android/Classes/Fragments/AddMarkerFragment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright © 2011-2013 Yanick Castonguay | ||
// | ||
// This file is part of MPfm. | ||
// | ||
// MPfm is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// MPfm is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with MPfm. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using Android.App; | ||
using Android.Content; | ||
using Android.OS; | ||
using Android.Views; | ||
using Android.Widget; | ||
using MPfm.Android.Classes.Adapters; | ||
using MPfm.Android.Classes.Fragments.Base; | ||
using MPfm.MVP.Presenters; | ||
using MPfm.MVP.Views; | ||
|
||
namespace MPfm.Android.Classes.Fragments | ||
{ | ||
public class AddMarkerFragment : BaseDialogFragment, IAddMarkerView | ||
{ | ||
private View _view; | ||
private RadioButton _radioVerse; | ||
private RadioButton _radioChorus; | ||
private RadioButton _radioBridge; | ||
private RadioButton _radioSolo; | ||
private Button _btnCancel; | ||
private Button _btnCreate; | ||
|
||
public AddMarkerFragment() : base(null) | ||
{ | ||
} | ||
|
||
public AddMarkerFragment(Action<IBaseView> onViewReady) | ||
: base(onViewReady) | ||
{ | ||
} | ||
|
||
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) | ||
{ | ||
Dialog.SetTitle("Select marker template"); | ||
_view = inflater.Inflate(Resource.Layout.AddMarker, container, false); | ||
|
||
_btnCancel = _view.FindViewById<Button>(Resource.Id.addMarker_btnCancel); | ||
_btnCreate = _view.FindViewById<Button>(Resource.Id.addMarker_btnCreate); | ||
_radioVerse = _view.FindViewById<RadioButton>(Resource.Id.addMarker_radioVerse); | ||
_radioChorus = _view.FindViewById<RadioButton>(Resource.Id.addMarker_radioChorus); | ||
_radioBridge = _view.FindViewById<RadioButton>(Resource.Id.addMarker_radioBridge); | ||
_radioSolo = _view.FindViewById<RadioButton>(Resource.Id.addMarker_radioSolo); | ||
_btnCancel.Click += (sender, args) => Dismiss(); | ||
_btnCreate.Click += (sender, args) => | ||
{ | ||
MarkerTemplateNameType template = MarkerTemplateNameType.None; | ||
if(_radioVerse.Checked) | ||
template = MarkerTemplateNameType.Verse; | ||
else if (_radioChorus.Checked) | ||
template = MarkerTemplateNameType.Chorus; | ||
else if (_radioBridge.Checked) | ||
template = MarkerTemplateNameType.Bridge; | ||
else if (_radioSolo.Checked) | ||
template = MarkerTemplateNameType.Solo; | ||
OnAddMarker(template); | ||
Dismiss(); | ||
}; | ||
_radioVerse.Checked = true; | ||
|
||
return _view; | ||
} | ||
|
||
public override void OnCreate(Bundle savedInstanceState) | ||
{ | ||
base.OnCreate(savedInstanceState); | ||
SetStyle((int)DialogFragmentStyle.Normal, (int)Resource.Style.DialogTheme); | ||
} | ||
|
||
#region IAddMarkerView implementation | ||
|
||
public Action<MarkerTemplateNameType> OnAddMarker { get; set; } | ||
|
||
public void AddMarkerError(Exception ex) | ||
{ | ||
Activity.RunOnUiThread(() => | ||
{ | ||
AlertDialog ad = new AlertDialog.Builder(Activity).Create(); | ||
ad.SetCancelable(false); | ||
ad.SetMessage(string.Format("An error has occured in AddMarker: {0}", ex)); | ||
ad.SetButton("OK", (sender, args) => ad.Dismiss()); | ||
ad.Show(); | ||
}); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="200dp" | ||
android:layout_height="56dp" | ||
android:orientation="vertical"> | ||
<TextView | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center_vertical" | ||
android:paddingTop="12dp" | ||
android:paddingLeft="12dp" | ||
android:paddingRight="12dp" | ||
android:paddingBottom="0dp" | ||
android:text="Please select a marker template:" | ||
android:textColor="#AAAAAA" | ||
android:textSize="14dp" /> | ||
<RadioGroup | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
<RadioButton android:id="@+id/addMarker_radioVerse" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="8dp" | ||
android:text="Verse" | ||
android:textSize="14dp" /> | ||
<RadioButton android:id="@+id/addMarker_radioChorus" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="8dp" | ||
android:text="Chorus" | ||
android:textSize="14dp" /> | ||
<RadioButton android:id="@+id/addMarker_radioBridge" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="8dp" | ||
android:text="Bridge" | ||
android:textSize="14dp" /> | ||
<RadioButton android:id="@+id/addMarker_radioSolo" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="8dp" | ||
android:text="Solo" | ||
android:textSize="14dp" /> | ||
</RadioGroup> | ||
<LinearLayout | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="4dp" | ||
android:orientation="horizontal"> | ||
<Button | ||
android:id="@+id/addMarker_btnCancel" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:drawableLeft="@drawable/actionbar_cancel" | ||
android:drawablePadding="2dp" | ||
android:background="@drawable/dialogbutton" | ||
android:text="Cancel" | ||
android:textColor="@color/dialogbutton_text" | ||
android:textSize="14dp" | ||
android:padding="6dp" /> | ||
<Button | ||
android:id="@+id/addMarker_btnCreate" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:drawableLeft="@drawable/selectimage" | ||
android:drawablePadding="2dp" | ||
android:background="@drawable/dialogbutton" | ||
android:text="Create" | ||
android:textColor="@color/dialogbutton_text" | ||
android:textSize="14dp" | ||
android:padding="6dp" /> | ||
</LinearLayout> | ||
</LinearLayout> |
Oops, something went wrong.