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

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


package com.tencent.mtt.external.setting;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
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.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.tencent.common.plugin.exports.QBPluginItemInfo;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.FileUtils;
import com.tencent.mtt.R;
import com.tencent.mtt.base.font.QbFontManager;
import com.tencent.mtt.base.font.QbFontPluginManager;
import com.tencent.mtt.base.skin.MttResourceNew;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.ui.widget.QBWebImageView;
import com.tencent.mtt.browser.WebEngine;
import com.tencent.mtt.browser.lite.FontSizeUtils;
import com.tencent.mtt.browser.setting.manager.SkinHelper;
import com.tencent.mtt.browser.setting.manager.SkinManager;
import com.tencent.mtt.cmc.CMC;
import com.tencent.mtt.external.setting.base.FontSizeManager;
import com.tencent.mtt.external.setting.facade.SettingView;
import com.tencent.mtt.external.setting.util.WallpaperToggleController;
import com.tencent.mtt.hippy.qb.views.pan.PanEventHelper;
import com.tencent.mtt.newskin.SimpleSkinBuilder;
import com.tencent.mtt.resource.UIResourceDimen;
import com.tencent.mtt.setting.PublicSettingManager;
import com.tencent.mtt.support.utils.UIBitmapUtils;
import com.tencent.mtt.view.setting.SettingItem;
import com.tencent.mtt.view.setting.SettingResCache;
import com.tencent.mtt.view.widget.QBSeekbar;
import com.tencent.qqlive.module.videoreport.collect.EventCollector;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import qb.a.e;
import qb.a.f;
import qb.a.g;
import qb.a.h;

public final class SkinAndFontSettingView extends SettingView implements View.OnClickListener, QbFontPluginManager.IFontCallback {

    private final int f59591a;

    private final int f59592b;

    private final int f59593c;

    private final int f59594d;
    private final int e;
    private final int f;
    private final String g;
    private final String h;
    private CharSequence[] i;
    private float[] j;
    private int k;
    private VelocityTracker l;
    private TextView m;
    private SettingItem n;
    private SettingItem o;
    private ImageView p;
    private ImageView q;
    private TextView r;
    private TextView s;
    private Handler t;

    public SkinAndFontSettingView(Context context) {
        super(context);
        this.f59591a = MttResources.h(f.da);
        this.f59592b = MttResources.h(f.cX);
        this.f59593c = MttResources.h(f.j);
        this.f59594d = MttResources.h(f.z);
        this.e = MttResources.h(f.bf);
        this.f = MttResources.h(f.bL);
        this.g = MttResources.l(h.aJ);
        this.h = MttResources.l(h.aK);
        this.t = new Handler(Looper.getMainLooper(), new Handler.Callback() {
            @Override
            public boolean handleMessage(Message message) {
                if (message.what != 1) {
                    return false;
                }
                if (message.arg1 >= 0) {
                    int i = message.arg1;
                    StatManager.b().c("EIC03010" + (i + 1));
                    SkinAndFontSettingView.this.m.setTextSize(1, (float) MttResources.r((int) SkinAndFontSettingView.this.a(i)));
                    FontSizeManager.a().a(i);
                }
                return true;
            }
        });
        f();
        a(context);
        this.l = VelocityTracker.obtain();
    }

    public float a(int i) {
        return (this.f59591a * FontSizeUtils.a(i)) / 100.0f;
    }

