diff --git a/GameSDKDemo/build.gradle b/GameSDKDemo/build.gradle
index a3d0d2d..bf19994 100644
--- a/GameSDKDemo/build.gradle
+++ b/GameSDKDemo/build.gradle
@@ -50,7 +50,7 @@ android {
defaultConfig {
minSdkVersion 14
- targetSdkVersion 26
+ targetSdkVersion 27
versionCode 6
versionName "1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -70,10 +70,10 @@ android {
abortOnError false
}
- applicationVariants.all{
- variant->
- variant.outputs.all{
- outputFileName = "GameSDKDemo-"+variant.name+defaultConfig.versionName+".apk"
+ applicationVariants.all {
+ variant ->
+ variant.outputs.all {
+ outputFileName = "GameSDKDemo-" + variant.name + defaultConfig.versionName + ".apk"
}
}
@@ -81,8 +81,12 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
+ implementation 'com.android.support:support-v4:26.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:26.1.0'
-// implementation project(':GameSDK')
- implementation 'com.gumptech.sdk:GameSDK:4.6.3'
+ implementation 'com.android.support:design:26.1.0'
+ implementation project(':GameSDK')
+// implementation project(':IAP5Helper')
+// implementation 'com.gumptech.sdk:GameSDK:4.6.5'
+// implementation 'com.gumptech.sdk:SamsungIAP:5.1.1'
}
diff --git a/GameSDKDemo/release/output.json b/GameSDKDemo/release/output.json
deleted file mode 100644
index cfd725c..0000000
--- a/GameSDKDemo/release/output.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":5,"versionName":"1.3","enabled":true,"outputFile":"GameSDKDemo-release.apk","fullName":"release","baseName":"release"},"path":"GameSDKDemo-release.apk","properties":{}}]
\ No newline at end of file
diff --git a/GameSDKDemo/src/main/AndroidManifest.xml b/GameSDKDemo/src/main/AndroidManifest.xml
index 4430b9b..9b8055e 100644
--- a/GameSDKDemo/src/main/AndroidManifest.xml
+++ b/GameSDKDemo/src/main/AndroidManifest.xml
@@ -9,6 +9,8 @@
+
+
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar"
+ android:screenOrientation="portrait">
-
-
+
+ android:screenOrientation="behind"
+ android:theme="@style/Theme.Translucent">
diff --git a/GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java b/GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
index 9677322..94208b6 100644
--- a/GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
+++ b/GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
@@ -1,7 +1,7 @@
package com.gumptech.sdk.demo;
-import android.app.Activity;
import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@@ -22,7 +22,7 @@ import com.gumptech.sdk.passport.fb.FBAccessToken;
import java.util.Locale;
-public class MainActivity extends Activity implements PurchaseCallback {
+public class MainActivity extends AppCompatActivity implements PurchaseCallback {
private static final String TAG = "MainActivity";
@@ -31,11 +31,21 @@ public class MainActivity extends Activity implements PurchaseCallback {
private Button btnLoginOrLogout;
private Button btnInit;
+ private Button btnCheckState;
+ private Button btnPay;
+ private Button btnIap;
private String appId = "100";
private String appKey = "f899139df5e1059396431415e770c6dd";
private GumpUser gumpUser;
+ /**
+ * 测试数据
+ */
+ String serverId = "100";
+ String roleId = "41080";
+ String product = "test";
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -46,6 +56,7 @@ public class MainActivity extends Activity implements PurchaseCallback {
userInfo = findViewById(R.id.user_info);
btnLoginOrLogout = findViewById(R.id.login_or_logout);
btnInit = findViewById(R.id.init);
+ btnCheckState = findViewById(R.id.check_state);
btnLoginOrLogout.setOnClickListener(new View.OnClickListener() {
@Override
@@ -74,30 +85,59 @@ public class MainActivity extends Activity implements PurchaseCallback {
});
}
});
- findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() {
+ btnCheckState.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+// btnCheckState.setEnabled(false);
+ GumpSDK.shouldUseCoPay(MainActivity.this, serverId, roleId, new ResultCallback() {
+ @Override
+ public void onResult(boolean isRisk) {
+ btnIap.setEnabled(isRisk);
+ btnPay.setEnabled(!isRisk);
+ }
+ });
+ }
+ });
+ btnPay = findViewById(R.id.pay);
+ btnPay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Bundle payInfo = new Bundle();
- payInfo.putString("product", "wa2");
- payInfo.putFloat("amount", 0.1f);
- payInfo.putString("extraInfo", "This is demo!");
- payInfo.putString("serverId", "s1");
- payInfo.putString("roleId", "100123");
- payInfo.putString("sessionKey", gumpUser.getSessionKey().getToken());
- GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this);
+ PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(new PaymentInfoSubmitFragment.OnSubmitListener() {
+ @Override
+ public void onSubmit(Bundle payInfo) {
+ GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this);
+ }
+ });
+// Bundle payInfo = new Bundle();
+// payInfo.putString("product", "test");
+// payInfo.putFloat("amount", 0.1f);
+// payInfo.putString("extraInfo", "This is demo!");
+// payInfo.putString("serverId", "s1");
+// payInfo.putString("roleId", "100123");
+// payInfo.putString("currency", "THB");
+ submitFragment.show(getSupportFragmentManager(), "pay");
}
});
- findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() {
+ btnIap = findViewById(R.id.iap);
+ btnIap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Bundle payInfo = new Bundle();
- payInfo.putString("product", "180010");
- payInfo.putFloat("amount", 0.1f);
- payInfo.putString("extraInfo", "This is demo!");
- payInfo.putString("serverId", "100");
- payInfo.putString("roleId", "100123");
- GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this);
+ PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(new PaymentInfoSubmitFragment.OnSubmitListener() {
+ @Override
+ public void onSubmit(Bundle payInfo) {
+ GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this);
+ }
+ });
+ submitFragment.show(getSupportFragmentManager(), "iap");
+// Bundle payInfo = new Bundle();
+// payInfo.putString("product", "dwe");
+// payInfo.putFloat("amount", 0.1f);
+// payInfo.putString("extraInfo", "This is demo!");
+// payInfo.putString("serverId", serverId);
+// payInfo.putString("roleId", "100123");
+// payInfo.putString("currency", "THB");
+// GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this);
}
});
@@ -123,10 +163,6 @@ public class MainActivity extends Activity implements PurchaseCallback {
* 设置启用Line登录
*/
GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE);
- /**
- * 设置屏幕方向
- */
- GumpSDK.getSettings().setScreenLandscape(true);
/**
* 设置支付版本
@@ -140,6 +176,7 @@ public class MainActivity extends Activity implements PurchaseCallback {
GumpSDK.setUserStateListener(new LoginStateListener() {
@Override
public void onLoginSuccess(GumpUser user) {
+ btnCheckState.setEnabled(true);
gumpUser = user;
String userType = null;
switch (user.getAccountType()) {
@@ -204,6 +241,7 @@ public class MainActivity extends Activity implements PurchaseCallback {
if (result == GumpSDK.CODE.OK) {
btnLoginOrLogout.setEnabled(true);
userInfo.setText("initialization has finished");
+
//checkRisk();
} else {
btnInit.setEnabled(true);
diff --git a/GameSDKDemo/src/main/java/com/gumptech/sdk/demo/PaymentInfoSubmitFragment.java b/GameSDKDemo/src/main/java/com/gumptech/sdk/demo/PaymentInfoSubmitFragment.java
new file mode 100644
index 0000000..e205061
--- /dev/null
+++ b/GameSDKDemo/src/main/java/com/gumptech/sdk/demo/PaymentInfoSubmitFragment.java
@@ -0,0 +1,149 @@
+package com.gumptech.sdk.demo;
+
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.design.widget.TextInputLayout;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.app.Fragment;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.view.LayoutInflater;
+import android.view.View;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class PaymentInfoSubmitFragment extends DialogFragment {
+
+ interface OnSubmitListener {
+ void onSubmit(Bundle payInfo);
+ }
+
+ private OnSubmitListener listener;
+
+ TextInputLayout etProduct,
+ etAmount,
+ etCurrency,
+ etServerId,
+ etRoleId,
+ etExtra;
+
+ public PaymentInfoSubmitFragment() {
+
+ }
+
+ public static PaymentInfoSubmitFragment newInstance(OnSubmitListener listener) {
+ PaymentInfoSubmitFragment fragment = new PaymentInfoSubmitFragment();
+ fragment.listener = listener;
+ return fragment;
+ }
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ View view = LayoutInflater.from(getContext()).inflate(R.layout.fragment_payment, null, false);
+ etProduct = view.findViewById(R.id.product);
+ etAmount = view.findViewById(R.id.amount);
+ etCurrency = view.findViewById(R.id.currency);
+ etServerId = view.findViewById(R.id.server_id);
+ etRoleId = view.findViewById(R.id.role_id);
+ etExtra = view.findViewById(R.id.extra);
+ etProduct.getEditText().addTextChangedListener(new EditTextWatcher(etProduct));
+ etAmount.getEditText().addTextChangedListener(new EditTextWatcher(etAmount));
+ etCurrency.getEditText().addTextChangedListener(new EditTextWatcher(etCurrency));
+ etServerId.getEditText().addTextChangedListener(new EditTextWatcher(etServerId));
+ etRoleId.getEditText().addTextChangedListener(new EditTextWatcher(etRoleId));
+ etExtra.getEditText().addTextChangedListener(new EditTextWatcher(etExtra));
+ //设置默认值
+ etProduct.getEditText().setText("EV1.test.abc");
+ etAmount.getEditText().setText("0.99");
+ etCurrency.getEditText().setText("USD");
+ etServerId.getEditText().setText("100");
+ etRoleId.getEditText().setText("41080");
+ view.findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String product = etProduct.getEditText().getText().toString();
+ String currency = etCurrency.getEditText().getText().toString();
+ String serverId = etServerId.getEditText().getText().toString();
+ String roleId = etRoleId.getEditText().getText().toString();
+ String extra = etExtra.getEditText().getText().toString();
+ String amount = etAmount.getEditText().getText().toString();
+ if (checkInput(product, amount, currency, serverId, roleId, extra)) {
+ Bundle payInfo = new Bundle();
+ payInfo.putString("product", product);
+ payInfo.putFloat("amount", Float.valueOf(amount));
+ payInfo.putString("extraInfo", extra);
+ payInfo.putString("serverId", serverId);
+ payInfo.putString("roleId", roleId);
+ payInfo.putString("currency", currency);
+ if (listener != null) {
+ listener.onSubmit(payInfo);
+ }
+ dismiss();
+ }
+ }
+ });
+ AlertDialog dialog = builder.setView(view).create();
+ return dialog;
+ }
+
+
+ private boolean checkInput(String product, String amount, String currency, String serverId, String roleId, String extra) {
+ if (TextUtils.isEmpty(product)) {
+ etProduct.setError("product is empty");
+ return false;
+ }
+ if (TextUtils.isEmpty(currency)) {
+ etCurrency.setError("currency is empty");
+ return false;
+ }
+ if (TextUtils.isEmpty(serverId)) {
+ etServerId.setError("serverId is empty");
+ return false;
+ }
+ if (TextUtils.isEmpty(roleId)) {
+ etRoleId.setError("roleId is empty");
+ return false;
+ }
+ if (TextUtils.isEmpty(extra)) {
+ etExtra.setError("extra is empty");
+ return false;
+ }
+ if (TextUtils.isEmpty(amount)) {
+ etAmount.setError("amount is empty");
+ return false;
+ }
+ return true;
+ }
+
+ class EditTextWatcher implements TextWatcher {
+
+ private TextInputLayout editText;
+
+ public EditTextWatcher(TextInputLayout editText) {
+ this.editText = editText;
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ editText.setError(null);
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+
+ }
+ }
+}
diff --git a/GameSDKDemo/src/main/res/layout/activity_main.xml b/GameSDKDemo/src/main/res/layout/activity_main.xml
index 8f49e12..98ec4a6 100644
--- a/GameSDKDemo/src/main/res/layout/activity_main.xml
+++ b/GameSDKDemo/src/main/res/layout/activity_main.xml
@@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:backgroundTint="@color/g_color"
android:enabled="false"
- android:text="Initialize"/>
+ android:text="@string/init"/>
+ android:text="@string/login"/>
+
+
+ android:enabled="false"
+ android:text="@string/iap"/>
+ android:enabled="false"
+ android:text="@string/pay"/>
\ No newline at end of file
diff --git a/GameSDKDemo/src/main/res/layout/fragment_payment.xml b/GameSDKDemo/src/main/res/layout/fragment_payment.xml
new file mode 100644
index 0000000..11b51ae
--- /dev/null
+++ b/GameSDKDemo/src/main/res/layout/fragment_payment.xml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GameSDKDemo/src/main/res/values-zh/strings.xml b/GameSDKDemo/src/main/res/values-zh/strings.xml
new file mode 100644
index 0000000..d0bd82f
--- /dev/null
+++ b/GameSDKDemo/src/main/res/values-zh/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ GameSDKSample
+
+ 初始化
+ 登录
+ 检查支付状态
+ 官方支付(无弹窗)
+ 弹窗支付
+
+
+ 商品id/商品名
+ 金额
+ 货币代码
+ serverId
+ roleId
+ 游戏透传信息(extraInfo)
+ 去支付
+
+
\ No newline at end of file
diff --git a/GameSDKDemo/src/main/res/values/strings.xml b/GameSDKDemo/src/main/res/values/strings.xml
index 77c965c..63ca08c 100644
--- a/GameSDKDemo/src/main/res/values/strings.xml
+++ b/GameSDKDemo/src/main/res/values/strings.xml
@@ -2,8 +2,20 @@
GameSDKSample
- Hello world!
- Settings
-
+
+ Initialize
+ Login
+ Check payemnt state
+ IAP
+ Pay
+
+ product
+ amount
+ currency
+ serverId
+ roleId
+ extraInfo
+ Submit
+
\ No newline at end of file
diff --git a/README.md b/README.md
index e608ea7..96990b8 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Gump SDK 4 for Android接入文档
-V4.6.3
-2018年10月23日
+V4.7.0
+2019年02月21日
## 版本概述
@@ -19,7 +19,7 @@ V4.6.3
}
}
dependencies {
- implementation 'com.gumptech.sdk:GameSDK:4.6.3'
+ implementation 'com.gumptech.sdk:GameSDK:4.7.0'
}
@@ -34,18 +34,13 @@ V4.6.3
其次注册相应的Activity,具体如下:
-
-
+
+ android:screenOrientation="behind"
+ android:theme="@style/Theme.Translucent" >
@@ -61,11 +56,7 @@ V4.6.3
*是否打印debug日志
- GumpSDK.getSettings().enableDebugLogging(true);
-
-*横竖屏控制,默认为横屏,参数为false即为竖屏
-
- GumpSDK.getSettings().setScreenLandscape(true);
+ GumpSDK.getSettings().enableDebugLogging(true);
*设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明
@@ -127,18 +118,30 @@ InitializeCallback为初始化回调接口,此接口只有一个回调方法init
gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法
#### 3.支付功能
-1)使用gump通行证登录,其中除nick外所有参数为必传参数
+调用支付前需先获取支付状态,根据状态调用支付方法
+
+ GumpSDK.shouldUseCoPay(Activity, serverId, roleId, new ResultCallback() {
+ @Override
+ public void onResult(boolean result) {
+ if(result){
+ //调用GumpSDK.iap
+ }else{
+ //调用GumpSDK.pay
+ }
+ }
+ });
+
+1)调用GumpSDK.pay
Bundle payInfo = new Bundle();
- payInfo.putString("nick", "thi");
payInfo.putString("product", "元宝");
payInfo.putFloat("amount", 40.0f);
payInfo.putString("extraInfo", "This is demo!");
payInfo.putString("serverId", "B4003");
payInfo.putString("roleId", "10010");
- payInfo.putString("sessionKey","sessionkey");
+ payInfo.putString("currency","currency");
GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback);
-调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey
+调用pay方法时,必须穿入一个bundle对象,包含如上字段,所有字段必须全部包含
2)IAP支付