private static void viewMmsMessageAttachment( Context context, Uri msgUri, SlideshowModel slideshow, int requestCode) { boolean isSimple = (slideshow == null) ? false : slideshow.isSimple(); if (isSimple) { // In attachment-editor mode, we only ever have one slide. MessageUtils.viewSimpleSlideshow(context, slideshow); } else { // If a slideshow was provided, save it to disk first. if (slideshow != null) { PduPersister persister = PduPersister.getPduPersister(context); try { PduBody pb = slideshow.toPduBody(); persister.updateParts(msgUri, pb); slideshow.sync(pb); } catch (MmsException e) { Log.e(TAG, "Unable to save message for preview"); return; } } // Launch the slideshow activity to play/view. Intent intent = new Intent(context, SlideshowActivity.class); intent.setData(msgUri); if (requestCode > 0 && context instanceof Activity) { ((Activity) context).startActivityForResult(intent, requestCode); } else { context.startActivity(intent); } } }
public static void viewSimpleSlideshow(Context context, SlideshowModel slideshow) { if (!slideshow.isSimple()) { throw new IllegalArgumentException("viewSimpleSlideshow() called on a non-simple slideshow"); } SlideModel slide = slideshow.get(0); MediaModel mm = null; if (slide.hasImage()) { mm = slide.getImage(); } else if (slide.hasVideo()) { mm = slide.getVideo(); } Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra("SingleItemOnly", true); // So we don't see "surrounding" images in Gallery String contentType; if (mm.isDrmProtected()) { contentType = mm.getDrmObject().getContentType(); } else { contentType = mm.getContentType(); } intent.setDataAndType(mm.getUri(), contentType); context.startActivity(intent); }
public static void viewMmsMessageAttachment( Context context, WorkingMessage msg, int requestCode) { SlideshowModel slideshow = msg.getSlideshow(); if (slideshow == null) { throw new IllegalStateException("msg.getSlideshow() == null"); } if (slideshow.isSimple()) { MessageUtils.viewSimpleSlideshow(context, slideshow); } else { Uri uri = msg.saveAsMms(false); if (uri != null) { // Pass null for the slideshow paramater, otherwise viewMmsMessageAttachment // will persist the slideshow to disk again (we just did that above in saveAsMms) viewMmsMessageAttachment(context, uri, null, requestCode); } } }