summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ImageGallery.java
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2009-07-29 13:45:42 +0800
committerOwen Lin <owenlin@google.com>2009-08-06 13:41:18 +0800
commit8f8cf3807d66cbd97172a262ce2da78ad2f2c2d9 (patch)
tree11d8a9fec738f24d25083d61ae0e09fcdb56b25a /src/com/android/camera/ImageGallery.java
parent28a217917a10c0a0dad1e890faee62d6ac05edb0 (diff)
downloadLegacyCamera-8f8cf3807d66cbd97172a262ce2da78ad2f2c2d9.zip
LegacyCamera-8f8cf3807d66cbd97172a262ce2da78ad2f2c2d9.tar.gz
LegacyCamera-8f8cf3807d66cbd97172a262ce2da78ad2f2c2d9.tar.bz2
Add the function to share multiple items in gallery.
Diffstat (limited to 'src/com/android/camera/ImageGallery.java')
-rw-r--r--src/com/android/camera/ImageGallery.java54
1 files changed, 49 insertions, 5 deletions
diff --git a/src/com/android/camera/ImageGallery.java b/src/com/android/camera/ImageGallery.java
index 95b2ff8..5803f48 100644
--- a/src/com/android/camera/ImageGallery.java
+++ b/src/com/android/camera/ImageGallery.java
@@ -16,10 +16,6 @@
package com.android.camera;
-import com.android.camera.gallery.IImage;
-import com.android.camera.gallery.IImageList;
-import com.android.camera.gallery.VideoObject;
-
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -43,6 +39,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Parcelable;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
@@ -58,6 +55,11 @@ import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;
+import android.widget.Toast;
+
+import com.android.camera.gallery.IImage;
+import com.android.camera.gallery.IImageList;
+import com.android.camera.gallery.VideoObject;
import java.util.ArrayList;
import java.util.HashSet;
@@ -107,7 +109,7 @@ public class ImageGallery extends Activity implements
// Must be called before setContentView().
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
- setContentView(R.layout.image_gallery_2);
+ setContentView(R.layout.image_gallery);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_gallery_title);
@@ -145,6 +147,13 @@ public class ImageGallery extends Activity implements
}
});
+ Button shareButton = (Button) findViewById(R.id.button_share);
+ shareButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ onShareMultipleClicked();
+ }
+ });
+
Button closeButton = (Button) findViewById(R.id.button_close);
closeButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
@@ -990,6 +999,41 @@ public class ImageGallery extends Activity implements
}
}
+ private String getShareMultipleMimeType() {
+ final int FLAG_IMAGE = 1, FLAG_VIDEO = 2;
+ int flag = 0;
+ for (IImage image : mMultiSelected) {
+ flag |= ImageManager.isImage(image) ? FLAG_IMAGE : FLAG_VIDEO;
+ }
+ return flag == FLAG_IMAGE
+ ? "image/*"
+ : flag == FLAG_VIDEO ? "video/*" : "*/*";
+ }
+
+ private void onShareMultipleClicked() {
+ Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_SEND_MULTIPLE);
+
+ String mimeType = getShareMultipleMimeType();
+ intent.setType(mimeType);
+ ArrayList<Parcelable> list = new ArrayList<Parcelable>();
+ for (IImage image : mMultiSelected) {
+ list.add(image.fullSizeImageUri());
+ }
+ intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, list);
+
+ boolean isImage = ImageManager.isImageMimeType(mimeType);
+ try {
+ startActivity(Intent.createChooser(intent, getText(
+ isImage ? R.string.sendImage : R.string.sendVideo)));
+ } catch (android.content.ActivityNotFoundException ex) {
+ Toast.makeText(this, isImage
+ ? R.string.no_way_to_share_image
+ : R.string.no_way_to_share_video,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+
private void onDeleteMultipleClicked() {
Runnable action = new Runnable() {
public void run() {