package com.sjm.sjmsdk.js; import android.app.Activity; import android.app.AlertDialog; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ResolveInfo; import android.graphics.Bitmap; import android.net.Uri; import android.net.http.SslError; import android.util.Log; import android.webkit.DownloadListener; import android.webkit.SslErrorHandler; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import com.czhj.sdk.common.Constants; public class b { Activity a; WebView b; WebViewClient c = new WebViewClient() { /* class com.sjm.sjmsdk.js.b.AnonymousClass1 */ public void onPageFinished(WebView webView, String str) { super.onPageFinished(webView, str); b.this.a.isFinishing(); } public void onPageStarted(WebView webView, String str, Bitmap bitmap) { super.onPageStarted(webView, str, bitmap); } public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) { int errorCode = webResourceError.getErrorCode(); Log.d("test", "onReceivedError.errCode=" + errorCode); if (errorCode == 400) { webView.loadUrl("file:///android_assets/error_handle.html"); } } public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) { } public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) { sslErrorHandler.proceed(); } @Override // android.webkit.WebViewClient public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) { return super.shouldOverrideUrlLoading(webView, webResourceRequest); } @Override // android.webkit.WebViewClient public boolean shouldOverrideUrlLoading(WebView webView, String str) { Log.d("test", "onReceivedError.shouldOverrideUrlLoading=" + str); if (b.this.a.isFinishing()) { return true; } final Activity activity = b.this.a; if (str.startsWith("alipays:") || str.startsWith("alipay")) { try { activity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str))); } catch (Exception unused) { new AlertDialog.Builder(activity).setMessage("未检测到支付宝客户端,请安装后重试。").setPositiveButton("立即安装", new DialogInterface.OnClickListener() { /* class com.sjm.sjmsdk.js.b.AnonymousClass1.AnonymousClass1 */ public void onClick(DialogInterface dialogInterface, int i) { activity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://d.alipay.com"))); } }).setNegativeButton("取消", (DialogInterface.OnClickListener) null).show(); } return true; } else if (str.startsWith("weixin:")) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.setData(Uri.parse(str)); activity.startActivity(intent); return true; } else if (str.startsWith(Constants.HTTP) || str.startsWith(Constants.HTTPS)) { return false; } else { try { Intent parseUri = Intent.parseUri(str, 1); parseUri.setFlags(805306368); parseUri.addCategory("android.intent.category.BROWSABLE"); parseUri.setComponent(null); if (parseUri != null) { activity.startActivity(parseUri); } return true; } catch (Exception e) { e.printStackTrace(); return true; } } } }; public ValueCallback<Uri> d; public ValueCallback<Uri[]> e; WebChromeClient f = new WebChromeClient() { /* class com.sjm.sjmsdk.js.b.AnonymousClass2 */ public void onProgressChanged(WebView webView, int i) { super.onProgressChanged(webView, i); b.this.a.isFinishing(); } public void onReceivedTitle(WebView webView, String str) { if (str != null && !str.equals("")) { b.this.a.setTitle(str); } } @Override // android.webkit.WebChromeClient public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) { b.this.e = valueCallback; b.this.a(); return true; } }; /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a() { Intent intent = new Intent("android.intent.action.GET_CONTENT"); intent.addCategory("android.intent.category.OPENABLE"); intent.setType("image/*"); this.a.startActivityForResult(Intent.createChooser(intent, "Image Chooser"), 12); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private boolean a(Context context, Intent intent) { for (ResolveInfo resolveInfo : context.getPackageManager().queryIntentActivities(intent, 65536)) { if (resolveInfo.activityInfo.packageName.contains("com.android.browser")) { return true; } } return false; } public void a(Activity activity, WebView webView) { this.a = activity; this.b = webView; WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setAppCacheMaxSize(8388608); settings.setAllowFileAccess(true); settings.setAppCacheEnabled(true); settings.setAppCachePath(activity.getApplication().getCacheDir().getAbsolutePath()); settings.setDatabaseEnabled(true); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setTextZoom(100); settings.setCacheMode(2); settings.setAllowFileAccess(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setLoadsImagesAutomatically(true); settings.setDefaultTextEncodingName("utf-8"); settings.setBlockNetworkImage(false); settings.setUseWideViewPort(true); webView.setWebChromeClient(this.f); webView.setWebViewClient(this.c); webView.setDownloadListener(new DownloadListener() { /* class com.sjm.sjmsdk.js.b.AnonymousClass3 */ public void onDownloadStart(String str, String str2, String str3, String str4, long j) { Log.d("test", "onReceivedError.onDownloadStart=" + str); Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.addCategory("android.intent.category.BROWSABLE"); intent.setData(Uri.parse(str)); b bVar = b.this; if (bVar.a((b) bVar.a, (Context) intent)) { intent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); } b.this.a.startActivity(intent); } }); } }