diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9236ab..b597391 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,56 @@
# Changelog
+
+## v3.5.1 Latest 2021/12/08
+### TapAchievement
+#### Optimization and fixed bugs
+- 修复读取服务器数据时已达成字段无法解析的问题
+### AntiAddiction
+#### Optimization and fixe bugs
+- 防沉迷服务端异常时增加兼容处理
+- 切换账号可隐藏
+- 更新切换账号的回调 code (1000 -> 1001)
+
+## v3.5.0 2021/11/30
+### TapRTC
+####New Feature
+- 新增 RTC(实时语音) 模块
+- TapFriends
+- Optimization and fixed bugs
+- 根据好友码查找好友
+- 根据好友码添加好友
+- 查询第三方好友列表
+- 关注 TapTap 好友
+### TapAchievement
+#### Optimization and fixed bugs
+- 修复读取本地数据已达成成就识别成未达成的问题
+### TapLogin
+#### Optimization and fixed bugs
+- 内嵌 web 登录页面支持异形刘海屏的正常展示
+### TapDB
+#### Optimization and fixed bugs
+- 上报新增 soc 相关参数
+### TapMoment
+#### Optimization and fixed bugs
+- 依赖更新
+### TapCommon
+#### Optimization and fixed bugs
+- 支持性更新
+
+## v3.3.2 2021/11/11
+### TapDB
+#### Optimization and fixed bugs
+- 更新一些内部字段
+### AntiAddiction
+#### Optimization and fixed bugs
+- Api 增加公用参数
+
+## v3.3.1 2021/10/25
+### TapFriends
+#### New Feature
+- 好友新增多语言支持
+#### Optimization and fixed bugs
+- 从分享页跳转到应用内且发送好友申请时,从提示改为回调。
+
## TapSDK v3.0.0 2021/07/16
Tips: 当前版本不支持 v2.x 升级
### TapBootstrap
diff --git a/README.md b/README.md
index 1b54dd9..e4a4a72 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,10 @@
-## TapSDK - 3.1.0 For Android Demo;
+## TapSDK - 3.5.1 For Android Demo;
## 运行示例程序
该示例程序成功运行打包体验的前提条件
1、已经在Tap开发者中心注册应用并获取登陆、内嵌动态等相关权限;将得到的「Client ID」和「Client Token」以及「Server URL」填入 MainActivity 中 TapSDK 初始化所需的参数;
+如果你使用的不是「内建账户」方式登陆,而是采用的 TapTap 单独授权方式,则不需要配置 ServerUrl 自定义域名参数;
-2、配置自己的签名信息,签名打包测试;
-
-3、可以下载项目中的 apk-release.apk 先体验;(好友功能不便测试,因为好友申请需要好友登陆后的 userID,而我们无法提前得知体验者登陆后的userID,可以将 Demo 工程下载后更改里面的参数测试好友功能)
-
\ No newline at end of file
+2、配置自己的签名信息,签名打包测试;
\ No newline at end of file
diff --git a/app-release.apk b/app-release.apk
deleted file mode 100644
index 3cb3bdf..0000000
Binary files a/app-release.apk and /dev/null differ
diff --git a/app/.DS_Store b/app/.DS_Store
deleted file mode 100644
index 643180e..0000000
Binary files a/app/.DS_Store and /dev/null differ
diff --git a/app/build.gradle b/app/build.gradle
index 4db2011..a838b75 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,6 +6,8 @@ android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
+
+
defaultConfig {
applicationId "com.tds.demo"
minSdkVersion 21
@@ -16,11 +18,22 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
+
+// ndk{
+// abiFilters "arm64-v8a, x86_64"
+// }
+
+// ndk.abiFilters("arm64-v8a, x86_64")
}
+
buildTypes {
release {
- minifyEnabled false
+ minifyEnabled true
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ debug {
+ minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
@@ -44,14 +57,16 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
- implementation name: 'TapBootStrap_3.1.0', ext: 'aar' // 必选: x.x.x 代表所下载的 SDK的版本号
- implementation(name: 'TapCommon_3.1.0', ext: 'aar')
- implementation(name: 'TapMoment_3.1.0', ext: 'aar')
- implementation(name: 'TapLogin_3.1.0', ext: 'aar')
- implementation(name: 'TapLicense_3.1.0', ext: 'aar')
- implementation(name: 'TapAchievement_3.1.0', ext: 'aar')
- implementation(name: 'TapDB_3.1.0', ext: 'aar')
- implementation 'cn.leancloud:realtime-android:8.0.4'
- implementation 'cn.leancloud:storage-android:8.0.4'
+ implementation name: 'TapBootStrap_3.5.1', ext: 'aar' // 必选: x.x.x 代表所下载的 SDK的版本号
+ implementation(name: 'TapCommon_3.5.1', ext: 'aar')
+ implementation(name: 'TapMoment_3.5.1', ext: 'aar')
+ implementation(name: 'TapLogin_3.5.1', ext: 'aar')
+ implementation(name: 'TapLicense_3.5.1', ext: 'aar')
+ implementation(name: 'TapAchievement_3.5.1', ext: 'aar')
+ implementation(name: 'TapDB_3.5.1', ext: 'aar')
+ implementation(name: 'AntiAddiction_1.0.2', ext: 'aar')
+ implementation(name: 'AntiAddictionUI_1.0.2', ext: 'aar')
+ implementation 'cn.leancloud:realtime-android:8.1.0'
+ implementation 'cn.leancloud:storage-android:8.1.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
}
\ No newline at end of file
diff --git a/app/libs/AntiAddictionUI_1.0.2.aar b/app/libs/AntiAddictionUI_1.0.2.aar
new file mode 100644
index 0000000..734026c
Binary files /dev/null and b/app/libs/AntiAddictionUI_1.0.2.aar differ
diff --git a/app/libs/AntiAddiction_1.0.2.aar b/app/libs/AntiAddiction_1.0.2.aar
new file mode 100644
index 0000000..ae00d66
Binary files /dev/null and b/app/libs/AntiAddiction_1.0.2.aar differ
diff --git a/app/libs/TapAchievement_3.1.0.aar b/app/libs/TapAchievement_3.1.0.aar
deleted file mode 100644
index 8d7a7d5..0000000
Binary files a/app/libs/TapAchievement_3.1.0.aar and /dev/null differ
diff --git a/app/libs/TapAchievement_3.5.1.aar b/app/libs/TapAchievement_3.5.1.aar
new file mode 100644
index 0000000..3f54113
Binary files /dev/null and b/app/libs/TapAchievement_3.5.1.aar differ
diff --git a/app/libs/TapBootstrap_3.1.0.aar b/app/libs/TapBootstrap_3.1.0.aar
deleted file mode 100644
index 0c9cf30..0000000
Binary files a/app/libs/TapBootstrap_3.1.0.aar and /dev/null differ
diff --git a/app/libs/TapBootstrap_3.5.1.aar b/app/libs/TapBootstrap_3.5.1.aar
new file mode 100644
index 0000000..006974c
Binary files /dev/null and b/app/libs/TapBootstrap_3.5.1.aar differ
diff --git a/app/libs/TapCommon_3.1.0.aar b/app/libs/TapCommon_3.1.0.aar
deleted file mode 100644
index fd1d7a4..0000000
Binary files a/app/libs/TapCommon_3.1.0.aar and /dev/null differ
diff --git a/app/libs/TapCommon_3.5.1.aar b/app/libs/TapCommon_3.5.1.aar
new file mode 100644
index 0000000..0faef0e
Binary files /dev/null and b/app/libs/TapCommon_3.5.1.aar differ
diff --git a/app/libs/TapDB_3.1.0.aar b/app/libs/TapDB_3.1.0.aar
deleted file mode 100644
index b64d6f2..0000000
Binary files a/app/libs/TapDB_3.1.0.aar and /dev/null differ
diff --git a/app/libs/TapDB_3.5.1.aar b/app/libs/TapDB_3.5.1.aar
new file mode 100644
index 0000000..c5692fb
Binary files /dev/null and b/app/libs/TapDB_3.5.1.aar differ
diff --git a/app/libs/TapFriend_3.5.1.aar b/app/libs/TapFriend_3.5.1.aar
new file mode 100644
index 0000000..e630c9a
Binary files /dev/null and b/app/libs/TapFriend_3.5.1.aar differ
diff --git a/app/libs/TapLicense_3.1.0.aar b/app/libs/TapLicense_3.1.0.aar
deleted file mode 100644
index fcacf04..0000000
Binary files a/app/libs/TapLicense_3.1.0.aar and /dev/null differ
diff --git a/app/libs/TapLicense_3.5.1.aar b/app/libs/TapLicense_3.5.1.aar
new file mode 100644
index 0000000..eeda63f
Binary files /dev/null and b/app/libs/TapLicense_3.5.1.aar differ
diff --git a/app/libs/TapLogin_3.1.0.aar b/app/libs/TapLogin_3.1.0.aar
deleted file mode 100644
index 0719dba..0000000
Binary files a/app/libs/TapLogin_3.1.0.aar and /dev/null differ
diff --git a/app/libs/TapLogin_3.5.1.aar b/app/libs/TapLogin_3.5.1.aar
new file mode 100644
index 0000000..a67c28c
Binary files /dev/null and b/app/libs/TapLogin_3.5.1.aar differ
diff --git a/app/libs/TapMoment_3.1.0.aar b/app/libs/TapMoment_3.5.1.aar
similarity index 93%
rename from app/libs/TapMoment_3.1.0.aar
rename to app/libs/TapMoment_3.5.1.aar
index b3392c4..1c7b8a6 100644
Binary files a/app/libs/TapMoment_3.1.0.aar and b/app/libs/TapMoment_3.5.1.aar differ
diff --git a/app/libs/TapSupport_3.5.1.aar b/app/libs/TapSupport_3.5.1.aar
new file mode 100644
index 0000000..0016b0b
Binary files /dev/null and b/app/libs/TapSupport_3.5.1.aar differ
diff --git a/app/libs/gson-2.8.6.jar b/app/libs/gson-2.8.6.jar
new file mode 100644
index 0000000..4765c4a
Binary files /dev/null and b/app/libs/gson-2.8.6.jar differ
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index 481bb43..d206c15 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -18,4 +18,39 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
-#-renamesourcefileattribute SourceFile
\ No newline at end of file
+#-renamesourcefileattribute SourceFile
+-keep class com.tds.** { *;}
+-keep class tds.androidx.** { *;}
+-keep class com.taptap.** { *;}
+-keep class com.tapsdk.** { *;}
+#-keep class cn.leancloud.** { *;}
+# proguard.cfg
+-keepattributes Signature
+-dontwarn com.jcraft.jzlib.**
+-keep class com.jcraft.jzlib.** { *;}
+-dontwarn sun.misc.**
+-keep class sun.misc.** { *;}
+-dontwarn retrofit2.**
+-keep class retrofit2.** { *;}
+-dontwarn io.reactivex.**
+-keep class io.reactivex.** { *;}
+-dontwarn sun.security.**
+-keep class sun.security.** { *; }
+-dontwarn com.google.**
+-keep class com.google.** { *;}
+-dontwarn cn.leancloud.**
+-keep class cn.leancloud.** { *;}
+-keep public class android.net.http.SslError
+-keep public class android.webkit.WebViewClient
+-dontwarn android.webkit.WebView
+-dontwarn android.net.http.SslError
+-dontwarn android.webkit.WebViewClient
+-dontwarn android.support.**
+-dontwarn org.apache.**
+-keep class org.apache.** { *;}
+-dontwarn okhttp3.**
+-keep class okhttp3.** { *;}
+-keep interface okhttp3.** { *; }
+-dontwarn okio.**
+-keep class okio.** { *;}
+-keepattributes *Annotation*
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4bb2c1a..bcf9606 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
package="com.example.tapsdk_android_demo">
+
currentUserLcFriendshipRequests = new ArrayList<>();
// 删除好友接口使用
LCFriendship queriedUserLCFriendship = null;
+ // 云存档示例
+ TapGameSave gameSave;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -100,12 +154,29 @@ protected void onCreate(Bundle savedInstanceState) {
private void initView() {
// 初始化按钮
- // 登陆相关
+ // 内建账户方式登陆相关
btTapLogin = findViewById(R.id.btn_tap_login);
btTapLoginStatus = findViewById(R.id.btn_tap_loginstatus);
btTapGouhuo = findViewById(R.id.btn_tap_gouhuo);
btTapLogout = findViewById(R.id.btn_tap_logout);
btTapLicense = findViewById(R.id.btn_tap_license);
+ btTapInitOnly = findViewById(R.id.btn_tap_init_only);
+ btTapBinding = findViewById(R.id.btn_tap_binding);
+ btTapBindingAgain = findViewById(R.id.btn_tap_binding_again);
+ btTapThirdLogin = findViewById(R.id.btn_tap_thirdLogin);
+ btTapThirdLoginAgain = findViewById(R.id.btn_tap_thirdLogin_Again);
+ // TapTap 单独登陆
+ btTapLoginOnly = findViewById(R.id.btn_tap_login_only);
+ btTapLoginStatusOnly = findViewById(R.id.btn_tap_loginstatus_only);
+ btTapLogoutOnly = findViewById(R.id.btn_tap_logout_only);
+
+ // 防沉迷
+ btAntiAddictionInit = findViewById(R.id.btn_tap_antiaddiction_init);
+ btAntiAddictionTapLogin = findViewById(R.id.btn_tap_antiaddiction_taplogin);
+ btAntiAddictionManual = findViewById(R.id.btn_tap_antiaddiction_manual);
+ btAntiAddictionAgeRange = findViewById(R.id.btn_tap_antiaddiction_agerange);
+ btAntiAddictionLogout = findViewById(R.id.btn_tap_antiaddiction_logout);
+
// 内嵌动态相关
btTapFetchNotification = findViewById(R.id.btn_tap_fetch_notification);
btTapOpenMoment = findViewById(R.id.btn_tap_open_moment);
@@ -131,13 +202,40 @@ private void initView() {
btFGrowAchievement = findViewById(R.id.btn_tap_achieve_grow);
btSwitchToastAchievement = findViewById(R.id.btn_tap_achieve_toast);
btShowAchievement = findViewById(R.id.btn_tap_achieve_open);
+ // 云存档相关
+ btSnapchatCreatsc = findViewById(R.id.btn_tap_snapchat_creatsc);
+ btSnapchatSavesc = findViewById(R.id.btn_tap_snapchat_savesc);
+ btSnapchatQueryCurrentUserAll = findViewById(R.id.btn_tap_snapchat_current_user);
+ btSnapchatQueryByConditon = findViewById(R.id.btn_tap_snapchat_current_user_condition);
+
+ // 排行榜
+ btRankingListSubmitAchievement = findViewById(R.id.btn_tap_rankinglist_submit_achievement);
+ btRankingListGetRank = findViewById(R.id.btn_tap_rankinglist_get_rank);
+ btRankingListUpdateStatistic = findViewById(R.id.btn_tap_rankinglist_update_statistic);
+ btRankingListGetUserStatistic = findViewById(R.id.btn_tap_rankinglist_get_user_statistic);
+ btRankingListGetResults = findViewById(R.id.btn_tap_rankinglist_get_results);
+
// 注册监听器
btTapLogin.setOnClickListener(this);
+ btTapLoginOnly.setOnClickListener(this);
btTapLoginStatus.setOnClickListener(this);
+ btTapLoginStatusOnly.setOnClickListener(this);
btTapGouhuo.setOnClickListener(this);
btTapLogout.setOnClickListener(this);
+ btTapLogoutOnly.setOnClickListener(this);
btTapLicense.setOnClickListener(this);
+ btTapInitOnly.setOnClickListener(this);
+ btTapBinding.setOnClickListener(this);
+ btTapBindingAgain.setOnClickListener(this);
+ btTapThirdLogin.setOnClickListener(this);
+ btTapThirdLoginAgain.setOnClickListener(this);
+ // 防沉迷
+ btAntiAddictionInit.setOnClickListener(this);
+ btAntiAddictionTapLogin.setOnClickListener(this);
+ btAntiAddictionManual.setOnClickListener(this);
+ btAntiAddictionAgeRange.setOnClickListener(this);
+ btAntiAddictionLogout.setOnClickListener(this);
// 内嵌动态相关
btTapFetchNotification.setOnClickListener(this);
btTapOpenMoment.setOnClickListener(this);
@@ -166,12 +264,29 @@ private void initView() {
btSwitchToastAchievement.setOnClickListener(this);
btShowAchievement.setOnClickListener(this);
+ // 云存档相关
+ btSnapchatCreatsc.setOnClickListener(this);
+ btSnapchatSavesc.setOnClickListener(this);
+ btSnapchatQueryCurrentUserAll.setOnClickListener(this);
+ btSnapchatQueryByConditon.setOnClickListener(this);
+
+ // 排行榜
+ btRankingListSubmitAchievement.setOnClickListener(this);
+ btRankingListGetRank.setOnClickListener(this);
+ btRankingListUpdateStatistic.setOnClickListener(this);
+ btRankingListGetUserStatistic.setOnClickListener(this);
+ btRankingListGetResults.setOnClickListener(this);
+
+
}
/*
* TapSDK 初始化,TapDB初始化,内嵌动态初始化
* */
public void initSDK() {
+ LeanCloud.setLogLevel(LCLogger.Level.DEBUG);
+ WebView.setWebContentsDebuggingEnabled(true);
+ // 内建账户方式登陆 SDK 初始化
// TapDB 初始化
TapDBConfig tapDBConfig = new TapDBConfig();
tapDBConfig.setEnable(true);
@@ -181,9 +296,11 @@ public void initSDK() {
TapConfig tapConfig = new TapConfig.Builder()
.withAppContext(getApplicationContext())
.withRegionType(TapRegionType.CN) // TapRegionType.CN: 国内 TapRegionType.IO: 国外
- .withClientId("0RiAlMny7jiz086FaU")
- .withClientToken("8V8wemqkpkxmAN7qKhvlh6v0pXc8JJzEZe3JFUnU")
- .withServerUrl("https://0rialmny.cloud.tds1.tapapis.cn")
+ // 自己账号 - 知恩
+ .withClientId("**** Yourself ClientID From TapDC ****")
+ .withClientToken("****** Yourself ClientToken From TapDC ******")
+ /* 如果使用 单独 TapTap 授权,则不需要配置自定义域名 */
+ .withServerUrl("****** Yourself ServerUrl From TapDC ******")
.withTapDBConfig(tapDBConfig)
.build();
TapBootstrap.init(MainActivity.this, tapConfig);
@@ -196,10 +313,16 @@ public void onCallback(int code, String msg) {
// 获取用户新消息成功
Toast.makeText(MainActivity.this, "获取新通知数据为: " + msg, Toast.LENGTH_SHORT).show();
}
+ if(code == TapMoment.CALLBACK_CODE_LOGIN_SUCCESS){
+ // 动态内登陆成功
+ Toast.makeText(MainActivity.this, "动态内登陆成功: " + msg, Toast.LENGTH_SHORT).show();
+ }
+ if(code == TapMoment.CALLBACK_CODE_PUBLISH_SUCCESS){
+ // 动态发布成功
+ Toast.makeText(MainActivity.this, "动态发布成功: " + msg, Toast.LENGTH_SHORT).show();
+ }
}
});
-
-
}
@Override
@@ -225,6 +348,59 @@ public void onClick(View v) {
// 付费验证
taptapLicense();
break;
+ case R.id.btn_tap_binding:
+ // 绑定
+ taptapBinding();
+ break;
+ case R.id.btn_tap_binding_again:
+ // 再次绑定
+ taptapBindingAgain();
+ break;
+ case R.id.btn_tap_thirdLogin:
+ // 第三方登陆
+ taptapThirdLogin();
+ break;
+ case R.id.btn_tap_thirdLogin_Again:
+ // 第三方登陆 Again
+ taptapThirdLoginAgain();
+ break;
+ case R.id.btn_tap_init_only:
+ // TapTap 单独 登陆功能
+ taptapInitOnly();
+ break;
+ case R.id.btn_tap_login_only:
+ // TapTap 单独 登陆功能
+ taptapLoginOnly();
+ break;
+ case R.id.btn_tap_loginstatus_only:
+ // TapTap 单独 登陆状态
+ taptapLoginStatusOnly();
+ break;
+ case R.id.btn_tap_logout_only:
+ // TapTap 单独 登出功能
+ taptapLogoutOnly();
+ break;
+ // 防沉迷
+ case R.id.btn_tap_antiaddiction_init:
+ // 防沉迷初始化
+ taptapAntiAddictionInit();
+ break;
+ case R.id.btn_tap_antiaddiction_taplogin:
+ // 防沉迷 TapLogin
+ taptapAntiAddictionTapLogin();
+ break;
+ case R.id.btn_tap_antiaddiction_manual:
+ // 防沉迷手动实名
+ taptapAntiAddictionManual();
+ break;
+ case R.id.btn_tap_antiaddiction_agerange:
+ // 防沉迷年龄段查询
+ taptapAntiAddictionAgeRange();
+ break;
+ case R.id.btn_tap_antiaddiction_logout:
+ // 防沉迷登出功能
+ taptapAntiAddictionLogout();
+ break;
case R.id.btn_tap_fetch_notification:
// 获取新消息
taptapFetchNotification();
@@ -313,7 +489,556 @@ public void onClick(View v) {
// 打开成就展示页
taptapShowAchieve();
break;
+ case R.id.btn_tap_snapchat_creatsc:
+ // 构建云存档数据
+ taptapSnapshotCreated();
+ break;
+ case R.id.btn_tap_snapchat_savesc:
+ // 保存存档
+ taptapSnapshotSave();
+ break;
+ case R.id.btn_tap_snapchat_current_user:
+ // 查询当前用户的所有存档
+ taptapSnapshotQueryCurrentAll();
+ break;
+ case R.id.btn_tap_snapchat_current_user_condition:
+ // 根据条件查询当前用户存档
+ taptapSnapshotQueryByconditon();
+ break;
+ case R.id.btn_tap_rankinglist_submit_achievement:
+ // 提交成绩
+ taptapSubmitAchievement();
+ break;
+ case R.id.btn_tap_rankinglist_get_rank:
+ // 获取名次
+ taptapGetRank();
+ break;
+ case R.id.btn_tap_rankinglist_update_statistic:
+ // 更新用户信息
+ taptapUpdateStatistic();
+ break;
+ case R.id.btn_tap_rankinglist_get_user_statistic:
+ // 查询排行榜成员成绩
+ taptapGetUserStatistic();
+ break;
+ case R.id.btn_tap_rankinglist_get_results:
+ // 获取指定区间的排名(Top 10)
+ taptapRankingListGetResults();
+ break;
+
+
+ }
+ }
+
+ private void taptapAntiAddictionLogout() {
+ AntiAddictionUIKit.logout();
+ }
+
+ private void taptapAntiAddictionAgeRange() {
+ int ageRange = AntiAddictionKit.currentUserAgeLimit();
+ Log.d(TAG, "玩家段年龄段是:" + String.valueOf(ageRange));
+ }
+
+ private void taptapAntiAddictionManual() {
+
+ String userIdentifier = "玩家的唯一标识NNNNNNNNYHHYWWTTAABC";
+ AntiAddictionUIKit.startup(MainActivity.this, false, userIdentifier, "");
+ }
+
+ private void taptapAntiAddictionTapLogin() {
+ AccessToken accessToken = TapLoginHelper.getCurrentAccessToken();
+// String tapTapAccessToken = accessToken.toJsonString();
+ boolean useTapLogin = true;
+ String userIdentifier = "玩家的唯一标识NNNNNNNNYHHYWWTTAABC";
+ String tapTapAccessToken = "TapTap 第三方登录的 access token";
+ AntiAddictionUIKit.startup(MainActivity.this, useTapLogin, userIdentifier, tapTapAccessToken);
+ }
+
+ private void taptapAntiAddictionInit() {
+ // Android SDK 的各接口第一个参数是当前 Activity,以下不再说明
+ String gameIdentifier = "6Rap5XF2ncLQB2oIiW";
+ AntiAddictionFunctionConfig config = new AntiAddictionFunctionConfig.Builder()
+ .enablePaymentLimit(true) // 是否启用消费限制功能
+ .enableOnLineTimeLimit(true) // 是否启用时长限制功能
+ .build();
+ AntiAddictionUIKit.init(MainActivity.this, gameIdentifier, config,
+ new AntiAddictionUICallback() {
+ @Override
+ public void onCallback(int code, Map extras) {
+ // 根据 code 不同提示玩家不同信息,详见下面的说明
+ if(null != extras){
+ Log.d(TAG, extras.toString());
+ Log.d(TAG, String.valueOf(code));
+ }
+ switch (code){
+ case Constants.ANTI_ADDICTION_CALLBACK_CODE.LOGIN_SUCCESS:
+// Log.d(TAG, extras.toString());
+ Log.d(TAG, "防沉迷登陆成功");
+ break;
+ case Constants.ANTI_ADDICTION_CALLBACK_CODE.LOGOUT:
+// Log.d(TAG, extras.toString());
+ Log.d(TAG, "防沉迷的登出");
+ break;
+ case Constants.ANTI_ADDICTION_CALLBACK_CODE.OPEN_ALERT_TIP:
+ Log.d(TAG, "防沉迷未成年允许游戏弹窗");
+ break;
+ case Constants.ANTI_ADDICTION_CALLBACK_CODE.NIGHT_STRICT:
+ Log.d(TAG, "防沉迷未成年玩家无法进行游戏");
+ break;
+ case Constants.ANTI_ADDICTION_CALLBACK_CODE.REAL_NAME_STOP:
+ Log.d(TAG, "防沉迷实名认证过程中点击了关闭实名窗");
+ break;
+ case Constants.ANTI_ADDICTION_CALLBACK_CODE.SWITCH_ACCOUNT:
+ Log.d(TAG, "防沉迷实名认证过程中点击了切换账号按钮");
+ break;
+ }
+ }
+ }
+ );
+ }
+
+ private void taptapThirdLogin() {
+ Map thirdPartyData = new HashMap();
+ // 必须
+ thirdPartyData.put("expires_in", 930516);
+ thirdPartyData.put("openid", "LeeJiEun_Giant_Openid");
+ thirdPartyData.put("access_token", "LeeJiEun_Giant_ACCESS_TOKEN");
+ // 可选
+ thirdPartyData.put("refresh_token", "LeeJiEun_Giant_REFRESH_TOKEN");
+ thirdPartyData.put("scope", "LeeJiEun_Giant_SCOPE");
+ TDSUser.loginWithAuthData(TDSUser.class, thirdPartyData, "giant").subscribe(new Observer() {
+ public void onSubscribe(Disposable disposable) {
+ }
+ public void onNext(TDSUser user) {
+ Log.d(TAG, "第三方登陆成功");
+ Log.d(TAG, user.toJSONString());
+ }
+ public void onError(Throwable throwable) {
+ Log.d(TAG, "尝试使用第三方账号登录,发生错误: " + throwable.getMessage());
+ }
+ public void onComplete() {
+ }
+ });
+ }
+
+ private void taptapThirdLoginAgain() {
+ Map thirdPartyData = new HashMap();
+ // 必须
+ thirdPartyData.put("expires_in", 19930516);
+ thirdPartyData.put("openid", "LeeJiEun_Giant_Openid_Again");
+ thirdPartyData.put("access_token", "LeeJiEun_Giant_ACCESS_TOKEN_Again");
+ // 可选
+ thirdPartyData.put("refresh_token", "LeeJiEun_Giant_REFRESH_TOKEN_Again");
+ thirdPartyData.put("scope", "LeeJiEun_Giant_SCOPE_Again");
+ TDSUser.loginWithAuthData(TDSUser.class, thirdPartyData, "taptap").subscribe(new Observer() {
+ public void onSubscribe(Disposable disposable) {
+ }
+ public void onNext(TDSUser user) {
+ Log.d(TAG, "第三方再次登陆成功");
+ Log.d(TAG, user.toJSONString());
+ }
+ public void onError(Throwable throwable) {
+ Log.d(TAG, "尝试使用第三方账号再次登录,发生错误: " + throwable.getMessage());
+ }
+ public void onComplete() {
+ }
+ });
+ }
+
+ private void taptapBinding() {
+ Map thirdPartyData = new HashMap();
+ // 必须
+ thirdPartyData.put("expires_in", 7200);
+ thirdPartyData.put("openid", "BANDINGpcb6jiHAjB82k8H9MjKkiQ==");
+ thirdPartyData.put("access_token", "BandingHAHAHAHAHA1/e3fyiwgwBGXeor93rQGfB_qfOpsArBYvze6W7zmV73zxKH1mpJUgehCWRbj0-c-ZrTlSV3qlAAaQW1C4tjJFlZjjxlvpJhGQ0JXHX7bfZwwKxiI8DJ0zu5XXOmE2LdwRXXMjbI0Syeuua5Ym5W2uK-JNfinO2jen6Sb7p_1GeJF-j3W_6nmYZPVJSP9BQap5b61zLOZ1c0r7-5t3d1Id-TeAj8Km78tj4rZ1QkLzgUFauRSxvHKMhkPOzW3LDVpMw3dns5B2Am_hw5ybgAOT0PDdVVRNe68DWz1JySB2G5ARPwDLonYwn13-_BoPl9ldaTK_ogF9chFmfLF_V5DFKg");
+ // 可选
+// thirdPartyData.put("expires_in", 7200);
+// thirdPartyData.put("openid", "QDNJfr2wFRRmFu8oqL2pCg==");
+// thirdPartyData.put("access_token", "1/B2sMNYgxvmuwNPg82IEuOZIAoT30WmB-L2FkHUxprcF39RCBTlFVKbcV_fHSMvSQMp5m_9cLnC78GzimhvGll4t8R0X5Vp_KAiTVk-JrnunHKYObD310JM5HikHz6YMaex9TPVaDtZV1jCFVZo1cUfDlCrpmm3o0urx_LZYqTamvDU_JnZTyunq7lD-2YI_LVekpqP5ZznhvcfyLA-r48lrwa1FuZM3cQygH5H_xvYTHHP1pPiPOPhzhZWJu7NP9Ya6ReNKPpMtAiFXnzokVhB1QKfcaPhYr9g60ogY6a3vii2Jn-hCWV61NqLFhGl3HoiWBmw7F1BQ4FnbbVidyHQ");
+ thirdPartyData.put("taptap_name", "lrj3zwhy01pr4ltbu4hiww2ba");
+// thirdPartyData.put("refresh_token", "TapTap_REFRESH_TOKEN");
+// thirdPartyData.put("scope", "TapTap_SCOPE");
+ TDSUser currentUser = TDSUser.getCurrentUser();
+ currentUser.associateWithAuthData(thirdPartyData, "taptap").subscribe(new Observer() {
+ @Override
+ public void onSubscribe(@androidx.annotation.NonNull Disposable d) {
+
+ }
+
+ @Override
+ public void onNext(@androidx.annotation.NonNull LCUser lcUser) {
+ Log.d(TAG, "绑定成功!");
+ Log.d(TAG, "绑定成功 TDSUserID : " + lcUser.getObjectId());
+
+ }
+
+ @Override
+ public void onError(@androidx.annotation.NonNull Throwable e) {
+ Log.d(TAG, "绑定失败: " + e.getMessage());
+ }
+
+ @Override
+ public void onComplete() {
+
+ }
+ });
+ }
+
+ private void taptapBindingAgain() {
+ Map thirdPartyData = new HashMap();
+ // 必须
+ thirdPartyData.put("expires_in", 7200);
+ thirdPartyData.put("openid", "WanWan_QDNJfr2wFRRmFu8oqL2pCg==");
+ thirdPartyData.put("access_token", "WanWan_1/B2sMNYgxvmuwNPg82IEuOZIAoT30WmB-L2FkHUxprcF39RCBTlFVKbcV_fHSMvSQMp5m_9cLnC78GzimhvGll4t8R0X5Vp_KAiTVk-JrnunHKYObD310JM5HikHz6YMaex9TPVaDtZV1jCFVZo1cUfDlCrpmm3o0urx_LZYqTamvDU_JnZTyunq7lD-2YI_LVekpqP5ZznhvcfyLA-r48lrwa1FuZM3cQygH5H_xvYTHHP1pPiPOPhzhZWJu7NP9Ya6ReNKPpMtAiFXnzokVhB1QKfcaPhYr9g60ogY6a3vii2Jn-hCWV61NqLFhGl3HoiWBmw7F1BQ4FnbbVidyHQ");
+ // 可选
+ thirdPartyData.put("refresh_token", "WanWan_TapTap_REFRESH_TOKEN");
+ thirdPartyData.put("scope", "WanWan_TapTap_SCOPE");
+ TDSUser currentUser = TDSUser.getCurrentUser();
+ currentUser.associateWithAuthData(thirdPartyData, "TapTap").subscribe(new Observer() {
+ @Override
+ public void onSubscribe(@androidx.annotation.NonNull Disposable d) {
+
+ }
+
+ @Override
+ public void onNext(@androidx.annotation.NonNull LCUser lcUser) {
+ Log.d(TAG, "再次绑定成功!");
+ Log.d(TAG, "再次绑定成功 TDSUserID : " + lcUser.getObjectId());
+
+ }
+
+ @Override
+ public void onError(@androidx.annotation.NonNull Throwable e) {
+ Log.d(TAG, "绑定失败: " + e.getMessage());
+ }
+
+ @Override
+ public void onComplete() {
+
+ }
+ });
+ }
+
+ private void taptapRankingListGetResults() {
+ // 获取指定区间的排名(Top 10)
+ LCLeaderboard leaderboard = LCLeaderboard.createWithoutData("Uaena");
+ leaderboard.getResults(0, 10, null, null).subscribe(new Observer() {
+ @Override
+ public void onSubscribe(@NotNull Disposable disposable) {}
+
+ @Override
+ public void onNext(@NotNull LCLeaderboardResult leaderboardResult) {
+ List rankings = leaderboardResult.getResults();
+ for (LCRanking lcr : rankings){
+ Log.d(TAG, lcr.toString());
+ }
+ }
+
+ @Override
+ public void onError(@NotNull Throwable throwable) {
+ // handle error
+ }
+
+ @Override
+ public void onComplete() {}
+ });
+ }
+
+ private void taptapGetUserStatistic() {
+ // 查询排行榜成员成绩
+ LCUser otherUser = null;
+ try {
+ otherUser = LCUser.createWithoutData(LCUser.class, LeeJiDongID);
+ } catch (LCException e) {
+ e.printStackTrace();
+ }
+ LCLeaderboard.getUserStatistics(otherUser).subscribe(new Observer() {
+ @Override
+ public void onSubscribe(@NotNull Disposable disposable) {}
+
+ @Override
+ public void onNext(@NotNull LCStatisticResult lcStatisticResult) {
+ List statistics = lcStatisticResult.getResults();
+ for (LCStatistic statistic : statistics) {
+ Log.d(TAG, statistic.getName());
+ Log.d(TAG, String.valueOf(statistic.getValue()));
+ }
+ }
+
+ @Override
+ public void onError(@NotNull Throwable throwable) {
+ // handle error
+ Toast.makeText(MainActivity.this, "查询失败: " + throwable.getMessage(), Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onComplete() {}
+ });
+ }
+
+ private void taptapUpdateStatistic() {
+ // 更新用户信息
+ TDSUser currentUser = TDSUser.getCurrentUser();
+ if (null == currentUser){
+ Toast.makeText(MainActivity.this, "请先执行 TapTap 登陆", Toast.LENGTH_SHORT).show();
+ return;
+ }
+ Map statistic = new HashMap<>();
+ statistic.put("score", 3458.0);
+ statistic.put("kills", 28.0);
+ LCLeaderboard.updateStatistic(currentUser, statistic).subscribe(new Observer() {
+ @Override
+ public void onSubscribe(@NotNull Disposable disposable) {}
+
+ @Override
+ public void onNext(@NotNull LCStatisticResult jsonObject) {
+ // saved
+ Toast.makeText(MainActivity.this, "更新成功!", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onError(@NotNull Throwable throwable) {
+ // handle error
+ Toast.makeText(MainActivity.this, "更新失败: " + throwable.getMessage(), Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onComplete() {}
+ });
+ }
+
+ private void taptapGetRank() {
+ // 获取名次
+ LCLeaderboard leaderboard = LCLeaderboard.createWithoutData("world");
+ leaderboard.getResults(0, 10, null, null).subscribe(new Observer() {
+ @Override
+ public void onSubscribe(@NotNull Disposable disposable) {}
+
+ @Override
+ public void onNext(@NotNull LCLeaderboardResult leaderboardResult) {
+ List rankings = leaderboardResult.getResults();
+ // process rankings
+ for (LCRanking lr : rankings){
+ Log.d(TAG, String.valueOf(lr.getRank()));
+ }
+ }
+
+ @Override
+ public void onError(@NotNull Throwable throwable) {
+ // handle error
+ }
+
+ @Override
+ public void onComplete() {}
+ });
+ }
+
+ private void taptapSubmitAchievement() {
+ // 提交成绩
+ TDSUser currentUser = TDSUser.getCurrentUser();
+ if (null == currentUser){
+ Toast.makeText(MainActivity.this, "请先执行 TapTap 登陆", Toast.LENGTH_SHORT).show();
+ return;
+ }
+ Log.d(TAG, currentUser.toJSONString());
+ Map statistic = new HashMap<>();
+ statistic.put("Uaena", 26.0);
+ LCLeaderboard.updateStatistic(currentUser, statistic).subscribe(new Observer() {
+ @Override
+ public void onSubscribe(@androidx.annotation.NonNull Disposable d) {
+
+ }
+
+ @Override
+ public void onNext(@androidx.annotation.NonNull LCStatisticResult lcStatisticResult) {
+ Toast.makeText(MainActivity.this, "成绩提交成功!", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onError(@androidx.annotation.NonNull Throwable e) {
+ Toast.makeText(MainActivity.this, "成绩提交失败: " + e.getMessage(), Toast.LENGTH_SHORT).show();
+ Toast.makeText(MainActivity.this, "成绩提交失败: " + e.toString(), Toast.LENGTH_SHORT).show();
+ Log.d(TAG, e.toString());
+ }
+
+ @Override
+ public void onComplete() {
+
+ }
+ });
+ }
+
+ private void taptapInitOnly() {
+ LoginSdkConfig loginSdkConfig = new LoginSdkConfig(true, true, RegionType.CN);
+ TapLoginHelper.init(getApplicationContext(), "0RiAlMny7jiz086FaU", loginSdkConfig);
+// TapLoginHelper.init(getApplicationContext(), "6Rap5XF2ncLQB2oIiW", loginSdkConfig);
+
+ }
+
+ private void taptapLogoutOnly() {
+ TapLoginHelper.logout();
+
+ }
+
+ private void taptapLoginStatusOnly() {
+ // 判断登陆后的 AccessToken 是否为空
+ if(TapLoginHelper.getCurrentAccessToken() == null ){
+ Toast.makeText(MainActivity.this, "未登陆", Toast.LENGTH_SHORT).show();
+ }else {
+ Toast.makeText(MainActivity.this, "已登陆", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ private void taptapLoginOnly() {
+ TapLoginHelper.TapLoginResultCallback loginCallback = new TapLoginHelper.TapLoginResultCallback() {
+ @Override
+ public void onLoginSuccess(AccessToken token) {
+ Log.d(TAG, "TapTap authorization succeed");
+ // 开发者调用 TapLoginHelper.getCurrentProfile() 可以获得当前用户的一些基本信息,例如名称、头像。
+ Profile profile = TapLoginHelper.getCurrentProfile();
+ }
+
+ @Override
+ public void onLoginCancel() {
+ Log.d(TAG, "TapTap authorization cancelled");
+ }
+
+ @Override
+ public void onLoginError(AccountGlobalError globalError) {
+ Log.d(TAG, "TapTap authorization failed. cause: " + globalError.getMessage());
+ }
+ };
+ TapLoginHelper.registerLoginCallback(loginCallback);
+ TapLoginHelper.startTapLogin(MainActivity.this, TapLoginHelper.SCOPE_PUBLIC_PROFILE);
+ }
+
+ private void taptapSnapshotQueryByconditon() {
+ LCQuery query = TapGameSave.getQueryWithUser();
+ // 查询 Summary 为 GameSnapshot_Description 的云存档
+ query.whereEqualTo(GAME_SAVE_SUMMARY, "GameSnapshot_Description");
+ query.findInBackground()
+ .subscribe(new Observer>() {
+ @Override
+ public void onSubscribe(@NotNull Disposable d) {
+
+ }
+
+ @Override
+ public void onNext(@NotNull List tapGameSaves) {
+ Log.d(TAG, "gameSave:" + JSON.toJSONString(tapGameSaves));
+ System.out.println("gameSave:" + JSON.toJSONString(tapGameSaves));
+ Toast.makeText(MainActivity.this, "gameSave:" + JSON.toJSONString(tapGameSaves), Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onError(@NotNull Throwable e) {
+ Log.d(TAG, "查询失败: " + e.toString());
+ Log.d(TAG, "查询失败: " + e.getMessage());
+ Toast.makeText(MainActivity.this, "查询失败: " + e.toString(), Toast.LENGTH_SHORT).show();
+ e.printStackTrace();
+ }
+
+ @Override
+ public void onComplete() {
+
+ }
+ });
+
+ }
+
+ private void taptapSnapshotQueryCurrentAll() {
+ TapGameSave.getCurrentUserGameSaves()
+ .subscribe(new Observer>() {
+ @Override
+ public void onSubscribe(@androidx.annotation.NonNull Disposable d) {
+
+ }
+
+ @Override
+ public void onNext(@androidx.annotation.NonNull List tapGameSaves) {
+ Log.d(TAG, "gameSave:" + JSON.toJSONString(tapGameSaves));
+ System.out.println("gameSave:" + JSON.toJSONString(tapGameSaves));
+ Toast.makeText(MainActivity.this, "gameSave:" + JSON.toJSONString(tapGameSaves), Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onError(@androidx.annotation.NonNull Throwable e) {
+ Log.d(TAG, "查询失败: " + e.getMessage());
+ Log.d(TAG, "查询失败: " + e.toString());
+ Toast.makeText(MainActivity.this, "查询失败: " + e.toString(), Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onComplete() {
+
+ }
+ });
+ }
+
+ private void taptapSnapshotSave() {
+ gameSave.saveInBackground().subscribe(new Observer() {
+ @Override
+ public void onSubscribe(@NotNull Disposable d) {
+
+ }
+
+ @Override
+ public void onNext(@NotNull TapGameSave gameSave) {
+ Log.d(TAG, "存档保存成功:" + gameSave.toJSONString());
+ System.out.println("存档保存成功:" + gameSave.toJSONString());
+ Toast.makeText(MainActivity.this, "存档保存成功:" + gameSave.toJSONString(), Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onError(@NotNull Throwable e) {
+ Log.d(TAG, "存档保存失败:" + e.getMessage());
+ Log.d(TAG, "存档保存失败:" + e.toString());
+ Toast.makeText(MainActivity.this, "存档保存失败: " + e.toString(), Toast.LENGTH_SHORT).show();
+ e.printStackTrace();
+ }
+
+ @Override
+ public void onComplete() {
+
+ }
+ });
+
+ }
+
+ private void taptapSnapshotCreated() {
+ gameSave = new TapGameSave();
+ // 存档名
+ gameSave.setName("GameSnapshot_Name");
+ // 存档概览
+ gameSave.setSummary("GameSnapshot_Description");
+ // 游玩时间
+ gameSave.setPlayedTime(999);
+ // 游戏进度
+ gameSave.setProgressValue(99);
+ // 存档封面图,仅支持 png 或者 jpeg 格式
+// gameSave.setCover("cover_path");
+ // 存档源文件 /storage/emulated/0/Android/data/packname/cache
+ String filePath = getApplicationContext().getExternalCacheDir().getAbsolutePath() + "/" + "LeeJiEun.txt";
+ String fileContent = "LeeJiEun You're My Celebtiry";
+ FileOutputStream fout = null;
+ try {
+ fout = new FileOutputStream(filePath);
+ fout.write(fileContent.getBytes());
+ fout.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }finally {
+ if (null != fout){
+ try {
+ fout.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
+ gameSave.setGameFile(filePath);
+ // 修改时间
+ gameSave.setModifiedAt(new Date());
}
boolean flagShow = false;
@@ -348,6 +1073,7 @@ private void taptapFetchUserAchieveData() {
for (TapAchievementBean tab : userList){
Log.d(TAG, tab.toString());
}
+ Toast.makeText(this, userList.toString(), Toast.LENGTH_SHORT).show();
}
// 服务端数据
@@ -359,14 +1085,17 @@ public void onGetAchievementList(List achievementList, Achie
case AchievementException.SDK_NOT_INIT:
// SDK 还未初始化数据
Log.d(TAG, "SDK 还未初始化数据");
+ Toast.makeText(MainActivity.this, "SDK 还未初始化数据", Toast.LENGTH_SHORT).show();
break;
default:
// 数据获取失败
Log.d(TAG, "数据获取失败");
+ Toast.makeText(MainActivity.this, "数据获取失败", Toast.LENGTH_SHORT).show();
}
} else {
// 成功获取数据
Log.d(TAG, "成功获取数据");
+ Toast.makeText(MainActivity.this, "成功获取数据", Toast.LENGTH_SHORT).show();
if(!achievementList.isEmpty()){
for(TapAchievementBean tab: achievementList){
Log.d(TAG, tab.toString());
@@ -384,6 +1113,7 @@ private void taptapFetchAllAchieveData() {
for(TapAchievementBean tab : allList){
Log.d(TAG, tab.toString());
}
+ Toast.makeText(this, allList.toString(), Toast.LENGTH_SHORT).show();
}
// 服务端数据
@@ -395,14 +1125,17 @@ public void onGetAchievementList(List achievementList, Achie
case AchievementException.SDK_NOT_INIT:
// SDK 还未初始化数据
Log.d(TAG, "SDK 还未初始化数据");
+ Toast.makeText(MainActivity.this, "SDK 还未初始化数据", Toast.LENGTH_SHORT).show();
break;
default:
// 数据获取失败
Log.d(TAG, "数据获取失败");
+ Toast.makeText(MainActivity.this, "数据获取失败", Toast.LENGTH_SHORT).show();
}
} else {
// 成功获取数据
Log.d(TAG, "成功获取数据");
+ Toast.makeText(MainActivity.this, "成功获取数据", Toast.LENGTH_SHORT).show();
if(!achievementList.isEmpty()){
for(TapAchievementBean tab: achievementList){
Log.d(TAG, tab.toString());
@@ -423,12 +1156,14 @@ private void taptapRegisterAchieve() {
public void onAchievementSDKInitSuccess() {
// 数据加载成功
Log.d(TAG, "数据加载成功!");
+ Toast.makeText(MainActivity.this, "数据加载成功!", Toast.LENGTH_SHORT).show();
}
@Override
public void onAchievementSDKInitFail(AchievementException exception) {
// 数据加载失败,请重试
Log.d(TAG, "数据加载失败: " + exception.toString());
+ Toast.makeText(MainActivity.this, "数据加载失败: " + exception.toString(), Toast.LENGTH_SHORT).show();
}
@Override
@@ -436,11 +1171,13 @@ public void onAchievementStatusUpdate(TapAchievementBean item, AchievementExcept
if (exception != null) {
// 成就更新失败
Log.d(TAG, "成就更新失败: " + exception.toString());
+ Toast.makeText(MainActivity.this, "成就更新失败: " + exception.toString(), Toast.LENGTH_SHORT).show();
return;
}
if (item != null) {
// item 更新成功
Log.d(TAG, "成就更新成功");
+ Toast.makeText(MainActivity.this, "成就更新成功", Toast.LENGTH_SHORT).show();
}
}
});
@@ -495,8 +1232,9 @@ public void onNext(LCNull response) {
@Override
public void onError(@NonNull Throwable e) {
- System.out.println("failed to delete friendship of jerry. cause: " + e.getMessage());
+ System.out.println("failed to delete friendship cause: " + e.getMessage());
Log.d(TAG,"failed to delete friendship of QueriedUser. cause: " + e.getMessage());
+ Toast.makeText(MainActivity.this, "failed to delete friendship of QueriedUser. cause: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
@@ -505,11 +1243,8 @@ public void onComplete() {}
}else {
Toast.makeText(this, "删除好友失败,没有查找到要删除好友的关系!", Toast.LENGTH_SHORT).show();
}
-
}
-
-
private void taptapGetFriendsList() {
TDSUser currentUser = TDSUser.currentUser();
LCQuery query = currentUser.friendshipQuery();
@@ -529,7 +1264,8 @@ public void onNext(List lcFriendships) {
@Override
public void onError(@NonNull Throwable e) {
- Log.d(TAG, "failed to query friendship of jerry. cause: " + e.getMessage());
+ Log.d(TAG, "failed to query friendship cause: " + e.getMessage());
+ Toast.makeText(MainActivity.this, "failed to query friendship cause: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
@@ -543,16 +1279,19 @@ private void taptapFriendshipRequestStatus() {
@Override
public void onNewRequestComing(LCFriendshipRequest request) {
Log.d(TAG, request.toString());
+ Toast.makeText(MainActivity.this, request.toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void onRequestAccepted(LCFriendshipRequest request) {
Log.d(TAG, request.toString());
+ Toast.makeText(MainActivity.this, request.toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void onRequestDeclined(LCFriendshipRequest request) {
Log.d(TAG, request.toString());
+ Toast.makeText(MainActivity.this, request.toString(), Toast.LENGTH_SHORT).show();
}
};
@@ -569,7 +1308,7 @@ private void taptapDeleteFriendshipRequest() {
LCFriendshipRequest queriedRequests = null;
// leeJiEun 同意了来自 leeJiDong 的好友请求
for(LCFriendshipRequest fr:currentUserLcFriendshipRequests ){
-
+ Toast.makeText(this, fr.getObjectId(), Toast.LENGTH_SHORT).show();
}
if (!currentUserLcFriendshipRequests.isEmpty()){
queriedRequests = currentUserLcFriendshipRequests.get(0);
@@ -584,7 +1323,8 @@ public void onNext(Boolean result) {}
@Override
public void onError(@NonNull Throwable e) {
- System.out.println("failed to delete friendship request of jerry. cause: " + e.getMessage());
+ System.out.println("failed to delete friendship request cause: " + e.getMessage());
+ Toast.makeText(MainActivity.this, "failed to delete friendship request cause: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
@@ -597,7 +1337,7 @@ private void taptapAcceptFriendshipRequest() {
LCFriendshipRequest queriedRequests = null;
// leeJiEun 同意了来自 leeJiDong 的好友请求
for(LCFriendshipRequest fr:currentUserLcFriendshipRequests ){
-
+ Log.d(TAG, fr.getFriend().getObjectId());
}
if (!currentUserLcFriendshipRequests.isEmpty()){
queriedRequests = currentUserLcFriendshipRequests.get(0);
@@ -611,11 +1351,13 @@ public void onSubscribe(@NonNull Disposable d) {}
public void onNext(LCFriendshipRequest result) {
Log.d(TAG, result.getFriend().getObjectId());
Log.d(TAG, "同意好友请求!");
+ Toast.makeText(MainActivity.this, "同意好友请求!", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(@NonNull Throwable e) {
- Log.d(TAG,"failed to accept friendship request of jerry. cause: " + e.getMessage());
+ Log.d(TAG,"failed to accept friendship request cause: " + e.getMessage());
+ Toast.makeText(MainActivity.this, "failed to accept friendship request cause: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
@@ -644,7 +1386,8 @@ public void onNext(LCFriendshipRequest result) {}
@Override
public void onError(@NonNull Throwable e) {
- System.out.println("failed to decline friendship request of jerry. cause: " + e.getMessage());
+ System.out.println("failed to decline friendship request cause: " + e.getMessage());
+ Toast.makeText(MainActivity.this, "failed to decline friendship request cause: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
@@ -652,7 +1395,6 @@ public void onComplete() {}
});
}
-
private void taptapGetFriendRequestList() {
TDSUser currentUser = TDSUser.currentUser();
currentUser.friendshipRequestQuery(LCFriendshipRequest.STATUS_PENDING, false, true)
@@ -665,16 +1407,21 @@ public void onSubscribe(@NonNull Disposable d) {}
public void onNext(List lcFriendshipRequests) {
Log.d(TAG, "friendship requests number to leeJiEun is: " +lcFriendshipRequests.size());
for(LCFriendshipRequest request: lcFriendshipRequests) {
+ request.getSourceUser();
+ request.getFriend();
System.out.println(request);
Log.d(TAG, request.toString());
Log.d(TAG, request.getFriend().getObjectId());
currentUserLcFriendshipRequests.add(request);
+ Toast.makeText(MainActivity.this, request.getFriend().getObjectId(), Toast.LENGTH_SHORT).show();
}
+
}
@Override
public void onError(@NonNull Throwable e) {
- Log.d(TAG, "failed to query friendship request of jerry. cause: " + e.getMessage());
+ Log.d(TAG, "failed to query friendship request cause: " + e.getMessage());
+ Toast.makeText(MainActivity.this, "failed to query friendship request cause: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
@@ -693,6 +1440,11 @@ private void taptapAddFriend() {
try {
// TODO 第一步更改:测试需要更改这里的 OcjectID
leeJiEun = LCObject.createWithoutData(TDSUser.class, LeeJiEunID);
+
+
+ LCQuery query = new LCQuery<>("TDSUser");
+
+
} catch (LCException e) {
e.printStackTrace();
}
@@ -709,7 +1461,7 @@ public void onNext(@NotNull LCFriendshipRequest lcFriendshipRequest) {
@Override
public void onError(@NotNull Throwable e) {
- System.out.println("failed to apply friend request to jerry.");
+ System.out.println("failed to apply friend request");
Toast.makeText(MainActivity.this, "添加失败:" + e.toString(), Toast.LENGTH_SHORT).show();
}
@@ -753,6 +1505,7 @@ public void onSuccess(Boolean aBoolean) {
public void onError(Throwable throwable) {
// 服务端检查出错或者网络异常
Toast.makeText(MainActivity.this, "服务端检查出错或者网络异常", Toast.LENGTH_SHORT).show();
+ Log.d(TAG,throwable.toString());
}
});
}
@@ -767,12 +1520,14 @@ private void taptapLoginStatus() {
} else {
// 用户已经登录过
Toast.makeText(MainActivity.this, "已经登陆,执行程序业务逻辑", Toast.LENGTH_SHORT).show();
+ String accessToken = TapLoginHelper.getCurrentAccessToken().toJsonString();
+ Log.d(TAG, accessToken);
}
}
private void taptapLogin() {
-
TDSUser currentUser = TDSUser.currentUser();
+
// 未登录用户会返回 null
if (currentUser == null) {
// 用户未登录过
@@ -780,16 +1535,13 @@ private void taptapLogin() {
@Override
public void onSuccess(TDSUser resultUser) {
// 开发者可以调用 resultUser 的方法获取更多属性。
- String userID = resultUser.getObjectId();
+ userID = resultUser.getObjectId();
+
String userName = resultUser.getUsername();
String avatar = (String) resultUser.get("avatar");
- String openID = (String) resultUser.get("openid");
- String unionID = (String) resultUser.get("unionid");
Log.d(TAG, "userID: " + userID);
Log.d(TAG, "userName: " +userName);
Log.d(TAG, "avatar: "+ avatar);
- Log.d(TAG, "openID: "+ openID);
- Log.d(TAG, "unionID: "+ unionID);
Map authData = (Map)resultUser.get("authData");
Map taptapAuthData = (Map) authData.get("taptap");
Log.d(TAG,"authData:"+ JSON.toJSONString(authData));
@@ -803,12 +1555,19 @@ public void onSuccess(TDSUser resultUser) {
public void onFail(TapError error) {
Toast.makeText(MainActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
Log.d(TAG, error.detailMessage);
+ Log.d(TAG, error.getMessage());
+ Log.d(TAG, error.toJSON());
}
}, TapLoginHelper.SCOPE_PUBLIC_PROFILE);
+
+
+
} else {
// 用户已经登录过
Toast.makeText(MainActivity.this, "已经登陆,执行程序业务逻辑", Toast.LENGTH_SHORT).show();
}
+
+
}
private void taptapOneKeyPublish() {
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 7b074da..437be14 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -7,278 +7,491 @@
android:orientation="vertical"
tools:context=".MainActivity">
-
+ android:layout_height="wrap_content">
-
+ android:layout_height="match_parent"
+ android:layout_marginStart="10dp"
+ android:layout_marginEnd="10dp"
+ android:orientation="vertical">
-
-
-
+ android:layout_marginTop="10dp"
+ android:text="「内建账户登陆」 相关:"
+ android:textColor="@color/gray" />
-
-
-
+
+
+ android:layout_marginTop="10dp"
+ android:text="「TapTap 单独登陆」 相关:"
+ android:textColor="@color/gray" />
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+ android:layout_marginTop="10dp"
+ android:text="「内嵌动态」 相关:"
+ android:textColor="@color/gray" />
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_marginTop="10dp"
+ android:text="「游戏内好友」 相关:"
+ android:textColor="@color/gray" />
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_marginTop="10dp"
+ android:text="「成就系统」 相关:"
+ android:textColor="@color/gray" />
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_marginTop="10dp"
+ android:text="「云存档」 相关:"
+ android:textColor="@color/gray" />
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_marginTop="10dp"
+ android:text="「排行榜」 相关:TapDC 后台创建排行榜"
+ android:textColor="@color/gray" />
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_marginTop="100px"
+ android:text="" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 5eb7e81..b339289 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Mar 29 18:41:56 CST 2021
+#Wed Dec 29 17:00:58 CST 2021
distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
+zipStoreBase=GRADLE_USER_HOME