OSDN Git Service

Bring back Share to filmstrip
authorMangesh Ghiware <mghiware@google.com>
Fri, 23 Aug 2013 20:28:21 +0000 (13:28 -0700)
committerMangesh Ghiware <mghiware@google.com>
Mon, 26 Aug 2013 23:49:45 +0000 (16:49 -0700)
Bug: 10367406
Change-Id: I37834442e3af209fb00b98e6da524263ac8c70f0

res/menu/operations.xml
src/com/android/camera/CameraActivity.java
src/com/android/camera/data/LocalData.java
src/com/android/camera/data/LocalMediaData.java

index 3f0f5a1..ad2c901 100644 (file)
             android:title="@string/share"
             android:visible="false"
             android:actionProviderClass="android.widget.ShareActionProvider"
-            android:showAsAction="ifRoom">
-    </item>
+            android:showAsAction="ifRoom" />
+    <item android:id="@+id/action_share_panorama"
+            android:icon="@drawable/ic_menu_share_holo_light"
+            android:title="@string/share_panorama"
+            android:visible="false"
+            android:actionProviderClass="android.widget.ShareActionProvider"
+            android:showAsAction="never" />
     <item android:id="@+id/action_delete"
             android:icon="@drawable/ic_menu_trash_holo_light"
             android:title="@string/delete"
index 6f85306..0603dd3 100644 (file)
@@ -49,6 +49,7 @@ import android.view.WindowManager;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.ProgressBar;
+import android.widget.ShareActionProvider;
 
 import com.android.camera.data.CameraDataAdapter;
 import com.android.camera.data.CameraPreviewData;
@@ -96,7 +97,9 @@ public class CameraActivity extends Activity
     private static final int SUPPORT_SETAS = 1 << 4;
     private static final int SUPPORT_EDIT = 1 << 5;
     private static final int SUPPORT_TRIM = 1 << 6;
-    private static final int SUPPORT_SHOW_ON_MAP = 1 << 7;
+    private static final int SUPPORT_SHARE = 1 << 7;
+    private static final int SUPPORT_SHARE_PANORAMA360 = 1 << 8;
+    private static final int SUPPORT_SHOW_ON_MAP = 1 << 9;
     private static final int SUPPORT_ALL = 0xffffffff;
 
     /** This data adapter is used by FilmStripView. */
@@ -131,6 +134,11 @@ public class CameraActivity extends Activity
     private Menu mActionBarMenu;
     private ViewGroup mUndoDeletionBar;
 
+    private ShareActionProvider mStandardShareActionProvider;
+    private Intent mStandardShareIntent;
+    private ShareActionProvider mPanoramaShareActionProvider;
+    private Intent mPanoramaShareIntent;
+
     public void gotoGallery() {
         mFilmStripView.getController().goToNextItem();
     }
@@ -268,6 +276,28 @@ public class CameraActivity extends Activity
         mBottomProgress.setProgress(progress);
     }
 
