Przeglądaj źródła

Changes due to CR

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 lat temu
rodzic
commit
77751da6b8

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

@@ -116,21 +116,20 @@ public class FileMenuFilter {
     }
 
     /**
-     * Filters out the file actions available in the passed {@link Menu} taken into account
-     * the state of the {@link OCFile} held by the filter.
+     * Filters out the file actions available in the passed {@link Menu} taken into account the state of the {@link
+     * OCFile} held by the filter.
      *
-     * @param menu                  Options or context menu to filter.
-     * @param inSingleFileFragment  True if this is not listing, but single file fragment, like preview or details.
-     * @param isMediaSupported      True is media playback is supported for this user
+     * @param menu                 Options or context menu to filter.
+     * @param inSingleFileFragment True if this is not listing, but single file fragment, like preview or details.
      */
-    public void filter(Menu menu, boolean inSingleFileFragment, boolean isMediaSupported) {
+    public void filter(Menu menu, boolean inSingleFileFragment) {
         if (files == null || files.isEmpty()) {
             hideAll(menu);
         } else {
             List<Integer> toShow = new ArrayList<>();
             List<Integer> toHide = new ArrayList<>();
 
-            filter(toShow, toHide, inSingleFileFragment, isMediaSupported);
+            filter(toShow, toHide, inSingleFileFragment);
 
             for (int i : toShow) {
                 showMenuItem(menu.findItem(i));
@@ -179,16 +178,13 @@ public class FileMenuFilter {
 
     /**
      * Decides what actions must be shown and hidden implementing the different rule sets.
-     *
-     * @param toShow                List to save the options that must be shown in the menu.
+     *  @param toShow                List to save the options that must be shown in the menu.
      * @param toHide                List to save the options that must be shown in the menu.
      * @param inSingleFileFragment  True if this is not listing, but single file fragment, like preview or details.
-     * @param isMediaSupported      True is media playback is supported for this user
      */
     private void filter(List<Integer> toShow,
                         List<Integer> toHide,
-                        boolean inSingleFileFragment,
-                        boolean isMediaSupported) {
+                        boolean inSingleFileFragment) {
         boolean synchronizing = anyFileSynchronizing();
         OCCapability capability = componentsGetter.getStorageManager().getCapability(user.getAccountName());
         boolean endToEndEncryptionEnabled = capability.getEndToEndEncryption().isTrue();
@@ -211,7 +207,7 @@ public class FileMenuFilter {
         filterEncrypt(toShow, toHide, endToEndEncryptionEnabled);
         filterUnsetEncrypted(toShow, toHide, endToEndEncryptionEnabled);
         filterSetPictureAs(toShow, toHide);
-        filterStream(toShow, toHide, isMediaSupported);
+        filterStream(toShow, toHide);
     }
 
     private void filterShareFile(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
@@ -429,8 +425,8 @@ public class FileMenuFilter {
         }
     }
 
-    private void filterStream(List<Integer> toShow, List<Integer> toHide, boolean isMediaSupported) {
-        if (files.isEmpty() || !isSingleFile() || !isSingleMedia() || !isMediaSupported) {
+    private void filterStream(List<Integer> toShow, List<Integer> toHide) {
+        if (files.isEmpty() || !isSingleFile() || !isSingleMedia()) {
             toHide.add(R.id.action_stream_media);
         } else {
             toShow.add(R.id.action_stream_media);

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

@@ -412,9 +412,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
                 currentUser
             );
 
-            mf.filter(menu,
-                      true,
-                      true);
+            mf.filter(menu, true);
         }
 
         if (getFile().isFolder()) {

+ 0 - 5
src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java

@@ -326,7 +326,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
         MenuItem allowDeletingItem = menu.findItem(R.id.allow_deleting);
         MenuItem expirationDateItem = menu.findItem(R.id.action_expiration_date);
         MenuItem reshareItem = menu.findItem(R.id.allow_resharing);
-        MenuItem sendNoteItem = menu.findItem(R.id.action_share_send_note);
 
         allowEditingItem.setChecked(canEdit(share));
 
@@ -350,8 +349,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
         SharingMenuHelper.setupExpirationDateMenuItem(menu.findItem(R.id.action_expiration_date),
                                                       share.getExpirationDate(),
                                                       getResources());
-
-        sendNoteItem.setVisible(true);
     }
 
     public void showLinkOverflowMenu(OCShare publicShare, ImageView overflowMenuShareLink) {
@@ -407,8 +404,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
         SharingMenuHelper.setupExpirationDateMenuItem(menu.findItem(R.id.action_share_expiration_date),
                                                       publicShare.getExpirationDate(),
                                                       res);
-
-        menu.findItem(R.id.action_share_send_note).setVisible(true);
     }
 
     @VisibleForTesting

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

@@ -522,16 +522,13 @@ public class OCFileListFragment extends ExtendedListFragment implements
     public void onOverflowIconClicked(OCFile file, View view) {
         PopupMenu popup = new PopupMenu(getActivity(), view);
         popup.inflate(R.menu.item_file);
-        User currentUser = ((FileActivity) getActivity()).getUser().orElseThrow(IllegalStateException::new);
         FileMenuFilter mf = new FileMenuFilter(mAdapter.getFiles().size(),
                                                Collections.singleton(file),
                                                mContainerActivity, getActivity(),
                                                true,
                                                deviceInfo,
                                                accountManager.getUser());
-        mf.filter(popup.getMenu(),
-                  true,
-                  true);
+        mf.filter(popup.getMenu(), true);
         popup.setOnMenuItemClickListener(item -> {
             Set<OCFile> checkedFiles = new HashSet<>();
             checkedFiles.add(file);
@@ -682,7 +679,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
             Set<OCFile> checkedFiles = mAdapter.getCheckedItems();
             String title = getResources().getQuantityString(R.plurals.items_selected_count, checkedCount, checkedCount);
             mode.setTitle(title);
-            User currentUser = accountManager.getUser();
             FileMenuFilter mf = new FileMenuFilter(
                 mAdapter.getFiles().size(),
                 checkedFiles,
@@ -693,7 +689,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
                 accountManager.getUser()
             );
 
-            mf.filter(menu, false, true);
+            mf.filter(menu, false);
 
             // Determine if we need to finish the action mode because there are no items selected
             if (checkedCount == 0 && !mIsActionModeNew) {

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

@@ -383,9 +383,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
                 currentUser
             );
 
-            mf.filter(menu,
-                      true,
-                      true);
+            mf.filter(menu, true);
         }
 
         // additional restriction for this fragment

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

@@ -356,7 +356,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
                 currentUser
             );
 
-            mf.filter(menu, true, true);
+            mf.filter(menu, true);
         }
 
         // additional restriction for this fragment

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

@@ -270,7 +270,7 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
                 deviceInfo,
                 user
             );
-            mf.filter(menu, true, true);
+            mf.filter(menu, true);
         }
 
         // additional restriction for this fragment