Commit 2d1a34aa9e882a63f9a5063d84a9b44582e9faa6

Authored by 赵康
1 parent 06e47b8f03
Exists in master

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

Showing 6 changed files with 7 additions and 8 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 2 16 versionCode 1000002
18 versionName "1.1" 17 versionName "1.0.2"
19 } 18 }
20 19
21 buildTypes { 20 buildTypes {
22 release { 21 release {
23 minifyEnabled false 22 minifyEnabled false
24 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25 } 24 }
26 } 25 }
27 lintOptions{ 26 lintOptions{
28 abortOnError false 27 abortOnError false
29 } 28 }
30 } 29 }
31 30
32 dependencies { 31 dependencies {
33 compile fileTree(dir: 'libs', include: ['*.jar']) 32 compile fileTree(dir: 'libs', include: ['*.jar'])
34 testCompile 'junit:junit:4.12' 33 testCompile 'junit:junit:4.12'
35 compile 'com.android.support:appcompat-v7:22.2.0' 34 compile 'com.android.support:appcompat-v7:22.2.0'
36 compile project(':GameSDK') 35 // compile project(':GameSDK')
37 // compile(name:'GameSDK-release4.1.4',ext:'aar') 36 compile(name:'GameSDK-release4.1.6',ext:'aar')
38 } 37 }
39 38
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.g.root.GumpPreference; 13 import com.g.root.GumpPreference;
14 import com.g.root.GumpSDK; 14 import com.g.root.GumpSDK;
15 import com.g.root.PaymentVersion; 15 import com.g.root.PaymentVersion;
16 import com.g.root.bean.GumpUser; 16 import com.g.root.bean.GumpUser;
17 import com.g.root.bean.PurchaseResult; 17 import com.g.root.bean.PurchaseResult;
18 import com.g.root.callback.InitializeCallback; 18 import com.g.root.callback.InitializeCallback;
19 import com.g.root.callback.LoginStateListener; 19 import com.g.root.callback.LoginStateListener;
20 import com.g.root.callback.PurchaseCallback; 20 import com.g.root.callback.PurchaseCallback;
21 import com.g.root.passport.fb.FBAccessToken; 21 import com.g.root.passport.fb.FBAccessToken;
22 22
23 public class MainActivity extends Activity implements PurchaseCallback { 23 public class MainActivity extends Activity implements PurchaseCallback {
24 24
25 private static final String TAG = "MainActivity"; 25 private static final String TAG = "MainActivity";
26 26
27 private TextView tvVersion; 27 private TextView tvVersion;
28 private TextView userInfo; 28 private TextView userInfo;
29 29
30 private Button btnLoginOrLogout; 30 private Button btnLoginOrLogout;
31 31
32 private String appId = "10022"; 32 private String appId = "10022";
33 private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; 33 private String appKey = "7e0ff37942c2de60cbcbd27041196ce3";
34 private String sessionKey; 34 private String sessionKey;
35 35
36 36
37 @Override 37 @Override
38 protected void onCreate(Bundle savedInstanceState) { 38 protected void onCreate(Bundle savedInstanceState) {
39 super.onCreate(savedInstanceState); 39 super.onCreate(savedInstanceState);
40 setContentView(R.layout.activity_main); 40 setContentView(R.layout.activity_main);
41 tvVersion = (TextView) findViewById(R.id.version); 41 tvVersion = (TextView) findViewById(R.id.version);
42 userInfo = (TextView) findViewById(R.id.user_info); 42 userInfo = (TextView) findViewById(R.id.user_info);
43 btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); 43 btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout);
44 btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { 44 btnLoginOrLogout.setOnClickListener(new View.OnClickListener() {
45 45
46 @Override 46 @Override
47 public void onClick(View v) { 47 public void onClick(View v) {
48 if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) 48 if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0)
49 GumpSDK.start(MainActivity.this); 49 GumpSDK.start(MainActivity.this);
50 else 50 else
51 GumpSDK.logout(MainActivity.this); 51 GumpSDK.logout(MainActivity.this);
52 } 52 }
53 }); 53 });
54 findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { 54 findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() {
55 55
56 @Override 56 @Override
57 public void onClick(View v) { 57 public void onClick(View v) {
58 Bundle payInfo = new Bundle(); 58 Bundle payInfo = new Bundle();
59 payInfo.putString("product", "test2"); 59 payInfo.putString("product", "test2");
60 payInfo.putFloat("amount", 0.1f); 60 payInfo.putFloat("amount", 0.1f);
61 payInfo.putString("extraInfo", "This is demo!"); 61 payInfo.putString("extraInfo", "This is demo!");
62 payInfo.putString("serverId", "100"); 62 payInfo.putString("serverId", "100");
63 payInfo.putString("roleId","100123"); 63 payInfo.putString("roleId","100123");
64 payInfo.putString("sessionKey", sessionKey); 64 payInfo.putString("sessionKey", sessionKey);
65 GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); 65 GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this);
66 } 66 }
67 }); 67 });
68 findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { 68 findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() {
69 @Override 69 @Override
70 public void onClick(View v) { 70 public void onClick(View v) {
71 Bundle payInfo = new Bundle(); 71 Bundle payInfo = new Bundle();
72 payInfo.putString("product", "gp_skuId"); 72 payInfo.putString("product", "renmbl.9");
73 payInfo.putFloat("amount", 0.1f); 73 payInfo.putFloat("amount", 0.1f);
74 payInfo.putString("extraInfo", "This is demo!"); 74 payInfo.putString("extraInfo", "This is demo!");
75 payInfo.putString("serverId", "100"); 75 payInfo.putString("serverId", "100");
76 payInfo.putString("roleId","100123"); 76 payInfo.putString("roleId","100123");
77 GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); 77 GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this);
78 } 78 }
79 }); 79 });
80 /** 80 /**
81 * 设置否是打印debug日志 81 * 设置否是打印debug日志
82 */ 82 */
83 GumpSDK.getSettings().enableDebugLogging(true); 83 GumpSDK.getSettings().enableDebugLogging(true);
84 /** 84 /**
85 * 设置是否启用facebook登录 85 * 设置是否启用facebook登录
86 */ 86 */
87 GumpSDK.getSettings().setFBEnable(true); 87 GumpSDK.getSettings().setFBEnable(true);
88 /** 88 /**
89 * 设置是否启用Vk登录 89 * 设置是否启用Vk登录
90 */ 90 */
91 GumpSDK.getSettings().setVKEnable(false); 91 GumpSDK.getSettings().setVKEnable(false);
92 /** 92 /**
93 * 设置屏幕方向 93 * 设置屏幕方向
94 */ 94 */
95 GumpSDK.getSettings().setScreenLandscape(true); 95 GumpSDK.getSettings().setScreenLandscape(true);
96 96
97 /** 97 /**
98 * 设置支付版本 98 * 设置支付版本
99 */ 99 */
100 GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); 100 GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4);
101 101
102 /** 102 /**
103 * 设置用户登录状态监听器 103 * 设置用户登录状态监听器
104 */ 104 */
105 105
106 GumpSDK.setUserStateListener(new LoginStateListener() { 106 GumpSDK.setUserStateListener(new LoginStateListener() {
107 @Override 107 @Override
108 public void onLoginSuccess(GumpUser user) { 108 public void onLoginSuccess(GumpUser user) {
109 ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); 109 ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
110 cm.setText(user.getSessionKey()); 110 cm.setText(user.getSessionKey());
111 sessionKey = user.getSessionKey(); 111 sessionKey = user.getSessionKey();
112 String userType = null; 112 String userType = null;
113 switch (user.getAccountType()) { 113 switch (user.getAccountType()) {
114 case GumpPreference.ACCOUNT_TYPE_FB: 114 case GumpPreference.ACCOUNT_TYPE_FB:
115 userType = "Facebook登录"; 115 userType = "Facebook登录";
116 String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); 116 String fbToken = FBAccessToken.getCurrentAccessToken().getToken();
117 Log.d(TAG, "FBAccessToken:" + fbToken); 117 Log.d(TAG, "FBAccessToken:" + fbToken);
118 break; 118 break;
119 case GumpPreference.ACCOUNT_TYPE_QUICK_REG: 119 case GumpPreference.ACCOUNT_TYPE_QUICK_REG:
120 userType = "快速登录"; 120 userType = "快速登录";
121 break; 121 break;
122 case GumpPreference.ACCOUNT_TYPE_REG: 122 case GumpPreference.ACCOUNT_TYPE_REG:
123 userType = "gump注册用户"; 123 userType = "gump注册用户";
124 break; 124 break;
125 case GumpPreference.ACCOUNT_TYPE_VK: 125 case GumpPreference.ACCOUNT_TYPE_VK:
126 userType = "vk登录"; 126 userType = "vk登录";
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 btnLoginOrLogout.setText("Logout"); 130 btnLoginOrLogout.setText("Logout");
131 btnLoginOrLogout.setTag(1); 131 btnLoginOrLogout.setTag(1);
132 } 132 }
133 133
134 @Override 134 @Override
135 public void onLoginFailed(int code, String msg) { 135 public void onLoginFailed(int code, String msg) {
136 userInfo.setText(msg); 136 userInfo.setText(msg);
137 Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); 137 Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show();
138 } 138 }
139 139
140 @Override 140 @Override
141 public void onLoginCanceled() { 141 public void onLoginCanceled() {
142 Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); 142 Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show();
143 } 143 }
144 144
145 @Override 145 @Override
146 public void onLogout() { 146 public void onLogout() {
147 btnLoginOrLogout.setText("Login"); 147 btnLoginOrLogout.setText("Login");
148 btnLoginOrLogout.setTag(0); 148 btnLoginOrLogout.setTag(0);
149 userInfo.setText("User is logout"); 149 userInfo.setText("User is logout");
150 } 150 }
151 }); 151 });
152 /** 152 /**
153 * 初始化sdk 153 * 初始化sdk
154 */ 154 */
155 GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { 155 GumpSDK.init(getApplicationContext(), appId, appKey, "1003", new InitializeCallback() {
156 @Override 156 @Override
157 public void initComplete(int result) { 157 public void initComplete(int result) {
158 if (result == GumpSDK.CODE.OK) { 158 if (result == GumpSDK.CODE.OK) {
159 btnLoginOrLogout.setEnabled(true); 159 btnLoginOrLogout.setEnabled(true);
160 } 160 }
161 } 161 }
162 }); 162 });
163 163
164 tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); 164 tvVersion.setText("SDK Version:" + GumpSDK.getVersion());
165 165
166 } 166 }
167 167
168 @Override 168 @Override
169 public void onPurchaseCompleted(PurchaseResult result) { 169 public void onPurchaseCompleted(PurchaseResult result) {
170 Log.i(TAG, "purchase completed"); 170 Log.i(TAG, "purchase completed");
171 } 171 }
172 172
173 @Override 173 @Override
174 public void onPurchaseError(int code, String msg) { 174 public void onPurchaseError(int code, String msg) {
175 Log.i(TAG, "purchase error"); 175 Log.i(TAG, "purchase error");
176 } 176 }
177 177
178 @Override 178 @Override
179 public void onPurchaseCanceled() { 179 public void onPurchaseCanceled() {
180 Log.i(TAG, "purchase canceled"); 180 Log.i(TAG, "purchase canceled");
181 } 181 }
182 182
183 183
184 } 184 }
185 185