summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Chen <raychen@google.com>2012-05-03 13:10:51 +0800
committerRay Chen <raychen@google.com>2012-05-22 11:06:48 +0800
commit7f9061790e1b67b6c674314ac41a399c550f8b88 (patch)
tree45b654cdcd4a2e3764d6ff5fdf5bbff3d227b443 /src
parent6ca39c75e668eab51645f33117cae5156f64975d (diff)
downloadandroid_packages_apps_Snap-7f9061790e1b67b6c674314ac41a399c550f8b88.tar.gz
android_packages_apps_Snap-7f9061790e1b67b6c674314ac41a399c550f8b88.tar.bz2
android_packages_apps_Snap-7f9061790e1b67b6c674314ac41a399c550f8b88.zip
Fix 6360834 Select All is shown in place of Deselect all option
The CL changes the SelectionManager's toggle method so it changes itself to inverse selection mode when all items are already selected, and onSelectionModeChange will be triggered so the listener can update the selection menu (Select all/Deselect all) and ActionBar. Change-Id: I9aa5507067415e52f6800c254ecb4d68e7395ffa b: 6360834
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java2
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java1
-rw-r--r--src/com/android/gallery3d/ui/ActionModeHandler.java2
-rw-r--r--src/com/android/gallery3d/ui/SelectionManager.java33
4 files changed, 26 insertions, 12 deletions
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index c6e3596ec..8376b2792 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -545,7 +545,7 @@ public class AlbumSetPage extends ActivityState implements
break;
}
case SelectionManager.SELECT_ALL_MODE: {
- mActionModeHandler.setTitle(getSelectedString());
+ mActionModeHandler.updateSupportedOperation();
mRootPane.invalidate();
break;
}
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index ea3badc79..71a6c8eef 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -212,6 +212,7 @@ public class PhotoPage extends ActivityState implements
}
mMediaSet = mActivity.getDataManager().getMediaSet(mSetPathString);
+ mSelectionManager.setSourceMediaSet(mMediaSet);
mCurrentIndex = data.getInt(KEY_INDEX_HINT, 0);
if (mMediaSet == null) {
Log.w(TAG, "failed to restore " + mSetPathString);
diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java
index c5773ed3e..746d41d4b 100644
--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -283,6 +283,8 @@ public class ActionModeHandler implements ActionMode.Callback {
mMenuTask.cancel();
}
+ updateSelectionMenu();
+
// Disable share action until share intent is in good shape
final MenuItem item = mShareActionProvider != null ?
mMenu.findItem(R.id.action_share) : null;
diff --git a/src/com/android/gallery3d/ui/SelectionManager.java b/src/com/android/gallery3d/ui/SelectionManager.java
index 1783b1111..86e92da90 100644
--- a/src/com/android/gallery3d/ui/SelectionManager.java
+++ b/src/com/android/gallery3d/ui/SelectionManager.java
@@ -107,15 +107,21 @@ public class SelectionManager {
return mInverseSelection ^ mClickedSet.contains(itemId);
}
+ private int getTotalCount() {
+ if (mSourceMediaSet == null) return -1;
+
+ if (mTotal < 0) {
+ mTotal = mIsAlbumSet
+ ? mSourceMediaSet.getSubMediaSetCount()
+ : mSourceMediaSet.getMediaItemCount();
+ }
+ return mTotal;
+ }
+
public int getSelectedCount() {
int count = mClickedSet.size();
if (mInverseSelection) {
- if (mTotal < 0) {
- mTotal = mIsAlbumSet
- ? mSourceMediaSet.getSubMediaSetCount()
- : mSourceMediaSet.getMediaItemCount();
- }
- count = mTotal - count;
+ count = getTotalCount() - count;
}
return count;
}
@@ -128,8 +134,14 @@ public class SelectionManager {
mClickedSet.add(path);
}
+ // Convert to inverse selection mode if everything is selected.
+ int count = getSelectedCount();
+ if (count == getTotalCount()) {
+ selectAll();
+ }
+
if (mListener != null) mListener.onSelectionChange(path, isItemSelected(path));
- if (getSelectedCount() == 0 && mAutoLeave) {
+ if (count == 0 && mAutoLeave) {
leaveSelectionMode();
}
}
@@ -159,8 +171,8 @@ public class SelectionManager {
ArrayList<Path> selected = new ArrayList<Path>();
if (mIsAlbumSet) {
if (mInverseSelection) {
- int max = mSourceMediaSet.getSubMediaSetCount();
- for (int i = 0; i < max; i++) {
+ int total = getTotalCount();
+ for (int i = 0; i < total; i++) {
MediaSet set = mSourceMediaSet.getSubMediaSet(i);
Path id = set.getPath();
if (!mClickedSet.contains(id)) {
@@ -182,8 +194,7 @@ public class SelectionManager {
}
} else {
if (mInverseSelection) {
-
- int total = mSourceMediaSet.getMediaItemCount();
+ int total = getTotalCount();
int index = 0;
while (index < total) {
int count = Math.min(total - index, MediaSet.MEDIAITEM_BATCH_FETCH_COUNT);