diff options
author | Bobby Georgescu <georgescu@google.com> | 2013-03-08 20:15:15 -0800 |
---|---|---|
committer | Bobby Georgescu <georgescu@google.com> | 2013-03-13 14:20:31 -0700 |
commit | e2bc54a09412790da5ac7d19c52b964e49e14c25 (patch) | |
tree | 1a8b298139d71257aaaa7badef075760ae267546 /src/com/android/photos/SelectionManager.java | |
parent | a27f45a5c142ec752f68ba752542972476dae8eb (diff) | |
download | android_packages_apps_Snap-e2bc54a09412790da5ac7d19c52b964e49e14c25.tar.gz android_packages_apps_Snap-e2bc54a09412790da5ac7d19c52b964e49e14c25.tar.bz2 android_packages_apps_Snap-e2bc54a09412790da5ac7d19c52b964e49e14c25.zip |
Sharing support for albums, bulk operations infrastructure
Change-Id: I590f60ab85ffbd9cf9d7cd9982627604fa1b427f
Diffstat (limited to 'src/com/android/photos/SelectionManager.java')
-rw-r--r-- | src/com/android/photos/SelectionManager.java | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/src/com/android/photos/SelectionManager.java b/src/com/android/photos/SelectionManager.java index 979dcc7da..ce340c731 100644 --- a/src/com/android/photos/SelectionManager.java +++ b/src/com/android/photos/SelectionManager.java @@ -26,7 +26,7 @@ import android.provider.MediaStore.Files.FileColumns; import android.widget.ShareActionProvider; import com.android.gallery3d.common.ApiHelper; -import com.android.gallery3d.data.MediaItem; +import com.android.gallery3d.data.MediaObject; import com.android.gallery3d.util.GalleryUtils; import java.util.ArrayList; @@ -41,6 +41,10 @@ public class SelectionManager { public ArrayList<Uri> getSelectedShareableUris(); } + public interface Client { + public void setSelectionManager(SelectionManager manager); + } + public SelectionManager(Activity activity) { mActivity = activity; if (ApiHelper.AT_LEAST_16) { @@ -76,10 +80,10 @@ public class SelectionManager { mSelectedTotalCount += increment; mCachedShareableUris = null; - if ((itemSupportedOperations & MediaItem.SUPPORT_DELETE) > 0) { + if ((itemSupportedOperations & MediaObject.SUPPORT_DELETE) > 0) { mSelectedDeletableCount += increment; } - if ((itemSupportedOperations & MediaItem.SUPPORT_SHARE) > 0) { + if ((itemSupportedOperations & MediaObject.SUPPORT_SHARE) > 0) { mSelectedShareableCount += increment; if (itemType == FileColumns.MEDIA_TYPE_IMAGE) { mSelectedShareableImageCount += increment; @@ -93,24 +97,42 @@ public class SelectionManager { mShareIntent.setAction(null).setType(null); } else if (mSelectedShareableCount >= 1) { mCachedShareableUris = mUriSource.getSelectedShareableUris(); - if (mSelectedShareableImageCount == mSelectedShareableCount) { - mShareIntent.setType(GalleryUtils.MIME_TYPE_IMAGE); - } else if (mSelectedShareableVideoCount == mSelectedShareableCount) { - mShareIntent.setType(GalleryUtils.MIME_TYPE_VIDEO); - } else { - mShareIntent.setType(GalleryUtils.MIME_TYPE_ALL); - } - if (mSelectedShareableCount == 1) { - mShareIntent.setAction(Intent.ACTION_SEND); - mShareIntent.putExtra(Intent.EXTRA_STREAM, mCachedShareableUris.get(0)); + if (mCachedShareableUris.size() == 0) { + mShareIntent.setAction(null).setType(null); } else { - mShareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); - mShareIntent.putExtra(Intent.EXTRA_STREAM, mCachedShareableUris); + if (mSelectedShareableImageCount == mSelectedShareableCount) { + mShareIntent.setType(GalleryUtils.MIME_TYPE_IMAGE); + } else if (mSelectedShareableVideoCount == mSelectedShareableCount) { + mShareIntent.setType(GalleryUtils.MIME_TYPE_VIDEO); + } else { + mShareIntent.setType(GalleryUtils.MIME_TYPE_ALL); + } + if (mCachedShareableUris.size() == 1) { + mShareIntent.setAction(Intent.ACTION_SEND); + mShareIntent.putExtra(Intent.EXTRA_STREAM, mCachedShareableUris.get(0)); + } else { + mShareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); + mShareIntent.putExtra(Intent.EXTRA_STREAM, mCachedShareableUris); + } } } share.setShareIntent(mShareIntent); - // TODO update deletability, editability, etc. + // TODO update editability, etc. + } + + public int getSupportedOperations() { + if (mSelectedTotalCount == 0) { + return 0; + } + int supported = 0; + if (mSelectedDeletableCount == mSelectedTotalCount) { + supported |= MediaObject.SUPPORT_DELETE; + } + if (mSelectedShareableCount > 0) { + supported |= MediaObject.SUPPORT_SHARE; + } + return supported; } public void onClearSelection() { |