Commit db6adf69989f81fc695124cbbfe304173154a037
1 parent
d495d19f86
Exists in
master
temp
Showing 2 changed files with 3 additions and 3 deletions Inline Diff
GameSDKDemo/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | 2 | ||
3 | /*The config for internal testing,you could ignore it | 3 | /*The config for internal testing,you could ignore it |
4 | * gump内部测试使用,你可以自行配置,或者直接删除这部分内容 | 4 | * gump内部测试使用,你可以自行配置,或者直接删除这部分内容 |
5 | * --start-- | 5 | * --start-- |
6 | */ | 6 | */ |
7 | def keystorePSW = '' | 7 | def keystorePSW = '' |
8 | def keystoreAlias = '' | 8 | def keystoreAlias = '' |
9 | def keystoreAliasPSW = '' | 9 | def keystoreAliasPSW = '' |
10 | // default keystore file, PLZ config file path in local.properties | 10 | // default keystore file, PLZ config file path in local.properties |
11 | def keyfile = file('s.keystore.temp') | 11 | def keyfile = file('s.keystore.temp') |
12 | 12 | ||
13 | Properties properties = new Properties() | 13 | Properties properties = new Properties() |
14 | // local.properties file in the root director | 14 | // local.properties file in the root director |
15 | properties.load(project.file('local.properties').newDataInputStream()) | 15 | properties.load(project.file('local.properties').newDataInputStream()) |
16 | def keystoreFilepath = properties.getProperty("keystore.path") | 16 | def keystoreFilepath = properties.getProperty("keystore.path") |
17 | 17 | ||
18 | if (keystoreFilepath) { | 18 | if (keystoreFilepath) { |
19 | keystorePSW = properties.getProperty("keystore.password") | 19 | keystorePSW = properties.getProperty("keystore.password") |
20 | keystoreAlias = properties.getProperty("keystore.alias") | 20 | keystoreAlias = properties.getProperty("keystore.alias") |
21 | keystoreAliasPSW = properties.getProperty("keystore.key_passwd") | 21 | keystoreAliasPSW = properties.getProperty("keystore.key_passwd") |
22 | keyfile = file(keystoreFilepath) | 22 | keyfile = file(keystoreFilepath) |
23 | } | 23 | } |
24 | /* | 24 | /* |
25 | * The config for internal testing,you could ignore it | 25 | * The config for internal testing,you could ignore it |
26 | * gump内部测试使用,你可以自行配置,或者直接删除这部分内容 | 26 | * gump内部测试使用,你可以自行配置,或者直接删除这部分内容 |
27 | * --end-- | 27 | * --end-- |
28 | */ | 28 | */ |
29 | 29 | ||
30 | repositories { | 30 | repositories { |
31 | maven { | 31 | maven { |
32 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" | 32 | url "http://117.50.8.198:8081/nexus/content/repositories/sdk" |
33 | } | 33 | } |
34 | jcenter() | 34 | jcenter() |
35 | google() | 35 | google() |
36 | } | 36 | } |
37 | 37 | ||
38 | android { | 38 | android { |
39 | compileSdkVersion 30 | 39 | compileSdkVersion 30 |
40 | buildToolsVersion '28.0.3' | 40 | buildToolsVersion '28.0.3' |
41 | 41 | ||
42 | signingConfigs { | 42 | signingConfigs { |
43 | release { | 43 | release { |
44 | storeFile keyfile | 44 | storeFile keyfile |
45 | storePassword keystorePSW | 45 | storePassword keystorePSW |
46 | keyPassword keystoreAliasPSW | 46 | keyPassword keystoreAliasPSW |
47 | keyAlias keystoreAlias | 47 | keyAlias keystoreAlias |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | defaultConfig { | 51 | defaultConfig { |
52 | minSdkVersion 14 | 52 | minSdkVersion 14 |
53 | targetSdkVersion 30 | 53 | targetSdkVersion 30 |
54 | applicationId "com.summon.empires2" | 54 | applicationId "com.ecgaaa.uuac" |
55 | versionCode 38 | 55 | versionCode 38 |
56 | versionName "1.0.3" | 56 | versionName "1.0.3" |
57 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | 57 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
58 | signingConfig signingConfigs.release | 58 | signingConfig signingConfigs.release |
59 | } | 59 | } |
60 | buildTypes { | 60 | buildTypes { |
61 | release { | 61 | release { |
62 | minifyEnabled false | 62 | minifyEnabled false |
63 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 63 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
64 | zipAlignEnabled true | 64 | zipAlignEnabled true |
65 | } | 65 | } |
66 | debug { | 66 | debug { |
67 | signingConfig signingConfigs.release | 67 | signingConfig signingConfigs.release |
68 | } | 68 | } |
69 | } | 69 | } |
70 | lintOptions { | 70 | lintOptions { |
71 | abortOnError false | 71 | abortOnError false |
72 | } | 72 | } |
73 | compileOptions { | 73 | compileOptions { |
74 | sourceCompatibility JavaVersion.VERSION_1_8 | 74 | sourceCompatibility JavaVersion.VERSION_1_8 |
75 | targetCompatibility JavaVersion.VERSION_1_8 | 75 | targetCompatibility JavaVersion.VERSION_1_8 |
76 | } | 76 | } |
77 | applicationVariants.all { | 77 | applicationVariants.all { |
78 | variant -> | 78 | variant -> |
79 | variant.outputs.all { | 79 | variant.outputs.all { |
80 | outputFileName = "GameSDKDemo-" + variant.name + defaultConfig.versionName + ".apk" | 80 | outputFileName = "GameSDKDemo-" + variant.name + defaultConfig.versionName + ".apk" |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | } | 84 | } |
85 | 85 | ||
86 | dependencies { | 86 | dependencies { |
87 | implementation fileTree(include: ['*.jar'], dir: 'libs') | 87 | implementation fileTree(include: ['*.jar'], dir: 'libs') |
88 | // implementation 'com.android.support:support-v4:27.1.1' | 88 | // implementation 'com.android.support:support-v4:27.1.1' |
89 | implementation 'androidx.appcompat:appcompat:1.2.0' | 89 | implementation 'androidx.appcompat:appcompat:1.2.0' |
90 | implementation 'androidx.fragment:fragment:1.2.5' | 90 | implementation 'androidx.fragment:fragment:1.2.5' |
91 | implementation 'com.google.android.material:material:1.2.1' | 91 | implementation 'com.google.android.material:material:1.2.1' |
92 | testImplementation 'junit:junit:4.12' | 92 | testImplementation 'junit:junit:4.12' |
93 | // implementation 'com.android.support:appcompat-v7:27.1.1' | 93 | // implementation 'com.android.support:appcompat-v7:27.1.1' |
94 | // implementation 'com.android.support:design:27.1.1' | 94 | // implementation 'com.android.support:design:27.1.1' |
95 | implementation project(':GameSDK') | 95 | implementation project(':GameSDK') |
96 | // implementation project(':IAP5Helper') | 96 | // implementation project(':IAP5Helper') |
97 | // implementation 'com.gumptech.sdk:GameSDK:4.8.0' | 97 | // implementation 'com.gumptech.sdk:GameSDK:4.8.0' |
98 | // implementation 'com.gump.game.sdk:SamsungIAP:5.1.1' | 98 | // implementation 'com.gump.game.sdk:SamsungIAP:5.1.1' |
99 | } | 99 | } |
100 | 100 |
GameSDKDemo/src/main/java/com/gump/game/sdk/demo/MainActivity.java
1 | package com.gump.game.sdk.demo; | 1 | package com.gump.game.sdk.demo; |
2 | 2 | ||
3 | import android.os.Bundle; | 3 | import android.os.Bundle; |
4 | import android.util.Log; | 4 | import android.util.Log; |
5 | import android.widget.Button; | 5 | import android.widget.Button; |
6 | import android.widget.TextView; | 6 | import android.widget.TextView; |
7 | import android.widget.Toast; | 7 | import android.widget.Toast; |
8 | 8 | ||
9 | import com.gump.game.sdk.GameSDK; | 9 | import com.gump.game.sdk.GameSDK; |
10 | import com.gump.game.sdk.GumpPreference; | 10 | import com.gump.game.sdk.GumpPreference; |
11 | import com.gump.game.sdk.SDKSettings; | 11 | import com.gump.game.sdk.SDKSettings; |
12 | import com.gump.game.sdk.bean.GumpUser; | 12 | import com.gump.game.sdk.bean.GumpUser; |
13 | import com.gump.game.sdk.callback.LoginStateListener; | 13 | import com.gump.game.sdk.callback.LoginStateListener; |
14 | import com.gump.game.sdk.callback.RechargeCallback; | 14 | import com.gump.game.sdk.callback.RechargeCallback; |
15 | import com.gump.game.sdk.passport.fb.FBAccessToken; | 15 | import com.gump.game.sdk.passport.fb.FBAccessToken; |
16 | 16 | ||
17 | import java.util.Locale; | 17 | import java.util.Locale; |
18 | 18 | ||
19 | import androidx.appcompat.app.AppCompatActivity; | 19 | import androidx.appcompat.app.AppCompatActivity; |
20 | 20 | ||
21 | public class MainActivity extends AppCompatActivity implements RechargeCallback { | 21 | public class MainActivity extends AppCompatActivity implements RechargeCallback { |
22 | 22 | ||
23 | private static final String TAG = "MainActivity"; | 23 | private static final String TAG = "MainActivity"; |
24 | 24 | ||
25 | private TextView tvVersion; | 25 | private TextView tvVersion; |
26 | private TextView userInfo; | 26 | private TextView userInfo; |
27 | 27 | ||
28 | private Button btnLoginOrLogout; | 28 | private Button btnLoginOrLogout; |
29 | private Button btnCheckState; | 29 | private Button btnCheckState; |
30 | private Button btnPay; | 30 | private Button btnPay; |
31 | private Button btnIap; | 31 | private Button btnIap; |
32 | 32 | ||
33 | private String appId = "10117"; | 33 | private String appId = "100"; |
34 | private String channelId = "1030"; | 34 | private String channelId = "1001"; |
35 | private GumpUser gumpUser; | 35 | private GumpUser gumpUser; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * 测试数据 | 38 | * 测试数据 |
39 | */ | 39 | */ |
40 | String serverId = "S168"; | 40 | String serverId = "S168"; |
41 | String roleId = "168000089"; | 41 | String roleId = "168000089"; |
42 | 42 | ||
43 | 43 | ||
44 | @Override | 44 | @Override |
45 | protected void onCreate(Bundle savedInstanceState) { | 45 | protected void onCreate(Bundle savedInstanceState) { |
46 | super.onCreate(savedInstanceState); | 46 | super.onCreate(savedInstanceState); |
47 | setContentView(R.layout.activity_main); | 47 | setContentView(R.layout.activity_main); |
48 | 48 | ||
49 | tvVersion = findViewById(R.id.version); | 49 | tvVersion = findViewById(R.id.version); |
50 | userInfo = findViewById(R.id.user_info); | 50 | userInfo = findViewById(R.id.user_info); |
51 | btnLoginOrLogout = findViewById(R.id.login_or_logout); | 51 | btnLoginOrLogout = findViewById(R.id.login_or_logout); |
52 | btnCheckState = findViewById(R.id.check_state); | 52 | btnCheckState = findViewById(R.id.check_state); |
53 | btnLoginOrLogout.setOnClickListener(v -> { | 53 | btnLoginOrLogout.setOnClickListener(v -> { |
54 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 54 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) |
55 | GameSDK.login(MainActivity.this); | 55 | GameSDK.login(MainActivity.this); |
56 | else | 56 | else |
57 | GameSDK.logout(MainActivity.this); | 57 | GameSDK.logout(MainActivity.this); |
58 | }); | 58 | }); |
59 | btnCheckState.setOnClickListener(v -> { | 59 | btnCheckState.setOnClickListener(v -> { |
60 | GameSDK.iapUsable(MainActivity.this, serverId, roleId, usable -> { | 60 | GameSDK.iapUsable(MainActivity.this, serverId, roleId, usable -> { |
61 | btnIap.setEnabled(usable); | 61 | btnIap.setEnabled(usable); |
62 | btnPay.setEnabled(!usable); | 62 | btnPay.setEnabled(!usable); |
63 | }); | 63 | }); |
64 | }); | 64 | }); |
65 | btnPay = findViewById(R.id.pay); | 65 | btnPay = findViewById(R.id.pay); |
66 | btnPay.setOnClickListener(v -> { | 66 | btnPay.setOnClickListener(v -> { |
67 | PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(payInfo -> GameSDK.pay(MainActivity.this, payInfo, MainActivity.this)); | 67 | PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(payInfo -> GameSDK.pay(MainActivity.this, payInfo, MainActivity.this)); |
68 | submitFragment.show(getSupportFragmentManager(), "pay"); | 68 | submitFragment.show(getSupportFragmentManager(), "pay"); |
69 | }); | 69 | }); |
70 | btnIap = findViewById(R.id.iap); | 70 | btnIap = findViewById(R.id.iap); |
71 | btnIap.setOnClickListener(v -> { | 71 | btnIap.setOnClickListener(v -> { |
72 | PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(payInfo -> GameSDK.iap(MainActivity.this, payInfo, MainActivity.this)); | 72 | PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(payInfo -> GameSDK.iap(MainActivity.this, payInfo, MainActivity.this)); |
73 | submitFragment.show(getSupportFragmentManager(), "iap"); | 73 | submitFragment.show(getSupportFragmentManager(), "iap"); |
74 | }); | 74 | }); |
75 | 75 | ||
76 | 76 | ||
77 | Log.i("DEMO", "country:" + Locale.getDefault().getCountry() + ",language:" + Locale.getDefault().getLanguage()); | 77 | Log.i("DEMO", "country:" + Locale.getDefault().getCountry() + ",language:" + Locale.getDefault().getLanguage()); |
78 | 78 | ||
79 | GameSDK.getSettings().setDebug(false); | 79 | GameSDK.getSettings().setDebug(false); |
80 | /** | 80 | /** |
81 | * 设置是否打印debug日志 | 81 | * 设置是否打印debug日志 |
82 | */ | 82 | */ |
83 | GameSDK.getSettings().enableDebugLogging(true); | 83 | GameSDK.getSettings().enableDebugLogging(true); |
84 | /** | 84 | /** |
85 | * 设置启用facebook登录 | 85 | * 设置启用facebook登录 |
86 | */ | 86 | */ |
87 | GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_FB); | 87 | GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_FB); |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * 设置启用google登录 | 90 | * 设置启用google登录 |
91 | */ | 91 | */ |
92 | GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_GOOGLE); | 92 | GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_GOOGLE); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * 设置启用Line登录 | 95 | * 设置启用Line登录 |
96 | */ | 96 | */ |
97 | GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); | 97 | GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); |
98 | 98 | ||
99 | 99 | ||
100 | /** | 100 | /** |
101 | * 设置用户登录状态监听器 | 101 | * 设置用户登录状态监听器 |
102 | */ | 102 | */ |
103 | 103 | ||
104 | GameSDK.setUserStateListener(new LoginStateListener() { | 104 | GameSDK.setUserStateListener(new LoginStateListener() { |
105 | @Override | 105 | @Override |
106 | public void onLoginSuccess(GumpUser user) { | 106 | public void onLoginSuccess(GumpUser user) { |
107 | btnCheckState.setEnabled(true); | 107 | btnCheckState.setEnabled(true); |
108 | gumpUser = user; | 108 | gumpUser = user; |
109 | String userType = null; | 109 | String userType = null; |
110 | switch (user.getAccountType()) { | 110 | switch (user.getAccountType()) { |
111 | case GumpPreference.ACCOUNT_TYPE_FB: | 111 | case GumpPreference.ACCOUNT_TYPE_FB: |
112 | userType = "Facebook登录"; | 112 | userType = "Facebook登录"; |
113 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | 113 | String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); |
114 | Log.d(TAG, "FBAccessToken:" + fbToken); | 114 | Log.d(TAG, "FBAccessToken:" + fbToken); |
115 | break; | 115 | break; |
116 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | 116 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: |
117 | userType = "快速登录"; | 117 | userType = "快速登录"; |
118 | break; | 118 | break; |
119 | case GumpPreference.ACCOUNT_TYPE_REG: | 119 | case GumpPreference.ACCOUNT_TYPE_REG: |
120 | userType = "gump注册用户"; | 120 | userType = "gump注册用户"; |
121 | break; | 121 | break; |
122 | case GumpPreference.ACCOUNT_TYPE_GOOGLE: | 122 | case GumpPreference.ACCOUNT_TYPE_GOOGLE: |
123 | userType = "google 登录"; | 123 | userType = "google 登录"; |
124 | break; | 124 | break; |
125 | case GumpPreference.ACCOUNT_TYPE_LINE: | 125 | case GumpPreference.ACCOUNT_TYPE_LINE: |
126 | userType = "Line登录"; | 126 | userType = "Line登录"; |
127 | break; | 127 | break; |
128 | } | 128 | } |
129 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey() | 129 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey() |
130 | .getToken()); | 130 | .getToken()); |
131 | btnLoginOrLogout.setText("Logout"); | 131 | btnLoginOrLogout.setText("Logout"); |
132 | btnLoginOrLogout.setTag(1); | 132 | btnLoginOrLogout.setTag(1); |
133 | } | 133 | } |
134 | 134 | ||
135 | @Override | 135 | @Override |
136 | public void onLoginFailed(int code, String msg) { | 136 | public void onLoginFailed(int code, String msg) { |
137 | userInfo.setText(msg); | 137 | userInfo.setText(msg); |
138 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | 138 | Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); |
139 | } | 139 | } |
140 | 140 | ||
141 | @Override | 141 | @Override |
142 | public void onLoginCanceled() { | 142 | public void onLoginCanceled() { |
143 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 143 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
144 | } | 144 | } |
145 | 145 | ||
146 | @Override | 146 | @Override |
147 | public void onLogout() { | 147 | public void onLogout() { |
148 | btnLoginOrLogout.setText("Login"); | 148 | btnLoginOrLogout.setText("Login"); |
149 | btnLoginOrLogout.setTag(0); | 149 | btnLoginOrLogout.setTag(0); |
150 | userInfo.setText("User is logout"); | 150 | userInfo.setText("User is logout"); |
151 | } | 151 | } |
152 | 152 | ||
153 | @Override | 153 | @Override |
154 | public void onPermissionDenied(String[] deniedPermissions) { | 154 | public void onPermissionDenied(String[] deniedPermissions) { |
155 | StringBuilder sb = new StringBuilder(); | 155 | StringBuilder sb = new StringBuilder(); |
156 | for (String s : deniedPermissions) { | 156 | for (String s : deniedPermissions) { |
157 | sb.append(s); | 157 | sb.append(s); |
158 | sb.append(","); | 158 | sb.append(","); |
159 | } | 159 | } |
160 | Toast.makeText(MainActivity.this, "Permission denied:" + sb.toString(), Toast.LENGTH_SHORT).show(); | 160 | Toast.makeText(MainActivity.this, "Permission denied:" + sb.toString(), Toast.LENGTH_SHORT).show(); |
161 | } | 161 | } |
162 | }); | 162 | }); |
163 | /** | 163 | /** |
164 | * 初始化sdk | 164 | * 初始化sdk |
165 | */ | 165 | */ |
166 | GameSDK.init(getApplicationContext(), appId,channelId); | 166 | GameSDK.init(getApplicationContext(), appId,channelId); |
167 | 167 | ||
168 | tvVersion.setText("SDK Version:" + GameSDK.getVersion()); | 168 | tvVersion.setText("SDK Version:" + GameSDK.getVersion()); |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | private void checkRisk() { | 172 | private void checkRisk() { |
173 | GameSDK.inspectRiskLevel(this, isRisk -> Log.i(TAG, isRisk ? "There is some risks" : "Nothing is risk")); | 173 | GameSDK.inspectRiskLevel(this, isRisk -> Log.i(TAG, isRisk ? "There is some risks" : "Nothing is risk")); |
174 | } | 174 | } |
175 | 175 | ||
176 | @Override | 176 | @Override |
177 | public void onPurchaseCompleted() { | 177 | public void onPurchaseCompleted() { |
178 | Log.i(TAG, "purchase completed"); | 178 | Log.i(TAG, "purchase completed"); |
179 | } | 179 | } |
180 | 180 | ||
181 | @Override | 181 | @Override |
182 | public void onPurchaseError(int code, String msg) { | 182 | public void onPurchaseError(int code, String msg) { |
183 | Log.i(TAG, "purchase error:"+code+","+msg); | 183 | Log.i(TAG, "purchase error:"+code+","+msg); |
184 | } | 184 | } |
185 | 185 | ||
186 | @Override | 186 | @Override |
187 | public void onPurchaseCanceled() { | 187 | public void onPurchaseCanceled() { |
188 | Log.i(TAG, "purchase canceled"); | 188 | Log.i(TAG, "purchase canceled"); |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | } | 192 | } |
193 | 193 |