Commit fbcd9c5022789e94f91915bb7a72a31a7f885064

Authored by 赵康
1 parent b53b3a3068
Exists in master

release3.3.5

升级支付接口到v3

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