QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 QLightNativePage.java 源代码,内容仅作参考


package com.tencent.mtt.qlight.page;

import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.Shape;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.tencent.common.featuretoggle.FeatureToggle;
import com.tencent.common.manifest.AppManifest;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.DeviceUtils;
import com.tencent.common.utils.UrlUtils;
import com.tencent.connect.common.Constants;
import com.tencent.luggage.wxa.gq.a;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.nativeframework.NativePage;
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.utils.PlatformStatUtils;
import com.tencent.mtt.base.utils.NotchUtil;
import com.tencent.mtt.base.utils.QBUrlUtils;
import com.tencent.mtt.base.webview.QBNewJsDialogFactory;
import com.tencent.mtt.base.webview.QBWebView;
import com.tencent.mtt.base.webview.QBWebViewPreloader;
import com.tencent.mtt.base.webview.WebViewUtils;
import com.tencent.mtt.base.webview.extension.IWebviewHeaderExtension;
import com.tencent.mtt.base.webview.extension.QBWebViewBackOrForwardChangeListener;
import com.tencent.mtt.base.webview.preload.IPreloadWebviewService;
import com.tencent.mtt.base.wup.PreferenceData;
import com.tencent.mtt.browser.SystemWebviewFixer;
import com.tencent.mtt.browser.WebEngine;
import com.tencent.mtt.browser.jsextension.facade.IJsHelperCallback;
import com.tencent.mtt.browser.setting.manager.SkinManager;
import com.tencent.mtt.browser.share.facade.IShare;
import com.tencent.mtt.browser.window.IPage;
import com.tencent.mtt.browser.window.IWebView;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.browser.window.data.PageInfo;
import com.tencent.mtt.browser.window.home.FrameWorkLogUtil;
import com.tencent.mtt.browser.window.templayer.BaseNativeGroup;
import com.tencent.mtt.browser.window.templayer.JsCallback;
import com.tencent.mtt.newskin.SimpleSkinBuilder;
import com.tencent.mtt.operation.event.EventLog;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.qlight.QLightTraceEventUrlExtension;
import com.tencent.mtt.qlight.clients.CommonLightChromeClientExtension;
import com.tencent.mtt.qlight.clients.CommonLightWebChromeClient;
import com.tencent.mtt.qlight.clients.CommonWebViewClient;
import com.tencent.mtt.qlight.clients.CommonWebviewInitHelper;
import com.tencent.mtt.qlight.extentions.WebResourceExtensions;
import com.tencent.mtt.qlight.jsapi.QLightJsApiImpl;
import com.tencent.mtt.qlight.view.QLightBgImageView;
import com.tencent.mtt.qlight.view.QLightSearchBarView;
import com.tencent.mtt.search.view.common.cloudconfig.SearchCloudConfigManager;
import com.tencent.mtt.setting.BaseSettings;
import com.tencent.mtt.support.utils.ViewCompat;
import com.tencent.mtt.uifw2.base.resource.QBResource;
import com.tencent.mtt.video.browser.export.wc.m3u8.M3U8Constants;
import com.tencent.mtt.view.common.QBView;
import com.tencent.mtt.view.widget.QBLoadingView;
import com.tencent.mtt.weboffline.WebOfflineClient;
import com.tencent.qqlive.module.videoreport.collect.EventCollector;
import com.tencent.rmpbusiness.report.TraceEvent;
import com.tencent.rmpbusiness.report.TraceEventCallback;
import com.tencent.smtt.utils.FileUtil;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import qb.a.e;
import qb.a.f;
import qb.business.BuildConfig;

public class QLightNativePage extends NativePage implements Handler.Callback, WebEngine.WebCoreStateObserver, CommonLightWebChromeClient.IWebChromeClientListener, CommonWebViewClient.IWebPageCommitVisible, CommonWebViewClient.IWebUrlInterface, QLightJsApiImpl.IQLightJsListener {
    private static final int o = MttResources.s(48);
    private long A;
    private long B;
    private boolean C;
    private boolean D;
    private IPreloadWebviewService E;
    private boolean F;

    ImageView f69657a;

    LinearLayout f69658b;

    final QLightConstParams f69659c;

    QBLoadingView f69660d;
    LinearLayout e;
    private QBWebView f;
    private CommonWebViewClient g;
    private String h;
    private String i;
    private String j;
    private TextView k;
    private View l;
    private ImageView m;
    private ImageView n;
    private QLightProgress p;
    private final QLightSearchBarView q;
    private IWebView.STATUS_BAR r;
    private int s;
    private JsCallback t;
    private Handler u;
    private boolean v;
    private boolean w;
    private String x;
    private Map<String, String> y;
    private boolean z;

