QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 SkinWebView.java 源代码,内容仅作参考
package com.tencent.mtt.external.setting.skin;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.webkit.WebResourceResponse;
import android.widget.FrameLayout;
import com.tencent.common.http.Apn;
import com.tencent.common.utils.UrlUtils;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.functionwindow.MttFunctionwindowProxy;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.stat.interfaces.IUnitTimeHelper;
import com.tencent.mtt.base.stat.interfaces.UnitTimeHelperFactory;
import com.tencent.mtt.base.utils.GetTask;
import com.tencent.mtt.base.webview.QBWebView;
import com.tencent.mtt.base.webview.WebViewUtils;
import com.tencent.mtt.base.webview.common.QBWebSettings;
import com.tencent.mtt.base.webview.common.QBWebViewClient;
import com.tencent.mtt.base.wrapper.callback.IScrollListener;
import com.tencent.mtt.browser.WebEngine;
import com.tencent.mtt.browser.engine.AppBroadcastObserver;
import com.tencent.mtt.browser.engine.AppBroadcastReceiver;
import com.tencent.mtt.browser.setting.manager.SkinManager;
import com.tencent.mtt.browser.setting.manager.UserSettingManager;
import com.tencent.mtt.browser.setting.skin.MttSkinInstallListener;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.external.setting.base.RotateScreenManager;
import com.tencent.mtt.external.setting.facade.ForwardListener;
import com.tencent.mtt.external.setting.facade.OnScreenChangeListener;
import com.tencent.mtt.external.setting.facade.ViewState;
import com.tencent.mtt.external.setting.manager.SkinWebCacheManager;
import java.util.HashMap;
import kotlin.text.Typography;
import tmsdk.common.gourd.vine.IMessageCenter;
public final class SkinWebView extends FrameLayout implements WebEngine.WebCoreStateObserver, AppBroadcastObserver, SkinManager.SkinDataReadyListener, MttSkinInstallListener, OnScreenChangeListener, ViewState, SkinWebCacheManager.SkinWebListener {
QBWebView f59820a;
ForwardListener f59821b;
MttFunctionwindowProxy f59822c;
long f59823d;
String e;
String f;
private boolean g;
private SkinManager h;
private boolean i;
private Handler j;
private IUnitTimeHelper k;
class AnonymousClass1 extends Handler {
final SkinWebView f59824a;
@Override
public void handleMessage(Message message) {
this.f59824a.f59820a.loadUrl(this.f59824a.e);
}
}
public class SkinWebViewClient extends QBWebViewClient {
public SkinWebViewClient() {
}
@Override
public WebResourceResponse shouldInterceptRequest(QBWebView qBWebView, String str) {
WebResourceResponse a2 = SkinWebCacheManager.a().a(str);
return a2 != null ? a2 : super.shouldInterceptRequest(qBWebView, str);
}
@Override
public boolean shouldOverrideUrlLoading(QBWebView qBWebView, String str) {
long currentTimeMillis = System.currentTimeMillis();
if (TextUtils.isEmpty(str) || currentTimeMillis - SkinWebView.this.f59823d <= 1000) {
return true;
}
if (!str.startsWith(GetTask.ICustomForegroundPredication.QB)) {
if (!TextUtils.isEmpty(SkinWebView.this.f) && SkinWebView.this.f.equals(str)) {
return true;
}
SkinWebView.this.f = str;
}
SkinWebView.this.f59823d = currentTimeMillis;
if (!TextUtils.isEmpty(str)) {
if (str.contains("isnewpage=true")) {
Bundle bundle = new Bundle();
bundle.putString("card_store_url", str);
if (str.contains("titlename=")) {
String decode = UrlUtils.decode(UrlUtils.getValueByKey(str, str.toLowerCase(), "titlename=", Typography.amp));
if (!TextUtils.isEmpty(decode)) {
bundle.putString("card_store_name", decode);
}
}
SkinWebView.this.a(35, bundle);
return true;
}
if (str.contains("openinmainwindow=true")) {
new UrlParams(str).b(1).c(13).e();
return true;
}
}
return super.shouldOverrideUrlLoading(qBWebView, str);
}
}
private void k() {
l();
addView(this.f59820a, new FrameLayout.LayoutParams(-1, -1));
QBWebView qBWebView = this.f59820a;
if (qBWebView == null || qBWebView.getView() == null) {
return;
}
this.f59820a.getView().setFocusableInTouchMode(true);
this.f59820a.getView().setBackgroundColor(MttResources.c(R.color.theme_home_color_bkg));
}
private void l() {
if (this.f59820a == null) {
this.f59820a = new QBWebView(ContextHolder.getAppContext());
m();
WebViewUtils.a(this.f59820a, (String) null);
this.f59820a.addDefaultJavaScriptInterface();
this.f59820a.setQBWebViewClient(new SkinWebViewClient());
this.f59820a.getQBSettings().m(true);
this.f59820a.getQBSettings().n(false);
this.f59820a.setX5WebViewOnScrollListener(new IScrollListener() {
@Override
public boolean onOverScroll(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, boolean z) {
if (SkinWebView.this.f59822c == null) {
return false;
}
return SkinWebView.this.f59822c.a(i, i2, i3, i4, i5, i6, i7, i8, z);
}
});
}
}
private void m() {
QBWebView qBWebView = this.f59820a;
if (qBWebView != null) {
QBWebSettings qBSettings = qBWebView.getQBSettings();
qBSettings.p(true);
qBSettings.q(true);
qBSettings.o(true);
UserSettingManager b2 = UserSettingManager.b();
if (b2 == null || this.f59820a.getSettingsExtension() == null) {
return;
}
this.f59820a.getSettingsExtension().f(b2.getBoolean("Key4FitScreen", false));
}
}
private void n() {
if (!this.g || this.f59820a == null) {
return;
}
this.g = false;
if (!this.h.b()) {
this.h.n();
this.h.a((SkinManager.SkinDataReadyListener) this);
}
this.f59820a.loadUrl(this.e);
}
@Override
public void a() {
this.j.post(new Runnable() {
@Override
public void run() {
if (SkinWebView.this.f59820a != null) {
SkinWebView.this.f59820a.reload();
}
}
});
}
void a(int i, Bundle bundle) {
ForwardListener forwardListener = this.f59821b;
if (forwardListener != null) {
forwardListener.a(i, bundle);
}
}
@Override
public void a(int i, final String str) {
this.j.post(new Runnable() {
@Override
public void run() {
if (SkinWebView.this.f59820a != null) {
SkinWebView.this.f59820a.loadUrl("javascript:x5onSkinUnzip(\"" + str + "\");");
}
}
});
}
@Override
public void a(String str) {
}
@Override
public void b() {
this.f = "";
RotateScreenManager.a().a(this);
RotateScreenManager.a().a((Activity) null, 3, 1);
if (!(ActivityHandler.b().n().getResources().getConfiguration().orientation == 2)) {
n();
}
h();
}
@Override
public void b(int i, final String str) {
this.j.post(new Runnable() {
@Override
public void run() {
if (SkinWebView.this.f59820a != null) {
SkinWebView.this.f59820a.loadUrl("javascript:x5onSkinDelete (\"" + str + "\");");
}
}
});
}
@Override
public void b(final String str) {
if (!TextUtils.isEmpty(str) && str.equals("wallpaper_custom")) {
StatManager.b().c("N443");
}
this.j.post(new Runnable() {
@Override
public void run() {
if (SkinWebView.this.f59820a != null) {
SkinWebView.this.f59820a.loadUrl("javascript:x5onSkinSwitch(\"" + str + "\");");
}
}
});
}
@Override
public void c() {
RotateScreenManager.a().b(this);
RotateScreenManager.a().b(null, 3, 1);
i();
}
@Override
public void c(int i, final String str) {
this.j.post(new Runnable() {
@Override
public void run() {
if (SkinWebView.this.f59820a != null) {
SkinWebView.this.f59820a.loadUrl("javascript:x5onSkinUnzip(\"" + str + "\");");
}
}
});
}
@Override
public void cd_() {
i();
}
@Override
public boolean ce_() {
return false;
}
@Override
public void d() {
h();
}
@Override
public void d(int i, String str) {
}
@Override
public void e(int i, String str) {
}
@Override
public boolean e() {
return false;
}
@Override
public void f() {
this.j.sendEmptyMessageDelayed(0, 1000L);
}
@Override
public void f(int i, String str) {
}
public IUnitTimeHelper getUnitTimeHelper() {
if (this.k == null) {
this.k = UnitTimeHelperFactory.a();
}
return this.k;
}
void h() {
HashMap hashMap = new HashMap();
hashMap.put("scene", "userskin");
IUnitTimeHelper unitTimeHelper = getUnitTimeHelper();
unitTimeHelper.a("settings");
unitTimeHelper.a(hashMap);
StatManager.b().b(unitTimeHelper, -1);
}
void i() {
HashMap hashMap = new HashMap();
hashMap.put("scene", "");
IUnitTimeHelper unitTimeHelper = getUnitTimeHelper();
unitTimeHelper.a("settings");
unitTimeHelper.a(hashMap);
StatManager.b().b(unitTimeHelper, -1);
}
public void j() {
QBWebView qBWebView = this.f59820a;
if (qBWebView == null || qBWebView.getView() == null) {
return;
}
this.f59820a.switchSkin();
this.f59820a.getView().setBackgroundColor(MttResources.c(R.color.theme_home_color_bkg));
this.f59820a.getView().postInvalidate();
}
@Override
public void onBroadcastReceiver(Intent intent) {
if (IMessageCenter.MSG_SYS_CONNECTIVITY_ACTION.equals(intent.getAction()) && Apn.isNetworkConnected() && this.f59820a != null && this.i) {
this.j.post(new Runnable() {
@Override
public void run() {
if (SkinWebView.this.f59820a != null) {
SkinWebView.this.f59820a.reload();
}
}
});
this.i = false;
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.h.b((MttSkinInstallListener) this);
this.h.b((SkinManager.SkinDataReadyListener) this);
QBWebView qBWebView = this.f59820a;
if (qBWebView != null) {
removeView(qBWebView);
this.f59820a.destroy();
}
AppBroadcastReceiver.a().b(this);
SkinWebCacheManager.a().a(this);
}
@Override
public void onScreenChange(Activity activity, int i) {
n();
}
@Override
public void onWebCorePrepared() {
k();
n();
}
public void setForwardListener(ForwardListener forwardListener) {
this.f59821b = forwardListener;
}
}