Commit e877dd7d0274d46936c3cb5a3b94cfbfd0408799
1 parent
1f96df5c37
Exists in
master
重构版本4.8.0\
Showing 14 changed files with 430 additions and 519 deletions Side-by-side Diff
- GameSDKDemo/build.gradle
- GameSDKDemo/proguard-rules.pro
- GameSDKDemo/src/androidTest/java/com/gump/game/sdk/demo/ApplicationTest.java
- GameSDKDemo/src/androidTest/java/com/gumptech/sdk/demo/ApplicationTest.java
- GameSDKDemo/src/main/AndroidManifest.xml
- GameSDKDemo/src/main/java/com/gump/game/sdk/demo/MainActivity.java
- GameSDKDemo/src/main/java/com/gump/game/sdk/demo/PaymentInfoSubmitFragment.java
- 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/test/java/com/gump/game/sdk/demo/ExampleUnitTest.java
- GameSDKDemo/src/test/java/com/gumptech/sdk/demo/ExampleUnitTest.java
- README.md
GameSDKDemo/build.gradle
| ... | ... | @@ -36,7 +36,7 @@ repositories { |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | android { |
| 39 | - compileSdkVersion 27 | |
| 39 | + compileSdkVersion 28 | |
| 40 | 40 | buildToolsVersion '28.0.3' |
| 41 | 41 | |
| 42 | 42 | signingConfigs { |
| ... | ... | @@ -71,8 +71,8 @@ android { |
| 71 | 71 | abortOnError false |
| 72 | 72 | } |
| 73 | 73 | compileOptions { |
| 74 | - sourceCompatibility JavaVersion.VERSION_1_7 | |
| 75 | - targetCompatibility JavaVersion.VERSION_1_7 | |
| 74 | + sourceCompatibility JavaVersion.VERSION_1_8 | |
| 75 | + targetCompatibility JavaVersion.VERSION_1_8 | |
| 76 | 76 | } |
| 77 | 77 | applicationVariants.all { |
| 78 | 78 | variant -> |
| ... | ... | @@ -85,12 +85,15 @@ android { |
| 85 | 85 | |
| 86 | 86 | dependencies { |
| 87 | 87 | implementation fileTree(include: ['*.jar'], dir: 'libs') |
| 88 | - implementation 'com.android.support:support-v4:27.1.1' | |
| 88 | +// implementation 'com.android.support:support-v4:27.1.1' | |
| 89 | + implementation 'androidx.appcompat:appcompat:1.1.0' | |
| 90 | + implementation 'androidx.fragment:fragment:1.1.0' | |
| 91 | + implementation 'com.google.android.material:material:1.0.0' | |
| 89 | 92 | testImplementation 'junit:junit:4.12' |
| 90 | - implementation 'com.android.support:appcompat-v7:27.1.1' | |
| 91 | - implementation 'com.android.support:design:27.1.1' | |
| 93 | +// implementation 'com.android.support:appcompat-v7:27.1.1' | |
| 94 | +// implementation 'com.android.support:design:27.1.1' | |
| 92 | 95 | // implementation project(':GameSDK') |
| 93 | 96 | // implementation project(':IAP5Helper') |
| 94 | - implementation 'com.gumptech.sdk:GameSDK:4.7.8' | |
| 95 | -// implementation 'com.gumptech.sdk:SamsungIAP:5.1.1' | |
| 97 | + implementation 'com.gumptech.sdk:GameSDK:4.8.0' | |
| 98 | +// implementation 'com.gump.game.sdk:SamsungIAP:5.1.1' | |
| 96 | 99 | } |
GameSDKDemo/proguard-rules.pro
| 1 | 1 | # Add project specific ProGuard rules here. |
| 2 | 2 | # By default, the flags in this file are appended to flags specified |
| 3 | -# in D:\DevTools\android-com.gumptech.sdk-windows/tools/proguard/proguard-android.txt | |
| 3 | +# in D:\DevTools\android-gump.gamee.sdk-windows/tools/proguard/proguard-android.txt | |
| 4 | 4 | # You can edit the include path and order by changing the proguardFiles |
| 5 | 5 | # directive in build.gradle. |
| 6 | 6 | # |
GameSDKDemo/src/androidTest/java/com/gump/game/sdk/demo/ApplicationTest.java
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +package com.gump.game.sdk.demo; | |
| 2 | + | |
| 3 | +import android.app.Application; | |
| 4 | +import android.test.ApplicationTestCase; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | |
| 8 | + */ | |
| 9 | +public class ApplicationTest extends ApplicationTestCase<Application> { | |
| 10 | + public ApplicationTest() { | |
| 11 | + super(Application.class); | |
| 12 | + } | |
| 13 | +} | |
| 0 | 14 | \ No newline at end of file |
GameSDKDemo/src/androidTest/java/com/gumptech/sdk/demo/ApplicationTest.java
| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | -package com.gumptech.sdk.demo; | |
| 2 | - | |
| 3 | -import android.app.Application; | |
| 4 | -import android.test.ApplicationTestCase; | |
| 5 | - | |
| 6 | -/** | |
| 7 | - * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | |
| 8 | - */ | |
| 9 | -public class ApplicationTest extends ApplicationTestCase<Application> { | |
| 10 | - public ApplicationTest() { | |
| 11 | - super(Application.class); | |
| 12 | - } | |
| 13 | -} | |
| 14 | 0 | \ No newline at end of file |
GameSDKDemo/src/main/AndroidManifest.xml
| 1 | 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 2 | - package="com.gumptech.sdk.demo"> | |
| 2 | + package="com.gump.game.sdk.demo"> | |
| 3 | 3 | |
| 4 | 4 | |
| 5 | 5 | <uses-permission android:name="android.permission.INTERNET"/> |
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | android:icon="@drawable/ic_launcher" |
| 18 | 18 | android:label="@string/app_name"> |
| 19 | 19 | <activity |
| 20 | - android:name="com.gumptech.sdk.demo.MainActivity" | |
| 20 | + android:name="com.gump.game.sdk.demo.MainActivity" | |
| 21 | 21 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 22 | 22 | android:label="@string/app_name" |
| 23 | 23 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" |
| ... | ... | @@ -29,15 +29,15 @@ |
| 29 | 29 | </intent-filter> |
| 30 | 30 | </activity> |
| 31 | 31 | <activity |
| 32 | - android:name="com.gumptech.sdk.ContainerActivity" | |
| 32 | + android:name="com.gump.game.sdk.PassportActivity" | |
| 33 | 33 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 34 | 34 | android:launchMode="singleTask" |
| 35 | - android:theme="@style/Theme.Orange" | |
| 35 | + android:theme="@style/Theme.Pink" | |
| 36 | 36 | android:screenOrientation="behind" |
| 37 | 37 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> |
| 38 | 38 | </activity> |
| 39 | 39 | <activity |
| 40 | - android:name="com.gumptech.sdk.PaymentActivity" | |
| 40 | + android:name="com.gump.game.sdk.RechargeActivity" | |
| 41 | 41 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 42 | 42 | android:launchMode="singleTask" |
| 43 | 43 | android:screenOrientation="behind" |
GameSDKDemo/src/main/java/com/gump/game/sdk/demo/MainActivity.java
| ... | ... | @@ -0,0 +1,192 @@ |
| 1 | +package com.gump.game.sdk.demo; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.util.Log; | |
| 5 | +import android.widget.Button; | |
| 6 | +import android.widget.TextView; | |
| 7 | +import android.widget.Toast; | |
| 8 | + | |
| 9 | +import com.gump.game.sdk.GameSDK; | |
| 10 | +import com.gump.game.sdk.GumpPreference; | |
| 11 | +import com.gump.game.sdk.SDKSettings; | |
| 12 | +import com.gump.game.sdk.bean.GumpUser; | |
| 13 | +import com.gump.game.sdk.callback.LoginStateListener; | |
| 14 | +import com.gump.game.sdk.callback.RechargeCallback; | |
| 15 | +import com.gump.game.sdk.passport.fb.FBAccessToken; | |
| 16 | + | |
| 17 | +import java.util.Locale; | |
| 18 | + | |
| 19 | +import androidx.appcompat.app.AppCompatActivity; | |
| 20 | + | |
| 21 | +public class MainActivity extends AppCompatActivity implements RechargeCallback { | |
| 22 | + | |
| 23 | + private static final String TAG = "MainActivity"; | |
| 24 | + | |
| 25 | + private TextView tvVersion; | |
| 26 | + private TextView userInfo; | |
| 27 | + | |
| 28 | + private Button btnLoginOrLogout; | |
| 29 | + private Button btnCheckState; | |
| 30 | + private Button btnPay; | |
| 31 | + private Button btnIap; | |
| 32 | + | |
| 33 | + private String appId = "100"; | |
| 34 | + private String appKey = "f899139df5e1059396431415e770c6dd"; | |
| 35 | + private GumpUser gumpUser; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 测试数据 | |
| 39 | + */ | |
| 40 | + String serverId = "100"; | |
| 41 | + String roleId = "41080"; | |
| 42 | + | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + protected void onCreate(Bundle savedInstanceState) { | |
| 46 | + super.onCreate(savedInstanceState); | |
| 47 | + setContentView(R.layout.activity_main); | |
| 48 | + | |
| 49 | + tvVersion = findViewById(R.id.version); | |
| 50 | + userInfo = findViewById(R.id.user_info); | |
| 51 | + btnLoginOrLogout = findViewById(R.id.login_or_logout); | |
| 52 | + btnCheckState = findViewById(R.id.check_state); | |
| 53 | + btnLoginOrLogout.setOnClickListener(v -> { | |
| 54 | + if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | |
| 55 | + GameSDK.login(MainActivity.this); | |
| 56 | + else | |
| 57 | + GameSDK.logout(MainActivity.this); | |
| 58 | + }); | |
| 59 | + btnCheckState.setOnClickListener(v -> { | |
| 60 | + GameSDK.iapUsable(MainActivity.this, serverId, roleId, usable -> { | |
| 61 | + btnIap.setEnabled(usable); | |
| 62 | + btnPay.setEnabled(!usable); | |
| 63 | + }); | |
| 64 | + }); | |
| 65 | + btnPay = findViewById(R.id.pay); | |
| 66 | + btnPay.setOnClickListener(v -> { | |
| 67 | + PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(payInfo -> GameSDK.pay(MainActivity.this, payInfo, MainActivity.this)); | |
| 68 | + submitFragment.show(getSupportFragmentManager(), "pay"); | |
| 69 | + }); | |
| 70 | + btnIap = findViewById(R.id.iap); | |
| 71 | + btnIap.setOnClickListener(v -> { | |
| 72 | + PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(payInfo -> GameSDK.iap(MainActivity.this, payInfo, MainActivity.this)); | |
| 73 | + submitFragment.show(getSupportFragmentManager(), "iap"); | |
| 74 | + }); | |
| 75 | + | |
| 76 | + | |
| 77 | + Log.i("DEMO", "country:" + Locale.getDefault().getCountry() + ",language:" + Locale.getDefault().getLanguage()); | |
| 78 | + | |
| 79 | + GameSDK.getSettings().setDebug(false); | |
| 80 | + /** | |
| 81 | + * 设置是否打印debug日志 | |
| 82 | + */ | |
| 83 | + GameSDK.getSettings().enableDebugLogging(true); | |
| 84 | + /** | |
| 85 | + * 设置启用facebook登录 | |
| 86 | + */ | |
| 87 | + GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_FB); | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * 设置启用google登录 | |
| 91 | + */ | |
| 92 | + GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_GOOGLE); | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * 设置启用Line登录 | |
| 96 | + */ | |
| 97 | + GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); | |
| 98 | + | |
| 99 | + | |
| 100 | + /** | |
| 101 | + * 设置用户登录状态监听器 | |
| 102 | + */ | |
| 103 | + | |
| 104 | + GameSDK.setUserStateListener(new LoginStateListener() { | |
| 105 | + @Override | |
| 106 | + public void onLoginSuccess(GumpUser user) { | |
| 107 | + btnCheckState.setEnabled(true); | |
| 108 | + gumpUser = user; | |
| 109 | + String userType = null; | |
| 110 | + switch (user.getAccountType()) { | |
| 111 | + case GumpPreference.ACCOUNT_TYPE_FB: | |
| 112 | + userType = "Facebook登录"; | |
| 113 | + String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | |
| 114 | + Log.d(TAG, "FBAccessToken:" + fbToken); | |
| 115 | + break; | |
| 116 | + case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | |
| 117 | + userType = "快速登录"; | |
| 118 | + break; | |
| 119 | + case GumpPreference.ACCOUNT_TYPE_REG: | |
| 120 | + userType = "gump注册用户"; | |
| 121 | + break; | |
| 122 | + case GumpPreference.ACCOUNT_TYPE_GOOGLE: | |
| 123 | + userType = "google 登录"; | |
| 124 | + break; | |
| 125 | + case GumpPreference.ACCOUNT_TYPE_LINE: | |
| 126 | + userType = "Line登录"; | |
| 127 | + break; | |
| 128 | + } | |
| 129 | + userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey() | |
| 130 | + .getToken()); | |
| 131 | + btnLoginOrLogout.setText("Logout"); | |
| 132 | + btnLoginOrLogout.setTag(1); | |
| 133 | + } | |
| 134 | + | |
| 135 | + @Override | |
| 136 | + public void onLoginFailed(int code, String msg) { | |
| 137 | + userInfo.setText(msg); | |
| 138 | + Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | |
| 139 | + } | |
| 140 | + | |
| 141 | + @Override | |
| 142 | + public void onLoginCanceled() { | |
| 143 | + Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | |
| 144 | + } | |
| 145 | + | |
| 146 | + @Override | |
| 147 | + public void onLogout() { | |
| 148 | + btnLoginOrLogout.setText("Login"); | |
| 149 | + btnLoginOrLogout.setTag(0); | |
| 150 | + userInfo.setText("User is logout"); | |
| 151 | + } | |
| 152 | + | |
| 153 | + @Override | |
| 154 | + public void onPermissionDenied(String[] deniedPermissions) { | |
| 155 | + StringBuilder sb = new StringBuilder(); | |
| 156 | + for (String s : deniedPermissions) { | |
| 157 | + sb.append(s); | |
| 158 | + sb.append(","); | |
| 159 | + } | |
| 160 | + Toast.makeText(MainActivity.this, "Permission denied:" + sb.toString(), Toast.LENGTH_SHORT).show(); | |
| 161 | + } | |
| 162 | + }); | |
| 163 | + /** | |
| 164 | + * 初始化sdk | |
| 165 | + */ | |
| 166 | + GameSDK.init(getApplicationContext(), appId); | |
| 167 | + | |
| 168 | + tvVersion.setText("SDK Version:" + GameSDK.getVersion()); | |
| 169 | + | |
| 170 | + } | |
| 171 | + | |
| 172 | + private void checkRisk() { | |
| 173 | + GameSDK.inspectRiskLevel(this, isRisk -> Log.i(TAG, isRisk ? "There is some risks" : "Nothing is risk")); | |
| 174 | + } | |
| 175 | + | |
| 176 | + @Override | |
| 177 | + public void onPurchaseCompleted() { | |
| 178 | + Log.i(TAG, "purchase completed"); | |
| 179 | + } | |
| 180 | + | |
| 181 | + @Override | |
| 182 | + public void onPurchaseError(int code, String msg) { | |
| 183 | + Log.i(TAG, "purchase error:"+code+","+msg); | |
| 184 | + } | |
| 185 | + | |
| 186 | + @Override | |
| 187 | + public void onPurchaseCanceled() { | |
| 188 | + Log.i(TAG, "purchase canceled"); | |
| 189 | + } | |
| 190 | + | |
| 191 | + | |
| 192 | +} |
GameSDKDemo/src/main/java/com/gump/game/sdk/demo/PaymentInfoSubmitFragment.java
| ... | ... | @@ -0,0 +1,142 @@ |
| 1 | +package com.gump.game.sdk.demo; | |
| 2 | + | |
| 3 | + | |
| 4 | +import android.app.AlertDialog; | |
| 5 | +import android.app.Dialog; | |
| 6 | +import android.os.Bundle; | |
| 7 | +import android.text.Editable; | |
| 8 | +import android.text.TextUtils; | |
| 9 | +import android.text.TextWatcher; | |
| 10 | +import android.view.LayoutInflater; | |
| 11 | +import android.view.View; | |
| 12 | + | |
| 13 | +import com.google.android.material.textfield.TextInputLayout; | |
| 14 | + | |
| 15 | +import androidx.annotation.NonNull; | |
| 16 | +import androidx.fragment.app.DialogFragment; | |
| 17 | + | |
| 18 | + | |
| 19 | +public class PaymentInfoSubmitFragment extends DialogFragment { | |
| 20 | + | |
| 21 | + interface OnSubmitListener { | |
| 22 | + void onSubmit(Bundle payInfo); | |
| 23 | + } | |
| 24 | + | |
| 25 | + private OnSubmitListener listener; | |
| 26 | + | |
| 27 | + TextInputLayout etProduct, | |
| 28 | + etAmount, | |
| 29 | + etCurrency, | |
| 30 | + etServerId, | |
| 31 | + etRoleId, | |
| 32 | + etExtra; | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + public static PaymentInfoSubmitFragment newInstance(OnSubmitListener listener) { | |
| 37 | + PaymentInfoSubmitFragment fragment = new PaymentInfoSubmitFragment(); | |
| 38 | + fragment.listener = listener; | |
| 39 | + return fragment; | |
| 40 | + } | |
| 41 | + | |
| 42 | + @NonNull | |
| 43 | + @Override | |
| 44 | + public Dialog onCreateDialog(Bundle savedInstanceState) { | |
| 45 | + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |
| 46 | + View view = LayoutInflater.from(getContext()).inflate(R.layout.fragment_payment, null, false); | |
| 47 | + etProduct = view.findViewById(R.id.product); | |
| 48 | + etAmount = view.findViewById(R.id.amount); | |
| 49 | + etCurrency = view.findViewById(R.id.currency); | |
| 50 | + etServerId = view.findViewById(R.id.server_id); | |
| 51 | + etRoleId = view.findViewById(R.id.role_id); | |
| 52 | + etExtra = view.findViewById(R.id.extra); | |
| 53 | + etProduct.getEditText().addTextChangedListener(new EditTextWatcher(etProduct)); | |
| 54 | + etAmount.getEditText().addTextChangedListener(new EditTextWatcher(etAmount)); | |
| 55 | + etCurrency.getEditText().addTextChangedListener(new EditTextWatcher(etCurrency)); | |
| 56 | + etServerId.getEditText().addTextChangedListener(new EditTextWatcher(etServerId)); | |
| 57 | + etRoleId.getEditText().addTextChangedListener(new EditTextWatcher(etRoleId)); | |
| 58 | + etExtra.getEditText().addTextChangedListener(new EditTextWatcher(etExtra)); | |
| 59 | + //设置默认值 | |
| 60 | + etProduct.getEditText().setText("EV1.test.abc"); | |
| 61 | + etAmount.getEditText().setText("0.99"); | |
| 62 | + etCurrency.getEditText().setText("USD"); | |
| 63 | + etServerId.getEditText().setText("100"); | |
| 64 | + etRoleId.getEditText().setText("41080"); | |
| 65 | + view.findViewById(R.id.submit).setOnClickListener(v -> { | |
| 66 | + String product = etProduct.getEditText().getText().toString(); | |
| 67 | + String currency = etCurrency.getEditText().getText().toString(); | |
| 68 | + String serverId = etServerId.getEditText().getText().toString(); | |
| 69 | + String roleId = etRoleId.getEditText().getText().toString(); | |
| 70 | + String extra = etExtra.getEditText().getText().toString(); | |
| 71 | + String amount = etAmount.getEditText().getText().toString(); | |
| 72 | + if (checkInput(product, amount, currency, serverId, roleId, extra)) { | |
| 73 | + Bundle payInfo = new Bundle(); | |
| 74 | + payInfo.putString("product", product); | |
| 75 | + payInfo.putFloat("amount", Float.valueOf(amount)); | |
| 76 | + payInfo.putString("extraInfo", extra); | |
| 77 | + payInfo.putString("serverId", serverId); | |
| 78 | + payInfo.putString("roleId", roleId); | |
| 79 | + payInfo.putString("currency", currency); | |
| 80 | + if (listener != null) { | |
| 81 | + listener.onSubmit(payInfo); | |
| 82 | + } | |
| 83 | + dismiss(); | |
| 84 | + } | |
| 85 | + }); | |
| 86 | + AlertDialog dialog = builder.setView(view).create(); | |
| 87 | + return dialog; | |
| 88 | + } | |
| 89 | + | |
| 90 | + | |
| 91 | + private boolean checkInput(String product, String amount, String currency, String serverId, String roleId, String extra) { | |
| 92 | + if (TextUtils.isEmpty(product)) { | |
| 93 | + etProduct.setError("product is empty"); | |
| 94 | + return false; | |
| 95 | + } | |
| 96 | + if (TextUtils.isEmpty(currency)) { | |
| 97 | + etCurrency.setError("currency is empty"); | |
| 98 | + return false; | |
| 99 | + } | |
| 100 | + if (TextUtils.isEmpty(serverId)) { | |
| 101 | + etServerId.setError("serverId is empty"); | |
| 102 | + return false; | |
| 103 | + } | |
| 104 | + if (TextUtils.isEmpty(roleId)) { | |
| 105 | + etRoleId.setError("roleId is empty"); | |
| 106 | + return false; | |
| 107 | + } | |
| 108 | + if (TextUtils.isEmpty(extra)) { | |
| 109 | + etExtra.setError("extra is empty"); | |
| 110 | + return false; | |
| 111 | + } | |
| 112 | + if (TextUtils.isEmpty(amount)) { | |
| 113 | + etAmount.setError("amount is empty"); | |
| 114 | + return false; | |
| 115 | + } | |
| 116 | + return true; | |
| 117 | + } | |
| 118 | + | |
| 119 | + class EditTextWatcher implements TextWatcher { | |
| 120 | + | |
| 121 | + private TextInputLayout editText; | |
| 122 | + | |
| 123 | + public EditTextWatcher(TextInputLayout editText) { | |
| 124 | + this.editText = editText; | |
| 125 | + } | |
| 126 | + | |
| 127 | + @Override | |
| 128 | + public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |
| 129 | + | |
| 130 | + } | |
| 131 | + | |
| 132 | + @Override | |
| 133 | + public void onTextChanged(CharSequence s, int start, int before, int count) { | |
| 134 | + editText.setError(null); | |
| 135 | + } | |
| 136 | + | |
| 137 | + @Override | |
| 138 | + public void afterTextChanged(Editable s) { | |
| 139 | + | |
| 140 | + } | |
| 141 | + } | |
| 142 | +} |
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
| ... | ... | @@ -1,266 +0,0 @@ |
| 1 | -package com.gumptech.sdk.demo; | |
| 2 | - | |
| 3 | -import android.os.Bundle; | |
| 4 | -import android.support.v7.app.AppCompatActivity; | |
| 5 | -import android.util.Log; | |
| 6 | -import android.view.View; | |
| 7 | -import android.widget.Button; | |
| 8 | -import android.widget.TextView; | |
| 9 | -import android.widget.Toast; | |
| 10 | - | |
| 11 | -import com.gumptech.sdk.GumpPreference; | |
| 12 | -import com.gumptech.sdk.GumpSDK; | |
| 13 | -import com.gumptech.sdk.PaymentVersion; | |
| 14 | -import com.gumptech.sdk.SDKSettings; | |
| 15 | -import com.gumptech.sdk.bean.GumpUser; | |
| 16 | -import com.gumptech.sdk.bean.PurchaseResult; | |
| 17 | -import com.gumptech.sdk.callback.InitializeCallback; | |
| 18 | -import com.gumptech.sdk.callback.LoginStateListener; | |
| 19 | -import com.gumptech.sdk.callback.PurchaseCallback; | |
| 20 | -import com.gumptech.sdk.callback.ResultCallback; | |
| 21 | -import com.gumptech.sdk.passport.fb.FBAccessToken; | |
| 22 | - | |
| 23 | -import java.util.Locale; | |
| 24 | - | |
| 25 | -public class MainActivity extends AppCompatActivity implements PurchaseCallback { | |
| 26 | - | |
| 27 | - private static final String TAG = "MainActivity"; | |
| 28 | - | |
| 29 | - private TextView tvVersion; | |
| 30 | - private TextView userInfo; | |
| 31 | - | |
| 32 | - private Button btnLoginOrLogout; | |
| 33 | - private Button btnInit; | |
| 34 | - private Button btnCheckState; | |
| 35 | - private Button btnPay; | |
| 36 | - private Button btnIap; | |
| 37 | - | |
| 38 | - private String appId = "100"; | |
| 39 | - private String appKey = "f899139df5e1059396431415e770c6dd"; | |
| 40 | - private GumpUser gumpUser; | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * 测试数据 | |
| 44 | - */ | |
| 45 | - String serverId = "100"; | |
| 46 | - String roleId = "41080"; | |
| 47 | - | |
| 48 | - | |
| 49 | - @Override | |
| 50 | - protected void onCreate(Bundle savedInstanceState) { | |
| 51 | - super.onCreate(savedInstanceState); | |
| 52 | - setContentView(R.layout.activity_main); | |
| 53 | - | |
| 54 | - tvVersion = findViewById(R.id.version); | |
| 55 | - userInfo = findViewById(R.id.user_info); | |
| 56 | - btnLoginOrLogout = findViewById(R.id.login_or_logout); | |
| 57 | - btnInit = findViewById(R.id.init); | |
| 58 | - btnCheckState = findViewById(R.id.check_state); | |
| 59 | - btnLoginOrLogout.setOnClickListener(new View.OnClickListener() { | |
| 60 | - | |
| 61 | - @Override | |
| 62 | - public void onClick(View v) { | |
| 63 | - if (btnLoginOrLogout.getTag() == null || (Integer) btnLoginOrLogout.getTag() == 0) | |
| 64 | - GumpSDK.start(MainActivity.this); | |
| 65 | - else | |
| 66 | - GumpSDK.logout(MainActivity.this); | |
| 67 | - } | |
| 68 | - }); | |
| 69 | - btnInit.setOnClickListener(new View.OnClickListener() { | |
| 70 | - @Override | |
| 71 | - public void onClick(View v) { | |
| 72 | - btnInit.setEnabled(false); | |
| 73 | - GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | |
| 74 | - @Override | |
| 75 | - public void initComplete(int result) { | |
| 76 | - if (result == GumpSDK.CODE.OK) { | |
| 77 | - btnLoginOrLogout.setEnabled(true); | |
| 78 | - userInfo.setText("initialization has finished"); | |
| 79 | - } else { | |
| 80 | - btnInit.setEnabled(true); | |
| 81 | - userInfo.setText("initialization has error"); | |
| 82 | - } | |
| 83 | - } | |
| 84 | - }); | |
| 85 | - } | |
| 86 | - }); | |
| 87 | - btnCheckState.setOnClickListener(new View.OnClickListener() { | |
| 88 | - @Override | |
| 89 | - public void onClick(View v) { | |
| 90 | -// btnCheckState.setEnabled(false); | |
| 91 | - GumpSDK.shouldUseCoPay(MainActivity.this, serverId, roleId, new ResultCallback() { | |
| 92 | - @Override | |
| 93 | - public void onResult(boolean isRisk) { | |
| 94 | - btnIap.setEnabled(isRisk); | |
| 95 | - btnPay.setEnabled(isRisk); | |
| 96 | - } | |
| 97 | - }); | |
| 98 | - } | |
| 99 | - }); | |
| 100 | - btnPay = findViewById(R.id.pay); | |
| 101 | - btnPay.setOnClickListener(new View.OnClickListener() { | |
| 102 | - | |
| 103 | - @Override | |
| 104 | - public void onClick(View v) { | |
| 105 | - PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(new PaymentInfoSubmitFragment.OnSubmitListener() { | |
| 106 | - @Override | |
| 107 | - public void onSubmit(Bundle payInfo) { | |
| 108 | - GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); | |
| 109 | - } | |
| 110 | - }); | |
| 111 | - submitFragment.show(getSupportFragmentManager(), "pay"); | |
| 112 | - } | |
| 113 | - }); | |
| 114 | - btnIap = findViewById(R.id.iap); | |
| 115 | - btnIap.setOnClickListener(new View.OnClickListener() { | |
| 116 | - @Override | |
| 117 | - public void onClick(View v) { | |
| 118 | - PaymentInfoSubmitFragment submitFragment = PaymentInfoSubmitFragment.newInstance(new PaymentInfoSubmitFragment.OnSubmitListener() { | |
| 119 | - @Override | |
| 120 | - public void onSubmit(Bundle payInfo) { | |
| 121 | - GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | |
| 122 | - } | |
| 123 | - }); | |
| 124 | - submitFragment.show(getSupportFragmentManager(), "iap"); | |
| 125 | - } | |
| 126 | - }); | |
| 127 | - | |
| 128 | - | |
| 129 | - Log.i("DEMO", "country:" + Locale.getDefault().getCountry() + ",language:" + Locale.getDefault().getLanguage()); | |
| 130 | - | |
| 131 | - GumpSDK.getSettings().setDebug(false); | |
| 132 | - /** | |
| 133 | - * 设置是否打印debug日志 | |
| 134 | - */ | |
| 135 | - GumpSDK.getSettings().enableDebugLogging(true); | |
| 136 | - /** | |
| 137 | - * 设置启用facebook登录 | |
| 138 | - */ | |
| 139 | - GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_FB); | |
| 140 | - | |
| 141 | - /** | |
| 142 | - * 设置启用google登录 | |
| 143 | - */ | |
| 144 | - GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_GOOGLE); | |
| 145 | - | |
| 146 | - /** | |
| 147 | - * 设置启用Line登录 | |
| 148 | - */ | |
| 149 | - GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_LINE); | |
| 150 | - | |
| 151 | - /** | |
| 152 | - * 设置支付版本 | |
| 153 | - */ | |
| 154 | - GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | |
| 155 | - | |
| 156 | - /** | |
| 157 | - * 设置用户登录状态监听器 | |
| 158 | - */ | |
| 159 | - | |
| 160 | - GumpSDK.setUserStateListener(new LoginStateListener() { | |
| 161 | - @Override | |
| 162 | - public void onLoginSuccess(GumpUser user) { | |
| 163 | - btnCheckState.setEnabled(true); | |
| 164 | - gumpUser = user; | |
| 165 | - String userType = null; | |
| 166 | - switch (user.getAccountType()) { | |
| 167 | - case GumpPreference.ACCOUNT_TYPE_FB: | |
| 168 | - userType = "Facebook登录"; | |
| 169 | - String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | |
| 170 | - Log.d(TAG, "FBAccessToken:" + fbToken); | |
| 171 | - break; | |
| 172 | - case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | |
| 173 | - userType = "快速登录"; | |
| 174 | - break; | |
| 175 | - case GumpPreference.ACCOUNT_TYPE_REG: | |
| 176 | - userType = "gump注册用户"; | |
| 177 | - break; | |
| 178 | - case GumpPreference.ACCOUNT_TYPE_GOOGLE: | |
| 179 | - userType = "google 登录"; | |
| 180 | - break; | |
| 181 | - case GumpPreference.ACCOUNT_TYPE_LINE: | |
| 182 | - userType = "Line登录"; | |
| 183 | - break; | |
| 184 | - } | |
| 185 | - userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey() | |
| 186 | - .getToken()); | |
| 187 | - btnLoginOrLogout.setText("Logout"); | |
| 188 | - btnLoginOrLogout.setTag(1); | |
| 189 | - } | |
| 190 | - | |
| 191 | - @Override | |
| 192 | - public void onLoginFailed(int code, String msg) { | |
| 193 | - userInfo.setText(msg); | |
| 194 | - Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | |
| 195 | - } | |
| 196 | - | |
| 197 | - @Override | |
| 198 | - public void onLoginCanceled() { | |
| 199 | - Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | |
| 200 | - } | |
| 201 | - | |
| 202 | - @Override | |
| 203 | - public void onLogout() { | |
| 204 | - btnLoginOrLogout.setText("Login"); | |
| 205 | - btnLoginOrLogout.setTag(0); | |
| 206 | - userInfo.setText("User is logout"); | |
| 207 | - } | |
| 208 | - | |
| 209 | - @Override | |
| 210 | - public void onPermissionDenied(String[] deniedPermissions) { | |
| 211 | - StringBuilder sb = new StringBuilder(); | |
| 212 | - for (String s : deniedPermissions) { | |
| 213 | - sb.append(s); | |
| 214 | - sb.append(","); | |
| 215 | - } | |
| 216 | - Toast.makeText(MainActivity.this, "Permission denied:" + sb.toString(), Toast.LENGTH_SHORT).show(); | |
| 217 | - } | |
| 218 | - }); | |
| 219 | - /** | |
| 220 | - * 初始化sdk | |
| 221 | - */ | |
| 222 | - GumpSDK.init(getApplicationContext(), appId, appKey, "1000", new InitializeCallback() { | |
| 223 | - @Override | |
| 224 | - public void initComplete(int result) { | |
| 225 | - if (result == GumpSDK.CODE.OK) { | |
| 226 | - btnLoginOrLogout.setEnabled(true); | |
| 227 | - userInfo.setText("initialization has finished"); | |
| 228 | - | |
| 229 | - //checkRisk(); | |
| 230 | - } else { | |
| 231 | - btnInit.setEnabled(true); | |
| 232 | - userInfo.setText("initialization has error"); | |
| 233 | - } | |
| 234 | - } | |
| 235 | - }); | |
| 236 | - | |
| 237 | - tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); | |
| 238 | - | |
| 239 | - } | |
| 240 | - | |
| 241 | - private void checkRisk() { | |
| 242 | - GumpSDK.checkRisk(this, new ResultCallback() { | |
| 243 | - @Override | |
| 244 | - public void onResult(boolean isRisk) { | |
| 245 | - Log.i(TAG, isRisk ? "There is some risks" : "Nothing is risk"); | |
| 246 | - } | |
| 247 | - }); | |
| 248 | - } | |
| 249 | - | |
| 250 | - @Override | |
| 251 | - public void onPurchaseCompleted(PurchaseResult result) { | |
| 252 | - Log.i(TAG, "purchase completed"); | |
| 253 | - } | |
| 254 | - | |
| 255 | - @Override | |
| 256 | - public void onPurchaseError(int code, String msg) { | |
| 257 | - Log.i(TAG, "purchase error:"+code+","+msg); | |
| 258 | - } | |
| 259 | - | |
| 260 | - @Override | |
| 261 | - public void onPurchaseCanceled() { | |
| 262 | - Log.i(TAG, "purchase canceled"); | |
| 263 | - } | |
| 264 | - | |
| 265 | - | |
| 266 | -} |
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/PaymentInfoSubmitFragment.java
| ... | ... | @@ -1,144 +0,0 @@ |
| 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.text.Editable; | |
| 11 | -import android.text.TextUtils; | |
| 12 | -import android.text.TextWatcher; | |
| 13 | -import android.view.LayoutInflater; | |
| 14 | -import android.view.View; | |
| 15 | - | |
| 16 | - | |
| 17 | - | |
| 18 | -public class PaymentInfoSubmitFragment extends DialogFragment { | |
| 19 | - | |
| 20 | - interface OnSubmitListener { | |
| 21 | - void onSubmit(Bundle payInfo); | |
| 22 | - } | |
| 23 | - | |
| 24 | - private OnSubmitListener listener; | |
| 25 | - | |
| 26 | - TextInputLayout etProduct, | |
| 27 | - etAmount, | |
| 28 | - etCurrency, | |
| 29 | - etServerId, | |
| 30 | - etRoleId, | |
| 31 | - etExtra; | |
| 32 | - | |
| 33 | - | |
| 34 | - | |
| 35 | - public static PaymentInfoSubmitFragment newInstance(OnSubmitListener listener) { | |
| 36 | - PaymentInfoSubmitFragment fragment = new PaymentInfoSubmitFragment(); | |
| 37 | - fragment.listener = listener; | |
| 38 | - return fragment; | |
| 39 | - } | |
| 40 | - | |
| 41 | - @NonNull | |
| 42 | - @Override | |
| 43 | - public Dialog onCreateDialog(Bundle savedInstanceState) { | |
| 44 | - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |
| 45 | - View view = LayoutInflater.from(getContext()).inflate(R.layout.fragment_payment, null, false); | |
| 46 | - etProduct = view.findViewById(R.id.product); | |
| 47 | - etAmount = view.findViewById(R.id.amount); | |
| 48 | - etCurrency = view.findViewById(R.id.currency); | |
| 49 | - etServerId = view.findViewById(R.id.server_id); | |
| 50 | - etRoleId = view.findViewById(R.id.role_id); | |
| 51 | - etExtra = view.findViewById(R.id.extra); | |
| 52 | - etProduct.getEditText().addTextChangedListener(new EditTextWatcher(etProduct)); | |
| 53 | - etAmount.getEditText().addTextChangedListener(new EditTextWatcher(etAmount)); | |
| 54 | - etCurrency.getEditText().addTextChangedListener(new EditTextWatcher(etCurrency)); | |
| 55 | - etServerId.getEditText().addTextChangedListener(new EditTextWatcher(etServerId)); | |
| 56 | - etRoleId.getEditText().addTextChangedListener(new EditTextWatcher(etRoleId)); | |
| 57 | - etExtra.getEditText().addTextChangedListener(new EditTextWatcher(etExtra)); | |
| 58 | - //设置默认值 | |
| 59 | - etProduct.getEditText().setText("EV1.test.abc"); | |
| 60 | - etAmount.getEditText().setText("0.99"); | |
| 61 | - etCurrency.getEditText().setText("USD"); | |
| 62 | - etServerId.getEditText().setText("100"); | |
| 63 | - etRoleId.getEditText().setText("41080"); | |
| 64 | - view.findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() { | |
| 65 | - @Override | |
| 66 | - public void onClick(View v) { | |
| 67 | - String product = etProduct.getEditText().getText().toString(); | |
| 68 | - String currency = etCurrency.getEditText().getText().toString(); | |
| 69 | - String serverId = etServerId.getEditText().getText().toString(); | |
| 70 | - String roleId = etRoleId.getEditText().getText().toString(); | |
| 71 | - String extra = etExtra.getEditText().getText().toString(); | |
| 72 | - String amount = etAmount.getEditText().getText().toString(); | |
| 73 | - if (checkInput(product, amount, currency, serverId, roleId, extra)) { | |
| 74 | - Bundle payInfo = new Bundle(); | |
| 75 | - payInfo.putString("product", product); | |
| 76 | - payInfo.putFloat("amount", Float.valueOf(amount)); | |
| 77 | - payInfo.putString("extraInfo", extra); | |
| 78 | - payInfo.putString("serverId", serverId); | |
| 79 | - payInfo.putString("roleId", roleId); | |
| 80 | - payInfo.putString("currency", currency); | |
| 81 | - if (listener != null) { | |
| 82 | - listener.onSubmit(payInfo); | |
| 83 | - } | |
| 84 | - dismiss(); | |
| 85 | - } | |
| 86 | - } | |
| 87 | - }); | |
| 88 | - AlertDialog dialog = builder.setView(view).create(); | |
| 89 | - return dialog; | |
| 90 | - } | |
| 91 | - | |
| 92 | - | |
| 93 | - private boolean checkInput(String product, String amount, String currency, String serverId, String roleId, String extra) { | |
| 94 | - if (TextUtils.isEmpty(product)) { | |
| 95 | - etProduct.setError("product is empty"); | |
| 96 | - return false; | |
| 97 | - } | |
| 98 | - if (TextUtils.isEmpty(currency)) { | |
| 99 | - etCurrency.setError("currency is empty"); | |
| 100 | - return false; | |
| 101 | - } | |
| 102 | - if (TextUtils.isEmpty(serverId)) { | |
| 103 | - etServerId.setError("serverId is empty"); | |
| 104 | - return false; | |
| 105 | - } | |
| 106 | - if (TextUtils.isEmpty(roleId)) { | |
| 107 | - etRoleId.setError("roleId is empty"); | |
| 108 | - return false; | |
| 109 | - } | |
| 110 | - if (TextUtils.isEmpty(extra)) { | |
| 111 | - etExtra.setError("extra is empty"); | |
| 112 | - return false; | |
| 113 | - } | |
| 114 | - if (TextUtils.isEmpty(amount)) { | |
| 115 | - etAmount.setError("amount is empty"); | |
| 116 | - return false; | |
| 117 | - } | |
| 118 | - return true; | |
| 119 | - } | |
| 120 | - | |
| 121 | - class EditTextWatcher implements TextWatcher { | |
| 122 | - | |
| 123 | - private TextInputLayout editText; | |
| 124 | - | |
| 125 | - public EditTextWatcher(TextInputLayout editText) { | |
| 126 | - this.editText = editText; | |
| 127 | - } | |
| 128 | - | |
| 129 | - @Override | |
| 130 | - public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |
| 131 | - | |
| 132 | - } | |
| 133 | - | |
| 134 | - @Override | |
| 135 | - public void onTextChanged(CharSequence s, int start, int before, int count) { | |
| 136 | - editText.setError(null); | |
| 137 | - } | |
| 138 | - | |
| 139 | - @Override | |
| 140 | - public void afterTextChanged(Editable s) { | |
| 141 | - | |
| 142 | - } | |
| 143 | - } | |
| 144 | -} |
GameSDKDemo/src/main/res/layout/activity_main.xml
| ... | ... | @@ -19,19 +19,10 @@ |
| 19 | 19 | android:textColor="@android:color/black"/> |
| 20 | 20 | |
| 21 | 21 | <Button |
| 22 | - android:id="@+id/init" | |
| 23 | - android:layout_width="match_parent" | |
| 24 | - android:layout_height="wrap_content" | |
| 25 | - android:backgroundTint="@color/g_color" | |
| 26 | - android:enabled="false" | |
| 27 | - android:text="@string/init"/> | |
| 28 | - | |
| 29 | - <Button | |
| 30 | 22 | android:id="@+id/login_or_logout" |
| 31 | 23 | android:layout_width="match_parent" |
| 32 | 24 | android:layout_height="wrap_content" |
| 33 | 25 | android:backgroundTint="@color/g_color" |
| 34 | - android:enabled="false" | |
| 35 | 26 | android:text="@string/login"/> |
| 36 | 27 | |
| 37 | 28 | <Button |
GameSDKDemo/src/main/res/layout/fragment_payment.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 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 | |
| 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 | + <com.google.android.material.textfield.TextInputLayout | |
| 11 | 11 | android:id="@+id/product" |
| 12 | 12 | android:layout_width="match_parent" |
| 13 | 13 | android:layout_height="wrap_content"> |
| ... | ... | @@ -15,11 +15,10 @@ |
| 15 | 15 | <EditText |
| 16 | 16 | android:layout_width="match_parent" |
| 17 | 17 | android:layout_height="wrap_content" |
| 18 | - android:hint="@string/hint_product" | |
| 19 | - /> | |
| 20 | - </android.support.design.widget.TextInputLayout> | |
| 18 | + android:hint="@string/hint_product" /> | |
| 19 | + </com.google.android.material.textfield.TextInputLayout> | |
| 21 | 20 | |
| 22 | - <android.support.design.widget.TextInputLayout | |
| 21 | + <com.google.android.material.textfield.TextInputLayout | |
| 23 | 22 | android:id="@+id/amount" |
| 24 | 23 | android:layout_width="match_parent" |
| 25 | 24 | android:layout_height="wrap_content"> |
| ... | ... | @@ -28,22 +27,21 @@ |
| 28 | 27 | android:layout_width="match_parent" |
| 29 | 28 | android:layout_height="wrap_content" |
| 30 | 29 | android:hint="@string/hint_amount" |
| 31 | - android:inputType="numberDecimal"/> | |
| 32 | - </android.support.design.widget.TextInputLayout> | |
| 30 | + android:inputType="numberDecimal" /> | |
| 31 | + </com.google.android.material.textfield.TextInputLayout> | |
| 33 | 32 | |
| 34 | - <android.support.design.widget.TextInputLayout | |
| 33 | + <com.google.android.material.textfield.TextInputLayout | |
| 35 | 34 | android:id="@+id/currency" |
| 36 | 35 | android:layout_width="match_parent" |
| 37 | 36 | android:layout_height="wrap_content"> |
| 38 | 37 | |
| 39 | 38 | <EditText |
| 40 | - | |
| 41 | 39 | android:layout_width="match_parent" |
| 42 | 40 | android:layout_height="wrap_content" |
| 43 | - android:hint="@string/hint_currency"/> | |
| 44 | - </android.support.design.widget.TextInputLayout> | |
| 41 | + android:hint="@string/hint_currency" /> | |
| 42 | + </com.google.android.material.textfield.TextInputLayout> | |
| 45 | 43 | |
| 46 | - <android.support.design.widget.TextInputLayout | |
| 44 | + <com.google.android.material.textfield.TextInputLayout | |
| 47 | 45 | android:id="@+id/server_id" |
| 48 | 46 | android:layout_width="match_parent" |
| 49 | 47 | android:layout_height="wrap_content"> |
| ... | ... | @@ -52,10 +50,10 @@ |
| 52 | 50 | |
| 53 | 51 | android:layout_width="match_parent" |
| 54 | 52 | android:layout_height="wrap_content" |
| 55 | - android:hint="@string/hint_server_id"/> | |
| 56 | - </android.support.design.widget.TextInputLayout> | |
| 53 | + android:hint="@string/hint_server_id" /> | |
| 54 | + </com.google.android.material.textfield.TextInputLayout> | |
| 57 | 55 | |
| 58 | - <android.support.design.widget.TextInputLayout | |
| 56 | + <com.google.android.material.textfield.TextInputLayout | |
| 59 | 57 | android:id="@+id/role_id" |
| 60 | 58 | android:layout_width="match_parent" |
| 61 | 59 | android:layout_height="wrap_content"> |
| ... | ... | @@ -64,10 +62,10 @@ |
| 64 | 62 | |
| 65 | 63 | android:layout_width="match_parent" |
| 66 | 64 | android:layout_height="wrap_content" |
| 67 | - android:hint="@string/hint_role_id"/> | |
| 68 | - </android.support.design.widget.TextInputLayout> | |
| 65 | + android:hint="@string/hint_role_id" /> | |
| 66 | + </com.google.android.material.textfield.TextInputLayout> | |
| 69 | 67 | |
| 70 | - <android.support.design.widget.TextInputLayout | |
| 68 | + <com.google.android.material.textfield.TextInputLayout | |
| 71 | 69 | android:id="@+id/extra" |
| 72 | 70 | android:layout_width="match_parent" |
| 73 | 71 | android:layout_height="wrap_content"> |
| ... | ... | @@ -76,14 +74,14 @@ |
| 76 | 74 | |
| 77 | 75 | android:layout_width="match_parent" |
| 78 | 76 | android:layout_height="wrap_content" |
| 79 | - android:hint="@string/hint_extra"/> | |
| 80 | - </android.support.design.widget.TextInputLayout> | |
| 77 | + android:hint="@string/hint_extra" /> | |
| 78 | + </com.google.android.material.textfield.TextInputLayout> | |
| 81 | 79 | |
| 82 | 80 | <Button |
| 83 | 81 | android:id="@+id/submit" |
| 84 | 82 | android:layout_width="match_parent" |
| 85 | 83 | android:layout_height="wrap_content" |
| 86 | - android:text="@string/go_pay"/> | |
| 84 | + android:text="@string/go_pay" /> | |
| 87 | 85 | |
| 88 | 86 | |
| 89 | 87 | </LinearLayout> |
| 90 | 88 | \ No newline at end of file |
GameSDKDemo/src/test/java/com/gump/game/sdk/demo/ExampleUnitTest.java
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +package com.gump.game.sdk.demo; | |
| 2 | + | |
| 3 | +import org.junit.Test; | |
| 4 | + | |
| 5 | +import static org.junit.Assert.*; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * To work on unit tests, switch the Test Artifact in the Build Variants view. | |
| 9 | + */ | |
| 10 | +public class ExampleUnitTest { | |
| 11 | + @Test | |
| 12 | + public void addition_isCorrect() throws Exception { | |
| 13 | + assertEquals(4, 2 + 2); | |
| 14 | + } | |
| 15 | +} | |
| 0 | 16 | \ No newline at end of file |
GameSDKDemo/src/test/java/com/gumptech/sdk/demo/ExampleUnitTest.java
| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | -package com.gumptech.sdk.demo; | |
| 2 | - | |
| 3 | -import org.junit.Test; | |
| 4 | - | |
| 5 | -import static org.junit.Assert.*; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * To work on unit tests, switch the Test Artifact in the Build Variants view. | |
| 9 | - */ | |
| 10 | -public class ExampleUnitTest { | |
| 11 | - @Test | |
| 12 | - public void addition_isCorrect() throws Exception { | |
| 13 | - assertEquals(4, 2 + 2); | |
| 14 | - } | |
| 15 | -} | |
| 16 | 0 | \ No newline at end of file |
README.md
| 1 | 1 | # Gump SDK 4 for Android接入文档 |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -V4.7.8 | |
| 5 | -2019年12月20日 | |
| 4 | +V4.8.0 | |
| 5 | +2020年01月15日 | |
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | ## 版本概述 |
| 9 | 9 | |
| 10 | -此版本为使用AndroidStudio开发的版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. | |
| 10 | +此版本为使用AndroidStudio开发的版本,使用aar的方式提供sdk接入包,并使用gradle在线依赖方式,aar内别不包含依赖包,请按此文档描述接入. | |
| 11 | 11 | |
| 12 | 12 | 此SDK适用android4.0以上系统. |
| 13 | 13 | |
| ... | ... | @@ -21,7 +21,7 @@ V4.7.8 |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | dependencies { |
| 24 | - implementation 'com.gumptech.sdk:GameSDK:4.7.8' | |
| 24 | + implementation 'com.gumptech.sdk:GameSDK:4.8.0' | |
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | |
| ... | ... | @@ -38,15 +38,15 @@ V4.7.8 |
| 38 | 38 | 其次注册相应的Activity,具体如下: |
| 39 | 39 | |
| 40 | 40 | <activity |
| 41 | - android:name="com.gumptech.sdk.ContainerActivity" | |
| 41 | + android:name="com.gump.game.sdk.PassportActivity" | |
| 42 | 42 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 43 | 43 | android:launchMode="singleTask" |
| 44 | - android:theme="@style/Theme.Origin" //登录界面的主题,可选项:Theme.Origin\Theme.Orange\Theme.Blue | |
| 44 | + android:theme="@style/Theme.Origin" //登录界面的主题,可选项:Theme.Origin\Theme.Orange\Theme.Blue\Theme.Pink | |
| 45 | 45 | android:screenOrientation="behind" |
| 46 | 46 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> |
| 47 | 47 | </activity> |
| 48 | 48 | <activity |
| 49 | - android:name="com.gumptech.sdk.PaymentActivity" | |
| 49 | + android:name="com.gump.game.sdk.RechargeActivity" | |
| 50 | 50 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
| 51 | 51 | android:launchMode="singleTask" |
| 52 | 52 | android:screenOrientation="behind" |
| ... | ... | @@ -66,33 +66,29 @@ V4.7.8 |
| 66 | 66 | |
| 67 | 67 | *是否打印debug日志 |
| 68 | 68 | |
| 69 | - GumpSDK.getSettings().enableDebugLogging(true); | |
| 69 | + GameSDK.getSettings().enableDebugLogging(true); | |
| 70 | 70 | |
| 71 | 71 | *设置需要启用的第三方登录,参数可选类型见第二章:[第三方登录平台](http://repository.gumptech.com:81/document/gamesdk4-android/blob/master/IntegrationGuide.md#1-third_plat) 字段说明 |
| 72 | 72 | |
| 73 | - GumpSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_*); | |
| 73 | + GameSDK.getSettings().requestThirdSupport(SDKSettings.THIRD_SUPPORT_*); | |
| 74 | 74 | |
| 75 | -*若要使用V4版支付请设置 | |
| 76 | 75 | |
| 77 | - GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | |
| 78 | - | |
| 79 | -#### 1.调用GumpSDK前需要执行初始化。 | |
| 76 | +#### 1.调用GameSDK前需要执行初始化。 | |
| 80 | 77 | |
| 81 | 78 | 若不需要分渠道 |
| 82 | 79 | |
| 83 | - GumpSDK.init(Context,Appid, Appkey,InitializeCallback); | |
| 80 | + GameSDK.init(Context,Appid); | |
| 84 | 81 | 如果需要定义渠道,必须使用如下方法 |
| 85 | 82 | |
| 86 | - GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); | |
| 83 | + GameSDK.init(Context,Appid,ChannelId); | |
| 87 | 84 | |
| 88 | -InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 | |
| 89 | 85 | |
| 90 | -#### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | |
| 86 | +#### 2.调用GameSDK的登录方法,将执行登录流程,需要一个Activity实例作参数 | |
| 91 | 87 | |
| 92 | - GumpSDK.start(Activity); | |
| 88 | + GameSDK.login(Activity); | |
| 93 | 89 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: |
| 94 | 90 | |
| 95 | - GumpSDK.setUserStateListener(new LoginStateListener() { | |
| 91 | + GameSDK.setUserStateListener(new LoginStateListener() { | |
| 96 | 92 | @Override |
| 97 | 93 | public void onLoginSuccess(GumpUser gumpUser) { |
| 98 | 94 | //登录成功,用户信息包含在GumpUser对象里 |
| ... | ... | @@ -128,20 +124,20 @@ InitializeCallback为初始化回调接口,此接口只有一个回调方法init |
| 128 | 124 | gumpUser.getSessionKey();//登录的sessionKey对象,获取sessionKey字符串请使用此对象的getToken()方法 |
| 129 | 125 | |
| 130 | 126 | #### 3.支付功能 |
| 131 | -调用支付前需先获取支付状态,根据状态调用支付方法 | |
| 127 | +调用支付前需先判断支付状态,根据状态调用支付方法 | |
| 132 | 128 | |
| 133 | - GumpSDK.shouldUseCoPay(Activity, serverId, roleId, new ResultCallback() { | |
| 129 | + GameSDK.iapUsable(Activity, serverId, roleId, new ResultCallback() { | |
| 134 | 130 | @Override |
| 135 | 131 | public void onResult(boolean result) { |
| 136 | 132 | if(result){ |
| 137 | - //调用GumpSDK.iap | |
| 133 | + //调用GameSDK.iap | |
| 138 | 134 | }else{ |
| 139 | - //调用GumpSDK.pay | |
| 135 | + //调用GameSDK.pay | |
| 140 | 136 | } |
| 141 | 137 | } |
| 142 | 138 | }); |
| 143 | 139 | |
| 144 | -1)调用GumpSDK.pay | |
| 140 | +1)调用GameSDK.pay | |
| 145 | 141 | |
| 146 | 142 | Bundle payInfo = new Bundle(); |
| 147 | 143 | payInfo.putString("product", "元宝"); |
| ... | ... | @@ -167,7 +163,7 @@ InitializeCallback为初始化回调接口,此接口只有一个回调方法init |
| 167 | 163 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 |
| 168 | 164 | |
| 169 | 165 | @Override |
| 170 | - public void onPurchaseCompleted(PurchaseResult result) { | |
| 166 | + public void onPurchaseCompleted() { | |
| 171 | 167 | Log.i(TAG,"purchase completed"); |
| 172 | 168 | } |
| 173 | 169 | |
| ... | ... | @@ -183,11 +179,11 @@ InitializeCallback为初始化回调接口,此接口只有一个回调方法init |
| 183 | 179 | |
| 184 | 180 | #### 4.注销登录 |
| 185 | 181 | |
| 186 | - GumpSDK.logout(Activity); | |
| 182 | + GameSDK.logout(Activity); | |
| 187 | 183 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 |
| 188 | 184 | #### 5.运营开关接口,若需要接入,会有我方运营人员提出需求,否则不需要接入(若对此接口不知所云,即可认为不需要接入,请自行忽略) |
| 189 | 185 | |
| 190 | - GumpSDK.checkRisk(this, new ResultCallback() { | |
| 186 | + GameSDK.inspectRiskLevel(this, new ResultCallback() { | |
| 191 | 187 | @Override |
| 192 | 188 | public void onResult(boolean result) { |
| 193 | 189 | Log.i(TAG,result?"There is some risks":"Nothing is risk"); |
| ... | ... | @@ -223,9 +219,8 @@ InitializeCallback为初始化回调接口,此接口只有一个回调方法init |
| 223 | 219 | -keep public class * extends android.app.Service |
| 224 | 220 | -keep public class com.google.vending.licensing.ILicensingService |
| 225 | 221 | -keep public class com.android.vending.licensing.ILicensingService |
| 226 | - -keep class com.gumptech.sdk.view.* {*;} | |
| 227 | - -keep class com.gumptech.sdk.web.* {*;} | |
| 228 | - -keep class com.gumptech.sdk.bridge.impl.*{*;} | |
| 222 | + -keep class com.gump.game.sdk.view.* {*;} | |
| 223 | + -keep class com.gump.game.sdk.web.* {*;} | |
| 229 | 224 | |
| 230 | 225 | |
| 231 | 226 | 使得混淆的时候不会影响SDK的命名空间。 |
| 232 | 227 | \ No newline at end of file |