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

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


package com.tencent.mtt.browser.appstoreguide;

import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.View;
import com.tencent.common.utils.StringUtils;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.functionwindow.IFunctionWndFactory;
import com.tencent.mtt.base.notification.facade.IMessageBubbleListener;
import com.tencent.mtt.base.notification.facade.IMessageBubbleService;
import com.tencent.mtt.base.notification.facade.NormalMessageBundle;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.wup.DomainListDataManager;
import com.tencent.mtt.browser.WebEngine;
import com.tencent.mtt.browser.appstoreguide.AppstoreGuideConfig;
import com.tencent.mtt.browser.appstoreguide.AppstoreGuideOpItem;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.qbinfo.IQConfigure;
import com.tencent.mtt.setting.PublicSettingManager;
import com.tencent.mtt.view.dialog.newui.SimpleDialogBuilder;
import com.tencent.mtt.view.dialog.newui.builder.api.base.IDialogBuilder;
import com.tencent.mtt.view.dialog.newui.builder.api.base.IDialogBuilderInterface;
import com.tencent.mtt.view.dialog.newui.dialog.DialogBase;
import com.tencent.mtt.view.dialog.newui.view.ViewOnClickListener;
import java.util.ArrayList;

class AppstoreGuideManager implements IAppstoreGuideManager {

    private DialogBase f35351a;

    private static class AppStateListener implements ActivityHandler.ApplicationStateListener {

        private long f35373a;

        public AppStateListener(long j) {
            this.f35373a = j;
        }

        @Override
        public void onApplicationState(ActivityHandler.State state) {
            if (state == ActivityHandler.State.foreground && System.currentTimeMillis() - this.f35373a <= 120000) {
                AppstoreGuideManager.b();
            } else if (state != ActivityHandler.State.foreground || System.currentTimeMillis() - this.f35373a <= 120000) {
                return;
            }
            ActivityHandler.b().b(this);
        }
    }

    public static class LazyInstance {

        private static final IAppstoreGuideManager f35374a = new AppstoreGuideManager();

        private static final Handler f35375b = new Handler(Looper.getMainLooper());

        private LazyInstance() {
        }
    }

    private AppstoreGuideManager() {
    }

    public static IAppstoreGuideManager a() {
        return LazyInstance.f35374a;
    }

    private void a(final GuideBundle guideBundle, final AppstoreGuideConfig appstoreGuideConfig) {
        LazyInstance.f35375b.postDelayed(new Runnable() {
            @Override
            public void run() {
                AppstoreGuideManager.this.b(guideBundle, appstoreGuideConfig);
            }
        }, 50L);
    }

    public void a(DialogBase dialogBase) {
        if (dialogBase == null || !dialogBase.isShowing()) {
            return;
        }
        dialogBase.dismiss();
    }

