From 414190774a73ba9029808f946a4ee066628862d7 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Wed, 14 Sep 2011 16:46:32 +0800 Subject: Fix 5291553 Not able to share downloaded image file Change-Id: I8e57b04e0231c592cc0dfe8a4f31e585510e753c --- src/com/android/gallery3d/app/PhotoPage.java | 33 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/com/android/gallery3d/app') diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index a3b385ac0..44b9299fc 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -85,6 +85,7 @@ public class PhotoPage extends ActivityState private FilmStripView mFilmStripView; private DetailsHelper mDetailsHelper; private boolean mShowDetails; + private Path mPendingSharePath; // mMediaSet could be null if there is no KEY_MEDIA_SET_PATH supplied. // E.g., viewing a photo in gmail attachment @@ -240,6 +241,7 @@ public class PhotoPage extends ActivityState mPhotoView.setModel(mModel); updateCurrentPhoto(mediaItem); } + mHandler = new SynchronizedHandler(mActivity.getGLRoot()) { @Override public void handleMessage(Message message) { @@ -257,6 +259,21 @@ public class PhotoPage extends ActivityState mPhotoView.setOpenedItem(itemPath); } + private void updateShareURI(Path path) { + if (mShareActionProvider != null) { + DataManager manager = mActivity.getDataManager(); + int type = manager.getMediaType(path); + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType(MenuExecutor.getMimeType(type)); + intent.putExtra(Intent.EXTRA_STREAM, manager.getContentUri(path)); + mShareActionProvider.setShareIntent(intent); + mPendingSharePath = null; + } else { + // This happens when ActionBar is not created yet. + mPendingSharePath = path; + } + } + private void setTitle(String title) { if (title == null) return; boolean showTitle = mActivity.getAndroidContext().getResources().getBoolean( @@ -276,19 +293,10 @@ public class PhotoPage extends ActivityState mDetailsHelper.reloadDetails(mModel.getCurrentIndex()); } setTitle(photo.getName()); - mPhotoView.showVideoPlayIcon(photo.getMediaType() - == MediaObject.MEDIA_TYPE_VIDEO); + mPhotoView.showVideoPlayIcon( + photo.getMediaType() == MediaObject.MEDIA_TYPE_VIDEO); - // If we have an ActionBar then we update the share intent - if (mShareActionProvider != null) { - Path path = photo.getPath(); - DataManager manager = mActivity.getDataManager(); - int type = manager.getMediaType(path); - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType(MenuExecutor.getMimeType(type)); - intent.putExtra(Intent.EXTRA_STREAM, manager.getContentUri(path)); - mShareActionProvider.setShareIntent(intent); - } + updateShareURI(photo.getPath()); } private void updateMenuOperations() { @@ -384,6 +392,7 @@ public class PhotoPage extends ActivityState menu.findItem(R.id.action_slideshow).setVisible( mMediaSet != null && !(mMediaSet instanceof MtpDevice)); mShareActionProvider = GalleryActionBar.initializeShareActionProvider(menu); + if (mPendingSharePath != null) updateShareURI(mPendingSharePath); mMenu = menu; mShowBars = true; updateMenuOperations(); -- cgit v1.2.3