diff options
author | ztenghui <ztenghui@google.com> | 2013-09-17 20:53:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-09-17 20:53:32 +0000 |
commit | 828c9190aafc9b57126f5a4868e5cee922cf9f2c (patch) | |
tree | fd83fc924bd0d149d63829cc3120914a1eff947f | |
parent | 53304d6953ff8f09a51c1128b7a0f3921e45b651 (diff) | |
parent | 05804751ba07c8abcf422f57467d0ed3de95576c (diff) | |
download | android_packages_apps_Snap-828c9190aafc9b57126f5a4868e5cee922cf9f2c.tar.gz android_packages_apps_Snap-828c9190aafc9b57126f5a4868e5cee922cf9f2c.tar.bz2 android_packages_apps_Snap-828c9190aafc9b57126f5a4868e5cee922cf9f2c.zip |
Merge "Use a new Intent to work around issues in framework" into gb-ub-photos-carlsbad
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index fe65c0290..f55d6bc05 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -163,6 +163,9 @@ public class CameraActivity extends Activity | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; private boolean mPendingDeletion = false; + private Intent mVideoShareIntent; + private Intent mImageShareIntent; + public void gotoGallery() { mFilmStripView.getController().goToNextItem(); } @@ -359,14 +362,39 @@ public class CameraActivity extends Activity } private void setStandardShareIntent(Uri contentUri, String mimeType) { - if (mStandardShareIntent == null) { - mStandardShareIntent = new Intent(Intent.ACTION_SEND); + mStandardShareIntent = getShareIntentFromType(mimeType); + if (mStandardShareIntent != null) { + mStandardShareIntent.putExtra(Intent.EXTRA_STREAM, contentUri); + mStandardShareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + if (mStandardShareActionProvider != null) { + mStandardShareActionProvider.setShareIntent(mStandardShareIntent); + } } - mStandardShareIntent.setType(mimeType); - mStandardShareIntent.putExtra(Intent.EXTRA_STREAM, contentUri); - if (mStandardShareActionProvider != null) { - mStandardShareActionProvider.setShareIntent(mStandardShareIntent); + } + + /** + * Get the share intent according to the mimeType + * + * @param mimeType The mimeType of current data. + * @return the video/image's ShareIntent or null if mimeType is invalid. + */ + private Intent getShareIntentFromType(String mimeType) { + // Lazily create the intent object. + if (mimeType.startsWith("video/")) { + if (mVideoShareIntent == null) { + mVideoShareIntent = new Intent(Intent.ACTION_SEND); + mVideoShareIntent.setType("video/*"); + } + return mVideoShareIntent; + } else if (mimeType.startsWith("image/")) { + if (mImageShareIntent == null) { + mImageShareIntent = new Intent(Intent.ACTION_SEND); + mImageShareIntent.setType("image/*"); + } + return mImageShareIntent; } + Log.w(TAG, "unsupported mimeType " + mimeType); + return null; } private void setPanoramaShareIntent(Uri contentUri) { |