From 9e8388286bb79ba341ba372bb3eb3ff63e124483 Mon Sep 17 00:00:00 2001 From: King Date: Thu, 6 Jun 2019 11:20:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=A6=E5=8F=B7=E7=BB=91?= =?UTF-8?q?=E5=AE=9A,=E5=A2=9E=E5=8A=A0=E8=B4=A6=E5=8F=B7=E8=81=94?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 38 ++++++++++++++-------- app/build.gradle | 6 ++-- .../java/com/gump/passport/demo/MainActivity.java | 31 +++++++++++------- app/src/main/res/layout/activity_main.xml | 10 ++---- 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index efee6e8..53ea5a8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Gump SDK 5 for Android接入文档 -V5.1.0 -2019年03月18日 +V5.2.2 +2019年06月06日 ## 版本概述 @@ -21,12 +21,10 @@ V5.1.0 } } dependencies { - //基础功能依赖,必须 - implementation 'com.gump:base:5.1.0' //登录功能依赖 - implementation 'com.gump:Passport:5.1.0' + implementation 'com.gump:Passport:5.2.2' //支付功能依赖 - implementation 'com.gump:Payment:5.1.0' + implementation 'com.gump:Payment:5.1.2' } ### 2.修改AndroidManifest.xml文件 @@ -81,6 +79,12 @@ AndroidManifest.xml配置: //失败回调 void onActionFailured() +Actinos枚举: + + SIGN 登录 + SWITCH_PENDING 切换PlayGame账号,需重启游戏 + SWITCH 已切换甘普账号,需重新加载用户角色信息 + 接下来,添加生命周期处理方法 @Override @@ -97,17 +101,16 @@ AndroidManifest.xml配置: super.onActivityResult(requestCode, resultCode, data); } -### 3.3 账号绑定 +### 3.3 账号联动 passport.link(Activity); ### 3.4 账号切换 -切换到系统账号 +切换到PlayGame账号 + + passport.switchAccount(); - passport.switchAccount(PlayerType.GamePlayer); -切换gump账号 - passport.switchAccount(PlayerType.GumpPlayer); ### 3.5 支付接入 注册相应的Activity,具体如下: @@ -127,7 +130,16 @@ AndroidManifest.xml配置: -三方支付调用 +1)判断是否使用三方支付 + + Payment.shouldUseCoPay(this, serverId, roleId, new ResultCallback() { + @Override + public void onResult(boolean isRisk) { + //isRisk==true时使用IAB支付,isRisk==false时使用三方支付 + } + }); + +2)三方支付调用 Bundle payInfo = new Bundle(); payInfo.putString("product", "wa2"); @@ -137,7 +149,7 @@ AndroidManifest.xml配置: payInfo.putString("roleId", "41080"); Payment.pay(Activity, payInfo, PurchaseCallback); -Google IAB支付调用 +3)Google IAB支付调用 Bundle payInfo = new Bundle(); payInfo.putString("product", "180010"); diff --git a/app/build.gradle b/app/build.gradle index 1239853..f2bb101 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,12 +39,12 @@ dependencies { testImplementation 'junit:junit:4.12' //基础功能依赖,必须 - implementation 'com.gump:base:5.1.0' +// implementation 'com.gump:base:5.1.1' // implementation project(':base') // 登录功能依赖 - implementation 'com.gump:Passport:5.1.0' + implementation 'com.gump:Passport:5.2.2' // implementation project(':passport') //支付功能依赖 - implementation 'com.gump:Payment:5.1.0' + implementation 'com.gump:Payment:5.1.2' // implementation project(':payment') } diff --git a/app/src/main/java/com/gump/passport/demo/MainActivity.java b/app/src/main/java/com/gump/passport/demo/MainActivity.java index a57b9be..a278bb6 100644 --- a/app/src/main/java/com/gump/passport/demo/MainActivity.java +++ b/app/src/main/java/com/gump/passport/demo/MainActivity.java @@ -18,7 +18,6 @@ import com.gump.SDKAgent; import com.gump.gpassport.Actions; import com.gump.gpassport.GamePlayer; import com.gump.gpassport.Passport; -import com.gump.gpassport.PlayerType; import com.gump.gpassport.StateListener; import com.gump.payment.Payment; import com.gump.payment.callback.PurchaseCallback; @@ -78,38 +77,42 @@ public class MainActivity extends AppCompatActivity implements StateListener, Pu } }); - mainLayout.findViewById(R.id.bind).setOnClickListener(new View.OnClickListener() { + /** + * gump账号联动 + */ + mainLayout.findViewById(R.id.link).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { passport.link(MainActivity.this); } }); + /** + * 切换PlayGames账号 + */ mainLayout.findViewById(R.id.switch_acc).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - passport.switchAccount(PlayerType.GamePlayer); + passport.switchAccount(); } }); - mainLayout.findViewById(R.id.switch_gump).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - passport.switchAccount(PlayerType.GumpPlayer); - } - }); - - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); boolean mode = sp.getBoolean("key_mode", true); String appId = sp.getString("key_appid", "100"); String channel = sp.getString("key_channel", "1000"); String payVersion = sp.getString("key_pay_version", "V3"); + /** + * SDK配置 + */ SDKAgent.init(getApplicationContext(), appId, channel); SDKAgent.getSettings().setDebug(mode); SDKAgent.getSettings().setPaymentVersion(PaymentVersion.valueOf(payVersion)); + /** + * 实例化登录功能 + */ passport = new Passport.Builder().context(MainActivity.this).setListener(MainActivity.this).build(); } @@ -179,7 +182,11 @@ public class MainActivity extends AppCompatActivity implements StateListener, Pu btnLogin.setVisibility(View.GONE); mainLayout.setVisibility(View.VISIBLE); break; - case SWITCH: + case SWITCH_PENDING://将要切换PlayGame账号 + tvInfo.setText("The player wanna to switch Account!"); + Toast.makeText(this, "The account will be switched!", Toast.LENGTH_LONG).show(); + break; + case SWITCH://账号已切换 tvInfo.setText("Switch account succed! Pls reboot the game!"); Toast.makeText(this, "The account has switched,pls reboot the Game!", Toast.LENGTH_LONG).show(); break; diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 9d0ab73..5c2a741 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -34,10 +34,10 @@ android:text="check payemnt state"/>