jimu-decompiled/sources/com/ubtrobot/ubtlib/social/SocialTool.java
2025-05-13 19:24:51 +02:00

89 lines
3.6 KiB
Java

package com.ubtrobot.ubtlib.social;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import com.ubtrobot.ubtlib.share.UbtSocialShareListener;
import java.text.MessageFormat;
/* loaded from: classes2.dex */
public class SocialTool {
private static UbtSocialAuthListener a;
private static UbtSocialShareListener b;
public static String a(Context context, String str) {
try {
String string = context.getPackageManager().getApplicationInfo(context.getPackageName(), PeripheralType.SERVO).metaData.getString(str);
if (!TextUtils.isEmpty(string)) {
Log.d("UbtSocial", MessageFormat.format("meta data {0}:{1}", str, string));
return string;
}
throw new RuntimeException(str + " don't exist in AndroidManifest.xml");
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(context.getPackageName() + " package name not found", e);
}
}
public static UbtSocialShareListener b() {
return b;
}
public static String a(Context context) {
ApplicationInfo applicationInfo = context.getApplicationInfo();
if (applicationInfo.labelRes != 0) {
Log.d("UbtSocial", "labelRes : " + context.getString(applicationInfo.labelRes));
return context.getString(applicationInfo.labelRes);
}
Log.d("UbtSocial", "nonLocalizedLabel : " + ((Object) applicationInfo.nonLocalizedLabel));
if (applicationInfo.nonLocalizedLabel != null) {
return (String) applicationInfo.nonLocalizedLabel;
}
String str = (String) context.getPackageManager().getApplicationLabel(applicationInfo);
Log.d("UbtSocial", "ApplicationLabel " + str);
if (str != null) {
return str;
}
throw new RuntimeException("couldn't get application label");
}
public static String a(BaseResp baseResp) {
return MessageFormat.format("wechat errCode: {0}, errStr: {1}, openId: {2}, transaction: {3}, classname: {4}", Integer.valueOf(baseResp.errCode), baseResp.errStr, baseResp.openId, baseResp.transaction, baseResp.getClass().getName());
}
public static String a(SendAuth.Resp resp) {
return MessageFormat.format("code: {0}, state: {1}, url: {2}, lang: {3}, country: {4}", resp.code, resp.state, resp.url, resp.lang, resp.country);
}
public static String a(SendMessageToWX.Resp resp) {
return MessageFormat.format("wechat errCode: {0}, errStr: {1}, openId: {2}, transaction: {3}, type: {4}", Integer.valueOf(resp.errCode), resp.errStr, resp.openId, resp.transaction, Integer.valueOf(resp.getType()));
}
public static void a(Activity activity, String str) {
activity.runOnUiThread(new Runnable() { // from class: com.ubtrobot.ubtlib.social.SocialTool.1
@Override // java.lang.Runnable
public void run() {
}
});
}
public static void a(UbtSocialAuthListener ubtSocialAuthListener) {
a = ubtSocialAuthListener;
}
public static UbtSocialAuthListener a() {
return a;
}
public static void a(UbtSocialShareListener ubtSocialShareListener) {
b = ubtSocialShareListener;
}
}