[Android] Fix add/remove favorite action item
Geoffrey Métais
git at videolan.org
Mon Feb 8 17:17:14 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 8 16:41:17 2016 +0100| [ce15d35afe01a31f82ed0efc3c129d02c69e6bdb] | committer: Geoffrey Métais
Fix add/remove favorite action item
> https://code.videolan.org/videolan/vlc-android/commit/ce15d35afe01a31f82ed0efc3c129d02c69e6bdb
---
vlc-android/res/menu/media_library.xml | 3 +--
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 9 ++++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/vlc-android/res/menu/media_library.xml b/vlc-android/res/menu/media_library.xml
index 65a329f..8f5a586 100644
--- a/vlc-android/res/menu/media_library.xml
+++ b/vlc-android/res/menu/media_library.xml
@@ -5,10 +5,9 @@
<item
android:id="@+id/ml_menu_save"
android:icon="@drawable/ic_menu_bookmark_outline_w"
- android:title="@string/clear_history"
android:nextFocusDown="@+id/ml_menu_search"
android:visible="false"
- vlc:showAsAction="ifRoom" />
+ vlc:showAsAction="always" />
<item
android:id="@+id/ml_menu_clean"
android:icon="@drawable/ic_trash_normal_w"
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 412a205..6adb8f4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -577,14 +577,17 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
item.setTitle(R.string.sortby_date);
}
- boolean networkSave = current instanceof NetworkBrowserFragment && !((NetworkBrowserFragment)current).isRootDirectory();
- if (networkSave) {
+ if (current instanceof NetworkBrowserFragment &&
+ !((NetworkBrowserFragment)current).isRootDirectory()) {
+ menu.findItem(R.id.ml_menu_search).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
item = menu.findItem(R.id.ml_menu_save);
item.setVisible(true);
String mrl = ((BaseBrowserFragment)current).mMrl;
- item.setIcon(MediaDatabase.getInstance().networkFavExists(Uri.parse(mrl)) ?
+ boolean isFavorite = MediaDatabase.getInstance().networkFavExists(Uri.parse(mrl));
+ item.setIcon(isFavorite ?
R.drawable.ic_menu_bookmark_w :
R.drawable.ic_menu_bookmark_outline_w);
+ item.setTitle(isFavorite ? R.string.favorites_remove : R.string.favorites_add);
} else
menu.findItem(R.id.ml_menu_save).setVisible(false);
if (current instanceof IHistory)
More information about the Android
mailing list