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:
@@ -87,9 +87,4 @@ public class UriImageRequestDescriptor extends ImageRequestDescriptor {
|
||||
return new NetworkUriImageRequest<UriImageRequestDescriptor>(context, this);
|
||||
}
|
||||
}
|
||||
|
||||
/** ID of the resource in MediaStore or null if this resource didn't come from MediaStore */
|
||||
public Long getMediaStoreId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -21,24 +21,17 @@ import com.android.messaging.util.ImageUtils;
|
||||
import com.android.messaging.util.UriUtil;
|
||||
|
||||
public class VideoThumbnailRequestDescriptor extends UriImageRequestDescriptor {
|
||||
protected final long mMediaId;
|
||||
public VideoThumbnailRequestDescriptor(final long id, String path, int desiredWidth,
|
||||
int desiredHeight, int sourceWidth, int sourceHeight) {
|
||||
super(UriUtil.getUriForResourceFile(path), desiredWidth, desiredHeight, sourceWidth,
|
||||
public VideoThumbnailRequestDescriptor(final long id, int desiredWidth, int desiredHeight,
|
||||
int sourceWidth, int sourceHeight) {
|
||||
super(UriUtil.getContentUriForMediaStoreId(id), desiredWidth, desiredHeight, sourceWidth,
|
||||
sourceHeight, false /* canCompress */, false /* isStatic */,
|
||||
false /* cropToCircle */,
|
||||
ImageUtils.DEFAULT_CIRCLE_BACKGROUND_COLOR /* circleBackgroundColor */,
|
||||
ImageUtils.DEFAULT_CIRCLE_STROKE_COLOR /* circleStrokeColor */);
|
||||
mMediaId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaRequest<ImageResource> buildSyncMediaRequest(Context context) {
|
||||
return new VideoThumbnailRequest(context, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMediaStoreId() {
|
||||
return mMediaId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user