Эх сурвалжийг харах

Do not show select/deselect all in the per-item overflow menus

Hari 7 жил өмнө
parent
commit
dbad84667d

+ 11 - 5
src/main/java/com/owncloud/android/files/FileMenuFilter.java

@@ -52,6 +52,7 @@ public class FileMenuFilter {
     private ComponentsGetter mComponentsGetter;
     private Account mAccount;
     private Context mContext;
+    private boolean mOverflowMenu;
 
     /**
      * Constructor
@@ -61,14 +62,16 @@ public class FileMenuFilter {
      * @param account           ownCloud {@link Account} holding targetFile.
      * @param cg                Accessor to app components, needed to access synchronization services
      * @param context           Android {@link Context}, needed to access build setup resources.
+     * @param overflowMenu      true if the overflow menu items are being filtered
      */
     public FileMenuFilter(int numberOfAllFiles, Collection<OCFile> targetFiles, Account account,
-                          ComponentsGetter cg, Context context) {
+                          ComponentsGetter cg, Context context, boolean overflowMenu) {
         mNumberOfAllFiles = numberOfAllFiles;
         mFiles = targetFiles;
         mAccount = account;
         mComponentsGetter = cg;
         mContext = context;
+        mOverflowMenu = overflowMenu;
     }
 
     /**
@@ -78,9 +81,12 @@ public class FileMenuFilter {
      * @param account           ownCloud {@link Account} holding targetFile.
      * @param cg                Accessor to app components, needed to access synchronization services
      * @param context           Android {@link Context}, needed to access build setup resources.
+     * @param overflowMenu      true if the overflow menu items are being filtered
      */
-    public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, Context context) {
-        this(1, Collections.singletonList(targetFile), account, cg, context);
+    public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, Context context,
+                          boolean overflowMenu) {
+        this(1, Collections.singletonList(targetFile), account, cg, context,
+                overflowMenu);
     }
 
     /**
@@ -178,7 +184,7 @@ public class FileMenuFilter {
         // SELECT ALL
         if (!inSingleFileFragment) {
             // Show only if at least one item isn't selected.
-            if (mFiles.size() >= mNumberOfAllFiles) {
+            if (mFiles.size() >= mNumberOfAllFiles || mOverflowMenu) {
                 toHide.add(R.id.action_select_all_action_menu);
             } else {
                 toShow.add(R.id.action_select_all_action_menu);
@@ -191,7 +197,7 @@ public class FileMenuFilter {
         // DESELECT ALL
         if (!inSingleFileFragment) {
             // Show only if at least one item is selected.
-            if (mFiles.isEmpty()) {
+            if (mFiles.isEmpty() || mOverflowMenu) {
                 toHide.add(R.id.action_deselect_all_action_menu);
             } else {
                 toShow.add(R.id.action_deselect_all_action_menu);

+ 2 - 1
src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -216,7 +216,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
                 mContainerActivity,
-                getActivity()
+                getActivity(),
+                false
             );
             mf.filter(menu, true);
         }

+ 4 - 2
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -529,7 +529,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
                 Collections.singleton(file),
                 ((FileActivity) getActivity()).getAccount(),
                 mContainerActivity,
-                getActivity()
+                getActivity(),
+                true
         );
         mf.filter(popup.getMenu());
         popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@@ -661,7 +662,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
                     checkedFiles,
                     ((FileActivity) getActivity()).getAccount(),
                     mContainerActivity,
-                    getActivity()
+                    getActivity(),
+                    false
             );
             mf.filter(menu, false);
             return true;

+ 2 - 1
src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java

@@ -275,7 +275,8 @@ public class PreviewImageFragment extends FileFragment {
                     getFile(),
                     mContainerActivity.getStorageManager().getAccount(),
                     mContainerActivity,
-                    getActivity()
+                    getActivity(),
+                    false
             );
             mf.filter(menu, true);
         }

+ 2 - 1
src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java

@@ -375,7 +375,8 @@ public class PreviewMediaFragment extends FileFragment implements
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
                 mContainerActivity,
-                getActivity()
+                getActivity(),
+                false
             );
             mf.filter(menu, true);
         }

+ 2 - 1
src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java

@@ -285,7 +285,8 @@ public class PreviewTextFragment extends FileFragment {
                     getFile(),
                     mContainerActivity.getStorageManager().getAccount(),
                     mContainerActivity,
-                    getActivity()
+                    getActivity(),
+                    false
             );
             mf.filter(menu, true);
         }