Support video attachments through GalleryMediaChooser

GalleryMediaChooser supports video types and more image types also. And
video thumbnails are overlaid with the play button image to distinguish
between images and videos.

Note:
 1. EXTRA_ALLOW_MULTIPLE is not specified for ACTION_GET_CONTENT.
 2. Files, methods and variables' name are still including "image".
 3. Content descriptions are not updated.

Test: Manual

Change-Id: I961928f150e4ae8ee80a1fba2f20c37fb5426669
Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
This commit is contained in:
Taesu Lee
2020-02-19 18:36:32 +09:00
parent a531636ae3
commit 6c77158718
20 changed files with 131 additions and 99 deletions
@@ -16,15 +16,11 @@
package com.android.messaging.datamodel.media;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Bitmap;
import android.provider.MediaStore.Video.Thumbnails;
import com.android.messaging.Factory;
import com.android.messaging.util.MediaMetadataRetrieverWrapper;
import com.android.messaging.util.MediaUtil;
import com.android.messaging.util.OsUtil;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -57,19 +53,15 @@ public class VideoThumbnailRequest extends ImageRequest<UriImageRequestDescripto
@Override
protected Bitmap getBitmapForResource() throws IOException {
final Long mediaId = mDescriptor.getMediaStoreId();
Bitmap bitmap = null;
if (mediaId != null) {
final ContentResolver cr = Factory.get().getApplicationContext().getContentResolver();
bitmap = Thumbnails.getThumbnail(cr, mediaId, Thumbnails.MICRO_KIND, null);
} else {
final MediaMetadataRetrieverWrapper retriever = new MediaMetadataRetrieverWrapper();
try {
retriever.setDataSource(mDescriptor.uri);
bitmap = retriever.getFrameAtTime();
} finally {
retriever.release();
}
// Get a thumbnail through MediaMetadataRetriever to get a representative frame at any time
// position instead.
final MediaMetadataRetrieverWrapper retriever = new MediaMetadataRetrieverWrapper();
try {
retriever.setDataSource(mDescriptor.uri);
bitmap = retriever.getFrameAtTime();
} finally {
retriever.release();
}
if (bitmap != null) {
mDescriptor.updateSourceDimensions(bitmap.getWidth(), bitmap.getHeight());