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

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


package com.tencent.mtt.browser.homepage.visit.tips;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.tencent.common.manifest.EventMessage;
import com.tencent.common.manifest.annotation.CreateMethod;
import com.tencent.common.manifest.annotation.EventReceiver;
import com.tencent.common.task.QBTask;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.notification.facade.IMessageBubbleListener;
import com.tencent.mtt.base.notification.facade.IMessageBubbleService;
import com.tencent.mtt.base.notification.facade.RoundTypeMessageBundle;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.utils.PlatformStatUtils;
import com.tencent.mtt.browser.homepage.fastcut.IFastCutTittleManager;
import com.tencent.mtt.browser.homepage.fastcut.manager.FastCutManager;
import com.tencent.mtt.browser.homepage.fastcut.model.FastCutItemRecord;
import com.tencent.mtt.browser.homepage.fastcut.report.FastCutReportHelper;
import com.tencent.mtt.browser.homepage.fastcut.util.FastCutIconUtil;
import com.tencent.mtt.browser.homepage.shortcat.model.FastCutRecordData;
import com.tencent.mtt.browser.multiwindow.facade.IMultiWindowService;
import com.tencent.mtt.frequence.visit.Scene;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.view.dialog.newui.SimpleDialogBuilder;
import com.tencent.mtt.view.dialog.newui.builder.api.ICommonDialogBuilder;
import com.tencent.mtt.view.dialog.newui.dialog.DialogBase;
import com.tencent.mtt.view.dialog.newui.view.ViewOnClickListener;
import java.util.concurrent.Callable;

public class ShowTipsManager implements ActivityHandler.ApplicationStateListener {

    private static final int f41280a = MttResources.s(32);

    private static final int f41281b = MttResources.s(54);

    private long f41282c;

    static class InstanceHolder {

        public static final ShowTipsManager f41300a = new ShowTipsManager();

        InstanceHolder() {
        }
    }

    private ShowTipsManager() {
        this.f41282c = -1L;
        ActivityHandler.b().a(this);
    }

    public static Drawable a(View view) {
        return new BitmapDrawable((Resources) null, b(view));
    }

    public static TextView a(String str, String str2) {
        TextView textView = new TextView(ContextHolder.getAppContext());
        if (TextUtils.isEmpty(str) && TextUtils.isEmpty(str2)) {
            return textView;
        }
        if (TextUtils.isEmpty(str2)) {
            str2 = str;
        }
        String a2 = FastCutIconUtil.a(null, str, str2);
        Drawable a3 = FastCutIconUtil.a(FastCutIconUtil.a(str), str2);
        textView.setText(a2);
        textView.setTextSize(1, 22.0f);
        textView.setGravity(17);
        textView.setBackground(a3);
        textView.setTextColor(-1);
        textView.setWidth(f41281b);
        textView.setHeight(f41281b);
        return textView;
    }

    private String a(String str) {
        char c2;
        switch (str.hashCode()) {
            case 98822:
                if (str.equals("csv")) {
                    c2 = 4;
                    break;
                }
                c2 = 65535;
                break;
            case 99640:
                if (str.equals("doc")) {
                    c2 = 0;
                    break;
                }
                c2 = 65535;
                break;
            case 110834:
                if (str.equals("pdf")) {
                    c2 = 7;
                    break;
                }
                c2 = 65535;
                break;
            case 111220:
                if (str.equals("ppt")) {
                    c2 = 5;
                    break;
                }
                c2 = 65535;
                break;
            case 118783:
                if (str.equals("xls")) {
                    c2 = 2;
                    break;
                }
                c2 = 65535;
                break;
            case 3088960:
                if (str.equals("docx")) {
                    c2 = 1;
                    break;
                }
                c2 = 65535;
                break;
            case 3447940:
                if (str.equals("pptx")) {
                    c2 = 6;
                    break;
                }
                c2 = 65535;
                break;
            case 3682393:
                if (str.equals("xlsx")) {
                    c2 = 3;
                    break;
                }
                c2 = 65535;
                break;
            default:
                c2 = 65535;
                break;
        }
        switch (c2) {
            case 0:
            case 1:
                return "https://m4.publicimg.browser.qq.com/publicimg/nav/xhome/icon_local_doc.png";
            case 2:
            case 3:
            case 4:
                return "https://m4.publicimg.browser.qq.com/publicimg/nav/xhome/icon_local_xls.png";
            case 5:
            case 6:
                return "https://m4.publicimg.browser.qq.com/publicimg/nav/xhome/icon_local_ppt.png";
            case 7:
                return "https://m4.publicimg.browser.qq.com/publicimg/nav/xhome/icon_local_pdf.png";
            default:
                return "";
        }
    }

