QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 BrowserWidgetMiniUtils.java 源代码,内容仅作参考
package com.tencent.mtt.widget.mini;
import MTT.HotWordInfo;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.net.Uri;
import android.text.TextUtils;
import android.widget.RemoteViews;
import com.qq.e.comm.constants.Constants;
import com.tencent.common.featuretoggle.FeatureToggle;
import com.tencent.common.fresco.pipeline.CImage;
import com.tencent.common.fresco.pipeline.ImageHub;
import com.tencent.common.fresco.request.ImageRequestCallBack;
import com.tencent.common.fresco.request.ImageRequester;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.R;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.browser.file.facade.IFileStatService;
import com.tencent.mtt.external.qrcode.common.ActionConstants2;
import com.tencent.mtt.external.reader.image.ImageReaderController;
import com.tencent.mtt.multiproc.QBSharedPreferences;
import com.tencent.mtt.wechatminiprogram.WidgetMiniEntity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import qb.browserbusinessbase.BuildConfig;
public class BrowserWidgetMiniUtils {
private static final int f75261a = MttResources.h(R.dimen.k6);
private static final int f75262b = MttResources.h(R.dimen.k3);
private static final int f75263c = MttResources.h(R.dimen.k5);
private static JSONObject f75264d;
private static HotWordInfo e;
private static List<WidgetMiniEntity> f;
private static PendingIntent a(Context context, String str, String str2) {
Intent intent = new Intent(context, (Class<?>) BrowserWidgetMiniProvider.class);
intent.setAction("com.tencent.mtt.browser.widget.action.CLICK");
intent.setData(Uri.parse("tag:" + str));
intent.putExtra(Constants.KEYS.EXPOSED_CLICK_URL_KEY, str2);
return PendingIntent.getBroadcast(context, 0, intent, 134217728);
}
private static SharedPreferences a() {
return QBSharedPreferences.getSharedPreferences(ContextHolder.getAppContext(), "browserWidget", 4, false, true);
}
private static String a(HotWordInfo hotWordInfo) {
return hotWordInfo != null ? hotWordInfo.sHotWordUrl : "qb://home/feeds?tabId=1&refresh=1&forceTop=1";
}
private static String a(JSONObject jSONObject) {
return (jSONObject == null || !jSONObject.has(Constants.KEYS.EXPOSED_CLICK_URL_KEY)) ? "qb://filesdk/clean/accelerate?callFrom=JK_WIDGET&entry=true" : jSONObject.optString(Constants.KEYS.EXPOSED_CLICK_URL_KEY);
}
public static void a(Context context, HotWordInfo hotWordInfo) {
if (FeatureToggle.a(BuildConfig.BUG_TOGGLE_92687991)) {
a(context, null, hotWordInfo, null);
return;
}
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
ComponentName componentName = new ComponentName(context, (Class<?>) BrowserWidgetMiniProvider.class);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.d5);
a(remoteViews, hotWordInfo);
a(context, remoteViews, a(hotWordInfo));
appWidgetManager.updateAppWidget(componentName, remoteViews);
}
public static void a(Context context, RemoteViews remoteViews, String str) {
if (TextUtils.isEmpty(str)) {
str = "qb://home/feeds?tabId=1&refresh=1&forceTop=1";
}
remoteViews.setOnClickPendingIntent(R.id.browser_widget_app_icon, a(context, "browser_widget_hot_word", str));
remoteViews.setOnClickPendingIntent(R.id.browser_widget_hot_word, a(context, "browser_widget_hot_word", str));
}
public static void a(Context context, RemoteViews remoteViews, List<WidgetMiniEntity> list) {
String str;
if (list == null || list.size() != 4) {
remoteViews.setOnClickPendingIntent(R.id.ly_widget_mini_1, a(context, "02321", "qb://wxapp/?appid=wxe100897f4542e613&source=100040"));
remoteViews.setOnClickPendingIntent(R.id.ly_widget_mini_2, a(context, "02322", "qb://wxapp/?appid=wxbb58374cdce267a6&source=100040"));
remoteViews.setOnClickPendingIntent(R.id.ly_widget_mini_3, a(context, "02323", "qb://wxapp/?appid=wxe64811f1b0de8fa5&source=100040"));
str = "qb://ext/rn?module=mptab&component=mptab&page=home";
} else {
remoteViews.setOnClickPendingIntent(R.id.ly_widget_mini_1, a(context, "02321", list.get(0).f74966c));
remoteViews.setOnClickPendingIntent(R.id.ly_widget_mini_2, a(context, "02322", list.get(1).f74966c));
remoteViews.setOnClickPendingIntent(R.id.ly_widget_mini_3, a(context, "02323", list.get(2).f74966c));
str = list.get(3).f74966c;
}
remoteViews.setOnClickPendingIntent(R.id.ly_widget_mini_4, a(context, "02324", str));
}
public static void a(Context context, List<WidgetMiniEntity> list) {
a(context, null, null, list);
}
public static void a(Context context, JSONObject jSONObject) {
if (FeatureToggle.a(BuildConfig.BUG_TOGGLE_92687991)) {
a(context, jSONObject, null, null);
return;
}
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
ComponentName componentName = new ComponentName(context, (Class<?>) BrowserWidgetMiniProvider.class);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.d5);
a(remoteViews, jSONObject);
b(context, remoteViews, a(jSONObject));
appWidgetManager.updateAppWidget(componentName, remoteViews);
}
public static synchronized void a(Context context, JSONObject jSONObject, HotWordInfo hotWordInfo, List<WidgetMiniEntity> list) {
synchronized (BrowserWidgetMiniUtils.class) {
if (jSONObject != null) {
try {
f75264d = jSONObject;
} catch (Throwable th) {
throw th;
}
}
if (hotWordInfo != null) {
e = hotWordInfo;
}
if (list != null) {
f = list;
}
try {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.d5);
a(remoteViews, e);
a(remoteViews, f75264d);
a(remoteViews, f);
a(context, remoteViews, a(e));
b(context, remoteViews, a(f75264d));
a(context, remoteViews, f);
AppWidgetManager.getInstance(context).updateAppWidget(new ComponentName(context, (Class<?>) BrowserWidgetMiniProvider.class), remoteViews);
} catch (Exception unused) {
}
}
}
public static void a(RemoteViews remoteViews, HotWordInfo hotWordInfo) {
if (remoteViews == null || hotWordInfo == null) {
return;
}
remoteViews.setTextViewText(R.id.browser_widget_hot_word, hotWordInfo.sHotWordName);
}
public static void a(final RemoteViews remoteViews, List<WidgetMiniEntity> list) {
if (remoteViews == null) {
return;
}
ArrayList arrayList = new ArrayList();
if (list != null && !list.isEmpty()) {
arrayList.addAll(list);
}
if (arrayList.size() != 4) {
arrayList.clear();
WidgetMiniEntity widgetMiniEntity = new WidgetMiniEntity();
widgetMiniEntity.f74964a = "WiFi助手";
widgetMiniEntity.f74965b = "https://srchstatic.imtt.qq.com/img/mini_program_spider/spider_wxe100897f4542e613.png";
widgetMiniEntity.f74966c = "qb://wxapp/?appid=wxe100897f4542e613&source=100040";
WidgetMiniEntity widgetMiniEntity2 = new WidgetMiniEntity();
widgetMiniEntity2.f74964a = "乘车码";
widgetMiniEntity2.f74965b = "https://srchstatic.imtt.qq.com/img/mini_program_spider/spider_wxbb58374cdce267a6.png";
widgetMiniEntity2.f74966c = "qb://wxapp/?appid=wxbb58374cdce267a6&source=100040";
WidgetMiniEntity widgetMiniEntity3 = new WidgetMiniEntity();
widgetMiniEntity3.f74964a = "气象在线";
widgetMiniEntity3.f74965b = "https://srchstatic.imtt.qq.com/img/mini_program_spider/spider_wxe64811f1b0de8fa5.png";
widgetMiniEntity3.f74966c = "qb://wxapp/?appid=wxe64811f1b0de8fa5&source=100040";
WidgetMiniEntity widgetMiniEntity4 = new WidgetMiniEntity();
widgetMiniEntity4.f74966c = "qb://ext/rn?module=mptab&component=mptab&page=home&coverToolbar=true&orientation=1&shortcut=true&title=服务大厅&isfrom=200003";
widgetMiniEntity4.f74965b = "https://m4.publicimg.browser.qq.com/publicimg/nav/user_center.png";
widgetMiniEntity4.f74964a = "服务大厅";
arrayList.add(widgetMiniEntity);
arrayList.add(widgetMiniEntity2);
arrayList.add(widgetMiniEntity3);
arrayList.add(widgetMiniEntity4);
}
remoteViews.setViewVisibility(R.id.ly_widget_mini_container, 0);
remoteViews.setViewVisibility(R.id.ly_widget_mini_1, 0);
remoteViews.setTextViewText(R.id.tv_widget_mini_1, ((WidgetMiniEntity) arrayList.get(0)).f74964a);
remoteViews.setImageViewResource(R.id.iv_widget_mini_1, R.drawable.au4);
ImageHub.a().a(((WidgetMiniEntity) arrayList.get(0)).f74965b, new ImageRequestCallBack() {
@Override
public void onRequestFailure(ImageRequester imageRequester, Throwable th) {
}
@Override
public void onRequestSuccess(ImageRequester imageRequester, CImage cImage) {
remoteViews.setImageViewBitmap(R.id.iv_widget_mini_1, BrowserWidgetMiniUtils.b(cImage.b()));
}
});
remoteViews.setViewVisibility(R.id.ly_widget_mini_2, 0);
remoteViews.setTextViewText(R.id.tv_widget_mini_2, ((WidgetMiniEntity) arrayList.get(1)).f74964a);
remoteViews.setImageViewResource(R.id.iv_widget_mini_2, R.drawable.au4);
ImageHub.a().a(((WidgetMiniEntity) arrayList.get(1)).f74965b, new ImageRequestCallBack() {
@Override
public void onRequestFailure(ImageRequester imageRequester, Throwable th) {
}
@Override
public void onRequestSuccess(ImageRequester imageRequester, CImage cImage) {
remoteViews.setImageViewBitmap(R.id.iv_widget_mini_2, BrowserWidgetMiniUtils.b(cImage.b()));
}
});
remoteViews.setViewVisibility(R.id.ly_widget_mini_3, 0);
remoteViews.setTextViewText(R.id.tv_widget_mini_3, ((WidgetMiniEntity) arrayList.get(2)).f74964a);
remoteViews.setImageViewResource(R.id.iv_widget_mini_3, R.drawable.au4);
ImageHub.a().a(((WidgetMiniEntity) arrayList.get(2)).f74965b, new ImageRequestCallBack() {
@Override
public void onRequestFailure(ImageRequester imageRequester, Throwable th) {
}
@Override
public void onRequestSuccess(ImageRequester imageRequester, CImage cImage) {
remoteViews.setImageViewBitmap(R.id.iv_widget_mini_3, BrowserWidgetMiniUtils.b(cImage.b()));
}
});
remoteViews.setViewVisibility(R.id.ly_widget_mini_4, 0);
remoteViews.setTextViewText(R.id.tv_widget_mini_4, ((WidgetMiniEntity) arrayList.get(3)).f74964a);
remoteViews.setImageViewResource(R.id.iv_widget_mini_4, R.drawable.au4);
ImageHub.a().a(((WidgetMiniEntity) arrayList.get(3)).f74965b, new ImageRequestCallBack() {
@Override
public void onRequestFailure(ImageRequester imageRequester, Throwable th) {
}
@Override
public void onRequestSuccess(ImageRequester imageRequester, CImage cImage) {
remoteViews.setImageViewBitmap(R.id.iv_widget_mini_4, BrowserWidgetMiniUtils.b(cImage.b()));
}
});
}
public static void a(RemoteViews remoteViews, JSONObject jSONObject) {
if (remoteViews == null || jSONObject == null) {
return;
}
int optInt = jSONObject.optInt("type");
remoteViews.setTextViewText(R.id.browser_widget_clean_size, jSONObject.optString("size"));
remoteViews.setTextViewText(R.id.browser_widget_clean_unit, jSONObject.optString(ImageReaderController.REPORT_UNIT));
int parseColor = Color.parseColor(jSONObject.optString("color", "#FFF44837"));
remoteViews.setTextColor(R.id.browser_widget_clean_size, parseColor);
remoteViews.setTextColor(R.id.browser_widget_clean_unit, parseColor);
remoteViews.setTextViewText(R.id.browser_widget_clean_btn, optInt == 0 ? "手机加速" : "去清理");
remoteViews.setTextViewText(R.id.browser_widget_clean_desc, optInt == 0 ? "占用" : "垃圾");
try {
Bitmap createBitmap = Bitmap.createBitmap(f75261a, f75262b, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
Paint paint = new Paint();
paint.setColor(parseColor);
paint.setStyle(Paint.Style.FILL);
canvas.drawRoundRect(new RectF(0.0f, 0.0f, f75261a, f75262b), f75263c, f75263c, paint);
remoteViews.setImageViewBitmap(R.id.browser_widget_clean_btn_bg, createBitmap);
} catch (Exception unused) {
remoteViews.setImageViewResource(R.id.browser_widget_clean_btn_bg, R.drawable.gh);
}
}
public static void a(String str) {
a(str, "");
}
public static void a(String str, int i) {
try {
Intent intent = new Intent(ActionConstants2.k);
String str2 = "mttbrowser://url=" + Uri.encode(str) + ",encoded=1";
intent.setPackage("com.tencent.mtt");
intent.setData(Uri.parse(str2));
intent.putExtra("ChannelID", "widget");
intent.putExtra("PosID", i);
intent.addFlags(268435456);
ContextHolder.getAppContext().startActivity(intent);
} catch (Exception unused) {
}
}
public static void a(String str, String str2) {
HashMap hashMap = new HashMap();
hashMap.put(IFileStatService.EVENT_REPORT_NAME, str);
hashMap.put("extra", str2);
StatManager.b().b("file_key_event", hashMap);
}
public static Bitmap b(Bitmap bitmap) {
int width = bitmap.getWidth();
Paint paint = new Paint();
paint.setAntiAlias(true);
Bitmap createBitmap = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
float f2 = width / 2;
canvas.drawCircle(f2, f2, f2, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, 0.0f, 0.0f, paint);
return createBitmap;
}
public static void b(Context context, RemoteViews remoteViews, String str) {
if (TextUtils.isEmpty(str)) {
str = "qb://filesdk/clean/accelerate?callFrom=JK_WIDGET&entry=true";
}
remoteViews.setOnClickPendingIntent(R.id.browser_widget_clean_content, a(context, "browser_widget_clean_content", str));
}
public static void b(String str, int i) {
a().edit().putInt(str, i).commit();
}
public static int c(String str, int i) {
return a().getInt(str, i);
}
}