packages/apps/Gallery2
修订版 | 67f9cd0df453240e51e450b8cc991c8a8d5b7fdd (tree) |
---|---|
时间 | 2011-09-20 01:44:24 |
作者 | Ray Chen <raychen@goog...> |
Commiter | Android Git Automerger |
am acbab5b1: Merge "Fix 5291553 Not able to share downloaded image file"
* commit 'acbab5b17f393e57f7466e5459fed41f518e2864':
@@ -85,6 +85,7 @@ public class PhotoPage extends ActivityState | ||
85 | 85 | private FilmStripView mFilmStripView; |
86 | 86 | private DetailsHelper mDetailsHelper; |
87 | 87 | private boolean mShowDetails; |
88 | + private Path mPendingSharePath; | |
88 | 89 | |
89 | 90 | // mMediaSet could be null if there is no KEY_MEDIA_SET_PATH supplied. |
90 | 91 | // E.g., viewing a photo in gmail attachment |
@@ -240,6 +241,7 @@ public class PhotoPage extends ActivityState | ||
240 | 241 | mPhotoView.setModel(mModel); |
241 | 242 | updateCurrentPhoto(mediaItem); |
242 | 243 | } |
244 | + | |
243 | 245 | mHandler = new SynchronizedHandler(mActivity.getGLRoot()) { |
244 | 246 | @Override |
245 | 247 | public void handleMessage(Message message) { |
@@ -257,6 +259,21 @@ public class PhotoPage extends ActivityState | ||
257 | 259 | mPhotoView.setOpenedItem(itemPath); |
258 | 260 | } |
259 | 261 | |
262 | + private void updateShareURI(Path path) { | |
263 | + if (mShareActionProvider != null) { | |
264 | + DataManager manager = mActivity.getDataManager(); | |
265 | + int type = manager.getMediaType(path); | |
266 | + Intent intent = new Intent(Intent.ACTION_SEND); | |
267 | + intent.setType(MenuExecutor.getMimeType(type)); | |
268 | + intent.putExtra(Intent.EXTRA_STREAM, manager.getContentUri(path)); | |
269 | + mShareActionProvider.setShareIntent(intent); | |
270 | + mPendingSharePath = null; | |
271 | + } else { | |
272 | + // This happens when ActionBar is not created yet. | |
273 | + mPendingSharePath = path; | |
274 | + } | |
275 | + } | |
276 | + | |
260 | 277 | private void setTitle(String title) { |
261 | 278 | if (title == null) return; |
262 | 279 | boolean showTitle = mActivity.getAndroidContext().getResources().getBoolean( |
@@ -276,19 +293,10 @@ public class PhotoPage extends ActivityState | ||
276 | 293 | mDetailsHelper.reloadDetails(mModel.getCurrentIndex()); |
277 | 294 | } |
278 | 295 | setTitle(photo.getName()); |
279 | - mPhotoView.showVideoPlayIcon(photo.getMediaType() | |
280 | - == MediaObject.MEDIA_TYPE_VIDEO); | |
296 | + mPhotoView.showVideoPlayIcon( | |
297 | + photo.getMediaType() == MediaObject.MEDIA_TYPE_VIDEO); | |
281 | 298 | |
282 | - // If we have an ActionBar then we update the share intent | |
283 | - if (mShareActionProvider != null) { | |
284 | - Path path = photo.getPath(); | |
285 | - DataManager manager = mActivity.getDataManager(); | |
286 | - int type = manager.getMediaType(path); | |
287 | - Intent intent = new Intent(Intent.ACTION_SEND); | |
288 | - intent.setType(MenuExecutor.getMimeType(type)); | |
289 | - intent.putExtra(Intent.EXTRA_STREAM, manager.getContentUri(path)); | |
290 | - mShareActionProvider.setShareIntent(intent); | |
291 | - } | |
299 | + updateShareURI(photo.getPath()); | |
292 | 300 | } |
293 | 301 | |
294 | 302 | private void updateMenuOperations() { |
@@ -384,6 +392,7 @@ public class PhotoPage extends ActivityState | ||
384 | 392 | menu.findItem(R.id.action_slideshow).setVisible( |
385 | 393 | mMediaSet != null && !(mMediaSet instanceof MtpDevice)); |
386 | 394 | mShareActionProvider = GalleryActionBar.initializeShareActionProvider(menu); |
395 | + if (mPendingSharePath != null) updateShareURI(mPendingSharePath); | |
387 | 396 | mMenu = menu; |
388 | 397 | mShowBars = true; |
389 | 398 | updateMenuOperations(); |