Merge "Clear selection after copy and when back is pressed."
diff --git a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
index 9309693..ea7054f 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java
@@ -491,6 +491,10 @@
return;
}
+ if (DirectoryFragment.get(getFragmentManager()).onBackPressed()) {
+ return;
+ }
+
if (!mState.hasLocationChanged()) {
super.onBackPressed();
return;
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
index f57aa4b..2aabc99 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -642,10 +642,7 @@
return true;
case R.id.menu_copy_to_clipboard:
- if (!selection.isEmpty()) {
- copySelectionToClipboard(selection);
- mode.finish();
- }
+ copySelectedToClipboard();
return true;
case R.id.menu_select_all:
@@ -664,6 +661,15 @@
}
}
+ public final boolean onBackPressed() {
+ if (mSelectionManager.hasSelection()) {
+ if (DEBUG) Log.d(TAG, "Clearing selection on back pressed.");
+ mSelectionManager.clearSelection();
+ return true;
+ }
+ return false;
+ }
+
private void cancelThumbnailTask(View view) {
final ImageView iconThumb = (ImageView) view.findViewById(R.id.icon_thumb);
if (iconThumb != null) {
@@ -993,6 +999,7 @@
Selection selection = mSelectionManager.getSelection(new Selection());
if (!selection.isEmpty()) {
copySelectionToClipboard(selection);
+ mSelectionManager.clearSelection();
}
}