Skip to content

Commit

Permalink
Merge pull request #23 from yuwenjian/master
Browse files Browse the repository at this point in the history
更新 SDK 版本以及修改部分初始化的代码
  • Loading branch information
hexinghuaxd authored Oct 9, 2022
2 parents 24b49ac + bc56c43 commit af12bd0
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 76 deletions.
34 changes: 18 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,30 @@ android {

multiDexEnabled true

// ndk{
// abiFilters "arm64-v8a, x86_64"
// }

// ndk.abiFilters("arm64-v8a, x86_64")
}
signingConfigs {
release {
// 替换为您的签名文件
storeFile file('mysign.keystore')
storePassword 'mysign'
keyAlias = 'mysign'
keyPassword 'mysign'
}
}


buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release

}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release

}
}
compileOptions {
Expand All @@ -50,23 +58,17 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: [ '*.aar'])

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
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.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 'cn.leancloud:realtime-android:8.2.12'
implementation 'cn.leancloud:storage-android:8.2.12'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
}
Binary file removed app/libs/AntiAddictionUI_1.0.2.aar
Binary file not shown.
Binary file added app/libs/AntiAddictionUI_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/AntiAddiction_1.0.2.aar
Binary file not shown.
Binary file added app/libs/AntiAddiction_3.16.0.aar
Binary file not shown.
Binary file added app/libs/TapAchievement_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/TapAchievement_3.5.1.aar
Binary file not shown.
Binary file added app/libs/TapBootstrap_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/TapBootstrap_3.5.1.aar
Binary file not shown.
Binary file added app/libs/TapCommon_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/TapCommon_3.5.1.aar
Binary file not shown.
Binary file added app/libs/TapDB_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/TapDB_3.5.1.aar
Binary file not shown.
Binary file added app/libs/TapFriend_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/TapFriend_3.5.1.aar
Binary file not shown.
Binary file added app/libs/TapLicense_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/TapLicense_3.5.1.aar
Binary file not shown.
Binary file added app/libs/TapLogin_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/TapLogin_3.5.1.aar
Binary file not shown.
Binary file not shown.
Binary file added app/libs/TapSupport_3.16.0.aar
Binary file not shown.
Binary file removed app/libs/TapSupport_3.5.1.aar
Binary file not shown.
Binary file removed app/libs/gson-2.8.6.jar
Binary file not shown.
Binary file added app/mysign.keystore
Binary file not shown.
104 changes: 47 additions & 57 deletions app/src/main/java/com/example/tapsdk_android_demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.widget.Toast;

import com.tapsdk.antiaddiction.AntiAddictionKit;
import com.tapsdk.antiaddiction.Config;
import com.tapsdk.antiaddiction.config.AntiAddictionFunctionConfig;
import com.tapsdk.antiaddiction.constants.Constants;
import com.tapsdk.antiaddictionui.AntiAddictionUICallback;
Expand Down Expand Up @@ -141,6 +142,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// 云存档示例
TapGameSave gameSave;


// 开发者中心后台应用配置信息
public static final String TDS_ClientID = "替换为您的ClientID";
public static final String TDS_ClientToken = "替换为您的ClientToken";
public static final String TDS_ServerUrl = "替换为您的ServerUrl";


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -296,11 +304,11 @@ public void initSDK() {
TapConfig tapConfig = new TapConfig.Builder()
.withAppContext(getApplicationContext())
.withRegionType(TapRegionType.CN) // TapRegionType.CN: 国内 TapRegionType.IO: 国外
// 自己账号 - 知恩
.withClientId("**** Yourself ClientID From TapDC ****")
.withClientToken("****** Yourself ClientToken From TapDC ******")
// 自己账号
.withClientId(TDS_ClientID)
.withClientToken(TDS_ClientToken)
/* 如果使用 单独 TapTap 授权,则不需要配置自定义域名 */
.withServerUrl("****** Yourself ServerUrl From TapDC ******")
.withServerUrl(TDS_ServerUrl)
.withTapDBConfig(tapDBConfig)
.build();
TapBootstrap.init(MainActivity.this, tapConfig);
Expand Down Expand Up @@ -539,62 +547,48 @@ private void taptapAntiAddictionAgeRange() {
Log.d(TAG, "玩家段年龄段是:" + String.valueOf(ageRange));
}

// 手动认证
private void taptapAntiAddictionManual() {

String userIdentifier = "玩家的唯一标识NNNNNNNNYHHYWWTTAABC";
AntiAddictionUIKit.startup(MainActivity.this, false, userIdentifier, "");
String userIdentifier = "XXXXXXXXXXXXXXX";
// 进行实名认证的初始化时将 enableTapLogin(false) 即可
AntiAddictionUIKit.startup(this, userIdentifier);
}

// Tap 快速认证
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);
String userIdentifier = "XXXXXXXX-XXXXX";
AntiAddictionUIKit.startup(this, userIdentifier);
}

private void taptapAntiAddictionInit() {
// Android SDK 的各接口第一个参数是当前 Activity,以下不再说明
String gameIdentifier = "6Rap5XF2ncLQB2oIiW";
AntiAddictionFunctionConfig config = new AntiAddictionFunctionConfig.Builder()
.enablePaymentLimit(true) // 是否启用消费限制功能
.enableOnLineTimeLimit(true) // 是否启用时长限制功能
Config config = new Config.Builder()
.withClientId(TDS_ClientID) // TapTap 开发者中心对应 Client ID
.enableTapLogin(true) // 是否启动 TapTap 快速认证, 如果使用手动验证,设置为 false 即可
.showSwitchAccount(false) // 是否显示切换账号按钮
.build();
AntiAddictionUIKit.init(MainActivity.this, gameIdentifier, config,
new AntiAddictionUICallback() {
@Override
public void onCallback(int code, Map<String, Object> 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;
}
}
}
);
AntiAddictionUIKit.init(this, config, (code, extras) -> {
switch (code){
case Constants.ANTI_ADDICTION_CALLBACK_CODE.LOGIN_SUCCESS:
Log.d(TAG, "防沉迷登陆成功");
break;
case Constants.ANTI_ADDICTION_CALLBACK_CODE.EXITED:
Log.d(TAG, "退出账号");
break;
case Constants.ANTI_ADDICTION_CALLBACK_CODE.DURATION_LIMIT:
Log.d(TAG, "时长限制");
break;
case Constants.ANTI_ADDICTION_CALLBACK_CODE.PERIOD_RESTRICT:
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() {
Expand Down Expand Up @@ -652,12 +646,8 @@ private void taptapBinding() {
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<LCUser>() {
@Override
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.enableJetifier=true
android.nonTransitiveRClass=true
android.injected.testOnly=false
4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Jul 19 14:47:25 CST 2021
sdk.dir=/Users/shouwang/Library/Android/sdk
#Sun Oct 09 11:32:06 CST 2022
sdk.dir=/Users/yuwenjian/Library/Android/sdk

0 comments on commit af12bd0

Please sign in to comment.