QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 FontCenterSettingView.java 源代码,内容仅作参考
package com.tencent.mtt.external.setting;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
import android.os.Looper;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.view.GravityCompat;
import com.tencent.common.http.Apn;
import com.tencent.common.plugin.exports.IQBPluginSystemCallback;
import com.tencent.common.plugin.exports.QBPluginItemInfo;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.StringUtils;
import com.tencent.mtt.base.font.QbFontManager;
import com.tencent.mtt.base.font.QbFontPluginManager;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.browser.share.facade.IShare;
import com.tencent.mtt.browser.share.facade.IShareStateListener;
import com.tencent.mtt.browser.share.facade.ShareBundle;
import com.tencent.mtt.browser.window.data.PageInfo;
import com.tencent.mtt.external.setting.facade.SettingView;
import com.tencent.mtt.newskin.SimpleSkinBuilder;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.setting.PublicSettingManager;
import com.tencent.mtt.view.dialog.newui.SimpleDialogBuilder;
import com.tencent.mtt.view.dialog.newui.dialog.DialogBase;
import com.tencent.mtt.view.dialog.newui.view.ViewOnClickListener;
import com.tencent.mtt.view.setting.SettingResCache;
import com.tencent.mtt.view.toast.MttToaster;
import com.tencent.mtt.view.widget.SimpleStyledButtonView;
import com.tencent.qqlive.module.videoreport.collect.EventCollector;
import com.tencent.tbs.core.MainActivity;
import java.util.ArrayList;
import java.util.Iterator;
import qb.a.e;
import qb.a.f;
import qb.a.g;
import qb.a.h;
public class FontCenterSettingView extends SettingView implements QbFontPluginManager.IFontCallback {
final int f59428a;
final int f59429b;
final int f59430c;
private LinearLayout f59431d;
private ArrayList<FontSelectItem> e;
private SettingResCache f;
public class FontSelectItem extends LinearLayout implements View.OnClickListener, IQBPluginSystemCallback, QbFontPluginManager.IFontCallback {
final int f59432a;
final int f59433b;
final int f59434c;
final int f59435d;
final int e;
final int f;
final int g;
final int h;
QBPluginItemInfo i;
boolean j;
Paint k;
TextView l;
ImageView m;
TextView n;
SimpleStyledButtonView o;
ImageView p;
class AnonymousClass1 implements Runnable {
final FontSelectItem f59436a;
@Override
public void run() {
QbFontPluginManager.a().a(this.f59436a.i.mPackageName, this.f59436a, true);
}
}
public FontSelectItem(Context context, QBPluginItemInfo qBPluginItemInfo, boolean z) {
super(context);
SimpleStyledButtonView simpleStyledButtonView;
String str;
long j;
this.f59432a = MttResources.h(f.f85879c);
this.f59433b = MttResources.h(f.e);
this.f59434c = MttResources.h(f.v);
this.f59435d = MttResources.h(f.E);
this.e = MttResources.h(f.Y);
this.f = MttResources.h(f.ag);
this.g = MttResources.h(f.cX);
this.h = MttResources.h(f.cZ);
this.i = qBPluginItemInfo;
this.j = z;
if (this.j) {
this.k = new Paint();
this.k.setColor(FontCenterSettingView.this.f.h);
}
boolean isEmpty = TextUtils.isEmpty(this.i.mPackageName);
setLayoutParams(new ViewGroup.LayoutParams(-1, isEmpty ? this.e : FontCenterSettingView.this.f59430c));
setOrientation(0);
SimpleSkinBuilder.a(this).a(FontCenterSettingView.this.f.p).c().f();
setOnClickListener(this);
LinearLayout linearLayout = new LinearLayout(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
layoutParams.gravity = 8388627;
layoutParams.leftMargin = this.f59434c;
layoutParams.weight = 1.0f;
linearLayout.setLayoutParams(layoutParams);
linearLayout.setOrientation(1);
linearLayout.setGravity(GravityCompat.START);
addView(linearLayout);
this.l = new TextView(context);
this.l.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
this.l.setGravity(8388627);
this.l.setTextSize(1, MttResources.r(this.h));
SimpleSkinBuilder.a(this.l).g(e.f85871a).f();
this.l.setText(this.i.mTitle);
linearLayout.addView(this.l);
if (!isEmpty) {
this.m = new ImageView(context);
this.m.setLayoutParams(new LinearLayout.LayoutParams(-2, this.f59434c));
this.m.setScaleType(ImageView.ScaleType.CENTER);
this.m.setVisibility(8);
linearLayout.addView(this.m);
if (!TextUtils.isEmpty(this.i.mPackageSize)) {
j = Long.parseLong(this.i.mPackageSize);
this.n = new TextView(context);
LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-1, -2);
layoutParams2.topMargin = this.f59433b;
this.n.setLayoutParams(layoutParams2);
this.n.setGravity(8388627);
this.n.setTextSize(1, MttResources.r(this.g));
SimpleSkinBuilder.a(this.n).g(e.q).f();
this.n.setText(j <= 0 ? StringUtils.a(j) : "");
this.n.setVisibility(j <= 0 ? 0 : 8);
linearLayout.addView(this.n, layoutParams2);
}
j = 0;
this.n = new TextView(context);
LinearLayout.LayoutParams layoutParams22 = new LinearLayout.LayoutParams(-1, -2);
layoutParams22.topMargin = this.f59433b;
this.n.setLayoutParams(layoutParams22);
this.n.setGravity(8388627);
this.n.setTextSize(1, MttResources.r(this.g));
SimpleSkinBuilder.a(this.n).g(e.q).f();
this.n.setText(j <= 0 ? StringUtils.a(j) : "");
this.n.setVisibility(j <= 0 ? 0 : 8);
linearLayout.addView(this.n, layoutParams22);
}
if (!isEmpty) {
this.o = new SimpleStyledButtonView(context);
if (QbFontManager.a().d(qBPluginItemInfo.mPackageName)) {
simpleStyledButtonView = this.o;
str = "UNLOCK";
} else {
simpleStyledButtonView = this.o;
str = "DOWNLOAD";
}
simpleStyledButtonView.setTag(str);
LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(this.f, this.f59435d);
layoutParams3.gravity = 8388629;
layoutParams3.rightMargin = FontCenterSettingView.this.f59428a;
layoutParams3.weight = 0.0f;
this.o.setLayoutParams(layoutParams3);
this.o.setStyle(7);
this.o.setOnClickListener(this);
addView(this.o);
}
this.p = new ImageView(context);
int i = this.f59434c;
LinearLayout.LayoutParams layoutParams4 = new LinearLayout.LayoutParams(i, i);
layoutParams4.gravity = 8388629;
layoutParams4.rightMargin = FontCenterSettingView.this.f59428a;
layoutParams4.weight = 0.0f;
this.p.setLayoutParams(layoutParams4);
ImageView imageView = this.p;
int i2 = this.f59432a;
imageView.setPadding(i2, 0, i2, 0);
this.p.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
SimpleSkinBuilder.a(this.p).g(g.s).f();
this.p.setVisibility(8);
addView(this.p);
if (isEmpty) {
return;
}
int[] iArr = {0};
a(QbFontPluginManager.a().a(this.i.mPackageName, iArr), iArr[0]);
QbFontPluginManager.a().a(this.i.mPackageName, this);
}
private void a(int i, int i2) {
SimpleStyledButtonView simpleStyledButtonView;
String l;
if (i == 0) {
this.o.setVisibility(8);
} else if (i == 1) {
this.o.setStyle(7);
Object tag = this.o.getTag();
if ((tag instanceof String) && "UNLOCK".equals(tag)) {
simpleStyledButtonView = this.o;
l = "解锁";
} else {
simpleStyledButtonView = this.o;
l = MttResources.l(h.g);
}
simpleStyledButtonView.setText(l);
this.o.setVisibility(0);
this.o.setClickable(true);
} else if (i == 2) {
this.o.setVisibility(0);
this.o.setStyle(11);
this.o.setClickable(false);
this.o.setProgress(i2);
this.o.setText("下载中");
}
postInvalidate();
}
public void a(Bitmap bitmap) {
if (bitmap == null || bitmap.isRecycled()) {
return;
}
this.l.setVisibility(8);
this.m.setVisibility(0);
int c2 = MttResources.c(e.f85871a);
BitmapDrawable bitmapDrawable = new BitmapDrawable(MttResources.b(), bitmap);
bitmapDrawable.setColorFilter(c2, PorterDuff.Mode.SRC_IN);
this.m.setBackgroundDrawable(bitmapDrawable);
ViewGroup.LayoutParams layoutParams = this.m.getLayoutParams();
if (layoutParams != null && bitmap.getHeight() > 0) {
layoutParams.width = (bitmap.getWidth() * layoutParams.height) / bitmap.getHeight();
this.m.setLayoutParams(layoutParams);
}
this.m.requestLayout();
}
public void b() {
a(2, 0);
BrowserExecutorSupplier.forIoTasks().execute(new Runnable() {
@Override
public void run() {
QbFontPluginManager.a().a(FontSelectItem.this.i.mPackageName, FontSelectItem.this, true);
}
});
}
private void c() {
SimpleDialogBuilder.e().e("分享给朋友可解锁字体,\r\n赶快行动吧").a("分享解锁").c("取消").a_(new ViewOnClickListener() {
@Override
public void onClick(View view, DialogBase dialogBase) {
dialogBase.dismiss();
StatManager.b().c("DIFNT9");
IShare iShare = (IShare) QBContext.getInstance().getService(IShare.class);
if (iShare != null) {
ShareBundle shareBundle = new ShareBundle(new PageInfo(0));
shareBundle.f45014b = "QQ浏览器";
shareBundle.f45015c = "多款个性字体,总有适合你的";
shareBundle.f45016d = "https://page.html5.qq.com/api/html?id=201114";
shareBundle.e = "https://res.imtt.qq.com/res_mtt/qbfont/oper/20190320_bg_thumbnail.png";
shareBundle.x = 350;
iShare.addShareStateListener(new IShareStateListener() {
@Override
public void onShareFinished(int i, int i2) {
if (i == 0) {
StatManager.b().c("DIFNT10");
FontSelectItem.this.d();
}
}
@Override
public void onShareInfoUpdated() {
}
});
iShare.doShare(shareBundle);
}
}
}).c(new ViewOnClickListener() {
@Override
public void onClick(View view, DialogBase dialogBase) {
dialogBase.dismiss();
}
}).e();
}
public void d() {
if (!TextUtils.isEmpty(this.i.mPackageName)) {
QbFontManager.a().c(this.i.mPackageName);
}
SimpleStyledButtonView simpleStyledButtonView = this.o;
if (simpleStyledButtonView != null) {
simpleStyledButtonView.setTag("DOWNLOAD");
this.o.setText("下载");
}
}
public void a() {
SimpleDialogBuilder.e().e("您当前处于移动网络,\r\n是否继续?").a("下载").c("取消").a_(new ViewOnClickListener() {
@Override
public void onClick(View view, DialogBase dialogBase) {
dialogBase.dismiss();
FontSelectItem.this.b();
}
}).c(new ViewOnClickListener() {
@Override
public void onClick(View view, DialogBase dialogBase) {
dialogBase.dismiss();
}
}).e();
}
@Override
public void a(int i, final QBPluginItemInfo qBPluginItemInfo, Object obj) {
if (i != 1) {
if (i == 4 && (obj instanceof Bitmap) && StringUtils.a(qBPluginItemInfo.mPackageName, this.i.mPackageName)) {
final Bitmap bitmap = (Bitmap) obj;
if (Looper.getMainLooper() == Looper.myLooper()) {
a(bitmap);
return;
} else {
BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
@Override
public void run() {
FontSelectItem.this.a(bitmap);
}
});
return;
}
}
return;
}
if (qBPluginItemInfo == null || TextUtils.isEmpty(qBPluginItemInfo.mPackageName) || !TextUtils.equals(QbFontManager.a().g(), qBPluginItemInfo.mPackageName) || !QbFontManager.a().a(qBPluginItemInfo.mPackageName, qBPluginItemInfo.mExt)) {
return;
}
if (Looper.getMainLooper() == Looper.myLooper()) {
FontCenterSettingView.this.a(qBPluginItemInfo.mPackageName);
QbFontManager.a().a((Activity) getContext());
if (!(getContext() instanceof MainActivity)) {
QbFontManager.a().a(ActivityHandler.b().n());
}
} else {
BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
@Override
public void run() {
FontCenterSettingView.this.a(qBPluginItemInfo.mPackageName);
QbFontManager.a().a((Activity) FontSelectItem.this.getContext());
if (FontSelectItem.this.getContext() instanceof MainActivity) {
return;
}
QbFontManager.a().a(ActivityHandler.b().n());
}
});
}
StatManager.b().c("DIFNT11");
PublicSettingManager.a().setInt("key_has_try_non_sys_font", 1);
}
public void a(boolean z) {
SimpleStyledButtonView simpleStyledButtonView;
String str;
SimpleStyledButtonView simpleStyledButtonView2;
if (z) {
this.p.setVisibility(0);
simpleStyledButtonView2 = this.o;
if (simpleStyledButtonView2 == null) {
return;
}
} else {
this.p.setVisibility(8);
if (this.o == null) {
return;
}
int a2 = QbFontPluginManager.a().a(this.i.mPackageName, (int[]) null);
if (a2 != 0) {
if (a2 == 1) {
this.o.setVisibility(0);
Object tag = this.o.getTag();
if ((tag instanceof String) && "UNLOCK".equals(tag)) {
simpleStyledButtonView = this.o;
str = "解锁";
} else {
simpleStyledButtonView = this.o;
str = MttResources.l(h.g);
}
} else {
if (a2 != 2) {
return;
}
this.o.setVisibility(0);
simpleStyledButtonView = this.o;
str = "下载中";
}
simpleStyledButtonView.setText(str);
return;
}
simpleStyledButtonView2 = this.o;
}
simpleStyledButtonView2.setVisibility(8);
}
@Override
public void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (!this.j || this.k == null) {
return;
}
canvas.drawRect(getPaddingLeft() + FontCenterSettingView.this.f.g, getHeight() - 1, getWidth() - getPaddingRight(), getHeight(), this.k);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
QbFontPluginManager.a().b(this);
}
@Override
public void onClick(View view) {
StatManager b2;
String str;
EventCollector.getInstance().onViewClickedBefore(view);
SimpleStyledButtonView simpleStyledButtonView = this.o;
if (view == simpleStyledButtonView) {
Object tag = simpleStyledButtonView.getTag();
if ((tag instanceof String) && "UNLOCK".equals(tag)) {
StatManager.b().c("DIFNT8");
c();
} else {
StatManager.b().c("DIFNT7");
if (QbFontPluginManager.a().a(this.i.mPackageName, (int[]) null) == 1) {
if (!Apn.isNetworkConnected()) {
MttToaster.show("无网络连接,请检查网络设置", 0);
} else if (Apn.isWifiMode()) {
b();
} else {
a();
}
}
}
} else {
if (TextUtils.isEmpty(this.i.mPackageName)) {
StatManager.b().c("DIFNT12");
StatManager.b().c("EIC030201");
} else {
StatManager.b().c("DIFNT11");
PublicSettingManager.a().setInt("key_has_try_non_sys_font", 1);
}
if (QbFontPluginManager.a().a(this.i.mPackageName, (int[]) null) == 0 && QbFontManager.a().a(this.i.mPackageName, this.i.mExt)) {
if (this.i.mPackageName.equals("com.tencent.mtt.plugin.font.setting.zaozigongfangyueyuanti")) {
b2 = StatManager.b();
str = "EIC030202";
} else if (this.i.mPackageName.equals("com.tencent.mtt.plugin.font.setting.zaozigongfangdianhei")) {
b2 = StatManager.b();
str = "EIC030203";
} else {
if (this.i.mPackageName.equals("com.tencent.mtt.plugin.font.setting.zaozigongfangkesong")) {
b2 = StatManager.b();
str = "EIC030204";
}
FontCenterSettingView.this.a(this.i.mPackageName);
QbFontManager.a().a((Activity) getContext());
if (!(getContext() instanceof MainActivity)) {
QbFontManager.a().a(ActivityHandler.b().n());
}
}
b2.c(str);
FontCenterSettingView.this.a(this.i.mPackageName);
QbFontManager.a().a((Activity) getContext());
if (!(getContext() instanceof MainActivity)) {
}
}
}
EventCollector.getInstance().onViewClicked(view);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
QbFontPluginManager.a().c(this);
}
@Override
public void onDownloadCreateed(String str, String str2) {
}
@Override
public void onDownloadProgress(String str, int i, int i2) {
if (TextUtils.isEmpty(str) || !str.equals(this.i.mPackageName)) {
return;
}
this.o.setProgress(i2);
}
@Override
public void onDownloadStart(String str, int i) {
}
@Override
public void onDownloadSuccessed(String str, String str2) {
}
@Override
public void onNeedDownloadNotify(String str, boolean z) {
}
@Override
public void onPrepareFinished(String str, QBPluginItemInfo qBPluginItemInfo, int i, int i2) {
if (i == 0) {
a(0, 0);
} else {
a(1, 0);
MttToaster.show("字体下载失败,请重试", 0);
}
}
@Override
public void onPrepareStart(String str) {
}
}
public FontCenterSettingView(Context context) {
super(context);
this.f59428a = MttResources.h(f.r);
this.f59429b = MttResources.h(f.t);
this.f59430c = MttResources.h(f.au);
this.f59431d = null;
this.e = new ArrayList<>();
this.f = SettingResCache.a();
this.f59431d = new LinearLayout(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
layoutParams.topMargin = this.f59428a;
layoutParams.bottomMargin = this.f59429b;
this.f59431d.setLayoutParams(layoutParams);
this.f59431d.setOrientation(1);
addView(this.f59431d);
QBPluginItemInfo qBPluginItemInfo = new QBPluginItemInfo();
qBPluginItemInfo.mTitle = "系统字体";
qBPluginItemInfo.mPackageName = "";
FontSelectItem fontSelectItem = new FontSelectItem(getContext(), qBPluginItemInfo, true);
this.f59431d.addView(fontSelectItem);
this.e.add(fontSelectItem);
a("");
QbFontPluginManager.a().a(this);
PublicSettingManager.a().setInt("key_has_visit_font_center", 1);
StatManager.b().c("DIFNT5");
}
public void a(String str) {
Iterator<FontSelectItem> it = this.e.iterator();
while (it.hasNext()) {
FontSelectItem next = it.next();
next.a(TextUtils.equals(next.i.mPackageName, str));
}
}
@Override
public void a(int i, QBPluginItemInfo qBPluginItemInfo, Object obj) {
if (i != 3) {
return;
}
this.f59431d.removeAllViews();
this.e.clear();
ArrayList<QBPluginItemInfo> b2 = QbFontPluginManager.a().b();
int size = b2.size();
int i2 = 0;
while (i2 < size) {
FontSelectItem fontSelectItem = new FontSelectItem(getContext(), b2.get(i2), !(i2 == size + (-1)));
this.f59431d.addView(fontSelectItem);
this.e.add(fontSelectItem);
i2++;
}
a(QbFontManager.a().e());
this.f59431d.requestLayout();
}
}