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

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


package com.tencent.mtt.browser.homepage.fastcut.util;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import com.tencent.common.http.NetUtils;
import com.tencent.common.utils.Md5Utils;
import com.tencent.common.utils.UrlUtils;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.browser.homepage.appdata.AppInfoLoader;
import com.tencent.mtt.browser.setting.manager.SkinManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class FastCutIconUtil {

    static final boolean f39741d = !FastCutIconUtil.class.desiredAssertionStatus();

    static Map<String, ColorType> f39738a = new HashMap();

    static List<ColorType> f39739b = new ArrayList();
    private static final String[] e = {"红", "紅", "橙", "黄", "黃", "绿", "綠", "青", "蓝", "藍", "紫"};

    static Map<String, String> f39740c = new HashMap();

    public enum ColorType {
        DEFAULT,
        RED,
        ORANGE,
        YELLOW,
        GREEN,
        CYAN,
        BLUE,
        PURPLE
    }

    static {
        c();
    }

    public static int a(String str) {
        if (TextUtils.isEmpty(str)) {
            return 0;
        }
        String lowerCase = str.toLowerCase();
        if (h(lowerCase)) {
            return 7;
        }
        if (o(lowerCase)) {
            return 2;
        }
        if (i(lowerCase)) {
            return 3;
        }
        if (m(lowerCase)) {
            return 6;
        }
        if (j(lowerCase)) {
            return 9;
        }
        if (k(lowerCase)) {
            return 8;
        }
        if (l(lowerCase)) {
            return 4;
        }
        return n(lowerCase) ? 1 : 0;
    }

    public static Drawable a() {
        return a(f39738a.get(""));
    }

    public static Drawable a(int i, String str) {
        Drawable c2;
        if (i == 1 || i == 2) {
            c2 = c(str);
            if (c2.getConstantState() == a().getConstantState()) {
                c2 = f(str);
            }
        } else {
            c2 = a();
        }
        c2.setVisible(true, true);
        c2.setAlpha(SkinManager.s().l() ? 102 : 255);
        return c2;
    }

    static Drawable a(ColorType colorType) {
        int i;
        Drawable drawable;
        Context appContext = ContextHolder.getAppContext();
        switch (colorType) {
            case DEFAULT:
            default:
                drawable = appContext.getDrawable(R.drawable.u5);
                break;
            case RED:
                i = R.drawable.ua;
                drawable = appContext.getDrawable(i);
                break;
            case ORANGE:
                i = R.drawable.u9;
                drawable = appContext.getDrawable(i);
                break;
            case YELLOW:
                i = R.drawable.ub;
                drawable = appContext.getDrawable(i);
                break;
            case GREEN:
                i = R.drawable.u8;
                drawable = appContext.getDrawable(i);
                break;
            case CYAN:
                i = R.drawable.u7;
                drawable = appContext.getDrawable(i);
                break;
            case BLUE:
                i = R.drawable.u6;
                drawable = appContext.getDrawable(i);
                break;
            case PURPLE:
                i = R.drawable.u_;
                drawable = appContext.getDrawable(i);
                break;
        }
        if (f39741d || drawable != null) {
            return drawable;
        }
        throw new AssertionError();
    }

    public static String a(Map<String, String> map, String str, String str2) {
        if ((map == null || !TextUtils.equals(map.get("Illegal"), "1")) && !TextUtils.isEmpty(str2)) {
            if (str2.length() >= 2) {
                String substring = str2.substring(0, 2);
                if (d(substring)) {
                    return substring;
                }
            }
            String a2 = AppInfoLoader.a(str2);
            return TextUtils.isEmpty(a2) ? e(str) : a2;
        }
        return e(str);
    }

    private static boolean a(char c2) {
        return c2 == 0 || c2 == '\t' || c2 == '\n' || c2 == '\r' || (c2 >= ' ' && c2 <= 55295) || ((c2 >= 57344 && c2 <= 65533) || (c2 >= 0 && c2 <= 65535));
    }

    public static String b(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        String lowerCase = str.toLowerCase();
        if (lowerCase.endsWith(".doc") || lowerCase.endsWith(".docx")) {
            return "https://m4.publicimg.browser.qq.com/publicimg/nav/quicklink/fast_cut_icon_word.png";
        }
        if (lowerCase.endsWith(".xls") || lowerCase.endsWith(".xlsx")) {
            return "https://m4.publicimg.browser.qq.com/publicimg/nav/quicklink/fast_cut_icon_excel.png";
        }
        if (lowerCase.endsWith(".ppt") || lowerCase.endsWith(".pptx")) {
            return "https://m4.publicimg.browser.qq.com/publicimg/nav/quicklink/fast_cut_icon_ppt.png";
        }
        if (lowerCase.endsWith(".pdf")) {
            return "https://m4.publicimg.browser.qq.com/publicimg/nav/quicklink/fast_cut_icon_pdf.png";
        }
        return null;
    }

    static boolean b() {
        return false;
    }

    public static Drawable c(String str) {
        String str2 = f39740c.get(str);
        if (str2 == null) {
            str2 = g(str);
            f39740c.put(str, str2);
        }
        return a(f39738a.get(str2));
    }

    private static synchronized void c() {
        synchronized (FastCutIconUtil.class) {
            f39739b.add(ColorType.DEFAULT);
            f39739b.add(ColorType.RED);
            f39739b.add(ColorType.ORANGE);
            f39739b.add(ColorType.YELLOW);
            f39739b.add(ColorType.GREEN);
            f39739b.add(ColorType.CYAN);
            f39739b.add(ColorType.BLUE);
            f39739b.add(ColorType.PURPLE);
            f39738a.put("", ColorType.DEFAULT);
            f39738a.put("红", ColorType.RED);
            f39738a.put("紅", ColorType.RED);
            f39738a.put("橙", ColorType.ORANGE);
            f39738a.put("黄", ColorType.YELLOW);
            f39738a.put("黃", ColorType.YELLOW);
            f39738a.put("绿", ColorType.GREEN);
            f39738a.put("綠", ColorType.GREEN);
            f39738a.put("青", ColorType.CYAN);
            f39738a.put("蓝", ColorType.BLUE);
            f39738a.put("藍", ColorType.BLUE);
            f39738a.put("紫", ColorType.PURPLE);
        }
    }

    public static boolean d(String str) {
        int length = str.length();
        for (int i = 0; i < length; i++) {
            if (!a(str.charAt(i))) {
                return true;
            }
        }
        return false;
    }

    public static String e(String str) {
        String hostNew = UrlUtils.getHostNew(str);
        return (TextUtils.isEmpty(hostNew) || hostNew.length() <= 0) ? "" : hostNew.substring(0, 1).toUpperCase();
    }

    public static Drawable f(String str) {
        return a(f39739b.get(Md5Utils.a(str).charAt(0) % f39739b.size()));
    }

    private static String g(String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        if (b() && str.length() > 500) {
            throw new IllegalArgumentException("文案过长,会影响查找性能,请优化。【此异常仅在调试时出现】");
        }
        int i = Integer.MAX_VALUE;
        for (String str2 : e) {
            int indexOf = str.indexOf(str2);
            if (indexOf != -1 && indexOf < i) {
                i = indexOf;
            }
        }
        return i != Integer.MAX_VALUE ? str.substring(i, i + 1) : "";
    }

    private static boolean h(String str) {
        return str.startsWith("qb://filesdk");
    }

    private static boolean i(String str) {
        return str.startsWith("qb://ext/read");
    }

    private static boolean j(String str) {
        return str.startsWith("qb://darkmode") || str.startsWith("qb://no_history");
    }

    private static boolean k(String str) {
        return str.startsWith("https://usercenter");
    }

    private static boolean l(String str) {
        return str.startsWith("qb://ext/novelreader") || str.startsWith("qb://ext/novel");
    }

    private static boolean m(String str) {
        return str.startsWith("qb://weapp/wxminiprogram") || str.startsWith("qb://wxapp");
    }

    private static boolean n(String str) {
        return str.startsWith(NetUtils.SCHEME_HTTP) || str.startsWith(NetUtils.SCHEME_HTTPS);
    }

    private static boolean o(String str) {
        return str.startsWith("qb://ext/search") || str.startsWith("qb://ext/search/vertical") || str.startsWith("qb://search") || str.startsWith("qb://searchresult") || str.startsWith("qb://enginesearch");
    }
}