Commit fbcd9c5022789e94f91915bb7a72a31a7f885064
1 parent
b53b3a3068
Exists in
master
release3.3.5
升级支付接口到v3
Showing 5 changed files with 177 additions and 165 deletions Inline Diff
android/GameSDKRelease/libs/GameSDK_v3.3.4_proguard.jar
No preview for this file type
android/GameSDKRelease/libs/GameSDK_v3.3.5_proguard.jar
No preview for this file type
android/GameSDKRelease/res/layout/pay_container.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | android:background="@color/payment_common_bg" | 5 | android:background="@color/payment_common_bg" |
6 | android:orientation="vertical" > | 6 | android:orientation="vertical" > |
7 | 7 | ||
8 | <LinearLayout | 8 | <ProgressBar |
9 | android:id="@+id/container" | 9 | android:id="@+id/loading_prog" |
10 | style="@android:style/Widget.ProgressBar.Horizontal" | ||
10 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
11 | android:layout_height="wrap_content" | 12 | android:layout_height="2dp" /> |
12 | android:orientation="vertical" > | 13 | |
13 | 14 | <WebView | |
14 | </LinearLayout> | 15 | android:id="@+id/mycard_web" |
16 | android:layout_width="fill_parent" | ||
17 | android:layout_height="fill_parent" /> | ||
18 | |||
19 | <!-- <LinearLayout --> | ||
20 | <!-- android:id="@+id/container" --> | ||
21 | <!-- android:layout_width="match_parent" --> | ||
22 | <!-- android:layout_height="wrap_content" --> | ||
23 | <!-- android:orientation="vertical" > --> | ||
24 | <!-- </LinearLayout> --> | ||
15 | 25 | ||
16 | </LinearLayout> | 26 | </LinearLayout> |
android/GameSDKSample/project.properties
1 | # This file is automatically generated by Android Tools. | 1 | # This file is automatically generated by Android Tools. |
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! | 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! |
3 | # | 3 | # |
4 | # This file must be checked in Version Control Systems. | 4 | # This file must be checked in Version Control Systems. |
5 | # | 5 | # |
6 | # To customize properties used by the Ant build system edit | 6 | # To customize properties used by the Ant build system edit |
7 | # "ant.properties", and override values to adapt the script to your | 7 | # "ant.properties", and override values to adapt the script to your |
8 | # project structure. | 8 | # project structure. |
9 | # | 9 | # |
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): |
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt |
12 | 12 | ||
13 | # Project target. | 13 | # Project target. |
14 | 14 | ||
15 | target=android-22 | 15 | target=android-21 |
16 | android.library.reference.1=../GameSDKRelease | 16 | android.library.reference.1=../../../../gamesdk/GameSDK |
17 | 17 |
android/GameSDKSample/src/com/gumptech/loginsdk/sample/MainActivity.java
1 | package com.gumptech.loginsdk.sample; | 1 | package com.gumptech.loginsdk.sample; |
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.bean.GumpUser; | 15 | import com.gumptech.sdk.bean.GumpUser; |
16 | import com.gumptech.sdk.bean.PurchaseResult; | 16 | import com.gumptech.sdk.bean.PurchaseResult; |
17 | import com.gumptech.sdk.callback.InitializeCallback; | 17 | import com.gumptech.sdk.callback.InitializeCallback; |
18 | import com.gumptech.sdk.callback.LoginStateListener; | 18 | import com.gumptech.sdk.callback.LoginStateListener; |
19 | import com.gumptech.sdk.callback.PurchaseCallback; | 19 | import com.gumptech.sdk.callback.PurchaseCallback; |
20 | import com.gumpsdk.wuruid.R; | 20 | import com.gumpsdk.wuruid.R; |
21 | 21 | ||
22 | public class MainActivity extends Activity implements PurchaseCallback{ | 22 | public class MainActivity extends Activity implements PurchaseCallback{ |
23 | 23 | ||
24 | private static final String TAG = "MainActivity"; | 24 | private static final String TAG = "MainActivity"; |
25 | 25 | ||
26 | private TextView tvVersion; | 26 | private TextView tvVersion; |
27 | private TextView userInfo; | 27 | private TextView userInfo; |
28 | 28 | ||
29 | private Button btnLoginOrLogout; | 29 | private Button btnLoginOrLogout; |
30 | 30 | ||
31 | private String appId = "10022"; | 31 | private String appId = "10022"; |
32 | private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; | 32 | private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; |
33 | 33 | private String sessionKey; | |
34 | @Override | 34 | |
35 | protected void onCreate(Bundle savedInstanceState) { | 35 | @Override |
36 | super.onCreate(savedInstanceState); | 36 | protected void onCreate(Bundle savedInstanceState) { |
37 | setContentView(R.layout.activity_main); | 37 | super.onCreate(savedInstanceState); |
38 | tvVersion = (TextView) findViewById(R.id.version); | 38 | setContentView(R.layout.activity_main); |
39 | userInfo = (TextView) findViewById(R.id.user_info); | 39 | tvVersion = (TextView) findViewById(R.id.version); |
40 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); | 40 | userInfo = (TextView) findViewById(R.id.user_info); |
41 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | 41 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); |
42 | 42 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | |
43 | @Override | 43 | |
44 | public void onClick(View v) { | 44 | @Override |
45 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 45 | public void onClick(View v) { |
46 | GumpSDK.start(MainActivity.this); | 46 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) |
47 | else | 47 | GumpSDK.start(MainActivity.this); |
48 | GumpSDK.logout(MainActivity.this); | 48 | else |
49 | } | 49 | GumpSDK.logout(MainActivity.this); |
50 | }); | 50 | } |
51 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 51 | }); |
52 | 52 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | |
53 | @Override | 53 | |
54 | public void onClick(View v) { | 54 | @Override |
55 | Bundle payInfo = new Bundle(); | 55 | public void onClick(View v) { |
56 | payInfo.putString("nick", "thi"); | 56 | Bundle payInfo = new Bundle(); |
57 | payInfo.putString("product", "元宝"); | 57 | payInfo.putString("nick", "thi"); |
58 | payInfo.putFloat("amount", 0.0f); | 58 | payInfo.putString("product", "元宝"); |
59 | payInfo.putString("extraInfo", "This is demo!"); | 59 | payInfo.putFloat("amount", 0.0f); |
60 | payInfo.putString("serverId", "5025"); | 60 | payInfo.putString("extraInfo", "This is demo!"); |
61 | GumpSDK.pay(MainActivity.this, payInfo, "7798753", MainActivity.this); | 61 | payInfo.putString("serverId", "100"); |
62 | } | 62 | payInfo.putString("sessionKey", sessionKey); |
63 | }); | 63 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); |
64 | /** | 64 | } |
65 | * 设置否是开启debug模式 | 65 | }); |
66 | */ | 66 | /** |
67 | GumpSDK.setDebugState(true); | 67 | * 设置否是开启debug模式 |
68 | /** | 68 | */ |
69 | * 设置是否启用facebook登录 | 69 | GumpSDK.setDebugState(false); |
70 | */ | 70 | /** |
71 | GumpSDK.setFBEnable(true); | 71 | * 设置是否启用facebook登录 |
72 | /** | 72 | */ |
73 | * 设置是否启用Vk登录 | 73 | GumpSDK.setFBEnable(true); |
74 | */ | 74 | /** |
75 | GumpSDK.setVKEnable(true); | 75 | * 设置是否启用Vk登录 |
76 | /** | 76 | */ |
77 | * 设置屏幕方向 | 77 | GumpSDK.setVKEnable(true); |
78 | */ | 78 | /** |
79 | GumpSDK.setScreenLandscape(false); | 79 | * 设置屏幕方向 |
80 | /** | 80 | */ |
81 | * 设置用户登录状态监听器 | 81 | GumpSDK.setScreenLandscape(true); |
82 | */ | 82 | /** |
83 | GumpSDK.setUserStateListener(new LoginStateListener() { | 83 | * 设置用户登录状态监听器 |
84 | @Override | 84 | */ |
85 | public void onLoginSuccess(GumpUser user) { | 85 | GumpSDK.setUserStateListener(new LoginStateListener() { |
86 | ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | 86 | @Override |
87 | cm.setText(user.getSessionKey()); | 87 | public void onLoginSuccess(GumpUser user) { |
88 | 88 | ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | |
89 | String userType=null; | 89 | cm.setText(user.getSessionKey()); |
90 | switch(user.getAccountType()){ | 90 | sessionKey = user.getSessionKey(); |
91 | case GumpPreference.ACCOUNT_TYPE_FB: | 91 | String userType=null; |
92 | userType = "Facebook登录"; | 92 | switch(user.getAccountType()){ |
93 | break; | 93 | case GumpPreference.ACCOUNT_TYPE_FB: |
94 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | 94 | userType = "Facebook登录"; |
95 | userType = "快速登录"; | 95 | break; |
96 | break; | 96 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: |
97 | case GumpPreference.ACCOUNT_TYPE_REG: | 97 | userType = "快速登录"; |
98 | userType = "gump注册用户"; | 98 | break; |
99 | break; | 99 | case GumpPreference.ACCOUNT_TYPE_REG: |
100 | case GumpPreference.ACCOUNT_TYPE_VK: | 100 | userType = "gump注册用户"; |
101 | userType = "vk登录"; | 101 | break; |
102 | break; | 102 | case GumpPreference.ACCOUNT_TYPE_VK: |
103 | } | 103 | userType = "vk登录"; |
104 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType()+") "+userType + "\n sessionKey:" + user.getSessionKey()); | 104 | break; |
105 | btnLoginOrLogout.setText("Logout"); | 105 | } |
106 | btnLoginOrLogout.setTag(1); | 106 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType()+") "+userType + "\n sessionKey:" + user.getSessionKey()); |
107 | } | 107 | btnLoginOrLogout.setText("Logout"); |
108 | 108 | btnLoginOrLogout.setTag(1); | |
109 | @Override | 109 | } |
110 | public void onLoginFailed(int code, String msg) { | 110 | |
111 | userInfo.setText(msg); | 111 | @Override |
112 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 112 | public void onLoginFailed(int code, String msg) { |
113 | } | 113 | userInfo.setText(msg); |
114 | 114 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | |
115 | @Override | 115 | } |
116 | public void onLoginCanceled() { | 116 | |
117 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 117 | @Override |
118 | } | 118 | public void onLoginCanceled() { |
119 | 119 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | |
120 | @Override | 120 | } |
121 | public void onLogout() { | 121 | |
122 | btnLoginOrLogout.setText("Login"); | 122 | @Override |
123 | btnLoginOrLogout.setTag(0); | 123 | public void onLogout() { |
124 | userInfo.setText("User is logout"); | 124 | btnLoginOrLogout.setText("Login"); |
125 | } | 125 | btnLoginOrLogout.setTag(0); |
126 | }); | 126 | userInfo.setText("User is logout"); |
127 | /** | 127 | } |
128 | * 初始化sdk | 128 | }); |
129 | */ | 129 | /** |
130 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | 130 | * 初始化sdk |
131 | @Override | 131 | */ |
132 | public void initComplete(int result) { | 132 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { |
133 | if (result == GumpSDK.CODE.OK) { | 133 | @Override |
134 | btnLoginOrLogout.setEnabled(true); | 134 | public void initComplete(int result) { |
135 | } | 135 | if (result == GumpSDK.CODE.OK) { |
136 | } | 136 | btnLoginOrLogout.setEnabled(true); |
137 | }); | 137 | } |
138 | 138 | } | |
139 | 139 | }); | |
140 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | 140 | |
141 | } | 141 | |
142 | 142 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | |
143 | @Override | 143 | } |
144 | public void onPurchaseCompleted(PurchaseResult result) { | 144 | |
145 | Log.i(TAG,"purchase completed"); | 145 | @Override |
146 | } | 146 | public void onPurchaseCompleted(PurchaseResult result) { |
147 | 147 | Log.i(TAG,"purchase completed"); | |
148 | @Override | 148 | } |
149 | public void onPurchaseError(int code, String msg) { | 149 | |
150 | Log.i(TAG,"purchase error"); | 150 | @Override |
151 | } | 151 | public void onPurchaseError(int code, String msg) { |
152 | 152 | Log.i(TAG,"purchase error"); | |
153 | @Override | 153 | } |
154 | public void onPurchaseCanceled() { | 154 | |
155 | Log.i(TAG,"purchase canceled"); | 155 | @Override |
156 | } | 156 | public void onPurchaseCanceled() { |
157 | } | 157 | Log.i(TAG,"purchase canceled"); |
158 | } | ||
159 | } | ||
158 | 160 |