Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,307 @@
package com.tencent.connect.share;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Base64;
import com.ijm.dataencryption.de.DataDecryptTool;
import com.tencent.connect.auth.QQToken;
import com.tencent.connect.common.BaseApi;
import com.tencent.connect.common.UIListenerManager;
import com.tencent.open.SocialConstants;
import com.tencent.open.TDialog;
import com.tencent.open.a.f;
import com.tencent.open.b.d;
import com.tencent.open.utils.b;
import com.tencent.open.utils.c;
import com.tencent.open.utils.i;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import java.io.File;
import java.util.ArrayList;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class QQShare extends BaseApi {
public String c;
public QQShare(Context context, QQToken qQToken) {
super(qQToken);
this.c = "";
}
private void c(final Activity activity, final Bundle bundle, final IUiListener iUiListener) {
f.c("openSDK_LOG.QQShare", "shareToMobileQQ() -- start.");
String string = bundle.getString(SocialConstants.PARAM_IMAGE_URL);
final String string2 = bundle.getString("title");
final String string3 = bundle.getString(SocialConstants.PARAM_SUMMARY);
f.a("openSDK_LOG.QQShare", "shareToMobileQQ -- imageUrl: " + string);
if (TextUtils.isEmpty(string)) {
d(activity, bundle, iUiListener);
} else if (!i.g(string)) {
bundle.putString(SocialConstants.PARAM_IMAGE_URL, null);
if (i.f(activity, "4.3.0")) {
f.b("openSDK_LOG.QQShare", "shareToMobileQQ -- QQ Version is < 4.3.0 ");
d(activity, bundle, iUiListener);
} else {
f.b("openSDK_LOG.QQShare", "shareToMobileQQ -- QQ Version is > 4.3.0 ");
a.a(activity, string, new c() { // from class: com.tencent.connect.share.QQShare.2
@Override // com.tencent.open.utils.c
public void a(int i, String str) {
if (i == 0) {
bundle.putString("imageLocalUrl", str);
} else if (TextUtils.isEmpty(string2) && TextUtils.isEmpty(string3)) {
IUiListener iUiListener2 = iUiListener;
if (iUiListener2 != null) {
iUiListener2.onError(new UiError(-6, "获取分享图片失败!", null));
f.e("openSDK_LOG.QQShare", "shareToMobileQQ -- error: 获取分享图片失败!");
}
d.a().a(1, "SHARE_CHECK_SDK", "1000", ((BaseApi) QQShare.this).b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "获取分享图片失败!");
return;
}
QQShare.this.d(activity, bundle, iUiListener);
}
@Override // com.tencent.open.utils.c
public void a(int i, ArrayList<String> arrayList) {
}
});
}
} else {
if (TextUtils.isEmpty(string2) && TextUtils.isEmpty(string3)) {
if (iUiListener != null) {
iUiListener.onError(new UiError(-6, "分享图片失败检测不到SD卡!", null));
f.e("openSDK_LOG.QQShare", "分享图片失败检测不到SD卡!");
}
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "分享图片失败检测不到SD卡!");
return;
}
if (i.f(activity, "4.3.0")) {
new b(activity).a(string, new c() { // from class: com.tencent.connect.share.QQShare.1
@Override // com.tencent.open.utils.c
public void a(int i, String str) {
if (i == 0) {
bundle.putString("imageLocalUrl", str);
} else if (TextUtils.isEmpty(string2) && TextUtils.isEmpty(string3)) {
IUiListener iUiListener2 = iUiListener;
if (iUiListener2 != null) {
iUiListener2.onError(new UiError(-6, "获取分享图片失败!", null));
f.e("openSDK_LOG.QQShare", "shareToMobileQQ -- error: 获取分享图片失败!");
}
d.a().a(1, "SHARE_CHECK_SDK", "1000", ((BaseApi) QQShare.this).b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "获取分享图片失败!");
return;
}
QQShare.this.d(activity, bundle, iUiListener);
}
@Override // com.tencent.open.utils.c
public void a(int i, ArrayList<String> arrayList) {
}
});
} else {
d(activity, bundle, iUiListener);
}
}
f.c("openSDK_LOG.QQShare", "shareToMobileQQ() -- end");
}
/* JADX INFO: Access modifiers changed from: private */
public void d(Activity activity, Bundle bundle, IUiListener iUiListener) {
int i;
int i2;
f.c("openSDK_LOG.QQShare", "doShareToQQ() -- start");
StringBuffer stringBuffer = new StringBuffer("mqqapi://share/to_fri?src_type=app&version=1&file_type=news");
String string = bundle.getString(SocialConstants.PARAM_IMAGE_URL);
String string2 = bundle.getString("title");
String string3 = bundle.getString(SocialConstants.PARAM_SUMMARY);
String string4 = bundle.getString(SocialConstants.PARAM_TARGET_URL);
String string5 = bundle.getString("audio_url");
int i3 = bundle.getInt("req_type", 1);
String string6 = bundle.getString("share_to_qq_ark_info");
int i4 = bundle.getInt("cflag", 0);
String string7 = bundle.getString("share_qq_ext_str");
String a = i.a(activity);
if (a == null) {
a = bundle.getString(SocialConstants.PARAM_APPNAME);
}
String str = a;
String string8 = bundle.getString("imageLocalUrl");
String b = this.b.b();
String c = this.b.c();
f.a("openSDK_LOG.QQShare", "doShareToQQ -- openid: " + c);
if (!TextUtils.isEmpty(string)) {
stringBuffer.append("&image_url=" + Base64.encodeToString(i.i(string), 2));
}
if (!TextUtils.isEmpty(string8)) {
stringBuffer.append("&file_data=" + Base64.encodeToString(i.i(string8), 2));
}
if (!TextUtils.isEmpty(string2)) {
stringBuffer.append("&title=" + Base64.encodeToString(i.i(string2), 2));
}
if (!TextUtils.isEmpty(string3)) {
stringBuffer.append("&description=" + Base64.encodeToString(i.i(string3), 2));
}
if (!TextUtils.isEmpty(b)) {
stringBuffer.append("&share_id=" + b);
}
if (!TextUtils.isEmpty(string4)) {
stringBuffer.append("&url=" + Base64.encodeToString(i.i(string4), 2));
}
if (!TextUtils.isEmpty(str)) {
if (str.length() > 20) {
str = str.substring(0, 20) + "...";
}
stringBuffer.append("&app_name=" + Base64.encodeToString(i.i(str), 2));
}
if (!TextUtils.isEmpty(c)) {
stringBuffer.append("&open_id=" + Base64.encodeToString(i.i(c), 2));
}
if (!TextUtils.isEmpty(string5)) {
stringBuffer.append("&audioUrl=" + Base64.encodeToString(i.i(string5), 2));
}
stringBuffer.append("&req_type=" + Base64.encodeToString(i.i(String.valueOf(i3)), 2));
if (!TextUtils.isEmpty(string6)) {
stringBuffer.append("&share_to_qq_ark_info=" + Base64.encodeToString(i.i(string6), 2));
}
if (!TextUtils.isEmpty(string7)) {
stringBuffer.append("&share_qq_ext_str=" + Base64.encodeToString(i.i(string7), 2));
}
stringBuffer.append("&cflag=" + Base64.encodeToString(i.i(String.valueOf(i4)), 2));
f.a("openSDK_LOG.QQShare", "doShareToQQ -- url: " + stringBuffer.toString());
com.tencent.connect.a.a.a(com.tencent.open.utils.d.a(), this.b, "requireApi", "shareToNativeQQ");
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(stringBuffer.toString()));
intent.putExtra("pkg_name", activity.getPackageName());
if (i.f(activity, "4.6.0")) {
f.c("openSDK_LOG.QQShare", "doShareToQQ, qqver below 4.6.");
if (a(intent)) {
UIListenerManager.a().a(11103, iUiListener);
a(activity, intent, 11103);
}
i2 = i4;
i = 1;
} else {
f.c("openSDK_LOG.QQShare", "doShareToQQ, qqver greater than 4.6.");
if (UIListenerManager.a().a("shareToQQ", iUiListener) != null) {
f.c("openSDK_LOG.QQShare", "doShareToQQ, last listener is not null, cancel it.");
}
if (a(intent)) {
i = 1;
a(activity, 10103, intent, true);
} else {
i = 1;
}
i2 = i4;
}
String str2 = i2 == i ? "11" : "10";
if (a(intent)) {
d.a().a(this.b.c(), this.b.b(), "ANDROIDQQ.SHARETOQQ.XX", str2, "3", "0", this.c, "0", "1", "0");
d.a().a(0, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "");
} else {
d.a().a(this.b.c(), this.b.b(), "ANDROIDQQ.SHARETOQQ.XX", str2, "3", "1", this.c, "0", "1", "0");
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "hasActivityForIntent fail");
}
f.c("openSDK_LOG.QQShare", "doShareToQQ() --end");
}
@Override // com.tencent.connect.common.BaseApi
public void releaseResource() {
}
public void b(Activity activity, Bundle bundle, IUiListener iUiListener) {
String str;
f.c("openSDK_LOG.QQShare", "shareToQQ() -- start.");
String string = bundle.getString(SocialConstants.PARAM_IMAGE_URL);
String string2 = bundle.getString("title");
String string3 = bundle.getString(SocialConstants.PARAM_SUMMARY);
String string4 = bundle.getString(SocialConstants.PARAM_TARGET_URL);
String string5 = bundle.getString("imageLocalUrl");
int i = bundle.getInt("req_type", 1);
f.c("openSDK_LOG.QQShare", "shareToQQ -- type: " + i);
if (i == 1) {
this.c = "1";
} else if (i == 2) {
this.c = "3";
} else if (i == 5) {
this.c = "2";
} else if (i == 6) {
this.c = "4";
}
if (i == 6) {
if (i.f(activity, "5.0.0")) {
iUiListener.onError(new UiError(-15, "手Q版本过低应用分享只支持手Q5.0及其以上版本", null));
f.e("openSDK_LOG.QQShare", "shareToQQ, app share is not support below qq5.0.");
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, app share is not support below qq5.0.");
return;
}
string4 = String.format("http://fusion.qq.com/cgi-bin/qzapps/unified_jump?appid=%1$s&from=%2$s&isOpenAppID=1", this.b.b(), "mqq");
bundle.putString(SocialConstants.PARAM_TARGET_URL, string4);
}
if (!i.b() && i.f(activity, "4.5.0")) {
iUiListener.onError(new UiError(-6, "分享图片失败检测不到SD卡!", null));
f.e("openSDK_LOG.QQShare", "shareToQQ sdcard is null--end");
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ sdcard is null");
return;
}
if (i == 5) {
if (i.f(activity, "4.3.0")) {
iUiListener.onError(new UiError(-6, "低版本手Q不支持该项功能!", null));
f.e("openSDK_LOG.QQShare", "shareToQQ, version below 4.3 is not support.");
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, version below 4.3 is not support.");
return;
} else if (!i.h(string5)) {
iUiListener.onError(new UiError(-6, "非法的图片地址!", null));
f.e("openSDK_LOG.QQShare", "shareToQQ -- error: 非法的图片地址!");
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "非法的图片地址!");
return;
}
}
if (i != 5) {
if (TextUtils.isEmpty(string4) || !(string4.startsWith("http://") || string4.startsWith("https://"))) {
iUiListener.onError(new UiError(-6, "传入参数有误!", null));
f.e("openSDK_LOG.QQShare", "shareToQQ, targetUrl is empty or illegal..");
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, targetUrl is empty or illegal..");
return;
} else if (TextUtils.isEmpty(string2)) {
iUiListener.onError(new UiError(-6, "title不能为空!", null));
f.e("openSDK_LOG.QQShare", "shareToQQ, title is empty.");
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, title is empty.");
return;
}
}
if (!TextUtils.isEmpty(string) && !string.startsWith("http://") && !string.startsWith("https://") && !new File(string).exists()) {
iUiListener.onError(new UiError(-6, "非法的图片地址!", null));
f.e("openSDK_LOG.QQShare", "shareToQQ, image url is emprty or illegal.");
d.a().a(1, "SHARE_CHECK_SDK", "1000", this.b.b(), String.valueOf(0), Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "shareToQQ, image url is emprty or illegal.");
return;
}
if (TextUtils.isEmpty(string2) || string2.length() <= 128) {
str = null;
} else {
str = null;
bundle.putString("title", i.a(string2, PeripheralType.SERVO, (String) null, (String) null));
}
if (!TextUtils.isEmpty(string3) && string3.length() > 512) {
bundle.putString(SocialConstants.PARAM_SUMMARY, i.a(string3, DataDecryptTool.DECRYPT_DB_FILE, str, str));
}
if (i.a(activity, bundle.getInt("cflag", 0) == 1)) {
f.c("openSDK_LOG.QQShare", "shareToQQ, support share");
c(activity, bundle, iUiListener);
} else {
try {
f.d("openSDK_LOG.QQShare", "shareToQQ, don't support share, will show download dialog");
new TDialog(activity, "", a(""), null, this.b).show();
} catch (RuntimeException e) {
f.b("openSDK_LOG.QQShare", " shareToQQ, TDialog.show not in main thread", e);
e.printStackTrace();
iUiListener.onError(new UiError(-6, "没有在主线程调用!", null));
}
}
f.c("openSDK_LOG.QQShare", "shareToQQ() -- end.");
}
}

