Commit adab52895079efc203649cfe55fd93743d6abaa7

Authored by 赵康
1 parent 983e266671
Exists in master

version:4.2.0:增加Google登录

Showing 6 changed files with 8 additions and 4 deletions Inline Diff

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