OSDN Git Service

Use vendor specific MIME type for sharing LightCycle panoramas
authorMangesh Ghiware <mghiware@google.com>
Mon, 24 Sep 2012 00:19:34 +0000 (17:19 -0700)
committerMangesh Ghiware <mghiware@google.com>
Mon, 24 Sep 2012 05:42:47 +0000 (22:42 -0700)
Bug: 7150324
Change-Id: I78d426672e9a8fc69f0b9b564438e40eb0230719

src/com/android/gallery3d/app/PhotoPage.java
src/com/android/gallery3d/data/LocalImage.java
src/com/android/gallery3d/data/MediaObject.java
src/com/android/gallery3d/data/UriImage.java
src/com/android/gallery3d/ui/ActionModeHandler.java
src/com/android/gallery3d/ui/MenuExecutor.java

index 818a908..ec45cc1 100644 (file)
@@ -429,7 +429,7 @@ public class PhotoPage extends ActivityState implements
                 return mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE;
             case R.id.photopage_bottom_control_panorama:
                 return (mCurrentPhoto.getSupportedOperations()
-                        & MediaItem.SUPPORT_VIEW_PANORAMA) != 0;
+                        & MediaItem.SUPPORT_PANORAMA) != 0;
             default:
                 return false;
         }
@@ -458,8 +458,10 @@ public class PhotoPage extends ActivityState implements
     private Intent createShareIntent(Path path) {
         DataManager manager = mActivity.getDataManager();
         int type = manager.getMediaType(path);
+        int support = manager.getSupportedOperations(path);
+        boolean isPanorama = (support & MediaObject.SUPPORT_PANORAMA) != 0;
         Intent intent = new Intent(Intent.ACTION_SEND);
-        intent.setType(MenuExecutor.getMimeType(type));
+        intent.setType(MenuExecutor.getMimeType(type, isPanorama));
         Uri uri = manager.getContentUri(path);
         intent.putExtra(Intent.EXTRA_STREAM, uri);
         return intent;
@@ -870,7 +872,7 @@ public class PhotoPage extends ActivityState implements
         boolean playVideo = (mSecureAlbum == null) &&
                 ((item.getSupportedOperations() & MediaItem.SUPPORT_PLAY) != 0);
         boolean viewPanorama = (mSecureAlbum == null) &&
-                (item.getSupportedOperations() & MediaItem.SUPPORT_VIEW_PANORAMA) != 0;
+                (item.getSupportedOperations() & MediaItem.SUPPORT_PANORAMA) != 0;
 
         if (playVideo) {
             // determine if the point is at center (1/6) of the photo view.
index a4211b7..c19649c 100644 (file)
@@ -248,7 +248,7 @@ public class LocalImage extends LocalMediaItem {
         }
 
         if (usePanoramaViewer()) {
-            operation |= SUPPORT_VIEW_PANORAMA;
+            operation |= SUPPORT_PANORAMA;
         }
         return operation;
     }
index 757515c..917f695 100644 (file)
@@ -37,7 +37,7 @@ public abstract class MediaObject {
     public static final int SUPPORT_INFO = 1 << 10;
     public static final int SUPPORT_IMPORT = 1 << 11;
     public static final int SUPPORT_TRIM = 1 << 12;
-    public static final int SUPPORT_VIEW_PANORAMA = 1 << 13;
+    public static final int SUPPORT_PANORAMA = 1 << 13;
     public static final int SUPPORT_ALL = 0xffffffff;
 
     // These are the bits returned from getMediaType():
index 6e33a95..737e85f 100644 (file)
@@ -219,7 +219,7 @@ public class UriImage extends MediaItem {
             supported |= SUPPORT_FULL_IMAGE;
         }
         if (usePanoramaViewer()) {
-            supported |= SUPPORT_VIEW_PANORAMA;
+            supported |= SUPPORT_PANORAMA;
         }
         return supported;
     }
index 379f79c..2adb05c 100644 (file)
@@ -219,7 +219,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
 
         switch (unexpandedPaths.size()) {
             case 1:
-                final String mimeType = MenuExecutor.getMimeType(type);
+                final String mimeType = MenuExecutor.getMimeType(type, false);
                 if (!GalleryUtils.isEditorAvailable(mActivity, mimeType)) {
                     operation &= ~MediaObject.SUPPORT_EDIT;
                 }
@@ -249,6 +249,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
         final ArrayList<Uri> uris = new ArrayList<Uri>();
         DataManager manager = mActivity.getDataManager();
         int type = 0;
+        boolean isPanorama = true;
         final Intent intent = new Intent();
         for (Path path : expandedPaths) {
             if (jc.isCancelled()) return null;
@@ -258,11 +259,14 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
             if ((support & MediaObject.SUPPORT_SHARE) != 0) {
                 uris.add(manager.getContentUri(path));
             }
+            if ((support & MediaObject.SUPPORT_PANORAMA) == 0) {
+                isPanorama = false;
+            }
         }
 
         final int size = uris.size();
         if (size > 0) {
-            final String mimeType = MenuExecutor.getMimeType(type);
+            final String mimeType = MenuExecutor.getMimeType(type, isPanorama);
             if (size > 1) {
                 intent.setAction(Intent.ACTION_SEND_MULTIPLE).setType(mimeType);
                 intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
@@ -270,7 +274,6 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
                 intent.setAction(Intent.ACTION_SEND).setType(mimeType);
                 intent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
             }
-            intent.setType(mimeType);
             setNfcBeamPushUris(uris.toArray(new Uri[uris.size()]));
         } else {
             setNfcBeamPushUris(null);
index 38d2cc4..bd386f8 100644 (file)
@@ -49,6 +49,11 @@ public class MenuExecutor {
     @SuppressWarnings("unused")
     private static final String TAG = "MenuExecutor";
 
+    private static final String MIME_TYPE_IMAGE = "image/*";
+    private static final String MIME_TYPE_VIDEO = "video/*";
+    private static final String MIME_TYPE_PANORAMA = "application/vnd.google.panorama+jpg";
+    private static final String MIME_TYPE_ALL = "*/*";
+
     private static final int MSG_TASK_COMPLETE = 1;
     private static final int MSG_TASK_UPDATE = 2;
     private static final int MSG_TASK_START = 3;
@@ -197,7 +202,9 @@ public class MenuExecutor {
     private Intent getIntentBySingleSelectedPath(String action) {
         DataManager manager = mActivity.getDataManager();
         Path path = getSingleSelectedPath();
-        String mimeType = getMimeType(manager.getMediaType(path));
+        int support = manager.getSupportedOperations(path);
+        boolean isPanorama = (support & MediaObject.SUPPORT_PANORAMA) != 0;
+        String mimeType = getMimeType(manager.getMediaType(path), isPanorama);
         return new Intent(action).setDataAndType(manager.getContentUri(path), mimeType);
     }
 
@@ -325,13 +332,14 @@ public class MenuExecutor {
         mWaitOnStop = waitOnStop;
     }
 
-    public static String getMimeType(int type) {
+    public static String getMimeType(int type, boolean isPanorama) {
+        if (isPanorama) return MIME_TYPE_PANORAMA;
         switch (type) {
             case MediaObject.MEDIA_TYPE_IMAGE :
-                return "image/*";
+                return MIME_TYPE_IMAGE;
             case MediaObject.MEDIA_TYPE_VIDEO :
-                return "video/*";
-            default: return "*/*";
+                return MIME_TYPE_VIDEO;
+            default: return MIME_TYPE_ALL;
         }
     }