use of com.owncloud.android.ui.dialog.RemoveFilesDialogFragment in project android by owncloud.
the class OCFileListFragment method onFileActionChosen.
/**
* Start the appropriate action(s) on the currently selected files given menu selected by the user.
*
* @param menuId Identifier of the action menu selected by the user
* @return 'true' if the menu selection started any action, 'false' otherwise.
*/
public boolean onFileActionChosen(int menuId) {
final ArrayList<OCFile> checkedFiles = mAdapter.getCheckedItems(getListView());
if (checkedFiles.size() <= 0)
return false;
if (checkedFiles.size() == 1) {
/// action only possible on a single file
OCFile singleFile = checkedFiles.get(0);
switch(menuId) {
case R.id.action_share_file:
{
mContainerActivity.getFileOperationsHelper().showShareFile(singleFile);
return true;
}
case R.id.action_open_file_with:
{
mContainerActivity.getFileOperationsHelper().openFile(singleFile);
return true;
}
case R.id.action_rename_file:
{
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(singleFile);
dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE);
return true;
}
case R.id.action_see_details:
{
if (mActiveActionMode != null) {
mActiveActionMode.finish();
}
mContainerActivity.showDetails(singleFile);
return true;
}
case R.id.action_send_file:
{
// Obtain the file
if (!singleFile.isDown()) {
// Download the file
Log_OC.d(TAG, singleFile.getRemotePath() + " : File must be downloaded");
((FileDisplayActivity) mContainerActivity).startDownloadForSending(singleFile);
} else {
mContainerActivity.getFileOperationsHelper().sendDownloadedFile(singleFile);
}
return true;
}
}
}
/// actions possible on a batch of files
switch(menuId) {
case R.id.action_remove_file:
{
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(checkedFiles);
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
return true;
}
case R.id.action_download_file:
case R.id.action_sync_file:
{
mContainerActivity.getFileOperationsHelper().syncFiles(checkedFiles);
return true;
}
case R.id.action_cancel_sync:
{
((FileDisplayActivity) mContainerActivity).cancelTransference(checkedFiles);
return true;
}
case R.id.action_set_available_offline:
{
mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(checkedFiles, true);
getListView().invalidateViews();
return true;
}
case R.id.action_unset_available_offline:
{
mContainerActivity.getFileOperationsHelper().toggleAvailableOffline(checkedFiles, false);
getListView().invalidateViews();
invalidateActionMode();
return true;
}
case R.id.action_move:
{
Intent action = new Intent(getActivity(), FolderPickerActivity.class);
action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, checkedFiles);
getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__MOVE_FILES);
return true;
}
case R.id.action_copy:
Intent action = new Intent(getActivity(), FolderPickerActivity.class);
action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, checkedFiles);
getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__COPY_FILES);
return true;
default:
return false;
}
}
Aggregations