Search in sources :

Example 1 with FileMenuFilter

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

the class FileDetailFragment method onPrepareOptionsMenu.

/**
 * {@inheritDoc}
 */
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (mContainerActivity.getStorageManager() != null) {
        FileMenuFilter mf = new FileMenuFilter(getFile(), mContainerActivity.getStorageManager().getAccount(), mContainerActivity, getActivity(), false);
        mf.filter(menu, true);
    }
    // additional restriction for this fragment
    MenuItem item = menu.findItem(R.id.action_see_details);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_select_all);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_move);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_copy);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_favorite);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_unset_favorite);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_search);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    Boolean dualPane = getResources().getBoolean(R.bool.large_land_layout);
    item = menu.findItem(R.id.action_switch_view);
    if (item != null && !dualPane) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    item = menu.findItem(R.id.action_sync_account);
    if (item != null && !dualPane) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    item = menu.findItem(R.id.action_sort);
    if (item != null && !dualPane) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    item = menu.findItem(R.id.action_send_share_file);
    if (item != null) {
        ThemeUtils.tintDrawable(item.getIcon(), ThemeUtils.fontColor());
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        if (getFile().isSharedWithMe() && !getFile().canReshare()) {
            // additional restriction for this fragment
            item.setVisible(false);
            item.setEnabled(false);
        }
    }
}
Also used : MenuItem(android.view.MenuItem) FileMenuFilter(com.owncloud.android.files.FileMenuFilter)

Example 2 with FileMenuFilter

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

the class PreviewTextFragment method onPrepareOptionsMenu.

/**
 * {@inheritDoc}
 */
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (mContainerActivity.getStorageManager() != null) {
        FileMenuFilter mf = new FileMenuFilter(getFile(), mContainerActivity.getStorageManager().getAccount(), mContainerActivity, getActivity());
        mf.filter(menu, false, false, false, false);
    }
    // additional restriction for this fragment
    MenuItem item = menu.findItem(R.id.action_rename_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_move);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    item = menu.findItem(R.id.action_copy);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // this one doesn't make sense since the file has to be down in order to be previewed
    item = menu.findItem(R.id.action_download_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    item = menu.findItem(R.id.action_sync_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    item = menu.findItem(R.id.action_search);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
}
Also used : MenuItem(android.view.MenuItem) FileMenuFilter(com.owncloud.android.files.FileMenuFilter)

Example 3 with FileMenuFilter

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

the class PreviewVideoFragment method onPrepareOptionsMenu.

/**
 * {@inheritDoc}
 */
@Override
public void onPrepareOptionsMenu(@NonNull Menu menu) {
    super.onPrepareOptionsMenu(menu);
    FileMenuFilter mf = new FileMenuFilter(getFile(), mAccount, mContainerActivity, getActivity());
    mf.filter(menu, false, false, false, false);
    // additional restrictions for this fragment
    MenuItem item = menu.findItem(R.id.action_search);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
}
Also used : MenuItem(android.view.MenuItem) FileMenuFilter(com.owncloud.android.files.FileMenuFilter)

Example 4 with FileMenuFilter

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

the class PreviewMediaFragment method onPrepareOptionsMenu.

@Override
public void onPrepareOptionsMenu(@NonNull Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (containerActivity.getStorageManager() != null) {
        User currentUser = accountManager.getUser();
        FileMenuFilter mf = new FileMenuFilter(getFile(), containerActivity, getActivity(), false, currentUser);
        mf.filter(menu, true);
    }
    // additional restriction for this fragment
    // TODO allow renaming in PreviewImageFragment
    MenuItem item = menu.findItem(R.id.action_rename_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_select_all);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_move);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_copy);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_favorite);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_unset_favorite);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    if (getFile().isSharedWithMe() && !getFile().canReshare()) {
        // additional restriction for this fragment
        item = menu.findItem(R.id.action_send_share_file);
        if (item != null) {
            item.setVisible(false);
            item.setEnabled(false);
        }
    }
}
Also used : User(com.nextcloud.client.account.User) MenuItem(android.view.MenuItem) FileMenuFilter(com.owncloud.android.files.FileMenuFilter)

Example 5 with FileMenuFilter

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

the class PreviewImageFragment method onPrepareOptionsMenu.

/**
     * {@inheritDoc}
     */
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (mContainerActivity.getStorageManager() != null && getFile() != null) {
        // Update the file
        setFile(mContainerActivity.getStorageManager().getFileById(getFile().getFileId()));
        FileMenuFilter mf = new FileMenuFilter(getFile(), mContainerActivity.getStorageManager().getAccount(), mContainerActivity, getActivity());
        mf.filter(menu);
    }
    // additional restriction for this fragment 
    // TODO allow renaming in PreviewImageFragment
    MenuItem item = menu.findItem(R.id.action_rename_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment 
    // TODO allow refresh file in PreviewImageFragment
    item = menu.findItem(R.id.action_sync_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_move);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
    // additional restriction for this fragment
    item = menu.findItem(R.id.action_copy);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }
}
Also used : MenuItem(android.view.MenuItem) 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