    public QLightNativePage(Context context, FrameLayout.LayoutParams layoutParams, BaseNativeGroup baseNativeGroup, UrlParams urlParams) {
        super(context, layoutParams, baseNativeGroup);
        this.s = 0;
        this.v = false;
        this.w = false;
        this.z = false;
        this.A = 0L;
        this.B = 0L;
        this.C = false;
        this.F = false;
        IPreloadWebviewService iPreloadWebviewService = null;
        this.e = null;
        String str = urlParams == null ? "" : urlParams.f46351a;
        HashMap<String, String> urlParam = UrlUtils.getUrlParam(str);
        this.j = urlParam.get("sceneId");
        this.f69659c = new QLightConstParams(urlParam);
        this.q = new QLightSearchBarView(this, str, this.f69659c.g, this.f69659c.f, context);
        b();
        c();
        a(this.f69659c);
        if (urlParams != null && (urlParams.i instanceof IPreloadWebviewService)) {
            iPreloadWebviewService = (IPreloadWebviewService) urlParams.i;
        }
        this.E = iPreloadWebviewService;
        this.D = QBUrlUtils.ab(str) && !SystemWebviewFixer.a();
        this.h = str;
        this.B = System.currentTimeMillis();
        this.r = IWebView.STATUS_BAR.NO_SHOW_DARK;
        this.s = MttResources.c(e.C);
        this.u = new Handler(Looper.getMainLooper(), this);
        this.f = g();
        addView(this.f, new FrameLayout.LayoutParams(-1, -1));
        a(context);
        StatManager.b().c("EI005");
        PlatformStatUtils.a("IMMERSIVE_H5_STAT_PRE_show");
        QLightJsApiImpl.getInstance().a(this);
        if (this.f69659c.p) {
            setBackgroundColor(Integer.MIN_VALUE);
        } else {
            setBackgroundNormalIds(0, e.C);
        }
        c(this.f69659c);
        a(this.f69659c.f, a(this.f69659c.h, this.f69659c.i));
        o();
        f();
    }

    private int a(boolean z, boolean z2) {
        if (z || z2) {
            Activity a2 = ActivityHandler.b().a();
            if (!NotchUtil.a(getContext())) {
                if (DeviceUtils.b(a2 != null ? a2.getWindow() : null)) {
                    this.f69657a.setVisibility(8);
                    if (this.f69657a.getVisibility() == 0 && !z) {
                        SimpleSkinBuilder.a(this.f69657a).c().a(e.C).f();
                    }
                }
            }
            this.f69657a.setVisibility(0);
            if (this.f69657a.getVisibility() == 0) {
                SimpleSkinBuilder.a(this.f69657a).c().a(e.C).f();
            }
        }
        if (this.f69657a.getVisibility() == 0) {
            return this.f69657a.getLayoutParams().height;
        }
        return 0;
    }

    public static QBWebView a(String str) {
        String str2 = TextUtils.isEmpty(str) ? "" : str;
        char c2 = 65535;
        int hashCode = str2.hashCode();
        if (hashCode != 50) {
            if (hashCode == 51 && str2.equals("3")) {
                c2 = 0;
            }
        } else if (str2.equals("2")) {
            c2 = 1;
        }
        return c2 != 0 ? c2 != 1 ? QBWebViewPreloader.a().b() : new QBWebView(ContextHolder.getAppContext(), true, null, 0, null, false, 0, 0, 3) : new QBWebView(ContextHolder.getAppContext(), true, null, 0, null, false, 0, 0, 1);
    }

    public static QBWebView a(boolean z) {
        return z ? new QBWebView(ContextHolder.getAppContext(), true, null, 0, null, false, 0, 0, 1) : QBWebViewPreloader.a().b();
    }

    private void a(int i) {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.f.getLayoutParams();
        layoutParams.topMargin = i;
        this.f.setLayoutParams(layoutParams);
    }

