mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
Changes due to CR
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
16997601fc
commit
77751da6b8
7 changed files with 17 additions and 34 deletions
|
@ -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
|
||||
*/
|
||||
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 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);
|
||||
|
|
|
@ -412,9 +412,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|||
currentUser
|
||||
);
|
||||
|
||||
mf.filter(menu,
|
||||
true,
|
||||
true);
|
||||
mf.filter(menu, true);
|
||||
}
|
||||
|
||||
if (getFile().isFolder()) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue