Merge "Fix display of spinner and SQL exception for view intent" into gb-ub-photos-arches
diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java
index dadb32c..6ca4bab 100644
--- a/src/com/android/gallery3d/app/Gallery.java
+++ b/src/com/android/gallery3d/app/Gallery.java
@@ -212,26 +212,6 @@
                     }
                 }
 
-                // Displays the filename as title, reading the filename from the interface:
-                // {@link android.provider.OpenableColumns#DISPLAY_NAME}.
-                AsyncQueryHandler queryHandler = new AsyncQueryHandler(getContentResolver()) {
-                    @Override
-                    protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
-                        try {
-                            if ((cursor != null) && cursor.moveToFirst()) {
-                                String displayName = cursor.getString(0);
-
-                                // Just show empty title if other apps don't set DISPLAY_NAME
-                                setTitle((displayName == null) ? "" : displayName);
-                            }
-                        } finally {
-                            Utils.closeSilently(cursor);
-                        }
-                    }
-                };
-                queryHandler.startQuery(0, null, uri, new String[] {OpenableColumns.DISPLAY_NAME},
-                        null, null, null);
-
                 getStateManager().startState(PhotoPage.class, data);
             }
         }
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 2a088b1..a219f51 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -149,6 +149,7 @@
     private MediaItem mCurrentPhoto = null;
     private MenuExecutor mMenuExecutor;
     private boolean mIsActive;
+    private boolean mShowSpinner;
     private String mSetPathString;
     // This is the original mSetPathString before adding the camera preview item.
     private String mOriginalSetPathString;
@@ -339,6 +340,7 @@
                         MSG_ALBUMPAGE_NONE) == MSG_ALBUMPAGE_STARTED;
         mCurrentIndex = data.getInt(KEY_INDEX_HINT, 0);
         if (mSetPathString != null) {
+            mShowSpinner = true;
             mAppBridge = (AppBridge) data.getParcelable(KEY_APP_BRIDGE);
             if (mAppBridge != null) {
                 mShowBars = false;
@@ -360,6 +362,7 @@
                 if (SecureSource.isSecurePath(mSetPathString)) {
                     mSecureAlbum = (SecureAlbum) mActivity.getDataManager()
                             .getMediaSet(mSetPathString);
+                    mShowSpinner = false;
                 }
                 if (data.getBoolean(KEY_SHOW_WHEN_LOCKED, false)) {
                     // Set the flag to be on top of the lock screen.
@@ -483,6 +486,7 @@
             mModel = new SinglePhotoDataAdapter(mActivity, mPhotoView, mediaItem);
             mPhotoView.setModel(mModel);
             updateCurrentPhoto(mediaItem);
+            mShowSpinner = false;
         }
 
         mPhotoView.setFilmMode(mStartInFilmstrip && mMediaSet.getMediaItemCount() > 1);
@@ -1186,7 +1190,7 @@
         mPhotoView.pause();
         mHandler.removeMessages(MSG_HIDE_BARS);
         mActionBar.removeOnMenuVisibilityListener(mMenuVisibilityListener);
-        if (mSecureAlbum == null) {
+        if (mShowSpinner) {
             mActionBar.disableAlbumModeMenu(true);
         }
         onCommitDeleteImage();
@@ -1271,7 +1275,7 @@
         mActionBar.setDisplayOptions(
                 ((mSecureAlbum == null) && (mSetPathString != null)), false);
         mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener);
-        if (mSecureAlbum == null) {
+        if (mShowSpinner) {
             mActionBar.enableAlbumModeMenu(
                     GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED, this);
         }