From 405e5f979f815564f2841579d52544890b7569fc Mon Sep 17 00:00:00 2001 From: Christofer Bodin Date: Thu, 10 Dec 2020 12:40:36 +0100 Subject: [PATCH] fix android intent chooser not showing camera/camcorder when all mime types are supported. --- .../InAppWebView/InAppWebViewChromeClient.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewChromeClient.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewChromeClient.java index 7cf1fec2..6cee2869 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewChromeClient.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewChromeClient.java @@ -971,6 +971,20 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR return intent; } + private Boolean acceptsAny(String[] types) { + if (isArrayEmpty(types)) { + return true; + } + + for (String type : types) { + if (type.equals("*/*")) { + return true; + } + } + + return false; + } + private Boolean acceptsImages(String types) { String mimeType = types; if (types.matches("\\.\\w+")) { @@ -981,7 +995,7 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR private Boolean acceptsImages(String[] types) { String[] mimeTypes = getAcceptedMimeType(types); - return isArrayEmpty(mimeTypes) || arrayContainsString(mimeTypes, "image"); + return acceptsAny(types) || arrayContainsString(mimeTypes, "image"); } private Boolean acceptsVideo(String types) { @@ -994,7 +1008,7 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR private Boolean acceptsVideo(String[] types) { String[] mimeTypes = getAcceptedMimeType(types); - return isArrayEmpty(mimeTypes) || arrayContainsString(mimeTypes, "video"); + return acceptsAny(types) || arrayContainsString(mimeTypes, "video"); } private Boolean arrayContainsString(String[] array, String pattern) {