Skip to content

Commit af12bd0

Browse files
authored
Merge pull request #23 from yuwenjian/master
更新 SDK 版本以及修改部分初始化的代码
2 parents 24b49ac + bc56c43 commit af12bd0

27 files changed

+70
-76
lines changed

app/build.gradle

+18-16
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,30 @@ android {
1919

2020
multiDexEnabled true
2121

22-
// ndk{
23-
// abiFilters "arm64-v8a, x86_64"
24-
// }
25-
26-
// ndk.abiFilters("arm64-v8a, x86_64")
22+
}
23+
signingConfigs {
24+
release {
25+
// 替换为您的签名文件
26+
storeFile file('mysign.keystore')
27+
storePassword 'mysign'
28+
keyAlias = 'mysign'
29+
keyPassword 'mysign'
30+
}
2731
}
2832

2933

3034
buildTypes {
3135
release {
3236
minifyEnabled true
3337
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
38+
signingConfig signingConfigs.release
39+
3440
}
3541
debug {
3642
minifyEnabled true
3743
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
44+
signingConfig signingConfigs.release
45+
3846
}
3947
}
4048
compileOptions {
@@ -50,23 +58,17 @@ android {
5058
}
5159

5260
dependencies {
61+
implementation fileTree(dir: 'libs', include: [ '*.aar'])
62+
5363
implementation 'androidx.appcompat:appcompat:1.2.0'
5464
implementation 'com.google.android.material:material:1.3.0'
5565
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
5666
testImplementation 'junit:junit:4.+'
5767
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
5868
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
5969
implementation 'com.google.android.flexbox:flexbox:3.0.0'
60-
implementation name: 'TapBootStrap_3.5.1', ext: 'aar' // 必选: x.x.x 代表所下载的 SDK的版本号
61-
implementation(name: 'TapCommon_3.5.1', ext: 'aar')
62-
implementation(name: 'TapMoment_3.5.1', ext: 'aar')
63-
implementation(name: 'TapLogin_3.5.1', ext: 'aar')
64-
implementation(name: 'TapLicense_3.5.1', ext: 'aar')
65-
implementation(name: 'TapAchievement_3.5.1', ext: 'aar')
66-
implementation(name: 'TapDB_3.5.1', ext: 'aar')
67-
implementation(name: 'AntiAddiction_1.0.2', ext: 'aar')
68-
implementation(name: 'AntiAddictionUI_1.0.2', ext: 'aar')
69-
implementation 'cn.leancloud:realtime-android:8.1.0'
70-
implementation 'cn.leancloud:storage-android:8.1.0'
70+
71+
implementation 'cn.leancloud:realtime-android:8.2.12'
72+
implementation 'cn.leancloud:storage-android:8.2.12'
7173
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
7274
}

app/libs/AntiAddictionUI_1.0.2.aar

-120 KB
Binary file not shown.

app/libs/AntiAddictionUI_3.16.0.aar

122 KB
Binary file not shown.

app/libs/AntiAddiction_1.0.2.aar

-798 KB
Binary file not shown.

app/libs/AntiAddiction_3.16.0.aar

1.01 MB
Binary file not shown.

app/libs/TapAchievement_3.16.0.aar

181 KB
Binary file not shown.

app/libs/TapAchievement_3.5.1.aar

-180 KB
Binary file not shown.

app/libs/TapBootstrap_3.16.0.aar

56.5 KB
Binary file not shown.

app/libs/TapBootstrap_3.5.1.aar

-42.3 KB
Binary file not shown.

app/libs/TapCommon_3.16.0.aar

1.75 MB
Binary file not shown.

app/libs/TapCommon_3.5.1.aar

-1.69 MB
Binary file not shown.

app/libs/TapDB_3.16.0.aar

115 KB
Binary file not shown.

app/libs/TapDB_3.5.1.aar

-109 KB
Binary file not shown.

app/libs/TapFriend_3.16.0.aar

205 KB
Binary file not shown.

app/libs/TapFriend_3.5.1.aar

-106 KB
Binary file not shown.

app/libs/TapLicense_3.16.0.aar

94 KB
Binary file not shown.

app/libs/TapLicense_3.5.1.aar

-95.3 KB
Binary file not shown.

app/libs/TapLogin_3.16.0.aar

159 KB
Binary file not shown.

app/libs/TapLogin_3.5.1.aar

-139 KB
Binary file not shown.
Binary file not shown.

app/libs/TapSupport_3.16.0.aar

11 KB
Binary file not shown.

app/libs/TapSupport_3.5.1.aar

-10.9 KB
Binary file not shown.

app/libs/gson-2.8.6.jar

-235 KB
Binary file not shown.

app/mysign.keystore

2.16 KB
Binary file not shown.

app/src/main/java/com/example/tapsdk_android_demo/MainActivity.java

+47-57
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.widget.Toast;
1313

1414
import com.tapsdk.antiaddiction.AntiAddictionKit;
15+
import com.tapsdk.antiaddiction.Config;
1516
import com.tapsdk.antiaddiction.config.AntiAddictionFunctionConfig;
1617
import com.tapsdk.antiaddiction.constants.Constants;
1718
import com.tapsdk.antiaddictionui.AntiAddictionUICallback;
@@ -141,6 +142,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
141142
// 云存档示例
142143
TapGameSave gameSave;
143144

145+
146+
// 开发者中心后台应用配置信息
147+
public static final String TDS_ClientID = "替换为您的ClientID";
148+
public static final String TDS_ClientToken = "替换为您的ClientToken";
149+
public static final String TDS_ServerUrl = "替换为您的ServerUrl";
150+
151+
144152
@Override
145153
protected void onCreate(Bundle savedInstanceState) {
146154
super.onCreate(savedInstanceState);
@@ -296,11 +304,11 @@ public void initSDK() {
296304
TapConfig tapConfig = new TapConfig.Builder()
297305
.withAppContext(getApplicationContext())
298306
.withRegionType(TapRegionType.CN) // TapRegionType.CN: 国内 TapRegionType.IO: 国外
299-
// 自己账号 - 知恩
300-
.withClientId("**** Yourself ClientID From TapDC ****")
301-
.withClientToken("****** Yourself ClientToken From TapDC ******")
307+
// 自己账号
308+
.withClientId(TDS_ClientID)
309+
.withClientToken(TDS_ClientToken)
302310
/* 如果使用 单独 TapTap 授权,则不需要配置自定义域名 */
303-
.withServerUrl("****** Yourself ServerUrl From TapDC ******")
311+
.withServerUrl(TDS_ServerUrl)
304312
.withTapDBConfig(tapDBConfig)
305313
.build();
306314
TapBootstrap.init(MainActivity.this, tapConfig);
@@ -539,62 +547,48 @@ private void taptapAntiAddictionAgeRange() {
539547
Log.d(TAG, "玩家段年龄段是:" + String.valueOf(ageRange));
540548
}
541549

550+
// 手动认证
542551
private void taptapAntiAddictionManual() {
543-
544-
String userIdentifier = "玩家的唯一标识NNNNNNNNYHHYWWTTAABC";
545-
AntiAddictionUIKit.startup(MainActivity.this, false, userIdentifier, "");
552+
String userIdentifier = "XXXXXXXXXXXXXXX";
553+
// 进行实名认证的初始化时将 enableTapLogin(false) 即可
554+
AntiAddictionUIKit.startup(this, userIdentifier);
546555
}
547556

557+
// Tap 快速认证
548558
private void taptapAntiAddictionTapLogin() {
549-
AccessToken accessToken = TapLoginHelper.getCurrentAccessToken();
550-
// String tapTapAccessToken = accessToken.toJsonString();
551-
boolean useTapLogin = true;
552-
String userIdentifier = "玩家的唯一标识NNNNNNNNYHHYWWTTAABC";
553-
String tapTapAccessToken = "TapTap 第三方登录的 access token";
554-
AntiAddictionUIKit.startup(MainActivity.this, useTapLogin, userIdentifier, tapTapAccessToken);
559+
String userIdentifier = "XXXXXXXX-XXXXX";
560+
AntiAddictionUIKit.startup(this, userIdentifier);
555561
}
556-
557562
private void taptapAntiAddictionInit() {
558563
// Android SDK 的各接口第一个参数是当前 Activity,以下不再说明
559-
String gameIdentifier = "6Rap5XF2ncLQB2oIiW";
560-
AntiAddictionFunctionConfig config = new AntiAddictionFunctionConfig.Builder()
561-
.enablePaymentLimit(true) // 是否启用消费限制功能
562-
.enableOnLineTimeLimit(true) // 是否启用时长限制功能
564+
Config config = new Config.Builder()
565+
.withClientId(TDS_ClientID) // TapTap 开发者中心对应 Client ID
566+
.enableTapLogin(true) // 是否启动 TapTap 快速认证, 如果使用手动验证,设置为 false 即可
567+
.showSwitchAccount(false) // 是否显示切换账号按钮
563568
.build();
564-
AntiAddictionUIKit.init(MainActivity.this, gameIdentifier, config,
565-
new AntiAddictionUICallback() {
566-
@Override
567-
public void onCallback(int code, Map<String, Object> extras) {
568-
// 根据 code 不同提示玩家不同信息,详见下面的说明
569-
if(null != extras){
570-
Log.d(TAG, extras.toString());
571-
Log.d(TAG, String.valueOf(code));
572-
}
573-
switch (code){
574-
case Constants.ANTI_ADDICTION_CALLBACK_CODE.LOGIN_SUCCESS:
575-
// Log.d(TAG, extras.toString());
576-
Log.d(TAG, "防沉迷登陆成功");
577-
break;
578-
case Constants.ANTI_ADDICTION_CALLBACK_CODE.LOGOUT:
579-
// Log.d(TAG, extras.toString());
580-
Log.d(TAG, "防沉迷的登出");
581-
break;
582-
case Constants.ANTI_ADDICTION_CALLBACK_CODE.OPEN_ALERT_TIP:
583-
Log.d(TAG, "防沉迷未成年允许游戏弹窗");
584-
break;
585-
case Constants.ANTI_ADDICTION_CALLBACK_CODE.NIGHT_STRICT:
586-
Log.d(TAG, "防沉迷未成年玩家无法进行游戏");
587-
break;
588-
case Constants.ANTI_ADDICTION_CALLBACK_CODE.REAL_NAME_STOP:
589-
Log.d(TAG, "防沉迷实名认证过程中点击了关闭实名窗");
590-
break;
591-
case Constants.ANTI_ADDICTION_CALLBACK_CODE.SWITCH_ACCOUNT:
592-
Log.d(TAG, "防沉迷实名认证过程中点击了切换账号按钮");
593-
break;
594-
}
595-
}
596-
}
597-
);
569+
AntiAddictionUIKit.init(this, config, (code, extras) -> {
570+
switch (code){
571+
case Constants.ANTI_ADDICTION_CALLBACK_CODE.LOGIN_SUCCESS:
572+
Log.d(TAG, "防沉迷登陆成功");
573+
break;
574+
case Constants.ANTI_ADDICTION_CALLBACK_CODE.EXITED:
575+
Log.d(TAG, "退出账号");
576+
break;
577+
case Constants.ANTI_ADDICTION_CALLBACK_CODE.DURATION_LIMIT:
578+
Log.d(TAG, "时长限制");
579+
break;
580+
case Constants.ANTI_ADDICTION_CALLBACK_CODE.PERIOD_RESTRICT:
581+
Log.d(TAG, "防沉迷未成年玩家无法进行游戏");
582+
break;
583+
case Constants.ANTI_ADDICTION_CALLBACK_CODE.REAL_NAME_STOP:
584+
Log.d(TAG, "防沉迷实名认证过程中点击了关闭实名窗");
585+
break;
586+
case Constants.ANTI_ADDICTION_CALLBACK_CODE.SWITCH_ACCOUNT:
587+
Log.d(TAG, "防沉迷实名认证过程中点击了切换账号按钮");
588+
break;
589+
}
590+
});
591+
598592
}
599593

600594
private void taptapThirdLogin() {
@@ -652,12 +646,8 @@ private void taptapBinding() {
652646
thirdPartyData.put("openid", "BANDINGpcb6jiHAjB82k8H9MjKkiQ==");
653647
thirdPartyData.put("access_token", "BandingHAHAHAHAHA1/e3fyiwgwBGXeor93rQGfB_qfOpsArBYvze6W7zmV73zxKH1mpJUgehCWRbj0-c-ZrTlSV3qlAAaQW1C4tjJFlZjjxlvpJhGQ0JXHX7bfZwwKxiI8DJ0zu5XXOmE2LdwRXXMjbI0Syeuua5Ym5W2uK-JNfinO2jen6Sb7p_1GeJF-j3W_6nmYZPVJSP9BQap5b61zLOZ1c0r7-5t3d1Id-TeAj8Km78tj4rZ1QkLzgUFauRSxvHKMhkPOzW3LDVpMw3dns5B2Am_hw5ybgAOT0PDdVVRNe68DWz1JySB2G5ARPwDLonYwn13-_BoPl9ldaTK_ogF9chFmfLF_V5DFKg");
654648
// 可选
655-
// thirdPartyData.put("expires_in", 7200);
656-
// thirdPartyData.put("openid", "QDNJfr2wFRRmFu8oqL2pCg==");
657-
// thirdPartyData.put("access_token", "1/B2sMNYgxvmuwNPg82IEuOZIAoT30WmB-L2FkHUxprcF39RCBTlFVKbcV_fHSMvSQMp5m_9cLnC78GzimhvGll4t8R0X5Vp_KAiTVk-JrnunHKYObD310JM5HikHz6YMaex9TPVaDtZV1jCFVZo1cUfDlCrpmm3o0urx_LZYqTamvDU_JnZTyunq7lD-2YI_LVekpqP5ZznhvcfyLA-r48lrwa1FuZM3cQygH5H_xvYTHHP1pPiPOPhzhZWJu7NP9Ya6ReNKPpMtAiFXnzokVhB1QKfcaPhYr9g60ogY6a3vii2Jn-hCWV61NqLFhGl3HoiWBmw7F1BQ4FnbbVidyHQ");
658649
thirdPartyData.put("taptap_name", "lrj3zwhy01pr4ltbu4hiww2ba");
659-
// thirdPartyData.put("refresh_token", "TapTap_REFRESH_TOKEN");
660-
// thirdPartyData.put("scope", "TapTap_SCOPE");
650+
661651
TDSUser currentUser = TDSUser.getCurrentUser();
662652
currentUser.associateWithAuthData(thirdPartyData, "taptap").subscribe(new Observer<LCUser>() {
663653
@Override

gradle.properties

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1616
# https://developer.android.com/topic/libraries/support-library/androidx-rn
1717
android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
19-
android.enableJetifier=true
19+
android.enableJetifier=true
20+
android.nonTransitiveRClass=true
21+
android.injected.testOnly=false

local.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# Location of the SDK. This is only used by Gradle.
55
# For customization when using a Version Control System, please read the
66
# header note.
7-
#Mon Jul 19 14:47:25 CST 2021
8-
sdk.dir=/Users/shouwang/Library/Android/sdk
7+
#Sun Oct 09 11:32:06 CST 2022
8+
sdk.dir=/Users/yuwenjian/Library/Android/sdk

0 commit comments

Comments
 (0)