xiaodi8 v1.0.0版本的 MD5 值为:6b857c57f508176c5ba1afb422bbb5a9
以下内容为反编译后的 WebViewUtils.java 源代码,内容仅作参考
package com.bslyun.app.browser;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import com.bslyun.app.activity.AboutActivity;
import com.bslyun.app.activity.MainActivity;
import com.bslyun.app.activity.WebActivity;
import com.bslyun.app.browser.local.LocalBrowser;
import com.bslyun.app.browser.x5.X5Browser;
import com.bslyun.app.d.a;
import com.bslyun.app.fragment.WebFragment;
import com.bslyun.app.modes.EventBusMessage;
import com.bslyun.app.utils.m;
import com.bslyun.app.utils.m0;
import com.bslyun.app.utils.y;
import com.luck.picture.lib.config.PictureMimeType;
import com.tencent.smtt.sdk.TbsVideoCacheTask;
import com.tencent.smtt.sdk.WebView;
import io.github.inflationx.calligraphy3.BuildConfig;
import java.io.File;
import java.util.ArrayList;
import org.greenrobot.eventbus.c;
public class WebViewUtils {
public static FragmentPopEvent fpe;
public static String mCameraFilePath;
public enum FragmentPopEvent {
JS_NAV,
BACK_GESTURE
}
public static void closeTopWindow(MainActivity mainActivity) {
fpe = FragmentPopEvent.JS_NAV;
if (mainActivity.getCurrentFragment().getChildFragmentManager().o0() > 0) {
mainActivity.getCurrentFragment().getChildFragmentManager().b1();
}
}
public static void closeTopWindowRefresh(MainActivity mainActivity) {
fpe = FragmentPopEvent.JS_NAV;
c.c().l(EventBusMessage.Factory.factory("pop_stack_with_reload"));
}
public static Intent createAlbumIntent(String str) {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType(str);
Intent intent2 = new Intent("android.intent.action.CHOOSER");
intent2.putExtra("android.intent.extra.INTENT", intent);
intent2.putExtra("android.intent.extra.TITLE", "Image Chooser");
return intent2;
}
public static Intent createCamcorderIntent() {
return new Intent("android.media.action.VIDEO_CAPTURE");
}
public static Intent createCameraIntent(Context context, ViewGroup viewGroup) {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
mCameraFilePath = getDiskCachePath(context) + "/browser-photos/" + System.currentTimeMillis() + PictureMimeType.JPG;
File file = new File(mCameraFilePath);
if (!file.exists()) {
file.getParentFile().mkdirs();
} else if (file.exists()) {
file.delete();
}
Uri fromFile = Uri.fromFile(file);
intent.putExtra("output", fromFile);
if (m0.Z(context)) {
LocalBrowser localBrowser = (LocalBrowser) viewGroup;
localBrowser.getLocalBrowserChromeClient().mCameraFilePath = mCameraFilePath;
localBrowser.getLocalBrowserChromeClient().cameraUri = fromFile;
} else {
X5Browser x5Browser = (X5Browser) viewGroup;
x5Browser.getX5BrowserChromeClient().mCameraFilePath = mCameraFilePath;
x5Browser.getX5BrowserChromeClient().cameraUri = fromFile;
}
return intent;
}
public static Intent createChooserIntent(Intent... intentArr) {
Intent intent = new Intent("android.intent.action.CHOOSER");
intent.putExtra("android.intent.extra.INITIAL_INTENTS", intentArr);
intent.putExtra("android.intent.extra.TITLE", "选择文件上传");
return intent;
}
public static Intent createDefaultOpenableIntent(Context context, ViewGroup viewGroup) {
mCameraFilePath = getDiskCachePath(context) + ("/browser-photos/" + System.currentTimeMillis() + PictureMimeType.JPG);
File file = new File(mCameraFilePath);
if (!file.exists()) {
file.getParentFile().mkdirs();
} else if (file.exists()) {
file.delete();
}
Uri fromFile = Uri.fromFile(file);
if (m0.Z(context)) {
LocalBrowser localBrowser = (LocalBrowser) viewGroup;
localBrowser.getLocalBrowserChromeClient().mCameraFilePath = mCameraFilePath;
localBrowser.getLocalBrowserChromeClient().cameraUri = fromFile;
} else {
X5Browser x5Browser = (X5Browser) viewGroup;
x5Browser.getX5BrowserChromeClient().mCameraFilePath = mCameraFilePath;
x5Browser.getX5BrowserChromeClient().cameraUri = fromFile;
}
ArrayList arrayList = new ArrayList();
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
for (ResolveInfo resolveInfo : context.getPackageManager().queryIntentActivities(intent, 0)) {
String str = resolveInfo.activityInfo.packageName;
Intent intent2 = new Intent(intent);
ActivityInfo activityInfo = resolveInfo.activityInfo;
intent2.setComponent(new ComponentName(activityInfo.packageName, activityInfo.name));
intent2.setPackage(str);
intent2.putExtra("output", fromFile);
arrayList.add(intent2);
}
Intent intent3 = new Intent("android.intent.action.GET_CONTENT");
intent3.addCategory("android.intent.category.OPENABLE");
intent3.setType("*/*");
Intent createChooser = Intent.createChooser(intent3, "file Chooser");
createChooser.putExtra("android.intent.extra.INITIAL_INTENTS", (Parcelable[]) arrayList.toArray(new Parcelable[0]));
return createChooser;
}
public static boolean createFragmentForUrl(Context context, WebView webView, String str, boolean z) {
WebView.HitTestResult hitTestResult;
if ((!a.f(context).x1 && !z) || (hitTestResult = webView.getHitTestResult()) == null || hitTestResult.getType() == 0 || !str.startsWith("http") || str.startsWith("https://wx.tenpay.com/")) {
return false;
}
EventBusMessage factory = EventBusMessage.Factory.factory("new_fragment");
factory.setObject(str);
c.c().l(factory);
return true;
}
public static Intent createOpenableIntent(String str) {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType(str);
return intent;
}
public static Intent createSoundRecorderIntent() {
return new Intent("android.provider.MediaStore.RECORD_SOUND");
}
public static boolean createX5FragmentForUrl(Context context, com.tencent.smtt.sdk.WebView webView, String str, boolean z) {
WebView.HitTestResult hitTestResult;
if ((!a.f(context).x1 && !z) || (hitTestResult = webView.getHitTestResult()) == null || hitTestResult.getType() == 0 || !str.startsWith("http") || str.startsWith("https://wx.tenpay.com/")) {
return false;
}
EventBusMessage factory = EventBusMessage.Factory.factory("new_fragment");
factory.setObject(str);
c.c().l(factory);
return true;
}
private static ValueCallback<Boolean> getDefaultIgnoreCallback() {
return new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean bool) {
}
};
}
public static String getDiskCachePath(Context context) {
if (!"mounted".equals(Environment.getExternalStorageState()) && Environment.isExternalStorageRemovable()) {
return context.getCacheDir().getPath();
}
return context.getExternalCacheDir().getPath();
}
public static void getFunction(MainActivity mainActivity, WebFragment webFragment, ViewGroup viewGroup, String str) {
String w;
a f2 = a.f(mainActivity);
str.hashCode();
char c2 = 65535;
switch (str.hashCode()) {
case 48:
if (str.equals("0")) {
c2 = 0;
break;
}
break;
case 49:
if (str.equals("1")) {
c2 = 1;
break;
}
break;
case 50:
if (str.equals("2")) {
c2 = 2;
break;
}
break;
case 51:
if (str.equals("3")) {
c2 = 3;
break;
}
break;
case 52:
if (str.equals("4")) {
c2 = 4;
break;
}
break;
case 53:
if (str.equals("5")) {
c2 = 5;
break;
}
break;
case 54:
if (str.equals("6")) {
c2 = 6;
break;
}
break;
case 55:
if (str.equals("7")) {
c2 = 7;
break;
}
break;
case 56:
if (str.equals("8")) {
c2 = '\b';
break;
}
break;
case 57:
if (str.equals("9")) {
c2 = '\t';
break;
}
break;
case 1568:
if (str.equals("11")) {
c2 = '\n';
break;
}
break;
case 1570:
if (str.equals("13")) {
c2 = 11;
break;
}
break;
case 1571:
if (str.equals("14")) {
c2 = '\f';
break;
}
break;
case 1572:
if (str.equals("15")) {
c2 = '\r';
break;
}
break;
case 1573:
if (str.equals("16")) {
c2 = 14;
break;
}
break;
}
switch (c2) {
case 0:
JavaScriptUtils.postJsInWebView(mainActivity, viewGroup, JavaScriptUtils.innerHtmlShare);
return;
case 1:
y.g(mainActivity, f2.T);
return;
case 2:
mainActivity.startActivity(new Intent(mainActivity, (Class<?>) AboutActivity.class));
return;
case 3:
y.d(mainActivity, viewGroup, 0);
return;
case 4:
webFragment.onAwakeOtherBrowser(webFragment.getUrl());
return;
case 5:
webFragment.goForward();
return;
case 6:
if (webFragment.canGoback()) {
webFragment.goBack();
return;
}
return;
case 7:
webFragment.reload();
return;
case '\b':
mainActivity.quit();
return;
case '\t':
if (mainActivity instanceof MainActivity) {
mainActivity.openLeftMenu();
return;
}
return;
case '\n':
if (TextUtils.isEmpty(f2.k1)) {
return;
}
if (!f2.k1.startsWith(com.tencent.smtt.sdk.WebView.SCHEME_TEL) && !f2.k1.startsWith("sms") && !f2.k1.startsWith("Mailto:")) {
if (f2.k1.startsWith("BSL.")) {
webFragment.postJS("javascript:(!function(){" + f2.k1 + "}())");
return;
}
if (f2.k1.startsWith("javascript:")) {
webFragment.postJS("javascript:(!function(){" + f2.k1 + "}())");
return;
}
return;
}
webFragment.postJS("window.location.href = '" + f2.k1 + "'");
return;
case 11:
if (com.bslyun.app.e.a.p != null) {
Intent intent = new Intent(mainActivity, (Class<?>) WebActivity.class);
intent.putExtra("titleText", com.bslyun.app.e.a.p.getTitle());
intent.putExtra(TbsVideoCacheTask.KEY_VIDEO_CACHE_PARAM_URL, com.bslyun.app.e.a.p.getUrl());
mainActivity.startActivity(intent);
}
new m(mainActivity, false);
return;
case '\f':
if (!TextUtils.isEmpty(f2.e0.a().e().get(webFragment.index).getUrl())) {
w = f2.e0.a().e().get(webFragment.index).getUrl();
} else {
w = !TextUtils.isEmpty(f2.e0.a().e().get(webFragment.index).w()) ? f2.e0.a().e().get(webFragment.index).w() : BuildConfig.FLAVOR;
}
if (TextUtils.isEmpty(w)) {
return;
}
webFragment.loadUrl(w);
return;
case '\r':
if (f2.x1 || f2.Q1) {
closeTopWindow(mainActivity);
return;
}
return;
case 14:
if (f2.x1 || f2.Q1) {
closeTopWindowRefresh(mainActivity);
return;
}
return;
default:
return;
}
}
private static com.tencent.smtt.sdk.ValueCallback<Boolean> getX5DefaultIgnoreCallback() {
return new com.tencent.smtt.sdk.ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean bool) {
}
};
}
public static void removeAllCookies(ValueCallback<Boolean> valueCallback) {
if (valueCallback == null) {
valueCallback = getDefaultIgnoreCallback();
}
if (Build.VERSION.SDK_INT < 21) {
CookieManager.getInstance().removeAllCookie();
syncCookie();
valueCallback.onReceiveValue(Boolean.valueOf(!CookieManager.getInstance().hasCookies()));
} else {
CookieManager.getInstance().removeAllCookies(valueCallback);
syncCookie();
}
}
public static void removeAllX5Cookies(com.tencent.smtt.sdk.ValueCallback<Boolean> valueCallback) {
if (valueCallback == null) {
valueCallback = getX5DefaultIgnoreCallback();
}
if (Build.VERSION.SDK_INT < 21) {
com.tencent.smtt.sdk.CookieManager.getInstance().removeAllCookie();
syncX5Cookie();
valueCallback.onReceiveValue(Boolean.valueOf(!com.tencent.smtt.sdk.CookieManager.getInstance().hasCookies()));
} else {
com.tencent.smtt.sdk.CookieManager.getInstance().removeAllCookies(valueCallback);
syncX5Cookie();
}
}
public static void removeExpiredCookies() {
CookieManager cookieManager = CookieManager.getInstance();
if (cookieManager != null) {
cookieManager.removeExpiredCookie();
syncCookie();
}
}
public static void removeExpiredX5Cookies() {
com.tencent.smtt.sdk.CookieManager cookieManager = com.tencent.smtt.sdk.CookieManager.getInstance();
if (cookieManager != null) {
cookieManager.removeExpiredCookie();
syncX5Cookie();
}
}
public static void syncCookie() {
if (Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().flush();
} else {
CookieSyncManager.getInstance().sync();
}
}
public static void syncCookies(String str) {
CookieManager cookieManager = CookieManager.getInstance();
String cookie = cookieManager.getCookie(str);
if (TextUtils.isEmpty(cookie)) {
return;
}
cookieManager.setCookie(str, cookie);
}
public static void syncX5Cookie() {
if (Build.VERSION.SDK_INT >= 21) {
com.tencent.smtt.sdk.CookieManager.getInstance().flush();
} else {
com.tencent.smtt.sdk.CookieSyncManager.getInstance().sync();
}
}
public static void syncX5Cookies(String str) {
com.tencent.smtt.sdk.CookieManager cookieManager = com.tencent.smtt.sdk.CookieManager.getInstance();
String cookie = cookieManager.getCookie(str);
if (TextUtils.isEmpty(cookie)) {
return;
}
cookieManager.setCookie(str, cookie);
}
}