正在查看: Top浏览器 v4.6.16 应用的 YaWebView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Top浏览器 v4.6.16 应用的 YaWebView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.pocket.topbrowser.browser.view.webview;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.webkit.CookieManager;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.AbsoluteLayout;
import androidx.core.view.ViewGroupKt;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import c.t.a.i.y;
import c.t.a.i.z;
import c.t.a.p.a;
import c.t.a.u.a;
import c.t.a.w.b0;
import c.t.a.w.r0;
import c.t.c.j.b1.k0;
import c.t.c.j.g1.x;
import c.t.c.j.r1.z.r;
import c.t.c.j.r1.z.v;
import com.pocket.common.dialog.list.ListDialog;
import com.pocket.common.view.video.TopVideoController;
import com.pocket.common.view.video.TopVideoView;
import com.pocket.topbrowser.browser.R$attr;
import com.pocket.topbrowser.browser.R$string;
import com.pocket.topbrowser.browser.view.webview.YaWebView;
import com.umeng.commonsdk.statistics.SdkVersion;
import h.i0.t;
import h.u;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.Objects;
import org.adblockplus.libadblockplus.android.settings.Utils;
import org.adblockplus.libadblockplus.android.webview.AdblockWebView;
public class YaWebView extends AdblockWebView implements a.c {
private static final String HEADER_DNT = "DNT";
public static final String HEADER_REQUESTED_WITH = "X-Requested-with";
private static final String HEADER_SAVE_DATA = "SAVE_DATA";
public static final String HEADER_WAP_PROFILE = "X-Wap-Profile";
private c.t.c.j.r1.z.r browserController;
private final GestureDetector gestureDetector;
private boolean invertPage;
private boolean isIncognito;
private boolean isShow;
private MotionEvent lastEvent;
private e mOnScrollChangeListener;
private final float maxFling;
private final Paint paint;
private final ArrayMap<String, String> requestHeaders;
private final f touchListener;
private final g webViewClickHandler;
private final h webViewHandler;
public static final b Companion = new b(null);
private static final int API = Build.VERSION.SDK_INT;
private static final int SCROLL_UP_THRESHOLD = c.h.b.o.h.a(30.0f);
private static final float[] negativeColorArray = {-1.0f, 0.0f, 0.0f, 0.0f, 255.0f, 0.0f, -1.0f, 0.0f, 0.0f, 255.0f, 0.0f, 0.0f, -1.0f, 0.0f, 255.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};
private static final float[] increaseContrastColorArray = {2.0f, 0.0f, 0.0f, 0.0f, -160.0f, 0.0f, 2.0f, 0.0f, 0.0f, -160.0f, 0.0f, 0.0f, 2.0f, 0.0f, -160.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};
public static final class a extends TopWebChromeClient {
public a() {
}
@Override
public void onHideCustomView() {
c.t.c.j.r1.z.r browserController = YaWebView.this.getBrowserController();
if (browserController == null) {
return;
}
browserController.onHideCustomView();
}
@Override
public void onProgressChanged(WebView webView, int i2) {
super.onProgressChanged(webView, i2);
c.t.c.j.r1.z.r browserController = YaWebView.this.getBrowserController();
if (browserController == null) {
return;
}
browserController.onProgressChanged(i2);
}
@Override
public void onReceivedIcon(WebView webView, Bitmap bitmap) {
c.t.c.j.r1.z.r browserController;
super.onReceivedIcon(webView, bitmap);
if (bitmap == null || (browserController = YaWebView.this.getBrowserController()) == null) {
return;
}
browserController.onReceivedIcon(bitmap);
}
@Override
public void onReceivedTitle(WebView webView, String str) {
super.onReceivedTitle(webView, str);
String url = webView == null ? null : webView.getUrl();
if (url == null || url.length() == 0) {
if (str == null || str.length() == 0) {
return;
}
}
c.t.c.j.r1.z.r browserController = YaWebView.this.getBrowserController();
if (browserController == null) {
return;
}
String url2 = webView != null ? webView.getUrl() : null;
h.b0.d.l.d(url2);
h.b0.d.l.e(url2, "view?.url!!");
h.b0.d.l.d(str);
browserController.onReceivedTitle(url2, str);
}
@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
h.b0.d.l.f(view, "view");
h.b0.d.l.f(customViewCallback, "callback");
c.t.c.j.r1.z.r browserController = YaWebView.this.getBrowserController();
if (browserController == null) {
return;
}
browserController.onShowCustomView(view, customViewCallback);
}
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
h.b0.d.l.f(webView, "webView");
h.b0.d.l.f(valueCallback, "filePathCallback");
h.b0.d.l.f(fileChooserParams, "fileChooserParams");
c.t.c.j.r1.z.r browserController = YaWebView.this.getBrowserController();
if (browserController == null) {
return true;
}
browserController.showFileChooser(valueCallback);
return true;
}
@Override
public void onShowCustomView(View view, int i2, WebChromeClient.CustomViewCallback customViewCallback) {
super.onShowCustomView(view, i2, customViewCallback);
}
}
public static final class b {
public b() {
}
public b(h.b0.d.g gVar) {
this();
}
}
public final class c extends GestureDetector.SimpleOnGestureListener {
public boolean a;
public final YaWebView b;
public c(YaWebView yaWebView) {
h.b0.d.l.f(yaWebView, "this$0");
this.b = yaWebView;
this.a = true;
}
@Override
public boolean onDoubleTapEvent(MotionEvent motionEvent) {
h.b0.d.l.f(motionEvent, "e");
this.a = false;
return false;
}
@Override
public boolean onDown(MotionEvent motionEvent) {
h.b0.d.l.f(motionEvent, "e");
return super.onDown(motionEvent);
}
@Override
public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f2, float f3) {
c.t.c.j.r1.z.r browserController;
h.b0.d.l.f(motionEvent, "e1");
h.b0.d.l.f(motionEvent2, "e2");
int i2 = (int) ((100 * f3) / this.b.maxFling);
if (i2 < -10) {
c.t.c.j.r1.z.r browserController2 = this.b.getBrowserController();
if (browserController2 != null) {
browserController2.hideActionBar();
}
} else if (i2 > 15 && (browserController = this.b.getBrowserController()) != null) {
browserController.showActionBar();
}
return super.onFling(motionEvent, motionEvent2, f2, f3);
}
@Override
public void onLongPress(MotionEvent motionEvent) {
h.b0.d.l.f(motionEvent, "e");
String url = this.b.getUrl();
if (url != null && t.L(url, "https://nav.topc1.com", false, 2, null)) {
return;
}
String url2 = this.b.getUrl();
if (!(url2 != null && t.L(url2, "http://nav.topc1.com", false, 2, null)) && this.a) {
this.b.lastEvent = motionEvent;
Message obtainMessage = this.b.webViewHandler.obtainMessage();
h.b0.d.l.e(obtainMessage, "webViewHandler.obtainMessage()");
obtainMessage.setTarget(this.b.webViewHandler);
this.b.requestFocusNodeHref(obtainMessage);
}
}
@Override
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f2, float f3) {
h.b0.d.l.f(motionEvent, "e1");
h.b0.d.l.f(motionEvent2, "e2");
return super.onScroll(motionEvent, motionEvent2, f2, f3);
}
@Override
public void onShowPress(MotionEvent motionEvent) {
h.b0.d.l.f(motionEvent, "e");
this.a = true;
}
}
public static final class d implements ActionMode.Callback {
public final ActionMode.Callback a;
public d(ActionMode.Callback callback) {
h.b0.d.l.f(callback, "callback");
this.a = callback;
}
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
if (menuItem != null) {
CharSequence title = menuItem.getTitle();
if (!(title == null || title.length() == 0)) {
if (t.L(menuItem.getTitle().toString(), "搜索", false, 2, null) || t.L(menuItem.getTitle().toString(), "search", false, 2, null)) {
return true;
}
return this.a.onActionItemClicked(actionMode, menuItem);
}
}
return this.a.onActionItemClicked(actionMode, menuItem);
}
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
return this.a.onCreateActionMode(actionMode, menu);
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
this.a.onDestroyActionMode(actionMode);
}
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
return this.a.onPrepareActionMode(actionMode, menu);
}
}
public interface e {
void a(int i2, int i3, int i4, int i5);
}
public final class f implements View.OnTouchListener {
public float a;
public final YaWebView b;
public f(YaWebView yaWebView) {
h.b0.d.l.f(yaWebView, "this$0");
this.b = yaWebView;
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
h.b0.d.l.f(view, "view");
h.b0.d.l.f(motionEvent, "event");
if (!view.hasFocus()) {
view.requestFocus();
}
int action = motionEvent.getAction();
if (action == 0) {
this.a = motionEvent.getRawY();
} else if (action == 2) {
float rawY = motionEvent.getRawY() - this.a;
if (rawY >= 0.0f) {
if ((view.getScrollY() == 0 || rawY >= YaWebView.SCROLL_UP_THRESHOLD) && !this.b.isShow) {
this.b.isShow = true;
c.t.c.j.r1.z.r browserController = this.b.getBrowserController();
if (browserController != null) {
browserController.showActionBar();
}
}
} else if (rawY < 0.0f && Math.abs(rawY) >= YaWebView.SCROLL_UP_THRESHOLD && this.b.isShow) {
this.b.isShow = false;
c.t.c.j.r1.z.r browserController2 = this.b.getBrowserController();
if (browserController2 != null) {
browserController2.hideActionBar();
}
}
}
return this.b.gestureDetector.onTouchEvent(motionEvent);
}
}
public static final class g extends Handler {
public final WeakReference<YaWebView> a;
public g(YaWebView yaWebView) {
super(Looper.getMainLooper());
h.b0.d.l.f(yaWebView, "view");
this.a = new WeakReference<>(yaWebView);
}
@Override
public void handleMessage(Message message) {
h.b0.d.l.f(message, "msg");
super.handleMessage(message);
String string = message.getData().getString(Utils.SUBSCRIPTION_FIELD_URL);
YaWebView yaWebView = this.a.get();
if (yaWebView == null) {
return;
}
yaWebView.clickPage(string);
}
}
public static final class h extends Handler {
public final WeakReference<YaWebView> a;
public h(YaWebView yaWebView) {
super(Looper.getMainLooper());
h.b0.d.l.f(yaWebView, "view");
this.a = new WeakReference<>(yaWebView);
}
@Override
public void handleMessage(Message message) {
h.b0.d.l.f(message, "msg");
super.handleMessage(message);
String string = message.getData().getString(Utils.SUBSCRIPTION_FIELD_URL);
YaWebView yaWebView = this.a.get();
if (yaWebView == null) {
return;
}
yaWebView.longClickPage(string);
}
}
public static final class i extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public i(String str) {
super(0);
this.a = str;
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
c.o.a.a.a("new_tab").b(new c.t.a.j.a.a("type_new_window_open", this.a));
}
}
public static final class j extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public j(String str) {
super(0);
this.a = str;
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
c.o.a.a.a("new_tab").b(new c.t.a.j.a.a("type_background_open", this.a));
}
}
public static final class k extends h.b0.d.m implements h.b0.c.a<u> {
public k() {
super(0);
}
public static final void a(YaWebView yaWebView) {
h.b0.d.l.f(yaWebView, "this$0");
yaWebView.setOnTouchListener(yaWebView.touchListener);
yaWebView.loadUrl("javascript:(function(){\n htmlInterface.log(\"结束自由复制\"); const arr = window.document.getElementsByTagName('a');\n for (let i = 0; i < arr.length; i++) {\n htmlInterface.log(\"循环\"); let tag = arr[i];\n if (tag != null && tag.tagName != null){\n tag = tag.tagName.toLocaleLowerCase();\n if (tag != null && tag ==='a'){\n const ele = arr[i];\n const hed = ele.getAttribute('copyhref');\n if (hed){\n ele.removeAttribute('copyhref');\n ele.setAttribute('href', hed);\n }\n }\n }\n }\n htmlInterface.log(\"END_SELECT_TEXT\");})()");
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
MotionEvent motionEvent = YaWebView.this.lastEvent;
if (motionEvent == null) {
return;
}
final YaWebView yaWebView = YaWebView.this;
yaWebView.loadUrl("javascript:(function(){\n htmlInterface.log(\"开始自由复制\"); let arr = window.document.getElementsByTagName('a');\n for (let i = 0; i < arr.length; i++) {\n htmlInterface.log(\"循环\"); let tag = arr[i];\n if (tag != null && tag.tagName != null){\n tag = tag.tagName.toLocaleLowerCase();\n if (tag != null && tag ==='a'){\n const ele = arr[i];\n const hed = ele.href;\n if (hed){\n ele.removeAttribute('href');\n ele.setAttribute('copyhref', hed);\n }\n }\n }\n }\n htmlInterface.log(\"START_SELECT_TEXT\");})()");
yaWebView.setOnTouchListener(null);
c.h.b.n.b g2 = c.h.b.n.b.g();
float x = motionEvent.getX();
float y = motionEvent.getY();
h.b0.d.l.e(yaWebView.getContext(), com.umeng.analytics.pro.d.R);
g2.f(new v(x, y + c.t.a.k.a.e(r5) + c.t.a.k.f.a(60), true));
c.h.b.o.i.c(new Runnable() {
@Override
public final void run() {
YaWebView.k.a(YaWebView.this);
}
}, 1000L);
}
}
public static final class l extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public l(String str) {
super(0);
this.a = str;
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
Activity i2 = c.h.b.o.a.h().i(true);
if (i2 == null) {
return;
}
i2.startActivity(b0.b(this.a));
}
}
public static final class m extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public m(String str) {
super(0);
this.a = str;
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
c.t.a.w.p.a(this.a);
c.h.a.e.d.c(r0.a.c(R$string.browser_copy_tips));
}
}
public static final class n extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public final YaWebView b;
public n(String str, YaWebView yaWebView) {
super(0);
this.a = str;
this.b = yaWebView;
}
public static final void a(String str, YaWebView yaWebView) {
h.b0.d.l.f(str, "$picUrl");
h.b0.d.l.f(yaWebView, "this$0");
try {
File a = c.h.b.o.e.a(str, "/storage/emulated/0/Download/");
if (a != null) {
c.t.a.i.e0.b bVar = c.t.a.i.e0.b.a;
Context context = yaWebView.getContext();
h.b0.d.l.e(context, com.umeng.analytics.pro.d.R);
bVar.b(context, a);
c.h.b.o.i.b(new Runnable() {
@Override
public final void run() {
YaWebView.n.b();
}
});
}
} catch (IOException e2) {
e2.printStackTrace();
}
}
public static final void b() {
c.h.a.e.d.c("下载完成");
}
public static final void e(String str, String str2, Throwable th) {
h.b0.d.l.f(str, "$picUrl");
if (TextUtils.isEmpty(str2)) {
c.h.a.e.d.c("下载失败");
return;
}
z zVar = new z();
zVar.m(c.t.a.w.z.a());
zVar.n("/storage/emulated/0/Download/");
h.b0.d.l.e(str2, "fileName");
zVar.l(h.i0.s.A(h.i0.s.A(h.i0.s.A(str2, " ", "", false, 4, null), "\\u3000", "", false, 4, null), "\t", "", false, 4, null));
zVar.p(str);
y.r().h(zVar);
c.h.a.e.d.c("开始下载,请在下载管理查看");
c.h.b.c.a.a("download_update").h(0);
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
if (!h.i0.s.G(this.a, "data:image", false, 2, null)) {
d.b.a.b.v<String> f2 = new x(this.a).a().k(d.b.a.i.a.c()).f(d.b.a.a.b.b.b());
final String str = this.a;
f2.g(new d.b.a.e.b() {
@Override
public final void a(Object obj, Object obj2) {
YaWebView.n.e(str, (String) obj, (Throwable) obj2);
}
});
return;
}
FragmentActivity i2 = c.h.b.o.a.h().i(true);
Objects.requireNonNull(i2, "null cannot be cast to non-null type androidx.fragment.app.FragmentActivity");
if (i2.getSupportFragmentManager().isStateSaved()) {
return;
}
c.h.b.n.b g2 = c.h.b.n.b.g();
final String str2 = this.a;
final YaWebView yaWebView = this.b;
g2.f(new Runnable() {
@Override
public final void run() {
YaWebView.n.a(str2, yaWebView);
}
});
}
}
public static final class o extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public o(String str) {
super(0);
this.a = str;
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
c.o.a.a.a("new_tab").b(new c.t.a.j.a.a("type_new_window_open", this.a));
}
}
public static final class p extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public p(String str) {
super(0);
this.a = str;
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
c.o.a.a.a("new_tab").b(new c.t.a.j.a.a("type_background_open", this.a));
}
}
public static final class q extends h.b0.d.m implements h.b0.c.a<u> {
public q() {
super(0);
}
public static final void a(YaWebView yaWebView) {
h.b0.d.l.f(yaWebView, "this$0");
yaWebView.setOnTouchListener(yaWebView.touchListener);
yaWebView.loadUrl("javascript:(function(){\n htmlInterface.log(\"结束自由复制\"); const arr = window.document.getElementsByTagName('a');\n for (let i = 0; i < arr.length; i++) {\n htmlInterface.log(\"循环\"); let tag = arr[i];\n if (tag != null && tag.tagName != null){\n tag = tag.tagName.toLocaleLowerCase();\n if (tag != null && tag ==='a'){\n const ele = arr[i];\n const hed = ele.getAttribute('copyhref');\n if (hed){\n ele.removeAttribute('copyhref');\n ele.setAttribute('href', hed);\n }\n }\n }\n }\n htmlInterface.log(\"END_SELECT_TEXT\");})()");
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
MotionEvent motionEvent = YaWebView.this.lastEvent;
if (motionEvent == null) {
return;
}
final YaWebView yaWebView = YaWebView.this;
yaWebView.loadUrl("javascript:(function(){\n htmlInterface.log(\"开始自由复制\"); let arr = window.document.getElementsByTagName('a');\n for (let i = 0; i < arr.length; i++) {\n htmlInterface.log(\"循环\"); let tag = arr[i];\n if (tag != null && tag.tagName != null){\n tag = tag.tagName.toLocaleLowerCase();\n if (tag != null && tag ==='a'){\n const ele = arr[i];\n const hed = ele.href;\n if (hed){\n ele.removeAttribute('href');\n ele.setAttribute('copyhref', hed);\n }\n }\n }\n }\n htmlInterface.log(\"START_SELECT_TEXT\");})()");
yaWebView.setOnTouchListener(null);
c.h.b.n.b g2 = c.h.b.n.b.g();
float x = motionEvent.getX();
float y = motionEvent.getY();
h.b0.d.l.e(yaWebView.getContext(), com.umeng.analytics.pro.d.R);
g2.f(new v(x, y + c.t.a.k.a.e(r5) + c.t.a.k.f.a(60), true));
c.h.b.o.i.c(new Runnable() {
@Override
public final void run() {
YaWebView.q.a(YaWebView.this);
}
}, 1000L);
}
}
public static final class r extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public r(String str) {
super(0);
this.a = str;
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
c.h.b.o.b.b().startActivity(b0.b(this.a));
}
}
public static final class s extends h.b0.d.m implements h.b0.c.a<u> {
public final String a;
public s(String str) {
super(0);
this.a = str;
}
@Override
public u invoke() {
invoke2();
return u.a;
}
public final void invoke2() {
c.t.a.w.p.a(this.a);
c.h.a.e.d.c(r0.a.c(R$string.browser_copy_tips));
}
}
public YaWebView(Context context) {
this(context, null, 0, 6, null);
h.b0.d.l.f(context, com.umeng.analytics.pro.d.R);
}
public YaWebView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0, 4, null);
h.b0.d.l.f(context, com.umeng.analytics.pro.d.R);
}
public YaWebView(Context context, AttributeSet attributeSet, int i2, int i3, h.b0.d.g gVar) {
this(context, (i3 & 2) != 0 ? null : attributeSet, (i3 & 4) != 0 ? 0 : i2);
}
public final void clickPage(String str) {
c.t.c.j.r1.z.r rVar = this.browserController;
if (rVar == null) {
return;
}
r.a.a(rVar, str, null, 2, null);
}
private final ViewParent findSwipeRefreshLayout(View view) {
ViewParent parent = view.getParent();
return (parent == 0 || (parent instanceof SwipeRefreshLayout) || !(parent instanceof View)) ? parent : findSwipeRefreshLayout((View) parent);
}
private final String getUserAgent() {
String userAgentString = getSettings().getUserAgentString();
return userAgentString == null ? "" : userAgentString;
}
private final void initializeSettings() {
WebSettings settings = getSettings();
settings.setMediaPlaybackRequiresUserGesture(true);
settings.setUserAgentString(c.t.c.j.q1.p.a.a.D());
int i2 = API;
if (i2 >= 21 && !isIncognito()) {
settings.setMixedContentMode(2);
} else if (i2 >= 21) {
settings.setMixedContentMode(1);
}
if (!isIncognito() || c.t.c.j.r1.z.t.a(c.t.c.j.r1.z.s.FULL_INCOGNITO)) {
settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true);
settings.setDatabaseEnabled(true);
settings.setCacheMode(-1);
} else {
settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(false);
settings.setDatabaseEnabled(false);
settings.setCacheMode(2);
}
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true);
settings.setAllowFileAccessFromFileURLs(false);
settings.setAllowUniversalAccessFromFileURLs(false);
c.h.b.o.i.c(new Runnable() {
@Override
public final void run() {
YaWebView.m45initializeSettings$lambda1(YaWebView.this);
}
}, 20L);
}
public static final void m45initializeSettings$lambda1(YaWebView yaWebView) {
h.b0.d.l.f(yaWebView, "this$0");
a.b bVar = c.t.a.u.a.a;
if (bVar.b()) {
WebSettings settings = yaWebView.getSettings();
h.b0.d.l.e(settings, "settings");
bVar.d(settings, 2);
} else {
WebSettings settings2 = yaWebView.getSettings();
h.b0.d.l.e(settings2, "settings");
bVar.d(settings2, 0);
}
}
public final void longClickPage(String str) {
WebView.HitTestResult hitTestResult = getHitTestResult();
h.b0.d.l.e(hitTestResult, "hitTestResult");
String extra = hitTestResult.getExtra();
if (str == null) {
if (extra != null) {
if (hitTestResult.getType() == 8 || hitTestResult.getType() == 5) {
showLongPressImageDialog(extra, extra);
return;
} else {
showLongPressLinkDialog(extra);
return;
}
}
return;
}
if (hitTestResult.getType() != 8 && hitTestResult.getType() != 5) {
showLongPressLinkDialog(str);
} else if (extra != null) {
showLongPressImageDialog(str, extra);
} else {
showLongPressLinkDialog(str);
}
}
private final void setColorMode(int i2) {
this.invertPage = false;
if (i2 == 0) {
this.paint.setColorFilter(null);
setNormalRendering();
this.invertPage = false;
return;
}
if (i2 == 1) {
this.paint.setColorFilter(new ColorMatrixColorFilter(negativeColorArray));
setHardwareRendering();
this.invertPage = true;
return;
}
if (i2 == 2) {
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0.0f);
this.paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
setHardwareRendering();
return;
}
if (i2 != 3) {
if (i2 != 4) {
return;
}
this.paint.setColorFilter(new ColorMatrixColorFilter(increaseContrastColorArray));
setHardwareRendering();
return;
}
ColorMatrix colorMatrix2 = new ColorMatrix();
colorMatrix2.set(negativeColorArray);
ColorMatrix colorMatrix3 = new ColorMatrix();
colorMatrix3.setSaturation(0.0f);
ColorMatrix colorMatrix4 = new ColorMatrix();
colorMatrix4.setConcat(colorMatrix2, colorMatrix3);
this.paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix4));
setHardwareRendering();
this.invertPage = true;
}
private final void setHardwareRendering() {
setLayerType(2, this.paint);
}
private final void setNormalRendering() {
setLayerType(0, null);
}
private final void showLongPressImageDialog(String str, String str2) {
ListDialog.a aVar = new ListDialog.a();
r0 r0Var = r0.a;
ListDialog d2 = aVar.a(r0Var.c(R$string.browser_open_new_tab), new i(str)).a(r0Var.c(R$string.browser_open_background_tab), new j(str)).a(r0Var.c(R$string.browser_free_copy), new k()).a(r0Var.c(R$string.browser_share), new l(str)).a(r0Var.c(R$string.browser_copy_link), new m(str)).a(r0Var.c(R$string.browser_download_image), new n(str2, this)).d();
if (getContext() instanceof FragmentActivity) {
FragmentActivity context = getContext();
Objects.requireNonNull(context, "null cannot be cast to non-null type androidx.fragment.app.FragmentActivity");
d2.q(context.getSupportFragmentManager());
}
}
private final void showLongPressLinkDialog(String str) {
ListDialog.a aVar = new ListDialog.a();
r0 r0Var = r0.a;
ListDialog d2 = aVar.a(r0Var.c(R$string.browser_open_new_tab), new o(str)).a(r0Var.c(R$string.browser_open_background_tab), new p(str)).a(r0Var.c(R$string.browser_free_copy), new q()).a(r0Var.c(R$string.browser_share), new r(str)).a(r0Var.c(R$string.browser_copy_link), new s(str)).d();
if (getContext() instanceof FragmentActivity) {
FragmentActivity context = getContext();
Objects.requireNonNull(context, "null cannot be cast to non-null type androidx.fragment.app.FragmentActivity");
d2.q(context.getSupportFragmentManager());
} else if (getContext() instanceof Fragment) {
Fragment context2 = getContext();
Objects.requireNonNull(context2, "null cannot be cast to non-null type androidx.fragment.app.Fragment");
d2.q(context2.getChildFragmentManager());
}
}
public void _$_clearFindViewByIdCache() {
}
public final c.t.c.j.r1.z.r getBrowserController() {
return this.browserController;
}
public final boolean getInvertPage() {
return this.invertPage;
}
public final e getMOnScrollChangeListener() {
return this.mOnScrollChangeListener;
}
public final ArrayMap<String, String> getRequestHeaders$browser_release() {
return this.requestHeaders;
}
public final TopVideoView getVideoView() {
for (TopVideoView topVideoView : ViewGroupKt.getChildren(this)) {
if (topVideoView instanceof TopVideoView) {
if (topVideoView.getVisibility() == 0) {
return topVideoView;
}
}
}
return null;
}
@SuppressLint({"SetJavaScriptEnabled"})
public final void initializePreferences() {
c.t.c.j.q1.p.a aVar = c.t.c.j.q1.p.a.a;
if (!aVar.k() && !aVar.w()) {
aVar.s();
}
if (aVar.k()) {
this.requestHeaders.put(HEADER_DNT, SdkVersion.MINI_VERSION);
} else {
this.requestHeaders.remove(HEADER_DNT);
}
if (aVar.w()) {
this.requestHeaders.put(HEADER_SAVE_DATA, "on");
} else {
this.requestHeaders.remove(HEADER_SAVE_DATA);
}
if (aVar.s()) {
this.requestHeaders.put(HEADER_REQUESTED_WITH, "");
this.requestHeaders.put(HEADER_WAP_PROFILE, "");
} else {
this.requestHeaders.remove(HEADER_REQUESTED_WITH);
this.requestHeaders.remove(HEADER_WAP_PROFILE);
}
setColorMode(aVar.t());
getSettings().setDefaultTextEncodingName(aVar.z());
getSettings().setJavaScriptEnabled(aVar.m());
getSettings().setJavaScriptCanOpenWindowsAutomatically(aVar.m());
getSettings().setGeolocationEnabled(this.isIncognito ? false : aVar.n());
getSettings().setSaveFormData(aVar.x() && !this.isIncognito);
if (aVar.A()) {
getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
try {
getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
} catch (Exception unused) {
c.h.b.j.e.c(new Object[]{"Problem setting LayoutAlgorithm to TEXT_AUTOSIZING"});
}
} else {
getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
}
WebSettings settings = getSettings();
c.t.c.j.q1.p.a aVar2 = c.t.c.j.q1.p.a.a;
settings.setBlockNetworkImage(aVar2.b());
getSettings().setSupportMultipleWindows(false);
getSettings().setUseWideViewPort(aVar2.C());
getSettings().setLoadWithOverviewMode(aVar2.p());
WebSettings settings2 = getSettings();
int B = aVar2.B();
int i2 = 100;
if (B == 0) {
i2 = 80;
} else if (B == 1) {
i2 = 90;
} else if (B != 2) {
if (B == 3) {
i2 = 110;
} else if (B == 4) {
i2 = 120;
}
}
settings2.setTextZoom(i2);
if (Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(this, !aVar2.c());
}
}
public final boolean isIncognito() {
return this.isIncognito;
}
@Override
public void onOverScrolled(int i2, int i3, boolean z, boolean z2) {
ViewParent parent;
ViewParent findSwipeRefreshLayout = findSwipeRefreshLayout(this);
if (z && (parent = getParent()) != null) {
parent.requestDisallowInterceptTouchEvent(false);
}
if (z2 && i3 == 0) {
if (findSwipeRefreshLayout != null) {
findSwipeRefreshLayout.requestDisallowInterceptTouchEvent(false);
}
} else if (findSwipeRefreshLayout != null) {
findSwipeRefreshLayout.requestDisallowInterceptTouchEvent(true);
}
super.onOverScrolled(i2, i3, z, z2);
}
@Override
public void onScrollChanged(int i2, int i3, int i4, int i5) {
super.onScrollChanged(i2, i3, i4, i5);
e eVar = this.mOnScrollChangeListener;
if (eVar != null) {
eVar.a(i2, i3, i4, i5);
}
for (TopVideoView topVideoView : ViewGroupKt.getChildren(this)) {
if (topVideoView instanceof TopVideoView) {
if (topVideoView.getVisibility() == 0) {
TopVideoView topVideoView2 = topVideoView;
ViewGroup.LayoutParams layoutParams = topVideoView2.getLayoutParams();
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.widget.AbsoluteLayout.LayoutParams");
AbsoluteLayout.LayoutParams layoutParams2 = (AbsoluteLayout.LayoutParams) layoutParams;
c.t.a.x.i.t webVideoInfoEntity = topVideoView2.getWebVideoInfoEntity();
int d2 = i3 - webVideoInfoEntity.d();
if (d2 > 0) {
layoutParams2.y = webVideoInfoEntity.d() + d2;
layoutParams2.x = 0;
layoutParams2.height = webVideoInfoEntity.a();
layoutParams2.width = -1;
} else {
layoutParams2.y = webVideoInfoEntity.d();
layoutParams2.x = webVideoInfoEntity.c();
layoutParams2.height = webVideoInfoEntity.a();
layoutParams2.width = webVideoInfoEntity.f();
}
topVideoView2.setLayoutParams(layoutParams2);
}
}
}
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
h.b0.d.l.f(motionEvent, "event");
if (motionEvent.getAction() == 0) {
ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(true);
}
ViewParent findSwipeRefreshLayout = findSwipeRefreshLayout(this);
if (findSwipeRefreshLayout != null) {
findSwipeRefreshLayout.requestDisallowInterceptTouchEvent(true);
}
}
return super.onTouchEvent(motionEvent);
}
public void onVisible(boolean z) {
if (z) {
onResume();
resumeTopVideo();
} else {
onPause();
pauseTopVideo();
}
}
public final void pauseTopVideo() {
for (TopVideoView topVideoView : ViewGroupKt.getChildren(this)) {
if (topVideoView instanceof TopVideoView) {
if (topVideoView.getVisibility() == 0) {
topVideoView.pause();
}
}
}
}
public final void replaceVideo(c.t.a.x.i.t tVar) {
h.b0.d.l.f(tVar, "videoInfo");
if (getVideoView() != null) {
return;
}
View topVideoView = new TopVideoView(getContext());
tVar.h(this);
topVideoView.setWebVideoInfoEntity(tVar);
TopVideoController topVideoController = new TopVideoController(getContext());
String e2 = tVar.e();
if (e2 == null) {
e2 = "";
}
topVideoController.a(e2, false, false);
topVideoView.setVideoController(topVideoController);
topVideoView.setUrl(k0.a.getUrlList().get(0));
String e3 = tVar.e();
topVideoView.setTitle(e3 != null ? e3 : "");
AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(new ViewGroup.LayoutParams(-1, -2));
layoutParams.y = tVar.d();
layoutParams.x = tVar.c();
layoutParams.height = tVar.a();
layoutParams.width = tVar.f();
addView(topVideoView, layoutParams);
}
public final void restorationVideo(TopVideoView topVideoView) {
h.b0.d.l.f(topVideoView, "topVideoView");
c.t.a.x.i.t webVideoInfoEntity = topVideoView.getWebVideoInfoEntity();
if (webVideoInfoEntity != null) {
TopVideoController topVideoController = new TopVideoController(getContext());
String e2 = webVideoInfoEntity.e();
if (e2 == null) {
e2 = "";
}
topVideoController.a(e2, false, false);
topVideoView.setVideoController(topVideoController);
topVideoView.setUrl(k0.a.getUrlList().get(0));
AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(new ViewGroup.LayoutParams(-1, -2));
layoutParams.y = webVideoInfoEntity.d();
layoutParams.x = webVideoInfoEntity.c();
layoutParams.height = webVideoInfoEntity.a();
layoutParams.width = webVideoInfoEntity.f();
addView((View) topVideoView, (ViewGroup.LayoutParams) layoutParams);
}
}
public final void resumeTopVideo() {
for (TopVideoView topVideoView : ViewGroupKt.getChildren(this)) {
if (topVideoView instanceof TopVideoView) {
c.t.a.x.i.o.c().k(true);
if (topVideoView.getVisibility() == 0) {
topVideoView.resume();
}
}
}
}
public final void setBrowserController(c.t.c.j.r1.z.r rVar) {
this.browserController = rVar;
}
public final void setIncognito(boolean z) {
this.isIncognito = z;
}
public final void setMOnScrollChangeListener(e eVar) {
this.mOnScrollChangeListener = eVar;
}
public final void setSoftwareRendering() {
setLayerType(1, null);
}
@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
h.b0.d.l.f(callback, "callback");
ActionMode startActionMode = super.startActionMode(new d(callback));
h.b0.d.l.e(startActionMode, "super.startActionMode(Cu…onModeCallback(callback))");
return startActionMode;
}
public YaWebView(Context context, AttributeSet attributeSet, int i2) {
super(context, attributeSet, i2);
h.b0.d.l.f(context, com.umeng.analytics.pro.d.R);
this.paint = new Paint();
f fVar = new f(this);
this.touchListener = fVar;
this.webViewHandler = new h(this);
this.webViewClickHandler = new g(this);
this.requestHeaders = new ArrayMap<>();
this.maxFling = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
setBackgroundColor(r0.a.b(c.t.a.u.a.a.a().b(context, R$attr.yaBackground)));
this.gestureDetector = new GestureDetector(context, new c(this));
setFocusableInTouchMode(true);
setFocusable(true);
int i3 = Build.VERSION.SDK_INT;
if (i3 < 23) {
setAnimationCacheEnabled(false);
setAlwaysDrawnWithCacheEnabled(false);
}
if (i3 >= 26) {
setImportantForAutofill(1);
}
setScrollbarFadingEnabled(true);
setSaveEnabled(true);
setNetworkAvailable(true);
setWebChromeClient(new a());
setOnTouchListener(fVar);
initializeSettings();
initializePreferences();
}
}