diff --git a/src/plugins/browser/android/com/foxdebug/browser/Browser.java b/src/plugins/browser/android/com/foxdebug/browser/Browser.java index 5b4b2acc4..e218075c7 100644 --- a/src/plugins/browser/android/com/foxdebug/browser/Browser.java +++ b/src/plugins/browser/android/com/foxdebug/browser/Browser.java @@ -117,11 +117,10 @@ public void onClick(View v) { ); faviconFrame = new FrameLayout(context); - faviconFrameParams = - new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ); + faviconFrameParams = new LinearLayout.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ); faviconFrameParams.gravity = Gravity.CENTER_VERTICAL; faviconFrame.setLayoutParams(faviconFrameParams); faviconFrame.addView(favicon); @@ -568,21 +567,24 @@ public boolean onShowFileChooser( if (browser.filePathCallback != null) { browser.filePathCallback.onReceiveValue(null); } - browser.filePathCallback = filePathCallback; - Intent selectDocument = new Intent(Intent.ACTION_GET_CONTENT); - Boolean isMultiple = - ( - fileChooserParams.getMode() == - WebChromeClient.FileChooserParams.MODE_OPEN_MULTIPLE - ); - String mimeType = fileChooserParams.getAcceptTypes()[0]; - mimeType = mimeType == null ? "*/*" : mimeType; + String[] acceptTypes = fileChooserParams.getAcceptTypes(); + String mimeType = "*/*"; // default if empty or null + if (acceptTypes != null && acceptTypes.length > 0) { + String firstType = acceptTypes[0]; + if (firstType != null && !firstType.trim().isEmpty()) { + mimeType = firstType; + } + } + Intent selectDocument = new Intent(Intent.ACTION_GET_CONTENT); selectDocument.addCategory(Intent.CATEGORY_OPENABLE); selectDocument.setType(mimeType); + boolean isMultiple = + (fileChooserParams.getMode() == + WebChromeClient.FileChooserParams.MODE_OPEN_MULTIPLE); if (isMultiple) { selectDocument.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }