OSDN Git Service

Fix behavior of up button in Camera app
authorBobby Georgescu <georgescu@google.com>
Wed, 26 Sep 2012 21:22:57 +0000 (14:22 -0700)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Wed, 26 Sep 2012 21:47:01 +0000 (14:47 -0700)
Bug: 7233448
- Up button now goes to gallery root when appropriate.

Change-Id: Ib474335b2ac4139e7c5a213bda3efa481b24f224

src/com/android/gallery3d/app/AlbumPage.java
src/com/android/gallery3d/app/PhotoPage.java
src/com/android/gallery3d/util/GalleryUtils.java

index 30682a1..a19798f 100644 (file)
@@ -214,7 +214,9 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
     }
 
     private void onUpPressed() {
-        if (mActivity.getStateManager().getStateCount() > 1) {
+        if (mInCameraApp) {
+            GalleryUtils.startGalleryActivity(mActivity);
+        } else if (mActivity.getStateManager().getStateCount() > 1) {
             super.onBackPressed();
         } else if (mParentMediaSetString != null) {
             Bundle data = new Bundle(getData());
index 29211ff..760c96d 100644 (file)
@@ -659,7 +659,8 @@ public class PhotoPage extends ActivityState implements
     }
 
     private void onUpPressed() {
-        if (mStartInFilmstrip && !mPhotoView.getFilmMode()) {
+        if ((mStartInFilmstrip || mAppBridge != null)
+                && !mPhotoView.getFilmMode()) {
             mPhotoView.setFilmMode(true);
             return;
         }
@@ -681,12 +682,7 @@ public class PhotoPage extends ActivityState implements
                             DataManager.INCLUDE_ALL));
             mActivity.getStateManager().switchState(this, AlbumPage.class, data);
         } else {
-            // Start the real gallery activity to view the camera roll.
-            Uri uri = Uri.parse("content://media/external/file?bucketId="
-                    + MediaSetUtils.CAMERA_BUCKET_ID);
-            Intent intent = new Intent(Intent.ACTION_VIEW);
-            intent.setDataAndType(uri, ContentResolver.CURSOR_DIR_BASE_TYPE + "/image");
-            ((Activity) mActivity).startActivity(intent);
+            GalleryUtils.startGalleryActivity(mActivity);
         }
     }
 
index f04a5cc..6639c55 100644 (file)
@@ -37,6 +37,7 @@ import android.util.Log;
 import android.view.WindowManager;
 
 import com.android.gallery3d.R;
+import com.android.gallery3d.app.Gallery;
 import com.android.gallery3d.app.PackagesMonitor;
 import com.android.gallery3d.common.ApiHelper;
 import com.android.gallery3d.data.DataManager;
@@ -240,6 +241,11 @@ public class GalleryUtils {
         context.startActivity(intent);
     }
 
+    public static void startGalleryActivity(Context context) {
+        Intent intent = new Intent(context, Gallery.class);
+        context.startActivity(intent);
+    }
+
     public static boolean isValidLocation(double latitude, double longitude) {
         // TODO: change || to && after we fix the default location issue
         return (latitude != MediaItem.INVALID_LATLNG || longitude != MediaItem.INVALID_LATLNG);