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