Commit 969c0010c26e93e5dd4ab09eb6bed83618c6c39b

Authored by 赵康
1 parent 7a5aadf066
Exists in master

v4.1.6:修复gp支付无回调的bug

Showing 9 changed files with 26 additions and 14 deletions Inline Diff

GameSDK-release4.1.5.aar
No preview for this file type
GameSDK-release4.1.6.aar
No preview for this file type
GameSDKDemo/build.gradle
1 apply plugin: 'com.android.application' 1 apply plugin: 'com.android.application'
2 2
3 repositories{ 3 repositories{
4 flatDir{ 4 flatDir{
5 dirs 'libs' 5 dirs 'libs'
6 } 6 }
7 } 7 }
8 8
9 android { 9 android {
10 compileSdkVersion 22 10 compileSdkVersion 22
11 buildToolsVersion "25.0.0" 11 buildToolsVersion "25.0.0"
12 12
13
14 defaultConfig { 13 defaultConfig {
15 minSdkVersion 9 14 minSdkVersion 9
16 targetSdkVersion 22 15 targetSdkVersion 22
17 versionCode 3 16 versionCode 4
18 versionName "1.2" 17 versionName "1.2"
19 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 18 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20 } 19 }
21 20
22 buildTypes { 21 buildTypes {
23 release { 22 release {
24 minifyEnabled false 23 minifyEnabled false
25 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26 } 25 }
27 } 26 }
28 lintOptions{ 27 lintOptions{
29 abortOnError false 28 abortOnError false
30 } 29 }
31 } 30 }
32 31
33 dependencies { 32 dependencies {
34 compile fileTree(dir: 'libs', include: ['*.jar']) 33 compile fileTree(dir: 'libs', include: ['*.jar'])
35 testCompile 'junit:junit:4.12' 34 testCompile 'junit:junit:4.12'
36 compile 'com.android.support:appcompat-v7:22.2.0' 35 compile 'com.android.support:appcompat-v7:22.2.0'
37 // compile project(':GameSDK') 36 // compile project(':GameSDK')
38 compile(name:'GameSDK-release4.1.5',ext:'aar') 37 compile(name:'GameSDK-release4.1.6',ext:'aar')
39 38
40 } 39 }
41 40
GameSDKDemo/libs/GameSDK-release4.1.5.aar
No preview for this file type
GameSDKDemo/libs/GameSDK-release4.1.6.aar
No preview for this file type
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
1 package com.gumptech.sdk.demo; 1 package com.gumptech.sdk.demo;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.content.Context; 4 import android.content.Context;
5 import android.os.Bundle; 5 import android.os.Bundle;
6 import android.text.ClipboardManager; 6 import android.text.ClipboardManager;
7 import android.util.Log; 7 import android.util.Log;
8 import android.view.View; 8 import android.view.View;
9 import android.widget.Button; 9 import android.widget.Button;
10 import android.widget.TextView; 10 import android.widget.TextView;
11 import android.widget.Toast; 11 import android.widget.Toast;
12 12
13 import com.gumptech.sdk.GumpPreference; 13 import com.gumptech.sdk.GumpPreference;
14 import com.gumptech.sdk.GumpSDK; 14 import com.gumptech.sdk.GumpSDK;
15 import com.gumptech.sdk.PaymentVersion; 15 import com.gumptech.sdk.PaymentVersion;
16 import com.gumptech.sdk.bean.GumpUser; 16 import com.gumptech.sdk.bean.GumpUser;
17 import com.gumptech.sdk.bean.PurchaseResult; 17 import com.gumptech.sdk.bean.PurchaseResult;
18 import com.gumptech.sdk.callback.InitializeCallback; 18 import com.gumptech.sdk.callback.InitializeCallback;
19 import com.gumptech.sdk.callback.LoginStateListener; 19 import com.gumptech.sdk.callback.LoginStateListener;
20 import com.gumptech.sdk.callback.PurchaseCallback; 20 import com.gumptech.sdk.callback.PurchaseCallback;
21 import com.gumptech.sdk.callback.ResultCallback; 21 import com.gumptech.sdk.callback.ResultCallback;
22 import com.gumptech.sdk.passport.fb.FBAccessToken; 22 import com.gumptech.sdk.passport.fb.FBAccessToken;
23 23
24 public class MainActivity extends Activity implements PurchaseCallback { 24 public class MainActivity extends Activity implements PurchaseCallback {
25 25
26 private static final String TAG = "MainActivity"; 26 private static final String TAG = "MainActivity";
27 27
28 private TextView tvVersion; 28 private TextView tvVersion;
29 private TextView userInfo; 29 private TextView userInfo;
30 30
31 private Button btnLoginOrLogout; 31 private Button btnLoginOrLogout;
32 32
33 private String appId = "10022"; 33 private String appId = "10022";
34 private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; 34 private String appKey = "c1aff6753244c6ee93d489992b51f012";
35 private String sessionKey; 35 private String sessionKey;
36 36
37 37
38 @Override 38 @Override
39 protected void onCreate(Bundle savedInstanceState) { 39 protected void onCreate(Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState); 40 super.onCreate(savedInstanceState);
41 setContentView(R.layout.activity_main); 41 setContentView(R.layout.activity_main);
42
42 tvVersion = (TextView) findViewById(R.id.version); 43 tvVersion = (TextView) findViewById(R.id.version);
43 userInfo = (TextView) findViewById(R.id.user_info); 44 userInfo = (TextView) findViewById(R.id.user_info);
44 btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); 45 btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout);
45 btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { 46 btnLoginOrLogout.setOnClickListener(new View.OnClickListener() {
46 47
47 @Override 48 @Override
48 public void onClick(View v) { 49 public void onClick(View v) {
49 if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) 50 if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0)
50 GumpSDK.start(MainActivity.this); 51 GumpSDK.start(MainActivity.this);
51 else 52 else
52 GumpSDK.logout(MainActivity.this); 53 GumpSDK.logout(MainActivity.this);
53 } 54 }
54 }); 55 });
55 findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { 56 findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() {
56 57
57 @Override 58 @Override
58 public void onClick(View v) { 59 public void onClick(View v) {
59 Bundle payInfo = new Bundle(); 60 Bundle payInfo = new Bundle();
60 payInfo.putString("product", "test2"); 61 payInfo.putString("product", "test2");
61 payInfo.putFloat("amount", 0.1f); 62 payInfo.putFloat("amount", 0.1f);
62 payInfo.putString("extraInfo", "This is demo!"); 63 payInfo.putString("extraInfo", "This is demo!");
63 payInfo.putString("serverId", "100"); 64 payInfo.putString("serverId", "100");
64 payInfo.putString("roleId","100123"); 65 payInfo.putString("roleId","100123");
65 payInfo.putString("sessionKey", sessionKey); 66 payInfo.putString("sessionKey", sessionKey);
66 GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); 67 GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this);
67 } 68 }
68 }); 69 });
69 findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { 70 findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() {
70 @Override 71 @Override
71 public void onClick(View v) { 72 public void onClick(View v) {
72 Bundle payInfo = new Bundle(); 73 Bundle payInfo = new Bundle();
73 payInfo.putString("product", "gp_skuId"); 74 payInfo.putString("product", "180010");
74 payInfo.putFloat("amount", 0.1f); 75 payInfo.putFloat("amount", 0.1f);
75 payInfo.putString("extraInfo", "This is demo!"); 76 payInfo.putString("extraInfo", "This is demo!");
76 payInfo.putString("serverId", "100"); 77 payInfo.putString("serverId", "100");
77 payInfo.putString("roleId","100123"); 78 payInfo.putString("roleId","100123");
78 GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); 79 GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this);
79 } 80 }
80 }); 81 });
81 /** 82 /**
82 * 设置否是打印debug日志 83 * 设置否是打印debug日志
83 */ 84 */
84 GumpSDK.getSettings().enableDebugLogging(true); 85 GumpSDK.getSettings().enableDebugLogging(true);
85 /** 86 /**
86 * 设置是否启用facebook登录 87 * 设置是否启用facebook登录
87 */ 88 */
88 GumpSDK.getSettings().setFBEnable(true); 89 GumpSDK.getSettings().setFBEnable(true);
89 /** 90 /**
90 * 设置是否启用Vk登录 91 * 设置是否启用Vk登录
91 */ 92 */
92 GumpSDK.getSettings().setVKEnable(false); 93 GumpSDK.getSettings().setVKEnable(false);
93 /** 94 /**
94 * 设置屏幕方向 95 * 设置屏幕方向
95 */ 96 */
96 GumpSDK.getSettings().setScreenLandscape(true); 97 GumpSDK.getSettings().setScreenLandscape(true);
97 98
98 /** 99 /**
99 * 设置支付版本 100 * 设置支付版本
100 */ 101 */
101 GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); 102 GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4);
102 103
103 /** 104 /**
104 * 设置用户登录状态监听器 105 * 设置用户登录状态监听器
105 */ 106 */
106 107
107 GumpSDK.setUserStateListener(new LoginStateListener() { 108 GumpSDK.setUserStateListener(new LoginStateListener() {
108 @Override 109 @Override
109 public void onLoginSuccess(GumpUser user) { 110 public void onLoginSuccess(GumpUser user) {
110 ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); 111 ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
111 cm.setText(user.getSessionKey()); 112 cm.setText(user.getSessionKey());
112 sessionKey = user.getSessionKey(); 113 sessionKey = user.getSessionKey();
113 String userType = null; 114 String userType = null;
114 switch (user.getAccountType()) { 115 switch (user.getAccountType()) {
115 case GumpPreference.ACCOUNT_TYPE_FB: 116 case GumpPreference.ACCOUNT_TYPE_FB:
116 userType = "Facebook登录"; 117 userType = "Facebook登录";
117 String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); 118 String fbToken = FBAccessToken.getCurrentAccessToken().getToken();
118 Log.d(TAG, "FBAccessToken:" + fbToken); 119 Log.d(TAG, "FBAccessToken:" + fbToken);
119 break; 120 break;
120 case GumpPreference.ACCOUNT_TYPE_QUICK_REG: 121 case GumpPreference.ACCOUNT_TYPE_QUICK_REG:
121 userType = "快速登录"; 122 userType = "快速登录";
122 break; 123 break;
123 case GumpPreference.ACCOUNT_TYPE_REG: 124 case GumpPreference.ACCOUNT_TYPE_REG:
124 userType = "gump注册用户"; 125 userType = "gump注册用户";
125 break; 126 break;
126 case GumpPreference.ACCOUNT_TYPE_VK: 127 case GumpPreference.ACCOUNT_TYPE_VK:
127 userType = "vk登录"; 128 userType = "vk登录";
128 break; 129 break;
129 } 130 }
130 userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey()); 131 userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey());
131 btnLoginOrLogout.setText("Logout"); 132 btnLoginOrLogout.setText("Logout");
132 btnLoginOrLogout.setTag(1); 133 btnLoginOrLogout.setTag(1);
133 } 134 }
134 135
135 @Override 136 @Override
136 public void onLoginFailed(int code, String msg) { 137 public void onLoginFailed(int code, String msg) {
137 userInfo.setText(msg); 138 userInfo.setText(msg);
138 Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); 139 Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show();
139 } 140 }
140 141
141 @Override 142 @Override
142 public void onLoginCanceled() { 143 public void onLoginCanceled() {
143 Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); 144 Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show();
144 } 145 }
145 146
146 @Override 147 @Override
147 public void onLogout() { 148 public void onLogout() {
148 btnLoginOrLogout.setText("Login"); 149 btnLoginOrLogout.setText("Login");
149 btnLoginOrLogout.setTag(0); 150 btnLoginOrLogout.setTag(0);
150 userInfo.setText("User is logout"); 151 userInfo.setText("User is logout");
151 } 152 }
152 }); 153 });
153 /** 154 /**
154 * 初始化sdk 155 * 初始化sdk
155 */ 156 */
156 GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { 157 GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() {
157 @Override 158 @Override
158 public void initComplete(int result) { 159 public void initComplete(int result) {
159 if (result == GumpSDK.CODE.OK) { 160 if (result == GumpSDK.CODE.OK) {
160 btnLoginOrLogout.setEnabled(true); 161 btnLoginOrLogout.setEnabled(true);
161 162
162 //checkRisk(); 163 //checkRisk();
163 } 164 }
164 } 165 }
165 }); 166 });
166 167
167 tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); 168 tvVersion.setText("SDK Version:" + GumpSDK.getVersion());
168 169
169 } 170 }
170 171
171 private void checkRisk(){ 172 private void checkRisk(){
172 GumpSDK.checkRisk(this, new ResultCallback() { 173 GumpSDK.checkRisk(this, new ResultCallback() {
173 @Override 174 @Override
174 public void onResult(boolean isRisk) { 175 public void onResult(boolean isRisk) {
175 Log.i(TAG,isRisk?"There is some risks":"Nothing is risk"); 176 Log.i(TAG,isRisk?"There is some risks":"Nothing is risk");
176 } 177 }
177 }); 178 });
178 } 179 }
179 180
180 @Override 181 @Override
181 public void onPurchaseCompleted(PurchaseResult result) { 182 public void onPurchaseCompleted(PurchaseResult result) {
182 Log.i(TAG, "purchase completed"); 183 Log.i(TAG, "purchase completed");
183 } 184 }
184 185
185 @Override 186 @Override
186 public void onPurchaseError(int code, String msg) { 187 public void onPurchaseError(int code, String msg) {
187 Log.i(TAG, "purchase error"); 188 Log.i(TAG, "purchase error");
188 } 189 }
189 190
190 @Override 191 @Override
191 public void onPurchaseCanceled() { 192 public void onPurchaseCanceled() {
192 Log.i(TAG, "purchase canceled"); 193 Log.i(TAG, "purchase canceled");
193 } 194 }
194 195
195 196
196 } 197 }
197 198
GameSDKDemo/src/main/res/layout/activity_main.xml
1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="match_parent" 2 android:layout_width="match_parent"
3 android:layout_height="match_parent" 3 android:layout_height="match_parent"
4 android:background="@android:color/white" 4 android:background="@android:color/white"
5 android:orientation="vertical"> 5 android:fitsSystemWindows="true"
6 android:orientation="vertical">
6 7
7 <TextView 8 <TextView
8 android:id="@+id/version" 9 android:id="@+id/version"
9 android:layout_width="wrap_content" 10 android:layout_width="wrap_content"
10 android:layout_height="wrap_content" 11 android:layout_height="wrap_content"
11 android:layout_gravity="center_horizontal" 12 android:layout_gravity="center_horizontal"
12 android:textColor="@color/black_text" /> 13 android:textColor="@color/black_text"/>
13 14
14 <TextView 15 <TextView
15 android:id="@+id/user_info" 16 android:id="@+id/user_info"
16 android:layout_width="match_parent" 17 android:layout_width="match_parent"
17 android:layout_height="wrap_content" 18 android:layout_height="wrap_content"
18 android:textColor="@android:color/black" /> 19 android:textColor="@android:color/black"/>
19 20
20 <Button 21 <Button
21 android:id="@+id/login_or_logout" 22 android:id="@+id/login_or_logout"
22 android:layout_width="match_parent" 23 android:layout_width="match_parent"
23 android:layout_height="wrap_content" 24 android:layout_height="wrap_content"
24 android:backgroundTint="@color/g_color" 25 android:backgroundTint="@color/g_color"
25 android:enabled="false" 26 android:enabled="false"
26 android:text="Login" /> 27 android:text="Login"/>
28
27 <Button 29 <Button
28 android:id="@+id/iap" 30 android:id="@+id/iap"
29 android:layout_width="match_parent" 31 android:layout_width="match_parent"
30 android:layout_height="wrap_content" 32 android:layout_height="wrap_content"
31 android:backgroundTint="@color/g_color" 33 android:backgroundTint="@color/g_color"
32 android:text="IAP"/> 34 android:text="IAP"/>
33 35
34 <Button 36 <Button
35 android:id="@+id/pay" 37 android:id="@+id/pay"
36 android:layout_width="match_parent" 38 android:layout_width="match_parent"
37 android:layout_height="wrap_content" 39 android:layout_height="wrap_content"
38 android:backgroundTint="@color/g_color" 40 android:backgroundTint="@color/g_color"
39 android:text="pay" /> 41 android:text="pay"/>
40 42
41 </LinearLayout> 43 </LinearLayout>
GameSDKDemo/src/main/res/values-v19/styles.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <resources>
3 <style name="AppTheme" parent="BaseAppTheme">
4 <item name="android:windowTranslucentStatus">true</item>
5 </style>
6 </resources>
GameSDKDemo/src/main/res/values/styles.xml
1 <resources> 1 <resources>
2 2
3 <!-- Base application theme. --> 3 <!-- Base application theme. -->
4 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 4 <style name="BaseAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5 <!-- Customize your theme here. --> 5 <!-- Customize your theme here. -->
6 <item name="colorPrimary">@color/colorPrimary</item> 6 <item name="colorPrimary">@color/colorPrimary</item>
7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8 <item name="colorAccent">@color/colorAccent</item> 8 <item name="colorAccent">@color/colorAccent</item>
9 </style> 9 </style>
10 10
11 <style name="AppTheme" parent="BaseAppTheme">
12
13 </style>
14
11 </resources> 15 </resources>
12 16