FileActionsBottomSheet: additional filtering in FileDetailFragment

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-11-11 15:41:21 +01:00
parent dd94167733
commit 7c53e77e57
No known key found for this signature in database
GPG key ID: 2585783189A62105
5 changed files with 28 additions and 31 deletions

View file

@ -49,7 +49,6 @@ import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener
import com.owncloud.android.utils.theme.ViewThemeUtils
import javax.inject.Inject
// TODO give events back
// TODO theming
class FileActionsBottomSheet private constructor() : BottomSheetDialogFragment(), Injectable {
@ -75,7 +74,7 @@ class FileActionsBottomSheet private constructor() : BottomSheetDialogFragment()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val args = requireArguments()
// TODO pass only IDs, fetch from DB to avoid TransactionTooLarge
// todo parse bundle in viewmodel, not here
val files: Array<OCFile>? = args.getParcelableArray(ARG_FILES) as Array<OCFile>?
require(files != null)
val numberOfAllFiles: Int = args.getInt(ARG_ALL_FILES_COUNT, 1)

View file

@ -79,6 +79,8 @@ import org.greenrobot.eventbus.ThreadMode;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
@ -240,9 +242,25 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
}
private void onOverflowIconClicked() {
// TODO this fragment originally used fragment_file_detail.xml menu, which has fewer things that item_file.xml. Figure that out
final OCFile file = getFile();
FileActionsBottomSheet.newInstance(file, containerActivity, true, this::optionsItemSelected)
final List<Integer> additionalFilter = new ArrayList<>(
Arrays.asList(
R.id.action_lock_file,
R.id.action_unlock_file,
R.id.action_edit,
R.id.action_favorite,
R.id.action_unset_favorite,
R.id.action_see_details,
R.id.action_move,
R.id.action_copy,
R.id.action_stream_media,
R.id.action_send_share_file,
R.id.action_select_all_action_menu));
if (getFile().isFolder()) {
additionalFilter.add(R.id.action_send_file);
additionalFilter.add(R.id.action_sync_file);
}
FileActionsBottomSheet.newInstance(file, containerActivity, true, this::optionsItemSelected, additionalFilter)
.show(getActivity().getSupportFragmentManager(), "actions");
}
@ -365,27 +383,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
MenuUtils.hideAll(menu);
}
private void prepareOptionsMenu(Menu menu) {
// if (containerActivity.getStorageManager() != null) {
// User currentUser = accountManager.getUser();
// FileMenuFilter mf = new FileMenuFilter(
// getFile(),
// containerActivity,
// getActivity(),
// false,
// currentUser
// );
//
// mf.filter(menu, true);
// }
// TODO handle this
if (getFile().isFolder()) {
MenuUtils.hideMenuItem(menu.findItem(R.id.action_send_file));
MenuUtils.hideMenuItem(menu.findItem(R.id.action_sync_file));
}
}
private void optionsItemSelected(final int itemId) {
if (itemId == R.id.action_send_file) {
containerActivity.getFileOperationsHelper().sendShareFile(getFile(), true);

View file

@ -357,7 +357,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
final OCFile fileNew = getFile();
if (fileNew != null) {
final List<Integer> additionalFilter =
final List<Integer> additionalFilter = new ArrayList<>(
Arrays.asList(
R.id.action_rename_file,
R.id.action_sync_file,
@ -366,7 +366,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
R.id.action_copy,
R.id.action_favorite,
R.id.action_unset_favorite
);
));
if (getFile() != null && getFile().isSharedWithMe() && !getFile().canReshare()) {
additionalFilter.add(R.id.action_send_share_file);
}

View file

@ -385,7 +385,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
final OCFile fileNew = getFile();
if (fileNew != null) {
final List<Integer> additionalFilter =
final List<Integer> additionalFilter = new ArrayList<>(
Arrays.asList(
R.id.action_rename_file,
R.id.action_sync_file,
@ -394,7 +394,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
R.id.action_copy,
R.id.action_favorite,
R.id.action_unset_favorite
);
));
if (getFile() != null && getFile().isSharedWithMe() && !getFile().canReshare()) {
additionalFilter.add(R.id.action_send_share_file);
}

View file

@ -53,6 +53,7 @@ import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@ -285,7 +286,7 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
final OCFile fileNew = getFile();
if (fileNew != null) {
final List<Integer> additionalFilter =
final List<Integer> additionalFilter = new ArrayList<>(
Arrays.asList(
R.id.action_rename_file,
R.id.action_sync_file,
@ -294,7 +295,7 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
R.id.action_copy,
R.id.action_favorite,
R.id.action_unset_favorite
);
));
if (getFile() != null && getFile().isSharedWithMe() && !getFile().canReshare()) {
additionalFilter.add(R.id.action_send_share_file);
}