Commit 9e8388286bb79ba341ba372bb3eb3ff63e124483

Authored by 赵康
1 parent f905cc4105
Exists in master

修改账号绑定,增加账号联动

Showing 4 changed files with 49 additions and 36 deletions Side-by-side Diff

1 1 # Gump SDK 5 for Android接入文档
2 2  
3   -V5.1.0
4   -2019年03月18日
  3 +V5.2.2
  4 +2019年06月06日
5 5  
6 6 ## 版本概述
7 7  
... ... @@ -21,12 +21,10 @@ V5.1.0
21 21 }
22 22 }
23 23 dependencies {
24   - //基础功能依赖,必须
25   - implementation 'com.gump:base:5.1.0'
26 24 //登录功能依赖
27   - implementation 'com.gump:Passport:5.1.0'
  25 + implementation 'com.gump:Passport:5.2.2'
28 26 //支付功能依赖
29   - implementation 'com.gump:Payment:5.1.0'
  27 + implementation 'com.gump:Payment:5.1.2'
30 28 }
31 29  
32 30 ### 2.修改AndroidManifest.xml文件
... ... @@ -81,6 +79,12 @@ AndroidManifest.xml配置:
81 79 //失败回调
82 80 void onActionFailured()
83 81  
  82 +Actinos枚举:
  83 +
  84 + SIGN 登录
  85 + SWITCH_PENDING 切换PlayGame账号,需重启游戏
  86 + SWITCH 已切换甘普账号,需重新加载用户角色信息
  87 +
84 88 接下来,添加生命周期处理方法
85 89  
86 90 @Override
... ... @@ -97,17 +101,16 @@ AndroidManifest.xml配置:
97 101 super.onActivityResult(requestCode, resultCode, data);
98 102 }
99 103  
100   -### 3.3 账号绑定
  104 +### 3.3 账号联动
101 105  
102 106 passport.link(Activity);
103 107  
104 108 ### 3.4 账号切换
105   -切换到系统账号
  109 +切换到PlayGame账号
  110 +
  111 + passport.switchAccount();
106 112  
107   - passport.switchAccount(PlayerType.GamePlayer);
108   -切换gump账号
109 113  
110   - passport.switchAccount(PlayerType.GumpPlayer);
111 114 ### 3.5 支付接入
112 115 注册相应的Activity,具体如下:
113 116  
... ... @@ -127,7 +130,16 @@ AndroidManifest.xml配置:
127 130 </intent-filter>
128 131 </activity>
129 132  
130   -三方支付调用
  133 +1)判断是否使用三方支付
  134 +
  135 + Payment.shouldUseCoPay(this, serverId, roleId, new ResultCallback() {
  136 + @Override
  137 + public void onResult(boolean isRisk) {
  138 + //isRisk==true时使用IAB支付,isRisk==false时使用三方支付
  139 + }
  140 + });
  141 +
  142 +2)三方支付调用
131 143  
132 144 Bundle payInfo = new Bundle();
133 145 payInfo.putString("product", "wa2");
... ... @@ -137,7 +149,7 @@ AndroidManifest.xml配置:
137 149 payInfo.putString("roleId", "41080");
138 150 Payment.pay(Activity, payInfo, PurchaseCallback);
139 151  
140   -Google IAB支付调用
  152 +3)Google IAB支付调用
