/** * Share the provided photo through other android apps * * <p>Will share the image as a image/jpg content type and include title and description as extra * * @param slideshowPhoto */ public void actionSharePhoto(SlideshowPhoto slideshowPhoto) { Log.i(LOG_PREFIX, "Attempting to share photo " + slideshowPhoto); // TODO: Refactor this code.. rather ugly due to some GoogleTV related hacks if (slideshowPhoto != null) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); // we assume the type is image/jpg shareIntent.setType("image/jpg"); String sharedText = slideshowPhoto.getTitle() + ": " + slideshowPhoto.getDescription() + "\n\n" + getResources().getString(R.string.share_footer); // if we have a cached file, add the stream and the sharedText // if not, add the url and the sharedText if (slideshowPhoto.isCacheExisting(rootFileDirectory)) { String path = "file://" + rootFileDirectory.getAbsolutePath() + "/" + slideshowPhoto.getFileName(); Log.i(LOG_PREFIX, "Attempting to pass stream url " + path); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path)); shareIntent.putExtra(Intent.EXTRA_TEXT, sharedText); } else { shareIntent.putExtra( Intent.EXTRA_TEXT, slideshowPhoto.getLargePhoto() + "\n\n" + sharedText); } shareIntent.putExtra(Intent.EXTRA_SUBJECT, slideshowPhoto.getTitle()); // Start the actual sharing activity try { List<ResolveInfo> relevantActivities = getPackageManager().queryIntentActivities(shareIntent, 0); if (AndroidUtils.isGoogleTV(getApplicationContext()) || relevantActivities == null || relevantActivities.size() == 0) { Log.i( LOG_PREFIX, "No activity found that can handle image/jpg. Performing simple text share"); Intent backupShareIntent = new Intent(); backupShareIntent.setAction(Intent.ACTION_SEND); backupShareIntent.setType("text/plain"); String backupSharedText = slideshowPhoto.getLargePhoto() + "\n\n" + sharedText; backupShareIntent.putExtra(Intent.EXTRA_TEXT, backupSharedText); startActivity(backupShareIntent); } else { startActivity(shareIntent); } } catch (ActivityNotFoundException e) { notifyUser("Unable to share current photo"); } } else { notifyUser("Unable to share current photo"); } }
@Override public void onDownloadError(DownloadableObject downloadableObject) { SlideshowPhoto slideshowPhoto = (SlideshowPhoto) downloadableObject; Log.w( LOG_PREFIX, "Unable to download slideshow photo with large photo url " + slideshowPhoto.getLargePhoto()); }