[Android] Fix sort option visibility

Geoffrey Métais git at videolan.org
Mon Jul 24 15:20:23 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 24 12:15:01 2017 +0200| [0f44259bf794f24ec081e0c9073be9d13f271b2a] | committer: Geoffrey Métais

Fix sort option visibility

> https://code.videolan.org/videolan/vlc-android/commit/0f44259bf794f24ec081e0c9073be9d13f271b2a
---

 vlc-android/res/menu/activity_option.xml                     |  3 ++-
 .../org/videolan/vlc/gui/browser/BaseBrowserFragment.java    | 12 +++++-------
 .../org/videolan/vlc/gui/browser/FileBrowserFragment.java    |  8 ++++----
 .../org/videolan/vlc/gui/browser/NetworkBrowserFragment.java | 10 +++++-----
 .../src/org/videolan/vlc/gui/browser/SortableFragment.java   |  7 ++++++-
 5 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/vlc-android/res/menu/activity_option.xml b/vlc-android/res/menu/activity_option.xml
index da0344a78..920714482 100644
--- a/vlc-android/res/menu/activity_option.xml
+++ b/vlc-android/res/menu/activity_option.xml
@@ -21,7 +21,8 @@
         android:title="@string/sortby"
         android:icon="@drawable/ic_menu_sort"
         android:id="@+id/ml_menu_sortby"
-        vlc:showAsAction="ifRoom">
+        vlc:showAsAction="ifRoom"
+        android:visible="false">
         <menu>
             <item
                 android:orderInCategory="2"
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 321fdcaf2..1f1f1be6a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -116,9 +116,6 @@ public abstract class BaseBrowserFragment extends SortableFragment implements IR
     protected abstract Fragment createFragment();
     protected abstract void browseRoot();
     protected abstract String getCategoryTitle();
-    public boolean isSortEnabled() {
-        return false;
-    }
 
     private Handler mBrowserHandler;
 
@@ -161,11 +158,8 @@ public abstract class BaseBrowserFragment extends SortableFragment implements IR
 
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
-        MenuItem item = menu.findItem(R.id.ml_menu_sortby);
-        item.setEnabled(isSortEnabled());
-        item.setVisible(isSortEnabled());
-        menu.findItem(R.id.ml_menu_filter).setVisible(enableSearchOption());
         super.onPrepareOptionsMenu(menu);
+        menu.findItem(R.id.ml_menu_filter).setVisible(enableSearchOption());
     }
 
     protected int getLayoutId(){
@@ -921,4 +915,8 @@ public abstract class BaseBrowserFragment extends SortableFragment implements IR
     public int sortDirection(int sortby) {
         return mAdapter.sortDirection(sortby);
     }
+
+    public boolean isSortEnabled() {
+        return false;
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
index c17e56720..842df04c5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
@@ -61,10 +61,6 @@ public class FileBrowserFragment<T extends BaseBrowserAdapter> extends BaseBrows
         ROOT = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY;
     }
 
-    public boolean isSortEnabled() {
-        return !mRoot;
-    }
-
     @Override
     public void onCreate(Bundle bundle) {
         super.onCreate(bundle);
@@ -180,4 +176,8 @@ public class FileBrowserFragment<T extends BaseBrowserAdapter> extends BaseBrows
         } else
             return super.handleContextItemSelected(item, position);
     }
+
+    public boolean isSortEnabled() {
+        return !mRoot;
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
index 4ffaa8119..c698334e5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -60,10 +60,6 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
         mAdapter = new BaseBrowserAdapter(this);
     }
 
-    public boolean isSortEnabled() {
-        return !mRoot;
-    }
-
     @Override
     public void onCreate(Bundle bundle) {
         super.onCreate(bundle);
@@ -80,6 +76,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
 
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
         MenuItem item = menu.findItem(R.id.ml_menu_save);
         item.setVisible(isSortEnabled());
 
@@ -88,7 +85,6 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
                 R.drawable.ic_menu_bookmark_w :
                 R.drawable.ic_menu_bookmark_outline_w);
         item.setTitle(isFavorite ? R.string.favorites_remove : R.string.favorites_add);
-        super.onPrepareOptionsMenu(menu);
     }
 
     public void onStart() {
@@ -309,6 +305,10 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
         dialog.show(fm, "fragment_add_server");
     }
 
+    public boolean isSortEnabled() {
+        return !mRoot;
+    }
+
     private boolean mSkipRefresh = false;
     private final BroadcastReceiver networkReceiver = new BroadcastReceiver() {
         boolean connected = true;
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
index 71cecfb40..cfd613666 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
@@ -39,8 +39,9 @@ public abstract class SortableFragment extends MediaBrowserFragment {
 
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
-        UiTools.updateSortTitles(this, menu);
         super.onPrepareOptionsMenu(menu);
+        menu.findItem(R.id.ml_menu_sortby).setVisible(isSortEnabled());
+        UiTools.updateSortTitles(this, menu);
     }
 
     @Override
@@ -80,4 +81,8 @@ public abstract class SortableFragment extends MediaBrowserFragment {
                 return super.onOptionsItemSelected(item);
         }
     }
+
+    public boolean isSortEnabled() {
+        return true;
+    }
 }



More information about the Android mailing list