    public void a(final String str) {
        SimpleDialogBuilder.a().a(IDialogBuilderInterface.ImageStyle.MATCH_MARGIN).a(MttResources.l(R.string.j1)).e(MttResources.l(R.string.j0)).a((CharSequence) MttResources.l(R.string.iz)).a_(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                AppstoreGuideManager.this.b(str);
                AppstoreGuideManager.this.a(dialogBase);
                AppstoreGuideManager appstoreGuideManager = AppstoreGuideManager.this;
                appstoreGuideManager.a(appstoreGuideManager.f35351a);
            }
        }).c(MttResources.l(R.string.iy)).c(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                AppstoreGuideUtils.a(str, "feedback_next_exposure");
                AppstoreGuideManager.this.a(dialogBase);
                AppstoreGuideManager appstoreGuideManager = AppstoreGuideManager.this;
                appstoreGuideManager.a(appstoreGuideManager.f35351a);
            }
        }).a(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialogInterface) {
                AppstoreGuideUtils.a(str, "feedback_exposure");
            }
        }).a(new IDialogBuilder.BackListener() {
            @Override
            public boolean handleBack(DialogBase dialogBase) {
                AppstoreGuideUtils.a(str, "feedback_close_exposure");
                AppstoreGuideManager.this.a(dialogBase);
                AppstoreGuideManager appstoreGuideManager = AppstoreGuideManager.this;
                appstoreGuideManager.a(appstoreGuideManager.f35351a);
                return true;
            }
        }).b(false).e();
    }

    public void a(String str, AppstoreGuideOpItem.UserOp userOp) {
        String str2;
        AppstoreGuideOpItem appstoreGuideOpItem = new AppstoreGuideOpItem();
        appstoreGuideOpItem.f35378c = str;
        appstoreGuideOpItem.e = true;
        appstoreGuideOpItem.f35376a = userOp;
        appstoreGuideOpItem.f35377b = System.currentTimeMillis();
        appstoreGuideOpItem.f35379d = IQConfigure.f69588a;
        PublicSettingManager.a().remove("sp_guide_key");
        PublicSettingManager.a().setString("sp_guide_key", appstoreGuideOpItem.a());
        if (userOp == AppstoreGuideOpItem.UserOp.UP_VOTE) {
            str2 = "praise_like_click";
        } else if (userOp == AppstoreGuideOpItem.UserOp.DOWN_VOTE) {
            str2 = "praise_unlike_click";
        } else if (userOp != AppstoreGuideOpItem.UserOp.CANCEL) {
            return;
        } else {
            str2 = "praise_close_click";
        }
        AppstoreGuideUtils.a(str, str2);
    }

    private boolean a(long j, long j2, long j3, String str, String str2) {
        return j3 - j >= j2 && !str2.equalsIgnoreCase(str);
    }

    private int b(GuideBundle guideBundle) {
        if (guideBundle == null) {
            return -4;
        }
        boolean c2 = c("ANDROID_PUBLIC_PREFS_APPSTORE_CTRL");
        boolean c3 = c("ANDROID_PUBLIC_PREFS_APPSTORE_SCENE_" + guideBundle.f35380a.toUpperCase());
        if (!c2) {
            return -1;
        }
        if (!c3) {
            return -2;
        }
        AppstoreGuideOpItem e = e();
        AppstoreGuideConfig f = f();
        if (e == null) {
            a(guideBundle, f);
            return 0;
        }
        AppstoreGuideOpItem.UserOp userOp = e.f35376a;
        if (userOp == AppstoreGuideOpItem.UserOp.UP_VOTE) {
            if (!a(e.f35377b, 86400000 * f.f35342a, System.currentTimeMillis(), e.f35379d, IQConfigure.f69588a)) {
                return -3;
            }
            a(guideBundle, f);
            return 0;
        }
        if (userOp != AppstoreGuideOpItem.UserOp.CANCEL && userOp != AppstoreGuideOpItem.UserOp.DOWN_VOTE) {
            a(guideBundle, f);
            return 0;
        }
        if (IQConfigure.f69588a.equalsIgnoreCase(e.f35379d)) {
            return -3;
        }
        a(guideBundle, f);
        return 0;
    }

    public static void b() {
        int i;
        if (TextUtils.equals(PublicSettingManager.a().getString("ANDROID_PUBLIC_PREFS_DEFAULT_BROWSER_SET_TIPS", "1"), "0") || "com.tencent.mtt".equals(WebEngine.e().G()) || (i = PublicSettingManager.a().getInt("set_default_browser_tips_show_times", 0)) >= 3) {
            return;
        }
        if (System.currentTimeMillis() - PublicSettingManager.a().getLong("set_default_browser_tips_last_show_time", 0L) < 86400000) {
            return;
        }
        NormalMessageBundle normalMessageBundle = new NormalMessageBundle();
        normalMessageBundle.f32713d = "设置QQ浏览器为默认浏览器,打开网页更便捷";
        normalMessageBundle.m = "";
        normalMessageBundle.e = "去设置";
        normalMessageBundle.f = true;
        ((IMessageBubbleService) QBContext.getInstance().getService(IMessageBubbleService.class)).showNormalBubble(normalMessageBundle, new IMessageBubbleListener() {
            @Override
            public void a() {
                Bundle bundle = new Bundle();
                bundle.putInt("ViewID", 13);
                bundle.putInt("set_default_browser_from_where", 1);
                ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams(IFunctionWndFactory.WND_SETTING).d(2).a(bundle).d(true));
                StatManager.b().c("BHS0003");
            }

            @Override
            public void b() {
                Bundle bundle = new Bundle();
                bundle.putInt("ViewID", 13);
                bundle.putInt("set_default_browser_from_where", 1);
                ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams(IFunctionWndFactory.WND_SETTING).d(2).a(bundle).d(true));
                StatManager.b().c("BHS0003");
            }

            @Override
            public void c() {
            }
        });
        StatManager.b().c("BHS0002");
        PublicSettingManager.a().setLong("set_default_browser_tips_last_show_time", System.currentTimeMillis());
        PublicSettingManager.a().setInt("set_default_browser_tips_show_times", i + 1);
    }

    public void b(final GuideBundle guideBundle, AppstoreGuideConfig appstoreGuideConfig) {
        AppstoreGuideConfig.TipsContent a2 = appstoreGuideConfig.a(guideBundle.f35380a);
        if (a2 == null) {
            return;
        }
        this.f35351a = SimpleDialogBuilder.a().a(IDialogBuilderInterface.ImageStyle.MATCH_MARGIN).a(a2.f35345b).e(a2.f35346c).a((CharSequence) a2.f35347d).a_(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                AppstoreGuideManager.this.d();
                AppstoreGuideManager.this.a(guideBundle.f35380a, AppstoreGuideOpItem.UserOp.UP_VOTE);
                ActivityHandler.b().a(new AppStateListener(System.currentTimeMillis()));
                AppstoreGuideManager.this.a(dialogBase);
            }
        }).b(a2.e).b(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                AppstoreGuideManager.this.a(guideBundle.f35380a);
                AppstoreGuideManager.this.a(guideBundle.f35380a, AppstoreGuideOpItem.UserOp.DOWN_VOTE);
            }
        }).c("取消").c(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                AppstoreGuideManager.this.a(guideBundle.f35380a, AppstoreGuideOpItem.UserOp.CANCEL);
                AppstoreGuideManager.this.a(dialogBase);
            }
        }).a(new IDialogBuilder.BackListener() {
            @Override
            public boolean handleBack(DialogBase dialogBase) {
                AppstoreGuideManager.this.a(guideBundle.f35380a, AppstoreGuideOpItem.UserOp.CANCEL);
                AppstoreGuideManager.this.a(dialogBase);
                return true;
            }
        }).b(false).a(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialogInterface) {
                AppstoreGuideUtils.a(guideBundle.f35380a, "praise_exposure");
            }
        }).e();
    }

    public void b(String str) {
        new UrlParams("https://res.imtt.qq.com/help/x5/bbs_redirect_android.html").b(1).c(13).e();
        AppstoreGuideUtils.a(str, "feedback_write_exposure");
    }

    private boolean c(String str) {
        return StringUtils.b(PublicSettingManager.a().getString(str, "0"), 0) == 1;
    }

    public void d() {
        AppstoreGuideUtils.a(ContextHolder.getAppContext());
    }

    private AppstoreGuideOpItem e() {
        String string = PublicSettingManager.a().getString("sp_guide_key", null);
        if (TextUtils.isEmpty(string)) {
            return null;
        }
        return AppstoreGuideOpItem.a(string);
    }

    private AppstoreGuideConfig f() {
        ArrayList<String> a2 = DomainListDataManager.a().a(379);
        return (a2 == null || a2.isEmpty()) ? AppstoreGuideConfig.a() : AppstoreGuideConfig.b(a2.get(0));
    }

    @Override
    public synchronized int a(GuideBundle guideBundle) {
        return b(guideBundle);
    }

    @Override
    public void c() {
        PublicSettingManager.a().remove("sp_guide_key");
    }
}