OSDN Git Service

Show undo option for 3 seconds after the last picture is deleted.
authorChih-Chung Chang <chihchung@google.com>
Wed, 27 Jun 2012 05:40:06 +0000 (13:40 +0800)
committerChih-Chung Chang <chihchung@google.com>
Wed, 27 Jun 2012 05:40:06 +0000 (13:40 +0800)
Bug: 6742326
Change-Id: I5008c1984fff0a2affaeabf2a195cfcdc517ebc2

src/com/android/gallery3d/app/PhotoPage.java
src/com/android/gallery3d/data/FilterDeleteSet.java

index 568f590..17f57c2 100644 (file)
@@ -253,7 +253,12 @@ public class PhotoPage extends ActivityState implements
                         MediaItem photo = mModel.getMediaItem(0);
                         if (photo != null) updateCurrentPhoto(photo);
                     } else if (mIsActive) {
-                        mActivity.getStateManager().finishState(PhotoPage.this);
+                        // We only want to finish the PhotoPage if there is no
+                        // deletion that the user can undo.
+                        if (mMediaSet.getNumberOfDeletions() == 0) {
+                            mActivity.getStateManager().finishState(
+                                    PhotoPage.this);
+                        }
                     }
                 }
 
index 97bbc12..dbd85d5 100644 (file)
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 // void addDeletion(Path path, int index);
 // void removeDelection(Path path);
 // void clearDeletion();
+// int getNumberOfDeletions();
 //
 public class FilterDeleteSet extends MediaSet implements ContentListener {
     private static final String TAG = "FilterDeleteSet";
@@ -242,4 +243,10 @@ public class FilterDeleteSet extends MediaSet implements ContentListener {
     public void clearDeletion() {
         sendRequest(REQUEST_CLEAR, null /* unused */ , 0 /* unused */);
     }
+
+    // Returns number of deletions _in effect_ (the number will only gets
+    // updated after a reload()).
+    public int getNumberOfDeletions() {
+        return mCurrent.size();
+    }
 }