From 4f32d514ee7474d867d04bf3934f9e11e9e92783 Mon Sep 17 00:00:00 2001 From: Mangesh Ghiware Date: Sun, 23 Sep 2012 17:19:34 -0700 Subject: [PATCH] Use vendor specific MIME type for sharing LightCycle panoramas Bug: 7150324 Change-Id: I78d426672e9a8fc69f0b9b564438e40eb0230719 --- src/com/android/gallery3d/app/PhotoPage.java | 8 +++++--- src/com/android/gallery3d/data/LocalImage.java | 2 +- src/com/android/gallery3d/data/MediaObject.java | 2 +- src/com/android/gallery3d/data/UriImage.java | 2 +- src/com/android/gallery3d/ui/ActionModeHandler.java | 9 ++++++--- src/com/android/gallery3d/ui/MenuExecutor.java | 18 +++++++++++++----- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 818a90867..ec45cc1be 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -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. diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index a4211b76e..c19649c3e 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -248,7 +248,7 @@ public class LocalImage extends LocalMediaItem { } if (usePanoramaViewer()) { - operation |= SUPPORT_VIEW_PANORAMA; + operation |= SUPPORT_PANORAMA; } return operation; } diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java index 757515c10..917f6953e 100644 --- a/src/com/android/gallery3d/data/MediaObject.java +++ b/src/com/android/gallery3d/data/MediaObject.java @@ -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(): diff --git a/src/com/android/gallery3d/data/UriImage.java b/src/com/android/gallery3d/data/UriImage.java index 6e33a95b3..737e85f25 100644 --- a/src/com/android/gallery3d/data/UriImage.java +++ b/src/com/android/gallery3d/data/UriImage.java @@ -219,7 +219,7 @@ public class UriImage extends MediaItem { supported |= SUPPORT_FULL_IMAGE; } if (usePanoramaViewer()) { - supported |= SUPPORT_VIEW_PANORAMA; + supported |= SUPPORT_PANORAMA; } return supported; } diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java index 379f79c76..2adb05cf0 100644 --- a/src/com/android/gallery3d/ui/ActionModeHandler.java +++ b/src/com/android/gallery3d/ui/ActionModeHandler.java @@ -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 uris = new ArrayList(); 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); diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java index 38d2cc4c8..bd386f8ab 100644 --- a/src/com/android/gallery3d/ui/MenuExecutor.java +++ b/src/com/android/gallery3d/ui/MenuExecutor.java @@ -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; } } -- 2.11.0