Search in sources :

Example 11 with FileMenuFilter

use of com.owncloud.android.files.FileMenuFilter in project android by nextcloud.

the class OCFileListFragment method onOverflowIconClicked.

@Override
public void onOverflowIconClicked(OCFile file, View view) {
    throttler.run("overflowClick", () -> {
        PopupMenu popup = new PopupMenu(getActivity(), view);
        popup.inflate(R.menu.item_file);
        FileMenuFilter mf = new FileMenuFilter(mAdapter.getFiles().size(), Collections.singleton(file), mContainerActivity, getActivity(), true, accountManager.getUser());
        mf.filter(popup.getMenu(), true);
        popup.setOnMenuItemClickListener(item -> {
            Set<OCFile> checkedFiles = new HashSet<>();
            checkedFiles.add(file);
            return onFileActionChosen(item, checkedFiles);
        });
        popup.show();
    });
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileMenuFilter(com.owncloud.android.files.FileMenuFilter) PopupMenu(android.widget.PopupMenu) HashSet(java.util.HashSet)

Example 12 with FileMenuFilter

use of com.owncloud.android.files.FileMenuFilter in project android by nextcloud.

the class PreviewTextFileFragment method onPrepareOptionsMenu.

/**
 * {@inheritDoc}
 */
@Override
public void onPrepareOptionsMenu(@NonNull Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (containerActivity.getStorageManager() != null) {
        User user = accountManager.getUser();
        FileMenuFilter mf = new FileMenuFilter(getFile(), containerActivity, getActivity(), false, user);
        mf.filter(menu, true);
    }
    // additional restriction for this fragment
    FileMenuFilter.hideMenuItems(menu.findItem(R.id.action_rename_file), menu.findItem(R.id.action_select_all), menu.findItem(R.id.action_move), menu.findItem(R.id.action_download_file), menu.findItem(R.id.action_sync_file), menu.findItem(R.id.action_favorite), menu.findItem(R.id.action_unset_favorite));
    if (getFile().isSharedWithMe() && !getFile().canReshare()) {
        FileMenuFilter.hideMenuItem(menu.findItem(R.id.action_send_share_file));
    }
}
Also used : User(com.nextcloud.client.account.User) FileMenuFilter(com.owncloud.android.files.FileMenuFilter)

Aggregations

FileMenuFilter (com.owncloud.android.files.FileMenuFilter)12 MenuItem (android.view.MenuItem)8 User (com.nextcloud.client.account.User)4 PopupMenu (android.widget.PopupMenu)1 OCFile (com.owncloud.android.datamodel.OCFile)1 HashSet (java.util.HashSet)1