From 6f0d0d345cce38e57cda6d705d8444d3e584d252 Mon Sep 17 00:00:00 2001 From: ycastonguay Date: Fri, 26 Jul 2013 02:23:53 -0400 Subject: [PATCH] Android: Added new long press contextual menu for MobileLibraryBrowser list view. Play and Delete buttons are functional. Added new sync actionbar icon. Lots of layout bug fixes in EqualizerPreset screens. Related to issue #406. --- .../Classes/Activities/MainActivity.cs | 2 +- .../MobileLibraryBrowserListAdapter.cs | 32 +++++++- .../Fragments/MobileLibraryBrowserFragment.cs | 5 +- MPfm/MPfm.Android/MPfm.Android.csproj | 4 + .../Resources/Layout/AlbumCell.axml | 12 +-- .../Resources/Layout/EqualizerPresetCell.axml | 6 +- .../Layout/EqualizerPresetDetails.axml | 20 +++-- .../Resources/Layout/EqualizerPresets.axml | 10 ++- .../Resources/Resource.Designer.cs | 71 +++++++++--------- .../drawable-hdpi/actionbar_sync.png | Bin 0 -> 1619 bytes .../drawable-mdpi/actionbar_sync.png | Bin 0 -> 1388 bytes .../drawable-xhdpi/actionbar_sync.png | Bin 0 -> 1891 bytes .../drawable-xxhdpi/actionbar_sync.png | Bin 0 -> 2427 bytes .../MobileLibraryBrowserPresenter.cs | 55 ++++++++++++-- .../Views/IMobileLibraryBrowserView.cs | 3 +- 15 files changed, 155 insertions(+), 65 deletions(-) create mode 100644 MPfm/MPfm.Android/Resources/drawable-hdpi/actionbar_sync.png create mode 100644 MPfm/MPfm.Android/Resources/drawable-mdpi/actionbar_sync.png create mode 100644 MPfm/MPfm.Android/Resources/drawable-xhdpi/actionbar_sync.png create mode 100644 MPfm/MPfm.Android/Resources/drawable-xxhdpi/actionbar_sync.png diff --git a/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs b/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs index 18fff915..089487c0 100644 --- a/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs +++ b/MPfm/MPfm.Android/Classes/Activities/MainActivity.cs @@ -320,7 +320,7 @@ public override bool OnCreateOptionsMenu(IMenu menu) break; case MobileOptionsMenuType.SyncLibrary: menuItem.SetShowAsAction(ShowAsAction.IfRoom); - menuItem.SetIcon(Resource.Drawable.actionbar_mobile); + menuItem.SetIcon(Resource.Drawable.actionbar_sync); break; case MobileOptionsMenuType.SyncLibraryCloud: menuItem.SetIcon(Resource.Drawable.actionbar_cloud); diff --git a/MPfm/MPfm.Android/Classes/Adapters/MobileLibraryBrowserListAdapter.cs b/MPfm/MPfm.Android/Classes/Adapters/MobileLibraryBrowserListAdapter.cs index 5d302d14..06a633a6 100644 --- a/MPfm/MPfm.Android/Classes/Adapters/MobileLibraryBrowserListAdapter.cs +++ b/MPfm/MPfm.Android/Classes/Adapters/MobileLibraryBrowserListAdapter.cs @@ -22,6 +22,7 @@ using Android.Views; using Android.Views.Animations; using Android.Widget; +using MPfm.Android.Classes.Fragments; using MPfm.MVP.Models; namespace MPfm.Android.Classes.Adapters @@ -29,21 +30,25 @@ namespace MPfm.Android.Classes.Adapters public class MobileLibraryBrowserListAdapter : BaseAdapter, View.IOnClickListener { readonly Activity _context; + readonly MobileLibraryBrowserFragment _fragment; readonly ListView _listView; List _items; int _editingRowPosition = -1; public bool IsEditingRow { get; private set; } - public MobileLibraryBrowserListAdapter(Activity context, ListView listView, List items) + public MobileLibraryBrowserListAdapter(Activity context, MobileLibraryBrowserFragment fragment, ListView listView, List items) { _context = context; + _fragment = fragment; _listView = listView; _items = items; } public void SetData(IEnumerable items) { + _editingRowPosition = -1; + IsEditingRow = false; _items = items.ToList(); NotifyDataSetChanged(); } @@ -87,6 +92,19 @@ public override View GetView(int position, View convertView, ViewGroup parent) btnPlay.SetOnClickListener(this); btnDelete.SetOnClickListener(this); + if (IsEditingRow && position == _editingRowPosition) + { + btnAdd.Visibility = ViewStates.Visible; + btnPlay.Visibility = ViewStates.Visible; + btnDelete.Visibility = ViewStates.Visible; + } + else + { + btnAdd.Visibility = ViewStates.Gone; + btnPlay.Visibility = ViewStates.Gone; + btnDelete.Visibility = ViewStates.Gone; + } + lblTitle.Text = item.Title; lblTitleWithSubtitle.Text = item.Title; lblSubtitle.Text = string.Empty; @@ -201,13 +219,23 @@ public void OnClick(View v) switch(v.Id) { case Resource.Id.mobileLibraryBrowserCell_imageAdd: - Console.WriteLine("MLBLA - ADD - position: {0}", position); + Console.WriteLine("MLBLA - ADD - position: {0}", position); break; case Resource.Id.mobileLibraryBrowserCell_imagePlay: Console.WriteLine("MLBLA - PLAY - position: {0}", position); + _fragment.OnPlayItem(position); break; case Resource.Id.mobileLibraryBrowserCell_imageDelete: Console.WriteLine("MLBLA - DELETE - position: {0}", position); + AlertDialog ad = new AlertDialog.Builder(_context) + .SetIconAttribute(global::Android.Resource.Attribute.AlertDialogIcon) + .SetTitle("Delete confirmation") + .SetMessage(string.Format("Are you sure you wish to delete {0}?", _items[position].Title)) + .SetCancelable(true) + .SetPositiveButton("OK", (sender, args) => _fragment.OnDeleteItem(position)) + .SetNegativeButton("Cancel", (sender, args) => {}) + .Create(); + ad.Show(); break; } } diff --git a/MPfm/MPfm.Android/Classes/Fragments/MobileLibraryBrowserFragment.cs b/MPfm/MPfm.Android/Classes/Fragments/MobileLibraryBrowserFragment.cs index 87bda6b0..26e09364 100644 --- a/MPfm/MPfm.Android/Classes/Fragments/MobileLibraryBrowserFragment.cs +++ b/MPfm/MPfm.Android/Classes/Fragments/MobileLibraryBrowserFragment.cs @@ -92,7 +92,7 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup container, _listView.Visibility = ViewStates.Gone; _gridView.Visibility = ViewStates.Gone; - _listAdapter = new MobileLibraryBrowserListAdapter(Activity, _listView, _entities.ToList()); + _listAdapter = new MobileLibraryBrowserListAdapter(Activity, this, _listView, _entities.ToList()); _listView.SetAdapter(_listAdapter); _listView.ItemClick += ListViewOnItemClick; _listView.ItemLongClick += ListViewOnItemLongClick; @@ -190,6 +190,7 @@ public override void OnDetach() public string Filter { get; set; } public Action OnItemClick { get; set; } public Action OnDeleteItem { get; set; } + public Action OnPlayItem { get; set; } public Action OnRequestAlbumArt { get; set; } public void MobileLibraryBrowserError(Exception ex) @@ -272,6 +273,8 @@ public void RefreshLibraryBrowser(IEnumerable entities, Mo { if (_listView != null) _listAdapter.SetData(_entities); + + _listView.SetSelection(0); } }); } diff --git a/MPfm/MPfm.Android/MPfm.Android.csproj b/MPfm/MPfm.Android/MPfm.Android.csproj index 9d18d0ce..4083d1a0 100644 --- a/MPfm/MPfm.Android/MPfm.Android.csproj +++ b/MPfm/MPfm.Android/MPfm.Android.csproj @@ -432,6 +432,10 @@ + + + + diff --git a/MPfm/MPfm.Android/Resources/Layout/AlbumCell.axml b/MPfm/MPfm.Android/Resources/Layout/AlbumCell.axml index c34c935d..a5bdaab1 100644 --- a/MPfm/MPfm.Android/Resources/Layout/AlbumCell.axml +++ b/MPfm/MPfm.Android/Resources/Layout/AlbumCell.axml @@ -3,9 +3,7 @@ android:id="@+id/albumCell_layout" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:background="@color/background" - android:gravity="center" - android:orientation="vertical"> + android:background="@color/background"> + android:textSize="18dp" /> + android:textColor="@color/button_textcolor" + android:textSize="14dp" />