    private TextView a(Context context, String str) {
        TextView textView = new TextView(context);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -2);
        layoutParams.topMargin = this.f59593c;
        layoutParams.bottomMargin = this.f59594d;
        textView.setLayoutParams(layoutParams);
        textView.setPadding(SettingResCache.a().g, 0, 0, 0);
        textView.setGravity(8388627);
        SimpleSkinBuilder.a(textView).g(e.f85873b).f();
        textView.setTextSize(1, MttResources.r(this.f59592b));
        textView.setText(str);
        return textView;
    }

    private void a(Context context) {
        this.m = new TextView(context);
        this.m.setLayoutParams(new FrameLayout.LayoutParams(-1, this.f));
        TextView textView = this.m;
        int i = this.f59594d;
        textView.setPadding(i, i, i, 0);
        this.m.setGravity(8388659);
        SimpleSkinBuilder.a(this.m).a(e.J).g(e.f85871a).c().f();
        this.m.setTextSize(1, MttResources.r((int) a(FontSizeManager.a().b())));
        this.m.setText(MttResources.n(R.string.bd2));
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, this.e));
        linearLayout.setGravity(17);
        SimpleSkinBuilder.a(linearLayout).a(e.J).c().f();
        QBSeekbar qBSeekbar = new QBSeekbar(getContext());
        qBSeekbar.a(this.i, this.j);
        qBSeekbar.setCursorSelection(FontSizeManager.a().b());
        qBSeekbar.setCursorBG(getCursorDrawable());
        qBSeekbar.setCursorChangedListener(new QBSeekbar.OnCursorChangeListener() {
            @Override
            public void a(int i2, String str) {
                if (SkinAndFontSettingView.this.k == i2) {
                    return;
                }
                StatManager.b().c("DIFNT4");
                if (i2 > SkinAndFontSettingView.this.i.length - 1 || i2 < 0) {
                    i2 = 2;
                }
                SkinAndFontSettingView.this.k = i2;
                SkinAndFontSettingView.this.t.removeMessages(1);
                Message obtainMessage = SkinAndFontSettingView.this.t.obtainMessage(1);
                obtainMessage.arg1 = i2;
                obtainMessage.sendToTarget();
            }
        });
        SimpleSkinBuilder.a(qBSeekbar).f();
        linearLayout.addView(qBSeekbar);
        View b2 = b(context);
        ((FrameLayout.LayoutParams) b2.getLayoutParams()).setMargins(0, x, 0, 0);
        addView(b2);
        addView(this.m);
        addView(b(context));
        View b3 = b(context);
        ((FrameLayout.LayoutParams) b3.getLayoutParams()).setMargins(0, x, 0, 0);
        addView(b3);
        addView(linearLayout);
        addView(b(context));
        addView(a(context, "设置后,网页的字体大小会相应改变。"));
        if (this.n == null) {
            this.n = new SettingItem(getContext(), 100, this.D);
            this.n.setId(74);
            this.n.setMainText(MttResources.l(R.string.bbe));
            this.n.a(0, 0, 0, 0);
            this.n.setOnClickListener(this);
            addView(this.n);
        }
        QbFontPluginManager.a().a(this);
        this.s = a(context, "更换后,App内所有字体均会改变");
        addView(this.s);
        if (SkinHelper.a()) {
            SettingItem settingItem = new SettingItem(getContext(), 100, this.D);
            settingItem.setId(75);
            settingItem.setMainText("壁纸中心");
            settingItem.a(0, 0, 0, 0);
            settingItem.setOnClickListener(this);
            settingItem.setSecondaryText("百余张精选壁纸等你来选");
            addView(settingItem);
            this.r = a(context, "仅在首页头部区域、直达页展示壁纸");
            View inflate = LayoutInflater.from(context).inflate(R.layout.cp, (ViewGroup) null);
            this.p = (ImageView) inflate.findViewById(R.id.iv_skin_simple_check);
            this.q = (ImageView) inflate.findViewById(R.id.iv_skin_full_check);
            if (SkinManager.s().x()) {
                this.p.setImageResource(R.drawable.b79);
                this.q.setImageResource(R.drawable.b7b);
                this.r.setText("仅在首页头部区域、直达页展示壁纸");
            } else {
                this.p.setImageResource(R.drawable.b7b);
                this.q.setImageResource(R.drawable.b79);
                this.r.setText("全场景展示壁纸,除直达外壁纸模糊显示");
            }
            this.p.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    EventCollector.getInstance().onViewClickedBefore(view);
                    SkinAndFontSettingView.this.a(true);
                    EventCollector.getInstance().onViewClicked(view);
                }
            });
            this.q.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    EventCollector.getInstance().onViewClickedBefore(view);
                    SkinAndFontSettingView.this.a(false);
                    EventCollector.getInstance().onViewClicked(view);
                }
            });
            ViewGroup.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, MttResources.s(222));
            QBWebImageView qBWebImageView = (QBWebImageView) inflate.findViewById(R.id.iv_simple_skin);
            QBWebImageView qBWebImageView2 = (QBWebImageView) inflate.findViewById(R.id.iv_full_skin);
            qBWebImageView2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    EventCollector.getInstance().onViewClickedBefore(view);
                    SkinAndFontSettingView.this.a(false);
                    EventCollector.getInstance().onViewClicked(view);
                }
            });
            qBWebImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    EventCollector.getInstance().onViewClickedBefore(view);
                    SkinAndFontSettingView.this.a(true);
                    EventCollector.getInstance().onViewClicked(view);
                }
            });
            qBWebImageView2.setPlaceHolderDrawable(null);
            qBWebImageView.setPlaceHolderDrawable(null);
            qBWebImageView2.setUrl("https://m4.publicimg.browser.qq.com/publicimg/nav/skin_setting_full_1.png");
            qBWebImageView.setUrl("https://m4.publicimg.browser.qq.com/publicimg/nav/skin_setting_simple_2.png");
            SimpleSkinBuilder.a(inflate).a(R.color.theme_common_color_item_bg).c(R.color.theme_common_color_item_bg).c().f();
            addView(inflate, layoutParams);
            addView(this.r);
            WallpaperToggleController.a(settingItem, PanEventHelper.PanEvent.EVENT_END);
        } else {
            if (this.o == null) {
                this.o = new SettingItem(getContext(), 100, this.D);
                this.o.setId(75);
                this.o.setMainText(WallpaperToggleController.b());
                this.o.a(0, 0, 0, 0);
                this.o.setOnClickListener(this);
                addView(this.o);
            }
            WallpaperToggleController.a(this.o, PanEventHelper.PanEvent.EVENT_END);
        }
        a("wallpapercentre_exp");
    }

    private static void a(String str) {
        HashMap hashMap = new HashMap();
        hashMap.put("action", str);
        hashMap.put("now_model", String.valueOf(SkinManager.s().x() ? 1 : 0));
        StatManager.b().b("wallpaper_model", hashMap);
    }

    public void a(boolean z) {
        TextView textView;
        String str;
        a("model_clk");
        ImageView imageView = this.p;
        if (z) {
            imageView.setImageResource(R.drawable.b79);
            this.q.setImageResource(R.drawable.b7b);
            textView = this.r;
            str = "仅在首页头部区域、直达页展示壁纸";
        } else {
            imageView.setImageResource(R.drawable.b7b);
            this.q.setImageResource(R.drawable.b79);
            textView = this.r;
            str = "全场景展示壁纸,除直达外壁纸模糊显示";
        }
        textView.setText(str);
        SkinManager.s().d(z);
    }

    private View b(Context context) {
        View view = new View(context);
        view.setLayoutParams(new FrameLayout.LayoutParams(-1, 1));
        SimpleSkinBuilder.a(view).a(e.E).f();
        return view;
    }

    private void f() {
        WebEngine e = WebEngine.e();
        if (e == null || !e.o()) {
            i();
        } else {
            h();
        }
        this.k = FontSizeManager.a().b();
    }

    private Bitmap getBackGroundSkinBitmap() {
        Bitmap c2 = MttResourceNew.c(g.bj);
        return c2 == null ? MttResourceNew.a(g.z, true) : c2;
    }

    private StateListDrawable getCursorDrawable() {
        Drawable i;
        Drawable i2;
        if (SkinManager.s().l()) {
            i = UIBitmapUtils.a(MttResources.i(R.drawable.b6e), Color.parseColor("#80000000"));
            i2 = UIBitmapUtils.a(MttResources.i(R.drawable.b6f), Color.parseColor("#80000000"));
        } else {
            i = MttResources.i(R.drawable.b6e);
            i2 = MttResources.i(R.drawable.b6f);
        }
        StateListDrawable stateListDrawable = new StateListDrawable();
        stateListDrawable.addState(new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled}, i2);
        stateListDrawable.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_focused}, i);
        stateListDrawable.addState(new int[]{android.R.attr.state_enabled}, i);
        stateListDrawable.addState(new int[]{android.R.attr.state_focused}, i);
        stateListDrawable.addState(new int[]{android.R.attr.state_window_focused}, i);
        stateListDrawable.addState(new int[0], i);
        return stateListDrawable;
    }

    private void h() {
        String str = this.g;
        this.i = new CharSequence[]{str, null, this.h, null, null, null, str};
        int i = this.f59592b;
        this.j = new float[]{i, 0.0f, i, 0.0f, 0.0f, 0.0f, UIResourceDimen.a(25.0f)};
    }

    private void i() {
        String str = this.g;
        this.i = new CharSequence[]{str, null, this.h, null, str};
        this.j = new float[]{MttResources.f(f.cQ), 0.0f, MttResources.f(f.cQ), 0.0f, UIResourceDimen.a(25.0f)};
    }

    @Override
    public void a(int i, QBPluginItemInfo qBPluginItemInfo, Object obj) {
        SettingItem settingItem;
        if (i == 3) {
            String e = QbFontManager.a().e();
            ArrayList<QBPluginItemInfo> b2 = QbFontPluginManager.a().b();
            int size = b2.size();
            for (int i2 = 0; i2 < size; i2++) {
                QBPluginItemInfo qBPluginItemInfo2 = b2.get(i2);
                if (TextUtils.equals(qBPluginItemInfo2.mPackageName, e) && (settingItem = this.n) != null) {
                    settingItem.setSecondaryText(qBPluginItemInfo2.mTitle);
                }
            }
        }
    }

    @Override
    public void b() {
        super.b();
        QbFontPluginManager.a().a(this);
    }

    public void e() {
        SettingItem settingItem = this.n;
        if (settingItem != null) {
            settingItem.setVisibility(8);
        }
        TextView textView = this.s;
        if (textView != null) {
            textView.setVisibility(8);
        }
    }

    @Override
    public void onClick(View view) {
        SettingItem settingItem;
        EventCollector.getInstance().onViewClickedBefore(view);
        int id = view.getId();
        if (id == 74) {
            StatManager.b().c("EIC0302");
            a(67, (Bundle) null);
        } else if (id == 75) {
            StatManager.b().c("DJ1012");
            StatManager.b().c("EIC11");
            HashMap hashMap = new HashMap();
            hashMap.put("url", "");
            hashMap.put("entry", String.valueOf(119));
            CMC.a("cmc://statistics/m?cmd=onStatEntryType", hashMap);
            PublicSettingManager.a().setBoolean("is_need_show_Red_point", false);
            PublicSettingManager.a().setLong("key_skin_hotpoint_chick_time", System.currentTimeMillis());
            WallpaperToggleController.a(PanEventHelper.PanEvent.EVENT_END);
            WallpaperToggleController.c();
            if (!SkinHelper.a() && (settingItem = this.o) != null) {
                settingItem.b();
                this.o.a(false, "");
            }
            BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
                @Override
                public void doRun() {
                    String string = PublicSettingManager.a().getString("key_skin_hotpoint_push_skin_thumb_path", "");
                    if (TextUtils.isEmpty(string)) {
                        return;
                    }
                    File file = new File(string);
                    if (file.exists()) {
                        try {
                            FileUtils.a(file);
                        } catch (Exception unused) {
                        }
                    }
                    PublicSettingManager.a().setString("key_skin_hotpoint_push_skin_thumb_path", "");
                }
            });
        }
        EventCollector.getInstance().onViewClicked(view);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        return motionEvent.getAction() == 2 ? this.l.getXVelocity() < this.l.getYVelocity() : super.onInterceptTouchEvent(motionEvent);
    }

    @Override
    public boolean onTouchEvent(MotionEvent motionEvent) {
        this.l.addMovement(motionEvent);
        return super.onTouchEvent(motionEvent);
    }
}