Parcourir la source

camera permission from h5 bug

hanjing il y a 6 ans
Parent
commit
a4764e0078

+ 4 - 11
app/src/main/java/com/sheep/gamegroup/module/webview/fragment/FgtWeb.java

@@ -246,7 +246,10 @@ public class FgtWeb extends BaseFgtWeb {
 
             @Override
             public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
-                if (!CameraUtil.checkCameraPermission(getActivity())) return true;
+                if (!CameraUtil.checkCameraPermission(getActivity())) {
+                    filePathCallback.onReceiveValue(new Uri[]{});
+                    return true;
+                }
                 if (mFilePathCallback != null) {
                     mFilePathCallback.onReceiveValue(null);
                 }
@@ -296,16 +299,6 @@ public class FgtWeb extends BaseFgtWeb {
                 return /*super.onShowFileChooser(webView, filePathCallback, fileChooserParams)*/true;
             }
 
-            //For Android 4.1
-            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
-                mUploadMessage = uploadMsg;
-                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
-                i.addCategory(Intent.CATEGORY_OPENABLE);
-                i.setType("image/*");
-                FgtWeb.this.startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILECHOOSER_RESULTCODE);
-
-            }
-
             @Override
             public void onProgressChanged(WebView view, int newProgress) {
                 LogUtil.println("ActWeb", "onProgressChanged", newProgress);

+ 4 - 11
app/src/main/java/com/sheep/gamegroup/module/webview/fragment/FgtWebX5.java

@@ -233,7 +233,10 @@ public class FgtWebX5 extends BaseFgtWebX5 {
 
             @Override
             public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
-                if (!CameraUtil.checkCameraPermission(getActivity())) return true;
+                if (!CameraUtil.checkCameraPermission(getActivity())) {
+                    filePathCallback.onReceiveValue(new Uri[]{});
+                    return true;
+                }
                 if (mFilePathCallback != null) {
                     mFilePathCallback.onReceiveValue(null);
                 }
@@ -283,16 +286,6 @@ public class FgtWebX5 extends BaseFgtWebX5 {
                 return /*super.onShowFileChooser(webView, filePathCallback, fileChooserParams)*/true;
             }
 
-            //For Android 4.1
-            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
-                mUploadMessage = uploadMsg;
-                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
-                i.addCategory(Intent.CATEGORY_OPENABLE);
-                i.setType("image/*");
-                FgtWebX5.this.startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILECHOOSER_RESULTCODE);
-
-            }
-
             @Override
             public void onProgressChanged(WebView view, int newProgress) {
                 LogUtil.println("ActWebX5", "onProgressChanged", newProgress);

+ 0 - 5
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -679,11 +679,6 @@ public class KFZSJs {
     }
 
     @JavascriptInterface
-    public boolean checkCameraPermission() {
-        return CameraUtil.checkCameraPermission(activity);
-    }
-
-    @JavascriptInterface
     public void loginThirdPartApp(String type) {
         UMShareAPI.get(SheepApp.getInstance()).doOauthVerify(activity,
                 "wx".equals(type) ? SHARE_MEDIA.WEIXIN : SHARE_MEDIA.QQ,