From 77751da6b8cc59dec2bf59941c407adc62aa862c Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 3 Nov 2020 11:24:08 +0100 Subject: [PATCH] Changes due to CR Signed-off-by: tobiasKaminsky --- .../android/files/FileMenuFilter.java | 26 ++++++++----------- .../ui/fragment/FileDetailFragment.java | 4 +-- .../fragment/FileDetailSharingFragment.java | 5 ---- .../ui/fragment/OCFileListFragment.java | 8 ++---- .../ui/preview/PreviewImageFragment.java | 4 +-- .../ui/preview/PreviewMediaFragment.java | 2 +- .../ui/preview/PreviewTextFileFragment.java | 2 +- 7 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/owncloud/android/files/FileMenuFilter.java b/src/main/java/com/owncloud/android/files/FileMenuFilter.java index 2b1e6a3c2c..d0b0240060 100644 --- a/src/main/java/com/owncloud/android/files/FileMenuFilter.java +++ b/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 toShow = new ArrayList<>(); List 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 toShow, List 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 toShow, List toHide, OCCapability capability) { @@ -429,8 +425,8 @@ public class FileMenuFilter { } } - private void filterStream(List toShow, List toHide, boolean isMediaSupported) { - if (files.isEmpty() || !isSingleFile() || !isSingleMedia() || !isMediaSupported) { + private void filterStream(List toShow, List toHide) { + if (files.isEmpty() || !isSingleFile() || !isSingleMedia()) { toHide.add(R.id.action_stream_media); } else { toShow.add(R.id.action_stream_media); diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index 6d69de90a4..e0eb5d89f0 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/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()) { diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java index 5e4d217544..5ccd74586f 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java +++ b/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 diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 26b0deb83c..c05a692797 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/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 checkedFiles = new HashSet<>(); checkedFiles.add(file); @@ -682,7 +679,6 @@ public class OCFileListFragment extends ExtendedListFragment implements Set 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) { diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java index 73c74e9f6b..b91bf45d2b 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/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 diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 97fa6829b8..bd57c37288 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/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 diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java index 4c674986df..8823333dbe 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java +++ b/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