OSDN Git Service

Bring back 'share 360 photosphere' to filmstrip
authorMangesh Ghiware <mghiware@google.com>
Fri, 23 Aug 2013 20:28:21 +0000 (13:28 -0700)
committerMangesh Ghiware <mghiware@google.com>
Wed, 4 Sep 2013 23:32:42 +0000 (16:32 -0700)
Bug: 10367406
Change-Id: Icb07e9e890a72bec6ed3b4c5a7e33400be3446f8

res/menu/operations.xml
src/com/android/camera/CameraActivity.java
src/com/android/camera/ui/FilmStripView.java

index ad2c901..0348e87 100644 (file)
      limitations under the License.
 -->
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:id="@+id/action_share"
+    <!-- Ideally, showAsAction for share_panorama and share should be reversed.
+         But, if share_panorama is set to never, it doesn't seem to get promoted
+         to the action bar and stays on the overflow menu. -->
+    <item android:id="@+id/action_share_panorama"
             android:icon="@drawable/ic_menu_share_holo_light"
-            android:title="@string/share"
+            android:title="@string/share_panorama"
             android:visible="false"
             android:actionProviderClass="android.widget.ShareActionProvider"
             android:showAsAction="ifRoom" />
-    <item android:id="@+id/action_share_panorama"
+    <item android:id="@+id/action_share"
             android:icon="@drawable/ic_menu_share_holo_light"
-            android:title="@string/share_panorama"
+            android:title="@string/share"
             android:visible="false"
             android:actionProviderClass="android.widget.ShareActionProvider"
             android:showAsAction="never" />
index 47a964f..3521de2 100644 (file)
@@ -230,38 +230,37 @@ public class CameraActivity extends Activity
                 }
 
                 @Override
-                public void onCurrentDataChanged(int dataID, boolean current) {
-                    if (!current) {
-                        hidePanoStitchingProgress();
-                    } else {
-                        LocalData currentData = mDataAdapter.getLocalData(dataID);
-                        if (currentData == null) {
-                            Log.w(TAG, "Current data ID not found.");
-                            hidePanoStitchingProgress();
-                            return;
-                        }
-
-                        if (currentData.getLocalDataType() ==
-                                LocalData.LOCAL_CAMERA_PREVIEW) {
-                            // Don't show the action bar in Camera preview.
-                            mActionBar.hide();
-                        } else {
-                            updateActionBarMenu(dataID);
-                        }
-
-                        Uri contentUri = currentData.getContentUri();
-                        if (contentUri == null) {
-                            hidePanoStitchingProgress();
-                            return;
-                        }
-                        int panoStitchingProgress = mPanoramaManager.getTaskProgress(contentUri);
-                        if (panoStitchingProgress < 0) {
-                            hidePanoStitchingProgress();
-                            return;
+                public void onCurrentDataChanged(final int dataID, final boolean current) {
+                    runOnUiThread(new Runnable() {
+                        @Override
+                        public void run() {
+                            if (!current) {
+                                hidePanoStitchingProgress();
+                            } else {
+                                LocalData currentData = mDataAdapter.getLocalData(dataID);
+                                if (currentData == null) {
+                                    Log.w(TAG, "Current data ID not found.");
+                                    hidePanoStitchingProgress();
+                                    return;
+                                }
+                                updateActionBarMenu(dataID);
+
+                                Uri contentUri = currentData.getContentUri();
+                                if (contentUri == null) {
+                                    hidePanoStitchingProgress();
+                                    return;
+                                }
+                                int panoStitchingProgress = mPanoramaManager.getTaskProgress(
+                                    contentUri);
+                                if (panoStitchingProgress < 0) {
+                                    hidePanoStitchingProgress();
+                                    return;
+                                }
+                                showPanoStitchingProgress();
+                                updateStitchingProgress(panoStitchingProgress);
+                            }
                         }
-                        showPanoStitchingProgress();
-                        updateStitchingProgress(panoStitchingProgress);
-                    }
+                    });
                 }
 
                 @Override
@@ -369,14 +368,35 @@ public class CameraActivity extends Activity
         setMenuItemVisible(mActionBarMenu, R.id.action_trim,
                 (supported & SUPPORT_TRIM) != 0);
 
-        if ((supported & SUPPORT_SHARE) != 0) {
-            setMenuItemVisible(mActionBarMenu, R.id.action_share, true);
-            setStandardShareIntent(currentData.getContentUri(), currentData.getMimeType());
-        }
-        if ((supported & SUPPORT_SHARE_PANORAMA360) != 0) {
-            setMenuItemVisible(mActionBarMenu, R.id.action_share_panorama, true);
+        boolean standardShare = (supported & SUPPORT_SHARE) != 0;
+        boolean panoramaShare = (supported & SUPPORT_SHARE_PANORAMA360) != 0;
+        setMenuItemVisible(mActionBarMenu, R.id.action_share, standardShare);
+        setMenuItemVisible(mActionBarMenu, R.id.action_share_panorama, panoramaShare);
+
+        if (panoramaShare) {
+            // For 360 PhotoSphere, relegate standard share to the overflow menu
+            MenuItem item = mActionBarMenu.findItem(R.id.action_share);
+            if (item != null) {
+                item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+                item.setTitle(getResources().getString(R.string.share_as_photo));
+            }
+            // And, promote "share as panorama" to action bar
+            item = mActionBarMenu.findItem(R.id.action_share_panorama);
+            if (item != null) {
+                item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+            }
             setPanoramaShareIntent(currentData.getContentUri());
         }
+        if (standardShare) {
+            if (!panoramaShare) {
+                MenuItem item = mActionBarMenu.findItem(R.id.action_share);
+                if (item != null) {
+                    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+                    item.setTitle(getResources().getString(R.string.share));
+                }
+            }
+            setStandardShareIntent(currentData.getContentUri(), currentData.getMimeType());
+        }
 
         boolean itemHasLocation = currentData.getLatLong() != null;
         setMenuItemVisible(mActionBarMenu, R.id.action_show_on_map,
@@ -496,6 +516,7 @@ public class CameraActivity extends Activity
         // Configure the standard share action provider
         MenuItem item = menu.findItem(R.id.action_share);
         mStandardShareActionProvider = (ShareActionProvider) item.getActionProvider();
+        mStandardShareActionProvider.setShareHistoryFileName("standard_share_history.xml");
         if (mStandardShareIntent != null) {
             mStandardShareActionProvider.setShareIntent(mStandardShareIntent);
         }
@@ -503,6 +524,7 @@ public class CameraActivity extends Activity
         // Configure the panorama share action provider
         item = menu.findItem(R.id.action_share_panorama);
         mPanoramaShareActionProvider = (ShareActionProvider) item.getActionProvider();
+        mPanoramaShareActionProvider.setShareHistoryFileName("panorama_share_history.xml");
         if (mPanoramaShareIntent != null) {
             mPanoramaShareActionProvider.setShareIntent(mPanoramaShareIntent);
         }
index 1805177..fd532fb 100644 (file)
@@ -971,6 +971,9 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
                     boolean isPanorama360) {
                 // Make sure the returned data is for the current image.
                 if (requestId == getCurrentId()) {
+                    if (mListener != null) {
+                        mListener.onCurrentDataChanged(requestId, true);
+                    }
                     mBottomControls.setViewPhotoSphereButtonVisibility(isPanorama);
                     mBottomControls.setTinyPlanetButtonVisibility(isPanorama360);
                 }