summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Brabham <optedoblivion@cyngn.com>2016-02-11 15:41:43 -0500
committerJoey Rizzoli <joey@cyanogenmoditalia.it>2016-10-17 16:38:21 +0200
commit68751562e547c33c6cf5ea485f8c53067878466d (patch)
tree89bb6bacc7eaf3534bcbf4c1a98ddab11faa9667
parentd2f032974a07aaebbe544c829d43258408af6342 (diff)
downloadandroid_packages_apps_Messaging-68751562e547c33c6cf5ea485f8c53067878466d.tar.gz
android_packages_apps_Messaging-68751562e547c33c6cf5ea485f8c53067878466d.tar.bz2
android_packages_apps_Messaging-68751562e547c33c6cf5ea485f8c53067878466d.zip
Messaging: Implement saved video attachments in MMS
Change-Id: I184a8d84f019d916fd07d8b90fb96b80408c6768 Ticket-Id: CRACKLING-937
-rw-r--r--res/layout/gallery_grid_item_view.xml16
-rw-r--r--src/com/android/messaging/datamodel/GalleryBoundCursorLoader.java2
-rw-r--r--src/com/android/messaging/datamodel/data/GalleryGridItemData.java38
-rw-r--r--src/com/android/messaging/datamodel/data/MessagePartData.java17
-rw-r--r--src/com/android/messaging/ui/mediapicker/GalleryGridItemView.java30
5 files changed, 91 insertions, 12 deletions
diff --git a/res/layout/gallery_grid_item_view.xml b/res/layout/gallery_grid_item_view.xml
index 8b7ee58..88e4a1b 100644
--- a/res/layout/gallery_grid_item_view.xml
+++ b/res/layout/gallery_grid_item_view.xml
@@ -27,6 +27,22 @@
android:layout_height="match_parent"
android:scaleType="centerCrop" />
+ <FrameLayout
+ android:id="@+id/video_button"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:visibility="invisible">
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:background="@drawable/transparent_button_background"
+ android:scaleType="fitCenter"
+ android:src="@drawable/ic_video_play_light"
+ android:contentDescription="@string/video_thumbnail_view_play_button_content_description"/>
+ </FrameLayout>
+
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/src/com/android/messaging/datamodel/GalleryBoundCursorLoader.java b/src/com/android/messaging/datamodel/GalleryBoundCursorLoader.java
index 28ec303..edcb150 100644
--- a/src/com/android/messaging/datamodel/GalleryBoundCursorLoader.java
+++ b/src/com/android/messaging/datamodel/GalleryBoundCursorLoader.java
@@ -35,7 +35,7 @@ public class GalleryBoundCursorLoader extends BoundCursorLoader {
private static final String SORT_ORDER = Media.DATE_MODIFIED + " DESC";
private static final String IMAGE_SELECTION = createSelection(
MessagePartData.ACCEPTABLE_IMAGE_TYPES,
- new Integer[] { FileColumns.MEDIA_TYPE_IMAGE });
+ new Integer[] { FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_VIDEO });
public GalleryBoundCursorLoader(final String bindingId, final Context context) {
super(bindingId, context, STORAGE_URI, GalleryGridItemData.IMAGE_PROJECTION,
diff --git a/src/com/android/messaging/datamodel/data/GalleryGridItemData.java b/src/com/android/messaging/datamodel/data/GalleryGridItemData.java
index 6649757..cb6fc98 100644
--- a/src/com/android/messaging/datamodel/data/GalleryGridItemData.java
+++ b/src/com/android/messaging/datamodel/data/GalleryGridItemData.java
@@ -26,6 +26,7 @@ import android.text.TextUtils;
import com.android.messaging.datamodel.media.FileImageRequestDescriptor;
import com.android.messaging.datamodel.media.ImageRequest;
import com.android.messaging.datamodel.media.UriImageRequestDescriptor;
+import com.android.messaging.datamodel.media.VideoThumbnailRequestDescriptor;
import com.android.messaging.util.Assert;
/**
@@ -59,6 +60,7 @@ public class GalleryGridItemData {
private UriImageRequestDescriptor mImageData;
private String mContentType;
private boolean mIsDocumentPickerItem;
+ private boolean mIsVideoItem;
private long mDateSeconds;
public GalleryGridItemData() {
@@ -71,6 +73,10 @@ public class GalleryGridItemData {
mImageData = null;
mContentType = null;
} else {
+
+ String mimeType = cursor.getString(INDEX_MIME_TYPE);
+ mIsVideoItem = mimeType != null && mimeType.toLowerCase().contains("video/");
+
int sourceWidth = cursor.getInt(INDEX_WIDTH);
int sourceHeight = cursor.getInt(INDEX_HEIGHT);
@@ -85,15 +91,25 @@ public class GalleryGridItemData {
mContentType = cursor.getString(INDEX_MIME_TYPE);
final String dateModified = cursor.getString(INDEX_DATE_MODIFIED);
mDateSeconds = !TextUtils.isEmpty(dateModified) ? Long.parseLong(dateModified) : -1;
- mImageData = new FileImageRequestDescriptor(
- cursor.getString(INDEX_DATA_PATH),
- desiredWidth,
- desiredHeight,
- sourceWidth,
- sourceHeight,
- true /* canUseThumbnail */,
- true /* allowCompression */,
- true /* isStatic */);
+ if (mIsVideoItem) {
+ mImageData = new VideoThumbnailRequestDescriptor(
+ cursor.getLong(INDEX_ID),
+ cursor.getString(INDEX_DATA_PATH),
+ desiredWidth,
+ desiredHeight,
+ sourceWidth,
+ sourceHeight);
+ } else {
+ mImageData = new FileImageRequestDescriptor(
+ cursor.getString(INDEX_DATA_PATH),
+ desiredWidth,
+ desiredHeight,
+ sourceWidth,
+ sourceHeight,
+ true /* canUseThumbnail */,
+ true /* allowCompression */,
+ true /* isStatic */);
+ }
}
}
@@ -101,6 +117,10 @@ public class GalleryGridItemData {
return mIsDocumentPickerItem;
}
+ public boolean isVideoItem() {
+ return mIsVideoItem;
+ }
+
public Uri getImageUri() {
return mImageData.uri;
}
diff --git a/src/com/android/messaging/datamodel/data/MessagePartData.java b/src/com/android/messaging/datamodel/data/MessagePartData.java
index fffaca8..a41eb3d 100644
--- a/src/com/android/messaging/datamodel/data/MessagePartData.java
+++ b/src/com/android/messaging/datamodel/data/MessagePartData.java
@@ -53,8 +53,21 @@ import java.util.concurrent.TimeUnit;
public class MessagePartData implements Parcelable {
public static final int UNSPECIFIED_SIZE = MessagingContentProvider.UNSPECIFIED_SIZE;
public static final String[] ACCEPTABLE_IMAGE_TYPES =
- new String[] { ContentType.IMAGE_JPEG, ContentType.IMAGE_JPG, ContentType.IMAGE_PNG,
- ContentType.IMAGE_GIF };
+ new String[] {
+ // Images
+ ContentType.IMAGE_JPEG,
+ ContentType.IMAGE_JPG,
+ ContentType.IMAGE_PNG,
+ ContentType.IMAGE_GIF,
+
+ // Videos
+ ContentType.VIDEO_MP4,
+ ContentType.VIDEO_MPEG,
+ ContentType.VIDEO_MPEG4,
+ ContentType.VIDEO_3GP,
+ ContentType.VIDEO_3GPP,
+ ContentType.VIDEO_WEBM,
+ };
private static final String[] sProjection = {
PartColumns._ID,
diff --git a/src/com/android/messaging/ui/mediapicker/GalleryGridItemView.java b/src/com/android/messaging/ui/mediapicker/GalleryGridItemView.java
index 3d71fe6..2006f57 100644
--- a/src/com/android/messaging/ui/mediapicker/GalleryGridItemView.java
+++ b/src/com/android/messaging/ui/mediapicker/GalleryGridItemView.java
@@ -51,6 +51,7 @@ public class GalleryGridItemView extends FrameLayout {
@VisibleForTesting
GalleryGridItemData mData;
+ private View mVideoButtonOverlayView;
private AsyncImageView mImageView;
private CheckBox mCheckBox;
private HostInterface mHostInterface;
@@ -69,6 +70,7 @@ public class GalleryGridItemView extends FrameLayout {
@Override
protected void onFinishInflate() {
super.onFinishInflate();
+ mVideoButtonOverlayView = findViewById(R.id.video_button);
mImageView = (AsyncImageView) findViewById(R.id.image);
mCheckBox = (CheckBox) findViewById(R.id.checkbox);
mCheckBox.setOnClickListener(mOnClickListener);
@@ -136,13 +138,28 @@ public class GalleryGridItemView extends FrameLayout {
private void updateImageView() {
if (mData.isDocumentPickerItem()) {
+ hideVideoPlayButtonOverlay();
mImageView.setScaleType(ScaleType.CENTER);
setBackgroundColor(ConversationDrawables.get().getConversationThemeColor());
mImageView.setImageResourceId(null);
mImageView.setImageResource(R.drawable.ic_photo_library_light);
mImageView.setContentDescription(getResources().getString(
R.string.pick_image_from_document_library_content_description));
+ } else if (mData.isVideoItem()) {
+ showVideoPlayButtonOverlay();
+ mImageView.setScaleType(ScaleType.CENTER_CROP);
+ setBackgroundColor(getResources().getColor(R.color.gallery_image_default_background));
+ mImageView.setImageResourceId(mData.getImageRequestDescriptor());
+ final long dateSeconds = mData.getDateSeconds();
+ final boolean isValidDate = (dateSeconds > 0);
+ final int templateId = isValidDate ?
+ R.string.mediapicker_gallery_image_item_description :
+ R.string.mediapicker_gallery_image_item_description_no_date;
+ String contentDescription = String.format(getResources().getString(templateId),
+ dateSeconds * TimeUnit.SECONDS.toMillis(1));
+ mImageView.setContentDescription(contentDescription);
} else {
+ hideVideoPlayButtonOverlay();
mImageView.setScaleType(ScaleType.CENTER_CROP);
setBackgroundColor(getResources().getColor(R.color.gallery_image_default_background));
mImageView.setImageResourceId(mData.getImageRequestDescriptor());
@@ -156,4 +173,17 @@ public class GalleryGridItemView extends FrameLayout {
mImageView.setContentDescription(contentDescription);
}
}
+
+ private void showVideoPlayButtonOverlay() {
+ if (mVideoButtonOverlayView != null) {
+ mVideoButtonOverlayView.setVisibility(View.VISIBLE);
+ }
+ }
+
+ private void hideVideoPlayButtonOverlay() {
+ if (mVideoButtonOverlayView != null) {
+ mVideoButtonOverlayView.setVisibility(View.INVISIBLE);
+ }
+ }
+
}