    private void a(Context context) {
        this.f69658b = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.qc, (ViewGroup) null);
        this.k = (TextView) this.f69658b.findViewById(R.id.qtitle_bar_title);
        this.k.setOnClickListener(this);
        this.m = (ImageView) this.f69658b.findViewById(R.id.qtitle_bar_back);
        this.m.setOnClickListener(this);
        this.n = (ImageView) this.f69658b.findViewById(R.id.qtitle_bar_share);
        this.n.setOnClickListener(this);
        this.f69657a = (ImageView) this.f69658b.findViewById(R.id.qstatus_bg);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.f69657a.getLayoutParams();
        layoutParams.height = BaseSettings.a().m();
        this.f69657a.setLayoutParams(layoutParams);
        setTitleColor(e.f85871a);
        if (this.q.c()) {
            FrameLayout frameLayout = (FrameLayout) this.f69658b.findViewById(R.id.qsearch_bar_container);
            frameLayout.setVisibility(0);
            this.f69658b.findViewById(R.id.qnomal_title_container).setVisibility(8);
            frameLayout.addView(this.q.a(), new FrameLayout.LayoutParams(-1, this.q.b()));
        }
        FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-1, -2);
        layoutParams2.gravity = 48;
        addView(this.f69658b, layoutParams2);
    }

    private void a(String str, int i) {
        int i2;
        int i3;
        if (this.q.c()) {
            i2 = this.q.b();
        } else {
            if (!TextUtils.equals(str, "0") && !TextUtils.isEmpty(str)) {
                if (TextUtils.equals(str, "1")) {
                    i3 = e.e;
                } else if (!TextUtils.equals(str, "2")) {
                    return;
                } else {
                    i3 = e.f85871a;
                }
                setTitleColor(i3);
                SimpleSkinBuilder.a(this.f69658b).a().f();
                this.f69658b.setBackgroundColor(0);
                a(i);
                return;
            }
            setTitleColor(e.f85871a);
            i2 = o;
        }
        a(i + i2);
        SimpleSkinBuilder.a(this.f69658b).a(e.C).c().f();
    }

    public void a(String str, Map<String, String> map) {
        String str2;
        if (isSinglePage(str)) {
            if (this.f69659c.l) {
                this.f.scrollto(0, 0);
                str2 = "单实例,直接复用,不做reload!";
            } else {
                reload();
                str2 = "单实例,转为reload!";
            }
            EventLog.a("沉浸式H5", str2);
            return;
        }
        String str3 = UrlUtils.getUrlParam(str).get("reurl");
        if (TextUtils.isEmpty(str3)) {
            return;
        }
        l();
        this.p.a();
        this.h = str;
        this.i = str3;
        EventLog.a("沉浸式H5", "当前是否X5内核:" + this.f.isX5WebView());
        EventLog.a("沉浸式H5", "loadUrl:" + str3);
        EventLog.a("沉浸式H5", "url参数:" + this.f69659c.toString());
        if (UrlUtils.isHttpUrl(this.i) || UrlUtils.isHttpsUrl(this.i)) {
            if (!this.F) {
                HashMap hashMap = new HashMap();
                hashMap.put("isImmersive", "1");
                if (map != null) {
                    hashMap.putAll(map);
                }
                this.i = UrlUtils.addParamsToUrl(this.i, "_load_ts=" + this.A + "&_url_ts=" + System.currentTimeMillis() + "&_page_ts=" + this.B);
                TraceEventCallback.a().onHippyCustomTraceEvent(str, "NEW_WEB_LOAD_URL", new Bundle());
                FrameWorkLogUtil.a("QLightPage", "doLoadUrl", "doLoadUrl", this.i);
                this.f.loadUrl(this.i, a(map));
            }
            long currentTimeMillis = System.currentTimeMillis() - this.A;
            EventLog.a("沉浸式H5", "从page到web加载url耗时:" + currentTimeMillis + " ms");
            PlatformStatUtils.a("IMMERSIVE_H5_LOAD_TIME", currentTimeMillis);
            TraceEventCallback.a().onHippyCustomTraceEvent(str, TraceEvent.TraceAction.WEB_LOAD_URL.name(), new Bundle());
            QLightTraceEventUrlExtension.getInstance().a(this.i, this.h);
            this.F = false;
        }
    }

    private void a(boolean z, int i) {
        if (!z) {
            i += this.q.c() ? this.q.b() : o;
        }
        this.p.a(i);
    }

    private boolean a(QBWebView qBWebView, String str, JSONObject jSONObject) {
        if (jSONObject == null) {
            return true;
        }
        if (!FeatureToggle.a(BuildConfig.BUG_TOGGLE_94168265) || qBWebView == getQBWebView()) {
            return !isActive();
        }
        EventLog.a("沉浸式H5", "qlight js 调用 action:" + str + ", 但是webview不匹配");
        return true;
    }

    private void b() {
        if (d()) {
            QLightBgImageView qLightBgImageView = new QLightBgImageView(getContext());
            qLightBgImageView.setId(R.id.qlight_bg_imageview);
            qLightBgImageView.setUrl(this.f69659c.t);
            qLightBgImageView.setFadeDuration(this.f69659c.v);
            addView(qLightBgImageView, new FrameLayout.LayoutParams(-1, -1));
        }
    }

    private void b(boolean z) {
        if (z || this.f.getView() == null) {
            return;
        }
        this.f.getView().setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                EventCollector.getInstance().onViewLongClickedBefore(view);
                EventCollector.getInstance().onViewLongClicked(view);
                return true;
            }
        });
    }

    private String c(boolean z) {
        return z ? "1" : "0";
    }

    private void c() {
        int parseColor;
        if (e()) {
            Integer num = null;
            try {
                if (this.f69659c.u.startsWith(M3U8Constants.COMMENT_PREFIX)) {
                    parseColor = Color.parseColor(this.f69659c.u);
                } else {
                    parseColor = Color.parseColor(M3U8Constants.COMMENT_PREFIX + this.f69659c.u);
                }
                num = Integer.valueOf(parseColor);
            } catch (IllegalArgumentException unused) {
            }
            if (num == null) {
                return;
            }
            QBView qBView = new QBView(getContext());
            qBView.setId(R.id.qlight_bg_colorview);
            qBView.setBackgroundColor(num.intValue());
            addView(qBView, new FrameLayout.LayoutParams(-1, -1));
            ViewCompat.a((View) qBView, 0.0f);
            ObjectAnimator ofFloat = ObjectAnimator.ofFloat(qBView, a.ab, 0.0f, 1.0f);
            ofFloat.setDuration(this.f69659c.v);
            ofFloat.start();
        }
    }

    private void c(QLightConstParams qLightConstParams) {
        StatManager.b().c("EI007_1");
        if (!qLightConstParams.f69656d) {
            StatManager.b().c("EI007_2");
            this.n.setVisibility(4);
            this.n.setClickable(false);
        }
        if (!qLightConstParams.e) {
            this.k.setVisibility(4);
            this.k.setClickable(false);
        }
        if (!qLightConstParams.f69655c && FeatureToggle.a(BuildConfig.BUG_TOGGLE_92550221)) {
            this.m.setVisibility(4);
            this.m.setClickable(false);
        }
        if (qLightConstParams.a()) {
            return;
        }
        this.f69658b.setOnClickListener(this);
        this.f69658b.setClickable(true);
    }

    private boolean d() {
        if (FeatureToggle.a(BuildConfig.FEATURE_TOGGLE_QLIGHT_LOADING_IMG_867582139)) {
            return !TextUtils.isEmpty(this.f69659c.t);
        }
        return false;
    }

    private boolean e() {
        if (FeatureToggle.a(BuildConfig.FEATURE_TOGGLE_868043797)) {
            return !TextUtils.isEmpty(this.f69659c.u);
        }
        return false;
    }

    private void f() {
        if (a()) {
            this.f69660d = new QBLoadingView(getContext(), (byte) 2, (byte) 2, (byte) 2);
            this.f69660d.setText("");
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
            layoutParams.gravity = 17;
            addView(this.f69660d, layoutParams);
            this.f69660d.startLoading();
        }
    }

    private QBWebView g() {
        EventLog.a("搜索端外投放沉浸式框架", "沉浸框架初始化webview", "useSystemCore=" + h());
        IPreloadWebviewService iPreloadWebviewService = this.E;
        if (iPreloadWebviewService != null && iPreloadWebviewService.b()) {
            if (!this.E.c()) {
                this.F = true;
                return this.E.a();
            }
            this.E.d();
        }
        return FeatureToggle.a(BuildConfig.FEATURE_TOGGLE_QLIGHT_CORE_TYPE_867689923) ? h() ? a("3") : a(this.f69659c.x) : a(this.D);
    }

    private boolean h() {
        return this.D || TextUtils.equals("3", this.f69659c.x);
    }

    public void i() {
        if (this.w) {
            return;
        }
        this.w = true;
        this.f.init();
        b(this.f69659c);
        this.g = new CommonWebViewClient(this, this.f, this.mWebViewClient);
        if (FeatureToggle.a(qb.framework.BuildConfig.FEATURE_TOGGLE_866448091)) {
            final WebOfflineClient webOfflineClient = new WebOfflineClient();
            this.g.a(webOfflineClient);
            this.f.setBackOrForwardChangeListener(new QBWebViewBackOrForwardChangeListener() {
                @Override
                public void onBackOrForwardChanged(QBWebView qBWebView) {
                    webOfflineClient.b(qBWebView.getUrl());
                }
            });
        }
        this.g.a(new WebResourceExtensions(this));
        this.g.a((CommonWebViewClient.IWebPageCommitVisible) this);
        this.g.a((CommonWebViewClient.IWebUrlInterface) this);
        this.f.setQBWebViewClient(this.g);
        this.f.addDefaultJavaScriptInterface();
        this.f.setOverScrollEnable(true);
        CommonLightWebChromeClient commonLightWebChromeClient = new CommonLightWebChromeClient(this, this.mWebViewClient);
        commonLightWebChromeClient.a(this);
        this.f.setQBWebChromeClient(commonLightWebChromeClient);
        CommonWebviewInitHelper.b(this.f);
        this.f.setWebChromeClientExtension(new CommonLightChromeClientExtension(this, this.f, this.mWebViewClient));
        WebViewUtils.a(this.f, "isImmersive/1");
        if (this.mWebViewClient != null && this.mWebViewClient.getBussinessProxy() != null) {
            this.t = this.mWebViewClient.getBussinessProxy().a(this, this.f, this.mWebViewClient);
        }
        this.p = new QLightProgress();
        this.p.a(this, getContext(), this.f69659c.y);
        this.g.a(this.p);
        if (this.z) {
            m();
        }
    }

    private void j() {
        Bundle bundle = new Bundle();
        bundle.putString("cancelFrom", "BACK");
        TraceEventCallback.a().c(this.h, bundle);
    }

    private boolean k() {
        return this.f69659c.n && (TextUtils.equals(this.f69659c.o, "0") || TextUtils.isEmpty(this.f69659c.o));
    }

    private void l() {
        b(this.f69659c.f69654b);
        if (this.f69659c.f69653a) {
            CommonWebviewInitHelper.a(this.f);
        }
        if (this.f69659c.i) {
            this.mPageAdapter.b(4);
        }
        int a2 = a(this.f69659c.h, this.f69659c.i);
        if (this.f69659c.h) {
            a(0);
        }
        a(this.f69659c.a(), a2);
        if (!TextUtils.isEmpty(this.f69659c.k)) {
            this.f.setEnableAutoPageDiscarding(false);
            this.f.setEnableAutoPageRestoration(false);
        }
        setWebviewNightMode(SkinManager.s().l());
        this.f.setVerticalScrollBarEnabled(!this.f69659c.q);
    }

    private void m() {
        this.f.active();
        JsCallback jsCallback = this.t;
        if (jsCallback != null) {
            jsCallback.a(true);
        }
        QLightConstParams qLightConstParams = this.f69659c;
        if (qLightConstParams != null && qLightConstParams.i) {
            this.mPageAdapter.b(4);
        }
        this.f.requestWebViewFocus();
        n();
    }

    private void n() {
        InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService("input_method");
        View findFocus = findFocus();
        if (inputMethodManager == null || findFocus == null) {
            return;
        }
        inputMethodManager.hideSoftInputFromWindow(findFocus.getWindowToken(), 0);
    }

    private void o() {
        if (this.f69659c.w) {
            this.e = new LinearLayout(getContext());
            this.e.setGravity(17);
            addView(this.e, new FrameLayout.LayoutParams(-1, -1));
            ImageView imageView = new ImageView(getContext());
            imageView.setScaleType(ImageView.ScaleType.FIT_XY);
            imageView.setBackgroundResource(R.drawable.common_icon_logo);
            int g = MttResources.g(f.aM);
            this.e.addView(imageView, new LinearLayout.LayoutParams(g, g));
        }
    }

    private void setTitleColor(int i) {
        SimpleSkinBuilder.a(this.k).g(i).f();
        SimpleSkinBuilder.a(this.m).h(i).f();
        SimpleSkinBuilder.a(this.n).h(i).f();
    }

    private void setWebviewNightMode(boolean z) {
        QLightConstParams qLightConstParams = this.f69659c;
        if (qLightConstParams == null || qLightConstParams.j) {
            this.f.switchSkin(SkinManager.s().l(), false);
            return;
        }
        if (this.l == null) {
            this.l = new View(getContext());
            this.l.setBackgroundColor(Integer.MIN_VALUE);
            addView(this.l, new FrameLayout.LayoutParams(-1, -1));
        }
        this.l.setVisibility(z ? 0 : 8);
    }

    @Override
    public String a(QBWebView qBWebView, String str, String str2, JSONObject jSONObject, IJsHelperCallback iJsHelperCallback) {
        QLightProgress qLightProgress;
        if (a(qBWebView, str, jSONObject)) {
            return null;
        }
        EventLog.a("沉浸式H5", "qlight js 调用 action:" + str + " , argsJson:" + jSONObject);
        if (TextUtils.equals(str, "toggleBackBtn")) {
            this.u.obtainMessage(101, Boolean.valueOf(jSONObject.optBoolean("enable"))).sendToTarget();
        } else if (TextUtils.equals(str, "getBackBtnCenter")) {
            if (iJsHelperCallback != null) {
                JSONObject jSONObject2 = new JSONObject();
                try {
                    int[] iArr = new int[2];
                    this.m.getLocationInWindow(iArr);
                    int height = iArr[1] + (this.m.getHeight() / 2);
                    EventLog.a("沉浸式H5", "返回按钮中间距离顶部高度:" + height);
                    jSONObject2.put("backCenter", height);
                } catch (JSONException unused) {
                }
                iJsHelperCallback.sendSuccJsCallback(str2, jSONObject2);
            }
        } else if (TextUtils.equals(str, "setProgressBarFull") && (qLightProgress = this.p) != null) {
            qLightProgress.b();
            EventLog.a("沉浸式H5", "通知进度栏加载完成");
        }
        return null;
    }

    public Map<String, String> a(Map<String, String> map) {
        IWebviewHeaderExtension[] iWebviewHeaderExtensionArr;
        HashMap hashMap = new HashMap();
        hashMap.put("isImmersive", "1");
        if (map != null) {
            hashMap.putAll(map);
        }
        if (!TextUtils.equals(PreferenceData.a("ANDROID_PUBLIC_PREFS_CLOSE_QLIGHT_ADD_HEADER"), "1") && (iWebviewHeaderExtensionArr = (IWebviewHeaderExtension[]) AppManifest.getInstance().queryExtensions(IWebviewHeaderExtension.class)) != null && iWebviewHeaderExtensionArr.length > 0) {
            for (IWebviewHeaderExtension iWebviewHeaderExtension : iWebviewHeaderExtensionArr) {
                if (iWebviewHeaderExtension != null && iWebviewHeaderExtension.getHeader(this.i) != null) {
                    hashMap.putAll(iWebviewHeaderExtension.getHeader(this.i));
                }
            }
        }
        return hashMap;
    }

    @Override
    public void a(QBWebView qBWebView, int i) {
        this.p.a(qBWebView, i);
    }

    @Override
    public void a(QBWebView qBWebView, String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        this.k.setText(str);
    }

    void a(QLightConstParams qLightConstParams) {
        if (k() && this.f69660d == null) {
            this.f69660d = new QBLoadingView(getContext(), (byte) 2, (byte) 3, (byte) 1);
            QBLoadingView qBLoadingView = this.f69660d;
            qBLoadingView.setPadding(qBLoadingView.getPaddingLeft(), MttResources.s(20), this.f69660d.getPaddingRight(), MttResources.s(20));
            this.f69660d.setBackgroundDrawable(new ShapeDrawable(new Shape() {

                int f69666a = QBResource.b(R.color.tl);

                RectF f69667b = new RectF();

                @Override
                public void draw(Canvas canvas, Paint paint) {
                    paint.setColor(this.f69666a);
                    this.f69667b.set(0.0f, 0.0f, getWidth(), getHeight());
                    canvas.drawRoundRect(this.f69667b, 4.0f, 4.0f, paint);
                }
            }));
            this.f69660d.setText("努力加载中");
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
            layoutParams.gravity = 17;
            addView(this.f69660d, layoutParams);
            this.f69660d.startLoading();
        }
    }

    public boolean a() {
        return this.f69659c.n && TextUtils.equals(this.f69659c.o, "1");
    }

    @Override
    public void active() {
        super.active();
        this.z = true;
        QLightSearchBarView qLightSearchBarView = this.q;
        if (qLightSearchBarView != null) {
            qLightSearchBarView.k();
        }
        if (this.w) {
            m();
        }
    }

    Map<String, String> b(String str) {
        HashMap hashMap = new HashMap();
        hashMap.put("action", str);
        hashMap.put("is_qlight", "1");
        hashMap.put("scene_id", this.j);
        StatManager.b().b("qlightaction", hashMap);
        return hashMap;
    }

    @Override
    public void b(QBWebView qBWebView, String str) {
        QBLoadingView qBLoadingView = this.f69660d;
        if (qBLoadingView != null) {
            qBLoadingView.stopLoading();
            this.f69660d.setVisibility(8);
        }
        LinearLayout linearLayout = this.e;
        if (linearLayout != null) {
            linearLayout.setVisibility(8);
        }
    }

    void b(QLightConstParams qLightConstParams) {
        if (qLightConstParams.p || d() || e()) {
            this.f.setWebViewBackgroundColor(0);
        }
    }

    @Override
    public void back(boolean z) {
        super.back(z);
        int goBackOrForwardToDesiredSteps = this.f.getGoBackOrForwardToDesiredSteps(-1);
        if (goBackOrForwardToDesiredSteps == -1) {
            this.f.goBackOrForward(-1);
        } else {
            this.f.goBackOrForward(goBackOrForwardToDesiredSteps);
        }
    }

    @Override
    public boolean canGoBack() {
        return this.f.canGoBack();
    }

    @Override
    public boolean coverToolbar() {
        return true;
    }

    @Override
    public void deactive() {
        super.deactive();
        this.z = false;
        if (this.w) {
            QBNewJsDialogFactory.b(this.f);
            this.f.deactive();
            JsCallback jsCallback = this.t;
            if (jsCallback != null) {
                jsCallback.a(false);
            }
            if (this.f69659c.m || !this.C) {
                return;
            }
            getNativeGroup().popUpWebview(this);
        }
    }

    @Override
    public void destroy() {
        super.destroy();
        if (this.z) {
            deactive();
        }
        QLightJsApiImpl.getInstance().b(this);
        QBNewJsDialogFactory.b(this.f);
        this.f.destroy();
        JsCallback jsCallback = this.t;
        if (jsCallback != null) {
            jsCallback.c();
            this.t.g();
        }
    }

    @Override
    public String getHttpUrl() {
        return this.i;
    }

    @Override
    public IPage.INSTANT_TYPE getInstType() {
        return IPage.INSTANT_TYPE.SIGLE_IN_PAGE;
    }

    public QBLoadingView getLoadingView() {
        return this.f69660d;
    }

    @Override
    public String getPageTitle() {
        if (!this.w) {
            return this.x;
        }
        if (Looper.myLooper() == Looper.getMainLooper()) {
            return this.f.getTitle();
        }
        if (getAddressBarDataSource() == null) {
            return null;
        }
        if (getAddressBarDataSource().f != null && !TextUtils.isEmpty(getAddressBarDataSource().f.j)) {
            return getAddressBarDataSource().f.j;
        }
        if (TextUtils.isEmpty(getAddressBarDataSource().f35820a)) {
            return null;
        }
        return getAddressBarDataSource().f35820a;
    }

    @Override
    public IPage.POP_TYPE getPopType() {
        return TextUtils.equals(this.f69659c.r, "1") ? IPage.POP_TYPE.NONE : IPage.POP_TYPE.ONLY_SELF;
    }

    @Override
    public QBWebView getQBWebView() {
        return this.f;
    }

    @Override
    public String getQbUrl() {
        return getUrl();
    }

    public QLightSearchBarView getSearchBarView() {
        return this.q;
    }

    @Override
    public PageInfo getShareBundle() {
        PageInfo pageInfo = new PageInfo();
        pageInfo.a(getPageTitle());
        pageInfo.b(this.f.getUrl());
        pageInfo.c(this.f.getUrl());
        pageInfo.a(0);
        return pageInfo;
    }

    @Override
    public int getStatusBarBgColor() {
        return this.s;
    }

    @Override
    public IUnitTimeHelper getUnitTimeHelper() {
        IUnitTimeHelper unitTimeHelper = super.getUnitTimeHelper();
        HashMap hashMap = new HashMap();
        hashMap.put("scene", this.j);
        unitTimeHelper.a(hashMap);
        return unitTimeHelper;
    }

    @Override
    public String getUrl() {
        return !this.w ? this.x : this.h;
    }

    @Override
    public boolean handleMessage(Message message) {
        if (message.what == 101 && (message.obj instanceof Boolean)) {
            boolean booleanValue = ((Boolean) message.obj).booleanValue();
            this.m.setVisibility(booleanValue ? 0 : 4);
            this.m.setClickable(booleanValue);
            PlatformStatUtils.a("IMMERSIVE_H5_STAT_PRE_back" + booleanValue);
        }
        return false;
    }

    @Override
    public boolean isActive() {
        return this.z;
    }

    @Override
    public boolean isBlankPage() {
        return this.f.isBlankPage();
    }

    @Override
    public boolean isForcePortalScreen() {
        return true;
    }

    @Override
    public boolean isNeedBackAnim() {
        return !this.f69659c.s;
    }

    @Override
    public boolean isSinglePage(String str) {
        QLightConstParams qLightConstParams = new QLightConstParams(UrlUtils.getUrlParam(str));
        QLightConstParams qLightConstParams2 = this.f69659c;
        return (qLightConstParams2 == null || TextUtils.isEmpty(qLightConstParams2.k) || !TextUtils.equals(this.f69659c.k, qLightConstParams.k)) ? false : true;
    }

    @Override
    public boolean isTransCardBackground(String str) {
        return this.f69659c.p;
    }

    @Override
    public void loadUrl(String str) {
        this.A = System.currentTimeMillis();
        loadUrl(str, null);
    }

    @Override
    public void loadUrl(final String str, final Map<String, String> map) {
        FrameWorkLogUtil.a("QLightPage", "loadUrl", "loadUrl", str);
        if (!WebEngine.e().g() && !h()) {
            this.x = str;
            this.y = map;
            WebEngine.e().a(this);
        } else if (Looper.myLooper() != Looper.getMainLooper()) {
            BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
                @Override
                public void run() {
                    QLightNativePage.this.i();
                    QLightNativePage.this.a(str, (Map<String, String>) map);
                }
            });
        } else {
            i();
            a(str, map);
        }
    }

    @Override
    public boolean onBackPressed() {
        j();
        if (SearchCloudConfigManager.a().b().a()) {
            this.q.e();
        }
        return super.onBackPressed();
    }

    @Override
    public void onClick(View view) {
        String str;
        EventCollector.getInstance().onViewClickedBefore(view);
        super.onClick(view);
        if (view != this.m) {
            if (view == this.n) {
                StatManager.b().c("EI006_2");
                PlatformStatUtils.a("IMMERSIVE_H5_STAT_PRE_shareClick");
                ((IShare) QBContext.getInstance().getService(IShare.class)).recordShareScene(Constants.VIA_REPORT_TYPE_START_WAP);
                ((IShare) QBContext.getInstance().getService(IShare.class)).shareCurPage();
                str = FileUtil.TBS_FILE_SHARE;
            }
            EventCollector.getInstance().onViewClicked(view);
        }
        StatManager.b().c("EI006_1");
        PlatformStatUtils.a("IMMERSIVE_H5_STAT_PRE_backClick");
        j();
        getNativeGroup().back();
        str = a.ad;
        b(str);
        EventCollector.getInstance().onViewClicked(view);
    }

    @Override
    public void onImageLoadConfigChanged() {
        this.f.invalidate();
    }

    @Override
    public void onSkinChanged() {
        super.onSkinChanged();
        this.v = true;
    }

    @Override
    public void onStart() {
        super.onStart();
        QLightSearchBarView qLightSearchBarView = this.q;
        if (qLightSearchBarView != null) {
            qLightSearchBarView.k();
        }
        if (this.w) {
            this.f.onResume();
            JsCallback jsCallback = this.t;
            if (jsCallback != null) {
                jsCallback.f();
            }
            QLightConstParams qLightConstParams = this.f69659c;
            if (qLightConstParams == null || !qLightConstParams.i) {
                return;
            }
            this.mPageAdapter.b(4);
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        if (this.w) {
            JsCallback jsCallback = this.t;
            if (jsCallback != null) {
                jsCallback.e();
            }
            this.f.onPause();
        }
    }

    @Override
    public void onTrimMemory(int i) {
        QBWebView qBWebView = this.f;
        if (qBWebView != null) {
            qBWebView.trimMemory(i);
        }
    }

    @Override
    public void onWebCorePrepared() {
        if (!TextUtils.isEmpty(this.x)) {
            loadUrl(this.x, this.y);
            this.x = null;
        }
        WebEngine.e().b(this);
    }

    @Override
    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        if (isActive()) {
            this.f.compatLoadUrl("javascript:window.qlight&&window.qlight.onWindowFocusChanged&&window.qlight.onWindowFocusChanged(\"" + c(z) + "\");");
        }
    }

    @Override
    public void pauseAudio() {
        this.f.pauseAudio();
    }

    @Override
    public void playAudio() {
        this.f.playAudio();
    }

    @Override
    public void pruneMemory() {
        QBWebView qBWebView = this.f;
        if (qBWebView != null) {
            qBWebView.pruneMemoryCache();
        }
    }

    @Override
    public void refreshSkin() {
        if (this.v) {
            this.f.active();
            JsCallback jsCallback = this.t;
            if (jsCallback != null) {
                jsCallback.a(true);
            }
            setWebviewNightMode(SkinManager.s().l());
            this.v = false;
        }
    }

    @Override
    public void reload() {
        super.reload();
        this.f.reload();
    }

    @Override
    public IWebView.STATUS_BAR statusBarType() {
        return SkinManager.s().l() ? IWebView.STATUS_BAR.NO_SHOW_LIGHT : this.r;
    }

    @Override
    public void stopLoading() {
        this.f.stopLoading();
        this.x = null;
    }

    @Override
    public void switchSkin() {
        QLightConstParams qLightConstParams = this.f69659c;
        if (qLightConstParams == null || qLightConstParams.j) {
            super.switchSkin();
        }
    }

    @Override
    public void toPage(String str) {
        super.toPage(str);
        this.C = true;
    }
}