package com.tencent.connect.avatar; import a.f; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import androidx.core.view.ViewCompat; import com.meizu.cloud.pushsdk.constants.PushConstants; import com.sensorsdata.analytics.android.sdk.SensorsDataAutoTrackHelper; import com.sensorsdata.analytics.android.sdk.SensorsDataInstrumented; import com.sensorsdata.analytics.android.sdk.aop.push.PushAutoTrackHelper; import com.tencent.connect.UserInfo; import com.tencent.connect.auth.QQToken; import com.tencent.connect.common.BaseApi; import com.tencent.open.b.e; import com.tencent.open.b.h; import com.tencent.open.utils.HttpUtils; import com.tencent.open.utils.g; import com.tencent.open.utils.m; import com.tencent.tauth.DefaultUiListener; import com.tencent.tauth.IUiListener; import com.tencent.tauth.UiError; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import org.json.JSONException; import org.json.JSONObject; /* compiled from: ProGuard */ public class ImageActivity extends Activity { /* renamed from: a reason: collision with root package name */ public RelativeLayout f27863a; private QQToken b; /* renamed from: c reason: collision with root package name */ private String f27864c; private Handler d; private c e; private Button f; /* renamed from: g reason: collision with root package name */ private Button f27865g; /* renamed from: h reason: collision with root package name */ private b f27866h; private TextView i; private ProgressBar j; private int k; private boolean l; private long m; private int n; private final int o = 640; private final int p = 640; /* renamed from: q reason: collision with root package name */ private Rect f27867q = new Rect(); private String r; private Bitmap s; private final View.OnClickListener t = new View.OnClickListener() { /* class com.tencent.connect.avatar.ImageActivity.AnonymousClass2 */ @SensorsDataInstrumented public void onClick(View view) { ImageActivity.this.j.setVisibility(0); ImageActivity.this.f27865g.setEnabled(false); ImageActivity.this.f27865g.setTextColor(Color.rgb(21, 21, 21)); ImageActivity.this.f.setEnabled(false); ImageActivity.this.f.setTextColor(Color.rgb(36, 94, 134)); f.n(new p4.f(new Runnable() { /* class com.tencent.connect.avatar.ImageActivity.AnonymousClass2.AnonymousClass1 */ public void run() { ImageActivity.this.c(); } }, "com.tencent.connect.avatar.ImageActivity$2"), "com.tencent.connect.avatar.ImageActivity$2"); if (ImageActivity.this.l) { ImageActivity.this.a("10657", 0L); } else { ImageActivity.this.a("10655", System.currentTimeMillis() - ImageActivity.this.m); if (ImageActivity.this.e.b) { ImageActivity.this.a("10654", 0L); } } SensorsDataAutoTrackHelper.trackViewOnClick(view); } }; /* renamed from: u reason: collision with root package name */ private final View.OnClickListener f27868u = new View.OnClickListener() { /* class com.tencent.connect.avatar.ImageActivity.AnonymousClass3 */ @SensorsDataInstrumented public void onClick(View view) { ImageActivity.this.a("10656", System.currentTimeMillis() - ImageActivity.this.m); ImageActivity.this.setResult(0); ImageActivity.this.d(); SensorsDataAutoTrackHelper.trackViewOnClick(view); } }; /* renamed from: v reason: collision with root package name */ private final IUiListener f27869v = new DefaultUiListener() { /* class com.tencent.connect.avatar.ImageActivity.AnonymousClass5 */ @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onCancel() { } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onComplete(Object obj) { ImageActivity.this.f27865g.setEnabled(true); int i = -1; ImageActivity.this.f27865g.setTextColor(-1); ImageActivity.this.f.setEnabled(true); ImageActivity.this.f.setTextColor(-1); ImageActivity.this.j.setVisibility(8); JSONObject jSONObject = (JSONObject) obj; try { i = jSONObject.getInt("ret"); } catch (JSONException e) { e.printStackTrace(); } if (i == 0) { ImageActivity.this.a((ImageActivity) "设置成功", (String) 0); ImageActivity.this.a("10658", 0L); e.a().a(ImageActivity.this.b.getOpenId(), ImageActivity.this.b.getAppId(), "ANDROIDSDK.SETAVATAR.SUCCEED", "12", PushConstants.PUSH_FLYME_3_CHANGE_VERSION_START, "0"); ImageActivity imageActivity = ImageActivity.this; if (imageActivity.f27864c != null && !"".equals(ImageActivity.this.f27864c)) { Intent intent = new Intent(); intent.setClassName(imageActivity, ImageActivity.this.f27864c); if (imageActivity.getPackageManager().resolveActivity(intent, 0) != null) { imageActivity.startActivity(intent); try { a31.a.a(); } catch (Exception unused) { } } } ImageActivity.this.a(0, jSONObject.toString(), null, null); ImageActivity.this.d(); return; } ImageActivity.this.a((ImageActivity) "设置出错了,请重新登录再尝试下呢:)", (String) 1); e.a().a(ImageActivity.this.b.getOpenId(), ImageActivity.this.b.getAppId(), "ANDROIDSDK.SETAVATAR.SUCCEED", "12", "19", "1"); } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onError(UiError uiError) { ImageActivity.this.f27865g.setEnabled(true); ImageActivity.this.f27865g.setTextColor(-1); ImageActivity.this.f.setEnabled(true); ImageActivity.this.f.setTextColor(-1); ImageActivity.this.f.setText("重试"); ImageActivity.this.j.setVisibility(8); ImageActivity.this.l = true; ImageActivity.this.a((ImageActivity) uiError.errorMessage, (String) 1); ImageActivity.this.a("10660", 0L); } }; private final IUiListener w = new DefaultUiListener() { /* class com.tencent.connect.avatar.ImageActivity.AnonymousClass6 */ private void a(int i) { if (ImageActivity.this.k < 2) { ImageActivity.this.e(); } } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onCancel() { } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onComplete(Object obj) { JSONObject jSONObject = (JSONObject) obj; int i = -1; try { i = jSONObject.getInt("ret"); if (i == 0) { final String string = jSONObject.getString("nickname"); ImageActivity.this.d.post(new Runnable() { /* class com.tencent.connect.avatar.ImageActivity.AnonymousClass6.AnonymousClass1 */ public void run() { ImageActivity.this.c((ImageActivity) string); } }); ImageActivity.this.a("10659", 0L); } else { ImageActivity.this.a("10661", 0L); } } catch (JSONException e) { e.printStackTrace(); } if (i != 0) { a(i); } } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onError(UiError uiError) { a(0); } }; /* compiled from: ProGuard */ public class QQAvatarImp extends BaseApi { public QQAvatarImp(QQToken qQToken) { super(qQToken); } public void setAvator(Bitmap bitmap, IUiListener iUiListener) { Bundle a5 = a(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 40, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); bitmap.recycle(); BaseApi.TempRequestListener tempRequestListener = new BaseApi.TempRequestListener(iUiListener); a5.putByteArray("picture", byteArray); HttpUtils.requestAsync(this.f27894c, g.a(), "user/set_user_face", a5, "POST", tempRequestListener); e.a().a(this.f27894c.getOpenId(), this.f27894c.getAppId(), "ANDROIDSDK.SETAVATAR.SUCCEED", "12", "19", "0"); } } /* compiled from: ProGuard */ public class a extends View { public a(Context context) { super(context); } public void a(Button button) { StateListDrawable stateListDrawable = new StateListDrawable(); Drawable b = ImageActivity.this.b((ImageActivity) "com.tencent.plus.blue_normal.png"); Drawable b2 = ImageActivity.this.b((ImageActivity) "com.tencent.plus.blue_down.png"); Drawable b5 = ImageActivity.this.b((ImageActivity) "com.tencent.plus.blue_disable.png"); stateListDrawable.addState(View.PRESSED_ENABLED_STATE_SET, b2); stateListDrawable.addState(View.ENABLED_FOCUSED_STATE_SET, b); stateListDrawable.addState(View.ENABLED_STATE_SET, b); stateListDrawable.addState(View.FOCUSED_STATE_SET, b); stateListDrawable.addState(View.EMPTY_STATE_SET, b5); button.setBackgroundDrawable(stateListDrawable); } public void b(Button button) { StateListDrawable stateListDrawable = new StateListDrawable(); Drawable b = ImageActivity.this.b((ImageActivity) "com.tencent.plus.gray_normal.png"); Drawable b2 = ImageActivity.this.b((ImageActivity) "com.tencent.plus.gray_down.png"); Drawable b5 = ImageActivity.this.b((ImageActivity) "com.tencent.plus.gray_disable.png"); stateListDrawable.addState(View.PRESSED_ENABLED_STATE_SET, b2); stateListDrawable.addState(View.ENABLED_FOCUSED_STATE_SET, b); stateListDrawable.addState(View.ENABLED_STATE_SET, b); stateListDrawable.addState(View.FOCUSED_STATE_SET, b); stateListDrawable.addState(View.EMPTY_STATE_SET, b5); button.setBackgroundDrawable(stateListDrawable); } } public void onBackPressed() { setResult(0); d(); } public void onCreate(Bundle bundle) { requestWindowFeature(1); super.onCreate(bundle); setRequestedOrientation(1); setContentView(a()); this.d = new Handler(); Bundle bundleExtra = getIntent().getBundleExtra("key_params"); this.r = bundleExtra.getString("picture"); this.f27864c = bundleExtra.getString("return_activity"); String string = bundleExtra.getString("appid"); String string2 = bundleExtra.getString("access_token"); long j12 = bundleExtra.getLong("expires_in"); String string3 = bundleExtra.getString("openid"); this.n = bundleExtra.getInt("exitAnim"); QQToken qQToken = new QQToken(string); this.b = qQToken; qQToken.setAccessToken(string2, ((j12 - System.currentTimeMillis()) / 1000) + ""); this.b.setOpenId(string3); b(); e(); this.m = System.currentTimeMillis(); a("10653", 0L); } public void onDestroy() { super.onDestroy(); this.e.setImageBitmap(null); Bitmap bitmap = this.s; if (bitmap != null && !bitmap.isRecycled()) { this.s.recycle(); } } @SensorsDataInstrumented public void onNewIntent(Intent intent) { super.onNewIntent(intent); PushAutoTrackHelper.onNewIntent(this, intent); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void c() { Matrix imageMatrix = this.e.getImageMatrix(); float[] fArr = new float[9]; imageMatrix.getValues(fArr); float f12 = fArr[2]; float f13 = fArr[5]; float f14 = fArr[0]; float width = 640.0f / ((float) this.f27867q.width()); Rect rect = this.f27867q; int i3 = (int) ((((float) rect.left) - f12) / f14); int i12 = i3 < 0 ? 0 : i3; int i13 = (int) ((((float) rect.top) - f13) / f14); int i14 = i13 < 0 ? 0 : i13; Matrix matrix = new Matrix(); matrix.set(imageMatrix); matrix.postScale(width, width); int i15 = (int) (650.0f / f14); try { Bitmap createBitmap = Bitmap.createBitmap(this.s, i12, i14, Math.min(this.s.getWidth() - i12, i15), Math.min(this.s.getHeight() - i14, i15), matrix, true); Bitmap createBitmap2 = Bitmap.createBitmap(createBitmap, 0, 0, 640, 640); createBitmap.recycle(); a(createBitmap2); } catch (IllegalArgumentException e6) { e6.printStackTrace(); a("图片读取失败,请检查该图片是否有效", 1); a(-5, null, "图片读取失败,请检查该图片是否有效", e6.getMessage()); d(); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void d() { finish(); int i3 = this.n; if (i3 != 0) { overridePendingTransition(0, i3); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void e() { this.k++; new UserInfo(this, this.b).getUserInfo(this.w); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private Drawable b(String str) { return m.a(str, this); } private void b() { try { Bitmap a5 = a(this.r); this.s = a5; if (a5 != null) { this.e.setImageBitmap(a5); this.f.setOnClickListener(this.t); this.f27865g.setOnClickListener(this.f27868u); this.f27863a.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { /* class com.tencent.connect.avatar.ImageActivity.AnonymousClass1 */ public void onGlobalLayout() { ImageActivity.this.f27863a.getViewTreeObserver().removeGlobalOnLayoutListener(this); ImageActivity imageActivity = ImageActivity.this; imageActivity.f27867q = imageActivity.f27866h.a(); ImageActivity.this.e.a(ImageActivity.this.f27867q); } }); return; } throw new IOException("cannot read picture: '" + this.r + "'!"); } catch (IOException e6) { e6.printStackTrace(); a("图片读取失败,请检查该图片是否有效", 1); a(-5, null, "图片读取失败,请检查该图片是否有效", e6.getMessage()); d(); } } private String d(String str) { return str.replaceAll(">", ">").replaceAll("<", "<").replaceAll(""", "\"").replaceAll("'", "'").replaceAll("&", "&"); } private Bitmap a(String str) throws IOException { BitmapFactory.Options options = new BitmapFactory.Options(); int i3 = 1; options.inJustDecodeBounds = true; Uri parse = Uri.parse(str); InputStream openInputStream = getContentResolver().openInputStream(parse); if (openInputStream == null) { return null; } try { BitmapFactory.decodeStream(openInputStream, null, options); } catch (OutOfMemoryError e6) { e6.printStackTrace(); } openInputStream.close(); int i12 = options.outWidth; int i13 = options.outHeight; while (i12 * i13 > 4194304) { i12 /= 2; i13 /= 2; i3 *= 2; } options.inJustDecodeBounds = false; options.inSampleSize = i3; try { return BitmapFactory.decodeStream(getContentResolver().openInputStream(parse), null, options); } catch (OutOfMemoryError e12) { e12.printStackTrace(); return null; } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void b(String str, int i3) { Toast makeText = Toast.makeText(this, str, 1); LinearLayout linearLayout = (LinearLayout) makeText.getView(); ((TextView) linearLayout.getChildAt(0)).setPadding(8, 0, 0, 0); ImageView imageView = new ImageView(this); imageView.setLayoutParams(new LinearLayout.LayoutParams(a.a(this, 16.0f), a.a(this, 16.0f))); if (i3 == 0) { imageView.setImageDrawable(b("com.tencent.plus.ic_success.png")); } else { imageView.setImageDrawable(b("com.tencent.plus.ic_error.png")); } linearLayout.addView(imageView, 0); linearLayout.setOrientation(0); linearLayout.setGravity(17); makeText.setView(linearLayout); makeText.setGravity(17, 0, 0); makeText.show(); } private View a() { ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-1, -1); ViewGroup.LayoutParams layoutParams2 = new ViewGroup.LayoutParams(-1, -1); ViewGroup.LayoutParams layoutParams3 = new ViewGroup.LayoutParams(-2, -2); RelativeLayout relativeLayout = new RelativeLayout(this); this.f27863a = relativeLayout; relativeLayout.setLayoutParams(layoutParams); this.f27863a.setBackgroundColor(ViewCompat.MEASURED_STATE_MASK); RelativeLayout relativeLayout2 = new RelativeLayout(this); relativeLayout2.setLayoutParams(layoutParams3); this.f27863a.addView(relativeLayout2); c cVar = new c(this); this.e = cVar; cVar.setLayoutParams(layoutParams2); this.e.setScaleType(ImageView.ScaleType.MATRIX); relativeLayout2.addView(this.e); this.f27866h = new b(this); RelativeLayout.LayoutParams layoutParams4 = new RelativeLayout.LayoutParams(layoutParams2); layoutParams4.addRule(14, -1); layoutParams4.addRule(15, -1); this.f27866h.setLayoutParams(layoutParams4); relativeLayout2.addView(this.f27866h); LinearLayout linearLayout = new LinearLayout(this); RelativeLayout.LayoutParams layoutParams5 = new RelativeLayout.LayoutParams(-2, a.a(this, 80.0f)); layoutParams5.addRule(14, -1); linearLayout.setLayoutParams(layoutParams5); linearLayout.setOrientation(0); linearLayout.setGravity(17); this.f27863a.addView(linearLayout); ImageView imageView = new ImageView(this); imageView.setLayoutParams(new LinearLayout.LayoutParams(a.a(this, 24.0f), a.a(this, 24.0f))); imageView.setImageDrawable(b("com.tencent.plus.logo.png")); linearLayout.addView(imageView); this.i = new TextView(this); LinearLayout.LayoutParams layoutParams6 = new LinearLayout.LayoutParams(layoutParams3); layoutParams6.leftMargin = a.a(this, 7.0f); this.i.setLayoutParams(layoutParams6); this.i.setEllipsize(TextUtils.TruncateAt.END); this.i.setSingleLine(); this.i.setTextColor(-1); this.i.setTextSize(24.0f); this.i.setVisibility(8); linearLayout.addView(this.i); RelativeLayout relativeLayout3 = new RelativeLayout(this); RelativeLayout.LayoutParams layoutParams7 = new RelativeLayout.LayoutParams(-1, a.a(this, 60.0f)); layoutParams7.addRule(12, -1); layoutParams7.addRule(9, -1); relativeLayout3.setLayoutParams(layoutParams7); relativeLayout3.setBackgroundDrawable(b("com.tencent.plus.bar.png")); int a5 = a.a(this, 10.0f); relativeLayout3.setPadding(a5, a5, a5, 0); this.f27863a.addView(relativeLayout3); a aVar = new a(this); int a12 = a.a(this, 14.0f); int a13 = a.a(this, 7.0f); this.f27865g = new Button(this); this.f27865g.setLayoutParams(new RelativeLayout.LayoutParams(a.a(this, 78.0f), a.a(this, 45.0f))); this.f27865g.setText("取消"); this.f27865g.setTextColor(-1); this.f27865g.setTextSize(18.0f); this.f27865g.setPadding(a12, a13, a12, a13); aVar.b(this.f27865g); relativeLayout3.addView(this.f27865g); this.f = new Button(this); RelativeLayout.LayoutParams layoutParams8 = new RelativeLayout.LayoutParams(a.a(this, 78.0f), a.a(this, 45.0f)); layoutParams8.addRule(11, -1); this.f.setLayoutParams(layoutParams8); this.f.setTextColor(-1); this.f.setTextSize(18.0f); this.f.setPadding(a12, a13, a12, a13); this.f.setText("选取"); aVar.a(this.f); relativeLayout3.addView(this.f); TextView textView = new TextView(this); RelativeLayout.LayoutParams layoutParams9 = new RelativeLayout.LayoutParams(layoutParams3); layoutParams9.addRule(13, -1); textView.setLayoutParams(layoutParams9); textView.setText("移动和缩放"); textView.setPadding(0, a.a(this, 3.0f), 0, 0); textView.setTextSize(18.0f); textView.setTextColor(-1); relativeLayout3.addView(textView); this.j = new ProgressBar(this); RelativeLayout.LayoutParams layoutParams10 = new RelativeLayout.LayoutParams(layoutParams3); layoutParams10.addRule(14, -1); layoutParams10.addRule(15, -1); this.j.setLayoutParams(layoutParams10); this.j.setVisibility(8); this.f27863a.addView(this.j); return this.f27863a; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void c(String str) { String d12 = d(str); if (!"".equals(d12)) { this.i.setText(d12); this.i.setVisibility(0); } } private void a(Bitmap bitmap) { new QQAvatarImp(this.b).setAvator(bitmap, this.f27869v); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(final String str, final int i3) { this.d.post(new Runnable() { /* class com.tencent.connect.avatar.ImageActivity.AnonymousClass4 */ public void run() { ImageActivity.this.b((ImageActivity) str, (String) i3); } }); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(int i3, String str, String str2, String str3) { Intent intent = new Intent(); intent.putExtra("key_error_code", i3); intent.putExtra("key_error_msg", str2); intent.putExtra("key_error_detail", str3); intent.putExtra("key_response", str); setResult(-1, intent); } public void a(String str, long j12) { a(str, j12, this.b.getAppId()); } public static void a(String str, long j12, String str2) { HashMap j13 = a01.a.j("strValue", str2, "nValue", str); j13.put("qver", "3.5.13.lite"); if (j12 != 0) { j13.put("elt", String.valueOf(j12)); } h.a().a("https://cgi.qplus.com/report/report", j13); } }