From ad4657df1ffa41317867d36eee26f6e2f88954a6 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Wed, 19 Apr 2017 19:06:00 -0700 Subject: [PATCH] Fix video selection support with extra mime type // FREEBIE --- .../securesms/mms/AttachmentManager.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java index 3582c44270..438f5d2943 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java @@ -298,15 +298,15 @@ public class AttachmentManager { } public static void selectDocument(Activity activity, int requestCode) { - selectMediaType(activity, "*/*", requestCode); + selectMediaType(activity, "*/*", null, requestCode); } public static void selectGallery(Activity activity, int requestCode) { - selectMediaType(activity, "image/* video/*", requestCode); + selectMediaType(activity, "image/*", new String[] {"image/*", "video/*"}, requestCode); } public static void selectAudio(Activity activity, int requestCode) { - selectMediaType(activity, "audio/*", requestCode); + selectMediaType(activity, "audio/*", null, requestCode); } public static void selectContactInfo(Activity activity, int requestCode) { @@ -353,10 +353,14 @@ public class AttachmentManager { } } - private static void selectMediaType(Activity activity, String type, int requestCode) { + private static void selectMediaType(Activity activity, @NonNull String type, @Nullable String[] extraMimeType, int requestCode) { final Intent intent = new Intent(); intent.setType(type); + if (extraMimeType != null && Build.VERSION.SDK_INT >= 19) { + intent.putExtra(Intent.EXTRA_MIME_TYPES, extraMimeType); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { intent.setAction(Intent.ACTION_OPEN_DOCUMENT); try { @@ -368,6 +372,7 @@ public class AttachmentManager { } intent.setAction(Intent.ACTION_GET_CONTENT); + try { activity.startActivityForResult(intent, requestCode); } catch (ActivityNotFoundException anfe) {