From 3cee7b310ee34a7d70766d96f05fe6c416bd830b Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Wed, 27 Jun 2018 08:13:52 -0400 Subject: [PATCH] Set Android share extension default mime type for images and videos (#1833) --- .../java/com/mattermost/share/ShareModule.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/mattermost/share/ShareModule.java b/android/app/src/main/java/com/mattermost/share/ShareModule.java index 5ce9cd654..d77cd982c 100644 --- a/android/app/src/main/java/com/mattermost/share/ShareModule.java +++ b/android/app/src/main/java/com/mattermost/share/ShareModule.java @@ -147,6 +147,13 @@ public class ShareModule extends ReactContextBaseJavaModule { Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); text = "file://" + RealPathUtil.getRealPathFromURI(currentActivity, uri); map.putString("value", text); + + if (type.equals("image/*")) { + type = "image/jpeg"; + } else if (type.equals("video/*")) { + type = "video/mp4"; + } + map.putString("type", type); items.pushMap(map); } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { @@ -156,7 +163,15 @@ public class ShareModule extends ReactContextBaseJavaModule { map = Arguments.createMap(); text = "file://" + filePath; map.putString("value", text); - map.putString("type", RealPathUtil.getMimeTypeFromUri(currentActivity, uri)); + + type = RealPathUtil.getMimeTypeFromUri(currentActivity, uri); + if (type.equals("image/*")) { + type = "image/jpeg"; + } else if (type.equals("video/*")) { + type = "video/mp4"; + } + + map.putString("type", type); items.pushMap(map); } }