Search in sources :

Example 1 with RemoveFilesDialogFragment

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;
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FolderPickerActivity(com.owncloud.android.ui.activity.FolderPickerActivity) RenameFileDialogFragment(com.owncloud.android.ui.dialog.RenameFileDialogFragment) RemoveFilesDialogFragment(com.owncloud.android.ui.dialog.RemoveFilesDialogFragment) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)1 OCFile (com.owncloud.android.datamodel.OCFile)1 FolderPickerActivity (com.owncloud.android.ui.activity.FolderPickerActivity)1 RemoveFilesDialogFragment (com.owncloud.android.ui.dialog.RemoveFilesDialogFragment)1 RenameFileDialogFragment (com.owncloud.android.ui.dialog.RenameFileDialogFragment)1