Fix video selection support with extra mime type

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-04-19 19:06:00 -07:00
parent bc33f8ec02
commit ad4657df1f

View File

@ -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) {