use of com.owncloud.android.files.FileMenuFilter in project android by nextcloud.
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(), false);
mf.filter(menu, true);
}
// 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_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);
}
// 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_sync_account);
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_sort);
if (item != null && !dualPane) {
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);
}
}
}
use of com.owncloud.android.files.FileMenuFilter in project android by owncloud.
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());
mf.filter(menu, false, false, false, false);
}
// 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_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);
}
item = menu.findItem(R.id.action_search);
if (item != null) {
item.setVisible(false);
item.setEnabled(false);
}
}
use of com.owncloud.android.files.FileMenuFilter in project android by owncloud.
the class PreviewAudioFragment method onPrepareOptionsMenu.
/**
* {@inheritDoc}
*/
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
FileMenuFilter mf = new FileMenuFilter(getFile(), mAccount, mContainerActivity, getActivity());
mf.filter(menu, false, false, false, false);
// additional restriction for this fragment
// TODO allow renaming in PreviewAudioFragment
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);
}
// additional restriction for this fragment
item = menu.findItem(R.id.action_copy);
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);
}
item = menu.findItem(R.id.action_sync_file);
if (item != null) {
item.setVisible(false);
item.setEnabled(false);
}
}
use of com.owncloud.android.files.FileMenuFilter in project android by nextcloud.
the class FileDetailFragment method prepareOptionsMenu.
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);
}
if (getFile().isFolder()) {
FileMenuFilter.hideMenuItems(menu.findItem(R.id.action_send_file));
FileMenuFilter.hideMenuItems(menu.findItem(R.id.action_sync_file));
}
}
use of com.owncloud.android.files.FileMenuFilter in project android by nextcloud.
the class PreviewImageFragment method onPrepareOptionsMenu.
/**
* {@inheritDoc}
*/
@Override
public void onPrepareOptionsMenu(@NonNull Menu menu) {
super.onPrepareOptionsMenu(menu);
if (containerActivity.getStorageManager() != null && getFile() != null) {
// Update the file
setFile(containerActivity.getStorageManager().getFileById(getFile().getFileId()));
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
// TODO allow refresh file in PreviewImageFragment
FileMenuFilter.hideMenuItems(menu.findItem(R.id.action_rename_file), menu.findItem(R.id.action_sync_file), menu.findItem(R.id.action_select_all), menu.findItem(R.id.action_move), menu.findItem(R.id.action_copy), 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));
}
}