141 153  
142 154 Bundle payInfo = new Bundle();
143 155 payInfo.putString("product", "180010");
... ... @@ -39,12 +39,12 @@ dependencies {
39 39 testImplementation 'junit:junit:4.12'
40 40  
41 41 //基础功能依赖,必须
42   - implementation 'com.gump:base:5.1.0'
  42 +// implementation 'com.gump:base:5.1.1'
43 43 // implementation project(':base')
44 44 // 登录功能依赖
45   - implementation 'com.gump:Passport:5.1.0'
  45 + implementation 'com.gump:Passport:5.2.2'
46 46 // implementation project(':passport')
47 47 //支付功能依赖
48   - implementation 'com.gump:Payment:5.1.0'
  48 + implementation 'com.gump:Payment:5.1.2'
49 49 // implementation project(':payment')
50 50 }
app/src/main/java/com/gump/passport/demo/MainActivity.java
... ... @@ -18,7 +18,6 @@ import com.gump.SDKAgent;
18 18 import com.gump.gpassport.Actions;
19 19 import com.gump.gpassport.GamePlayer;
20 20 import com.gump.gpassport.Passport;
21   -import com.gump.gpassport.PlayerType;
22 21 import com.gump.gpassport.StateListener;
23 22 import com.gump.payment.Payment;
24 23 import com.gump.payment.callback.PurchaseCallback;
... ... @@ -78,38 +77,42 @@ public class MainActivity extends AppCompatActivity implements StateListener, Pu
78 77 }
79 78 });
80 79  
81   - mainLayout.findViewById(R.id.bind).setOnClickListener(new View.OnClickListener() {
  80 + /**
  81 + * gump账号联动
  82 + */
  83 + mainLayout.findViewById(R.id.link).setOnClickListener(new View.OnClickListener() {
82 84 @Override
83 85 public void onClick(View v) {
84 86 passport.link(MainActivity.this);
85 87 }
86 88 });
87 89  
  90 + /**
  91 + * 切换PlayGames账号
  92 + */
88 93 mainLayout.findViewById(R.id.switch_acc).setOnClickListener(new View.OnClickListener() {
89 94 @Override
90 95 public void onClick(View v) {
91   - passport.switchAccount(PlayerType.GamePlayer);
  96 + passport.switchAccount();
92 97 }
93 98 });
94 99  
95   - mainLayout.findViewById(R.id.switch_gump).setOnClickListener(new View.OnClickListener() {
96   - @Override
97   - public void onClick(View v) {
98   - passport.switchAccount(PlayerType.GumpPlayer);
99   - }
100   - });
101   -
102   -
103 100 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
104 101 boolean mode = sp.getBoolean("key_mode", true);
105 102 String appId = sp.getString("key_appid", "100");
106 103 String channel = sp.getString("key_channel", "1000");
107 104 String payVersion = sp.getString("key_pay_version", "V3");
108 105  
  106 + /**
  107 + * SDK配置
  108 + */
109 109 SDKAgent.init(getApplicationContext(), appId, channel);
110 110 SDKAgent.getSettings().setDebug(mode);
111 111 SDKAgent.getSettings().setPaymentVersion(PaymentVersion.valueOf(payVersion));
112 112  
  113 + /**
  114 + * 实例化登录功能
  115 + */
113 116 passport = new Passport.Builder().context(MainActivity.this).setListener(MainActivity.this).build();
114 117  
115 118 }
... ... @@ -179,7 +182,11 @@ public class MainActivity extends AppCompatActivity implements StateListener, Pu
179 182 btnLogin.setVisibility(View.GONE);
180 183 mainLayout.setVisibility(View.VISIBLE);
181 184 break;
182   - case SWITCH:
  185 + case SWITCH_PENDING://将要切换PlayGame账号
  186 + tvInfo.setText("The player wanna to switch Account!");
  187 + Toast.makeText(this, "The account will be switched!", Toast.LENGTH_LONG).show();
  188 + break;
  189 + case SWITCH://账号已切换
183 190 tvInfo.setText("Switch account succed! Pls reboot the game!");
184 191 Toast.makeText(this, "The account has switched,pls reboot the Game!", Toast.LENGTH_LONG).show();
185 192 break;
app/src/main/res/layout/activity_main.xml
... ... @@ -34,10 +34,10 @@
34 34 android:text="check payemnt state"/>
35 35  
36 36 <Button
37   - android:id="@+id/bind"
  37 + android:id="@+id/link"
38 38 android:layout_width="match_parent"
39 39 android:layout_height="wrap_content"
40   - android:text="Bind Gump account"/>
  40 + android:text="Link Gump account"/>
41 41  
42 42 <Button
43 43 android:id="@+id/switch_acc"
... ... @@ -46,12 +46,6 @@
46 46 android:text="Switch to games player"/>
47 47  
48 48 <Button
49   - android:id="@+id/switch_gump"
50   - android:layout_width="match_parent"
51   - android:layout_height="wrap_content"
52   - android:text="Switch to gump player"/>
53   -
54   - <Button
55 49 android:id="@+id/iab"
56 50 android:layout_width="match_parent"
57 51 android:layout_height="wrap_content"