summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steve McKay <smckay@google.com> 2016-03-08 23:44:00 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-03-08 23:44:01 +0000
commit67daccc11b7a7c80e7f37fba219dd154252d59e4 (patch)
tree391d531fc4965e780383ff5462fd640f64521ebe
parent779c4d38c465673fdd8d5d86a96f2d2a727b9893 (diff)
parentda4b8aa3f18b0462a69883544a4453924e3feb3e (diff)
Merge "Don't exit selection after sharing and copying..." into nyc-dev
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
index 19679231c130..8d4472dc9450 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -586,18 +586,17 @@ public class DirectoryFragment extends Fragment
case R.id.menu_share:
shareDocuments(selection);
- mode.finish();
return true;
case R.id.menu_delete:
- // Exit selection mode first, so we avoid deselecting deleted documents.
- mode.finish();
- deleteDocuments(selection);
+ // Pass mode along to the delete function so it can
+ // end action mode when documents are deleted.
+ // It won't end action mode if user cancels the delete.
+ deleteDocuments(selection, mode);
return true;
case R.id.menu_copy_to:
transferDocuments(selection, FileOperationService.OPERATION_COPY);
- mode.finish();
return true;
case R.id.menu_move_to:
@@ -615,8 +614,10 @@ public class DirectoryFragment extends Fragment
return true;
case R.id.menu_rename:
- renameDocuments(selection);
+ // Exit selection mode first, so we avoid deselecting deleted
+ // (renamed) documents.
mode.finish();
+ renameDocuments(selection);
return true;
default:
@@ -700,7 +701,7 @@ public class DirectoryFragment extends Fragment
}.execute(selected);
}
- private void deleteDocuments(final Selection selected) {
+ private void deleteDocuments(final Selection selected, final ActionMode mode) {
assert(!selected.isEmpty());
final DocumentInfo srcParent = getDisplayState().stack.peek();
@@ -732,7 +733,15 @@ public class DirectoryFragment extends Fragment
android.R.string.yes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- // Hide the files in the UI.
+ // Finish selection mode first which clears selection so we
+ // don't end up trying to deselect deleted documents.
+ // This is done here, rather in the onActionItemClicked
+ // so we can avoid de-selecting items in the case where
+ // the user cancels the delete.
+ mode.finish();
+ // Hide the files in the UI...since the operation
+ // might be queued up on FileOperationService.
+ // We're walking a line here.
mAdapter.hide(selected.getAll());
FileOperations.delete(
getActivity(), docs, srcParent, getDisplayState().stack);