Commit f53f15711d7186273c54830f077e6028fccb2263
1 parent
c888d88aa9
Exists in
master
v3.3.11
增加fb web登录 修改若干可能的bug
Showing 4 changed files with 16 additions and 11 deletions Inline Diff
android/GameSDKRelease/libs/GameSDK_v3.3.10_proguard.jar
No preview for this file type
android/GameSDKRelease/libs/GameSDK_v3.3.11_proguard.jar
No preview for this file type
android/GameSDKRelease/res/layout/fragment_web.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 | <FrameLayout 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="@android:color/white" | 5 | android:background="@android:color/white" |
| 6 | android:minHeight="300dp" | ||
| 6 | android:minWidth="293dp" | 7 | android:minWidth="293dp" |
| 7 | android:orientation="vertical" > | 8 | android:orientation="vertical" > |
| 8 | 9 | ||
| 9 | <ProgressBar | ||
| 10 | android:id="@+id/loading_prog" | ||
| 11 | style="@android:style/Widget.ProgressBar.Horizontal" | ||
| 12 | android:layout_width="match_parent" | ||
| 13 | android:layout_height="2dp" /> | ||
| 14 | |||
| 15 | <WebView | 10 | <WebView |
| 16 | android:id="@+id/mycard_web" | 11 | android:id="@+id/mycard_web" |
| 17 | android:layout_width="fill_parent" | 12 | android:layout_width="fill_parent" |
| 18 | android:layout_height="fill_parent" /> | 13 | android:layout_height="fill_parent" /> |
| 19 | 14 | ||
| 20 | </LinearLayout> | ||
| 15 | <ProgressBar | ||
| 16 | android:id="@+id/loading_prog" |
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 = "10031"; | 31 | private String appId = "10022"; |
| 32 | private String appKey = "d2cb583f4b5bdc51b965ae555ee6bca5"; | 32 | private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; |
| 33 | private String sessionKey; | 33 | private String sessionKey; |
| 34 | 34 | ||
| 35 | @Override | 35 | @Override |
| 36 | protected void onCreate(Bundle savedInstanceState) { | 36 | protected void onCreate(Bundle savedInstanceState) { |
| 37 | super.onCreate(savedInstanceState); | 37 | super.onCreate(savedInstanceState); |
| 38 | setContentView(R.layout.activity_main); | 38 | setContentView(R.layout.activity_main); |
| 39 | tvVersion = (TextView) findViewById(R.id.version); | 39 | tvVersion = (TextView) findViewById(R.id.version); |
| 40 | userInfo = (TextView) findViewById(R.id.user_info); | 40 | userInfo = (TextView) findViewById(R.id.user_info); |
| 41 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); | 41 | btnLoginOrLogout = (Button) findViewById(R.id.login_or_logout); |
| 42 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | 42 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { |
| 43 | 43 | ||
| 44 | @Override | 44 | @Override |
| 45 | public void onClick(View v) { | 45 | public void onClick(View v) { |
| 46 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | 46 | if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) |
| 47 | GumpSDK.start(MainActivity.this); | 47 | GumpSDK.start(MainActivity.this); |
| 48 | else | 48 | else |
| 49 | GumpSDK.logout(MainActivity.this); | 49 | GumpSDK.logout(MainActivity.this); |
| 50 | } | 50 | } |
| 51 | }); | 51 | }); |
| 52 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | 52 | findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { |
| 53 | 53 | ||
| 54 | @Override | 54 | @Override |
| 55 | public void onClick(View v) { | 55 | public void onClick(View v) { |
| 56 | Bundle payInfo = new Bundle(); | 56 | Bundle payInfo = new Bundle(); |
| 57 | payInfo.putString("nick", "thi"); | 57 | payInfo.putString("nick", "thi"); |
| 58 | payInfo.putString("product", "元宝"); | 58 | payInfo.putString("product", "元宝"); |
| 59 | payInfo.putFloat("amount", 0.1f); | 59 | payInfo.putFloat("amount", 0.1f); |
| 60 | payInfo.putString("extraInfo", "This is demo!"); | 60 | payInfo.putString("extraInfo", "This is demo!"); |
| 61 | payInfo.putString("serverId", "100"); | 61 | payInfo.putString("serverId", "100"); |
| 62 | payInfo.putString("sessionKey", sessionKey); | 62 | payInfo.putString("sessionKey", sessionKey); |
| 63 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | 63 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); |
| 64 | } | 64 | } |
| 65 | }); | 65 | }); |
| 66 | /** | 66 | /** |
| 67 | * 设置否是开启debug模式 | 67 | * 设置否是开启debug模式 |
| 68 | */ | 68 | */ |
| 69 | GumpSDK.setDebugState(true); | 69 | GumpSDK.setDebugState(true); |
| 70 | /** | 70 | /** |
| 71 | * 设置是否启用facebook登录 | 71 | * 设置是否启用facebook登录 |
| 72 | */ | 72 | */ |
| 73 | GumpSDK.setFBEnable(false); | 73 | GumpSDK.setFBEnable(true); |
| 74 | /** | 74 | /** |
| 75 | * 设置是否启用Vk登录 | 75 | * 设置是否启用Vk登录 |
| 76 | */ | 76 | */ |
| 77 | GumpSDK.setVKEnable(false); | 77 | GumpSDK.setVKEnable(false); |
| 78 | /** | 78 | /** |
| 79 | * 设置屏幕方向 | 79 | * 设置屏幕方向 |
| 80 | */ | 80 | */ |
| 81 | GumpSDK.setScreenLandscape(true); | 81 | GumpSDK.setScreenLandscape(true); |
| 82 | /** | 82 | /** |
| 83 | * 设置用户登录状态监听器 | 83 | * 设置用户登录状态监听器 |
| 84 | */ | 84 | */ |
| 85 | |||
| 86 | // GumpSDK.forceFBWithWeb(); | ||
| 85 | GumpSDK.setUserStateListener(new LoginStateListener() { | 87 | GumpSDK.setUserStateListener(new LoginStateListener() { |
| 86 | @Override | 88 | @Override |
| 87 | public void onLoginSuccess(GumpUser user) { | 89 | public void onLoginSuccess(GumpUser user) { |
| 88 | ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | 90 | ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); |
| 89 | cm.setText(user.getSessionKey()); | 91 | cm.setText(user.getSessionKey()); |
| 90 | sessionKey = user.getSessionKey(); | 92 | sessionKey = user.getSessionKey(); |
| 91 | String userType=null; | 93 | String userType=null; |
| 92 | switch(user.getAccountType()){ | 94 | switch(user.getAccountType()){ |
| 93 | case GumpPreference.ACCOUNT_TYPE_FB: | 95 | case GumpPreference.ACCOUNT_TYPE_FB: |
| 94 | userType = "Facebook登录"; | 96 | userType = "Facebook登录"; |
| 95 | break; | 97 | break; |
| 96 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | 98 | case GumpPreference.ACCOUNT_TYPE_QUICK_REG: |
| 97 | userType = "快速登录"; | 99 | userType = "快速登录"; |
| 98 | break; | 100 | break; |
| 99 | case GumpPreference.ACCOUNT_TYPE_REG: | 101 | case GumpPreference.ACCOUNT_TYPE_REG: |
| 100 | userType = "gump注册用户"; | 102 | userType = "gump注册用户"; |
| 101 | break; | 103 | break; |
| 102 | case GumpPreference.ACCOUNT_TYPE_VK: | 104 | case GumpPreference.ACCOUNT_TYPE_VK: |
| 103 | userType = "vk登录"; | 105 | userType = "vk登录"; |
| 104 | break; | 106 | break; |
| 105 | } | 107 | } |
| 106 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType()+") "+userType + "\n sessionKey:" + user.getSessionKey()); | 108 | userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType()+") "+userType + "\n sessionKey:" + user.getSessionKey()); |
| 107 | btnLoginOrLogout.setText("Logout"); | 109 | btnLoginOrLogout.setText("Logout"); |
| 108 | btnLoginOrLogout.setTag(1); | 110 | btnLoginOrLogout.setTag(1); |
| 109 | } | 111 | } |
| 110 | 112 | ||
| 111 | @Override | 113 | @Override |
| 112 | public void onLoginFailed(int code, String msg) { | 114 | public void onLoginFailed(int code, String msg) { |
| 113 | userInfo.setText(msg); | 115 | userInfo.setText(msg); |
| 114 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 116 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); |
| 115 | } | 117 | } |
| 116 | 118 | ||
| 117 | @Override | 119 | @Override |
| 118 | public void onLoginCanceled() { | 120 | public void onLoginCanceled() { |
| 119 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 121 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
| 120 | } | 122 | } |
| 121 | 123 | ||
| 122 | @Override | 124 | @Override |
| 123 | public void onLogout() { | 125 | public void onLogout() { |
| 124 | btnLoginOrLogout.setText("Login"); | 126 | btnLoginOrLogout.setText("Login"); |
| 125 | btnLoginOrLogout.setTag(0); | 127 | btnLoginOrLogout.setTag(0); |
| 126 | userInfo.setText("User is logout"); | 128 | userInfo.setText("User is logout"); |
| 127 | } | 129 | } |
| 128 | }); | 130 | }); |
| 129 | /** | 131 | /** |
| 130 | * 初始化sdk | 132 | * 初始化sdk |
| 131 | */ | 133 | */ |
| 132 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | 134 | GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { |
| 133 | @Override | 135 | @Override |
| 134 | public void initComplete(int result) { | 136 | public void initComplete(int result) { |
| 135 | if (result == GumpSDK.CODE.OK) { | 137 | if (result == GumpSDK.CODE.OK) { |
| 136 | btnLoginOrLogout.setEnabled(true); | 138 | btnLoginOrLogout.setEnabled(true); |
| 137 | } | 139 | } |
| 138 | } | 140 | } |
| 139 | }); | 141 | }); |
| 140 | 142 | ||
| 141 | 143 | ||
| 142 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | 144 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); |
| 143 | } | 145 | } |
| 144 | 146 | ||
| 145 | @Override | 147 | @Override |
| 146 | public void onPurchaseCompleted(PurchaseResult result) { | 148 | public void onPurchaseCompleted(PurchaseResult result) { |
| 147 | Log.i(TAG,"purchase completed"); | 149 | Log.i(TAG,"purchase completed"); |
| 148 | } | 150 | } |
| 149 | 151 | ||
| 150 | @Override | 152 | @Override |
| 151 | public void onPurchaseError(int code, String msg) { | 153 | public void onPurchaseError(int code, String msg) { |
| 152 | Log.i(TAG,"purchase error"); | 154 | Log.i(TAG,"purchase error"); |
| 153 | } | 155 | } |
| 154 | 156 | ||
| 155 | @Override | 157 | @Override |
| 156 | public void onPurchaseCanceled() { | 158 | public void onPurchaseCanceled() { |
| 157 | Log.i(TAG,"purchase canceled"); | 159 | Log.i(TAG,"purchase canceled"); |
| 158 | } | 160 | } |
| 159 | } | 161 | } |
| 160 | 162 |