|
@@ -30,6 +30,7 @@ import android.app.AlertDialog;
|
|
import android.app.Dialog;
|
|
import android.app.Dialog;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.NonNull;
|
|
|
|
+import android.view.ActionMode;
|
|
|
|
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.datamodel.OCFile;
|
|
import com.owncloud.android.datamodel.OCFile;
|
|
@@ -47,6 +48,21 @@ implements ConfirmationDialogFragmentListener {
|
|
|
|
|
|
private static final String ARG_TARGET_FILES = "TARGET_FILES";
|
|
private static final String ARG_TARGET_FILES = "TARGET_FILES";
|
|
|
|
|
|
|
|
+ private ActionMode actionMode;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Public factory method to create new RemoveFilesDialogFragment instances.
|
|
|
|
+ *
|
|
|
|
+ * @param files Files to remove.
|
|
|
|
+ * @param actionMode ActionMode to finish on confirmation
|
|
|
|
+ * @return Dialog ready to show.
|
|
|
|
+ */
|
|
|
|
+ public static RemoveFilesDialogFragment newInstance(ArrayList<OCFile> files, ActionMode actionMode) {
|
|
|
|
+ RemoveFilesDialogFragment dialogFragment = newInstance(files);
|
|
|
|
+ dialogFragment.setActionMode(actionMode);
|
|
|
|
+ return dialogFragment;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Public factory method to create new RemoveFilesDialogFragment instances.
|
|
* Public factory method to create new RemoveFilesDialogFragment instances.
|
|
*
|
|
*
|
|
@@ -137,12 +153,20 @@ implements ConfirmationDialogFragmentListener {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Performs the removal of the target file, both locally and in the server.
|
|
|
|
|
|
+ * Performs the removal of the target file, both locally and in the server and
|
|
|
|
+ * finishes the supplied ActionMode if one was given.
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void onConfirmation(String callerTag) {
|
|
public void onConfirmation(String callerTag) {
|
|
ComponentsGetter cg = (ComponentsGetter) getActivity();
|
|
ComponentsGetter cg = (ComponentsGetter) getActivity();
|
|
cg.getFileOperationsHelper().removeFiles(mTargetFiles, false, false);
|
|
cg.getFileOperationsHelper().removeFiles(mTargetFiles, false, false);
|
|
|
|
+
|
|
|
|
+ // This is used when finishing an actionMode,
|
|
|
|
+ // for example if we want to exit the selection mode
|
|
|
|
+ // after deleting the target files.
|
|
|
|
+ if (actionMode != null) {
|
|
|
|
+ actionMode.finish();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -158,4 +182,8 @@ implements ConfirmationDialogFragmentListener {
|
|
public void onNeutral(String callerTag) {
|
|
public void onNeutral(String callerTag) {
|
|
// nothing to do here
|
|
// nothing to do here
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void setActionMode(ActionMode actionMode) {
|
|
|
|
+ this.actionMode = actionMode;
|
|
|
|
+ }
|
|
}
|
|
}
|