View File

@@ -0,0 +1,78 @@
package com.tencent.connect.share;
import android.content.Context;
import com.tencent.connect.auth.QQToken;
import com.tencent.connect.common.BaseApi;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class QzoneShare extends BaseApi {
public String c;
private boolean d;
private boolean e;
private boolean f;
private boolean g;
public QzoneShare(Context context, QQToken qQToken) {
super(qQToken);
this.c = "";
this.d = true;
this.e = false;
this.f = false;
this.g = false;
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX WARN: Removed duplicated region for block: B:16:0x00bd */
/* JADX WARN: Removed duplicated region for block: B:31:0x0116 */
/* JADX WARN: Removed duplicated region for block: B:34:0x0139 */
/* JADX WARN: Removed duplicated region for block: B:37:0x015c */
/* JADX WARN: Removed duplicated region for block: B:40:0x0176 */
/* JADX WARN: Removed duplicated region for block: B:43:0x0199 */
/* JADX WARN: Removed duplicated region for block: B:46:0x01bc */
/* JADX WARN: Removed duplicated region for block: B:49:0x01df */
/* JADX WARN: Removed duplicated region for block: B:52:0x0223 */
/* JADX WARN: Removed duplicated region for block: B:55:0x0245 */
/* JADX WARN: Removed duplicated region for block: B:58:0x02d1 */
/* JADX WARN: Removed duplicated region for block: B:64:0x0316 */
/* JADX WARN: Removed duplicated region for block: B:68:0x035e */
/* JADX WARN: Removed duplicated region for block: B:69:0x02eb */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public void c(android.app.Activity r25, android.os.Bundle r26, com.tencent.tauth.IUiListener r27) {
/*
Method dump skipped, instructions count: 941
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.connect.share.QzoneShare.c(android.app.Activity, android.os.Bundle, com.tencent.tauth.IUiListener):void");
}
/* JADX WARN: Removed duplicated region for block: B:101:0x035e */
/* JADX WARN: Removed duplicated region for block: B:103:0x026e */
/* JADX WARN: Removed duplicated region for block: B:129:0x0191 */
/* JADX WARN: Removed duplicated region for block: B:12:0x009d */
/* JADX WARN: Removed duplicated region for block: B:132:0x00b1 */
/* JADX WARN: Removed duplicated region for block: B:17:0x00b7 */
/* JADX WARN: Removed duplicated region for block: B:38:0x01e5 */
/* JADX WARN: Removed duplicated region for block: B:48:0x0267 */
/* JADX WARN: Removed duplicated region for block: B:51:0x02e7 */
/* JADX WARN: Removed duplicated region for block: B:76:0x039e */
/* JADX WARN: Removed duplicated region for block: B:79:0x03ad */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public void b(final android.app.Activity r29, final android.os.Bundle r30, final com.tencent.tauth.IUiListener r31) {
/*
Method dump skipped, instructions count: 1103
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.connect.share.QzoneShare.b(android.app.Activity, android.os.Bundle, com.tencent.tauth.IUiListener):void");
}
@Override // com.tencent.connect.common.BaseApi
public void releaseResource() {
}
}

View File

@@ -0,0 +1,266 @@
package com.tencent.connect.share;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import com.tencent.open.a.f;
import com.tencent.open.utils.c;
import com.tencent.open.utils.i;
import com.thoughtworks.xstream.XStream;
import com.twitter.sdk.android.core.TwitterAuthConfig;
import com.ubt.jimu.base.cache.Constants;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class a {
/* JADX INFO: Access modifiers changed from: private */
public static final boolean b(String str, int i, int i2) {
if (TextUtils.isEmpty(str)) {
return false;
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
try {
BitmapFactory.decodeFile(str, options);
} catch (OutOfMemoryError e) {
e.printStackTrace();
}
int i3 = options.outWidth;
int i4 = options.outHeight;
if (options.mCancel || i3 == -1 || i4 == -1) {
return false;
}
int i5 = i3 > i4 ? i3 : i4;
if (i3 >= i4) {
i3 = i4;
}
f.b("openSDK_LOG.AsynScaleCompressImage", "longSide=" + i5 + "shortSide=" + i3);
options.inPreferredConfig = Bitmap.Config.RGB_565;
return i5 > i2 || i3 > i;
}
public static final void a(Context context, final String str, final c cVar) {
f.b("openSDK_LOG.AsynScaleCompressImage", "scaleCompressImage");
if (TextUtils.isEmpty(str)) {
cVar.a(1, (String) null);
} else if (!i.b()) {
cVar.a(2, (String) null);
} else {
final Handler handler = new Handler(context.getMainLooper()) { // from class: com.tencent.connect.share.a.1
@Override // android.os.Handler
public void handleMessage(Message message) {
int i = message.what;
if (i == 101) {
cVar.a(0, (String) message.obj);
} else if (i != 102) {
super.handleMessage(message);
} else {
cVar.a(message.arg1, (String) null);
}
}
};
new Thread(new Runnable() { // from class: com.tencent.connect.share.a.2
@Override // java.lang.Runnable
public void run() {
String a;
Bitmap a2 = a.a(str, TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE);
if (a2 != null) {
String str2 = Environment.getExternalStorageDirectory() + "/tmp/";
String str3 = "share2qq_temp" + i.f(str) + ".jpg";
if (a.b(str, TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE, TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE)) {
f.b("openSDK_LOG.AsynScaleCompressImage", "out of bound,compress!");
a = a.a(a2, str2, str3);
} else {
f.b("openSDK_LOG.AsynScaleCompressImage", "not out of bound,not compress!");
a = str;
}
f.b("openSDK_LOG.AsynScaleCompressImage", "-->destFilePath: " + a);
if (a != null) {
Message obtainMessage = handler.obtainMessage(101);
obtainMessage.obj = a;
handler.sendMessage(obtainMessage);
return;
}
}
Message obtainMessage2 = handler.obtainMessage(102);
obtainMessage2.arg1 = 3;
handler.sendMessage(obtainMessage2);
}
}).start();
}
}
public static final void a(Context context, final ArrayList<String> arrayList, final c cVar) {
f.b("openSDK_LOG.AsynScaleCompressImage", "batchScaleCompressImage");
if (arrayList == null) {
cVar.a(1, (String) null);
} else {
final Handler handler = new Handler(context.getMainLooper()) { // from class: com.tencent.connect.share.a.3
@Override // android.os.Handler
public void handleMessage(Message message) {
if (message.what != 101) {
super.handleMessage(message);
} else {
cVar.a(0, message.getData().getStringArrayList(Constants.IMAGE_PATH));
}
}
};
new Thread(new Runnable() { // from class: com.tencent.connect.share.a.4
@Override // java.lang.Runnable
public void run() {
Bitmap a;
for (int i = 0; i < arrayList.size(); i++) {
String str = (String) arrayList.get(i);
if (!i.g(str) && i.h(str) && (a = a.a(str, XStream.PRIORITY_VERY_HIGH)) != null) {
String str2 = Environment.getExternalStorageDirectory() + "/tmp/";
String str3 = "share2qzone_temp" + i.f(str) + ".jpg";
if (a.b(str, 640, XStream.PRIORITY_VERY_HIGH)) {
f.b("openSDK_LOG.AsynScaleCompressImage", "out of bound, compress!");
str = a.a(a, str2, str3);
} else {
f.b("openSDK_LOG.AsynScaleCompressImage", "not out of bound,not compress!");
}
if (str != null) {
arrayList.set(i, str);
}
}
}
Message obtainMessage = handler.obtainMessage(101);
Bundle bundle = new Bundle();
bundle.putStringArrayList(Constants.IMAGE_PATH, arrayList);
obtainMessage.setData(bundle);
handler.sendMessage(obtainMessage);
}
}).start();
}
}
private static int b(BitmapFactory.Options options, int i, int i2) {
int min;
double d = options.outWidth;
double d2 = options.outHeight;
int ceil = i2 == -1 ? 1 : (int) Math.ceil(Math.sqrt((d * d2) / i2));
if (i == -1) {
min = PeripheralType.SERVO;
} else {
double d3 = i;
min = (int) Math.min(Math.floor(d / d3), Math.floor(d2 / d3));
}
if (min < ceil) {
return ceil;
}
if (i2 == -1 && i == -1) {
return 1;
}
return i == -1 ? ceil : min;
}
private static Bitmap a(Bitmap bitmap, int i) {
Matrix matrix = new Matrix();
int width = bitmap.getWidth();
int height = bitmap.getHeight();
if (width <= height) {
width = height;
}
float f = i / width;
matrix.postScale(f, f);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
protected static final String a(Bitmap bitmap, String str, String str2) {
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
StringBuffer stringBuffer = new StringBuffer(str);
stringBuffer.append(str2);
String stringBuffer2 = stringBuffer.toString();
File file2 = new File(stringBuffer2);
if (file2.exists()) {
file2.delete();
}
if (bitmap == null) {
return null;
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file2);
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
bitmap.recycle();
return stringBuffer2;
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (IOException e2) {
e2.printStackTrace();
return null;
}
}
public static final Bitmap a(String str, int i) {
Bitmap bitmap;
if (TextUtils.isEmpty(str)) {
return null;
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
try {
BitmapFactory.decodeFile(str, options);
} catch (OutOfMemoryError e) {
e.printStackTrace();
}
int i2 = options.outWidth;
int i3 = options.outHeight;
if (options.mCancel || i2 == -1 || i3 == -1) {
return null;
}
if (i2 <= i3) {
i2 = i3;
}
options.inPreferredConfig = Bitmap.Config.RGB_565;
if (i2 > i) {
options.inSampleSize = a(options, -1, i * i);
}
options.inJustDecodeBounds = false;
try {
bitmap = BitmapFactory.decodeFile(str, options);
} catch (OutOfMemoryError e2) {
e2.printStackTrace();
bitmap = null;
}
if (bitmap == null) {
return null;
}
int i4 = options.outWidth;
int i5 = options.outHeight;
if (i4 > i5) {
i5 = i4;
}
return i5 > i ? a(bitmap, i) : bitmap;
}
public static final int a(BitmapFactory.Options options, int i, int i2) {
int b = b(options, i, i2);
if (b > 8) {
return ((b + 7) / 8) * 8;
}
int i3 = 1;
while (i3 < b) {
i3 <<= 1;
}
return i3;
}
}