    private void a() {
        if (this.f41282c == -1 || !((IMessageBubbleService) QBContext.getInstance().getService(IMessageBubbleService.class)).closeMyBubble(this.f41282c)) {
            return;
        }
        this.f41282c = -1L;
    }

    public void a(final String str, final String str2, final String str3) {
        final Bitmap p = MttResources.p(R.drawable.ah5);
        final ICommonDialogBuilder c2 = SimpleDialogBuilder.a(ActivityHandler.b().n()).b(true).d("添加至直达,下次使用更快捷").a((CharSequence) "添加直达").c("暂不添加").a_(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                ShowTipsManager.this.b(str, str2, str3, Scene.MINI_PROGRAM_FOR_DIALOG, "");
                dialogBase.dismiss();
            }
        }).c(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                dialogBase.dismiss();
            }
        });
        RequestOptions requestOptions = new RequestOptions();
        int i = f41280a;
        Glide.with(ContextHolder.getAppContext()).asBitmap().load(str3).apply(requestOptions.override(i, i).fitCenter()).into((RequestBuilder<Bitmap>) new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) {
                ShowTipsManager.b(ShowTipsManager.b(p, bitmap), c2);
            }
        });
    }

    private void a(String str, String str2, String str3, final String str4, boolean z, final String str5, long j, final String str6, boolean z2, boolean z3, final Scene scene, final String str7) {
        if (scene == Scene.WEB && !TextUtils.equals(WindowPopHelper.b(), str6)) {
            PlatformStatUtils.a("VISITHELPER_SHOWTIPS_URL_DIFF");
            return;
        }
        if (scene != Scene.WEB || ((IFastCutTittleManager) QBContext.getInstance().getService(IFastCutTittleManager.class)).isValidTittle(str)) {
            RoundTypeMessageBundle roundTypeMessageBundle = new RoundTypeMessageBundle();
            if (str5.equals("")) {
                roundTypeMessageBundle.f32712c = a(a(str6, str4));
            } else {
                roundTypeMessageBundle.f32711b = str5;
            }
            roundTypeMessageBundle.j = str;
            roundTypeMessageBundle.k = str2;
            roundTypeMessageBundle.e = str3;
            roundTypeMessageBundle.f = z;
            roundTypeMessageBundle.g = j;
            if (scene != Scene.WEB) {
                roundTypeMessageBundle.i = true;
            }
            roundTypeMessageBundle.n = 1;
            roundTypeMessageBundle.l = z2;
            roundTypeMessageBundle.m = z3;
            this.f41282c = ((IMessageBubbleService) QBContext.getInstance().getService(IMessageBubbleService.class)).showNormalBubble(roundTypeMessageBundle, new IMessageBubbleListener() {
                @Override
                public void a() {
                }

                @Override
                public void b() {
                    ShowTipsManager.this.b(str4, str6, str5, scene, str7);
                }

                @Override
                public void c() {
                }
            });
        }
    }

    private void a(String str, String str2, String str3, String str4, boolean z, boolean z2, Scene scene, String str5, long j) {
        a(str, "一键访问,方便快捷", "添加", str4, true, str2, j, str3, z, z2, scene, str5);
    }

    public static Bitmap b(Bitmap bitmap, Bitmap bitmap2) {
        Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
        Canvas canvas = new Canvas(createBitmap);
        canvas.drawBitmap(bitmap, 0.0f, 0.0f, (Paint) null);
        canvas.drawBitmap(bitmap2, MttResources.s(150), MttResources.s(45), (Paint) null);
        return createBitmap;
    }

    public static Bitmap b(View view) {
        view.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0));
        view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
        view.setDrawingCacheEnabled(true);
        Bitmap createBitmap = Bitmap.createBitmap(view.getDrawingCache());
        view.destroyDrawingCache();
        view.setDrawingCacheEnabled(false);
        return createBitmap;
    }

    public static void b(Bitmap bitmap, ICommonDialogBuilder iCommonDialogBuilder) {
        iCommonDialogBuilder.a(bitmap).e();
    }

    public void b(String str, String str2, String str3, Scene scene, String str4) {
        FastCutRecordData.FastCutRecord.Builder newBuilder = FastCutRecordData.FastCutRecord.newBuilder();
        if (str == null) {
            str = "";
        }
        FastCutRecordData.FastCutRecord.Builder title = newBuilder.setTitle(str);
        if (str2 == null) {
            str2 = "";
        }
        FastCutRecordData.FastCutRecord.Builder deepLink = title.setDeepLink(str2);
        if (str4 == null) {
            str4 = "";
        }
        FastCutRecordData.FastCutRecord.Builder serviceWindowId = deepLink.setServiceWindowId(str4);
        if (str3 == null) {
            str3 = "";
        }
        FastCutItemRecord fastCutItemRecord = new FastCutItemRecord(serviceWindowId.setIconUrl(str3).setSourceId(scene.getSource()).build());
        FastCutManager.getInstance().addFastCut(fastCutItemRecord, true, null);
        FastCutReportHelper.a(fastCutItemRecord, "3", scene);
    }

    public static ShowTipsManager getInstance() {
        return InstanceHolder.f41300a;
    }

    public void a(String str, String str2, String str3, Scene scene) {
        a(str, str2, str3, scene, "");
    }

    public void a(final String str, final String str2, final String str3, Scene scene, String str4) {
        String str5;
        String str6;
        String str7;
        boolean z;
        boolean z2;
        long j;
        String str8;
        switch (scene) {
            case WEB:
                str5 = str;
                str6 = str2;
                str7 = str3;
                z = true;
                z2 = true;
                j = 0;
                str8 = "常用网址添加到直达";
                a(str8, str5, str6, str7, z, z2, scene, str4, j);
                return;
            case FILE:
                str6 = str2;
                str7 = str3;
                str5 = a(str);
                z = false;
                z2 = false;
                j = 7000;
                str8 = "常用文件添加到直达";
                a(str8, str5, str6, str7, z, z2, scene, str4, j);
                return;
            case MINI_PROGRAM_FOR_DIALOG:
                QBTask.b((Callable) new Callable<Object>() {
                    @Override
                    public Object call() throws Exception {
                        ShowTipsManager.this.a(str3, str2, str);
                        return null;
                    }
                });
                return;
            case MINI_PROGRAM_FOR_TIPS:
                a("常用小程序添加直达", str, str2, str3, true, true, scene, str4, 0L);
                break;
            case QB_SERVICE:
                a("常用服务窗添加直达", str, str2, str3, true, true, scene, str4, 0L);
                break;
            case TENCENT_LONG_VIDEO:
                a("爱看视频添加到直达", str, str2, str3, true, true, scene, str4, 0L);
                return;
            case NOVEL_TXT:
                a("常看小说添加到直达", str, str2, str3, true, true, scene, str4, 7000L);
                break;
        }
    }

    @Override
    public void onApplicationState(ActivityHandler.State state) {
        if (state == ActivityHandler.State.background) {
            a();
        }
    }

    @EventReceiver(createMethod = CreateMethod.GET, eventName = "onBrowserMenuShow")
    public void onBrowserMenuShow(EventMessage eventMessage) {
        a();
    }

    @EventReceiver(createMethod = CreateMethod.GET, eventName = IMultiWindowService.EVENT_MULTI_WINDOW)
    public void onMultiWindowShow(EventMessage eventMessage) {
        a();
    }

    @EventReceiver(createMethod = CreateMethod.GET, eventName = "com.tencent.mtt.browser.window.data.WindowInfo.onPageBackOrForwardChanged")
    public void onPageBackOrForwardChanged(EventMessage eventMessage) {
        a();
    }
}