Commit 4a6edc661e93caa3d9c38c4b19efc9a94b091819
1 parent
7bcb33a927
Exists in
master
SDK v4.7.0:增加支付弹窗;修改loading样式;增加支付状态接口;增加三星支付接口;订单信息可修改
Showing 10 changed files with 390 additions and 67 deletions Side-by-side Diff
- GameSDKDemo/build.gradle
- GameSDKDemo/release/output.json
- GameSDKDemo/src/main/AndroidManifest.xml
- GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
- GameSDKDemo/src/main/java/com/gumptech/sdk/demo/PaymentInfoSubmitFragment.java
- GameSDKDemo/src/main/res/layout/activity_main.xml
- GameSDKDemo/src/main/res/layout/fragment_payment.xml
- GameSDKDemo/src/main/res/values-zh/strings.xml
- GameSDKDemo/src/main/res/values/strings.xml
- README.md
GameSDKDemo/build.gradle
| ... | ... | @@ -50,7 +50,7 @@ android { |
| 50 | 50 | |
| 51 | 51 | defaultConfig { |
| 52 | 52 | minSdkVersion 14 |
| 53 | - targetSdkVersion 26 | |
| 53 | + targetSdkVersion 27 | |
| 54 | 54 | versionCode 6 |
| 55 | 55 | versionName "1.4" |
| 56 | 56 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
| ... | ... | @@ -70,10 +70,10 @@ android { |
| 70 | 70 | abortOnError false |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - applicationVariants.all{ | |
| 74 | - variant-> | |
| 75 | - variant.outputs.all{ | |
| 76 | - outputFileName = "GameSDKDemo-"+variant.name+defaultConfig.versionName+".apk" | |
| 73 | + applicationVariants.all { | |
| 74 | + variant -> | |
| 75 | + variant.outputs.all { | |
| 76 | + outputFileName = "GameSDKDemo-" + variant.name + defaultConfig.versionName + ".apk" | |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| ... | ... | @@ -81,8 +81,12 @@ android { |
| 81 | 81 | |
| 82 | 82 | dependencies { |
| 83 | 83 | implementation fileTree(include: ['*.jar'], dir: 'libs') |
| 84 | + implementation 'com.android.support:support-v4:26.1.0' | |
| 84 | 85 | testImplementation 'junit:junit:4.12' |
| 85 | 86 | implementation 'com.android.support:appcompat-v7:26.1.0' |
| 86 | -// implementation project(':GameSDK') | |
| 87 | - implementation 'com.gumptech.sdk:GameSDK:4.6.3' | |
| 87 | + implementation 'com.android.support:design:26.1.0' | |
| 88 | + implementation project(':GameSDK') | |
| 89 | +// implementation project(':IAP5Helper') | |
| 90 | +// implementation 'com.gumptech.sdk:GameSDK:4.6.5' | |
| 91 | +// implementation 'com.gumptech.sdk:SamsungIAP:5.1.1' | |
| 88 | 92 | } |
GameSDKDemo/release/output.json
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -[{"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":{}}] | |
| 2 | 0 | \ No newline at end of file |
GameSDKDemo/src/main/AndroidManifest.xml
| ... | ... | @@ -9,6 +9,8 @@ |
| 9 | 9 | |
| 10 | 10 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
| 11 | 11 | <uses-permission android:name="com.android.vending.BILLING"/> |
| 12 | + <!--samgung iap need this permission--> | |
| 13 | + <uses-permission android:name="com.samsung.android.iap.permission.BILLING"/> | |
| 12 | 14 | |
| 13 | 15 | <application |
| 14 | 16 | android:allowBackup="true" |
| ... | ... | @@ -18,25 +20,21 @@ |
| 18 | 20 | android:name="com.gumptech.sdk.demo.MainActivity" |
| 19 | 21 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 20 | 22 | android:label="@string/app_name" |
| 21 | - android:screenOrientation="landscape"> | |
| 23 | + android:theme="@style/Theme.AppCompat.Light.NoActionBar" | |
| 24 | + android:screenOrientation="portrait"> | |
| 22 | 25 | <intent-filter> |
| 23 | 26 | <action android:name="android.intent.action.MAIN"/> |
| 24 | 27 | |
| 25 | 28 | <category android:name="android.intent.category.LAUNCHER"/> |
| 26 | 29 | </intent-filter> |
| 27 | 30 | </activity> |
| 28 | - <activity | |
| 29 | - android:name="com.gumptech.sdk.ContainerActivity" | |
| 30 | - android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | |
| 31 | - android:launchMode="singleTask" | |
| 32 | - android:theme="@style/Theme.TransparentWin" | |
| 33 | - android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> | |
| 34 | - </activity> | |
| 31 | + | |
| 35 | 32 | <activity |
| 36 | 33 | android:name="com.gumptech.sdk.PaymentActivity" |
| 37 | 34 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 38 | 35 | android:launchMode="singleTask" |
| 39 | - android:theme="@android:style/Theme.Light.NoTitleBar"> | |
| 36 | + android:screenOrientation="behind" | |
| 37 | + android:theme="@style/Theme.Translucent"> | |
| 40 | 38 | <intent-filter> |
| 41 | 39 | <category android:name="android.intent.category.DEFAULT"/> |
| 42 | 40 |
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
| 1 | 1 | package com.gumptech.sdk.demo; |
| 2 | 2 | |
| 3 | -import android.app.Activity; | |
| 4 | 3 | import android.os.Bundle; |
| 4 | +import android.support.v7.app.AppCompatActivity; | |
| 5 | 5 | import android.util.Log; |
| 6 | 6 | import android.view.View; |
| 7 | 7 | import android.widget.Button; |
| ... | ... | @@ -22,7 +22,7 @@ import com.gumptech.sdk.passport.fb.FBAccessToken; |
| 22 | 22 | |
| 23 | 23 | import java.util.Locale; |
| 24 | 24 | |
| 25 | -public class MainActivity extends Activity implements PurchaseCallback { | |
| 25 | +public class MainActivity extends AppCompatActivity implements PurchaseCallback { | |
| 26 | 26 | |
| 27 | 27 | private static final String TAG = "MainActivity"; |
| 28 | 28 | |
| ... | ... | @@ -31,11 +31,21 @@ public class MainActivity extends Activity implements PurchaseCallback { |
| 31 | 31 | |
| 32 | 32 | private Button btnLoginOrLogout; |
| 33 | 33 | private Button btnInit; |
| 34 | + private Button btnCheckState; | |
| 35 | + private Button btnPay; | |
| 36 | + private Button btnIap; | |
| 34 | 37 | |
| 35 | 38 | private String appId = "100"; |
| 36 | 39 | private String appKey = "f899139df5e1059396431415e770c6dd"; |
| 37 | 40 | private GumpUser gumpUser; |
| 38 | 41 | |
| 42 | + /** | |
| 43 | + * 测试数据 | |
| 44 | + */ | |
| 45 | + String serverId = "100"; | |
| 46 | + String roleId = "41080"; | |
| 47 | + String product = "test"; | |
| 48 | + | |
| 39 | 49 | |
| 40 | 50 | @Override |
| 41 | 51 | protected void onCreate(Bundle savedInstanceState) { |
| ... | ... | @@ -46,6 +56,7 @@ public class MainActivity extends Activity implements PurchaseCallback { |
| 46 | 56 | userInfo = findViewById(R.id.user_info); |
| 47 | 57 | btnLoginOrLogout = findViewById(R.id.login_or_logout); |
| 48 | 58 | btnInit = findViewById(R.id.init); |
| 59 | + btnCheckState = findViewById(R.id.check_state); | |
| 49 | 60 | btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { |
| 50 | 61 | |
| 51 | 62 | @Override |
| ... | ... | @@ -74,30 +85,59 @@ public class MainActivity extends Activity implements PurchaseCallback { |
| 74 | 85 | }); |
| 75 | 86 | } |
| 76 | 87 | }); |
| 77 | - findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { | |
| 88 | + btnCheckState.setOnClickListener(new View.OnClickListener() { | |
| 89 | + @Override | |
| 90 | + public void onClick(View v) { | |
| 91 | +// btnCheckState.setEnabled(false); | |
| 92 | + GumpSDK.shouldUseCoPay(MainActivity.this, serverId, roleId, new ResultCallback() { | |
| 93 | + @Override | |
| 94 | + public void onResult(boolean isRisk) { | |
| 95 | + btnIap.setEnabled(isRisk); | |
| 96 | + btnPay.setEnabled(!isRisk); | |
| 97 | + } | |
| 98 | + }); | |
| 99 | + } | |
| 100 | + }); | |
| 101 | + btnPay = findViewById(R.id.pay); | |
| 102 | + btnPay.setOnClickListener(new View.OnClickListener() { | |
| 78 | 103 | |
| 79 | 104 | @Override |
| 80 | 105 | public void onClick(View v) { |
| 81 | - Bundle payInfo = new Bundle(); | |
| 82 | - payInfo.putString("product", "wa2"); | |
| 83 | - payInfo.putFloat("amount", 0.1f); | |
| 84 | - payInfo.putString("extraInfo", "This is demo!"); | |
| 85 | - payInfo.putString("serverId", "s1"); | |
| 86 | - payInfo.putString("roleId", "100123"); | |
| 87 | - payInfo.putString("sessionKey", gumpUser.getSessionKey().getToken()); | |
| 88 | - GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | |
| 106 | + PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(new PaymentInfoSubmitFragment.OnSubmitListener() { | |
| 107 | + @Override | |
| 108 | + public void onSubmit(Bundle payInfo) { | |
| 109 | + GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | |
| 110 | + } | |
| 111 | + }); | |
| 112 | +// Bundle payInfo = new Bundle(); | |
| 113 | +// payInfo.putString("product", "test"); | |
| 114 | +// payInfo.putFloat("amount", 0.1f); | |
| 115 | +// payInfo.putString("extraInfo", "This is demo!"); | |
| 116 | +// payInfo.putString("serverId", "s1"); | |
| 117 | +// payInfo.putString("roleId", "100123"); | |
| 118 | +// payInfo.putString("currency", "THB"); | |
| 119 | + submitFragment.show(getSupportFragmentManager(), "pay"); | |
| 89 | 120 | } |
| 90 | 121 | }); |
| 91 | - findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { | |
| 122 | + btnIap = findViewById(R.id.iap); | |
| 123 | + btnIap.setOnClickListener(new View.OnClickListener() { | |
| 92 | 124 | @Override |
| 93 | 125 | public void onClick(View v) { |
| 94 | - Bundle payInfo = new Bundle(); | |
| 95 | - payInfo.putString("product", "180010"); | |
| 96 | - payInfo.putFloat("amount", 0.1f); | |
| 97 | - payInfo.putString("extraInfo", "This is demo!"); | |
| 98 | - payInfo.putString("serverId", "100"); | |
| 99 | - payInfo.putString("roleId", "100123"); | |
| 100 | - GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | |
| 126 | + PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(new PaymentInfoSubmitFragment.OnSubmitListener() { | |
| 127 | + @Override | |
| 128 | + public void onSubmit(Bundle payInfo) { | |
| 129 | + GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | |
| 130 | + } | |
| 131 | + }); | |
| 132 | + submitFragment.show(getSupportFragmentManager(), "iap"); | |
| 133 | +// Bundle payInfo = new Bundle(); | |
| 134 | +// payInfo.putString("product", "dwe"); | |
| 135 | +// payInfo.putFloat("amount", 0.1f); | |
| 136 | +// payInfo.putString("extraInfo", "This is demo!"); | |
| 137 | +// payInfo.putString("serverId", serverId); | |
| 138 | +// payInfo.putString("roleId", "100123"); | |
| 139 | +// payInfo.putString("currency", "THB"); | |
| 140 | +// GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | |
| 101 | 141 | } |
| 102 | 142 | }); |
| 103 | 143 | |
| ... | ... | @@ -123,10 +163,6 @@ public class MainActivity extends Activity implements PurchaseCallback { |
| 123 | 163 | * 设置启用Line登录 |
| 124 | 164 | */ |
| 125 | 165 | GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); |
| 126 | - /** | |
| 127 | - * 设置屏幕方向 | |
| 128 | - */ | |
| 129 | - GumpSDK.getSettings().setScreenLandscape(true); | |
| 130 | 166 | |
| 131 | 167 | /** |
| 132 | 168 | * 设置支付版本 |
| ... | ... | @@ -140,6 +176,7 @@ public class MainActivity extends Activity implements PurchaseCallback { |
| 140 | 176 | GumpSDK.setUserStateListener(new LoginStateListener() { |
| 141 | 177 | @Override |
| 142 | 178 | public void onLoginSuccess(GumpUser user) { |
| 179 | + btnCheckState.setEnabled(true); | |
| 143 | 180 | gumpUser = user; |
| 144 | 181 | String userType = null; |
| 145 | 182 | switch (user.getAccountType()) { |
| ... | ... | @@ -204,6 +241,7 @@ public class MainActivity extends Activity implements PurchaseCallback { |
| 204 | 241 | if (result == GumpSDK.CODE.OK) { |
| 205 | 242 | btnLoginOrLogout.setEnabled(true); |
| 206 | 243 | userInfo.setText("initialization has finished"); |
| 244 | + | |
| 207 | 245 | //checkRisk(); |
| 208 | 246 | } else { |
| 209 | 247 | btnInit.setEnabled(true); |
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/PaymentInfoSubmitFragment.java
| ... | ... | @@ -0,0 +1,149 @@ |
| 1 | +package com.gumptech.sdk.demo; | |
| 2 | + | |
| 3 | + | |
| 4 | +import android.app.AlertDialog; | |
| 5 | +import android.app.Dialog; | |
| 6 | +import android.os.Bundle; | |
| 7 | +import android.support.annotation.NonNull; | |
| 8 | +import android.support.design.widget.TextInputLayout; | |
| 9 | +import android.support.v4.app.DialogFragment; | |
| 10 | +import android.support.v4.app.Fragment; | |
| 11 | +import android.text.Editable; | |
| 12 | +import android.text.TextUtils; | |
| 13 | +import android.text.TextWatcher; | |
| 14 | +import android.view.LayoutInflater; | |
| 15 | +import android.view.View; | |
| 16 | + | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * A simple {@link Fragment} subclass. | |
| 20 | + */ | |
| 21 | +public class PaymentInfoSubmitFragment extends DialogFragment { | |
| 22 | + | |
| 23 | + interface OnSubmitListener { | |
| 24 | + void onSubmit(Bundle payInfo); | |
| 25 | + } | |
| 26 | + | |
| 27 | + private OnSubmitListener listener; | |
| 28 | + | |
| 29 | + TextInputLayout etProduct, | |
| 30 | + etAmount, | |
| 31 | + etCurrency, | |
| 32 | + etServerId, | |
| 33 | + etRoleId, | |
| 34 | + etExtra; | |
| 35 | + | |
| 36 | + public PaymentInfoSubmitFragment() { | |
| 37 | + | |
| 38 | + } | |
| 39 | + | |
| 40 | + public static PaymentInfoSubmitFragment newInstance(OnSubmitListener listener) { | |
| 41 | + PaymentInfoSubmitFragment fragment = new PaymentInfoSubmitFragment(); | |
| 42 | + fragment.listener = listener; | |
| 43 | + return fragment; | |
| 44 | + } | |
| 45 | + | |
| 46 | + @NonNull | |
| 47 | + @Override | |
| 48 | + public Dialog onCreateDialog(Bundle savedInstanceState) { | |
| 49 | + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |
| 50 | + View view = LayoutInflater.from(getContext()).inflate(R.layout.fragment_payment, null, false); | |
| 51 | + etProduct = view.findViewById(R.id.product); | |
| 52 | + etAmount = view.findViewById(R.id.amount); | |
| 53 | + etCurrency = view.findViewById(R.id.currency); | |
| 54 | + etServerId = view.findViewById(R.id.server_id); | |
| 55 | + etRoleId = view.findViewById(R.id.role_id); | |
| 56 | + etExtra = view.findViewById(R.id.extra); | |
| 57 | + etProduct.getEditText().addTextChangedListener(new EditTextWatcher(etProduct)); | |
| 58 | + etAmount.getEditText().addTextChangedListener(new EditTextWatcher(etAmount)); | |
| 59 | + etCurrency.getEditText().addTextChangedListener(new EditTextWatcher(etCurrency)); | |
| 60 | + etServerId.getEditText().addTextChangedListener(new EditTextWatcher(etServerId)); | |
| 61 | + etRoleId.getEditText().addTextChangedListener(new EditTextWatcher(etRoleId)); | |
| 62 | + etExtra.getEditText().addTextChangedListener(new EditTextWatcher(etExtra)); | |
| 63 | + //设置默认值 | |
| 64 | + etProduct.getEditText().setText("EV1.test.abc"); | |
| 65 | + etAmount.getEditText().setText("0.99"); | |
| 66 | + etCurrency.getEditText().setText("USD"); | |
| 67 | + etServerId.getEditText().setText("100"); | |
| 68 | + etRoleId.getEditText().setText("41080"); | |
| 69 | + view.findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() { | |
| 70 | + @Override | |
| 71 | + public void onClick(View v) { | |
| 72 | + String product = etProduct.getEditText().getText().toString(); | |
| 73 | + String currency = etCurrency.getEditText().getText().toString(); | |
| 74 | + String serverId = etServerId.getEditText().getText().toString(); | |
| 75 | + String roleId = etRoleId.getEditText().getText().toString(); | |
| 76 | + String extra = etExtra.getEditText().getText().toString(); | |
| 77 | + String amount = etAmount.getEditText().getText().toString(); | |
| 78 | + if (checkInput(product, amount, currency, serverId, roleId, extra)) { | |
| 79 | + Bundle payInfo = new Bundle(); | |
| 80 | + payInfo.putString("product", product); | |
| 81 | + payInfo.putFloat("amount", Float.valueOf(amount)); | |
| 82 | + payInfo.putString("extraInfo", extra); | |
| 83 | + payInfo.putString("serverId", serverId); | |
| 84 | + payInfo.putString("roleId", roleId); | |
| 85 | + payInfo.putString("currency", currency); | |
| 86 | + if (listener != null) { | |
| 87 | + listener.onSubmit(payInfo); | |
| 88 | + } | |
| 89 | + dismiss(); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + }); | |
| 93 | + AlertDialog dialog = builder.setView(view).create(); | |
| 94 | + return dialog; | |
| 95 | + } | |
| 96 | + | |
| 97 | + | |
| 98 | + private boolean checkInput(String product, String amount, String currency, String serverId, String roleId, String extra) { | |
| 99 | + if (TextUtils.isEmpty(product)) { | |
| 100 | + etProduct.setError("product is empty"); | |
| 101 | + return false; | |
| 102 | + } | |
| 103 | + if (TextUtils.isEmpty(currency)) { | |
| 104 | + etCurrency.setError("currency is empty"); | |
| 105 | + return false; | |
| 106 | + } | |
| 107 | + if (TextUtils.isEmpty(serverId)) { | |
| 108 | + etServerId.setError("serverId is empty"); | |
| 109 | + return false; | |
| 110 | + } | |
| 111 | + if (TextUtils.isEmpty(roleId)) { | |
| 112 | + etRoleId.setError("roleId is empty"); | |
| 113 | + return false; | |
| 114 | + } | |
| 115 | + if (TextUtils.isEmpty(extra)) { | |
| 116 | + etExtra.setError("extra is empty"); | |
| 117 | + return false; | |
| 118 | + } | |
| 119 | + if (TextUtils.isEmpty(amount)) { | |
| 120 | + etAmount.setError("amount is empty"); | |
| 121 | + return false; | |
| 122 | + } | |
| 123 | + return true; | |
| 124 | + } | |
| 125 | + | |
| 126 | + class EditTextWatcher implements TextWatcher { | |
| 127 | + | |
| 128 | + private TextInputLayout editText; | |
| 129 | + | |
| 130 | + public EditTextWatcher(TextInputLayout editText) { | |
| 131 | + this.editText = editText; | |
| 132 | + } | |
| 133 | + | |
| 134 | + @Override | |
| 135 | + public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |
| 136 | + | |
| 137 | + } | |
| 138 | + | |
| 139 | + @Override | |
| 140 | + public void onTextChanged(CharSequence s, int start, int before, int count) { | |
| 141 | + editText.setError(null); | |
| 142 | + } | |
| 143 | + | |
| 144 | + @Override | |
| 145 | + public void afterTextChanged(Editable s) { | |
| 146 | + | |
| 147 | + } | |
| 148 | + } | |
| 149 | +} |
GameSDKDemo/src/main/res/layout/activity_main.xml
| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | android:layout_height="wrap_content" |
| 25 | 25 | android:backgroundTint="@color/g_color" |
| 26 | 26 | android:enabled="false" |
| 27 | - android:text="Initialize"/> | |
| 27 | + android:text="@string/init"/> | |
| 28 | 28 | |
| 29 | 29 | <Button |
| 30 | 30 | android:id="@+id/login_or_logout" |
| ... | ... | @@ -32,21 +32,31 @@ |
| 32 | 32 | android:layout_height="wrap_content" |
| 33 | 33 | android:backgroundTint="@color/g_color" |
| 34 | 34 | android:enabled="false" |
| 35 | - android:text="Login"/> | |
| 35 | + android:text="@string/login"/> | |
| 36 | + | |
| 37 | + <Button | |
| 38 | + android:id="@+id/check_state" | |
| 39 | + android:layout_width="match_parent" | |
| 40 | + android:layout_height="wrap_content" | |
| 41 | + android:backgroundTint="@color/g_color" | |
| 42 | + android:enabled="false" | |
| 43 | + android:text="@string/check"/> | |
| 36 | 44 | |
| 37 | 45 | <Button |
| 38 | 46 | android:id="@+id/iap" |
| 39 | 47 | android:layout_width="match_parent" |
| 40 | 48 | android:layout_height="wrap_content" |
| 41 | 49 | android:backgroundTint="@color/g_color" |
| 42 | - android:text="IAP"/> | |
| 50 | + android:enabled="false" | |
| 51 | + android:text="@string/iap"/> | |
| 43 | 52 | |
| 44 | 53 | <Button |
| 45 | 54 | android:id="@+id/pay" |
| 46 | 55 | android:layout_width="match_parent" |
| 47 | 56 | android:layout_height="wrap_content" |
| 48 | 57 | android:backgroundTint="@color/g_color" |
| 49 | - android:text="pay"/> | |
| 58 | + android:enabled="false" | |
| 59 | + android:text="@string/pay"/> | |
| 50 | 60 | |
| 51 | 61 | |
| 52 | 62 | </LinearLayout> |
| 53 | 63 | \ No newline at end of file |
GameSDKDemo/src/main/res/layout/fragment_payment.xml
| ... | ... | @@ -0,0 +1,89 @@ |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 4 | + xmlns:tools="http://schemas.android.com/tools" | |
| 5 | + android:layout_width="match_parent" | |
| 6 | + android:layout_height="match_parent" | |
| 7 | + android:orientation="vertical" | |
| 8 | + tools:context=".PaymentInfoSubmitFragment"> | |
| 9 | + | |
| 10 | + <android.support.design.widget.TextInputLayout | |
| 11 | + android:id="@+id/product" | |
| 12 | + android:layout_width="match_parent" | |
| 13 | + android:layout_height="wrap_content"> | |
| 14 | + | |
| 15 | + <EditText | |
| 16 | + android:layout_width="match_parent" | |
| 17 | + android:layout_height="wrap_content" | |
| 18 | + android:hint="@string/hint_product" | |
| 19 | + /> | |
| 20 | + </android.support.design.widget.TextInputLayout> | |
| 21 | + | |
| 22 | + <android.support.design.widget.TextInputLayout | |
| 23 | + android:id="@+id/amount" | |
| 24 | + android:layout_width="match_parent" | |
| 25 | + android:layout_height="wrap_content"> | |
| 26 | + | |
| 27 | + <EditText | |
| 28 | + android:layout_width="match_parent" | |
| 29 | + android:layout_height="wrap_content" | |
| 30 | + android:hint="@string/hint_amount" | |
| 31 | + android:inputType="numberDecimal"/> | |
| 32 | + </android.support.design.widget.TextInputLayout> | |
| 33 | + | |
| 34 | + <android.support.design.widget.TextInputLayout | |
| 35 | + android:id="@+id/currency" | |
| 36 | + android:layout_width="match_parent" | |
| 37 | + android:layout_height="wrap_content"> | |
| 38 | + | |
| 39 | + <EditText | |
| 40 | + | |
| 41 | + android:layout_width="match_parent" | |
| 42 | + android:layout_height="wrap_content" | |
| 43 | + android:hint="@string/hint_currency"/> | |
| 44 | + </android.support.design.widget.TextInputLayout> | |
| 45 | + | |
| 46 | + <android.support.design.widget.TextInputLayout | |
| 47 | + android:id="@+id/server_id" | |
| 48 | + android:layout_width="match_parent" | |
| 49 | + android:layout_height="wrap_content"> | |
| 50 | + | |
| 51 | + <EditText | |
| 52 | + | |
| 53 | + android:layout_width="match_parent" | |
| 54 | + android:layout_height="wrap_content" | |
| 55 | + android:hint="@string/hint_server_id"/> | |
| 56 | + </android.support.design.widget.TextInputLayout> | |
| 57 | + | |
| 58 | + <android.support.design.widget.TextInputLayout | |
| 59 | + android:id="@+id/role_id" | |
| 60 | + android:layout_width="match_parent" | |
| 61 | + android:layout_height="wrap_content"> | |
| 62 | + | |
| 63 | + <EditText | |
| 64 | + | |
| 65 | + android:layout_width="match_parent" | |
| 66 | + android:layout_height="wrap_content" | |
| 67 | + android:hint="@string/hint_role_id"/> | |
| 68 | + </android.support.design.widget.TextInputLayout> | |
| 69 | + | |
| 70 | + <android.support.design.widget.TextInputLayout | |
| 71 | + android:id="@+id/extra" | |
| 72 | + android:layout_width="match_parent" | |
| 73 | + android:layout_height="wrap_content"> | |
| 74 | + | |
| 75 | + <EditText | |
| 76 | + | |
| 77 | + android:layout_width="match_parent" | |
| 78 | + android:layout_height="wrap_content" | |
| 79 | + android:hint="@string/hint_extra"/> | |
| 80 | + </android.support.design.widget.TextInputLayout> | |
| 81 | + | |
| 82 | + <Button | |
| 83 | + android:id="@+id/submit" | |
| 84 | + android:layout_width="match_parent" | |
| 85 | + android:layout_height="wrap_content" | |
| 86 | + android:text="@string/go_pay"/> | |
| 87 | + | |
| 88 | + | |
| 89 | +</LinearLayout> | |
| 0 | 90 | \ No newline at end of file |
GameSDKDemo/src/main/res/values-zh/strings.xml
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<resources> | |
| 3 | + | |
| 4 | + <string name="app_name">GameSDKSample</string> | |
| 5 | + | |
| 6 | + <string name="init">初始化</string> | |
| 7 | + <string name="login">登录</string> | |
| 8 | + <string name="check">检查支付状态</string> | |
| 9 | + <string name="iap">官方支付(无弹窗)</string> | |
| 10 | + <string name="pay">弹窗支付</string> | |
| 11 | + | |
| 12 | + | |
| 13 | + <string name="hint_product">商品id/商品名</string> | |
| 14 | + <string name="hint_amount">金额</string> | |
| 15 | + <string name="hint_currency">货币代码</string> | |
| 16 | + <string name="hint_server_id">serverId</string> | |
| 17 | + <string name="hint_role_id">roleId</string> | |
| 18 | + <string name="hint_extra">游戏透传信息(extraInfo)</string> | |
| 19 | + <string name="go_pay">去支付</string> | |
| 20 | +</resources> | |
| 21 | + | |
| 0 | 22 | \ No newline at end of file |
GameSDKDemo/src/main/res/values/strings.xml
| ... | ... | @@ -2,8 +2,20 @@ |
| 2 | 2 | <resources> |
| 3 | 3 | |
| 4 | 4 | <string name="app_name">GameSDKSample</string> |
| 5 | - <string name="hello_world">Hello world!</string> | |
| 6 | - <string name="action_settings">Settings</string> | |
| 7 | - | |
| 5 | + | |
| 6 | + <string name="init">Initialize</string> | |
| 7 | + <string name="login">Login</string> | |
| 8 | + <string name="check">Check payemnt state</string> | |
| 9 | + <string name="iap">IAP</string> | |
| 10 | + <string name="pay">Pay</string> | |
| 11 | + | |
| 12 | + <string name="hint_product">product</string> | |
| 13 | + <string name="hint_amount">amount</string> | |
| 14 | + <string name="hint_currency">currency</string> | |
| 15 | + <string name="hint_server_id">serverId</string> | |
| 16 | + <string name="hint_role_id">roleId</string> | |
| 17 | + <string name="hint_extra">extraInfo</string> | |
| 18 | + <string name="go_pay">Submit</string> | |
| 19 | + | |
| 8 | 20 | </resources> |
| 9 | 21 | |
| 10 | 22 | \ No newline at end of file |
README.md
| 1 | 1 | # Gump SDK 4 for Android接入文档 |
| 2 | 2 | |
| 3 | -V4.6.3 | |
| 4 | -2018年10月23日 | |
| 3 | +V4.7.0 | |
| 4 | +2019年02月21日 | |
| 5 | 5 | |
| 6 | 6 | ## 版本概述 |
| 7 | 7 | |
| ... | ... | @@ -19,7 +19,7 @@ V4.6.3 |
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | dependencies { |
| 22 | - implementation 'com.gumptech.sdk:GameSDK:4.6.3' | |
| 22 | + implementation 'com.gumptech.sdk:GameSDK:4.7.0' | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| ... | ... | @@ -34,18 +34,13 @@ V4.6.3 |
| 34 | 34 | |
| 35 | 35 | 其次注册相应的Activity,具体如下: |
| 36 | 36 | |
| 37 | - <activity | |
| 38 | - android:name="com.gumptech.sdk.ContainerActivity" | |
| 39 | - android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | |
| 40 | - android:windowSoftInputMode="stateAlwaysHidden|adjustPan" | |
| 41 | - android:launchMode="singleTask" | |
| 42 | - android:theme="@style/Theme.TransparentWin" > | |
| 43 | - </activity> | |
| 37 | + | |
| 44 | 38 | <activity |
| 45 | 39 | android:name="com.gumptech.sdk.PaymentActivity" |
| 46 | 40 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 47 | 41 | android:launchMode="singleTask" |
| 48 | - android:theme="@android:style/Theme.Translucent.NoTitleBar" > | |
| 42 | + android:screenOrientation="behind" | |
| 43 | + android:theme="@style/Theme.Translucent" > | |
| 49 | 44 | <intent-filter> |
| 50 | 45 | <category android:name="android.intent.category.DEFAULT" /> |
| 51 | 46 | <action android:name="android.intent.action.VIEW" /> |
| ... | ... | @@ -61,11 +56,7 @@ V4.6.3 |
| 61 | 56 | |
| 62 | 57 | *是否打印debug日志 |
| 63 | 58 | |
| 64 | - GumpSDK.getSettings().enableDebugLogging(true); | |
| 65 | - | |
| 66 | -*横竖屏控制,默认为横屏,参数为false即为竖屏 | |
| 67 | - | |
| 68 | - GumpSDK.getSettings().setScreenLandscape(true); | |
| 59 | + GumpSDK.getSettings().enableDebugLogging(true); | |
| 69 | 60 | |
| 70 | 61 | *设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明 |
| 71 | 62 | |
| ... | ... | @@ -127,18 +118,30 @@ InitializeCallback为初始化回调接口,此接口只有一个回调方法init |
| 127 | 118 | gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法 |
| 128 | 119 | |
| 129 | 120 | #### 3.支付功能 |
| 130 | -1)使用gump通行证登录,其中除nick外所有参数为必传参数 | |
| 121 | +调用支付前需先获取支付状态,根据状态调用支付方法 | |
| 122 | + | |
| 123 | + GumpSDK.shouldUseCoPay(Activity, serverId, roleId, new ResultCallback() { | |
| 124 | + @Override | |
| 125 | + public void onResult(boolean result) { | |
| 126 | + if(result){ | |
| 127 | + //调用GumpSDK.iap | |
| 128 | + }else{ | |
| 129 | + //调用GumpSDK.pay | |
| 130 | + } | |
| 131 | + } | |
| 132 | + }); | |
| 133 | + | |
| 134 | +1)调用GumpSDK.pay | |
| 131 | 135 | |
| 132 | 136 | Bundle payInfo = new Bundle(); |
| 133 | - payInfo.putString("nick", "thi"); | |
| 134 | 137 | payInfo.putString("product", "元宝"); |
| 135 | 138 | payInfo.putFloat("amount", 40.0f); |
| 136 | 139 | payInfo.putString("extraInfo", "This is demo!"); |
| 137 | 140 | payInfo.putString("serverId", "B4003"); |
| 138 | 141 | payInfo.putString("roleId", "10010"); |
| 139 | - payInfo.putString("sessionKey","sessionkey"); | |
| 142 | + payInfo.putString("currency","currency"); | |
| 140 | 143 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); |
| 141 | -调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey | |
| 144 | +调用pay方法时,必须穿入一个bundle对象,包含如上字段,所有字段必须全部包含 | |
| 142 | 145 | |
| 143 | 146 | |
| 144 | 147 | 2)IAP支付 |