Initial commit
This commit is contained in:
27
sources/com/ubtrobot/ubtlib/account/AccountType.java
Normal file
27
sources/com/ubtrobot/ubtlib/account/AccountType.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.ubtrobot.ubtlib.account;
|
||||
|
||||
import android.util.Patterns;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum AccountType {
|
||||
mobile_phone("userPhone", "1"),
|
||||
email("userEmail", "2");
|
||||
|
||||
public String typeKey;
|
||||
public String typeValue;
|
||||
|
||||
AccountType(String str, String str2) {
|
||||
this.typeKey = str;
|
||||
this.typeValue = str2;
|
||||
}
|
||||
|
||||
public static AccountType convertToEnum(String str) {
|
||||
if (Patterns.EMAIL_ADDRESS.matcher(str).find()) {
|
||||
return email;
|
||||
}
|
||||
if (Patterns.PHONE.matcher(str).find()) {
|
||||
return mobile_phone;
|
||||
}
|
||||
throw new RuntimeException("account format error, accout : " + str);
|
||||
}
|
||||
}
|
201
sources/com/ubtrobot/ubtlib/account/UbtUserEntity.java
Normal file
201
sources/com/ubtrobot/ubtlib/account/UbtUserEntity.java
Normal file
@@ -0,0 +1,201 @@
|
||||
package com.ubtrobot.ubtlib.account;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtUserEntity implements Parcelable {
|
||||
public static final Parcelable.Creator<UbtUserEntity> CREATOR = new Parcelable.Creator<UbtUserEntity>() { // from class: com.ubtrobot.ubtlib.account.UbtUserEntity.1
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public UbtUserEntity createFromParcel(Parcel parcel) {
|
||||
return new UbtUserEntity(parcel);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // android.os.Parcelable.Creator
|
||||
public UbtUserEntity[] newArray(int i) {
|
||||
return new UbtUserEntity[i];
|
||||
}
|
||||
};
|
||||
private String isDev;
|
||||
private String nickName;
|
||||
private Integer registerType;
|
||||
private String userBirthday;
|
||||
private String userEmail;
|
||||
private String userGender;
|
||||
private String userId;
|
||||
private String userImage;
|
||||
private String userName;
|
||||
private String userPassword;
|
||||
private String userPhone;
|
||||
private String userRoleType;
|
||||
private String userStatus;
|
||||
private String verificationCode;
|
||||
private String webappRoleId;
|
||||
|
||||
public UbtUserEntity() {
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getIsDev() {
|
||||
return this.isDev;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return this.nickName;
|
||||
}
|
||||
|
||||
public Integer getRegisterType() {
|
||||
return this.registerType;
|
||||
}
|
||||
|
||||
public String getUserBirthday() {
|
||||
return this.userBirthday;
|
||||
}
|
||||
|
||||
public String getUserEmail() {
|
||||
return this.userEmail;
|
||||
}
|
||||
|
||||
public String getUserGender() {
|
||||
return this.userGender;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public String getUserImage() {
|
||||
return this.userImage;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.userName;
|
||||
}
|
||||
|
||||
public String getUserPassword() {
|
||||
return this.userPassword;
|
||||
}
|
||||
|
||||
public String getUserPhone() {
|
||||
return this.userPhone;
|
||||
}
|
||||
|
||||
public String getUserRoleType() {
|
||||
return this.userRoleType;
|
||||
}
|
||||
|
||||
public String getUserStatus() {
|
||||
return this.userStatus;
|
||||
}
|
||||
|
||||
public String getVerificationCode() {
|
||||
return this.verificationCode;
|
||||
}
|
||||
|
||||
public String getWebappRoleId() {
|
||||
return this.webappRoleId;
|
||||
}
|
||||
|
||||
public void setIsDev(String str) {
|
||||
this.isDev = str;
|
||||
}
|
||||
|
||||
public void setNickName(String str) {
|
||||
this.nickName = str;
|
||||
}
|
||||
|
||||
public void setRegisterType(Integer num) {
|
||||
this.registerType = num;
|
||||
}
|
||||
|
||||
public void setUserBirthday(String str) {
|
||||
this.userBirthday = str;
|
||||
}
|
||||
|
||||
public void setUserEmail(String str) {
|
||||
this.userEmail = str;
|
||||
}
|
||||
|
||||
public void setUserGender(String str) {
|
||||
this.userGender = str;
|
||||
}
|
||||
|
||||
public void setUserId(String str) {
|
||||
this.userId = str;
|
||||
}
|
||||
|
||||
public void setUserImage(String str) {
|
||||
this.userImage = str;
|
||||
}
|
||||
|
||||
public void setUserName(String str) {
|
||||
this.userName = str;
|
||||
}
|
||||
|
||||
public void setUserPassword(String str) {
|
||||
this.userPassword = str;
|
||||
}
|
||||
|
||||
public void setUserPhone(String str) {
|
||||
this.userPhone = str;
|
||||
}
|
||||
|
||||
public void setUserRoleType(String str) {
|
||||
this.userRoleType = str;
|
||||
}
|
||||
|
||||
public void setUserStatus(String str) {
|
||||
this.userStatus = str;
|
||||
}
|
||||
|
||||
public void setVerificationCode(String str) {
|
||||
this.verificationCode = str;
|
||||
}
|
||||
|
||||
public void setWebappRoleId(String str) {
|
||||
this.webappRoleId = str;
|
||||
}
|
||||
|
||||
@Override // android.os.Parcelable
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
parcel.writeString(this.userId);
|
||||
parcel.writeString(this.userName);
|
||||
parcel.writeString(this.userPassword);
|
||||
parcel.writeString(this.userEmail);
|
||||
parcel.writeString(this.userPhone);
|
||||
parcel.writeString(this.userGender);
|
||||
parcel.writeString(this.nickName);
|
||||
parcel.writeString(this.userBirthday);
|
||||
parcel.writeString(this.userStatus);
|
||||
parcel.writeString(this.userRoleType);
|
||||
parcel.writeString(this.userImage);
|
||||
parcel.writeValue(this.registerType);
|
||||
parcel.writeString(this.isDev);
|
||||
parcel.writeString(this.webappRoleId);
|
||||
parcel.writeString(this.verificationCode);
|
||||
}
|
||||
|
||||
protected UbtUserEntity(Parcel parcel) {
|
||||
this.userId = parcel.readString();
|
||||
this.userName = parcel.readString();
|
||||
this.userPassword = parcel.readString();
|
||||
this.userEmail = parcel.readString();
|
||||
this.userPhone = parcel.readString();
|
||||
this.userGender = parcel.readString();
|
||||
this.nickName = parcel.readString();
|
||||
this.userBirthday = parcel.readString();
|
||||
this.userStatus = parcel.readString();
|
||||
this.userRoleType = parcel.readString();
|
||||
this.userImage = parcel.readString();
|
||||
this.registerType = (Integer) parcel.readValue(Integer.class.getClassLoader());
|
||||
this.isDev = parcel.readString();
|
||||
this.webappRoleId = parcel.readString();
|
||||
this.verificationCode = parcel.readString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package com.ubtrobot.ubtlib.analytics;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class FirebaseAnalyticsImp implements IAnalytics {
|
||||
private FirebaseAnalytics a;
|
||||
|
||||
public void a(Context context) {
|
||||
this.a = FirebaseAnalytics.getInstance(context);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void b(Activity activity, String str) {
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
}
|
||||
|
||||
public void b(boolean z) {
|
||||
}
|
||||
|
||||
public void c(String str) {
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(String str, Map<String, String> map) {
|
||||
Bundle bundle = new Bundle();
|
||||
Log.d("FirebaseAnalyticsImp", "Event param: key= " + map.size());
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
Log.d("FirebaseAnalyticsImp", "Event param: key= " + entry.getKey() + " and value= " + entry.getValue());
|
||||
bundle.putString(entry.getKey(), entry.getValue());
|
||||
}
|
||||
this.a.a(str, bundle);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(String str) {
|
||||
this.a.a(str, null);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(Activity activity, String str) {
|
||||
this.a.setCurrentScreen(activity, str, null);
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.a.a(z);
|
||||
}
|
||||
}
|
15
sources/com/ubtrobot/ubtlib/analytics/IAnalytics.java
Normal file
15
sources/com/ubtrobot/ubtlib/analytics/IAnalytics.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.ubtrobot.ubtlib.analytics;
|
||||
|
||||
import android.app.Activity;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IAnalytics {
|
||||
void a(Activity activity, String str);
|
||||
|
||||
void a(String str);
|
||||
|
||||
void a(String str, Map<String, String> map);
|
||||
|
||||
void b(Activity activity, String str);
|
||||
}
|
106
sources/com/ubtrobot/ubtlib/analytics/JimuAnalytics.java
Normal file
106
sources/com/ubtrobot/ubtlib/analytics/JimuAnalytics.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package com.ubtrobot.ubtlib.analytics;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class JimuAnalytics implements IAnalytics {
|
||||
private static JimuAnalytics e;
|
||||
private volatile boolean c = true;
|
||||
private volatile boolean d = false;
|
||||
private FirebaseAnalyticsImp b = new FirebaseAnalyticsImp();
|
||||
private UbtAnalytics a = new UbtAnalytics();
|
||||
|
||||
private JimuAnalytics() {
|
||||
}
|
||||
|
||||
public static synchronized JimuAnalytics b() {
|
||||
JimuAnalytics jimuAnalytics;
|
||||
synchronized (JimuAnalytics.class) {
|
||||
if (e == null) {
|
||||
e = new JimuAnalytics();
|
||||
}
|
||||
jimuAnalytics = e;
|
||||
}
|
||||
return jimuAnalytics;
|
||||
}
|
||||
|
||||
public void a(Context context) {
|
||||
if (this.d) {
|
||||
return;
|
||||
}
|
||||
this.a.a(context);
|
||||
this.b.a(context);
|
||||
this.d = true;
|
||||
}
|
||||
|
||||
public void c(String str) {
|
||||
if (a() && this.d) {
|
||||
this.a.c(str);
|
||||
this.b.c(str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void b(Activity activity, String str) {
|
||||
if (a() && this.d) {
|
||||
this.a.b(activity, str);
|
||||
this.b.b(activity, str);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(String str, String str2) {
|
||||
if (a() && this.d) {
|
||||
this.a.a(str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(String str, Map<String, String> map) {
|
||||
if (a() && this.d) {
|
||||
this.a.a(str, map);
|
||||
this.b.a(str, map);
|
||||
}
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
if (a() && this.d) {
|
||||
this.a.b(str);
|
||||
this.b.b(str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(String str) {
|
||||
if (a() && this.d) {
|
||||
this.a.a(str);
|
||||
this.b.a(str);
|
||||
}
|
||||
}
|
||||
|
||||
public void b(boolean z) {
|
||||
if (a() && this.d) {
|
||||
this.a.b(z);
|
||||
this.b.b(z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(Activity activity, String str) {
|
||||
if (a() && this.d) {
|
||||
this.a.a(activity, str);
|
||||
this.b.a(activity, str);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.c = z;
|
||||
this.b.a(z);
|
||||
this.a.a(z);
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
137
sources/com/ubtrobot/ubtlib/analytics/UbtAnalytics.java
Normal file
137
sources/com/ubtrobot/ubtlib/analytics/UbtAnalytics.java
Normal file
@@ -0,0 +1,137 @@
|
||||
package com.ubtrobot.ubtlib.analytics;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.ubtrobot.analytics.mobile.AnalyticsKit;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtAnalytics implements IAnalytics {
|
||||
private boolean a = false;
|
||||
|
||||
public void a(Context context) {
|
||||
if (this.a) {
|
||||
return;
|
||||
}
|
||||
Context applicationContext = context.getApplicationContext();
|
||||
try {
|
||||
Bundle bundle = applicationContext.getPackageManager().getApplicationInfo(applicationContext.getPackageName(), PeripheralType.SERVO).metaData;
|
||||
if (bundle == null) {
|
||||
Log.w("UbtAnalytics", "No ubtrobot analytics appid and key in AndroidManifest.xml.");
|
||||
return;
|
||||
}
|
||||
String string = bundle.getString("app_id_ubt_analytics");
|
||||
String string2 = bundle.getString("app_key_ubt_analytics");
|
||||
if (TextUtils.isEmpty(string) || TextUtils.isEmpty(string2)) {
|
||||
return;
|
||||
}
|
||||
Log.i("UbtAnalytics", "ubtrobot analytics appid:" + string);
|
||||
Log.i("UbtAnalytics", "ubtrobot analytics key:" + string2);
|
||||
String a = a();
|
||||
Log.w("UbtAnalytics", "ubtrobot analytics deviceId:" + a);
|
||||
AnalyticsKit.a(context, string, string2, a, null);
|
||||
this.a = true;
|
||||
Log.i("UbtAnalytics", "Ubtrobot AnalyticsKit initialized");
|
||||
} catch (Exception e) {
|
||||
this.a = false;
|
||||
Log.w("UbtAnalytics", "UbtAnalytics init fail!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void b(Activity activity, String str) {
|
||||
if (!this.a) {
|
||||
Log.e("UbtAnalytics", "UbtAnalytics not inited!");
|
||||
return;
|
||||
}
|
||||
Log.d("UbtAnalytics", "recordContentViewEnd screenName:" + str);
|
||||
AnalyticsKit.d(str);
|
||||
}
|
||||
|
||||
public void c(String str) {
|
||||
if (!this.a) {
|
||||
Log.e("UbtAnalytics", "UbtAnalytics not inited!");
|
||||
return;
|
||||
}
|
||||
Log.d("UbtAnalytics", "recordActivityStart activityName:" + str);
|
||||
AnalyticsKit.b(str);
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
if (!this.a) {
|
||||
Log.e("UbtAnalytics", "UbtAnalytics not inited!");
|
||||
return;
|
||||
}
|
||||
Log.d("UbtAnalytics", "recordActivityEnd activityName:" + str);
|
||||
AnalyticsKit.a(str);
|
||||
}
|
||||
|
||||
public void b(boolean z) {
|
||||
AnalyticsKit.b(z);
|
||||
}
|
||||
|
||||
public void a(String str, String str2) {
|
||||
if (!this.a) {
|
||||
Log.e("UbtAnalytics", "UbtAnalytics not inited!");
|
||||
return;
|
||||
}
|
||||
Log.d("UbtAnalytics", "setDeviceInfo userId:" + str + " channel:" + str2);
|
||||
AnalyticsKit.c(str, str2);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(String str, Map<String, String> map) {
|
||||
if (!this.a) {
|
||||
Log.e("UbtAnalytics", "UbtAnalytics not inited!");
|
||||
return;
|
||||
}
|
||||
if (map.containsKey("duration")) {
|
||||
long longValue = Long.valueOf(map.get("duration")).longValue();
|
||||
map.remove("duration");
|
||||
Log.d("UbtAnalytics", "recordEvent eventId:" + str + " duration:" + longValue + " map:" + map);
|
||||
AnalyticsKit.b(str, longValue, map);
|
||||
return;
|
||||
}
|
||||
Log.d("UbtAnalytics", "recordEvent eventId:" + str + " map:" + map);
|
||||
AnalyticsKit.a(str, map);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(String str) {
|
||||
if (!this.a) {
|
||||
Log.e("UbtAnalytics", "UbtAnalytics not inited!");
|
||||
return;
|
||||
}
|
||||
Log.d("UbtAnalytics", "recordEvent eventId:" + str);
|
||||
AnalyticsKit.c(str);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.analytics.IAnalytics
|
||||
public void a(Activity activity, String str) {
|
||||
if (!this.a) {
|
||||
Log.e("UbtAnalytics", "UbtAnalytics not inited!");
|
||||
return;
|
||||
}
|
||||
Log.d("UbtAnalytics", "recordContentViewStart screenName:" + str);
|
||||
AnalyticsKit.e(str);
|
||||
}
|
||||
|
||||
public static String a() {
|
||||
String str = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) + (Build.CPU_ABI.length() % 10) + (Build.DEVICE.length() % 10) + (Build.DISPLAY.length() % 10) + (Build.HOST.length() % 10) + (Build.ID.length() % 10) + (Build.MANUFACTURER.length() % 10) + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10) + (Build.TAGS.length() % 10) + (Build.TYPE.length() % 10) + (Build.USER.length() % 10);
|
||||
try {
|
||||
return new UUID(str.hashCode(), Build.class.getField("SERIAL").get(null).toString().hashCode()).toString();
|
||||
} catch (Exception unused) {
|
||||
return new UUID(str.hashCode(), "serial".hashCode()).toString();
|
||||
}
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
AnalyticsKit.a(z);
|
||||
}
|
||||
}
|
16
sources/com/ubtrobot/ubtlib/analytics/UbtPageIdUtil.java
Normal file
16
sources/com/ubtrobot/ubtlib/analytics/UbtPageIdUtil.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.ubtrobot.ubtlib.analytics;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtPageIdUtil {
|
||||
private static HashMap<String, String> a = new HashMap<>();
|
||||
|
||||
public static String a(String str, String str2) {
|
||||
return a.put(str, str2);
|
||||
}
|
||||
|
||||
public static String a(String str) {
|
||||
return a.get(str);
|
||||
}
|
||||
}
|
57
sources/com/ubtrobot/ubtlib/share/ShareBuilder.java
Normal file
57
sources/com/ubtrobot/ubtlib/share/ShareBuilder.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.ubtrobot.ubtlib.share;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ShareBuilder {
|
||||
private String a;
|
||||
private String b;
|
||||
private String c;
|
||||
private int d;
|
||||
private Uri e;
|
||||
|
||||
public ShareBuilder a(String str) {
|
||||
this.c = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ShareBuilder b(String str) {
|
||||
this.a = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ShareBuilder c(String str) {
|
||||
this.b = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String d() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public String e() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public ShareBuilder a(int i) {
|
||||
this.d = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String b() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public int c() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public ShareBuilder a(Uri uri) {
|
||||
this.e = uri;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Uri a() {
|
||||
return this.e;
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.ubtrobot.ubtlib.share;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface UbtSocialShareListener {
|
||||
void a();
|
||||
|
||||
void onCancel();
|
||||
|
||||
void onSuccess();
|
||||
}
|
128
sources/com/ubtrobot/ubtlib/social/FacebookUbtSocialImpl.java
Normal file
128
sources/com/ubtrobot/ubtlib/social/FacebookUbtSocialImpl.java
Normal file
@@ -0,0 +1,128 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import com.facebook.AccessToken;
|
||||
import com.facebook.CallbackManager;
|
||||
import com.facebook.FacebookCallback;
|
||||
import com.facebook.FacebookException;
|
||||
import com.facebook.GraphRequest;
|
||||
import com.facebook.GraphResponse;
|
||||
import com.facebook.login.LoginManager;
|
||||
import com.facebook.login.LoginResult;
|
||||
import com.facebook.share.model.ShareLinkContent;
|
||||
import com.facebook.share.widget.ShareDialog;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import com.ubtrobot.ubtlib.share.ShareBuilder;
|
||||
import com.ubtrobot.ubtlib.share.UbtSocialShareListener;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class FacebookUbtSocialImpl implements IUbtSocial {
|
||||
private Activity a;
|
||||
private LoginManager b;
|
||||
private CallbackManager c;
|
||||
private AccessToken d;
|
||||
private FacebookCallback<LoginResult> e;
|
||||
private String f;
|
||||
private ShareDialog g;
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialShareListener ubtSocialShareListener) {
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public boolean b() {
|
||||
try {
|
||||
this.a.getPackageManager().getPackageInfo("com.facebook.katana", 0);
|
||||
return true;
|
||||
} catch (PackageManager.NameNotFoundException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a() {
|
||||
LoginManager.a().a(this.a, Arrays.asList("public_profile"));
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(Activity activity) {
|
||||
this.a = activity;
|
||||
this.g = new ShareDialog(this.a);
|
||||
this.b = LoginManager.a();
|
||||
this.c = CallbackManager.Factory.a();
|
||||
this.d = AccessToken.getCurrentAccessToken();
|
||||
this.f = SocialTool.a((Context) this.a, "com.facebook.sdk.ApplicationId");
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(int i, int i2, Intent intent) {
|
||||
this.c.a(i, i2, intent);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(final UbtSocialAuthListener ubtSocialAuthListener) {
|
||||
this.e = new FacebookCallback<LoginResult>() { // from class: com.ubtrobot.ubtlib.social.FacebookUbtSocialImpl.1
|
||||
@Override // com.facebook.FacebookCallback
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onSuccess(LoginResult loginResult) {
|
||||
FacebookUbtSocialImpl.this.d = loginResult.a();
|
||||
GraphRequest a = GraphRequest.a(FacebookUbtSocialImpl.this.d, new GraphRequest.GraphJSONObjectCallback() { // from class: com.ubtrobot.ubtlib.social.FacebookUbtSocialImpl.1.1
|
||||
@Override // com.facebook.GraphRequest.GraphJSONObjectCallback
|
||||
public void a(JSONObject jSONObject, GraphResponse graphResponse) {
|
||||
if (graphResponse == null || graphResponse.b() == null) {
|
||||
ubtSocialAuthListener.a(new Throwable(""));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String string = graphResponse.b().getJSONObject(SocialConstants.PARAM_AVATAR_URI).getJSONObject("data").getString("url");
|
||||
String optString = graphResponse.b().optString(MediationMetaData.KEY_NAME);
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put("ubtsocial_user_id", FacebookUbtSocialImpl.this.d.getUserId());
|
||||
hashMap.put(AccessToken.ACCESS_TOKEN_KEY, FacebookUbtSocialImpl.this.d.getToken());
|
||||
hashMap.put("ubtsocial_app_id", FacebookUbtSocialImpl.this.f);
|
||||
hashMap.put("social_type", UbtSocialType.FACEBOOK.loginType);
|
||||
hashMap.put("nick_name", optString);
|
||||
hashMap.put("head_image", string);
|
||||
ubtSocialAuthListener.a(hashMap);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
ubtSocialAuthListener.a(new Throwable(""));
|
||||
}
|
||||
}
|
||||
});
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("fields", "id,name,link,gender,picture.type(large)");
|
||||
a.a(bundle);
|
||||
a.b();
|
||||
}
|
||||
|
||||
@Override // com.facebook.FacebookCallback
|
||||
public void onCancel() {
|
||||
ubtSocialAuthListener.onCancel();
|
||||
}
|
||||
|
||||
@Override // com.facebook.FacebookCallback
|
||||
public void a(FacebookException facebookException) {
|
||||
ubtSocialAuthListener.a(facebookException);
|
||||
}
|
||||
};
|
||||
this.b.a(this.c, this.e);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(ShareBuilder shareBuilder) {
|
||||
ShareLinkContent.Builder builder = new ShareLinkContent.Builder();
|
||||
builder.a(Uri.parse(shareBuilder.e()));
|
||||
this.g.a((ShareDialog) builder.a());
|
||||
}
|
||||
}
|
23
sources/com/ubtrobot/ubtlib/social/IUbtSocial.java
Normal file
23
sources/com/ubtrobot/ubtlib/social/IUbtSocial.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import com.ubtrobot.ubtlib.share.ShareBuilder;
|
||||
import com.ubtrobot.ubtlib.share.UbtSocialShareListener;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IUbtSocial {
|
||||
void a();
|
||||
|
||||
void a(int i, int i2, Intent intent);
|
||||
|
||||
void a(Activity activity);
|
||||
|
||||
void a(ShareBuilder shareBuilder);
|
||||
|
||||
void a(UbtSocialShareListener ubtSocialShareListener);
|
||||
|
||||
void a(UbtSocialAuthListener ubtSocialAuthListener);
|
||||
|
||||
boolean b();
|
||||
}
|
88
sources/com/ubtrobot/ubtlib/social/SocialTool.java
Normal file
88
sources/com/ubtrobot/ubtlib/social/SocialTool.java
Normal file
@@ -0,0 +1,88 @@
|
||||
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;
|
||||
}
|
||||
}
|
169
sources/com/ubtrobot/ubtlib/social/TencentUbtSocialImpl.java
Normal file
169
sources/com/ubtrobot/ubtlib/social/TencentUbtSocialImpl.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import com.facebook.AccessToken;
|
||||
import com.tencent.connect.UserInfo;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import com.tencent.tauth.IUiListener;
|
||||
import com.tencent.tauth.Tencent;
|
||||
import com.tencent.tauth.UiError;
|
||||
import com.ubtrobot.ubtlib.share.ShareBuilder;
|
||||
import com.ubtrobot.ubtlib.share.UbtSocialShareListener;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class TencentUbtSocialImpl implements IUbtSocial {
|
||||
private UbtSocialAuthListener a;
|
||||
private UbtSocialShareListener b;
|
||||
private Activity c;
|
||||
private IUiListener d;
|
||||
private Tencent e;
|
||||
private String f;
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(Activity activity) {
|
||||
this.f = SocialTool.a((Context) activity, "app_id_qq");
|
||||
this.e = Tencent.a(this.f, activity.getApplicationContext());
|
||||
this.c = activity;
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public boolean b() {
|
||||
try {
|
||||
this.c.getPackageManager().getPackageInfo("com.tencent.mobileqq", 0);
|
||||
return true;
|
||||
} catch (PackageManager.NameNotFoundException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialAuthListener ubtSocialAuthListener) {
|
||||
this.a = ubtSocialAuthListener;
|
||||
this.d = new IUiListener() { // from class: com.ubtrobot.ubtlib.social.TencentUbtSocialImpl.1
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onCancel() {
|
||||
if (TencentUbtSocialImpl.this.a != null) {
|
||||
TencentUbtSocialImpl.this.a.onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onComplete(Object obj) {
|
||||
try {
|
||||
JSONObject jSONObject = (JSONObject) obj;
|
||||
Log.i("UbtSocial", jSONObject.toString());
|
||||
final HashMap hashMap = new HashMap();
|
||||
hashMap.put("ubtsocial_user_id", jSONObject.getString(SocialConstants.PARAM_OPEN_ID));
|
||||
hashMap.put(AccessToken.ACCESS_TOKEN_KEY, jSONObject.getString(AccessToken.ACCESS_TOKEN_KEY));
|
||||
hashMap.put("ubtsocial_app_id", TencentUbtSocialImpl.this.f);
|
||||
hashMap.put("social_type", UbtSocialType.QQ.loginType);
|
||||
TencentUbtSocialImpl.this.e.b().a(jSONObject.getString(SocialConstants.PARAM_OPEN_ID));
|
||||
TencentUbtSocialImpl.this.e.b().a(jSONObject.getString(AccessToken.ACCESS_TOKEN_KEY), jSONObject.getString(AccessToken.EXPIRES_IN_KEY));
|
||||
new UserInfo(TencentUbtSocialImpl.this.c, TencentUbtSocialImpl.this.e.b()).a(new IUiListener() { // from class: com.ubtrobot.ubtlib.social.TencentUbtSocialImpl.1.1
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onCancel() {
|
||||
if (TencentUbtSocialImpl.this.a != null) {
|
||||
TencentUbtSocialImpl.this.a.onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onComplete(Object obj2) {
|
||||
JSONObject jSONObject2 = (JSONObject) obj2;
|
||||
try {
|
||||
hashMap.put("nick_name", jSONObject2.getString("nickname"));
|
||||
hashMap.put("head_image", jSONObject2.getString("figureurl"));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (TencentUbtSocialImpl.this.a != null) {
|
||||
TencentUbtSocialImpl.this.a.a(hashMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onError(UiError uiError) {
|
||||
String format = MessageFormat.format("errorCode: {0}, errorMessage: {1}, errorDetail: {2}", Integer.valueOf(uiError.a), uiError.b, uiError.c);
|
||||
if (TencentUbtSocialImpl.this.a != null) {
|
||||
TencentUbtSocialImpl.this.a.a(new Exception(format));
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
if (TencentUbtSocialImpl.this.a != null) {
|
||||
TencentUbtSocialImpl.this.a.a(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onError(UiError uiError) {
|
||||
String format = MessageFormat.format("errorCode: {0}, errorMessage: {1}, errorDetail: {2}", Integer.valueOf(uiError.a), uiError.b, uiError.c);
|
||||
if (TencentUbtSocialImpl.this.a != null) {
|
||||
TencentUbtSocialImpl.this.a.a(new Exception(format));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(int i, int i2, Intent intent) {
|
||||
Tencent.a(i, i2, intent, this.d);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a() {
|
||||
this.e.a(this.c, "all", this.d);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(ShareBuilder shareBuilder) {
|
||||
if (Thread.currentThread() == this.c.getMainLooper().getThread()) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("title", shareBuilder.d());
|
||||
bundle.putString(SocialConstants.PARAM_TARGET_URL, shareBuilder.e());
|
||||
this.d = new IUiListener() { // from class: com.ubtrobot.ubtlib.social.TencentUbtSocialImpl.2
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onCancel() {
|
||||
TencentUbtSocialImpl.this.b.onCancel();
|
||||
}
|
||||
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onComplete(Object obj) {
|
||||
TencentUbtSocialImpl.this.b.onSuccess();
|
||||
}
|
||||
|
||||
@Override // com.tencent.tauth.IUiListener
|
||||
public void onError(UiError uiError) {
|
||||
TencentUbtSocialImpl.this.b.a();
|
||||
}
|
||||
};
|
||||
int c = shareBuilder.c();
|
||||
if (c == 272) {
|
||||
this.e.a(this.c, bundle, this.d);
|
||||
return;
|
||||
} else {
|
||||
if (c == 273) {
|
||||
this.e.b(this.c, bundle, this.d);
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("share platform error, only support qq and qzone, current platform " + c);
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("没有在主线程调用!");
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialShareListener ubtSocialShareListener) {
|
||||
this.b = ubtSocialShareListener;
|
||||
}
|
||||
}
|
126
sources/com/ubtrobot/ubtlib/social/TwitterUbtSocialImpl.java
Normal file
126
sources/com/ubtrobot/ubtlib/social/TwitterUbtSocialImpl.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import com.facebook.AccessToken;
|
||||
import com.twitter.sdk.android.core.Callback;
|
||||
import com.twitter.sdk.android.core.Result;
|
||||
import com.twitter.sdk.android.core.TwitterAuthConfig;
|
||||
import com.twitter.sdk.android.core.TwitterCore;
|
||||
import com.twitter.sdk.android.core.TwitterException;
|
||||
import com.twitter.sdk.android.core.TwitterSession;
|
||||
import com.twitter.sdk.android.core.identity.TwitterAuthClient;
|
||||
import com.twitter.sdk.android.core.models.User;
|
||||
import com.twitter.sdk.android.tweetcomposer.TweetComposer;
|
||||
import com.ubtrobot.ubtlib.share.ShareBuilder;
|
||||
import com.ubtrobot.ubtlib.share.UbtSocialShareListener;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class TwitterUbtSocialImpl implements IUbtSocial {
|
||||
private UbtSocialAuthListener a;
|
||||
private Activity b;
|
||||
private TwitterAuthClient c;
|
||||
private Callback<TwitterSession> d;
|
||||
private String e;
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialShareListener ubtSocialShareListener) {
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(ShareBuilder shareBuilder) {
|
||||
TweetComposer.Builder builder = new TweetComposer.Builder(this.b);
|
||||
builder.a(shareBuilder.b());
|
||||
builder.a(shareBuilder.a());
|
||||
builder.d();
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public boolean b() {
|
||||
try {
|
||||
this.b.getPackageManager().getPackageInfo("com.twitter.android", 0);
|
||||
return true;
|
||||
} catch (PackageManager.NameNotFoundException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a() {
|
||||
try {
|
||||
this.c.a(this.b, this.d);
|
||||
} catch (Exception e) {
|
||||
UbtSocialAuthListener ubtSocialAuthListener = this.a;
|
||||
if (ubtSocialAuthListener != null) {
|
||||
ubtSocialAuthListener.a(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(Activity activity) {
|
||||
this.e = SocialTool.a((Context) activity, "app_id_twitter");
|
||||
Fabric.a(activity, new TwitterCore(new TwitterAuthConfig(this.e, SocialTool.a((Context) activity, "app_secret_twitter"))), new TweetComposer());
|
||||
this.b = activity;
|
||||
this.c = new TwitterAuthClient();
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(int i, int i2, Intent intent) {
|
||||
if (i2 == 0) {
|
||||
UbtSocialAuthListener ubtSocialAuthListener = this.a;
|
||||
if (ubtSocialAuthListener != null) {
|
||||
ubtSocialAuthListener.onCancel();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.c.a(i, i2, intent);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialAuthListener ubtSocialAuthListener) {
|
||||
this.a = ubtSocialAuthListener;
|
||||
this.d = new Callback<TwitterSession>() { // from class: com.ubtrobot.ubtlib.social.TwitterUbtSocialImpl.1
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(Result<TwitterSession> result) {
|
||||
final TwitterSession twitterSession = result.a;
|
||||
TwitterCore.z().p().a().verifyCredentials(false, false).enqueue(new Callback<User>() { // from class: com.ubtrobot.ubtlib.social.TwitterUbtSocialImpl.1.1
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(Result<User> result2) {
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put(AccessToken.ACCESS_TOKEN_KEY, twitterSession.a().token);
|
||||
hashMap.put("ubtsocial_user_id", twitterSession.c() + "");
|
||||
hashMap.put("ubtsocial_app_id", TwitterUbtSocialImpl.this.e);
|
||||
hashMap.put("social_type", UbtSocialType.TWITTER.loginType);
|
||||
User user = result2.a;
|
||||
String str = user.profileImageUrl;
|
||||
hashMap.put("nick_name", user.name);
|
||||
hashMap.put("head_image", str);
|
||||
if (TwitterUbtSocialImpl.this.a != null) {
|
||||
TwitterUbtSocialImpl.this.a.a(hashMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(TwitterException twitterException) {
|
||||
if (TwitterUbtSocialImpl.this.a != null) {
|
||||
TwitterUbtSocialImpl.this.a.a(twitterException);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.twitter.sdk.android.core.Callback
|
||||
public void a(TwitterException twitterException) {
|
||||
if (TwitterUbtSocialImpl.this.a != null) {
|
||||
TwitterUbtSocialImpl.this.a.a(twitterException);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
105
sources/com/ubtrobot/ubtlib/social/UbtSocial.java
Normal file
105
sources/com/ubtrobot/ubtlib/social/UbtSocial.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import com.ubtrobot.ubtlib.share.ShareBuilder;
|
||||
import com.ubtrobot.ubtlib.share.UbtSocialShareListener;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtSocial implements IUbtSocial {
|
||||
private static IUbtSocial a;
|
||||
private static UbtSocial b;
|
||||
|
||||
/* renamed from: com.ubtrobot.ubtlib.social.UbtSocial$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] a = new int[UbtSocialType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[UbtSocialType.QQ.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[UbtSocialType.WECHAT.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
a[UbtSocialType.TWITTER.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
a[UbtSocialType.FACEBOOK.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UbtSocial() {
|
||||
}
|
||||
|
||||
public static synchronized UbtSocial a(Activity activity, UbtSocialType ubtSocialType) {
|
||||
IUbtSocial tencentUbtSocialImpl;
|
||||
UbtSocial ubtSocial;
|
||||
synchronized (UbtSocial.class) {
|
||||
if (b == null) {
|
||||
b = new UbtSocial();
|
||||
}
|
||||
int i = AnonymousClass1.a[ubtSocialType.ordinal()];
|
||||
if (i == 1) {
|
||||
tencentUbtSocialImpl = new TencentUbtSocialImpl();
|
||||
tencentUbtSocialImpl.a(activity);
|
||||
} else if (i == 2) {
|
||||
tencentUbtSocialImpl = new WechatUbtSocialImpl();
|
||||
tencentUbtSocialImpl.a(activity);
|
||||
} else if (i == 3) {
|
||||
tencentUbtSocialImpl = new TwitterUbtSocialImpl();
|
||||
tencentUbtSocialImpl.a(activity);
|
||||
} else {
|
||||
if (i != 4) {
|
||||
throw new RuntimeException(MessageFormat.format("social type : {0} not support", ubtSocialType.toString()));
|
||||
}
|
||||
tencentUbtSocialImpl = new FacebookUbtSocialImpl();
|
||||
tencentUbtSocialImpl.a(activity);
|
||||
}
|
||||
a = tencentUbtSocialImpl;
|
||||
ubtSocial = b;
|
||||
}
|
||||
return ubtSocial;
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public boolean b() {
|
||||
return a.b();
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(ShareBuilder shareBuilder) {
|
||||
a.a(shareBuilder);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialShareListener ubtSocialShareListener) {
|
||||
a.a(ubtSocialShareListener);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a() {
|
||||
a.a();
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialAuthListener ubtSocialAuthListener) {
|
||||
a.a(ubtSocialAuthListener);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(Activity activity) {
|
||||
a.a(activity);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(int i, int i2, Intent intent) {
|
||||
a.a(i, i2, intent);
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface UbtSocialAuthListener {
|
||||
void a(Throwable th);
|
||||
|
||||
void a(Map<String, String> map);
|
||||
|
||||
void onCancel();
|
||||
}
|
24
sources/com/ubtrobot/ubtlib/social/UbtSocialService.java
Normal file
24
sources/com/ubtrobot/ubtlib/social/UbtSocialService.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import com.ubt.jimu.base.entities.Course;
|
||||
import com.ubtrobot.ubtlib.tool.NetRequestBaseService;
|
||||
import java.util.HashMap;
|
||||
import okhttp3.Callback;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtSocialService extends NetRequestBaseService {
|
||||
public static void a(String str, String str2, String str3, Callback callback) {
|
||||
Preconditions.a(str, "access_token_code == null");
|
||||
Preconditions.a(str2, "appId == null");
|
||||
Preconditions.a(str3, "appSecret == null");
|
||||
Preconditions.a(callback, "callback == null");
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put(SocialConstants.PARAM_APP_ID, str2);
|
||||
hashMap.put("secret", str3);
|
||||
hashMap.put(Course.TYPE_BLOCKLY, str);
|
||||
hashMap.put("grant_type", "authorization_code");
|
||||
NetRequestBaseService.a.newCall(NetRequestBaseService.a("https://api.weixin.qq.com/sns/oauth2/access_token", hashMap)).enqueue(callback);
|
||||
}
|
||||
}
|
16
sources/com/ubtrobot/ubtlib/social/UbtSocialType.java
Normal file
16
sources/com/ubtrobot/ubtlib/social/UbtSocialType.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum UbtSocialType {
|
||||
SINA_WEIBO("sina"),
|
||||
QQ("QQ"),
|
||||
WECHAT("WX"),
|
||||
FACEBOOK("facebook"),
|
||||
TWITTER("twitter");
|
||||
|
||||
public String loginType;
|
||||
|
||||
UbtSocialType(String str) {
|
||||
this.loginType = str;
|
||||
}
|
||||
}
|
123
sources/com/ubtrobot/ubtlib/social/WeChatCallbackActivity.java
Normal file
123
sources/com/ubtrobot/ubtlib/social/WeChatCallbackActivity.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import com.facebook.AccessToken;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import com.ubtrobot.ubtlib.share.UbtSocialShareListener;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WeChatCallbackActivity extends Activity implements IWXAPIEventHandler {
|
||||
private static final String d = WeChatCallbackActivity.class.getSimpleName();
|
||||
private IWXAPI a;
|
||||
private String b;
|
||||
private String c;
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
this.b = SocialTool.a((Context) this, "app_id_wechat");
|
||||
this.c = SocialTool.a((Context) this, "app_secret_wechat");
|
||||
this.a = WXAPIFactory.createWXAPI(this, this.b);
|
||||
this.a.handleIntent(getIntent(), this);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
setIntent(intent);
|
||||
this.a.handleIntent(intent, this);
|
||||
}
|
||||
|
||||
@Override // com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
|
||||
public void onReq(BaseReq baseReq) {
|
||||
}
|
||||
|
||||
@Override // com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
|
||||
public void onResp(BaseResp baseResp) {
|
||||
Log.d(d, SocialTool.a(baseResp));
|
||||
if (baseResp instanceof SendAuth.Resp) {
|
||||
a((SendAuth.Resp) baseResp);
|
||||
} else if (baseResp instanceof SendMessageToWX.Resp) {
|
||||
a((SendMessageToWX.Resp) baseResp);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void a(SendMessageToWX.Resp resp) {
|
||||
Log.d(d, SocialTool.a(resp));
|
||||
UbtSocialShareListener b = SocialTool.b();
|
||||
int i = resp.errCode;
|
||||
if (i == -2) {
|
||||
b.onCancel();
|
||||
} else if (i != 0) {
|
||||
b.a();
|
||||
} else {
|
||||
b.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
private void a(final SendAuth.Resp resp) {
|
||||
Log.d(d, SocialTool.a(resp));
|
||||
final UbtSocialAuthListener a = SocialTool.a();
|
||||
int i = resp.errCode;
|
||||
if (i == -2) {
|
||||
if (a != null) {
|
||||
a.onCancel();
|
||||
}
|
||||
} else if (i == 0) {
|
||||
UbtSocialService.a(resp.code, this.b, this.c, new Callback() { // from class: com.ubtrobot.ubtlib.social.WeChatCallbackActivity.1
|
||||
@Override // okhttp3.Callback
|
||||
public void onFailure(Call call, IOException iOException) {
|
||||
UbtSocialAuthListener ubtSocialAuthListener = a;
|
||||
if (ubtSocialAuthListener != null) {
|
||||
ubtSocialAuthListener.a(iOException);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // okhttp3.Callback
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String string = response.body().string();
|
||||
Log.d(WeChatCallbackActivity.d, string);
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(string);
|
||||
if (!jSONObject.has("errcode")) {
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put(AccessToken.ACCESS_TOKEN_KEY, jSONObject.getString(AccessToken.ACCESS_TOKEN_KEY));
|
||||
hashMap.put("ubtsocial_user_id", jSONObject.getString(SocialConstants.PARAM_OPEN_ID));
|
||||
hashMap.put("access_token_code", resp.code);
|
||||
hashMap.put("social_type", UbtSocialType.WECHAT.loginType);
|
||||
hashMap.put("ubtsocial_app_id", WeChatCallbackActivity.this.b);
|
||||
if (a != null) {
|
||||
a.a(hashMap);
|
||||
}
|
||||
} else if (a != null) {
|
||||
a.a(new Exception(string));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (a != null) {
|
||||
a.a(new Exception("errcode: " + resp.errCode));
|
||||
}
|
||||
}
|
||||
}
|
82
sources/com/ubtrobot/ubtlib/social/WechatUbtSocialImpl.java
Normal file
82
sources/com/ubtrobot/ubtlib/social/WechatUbtSocialImpl.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package com.ubtrobot.ubtlib.social;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.ubtrobot.ubtlib.share.ShareBuilder;
|
||||
import com.ubtrobot.ubtlib.share.UbtSocialShareListener;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WechatUbtSocialImpl implements IUbtSocial {
|
||||
private IWXAPI a;
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a() {
|
||||
SendAuth.Req req = new SendAuth.Req();
|
||||
req.scope = "snsapi_userinfo";
|
||||
req.state = "ubt_technology_jimu";
|
||||
this.a.sendReq(req);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public boolean b() {
|
||||
return this.a.isWXAppInstalled();
|
||||
}
|
||||
|
||||
private SendMessageToWX.Req b(ShareBuilder shareBuilder) {
|
||||
WXWebpageObject wXWebpageObject = new WXWebpageObject();
|
||||
wXWebpageObject.webpageUrl = shareBuilder.e();
|
||||
WXMediaMessage wXMediaMessage = new WXMediaMessage(wXWebpageObject);
|
||||
wXMediaMessage.title = shareBuilder.d();
|
||||
wXMediaMessage.description = shareBuilder.b();
|
||||
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
req.message = wXMediaMessage;
|
||||
req.transaction = System.currentTimeMillis() + "";
|
||||
return req;
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(Activity activity) {
|
||||
String a = SocialTool.a((Context) activity, "app_id_wechat");
|
||||
this.a = WXAPIFactory.createWXAPI(activity, a);
|
||||
if (!this.a.registerApp(a)) {
|
||||
throw new RuntimeException("register app id to wechat failed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(int i, int i2, Intent intent) {
|
||||
Log.e("xxxx", "");
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialAuthListener ubtSocialAuthListener) {
|
||||
SocialTool.a(ubtSocialAuthListener);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(ShareBuilder shareBuilder) {
|
||||
int c = shareBuilder.c();
|
||||
SendMessageToWX.Req b = b(shareBuilder);
|
||||
if (c == 274) {
|
||||
b.scene = 0;
|
||||
} else if (c == 275) {
|
||||
b.scene = 1;
|
||||
} else {
|
||||
throw new IllegalArgumentException("share platform error, only support wechat, current platform " + c);
|
||||
}
|
||||
this.a.sendReq(b);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.ubtlib.social.IUbtSocial
|
||||
public void a(UbtSocialShareListener ubtSocialShareListener) {
|
||||
SocialTool.a(ubtSocialShareListener);
|
||||
}
|
||||
}
|
11
sources/com/ubtrobot/ubtlib/stat/UbtStats.java
Normal file
11
sources/com/ubtrobot/ubtlib/stat/UbtStats.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.ubtrobot.ubtlib.stat;
|
||||
|
||||
import android.content.Context;
|
||||
import com.twitter.sdk.android.core.TwitterAuthConfig;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UbtStats {
|
||||
public static void a(Context context, boolean z) {
|
||||
new TwitterAuthConfig("N2p0rr7ID2I9cdlsRdp24yNwx", "W9msoV4Og7smvxy6XyWyvuC6uQXQ08XzlRxJYZtH3QMtjSo61X");
|
||||
}
|
||||
}
|
40
sources/com/ubtrobot/ubtlib/tool/NetRequestBaseService.java
Normal file
40
sources/com/ubtrobot/ubtlib/tool/NetRequestBaseService.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.ubtrobot.ubtlib.tool;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class NetRequestBaseService {
|
||||
protected static OkHttpClient a;
|
||||
protected static final Interceptor b;
|
||||
|
||||
static {
|
||||
MediaType.parse("application/json;charset=utf-8");
|
||||
b = new Interceptor() { // from class: com.ubtrobot.ubtlib.tool.NetRequestBaseService.1
|
||||
@Override // okhttp3.Interceptor
|
||||
public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
Log.d("UbtSocial", String.format("Sending request %s on %s%n%s", request.url(), chain.connection(), request.headers()));
|
||||
return chain.proceed(request);
|
||||
}
|
||||
};
|
||||
a = new OkHttpClient.Builder().addInterceptor(b).build();
|
||||
}
|
||||
|
||||
public static Request a(String str, Map<String, String> map) {
|
||||
Preconditions.a(str, "url == null");
|
||||
Uri.Builder buildUpon = Uri.parse(str).buildUpon();
|
||||
for (String str2 : map.keySet()) {
|
||||
buildUpon.appendQueryParameter(str2, map.get(str2));
|
||||
}
|
||||
return new Request.Builder().url(buildUpon.build().toString()).build();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user