鑫垚影视 v20.42版本的 MD5 值为:e3822d25ef47121f1770bb4806abacfe
以下内容为反编译后的 DWebView.java 源代码,内容仅作参考
package com.sniffer.xwebview.base.dwebview;
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.URLUtil;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.Toast;
import com.movie.heaven.widget.expandable.ExpandableTextView;
import com.sniffer.xwebview.R;
import com.sniffer.xwebview.bridge.webview.BridgeWebView;
import com.sniffer.xwebview.bridge.webview.BridgeWebViewCallBack;
import com.sniffer.xwebview.util.SnifferLogUtil;
import com.sniffer.xwebview.util.webutil.JavaScriptUtil;
import com.sniffer.xwebview.util.webutil.XWebConstants;
import com.sniffer.xwebview.util.webutil.XWebSetting;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class DWebView extends BridgeWebView {
private static final String FILE = "file://";
private static final String HTTP = "http://";
private static final String HTTPS = "https://";
private static final String TAG = "DWebView";
private boolean filterAppScheme;
private boolean filterDownLoad;
private boolean filterImage;
private boolean filterJsAlert;
public Context mContext;
public FrameLayout mWebViewVideoFragment;
public boolean needClearHistory;
private boolean showLongClick;
private boolean showProgress;
public BridgeWebViewCallBack webViewCallBack;
private XWebSetting xWebSetting;
public DWebView(Context context, AttributeSet attributeSet, XWebSetting xWebSetting) {
super(context, attributeSet);
this.needClearHistory = false;
if (xWebSetting != null) {
this.xWebSetting = xWebSetting;
}
init(context, attributeSet);
}
public static String converKeywordLoadOrSearch(String str) {
return converKeywordLoadOrSearch(str, "http://www.baidu.com/s?wd={keyword}&ie=UTF-8");
}
private void longClick() {
SnifferLogUtil.e(TAG, "longClick: ");
setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
WebView.HitTestResult hitTestResult = DWebView.this.getHitTestResult();
if (hitTestResult == null) {
return false;
}
int type = hitTestResult.getType();
String extra = hitTestResult.getExtra();
if (type != 5) {
if (type == 7) {
if (DWebView.this.xWebSetting.isShowLongClick() && extra != null && URLUtil.isValidUrl(extra)) {
JavaScriptUtil.onLinkSelected((Activity) DWebView.this.getContext(), DWebView.this, extra);
}
return true;
}
if (type != 8) {
return false;
}
}
if (DWebView.this.xWebSetting.isShowLongClick() && extra != null && URLUtil.isValidUrl(extra)) {
JavaScriptUtil.onImgSelected((Activity) DWebView.this.getContext(), DWebView.this, extra);
}
return true;
}
});
}
public void applySetting() {
SnifferLogUtil.e(TAG, "applySetting: ");
DWebDefaultSettingManager.settings(this, getXWebSetting());
setWebViewClient(new MyWebViewClient(this.mContext, this));
setWebChromeClient(new MyWebChromeClient(this.mContext, this));
}
public XWebSetting getXWebSetting() {
if (this.xWebSetting == null) {
this.xWebSetting = new XWebSetting();
}
return this.xWebSetting;
}
public void init(Context context, AttributeSet attributeSet) {
SnifferLogUtil.e(TAG, "init AttributeSet: ");
this.mContext = context;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.DWebView);
this.filterDownLoad = obtainStyledAttributes.getBoolean(R.styleable.DWebView_dwebview_filter_download, false);
this.filterAppScheme = obtainStyledAttributes.getBoolean(R.styleable.DWebView_dwebview_filter_appscheme, false);
this.filterImage = obtainStyledAttributes.getBoolean(R.styleable.DWebView_dwebview_filter_image, false);
this.filterJsAlert = obtainStyledAttributes.getBoolean(R.styleable.DWebView_dwebview_filter_jsalert, false);
this.showProgress = obtainStyledAttributes.getBoolean(R.styleable.DWebView_dwebview_show_progress, true);
this.showLongClick = obtainStyledAttributes.getBoolean(R.styleable.DWebView_dwebview_show_long_click, true);
obtainStyledAttributes.recycle();
longClick();
}
public void loadStringHtml(String str) {
SnifferLogUtil.e(TAG, "loadStringHtml: ");
loadDataWithBaseURL(null, str, "text/html", "utf-8", null);
}
public String loadUrl(String str, boolean z) {
SnifferLogUtil.e(TAG, "loadUrl: " + z + "--" + str);
stopLoading();
if (z) {
String converKeywordLoadOrSearch = converKeywordLoadOrSearch(str);
loadUrl(converKeywordLoadOrSearch);
return converKeywordLoadOrSearch;
}
loadUrl(str);
return str;
}
public void registerdWebViewCallBack(BridgeWebViewCallBack bridgeWebViewCallBack) {
this.webViewCallBack = bridgeWebViewCallBack;
}
public void setVideoFragment(FrameLayout frameLayout) {
this.mWebViewVideoFragment = frameLayout;
}
public void setXWebSetting(XWebSetting xWebSetting) {
if (xWebSetting == null) {
xWebSetting = new XWebSetting();
}
if (!xWebSetting.isFilterDownLoad()) {
xWebSetting.setFilterDownLoad(this.filterDownLoad);
}
if (!xWebSetting.isFilterScheme()) {
xWebSetting.setFilterScheme(this.filterAppScheme);
}
if (!xWebSetting.isFilterImage()) {
xWebSetting.setFilterImage(this.filterImage);
}
if (!xWebSetting.isFilterJsAlert()) {
xWebSetting.setFilterJsAlert(this.filterJsAlert);
}
if (xWebSetting.isShowProgress()) {
xWebSetting.setShowProgress(this.showProgress);
}
if (xWebSetting.isShowLongClick()) {
xWebSetting.setShowLongClick(this.showLongClick);
}
this.xWebSetting = xWebSetting;
SnifferLogUtil.e(TAG, "setXWebSetting: " + this.xWebSetting.toString());
}
public void switchUserAgent() {
SnifferLogUtil.e(TAG, "switchUserAgent: ");
if (!getSettings().getUserAgentString().equals(XWebConstants.USERAGENT_WINDOWS)) {
getSettings().setUserAgentString(XWebConstants.USERAGENT_WINDOWS);
Toast.makeText(this.mContext, "已切换电脑端UserAgent", 0).show();
} else {
getSettings().setUserAgentString(XWebConstants.USERAGENT_MOBILE);
Toast.makeText(this.mContext, "已切换移动端UserAgent", 0).show();
}
loadUrl(getUrl(), false);
}
public static String converKeywordLoadOrSearch(String str, String str2) {
if (TextUtils.isEmpty(str)) {
SnifferLogUtil.e(TAG, "url null");
return "about:blank";
}
String trim = str.trim();
if (trim.startsWith("www.")) {
trim = HTTP + trim;
} else if (trim.startsWith("ftp.")) {
trim = "ftp://" + trim;
}
boolean contains = trim.contains(".");
boolean z = TextUtils.isDigitsOnly(trim.replace(".", "")) && trim.replace(".", "").length() >= 4 && trim.contains(".");
boolean contains2 = trim.contains("about:");
boolean z2 = trim.startsWith("ftp://") || trim.startsWith(HTTP) || trim.startsWith(FILE) || trim.startsWith(HTTPS) || z;
boolean z3 = (trim.contains(ExpandableTextView.Space) || !contains) && !contains2;
if (z && (!trim.startsWith(HTTP) || !trim.startsWith(HTTPS))) {
trim = HTTP + trim;
}
if (z3) {
try {
trim = URLEncoder.encode(trim, "UTF-8");
} catch (UnsupportedEncodingException e2) {
e2.printStackTrace();
}
return str2.replace("{keyword}", trim);
}
if (z2) {
return trim;
}
return HTTP + trim;
}
public DWebView(Context context, XWebSetting xWebSetting) {
super(context);
this.needClearHistory = false;
if (xWebSetting != null) {
this.xWebSetting = xWebSetting;
}
init(context, null);
}
public DWebView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.needClearHistory = false;
init(context, attributeSet);
}
public DWebView(Context context) {
super(context);
this.needClearHistory = false;
init(context, null);
}
}