diff options
author | Martin Brabham <optedoblivion@cyngn.com> | 2016-02-11 15:41:43 -0500 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2018-01-21 21:57:18 +0200 |
commit | 74a5f246841b897157e70bc56a0f2e234cd62740 (patch) | |
tree | 148b3f718408da03f0dea2c15e970790be4720b4 /src | |
parent | aeaabf366c293dfbedd2510850e7a8a474d8b1d0 (diff) | |
download | packages_apps_Messaging-74a5f246841b897157e70bc56a0f2e234cd62740.tar.gz packages_apps_Messaging-74a5f246841b897157e70bc56a0f2e234cd62740.tar.bz2 packages_apps_Messaging-74a5f246841b897157e70bc56a0f2e234cd62740.zip |
Messaging: Implement saved video attachments in MMS
Change-Id: I184a8d84f019d916fd07d8b90fb96b80408c6768
Ticket-Id: CRACKLING-937
Diffstat (limited to 'src')
4 files changed, 75 insertions, 12 deletions
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); + } + } + } |