summaryrefslogtreecommitdiffstats
path: root/src/com/android/photos/SelectionManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/photos/SelectionManager.java')
-rw-r--r--src/com/android/photos/SelectionManager.java54
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() {