+    private void setStandardShareIntent(Uri contentUri, String mimeType) {
+        if (mStandardShareIntent == null) {
+            mStandardShareIntent = new Intent(Intent.ACTION_SEND);
+        }
+        mStandardShareIntent.setType(mimeType);
+        mStandardShareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
+        if (mStandardShareActionProvider != null) {
+            mStandardShareActionProvider.setShareIntent(mStandardShareIntent);
+        }
+    }
+
+    private void setPanoramaShareIntent(Uri contentUri) {
+        if (mPanoramaShareIntent == null) {
+            mPanoramaShareIntent = new Intent(Intent.ACTION_SEND);
+        }
+        mPanoramaShareIntent.setType("application/vnd.google.panorama360+jpg");
+        mPanoramaShareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
+        if (mPanoramaShareActionProvider != null) {
+            mPanoramaShareActionProvider.setShareIntent(mPanoramaShareIntent);
+        }
+    }
+
     /**
      * According to the data type, make the menu items for supported operations
      * visible.
@@ -286,14 +316,21 @@ public class CameraActivity extends Activity
             case LocalData.LOCAL_IMAGE:
                 supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO
                         | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT
-                        | SUPPORT_SHOW_ON_MAP;
+                        | SUPPORT_SHARE | SUPPORT_SHOW_ON_MAP;
                 break;
             case LocalData.LOCAL_VIDEO:
-                supported |= SUPPORT_DELETE | SUPPORT_INFO | SUPPORT_TRIM;
+                supported |= SUPPORT_DELETE | SUPPORT_INFO | SUPPORT_TRIM
+                        | SUPPORT_SHARE;
                 break;
             case LocalData.LOCAL_PHOTO_SPHERE:
                 supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO
                         | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT
+                        | SUPPORT_SHARE | SUPPORT_SHOW_ON_MAP;
+                break;
+            case LocalData.LOCAL_360_PHOTO_SPHERE:
+                supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO
+                        | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT
+                        | SUPPORT_SHARE | SUPPORT_SHARE_PANORAMA360
                         | SUPPORT_SHOW_ON_MAP;
                 break;
             default:
@@ -306,16 +343,25 @@ public class CameraActivity extends Activity
                 (supported & SUPPORT_ROTATE) != 0);
         setMenuItemVisible(mActionBarMenu, R.id.action_rotate_cw,
                 (supported & SUPPORT_ROTATE) != 0);
+        setMenuItemVisible(mActionBarMenu, R.id.action_details,
+                (supported & SUPPORT_INFO) != 0);
         setMenuItemVisible(mActionBarMenu, R.id.action_crop,
                 (supported & SUPPORT_CROP) != 0);
-        setMenuItemVisible(mActionBarMenu, R.id.action_trim,
-                (supported & SUPPORT_TRIM) != 0);
         setMenuItemVisible(mActionBarMenu, R.id.action_setas,
                 (supported & SUPPORT_SETAS) != 0);
         setMenuItemVisible(mActionBarMenu, R.id.action_edit,
                 (supported & SUPPORT_EDIT) != 0);
-        setMenuItemVisible(mActionBarMenu, R.id.action_details,
-                (supported & SUPPORT_INFO) != 0);
+        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);
+            setPanoramaShareIntent(currentData.getContentUri());
+        }
 
         boolean itemHasLocation = currentData.getLatLong() != null;
         setMenuItemVisible(mActionBarMenu, R.id.action_show_on_map,
@@ -431,6 +477,21 @@ public class CameraActivity extends Activity
         MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.menu.operations, menu);
         mActionBarMenu = menu;
+
+        // Configure the standard share action provider
+        MenuItem item = menu.findItem(R.id.action_share);
+        mStandardShareActionProvider = (ShareActionProvider) item.getActionProvider();
+        if (mStandardShareIntent != null) {
+            mStandardShareActionProvider.setShareIntent(mStandardShareIntent);
+        }
+
+        // Configure the panorama share action provider
+        item = menu.findItem(R.id.action_share_panorama);
+        mPanoramaShareActionProvider = (ShareActionProvider) item.getActionProvider();
+        if (mPanoramaShareIntent != null) {
+            mPanoramaShareActionProvider.setShareIntent(mPanoramaShareIntent);
+        }
+
         return super.onCreateOptionsMenu(menu);
     }
 
index 8256712..11d36da 100644 (file)
@@ -38,16 +38,30 @@ public interface LocalData extends FilmStripView.ImageData {
     public static final int ACTION_DELETE = (1 << 1);
 
     // Local data types. Returned by getLocalDataType().
-    // Camera preview.
-    public static final int LOCAL_CAMERA_PREVIEW = 1;
-    // A data for showing an arbitrary view.
-    public static final int LOCAL_VIEW           = 2;
-    // A still image.
-    public static final int LOCAL_IMAGE          = 3;
-    // A video.
-    public static final int LOCAL_VIDEO          = 4;
-    // A still image but with valid PhotoSphere metadata.
-    public static final int LOCAL_PHOTO_SPHERE   = 5;
+    /**
+     * Constant for denoting a camera preview.
+     */
+    public static final int LOCAL_CAMERA_PREVIEW   = 1;
+    /**
+     * Constant for denoting an arbitrary view.
+     */
+    public static final int LOCAL_VIEW             = 2;
+    /**
+     * Constant for denoting a still image.
+     */
+    public static final int LOCAL_IMAGE            = 3;
+    /**
+     * Constant for denoting a video.
+     */
+    public static final int LOCAL_VIDEO            = 4;
+    /**
+     * Constant for denoting a still image, with valid PhotoSphere metadata.
+     */
+    public static final int LOCAL_PHOTO_SPHERE     = 5;
+    /**
+     * Constant for denoting a still image, with valid 360 PhotoSphere metadata.
+     */
+    public static final int LOCAL_360_PHOTO_SPHERE = 6;
 
     View getView(Context c, int width, int height, Drawable placeHolder);
 
@@ -118,7 +132,7 @@ public interface LocalData extends FilmStripView.ImageData {
      *
      * @return The local data type. Could be one of the following:
      * {@code LOCAL_CAMERA_PREVIEW}, {@code LOCAL_VIEW}, {@code LOCAL_IMAGE},
-     * {@code LOCAL_VIDEO}, and {@code LOCAL_PHOTO_SPHERE},
+     * {@code LOCAL_VIDEO}, {@code LOCAL_PHOTO_SPHERE}, and {@code LOCAL_360_PHOTO_SPHERE}
      */
     int getLocalDataType();
 
index 1f87b50..88f127f 100644 (file)
@@ -380,8 +380,12 @@ public abstract class LocalMediaData implements LocalData {
 
         @Override
         public int getLocalDataType() {
-            if (mPanoramaMetadata != null && mPanoramaMetadata.mUsePanoramaViewer) {
-                return LOCAL_PHOTO_SPHERE;
+            if (mPanoramaMetadata != null) {
+                if (mPanoramaMetadata.mIsPanorama360) {
+                    return LOCAL_360_PHOTO_SPHERE;
+                } else if (mPanoramaMetadata.mUsePanoramaViewer) {
+                    return LOCAL_PHOTO_SPHERE;
+                }
             }
             return LOCAL_IMAGE;
         }