Commit f905cc4105f59921e7840dbd80421509955603fe

Authored by 赵康
1 parent 083363adac
Exists in master

SDK has update to 5.1.0

Showing 17 changed files with 768 additions and 63 deletions Inline Diff

1 # Gump SDK 5 for Android接入文档 1 # Gump SDK 5 for Android接入文档
2 2
3 V5.0.0 3 V5.1.0
4 2018年11月02日 4 2019年03月18日
5 5
6 ## 版本概述 6 ## 版本概述
7 7
8 此版本为使用AndroidStudio开发的版本,使用aar在线依赖的方式提供sdk接入包,相对上一版本没有任何继承关系,请按此文档描述接入. 8 此版本为使用AndroidStudio开发的版本,使用aar在线依赖的方式提供sdk接入包,相对上一版本没有任何继承关系,请按此文档描述接入.
9 9
10 此SDK适用android4.0以上系统. 10 此SDK适用android4.0以上系统.
11 11
12 本SDK分为两个部分:登录和支付,请按需引用依赖包. 12 本SDK分为两个部分:登录和支付,请按需引用依赖包.
13 13
14 ## 第一章 接入指南 14 ## 第一章 接入指南
15 ### 1.依赖导入 15 ### 1.依赖导入
16 配置gradle,以下为必须项 16 配置gradle,以下为必须项
17 17
18 repositories{ 18 repositories{
19 maven{ 19 maven{
20 url "http://117.50.8.198:8081/nexus/content/repositories/sdk" 20 url "http://117.50.8.198:8081/nexus/content/repositories/sdk"
21 } 21 }
22 } 22 }
23 dependencies { 23 dependencies {
24 //基础功能依赖,必须 24 //基础功能依赖,必须
25 implementation 'com.gump:base:5.0.0' 25 implementation 'com.gump:base:5.1.0'
26 //登录功能依赖 26 //登录功能依赖
27 implementation 'com.gump:Passport:5.0.0' 27 implementation 'com.gump:Passport:5.1.0'
28 //支付功能依赖 28 //支付功能依赖
29 implementation 'com.gump:Payment:5.0.0' 29 implementation 'com.gump:Payment:5.1.0'
30 } 30 }
31 31
32 ### 2.修改AndroidManifest.xml文件 32 ### 2.修改AndroidManifest.xml文件
33 首先添加必要的权限,如下所示: 33 首先添加必要的权限,如下所示:
34 34
35 <uses-permission android:name="android.permission.INTERNET" /> 35 <uses-permission android:name="android.permission.INTERNET" />
36 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 36 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
37 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 37 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
38 <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> 38 <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. -->
39 <uses-permission android:name="com.android.vending.BILLING" /> 39 <uses-permission android:name="com.android.vending.BILLING" />
40 40
41 创建一个strings 配置如下 41 创建一个strings 配置如下
42 42
43 <string name="app_id">your_play_games_app_id</string> 43 <string name="app_id">your_play_games_app_id</string>
44 44
45 增加play games的meta-data配置 45 增加play games的meta-data配置
46 46
47 <meta-data 47 <meta-data
48 android:name="com.google.android.gms.games.APP_ID" 48 android:name="com.google.android.gms.games.APP_ID"
49 android:value="@string/app_id"/> 49 android:value="@string/app_id"/>
50 <meta-data 50 <meta-data
51 android:name="com.google.android.gms.version" 51 android:name="com.google.android.gms.version"
52 android:value="@integer/google_play_services_version"/> 52 android:value="@integer/google_play_services_version"/>
53 53
54 ### 3.1 初始化与配置 54 ### 3.1 初始化与配置
55 *横竖屏控制,默认为横屏,参数为false即为竖屏
56
57 SDKAgent.getSettings().setScreenLandscape(true);
58 55
59 *若要使用V4版支付请设置 56 *若要使用V4版支付请设置
60 57
61 SDKAgent.getSettings().setPaymentVersion(PaymentVersion.V4); 58 SDKAgent.getSettings().setPaymentVersion(PaymentVersion.V4);
62 59
63 *执行初始化 60 *执行初始化
64 61
65 SDKAgent.init(Context,Appid,ChannelId); 62 SDKAgent.init(Context,Appid,ChannelId);
66 63
67 ### 3.2 登录接入 64 ### 3.2 登录接入
65 AndroidManifest.xml配置:
66
67 <activity
68 android:name="com.gump.gpassport.GumpLoginActivity"
69 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"
70 android:launchMode="singleTask"
71 android:screenOrientation="behind"
72 android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
68 构建Passport实例 73 构建Passport实例
69 74
70 passport = new Passport.Builder().context(Context).setListener(StateListener).build(); 75 passport = new Passport.Builder().context(Context).setListener(StateListener).build();
71 76
72 其中StateListener为登录状态监听接口,需要实现如下方法 77 其中StateListener为登录状态监听接口,需要实现如下方法
73 78
74 //成功回调,成功事件类型由action枚举对象标识,player是成功返回的玩家对象 79 //成功回调,成功事件类型由action枚举对象标识,player是成功返回的玩家对象
75 void onActionSucced(Actions action, GamePlayer player) 80 void onActionSucced(Actions action, GamePlayer player)
76 //失败回调 81 //失败回调
77 void onActionFailured() 82 void onActionFailured()
78 83
79 接下来,添加生命周期处理方法 84 接下来,添加生命周期处理方法
80 85
81 @Override 86 @Override
82 protected void onResume() { 87 protected void onResume() {
83 super.onResume(); 88 super.onResume();
84 passport.onResume(); 89 passport.onResume();
85 } 90 }
86 91
87 处理结果返回 92 处理结果返回
88 93
89 @Override 94 @Override
90 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 95 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
91 if (!passport.onActivityResult(requestCode, resultCode, data)) 96 if (!passport.onActivityResult(requestCode, resultCode, data))
92 super.onActivityResult(requestCode, resultCode, data); 97 super.onActivityResult(requestCode, resultCode, data);
93 } 98 }
94 99
95 ### 3.3 支付接入 100 ### 3.3 账号绑定
101
102 passport.link(Activity);
103
104 ### 3.4 账号切换
105 切换到系统账号
106
107 passport.switchAccount(PlayerType.GamePlayer);
108 切换gump账号
109
110 passport.switchAccount(PlayerType.GumpPlayer);
111 ### 3.5 支付接入
96 注册相应的Activity,具体如下: 112 注册相应的Activity,具体如下:
97 113
98 <activity 114 <activity
99 android:name="com.gumptech.sdk.PaymentActivity" 115 android:name="com.gumptech.sdk.PaymentActivity"
100 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" 116 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"
101 android:launchMode="singleTask" 117 android:launchMode="singleTask"
118 android:screenOrientation="behind"
102 android:theme="@android:style/Theme.Translucent.NoTitleBar" > 119 android:theme="@android:style/Theme.Translucent.NoTitleBar" >
103 <intent-filter> 120 <intent-filter>
104 <category android:name="android.intent.category.DEFAULT" /> 121 <category android:name="android.intent.category.DEFAULT" />
105 <action android:name="android.intent.action.VIEW" /> 122 <action android:name="android.intent.action.VIEW" />
106 <category android:name="android.intent.category.BROWSABLE" /> 123 <category android:name="android.intent.category.BROWSABLE" />
107 <data 124 <data
108 android:host="com.gump.sdk" 125 android:host="com.gump.sdk"
109 android:scheme="gump+游戏的appId" /> 126 android:scheme="gump+游戏的appId" />
110 </intent-filter> 127 </intent-filter>
111 </activity> 128 </activity>
112 129
113 三方支付调用 130 三方支付调用
114 131
115 Bundle payInfo = new Bundle(); 132 Bundle payInfo = new Bundle();
116 payInfo.putString("product", "wa2"); 133 payInfo.putString("product", "wa2");
117 payInfo.putFloat("amount", 0.1f); 134 payInfo.putFloat("amount", 0.1f);
118 payInfo.putString("extraInfo", "This is demo!"); 135 payInfo.putString("extraInfo", "This is demo!");
119 payInfo.putString("serverId", "100"); 136 payInfo.putString("serverId", "100");
120 payInfo.putString("roleId", "41080"); 137 payInfo.putString("roleId", "41080");
121 Payment.pay(Activity, payInfo, PurchaseCallback); 138 Payment.pay(Activity, payInfo, PurchaseCallback);
122 139
123 Google IAB支付调用 140 Google IAB支付调用
124 141
125 Bundle payInfo = new Bundle(); 142 Bundle payInfo = new Bundle();
126 payInfo.putString("product", "180010"); 143 payInfo.putString("product", "180010");
127 payInfo.putFloat("amount", 0.1f); 144 payInfo.putFloat("amount", 0.1f);
128 payInfo.putString("extraInfo", "This is demo!"); 145 payInfo.putString("extraInfo", "This is demo!");
129 payInfo.putString("serverId", "100"); 146 payInfo.putString("serverId", "100");
130 payInfo.putString("roleId", "41080"); 147 payInfo.putString("roleId", "41080");
131 Payment.launchIAP(Activity, payInfo, PurchaseCallback); 148 Payment.launchIAP(Activity, payInfo, PurchaseCallback);
132 149
133 PurchaseCallback为支付状态回调接口,此接口含有3个方法 150 PurchaseCallback为支付状态回调接口,此接口含有3个方法
134 151
135 @Override 152 @Override
136 public void onPurchaseCompleted(PurchaseResult result) { 153 public void onPurchaseCompleted(PurchaseResult result) {
137 Log.i(TAG,"purchase completed"); 154 Log.i(TAG,"purchase completed");
138 } 155 }
139 156
140 @Override 157 @Override
141 public void onPurchaseError(int code, String msg) { 158 public void onPurchaseError(int code, String msg) {
142 Log.i(TAG,"purchase error"); 159 Log.i(TAG,"purchase error");
143 } 160 }
144 161
145 @Override 162 @Override
146 public void onPurchaseCanceled() { 163 public void onPurchaseCanceled() {
147 Log.i(TAG,"purchase canceled"); 164 Log.i(TAG,"purchase canceled");
148 } 165 }
149 166
150 ## 第二章 常见问题 167 ## 第二章 常见问题
151 ### 问题1: 如何避免混淆对SDK的影响? 168 ### 问题1: 如何避免混淆对SDK的影响?
152 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java 169 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java
153 类,导致SDK无法正常工作,解决方法如下: 170 类,导致SDK无法正常工作,解决方法如下:
154 Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 171 Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上
155 172
1 apply plugin: 'com.android.application' 1 apply plugin: 'com.android.application'
2 2
3 3
4 android { 4 android {
5 compileSdkVersion 27 5 compileSdkVersion 27
6 defaultConfig { 6 defaultConfig {
7 applicationId "com.gump.passport.demo" 7 applicationId "com.gump.passport.demo"
8 minSdkVersion 14 8 minSdkVersion 15
9 targetSdkVersion 27 9 targetSdkVersion 27
10 versionCode 2 10 versionCode 9
11 versionName "1.0.1" 11 versionName "1.0.9"
12 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 vectorDrawables.useSupportLibrary = true
13 } 14 }
14 buildTypes { 15 buildTypes {
15 release { 16 release {
16 minifyEnabled false 17 minifyEnabled false
17 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 } 19 }
19 } 20 }
20 21
21 applicationVariants.all { 22 applicationVariants.all {
22 variant -> 23 variant ->
23 variant.outputs.all { 24 variant.outputs.all {
24 outputFileName = "SDKDemo-" + variant.name + defaultConfig.versionName + ".apk" 25 outputFileName = "SDKDemo-" + variant.name + defaultConfig.versionName + ".apk"
25 } 26 }
26 } 27 }
27 28
28 lintOptions { 29 lintOptions {
29 abortOnError false 30 abortOnError false
30 } 31 }
31 } 32 }
32 33
33 dependencies { 34 dependencies {
34 implementation fileTree(dir: 'libs', include: ['*.jar']) 35 implementation fileTree(dir: 'libs', include: ['*.jar'])
35 implementation 'com.android.support:appcompat-v7:27.1.1' 36 implementation 'com.android.support:appcompat-v7:27.1.1'
37 implementation 'com.android.support:support-v4:27.1.1'
38 implementation 'com.android.support:support-vector-drawable:27.1.1'
36 testImplementation 'junit:junit:4.12' 39 testImplementation 'junit:junit:4.12'
37 40
38 //基础功能依赖,必须 41 //基础功能依赖,必须
39 implementation 'com.gump:base:5.0.0' 42 implementation 'com.gump:base:5.1.0'
40 // implementation project(':base') 43 // implementation project(':base')
41 //登录功能依赖 44 // 登录功能依赖
42 implementation 'com.gump:Passport:5.0.0' 45 implementation 'com.gump:Passport:5.1.0'
43 // implementation project(':passport') 46 // implementation project(':passport')
44 //支付功能依赖 47 //支付功能依赖
45 implementation 'com.gump:Payment:5.0.0' 48 implementation 'com.gump:Payment:5.1.0'
46 // implementation project(':payment') 49 // implementation project(':payment')
47 } 50 }
48 51
app/src/main/AndroidManifest.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.gump.passport.demo"> 3 package="com.gump.passport.demo">
4 4
5 <uses-permission android:name="android.permission.INTERNET"/> 5 <uses-permission android:name="android.permission.INTERNET"/>
6 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 6 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
7 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 7 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
8 8
9 <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> 9 <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. -->
10 <uses-permission android:name="com.android.vending.BILLING"/> 10 <uses-permission android:name="com.android.vending.BILLING"/>
11
11 <application 12 <application
13 android:name=".GameApplication"
12 android:allowBackup="true" 14 android:allowBackup="true"
13 android:icon="@mipmap/ic_launcher" 15 android:icon="@mipmap/ic_launcher"
14 android:label="@string/app_name" 16 android:label="@string/app_name"
15 android:roundIcon="@mipmap/ic_launcher_round" 17 android:roundIcon="@mipmap/ic_launcher_round"
16 android:supportsRtl="true" 18 android:supportsRtl="true"
17 android:theme="@style/AppTheme"> 19 android:theme="@style/AppTheme">
18 <meta-data 20 <meta-data
19 android:name="com.google.android.gms.games.APP_ID" 21 android:name="com.google.android.gms.games.APP_ID"
20 android:value="@string/app_id"/> 22 android:value="@string/app_id"/>
21 <meta-data 23 <meta-data
22 android:name="com.google.android.gms.version" 24 android:name="com.google.android.gms.version"
23 android:value="@integer/google_play_services_version"/> 25 android:value="@integer/google_play_services_version"/>
24 26
25 <activity android:name=".MainActivity"> 27 <activity android:name=".MainActivity">
26 <intent-filter> 28 <intent-filter>
27 <action android:name="android.intent.action.MAIN"/> 29 <action android:name="android.intent.action.MAIN"/>
28 30
29 <category android:name="android.intent.category.LAUNCHER"/> 31 <category android:name="android.intent.category.LAUNCHER"/>
30 </intent-filter> 32 </intent-filter>
31 </activity> 33 </activity>
32
33 <activity 34 <activity
34 android:name="com.gump.payment.PaymentActivity" 35 android:name="com.gump.payment.PaymentActivity"
35 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" 36 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"
37 android:screenOrientation="behind"
36 android:launchMode="singleTask" 38 android:launchMode="singleTask"
37 android:theme="@android:style/Theme.Light.NoTitleBar"> 39 android:theme="@style/Theme.Translucent">
38 <intent-filter> 40 <intent-filter>
39 <category android:name="android.intent.category.DEFAULT"/>
40
41 <action android:name="android.intent.action.VIEW"/> 41 <action android:name="android.intent.action.VIEW"/>
42 42
43 <category android:name="android.intent.category.DEFAULT"/>
44
43 <category android:name="android.intent.category.BROWSABLE"/> 45 <category android:name="android.intent.category.BROWSABLE"/>
44 46
45 <data 47 <data
46 android:host="com.gump.sdk" 48 android:host="com.gump.sdk"
47 android:scheme="gump100"/> 49 android:scheme="gump100"/>
48 </intent-filter> 50 </intent-filter>
49 </activity> 51 </activity>
52 <activity
53 android:name="com.gump.gpassport.GumpLoginActivity"
54 android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout"
55 android:launchMode="singleTask"
56 android:screenOrientation="behind"
57 android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
58 <activity
59 android:name=".SettingsActivity"
60 android:label="@string/title_activity_settings"
61 android:parentActivityName=".MainActivity">
62 <meta-data
63 android:name="android.support.PARENT_ACTIVITY"
64 android:value="com.gump.passport.demo.MainActivity"/>
65 </activity>
app/src/main/java/com/gump/passport/demo/AppCompatPreferenceActivity.java
File was created 1 package com.gump.passport.demo;
2
3 import android.content.res.Configuration;
4 import android.os.Bundle;
5 import android.preference.PreferenceActivity;
6 import android.support.annotation.LayoutRes;
7 import android.support.annotation.Nullable;
8 import android.support.v7.app.ActionBar;
9 import android.support.v7.app.AppCompatDelegate;
10 import android.support.v7.widget.Toolbar;
11 import android.view.MenuInflater;
12 import android.view.View;
13 import android.view.ViewGroup;
14
15 /**
16 * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
17 * to be used with AppCompat.
18 */
19 public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
20
21 private AppCompatDelegate mDelegate;
22
23 @Override
24 protected void onCreate(Bundle savedInstanceState) {
25 getDelegate().installViewFactory();
26 getDelegate().onCreate(savedInstanceState);
27 super.onCreate(savedInstanceState);
28 }
29
30 @Override
31 protected void onPostCreate(Bundle savedInstanceState) {
32 super.onPostCreate(savedInstanceState);
33 getDelegate().onPostCreate(savedInstanceState);
34 }
35
36 public ActionBar getSupportActionBar() {
37 return getDelegate().getSupportActionBar();
38 }
39
40 public void setSupportActionBar(@Nullable Toolbar toolbar) {
41 getDelegate().setSupportActionBar(toolbar);
42 }
43
44 @Override
45 public MenuInflater getMenuInflater() {
46 return getDelegate().getMenuInflater();
47 }
48
49 @Override
50 public void setContentView(@LayoutRes int layoutResID) {
51 getDelegate().setContentView(layoutResID);
52 }
53
54 @Override
55 public void setContentView(View view) {
56 getDelegate().setContentView(view);
57 }
58
59 @Override
60 public void setContentView(View view, ViewGroup.LayoutParams params) {
61 getDelegate().setContentView(view, params);
62 }
63
64 @Override
65 public void addContentView(View view, ViewGroup.LayoutParams params) {
66 getDelegate().addContentView(view, params);
67 }
68
69 @Override
70 protected void onPostResume() {
71 super.onPostResume();
72 getDelegate().onPostResume();
73 }
74
75 @Override
76 protected void onTitleChanged(CharSequence title, int color) {
77 super.onTitleChanged(title, color);
78 getDelegate().setTitle(title);
79 }
80
81 @Override
82 public void onConfigurationChanged(Configuration newConfig) {
83 super.onConfigurationChanged(newConfig);
84 getDelegate().onConfigurationChanged(newConfig);
85 }
86
87 @Override
88 protected void onStop() {
89 super.onStop();
90 getDelegate().onStop();
91 }
92
93 @Override
94 protected void onDestroy() {
95 super.onDestroy();
96 getDelegate().onDestroy();
97 }
98
99 public void invalidateOptionsMenu() {
100 getDelegate().invalidateOptionsMenu();
101 }
102
103 private AppCompatDelegate getDelegate() {
104 if (mDelegate == null) {
105 mDelegate = AppCompatDelegate.create(this, null);
106 }
107 return mDelegate;
108 }
109 }
110
app/src/main/java/com/gump/passport/demo/GameApplication.java
File was created 1 package com.gump.passport.demo;
2
3 import android.app.Application;
4
5 public class GameApplication extends Application {
6 }
7
app/src/main/java/com/gump/passport/demo/MainActivity.java
1 package com.gump.passport.demo; 1 package com.gump.passport.demo;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.content.SharedPreferences;
4 import android.os.Bundle; 5 import android.os.Bundle;
6 import android.preference.PreferenceManager;
5 import android.support.v7.app.AppCompatActivity; 7 import android.support.v7.app.AppCompatActivity;
6 import android.util.Log; 8 import android.util.Log;
9 import android.view.Menu;
10 import android.view.MenuItem;
7 import android.view.View; 11 import android.view.View;
12 import android.widget.Button;
8 import android.widget.TextView; 13 import android.widget.TextView;
14 import android.widget.Toast;
9 15
10 import com.gump.PaymentVersion; 16 import com.gump.PaymentVersion;
11 import com.gump.SDKAgent; 17 import com.gump.SDKAgent;
12 import com.gump.gpassport.Actions; 18 import com.gump.gpassport.Actions;
13 import com.gump.gpassport.GamePlayer; 19 import com.gump.gpassport.GamePlayer;
14 import com.gump.gpassport.Passport; 20 import com.gump.gpassport.Passport;
21 import com.gump.gpassport.PlayerType;
15 import com.gump.gpassport.StateListener; 22 import com.gump.gpassport.StateListener;
16 import com.gump.payment.Payment; 23 import com.gump.payment.Payment;
17 import com.gump.payment.PurchaseCallback; 24 import com.gump.payment.callback.PurchaseCallback;
25 import com.gump.payment.callback.ResultCallback;
18 26
19 public class MainActivity extends AppCompatActivity implements StateListener, PurchaseCallback { 27 public class MainActivity extends AppCompatActivity implements StateListener, PurchaseCallback {
20 28
21 private static final String TAG = "Gump Demo"; 29 private static final String TAG = "MainActivity";
22
23 private Passport passport; 30 private Passport passport;
24
25 private TextView tvInfo; 31 private TextView tvInfo;
32 private View mainLayout;
33 private Button btnLogin;
34
35 private GamePlayer currentPlayer;
26 36
37 private Button btnIab;
38 private Button btnPay;
39 private Button btnCheck;
27 40
28 @Override 41 @Override
29 protected void onCreate(Bundle savedInstanceState) { 42 protected void onCreate(Bundle savedInstanceState) {
30 super.onCreate(savedInstanceState); 43 super.onCreate(savedInstanceState);
31 setContentView(R.layout.activity_main); 44 setContentView(R.layout.activity_main);
32 SDKAgent.init(getApplicationContext(), "100", "1000");
33
34 SDKAgent.getSettings().setDebug(true);
35 SDKAgent.getSettings().setScreenLandscape(true);
36 SDKAgent.getSettings().setPaymentVersion(PaymentVersion.V4);
37 45
38 tvInfo = findViewById(R.id.info); 46 tvInfo = findViewById(R.id.info);
39 passport = new Passport.Builder().context(this).setListener(this).build(); 47 mainLayout = findViewById(R.id.main_layout);
40 findViewById(R.id.login).setOnClickListener(new View.OnClickListener() { 48 btnLogin = findViewById(R.id.login);
49 btnLogin.setOnClickListener(new View.OnClickListener() {
41 @Override 50 @Override
42 public void onClick(View v) { 51 public void onClick(View v) {
43 passport.signIn(MainActivity.this); 52 passport.signIn(MainActivity.this);
44 } 53 }
45 }); 54 });
46 55
47 56 btnCheck = mainLayout.findViewById(R.id.check);
48 findViewById(R.id.iab).setOnClickListener(new View.OnClickListener() { 57 btnCheck.setOnClickListener(new View.OnClickListener() {
49 @Override 58 @Override
50 public void onClick(View v) { 59 public void onClick(View v) {
51 Bundle payInfo = new Bundle(); 60 initPay();
52 payInfo.putString("product", "180010"); 61 }
53 payInfo.putFloat("amount", 0.1f); 62 });
54 payInfo.putString("extraInfo", "This is demo!"); 63 btnIab = mainLayout.findViewById(R.id.iab);
55 payInfo.putString("serverId", "100"); 64 btnIab.setOnClickListener(new View.OnClickListener() {
56 payInfo.putString("roleId", "41080"); 65 @Override
66 public void onClick(View v) {
67 Bundle payInfo = assemblePayBundle();
57 Payment.launchIAP(MainActivity.this, payInfo, MainActivity.this); 68 Payment.launchIAP(MainActivity.this, payInfo, MainActivity.this);
58 } 69 }
59 }); 70 });
60 71
61 findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { 72 btnPay = mainLayout.findViewById(R.id.pay);
73 btnPay.setOnClickListener(new View.OnClickListener() {
62 @Override 74 @Override
63 public void onClick(View v) { 75 public void onClick(View v) {
64 Bundle payInfo = new Bundle(); 76 Bundle payInfo = assemblePayBundle();
65 payInfo.putString("product", "wa2");
66 payInfo.putFloat("amount", 0.1f);
67 payInfo.putString("extraInfo", "This is demo!");
68 payInfo.putString("serverId", "100");
69 payInfo.putString("roleId", "41080");
70 Payment.pay(MainActivity.this, payInfo, MainActivity.this); 77 Payment.pay(MainActivity.this, payInfo, MainActivity.this);
71 } 78 }
72 }); 79 });
80
81 mainLayout.findViewById(R.id.bind).setOnClickListener(new View.OnClickListener() {
82 @Override
83 public void onClick(View v) {
84 passport.link(MainActivity.this);
85 }
86 });
87
88 mainLayout.findViewById(R.id.switch_acc).setOnClickListener(new View.OnClickListener() {
89 @Override
90 public void onClick(View v) {
91 passport.switchAccount(PlayerType.GamePlayer);
92 }
93 });
94
95 mainLayout.findViewById(R.id.switch_gump).setOnClickListener(new View.OnClickListener() {
96 @Override
97 public void onClick(View v) {
98 passport.switchAccount(PlayerType.GumpPlayer);
99 }
100 });
101
102
103 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
104 boolean mode = sp.getBoolean("key_mode", true);
105 String appId = sp.getString("key_appid", "100");
106 String channel = sp.getString("key_channel", "1000");
107 String payVersion = sp.getString("key_pay_version", "V3");
108
109 SDKAgent.init(getApplicationContext(), appId, channel);
110 SDKAgent.getSettings().setDebug(mode);
111 SDKAgent.getSettings().setPaymentVersion(PaymentVersion.valueOf(payVersion));
112
113 passport = new Passport.Builder().context(MainActivity.this).setListener(MainActivity.this).build();
114
115 }
116
117 private Bundle assemblePayBundle() {
118 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
119 Bundle payInfo = new Bundle();
120 payInfo.putString("product", sp.getString("key_product", "10080"));
121 payInfo.putFloat("amount", sp.getFloat("key_amount", 0.1f));
122 payInfo.putString("extraInfo", sp.getString("key_extra", "test"));
123 payInfo.putString("serverId", sp.getString("key_server_id", "100"));
124 payInfo.putString("roleId", sp.getString("key_role_id", "41080"));
125 payInfo.putString("currency", sp.getString("key_currency", "THB"));
126 return payInfo;
127 }
128
129
130 private void initPay() {
131 btnCheck.setEnabled(false);
132 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
133 String serverId = sp.getString("key_server_id", "100");
134 String roleId = sp.getString("key_role_id", "41080");
135 Payment.shouldUseCoPay(this, serverId, roleId, new ResultCallback() {
136 @Override
137 public void onResult(boolean isRisk) {
138 btnCheck.setEnabled(true);
139 btnIab.setEnabled(isRisk);
140 btnPay.setEnabled(!isRisk);
141 }
142 });
143 }
144
145 @Override
146 public boolean onCreateOptionsMenu(Menu menu) {
147 getMenuInflater().inflate(R.menu.main, menu);
148 return super.onCreateOptionsMenu(menu);
149 }
150
151 @Override
152 public boolean onOptionsItemSelected(MenuItem item) {
153 if (item.getItemId() == R.id.setting) {
154 Intent intent = new Intent(this, SettingsActivity.class);
155 startActivity(intent);
156 return true;
157 }
158 return super.onOptionsItemSelected(item);
73 } 159 }
74 160
75 @Override 161 @Override
76 protected void onResume() { 162 public void onResume() {
77 super.onResume(); 163 super.onResume();
78 passport.onResume(); 164 passport.onResume();
79 } 165 }
80 166
81 @Override 167 @Override
82 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 168 public void onActivityResult(int requestCode, int resultCode, Intent data) {
83 if (!passport.onActivityResult(requestCode, resultCode, data)) 169 if (!passport.onActivityResult(requestCode, resultCode, data))
84 super.onActivityResult(requestCode, resultCode, data); 170 super.onActivityResult(requestCode, resultCode, data);
85 } 171 }
86 172
87 @Override 173 @Override
88 public void onActionSucced(Actions action, GamePlayer player) { 174 public void onActionSucced(Actions action, GamePlayer player) {
89 tvInfo.setText("login succed! gump id=" + player.getId() + ",playerType=" + player.getPlayerType()); 175 switch (action) {
176 case SIGN:
177 currentPlayer = player;
178 tvInfo.setText("Login succed! gump id=" + player.getId() + ",playerType=" + player.getPlayerType());
179 btnLogin.setVisibility(View.GONE);
180 mainLayout.setVisibility(View.VISIBLE);
181 break;
182 case SWITCH:
183 tvInfo.setText("Switch account succed! Pls reboot the game!");
184 Toast.makeText(this, "The account has switched,pls reboot the Game!", Toast.LENGTH_LONG).show();
185 break;
186 }
90 } 187 }
91 188
92 @Override 189 @Override
93 public void onActionFailured() { 190 public void onActionFailured(Throwable e) {
94 tvInfo.setText("login has error"); 191 tvInfo.setText("login has error:" + e.getMessage());
95 } 192 }
96 193
97 @Override 194 @Override
98 public void onPurchaseCompleted() { 195 public void onPurchaseCompleted() {
99 Log.i(TAG, "purchase completed"); 196 Log.i(TAG, "purchase completed");
100 } 197 }
app/src/main/java/com/gump/passport/demo/SettingsActivity.java
File was created 1 package com.gump.passport.demo;
2
3 import android.annotation.TargetApi;
4 import android.content.Context;
5 import android.content.Intent;
6 import android.content.res.Configuration;
7 import android.os.Build;
8 import android.os.Bundle;
9 import android.preference.ListPreference;
10 import android.preference.Preference;
11 import android.preference.PreferenceActivity;
12 import android.preference.PreferenceFragment;
13 import android.preference.PreferenceManager;
14 import android.support.annotation.Nullable;
15 import android.support.v4.app.NavUtils;
16 import android.support.v7.app.ActionBar;
17 import android.view.MenuItem;
18
19 import java.util.List;
20
21 /**
22 * A {@link PreferenceActivity} that presents a set of application settings. On
23 * handset devices, settings are presented as a single list. On tablets,
24 * settings are split by category, with category headers shown to the left of
25 * the list of settings.
26 * <p>
27 * See <a href="http://developer.android.com/design/patterns/settings.html">
28 * Android Design: Settings</a> for design guidelines and the <a
29 * href="http://developer.android.com/guide/topics/ui/settings.html">Settings
30 * API Guide</a> for more information on developing a Settings UI.
31 */
32 public class SettingsActivity extends AppCompatPreferenceActivity {
33
34 /**
35 * A preference value change listener that updates the preference's summary
36 * to reflect its new value.
37 */
38 private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
39 @Override
40 public boolean onPreferenceChange(Preference preference, Object value) {
41 String stringValue = value.toString();
42
43 if (preference instanceof ListPreference) {
44 // For list preferences, look up the correct display value in
45 // the preference's 'entries' list.
46 ListPreference listPreference = (ListPreference) preference;
47 int index = listPreference.findIndexOfValue(stringValue);
48
49 // Set the summary to reflect the new value.
50 preference.setSummary(
51 index >= 0
52 ? listPreference.getEntries()[index]
53 : null);
54
55 } else {
56 // For all other preferences, set the summary to the value's
57 // simple string representation.
58 preference.setSummary(stringValue);
59 }
60 return true;
61 }
62 };
63
64 /**
65 * Helper method to determine if the device has an extra-large screen. For
66 * example, 10" tablets are extra-large.
67 */
68 private static boolean isXLargeTablet(Context context) {
69 return (context.getResources().getConfiguration().screenLayout
70 & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
71 }
72
73 /**
74 * Binds a preference's summary to its value. More specifically, when the
75 * preference's value is changed, its summary (line of text below the
76 * preference title) is updated to reflect the value. The summary is also
77 * immediately updated upon calling this method. The exact display format is
78 * dependent on the type of preference.
79 *
80 * @see #sBindPreferenceSummaryToValueListener
81 */
82 private static void bindPreferenceSummaryToValue(Preference preference) {
83 // Set the listener to watch for value changes.
84 preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
85
86 // Trigger the listener immediately with the preference's
87 // current value.
88 sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
89 PreferenceManager.getDefaultSharedPreferences(preference.getContext())
90 .getString(preference.getKey(), ""));
91 }
92
93 @Override
94 protected void onCreate(Bundle savedInstanceState) {
95 super.onCreate(savedInstanceState);
96 setupActionBar();
97 }
98
99 /**
100 * Set up the {@link android.app.ActionBar}, if the API is available.
101 */
102 private void setupActionBar() {
103 ActionBar actionBar = getSupportActionBar();
104 if (actionBar != null) {
105 // Show the Up button in the action bar.
106 actionBar.setDisplayHomeAsUpEnabled(true);
107 }
108 }
109
110 @Override
111 public boolean onMenuItemSelected(int featureId, MenuItem item) {
112 int id = item.getItemId();
113 if (id == android.R.id.home) {
114 if (!super.onMenuItemSelected(featureId, item)) {
115 NavUtils.navigateUpFromSameTask(this);
116 }
117 return true;
118 }
119 return super.onMenuItemSelected(featureId, item);
120 }
121
122 /**
123 * {@inheritDoc}
124 */
125 @Override
126 public boolean onIsMultiPane() {
127 return isXLargeTablet(this);
128 }
129
130 /**
131 * {@inheritDoc}
132 */
133 @Override
134 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
135 public void onBuildHeaders(List<Header> target) {
136 loadHeadersFromResource(R.xml.pref_headers, target);
137 }
138
139 /**
140 * This method stops fragment injection in malicious applications.
141 * Make sure to deny any unknown fragments here.
142 */
143 protected boolean isValidFragment(String fragmentName) {
144 return PreferenceFragment.class.getName().equals(fragmentName)
145 || GeneralPreferenceFragment.class.getName().equals(fragmentName)
146 || ParamPreferenceFragment.class.getName().equals(fragmentName);
147 }
148
149 /**
150 * sdk配置
151 */
152 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
153 public static class GeneralPreferenceFragment extends PreferenceFragment {
154 @Override
155 public void onCreate(Bundle savedInstanceState) {
156 super.onCreate(savedInstanceState);
157 addPreferencesFromResource(R.xml.pref_general);
158 setHasOptionsMenu(true);
159
160 // Bind the summaries of EditText/List/Dialog/Ringtone preferences
161 // to their values. When their values change, their summaries are
162 // updated to reflect the new value, per the Android Design
163 // guidelines.
164 // bindPreferenceSummaryToValue(findPreference("key_mode"));
165 bindPreferenceSummaryToValue(findPreference("key_pay_version"));
166 }
167
168 @Override
169 public boolean onOptionsItemSelected(MenuItem item) {
170 int id = item.getItemId();
171 if (id == android.R.id.home) {
172 startActivity(new Intent(getActivity(), SettingsActivity.class));
173 return true;
174 }
175 return super.onOptionsItemSelected(item);
176 }
177 }
178
179 /**
180 * 基础参数配置
181 */
182 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
183 public static class ParamPreferenceFragment extends PreferenceFragment {
184 @Override
185 public void onCreate(Bundle savedInstanceState) {
186 super.onCreate(savedInstanceState);
187 addPreferencesFromResource(R.xml.pref_param);
188 setHasOptionsMenu(true);
189
190 // Bind the summaries of EditText/List/Dialog/Ringtone preferences
191 // to their values. When their values change, their summaries are
192 // updated to reflect the new value, per the Android Design
193 // guidelines.
194 bindPreferenceSummaryToValue(findPreference("key_appid"));
195 bindPreferenceSummaryToValue(findPreference("key_channel"));
196 }
197
198 @Override
199 public boolean onOptionsItemSelected(MenuItem item) {
200 int id = item.getItemId();
201 if (id == android.R.id.home) {
202 startActivity(new Intent(getActivity(), SettingsActivity.class));
203 return true;
204 }
205 return super.onOptionsItemSelected(item);
206 }
207 }
208
209 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
210 public static class PaymentPreerenceFragment extends PreferenceFragment {
211 @Override
212 public void onCreate(@Nullable Bundle savedInstanceState) {
213 super.onCreate(savedInstanceState);
214 addPreferencesFromResource(R.xml.pref_payment);
215 setHasOptionsMenu(true);
216
217 bindPreferenceSummaryToValue(findPreference("key_server_id"));
218 bindPreferenceSummaryToValue(findPreference("key_role_id"));
219 bindPreferenceSummaryToValue(findPreference("key_product"));
220 bindPreferenceSummaryToValue(findPreference("key_amount"));
221 bindPreferenceSummaryToValue(findPreference("key_currency"));
222 bindPreferenceSummaryToValue(findPreference("key_extra"));
223 }
224
225 @Override
226 public boolean onOptionsItemSelected(MenuItem item) {
227 int id = item.getItemId();
228 if (id == android.R.id.home) {
229 startActivity(new Intent(getActivity(), SettingsActivity.class));
230 return true;
231 }
232 return super.onOptionsItemSelected(item);
233 }
234 }
235 }
236
app/src/main/res/drawable/ic_attach_money_black_24dp.xml
File was created 1 <vector xmlns:android="http://schemas.android.com/apk/res/android"
2 android:width="24dp"
3 android:height="24dp"
4 android:viewportWidth="24.0"
5 android:viewportHeight="24.0">
6 <path
7 android:fillColor="#FF000000"
8 android:pathData="M11.8,10.9c-2.27,-0.59 -3,-1.2 -3,-2.15 0,-1.09 1.01,-1.85 2.7,-1.85 1.78,0 2.44,0.85 2.5,2.1h2.21c-0.07,-1.72 -1.12,-3.3 -3.21,-3.81V3h-3v2.16c-1.94,0.42 -3.5,1.68 -3.5,3.61 0,2.31 1.91,3.46 4.7,4.13 2.5,0.6 3,1.48 3,2.41 0,0.69 -0.49,1.79 -2.7,1.79 -2.06,0 -2.87,-0.92 -2.98,-2.1h-2.2c0.12,2.19 1.76,3.42 3.68,3.83V21h3v-2.15c1.95,-0.37 3.5,-1.5 3.5,-3.55 0,-2.84 -2.43,-3.81 -4.7,-4.4z"/>
9 </vector>
10
app/src/main/res/drawable/ic_build_black_24dp.xml
File was created 1 <vector xmlns:android="http://schemas.android.com/apk/res/android"
2 android:width="24dp"
3 android:height="24dp"
4 android:viewportWidth="24.0"
5 android:viewportHeight="24.0">
6 <path
7 android:fillColor="#FF000000"
8 android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z"/>
9 </vector>
10
app/src/main/res/drawable/ic_text_fields_black_24dp.xml
File was created 1 <vector xmlns:android="http://schemas.android.com/apk/res/android"
2 android:width="24dp"
3 android:height="24dp"
4 android:viewportWidth="24.0"
5 android:viewportHeight="24.0">
6 <path
7 android:fillColor="#FF000000"
8 android:pathData="M2.5,4v3h5v12h3L10.5,7h5L15.5,4h-13zM21.5,9h-9v3h3v7h3v-7h3L21.5,9z"/>
9 </vector>
10
app/src/main/res/layout/activity_main.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout 2 <LinearLayout
3 xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:android="http://schemas.android.com/apk/res/android"
4 xmlns:app="http://schemas.android.com/apk/res-auto"
5 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:tools="http://schemas.android.com/tools"
6 android:layout_width="match_parent" 5 android:layout_width="match_parent"
7 android:layout_height="match_parent" 6 android:layout_height="match_parent"
8 android:orientation="vertical" 7 android:orientation="vertical"
9 tools:context=".MainActivity"> 8 tools:context=".MainActivity">
10 9
11 <TextView 10 <TextView
12 android:id="@+id/info" 11 android:id="@+id/info"
13 android:layout_width="wrap_content" 12 android:layout_width="match_parent"
14 android:layout_height="wrap_content"/> 13 android:layout_height="wrap_content"
14 android:lines="2"/>
15 15
16 <Button 16 <Button
17 android:id="@+id/login" 17 android:id="@+id/login"
18 android:layout_width="match_parent" 18 android:layout_width="match_parent"
19 android:layout_height="wrap_content" 19 android:layout_height="wrap_content"
20 android:text="login"/> 20 android:text="login"/>
21 21
22 <Button
23 android:id="@+id/iab"
24 android:layout_width="match_parent"
25 android:layout_height="wrap_content"
26 android:text="iab"/>
27 22
28 <Button 23 <LinearLayout
29 android:id="@+id/pay" 24 android:id="@+id/main_layout"
30 android:layout_width="match_parent" 25 android:layout_width="match_parent"
31 android:layout_height="wrap_content" 26 android:layout_height="match_parent"
32 android:text="payment"/> 27 android:orientation="vertical"
28 android:visibility="gone">
29
30 <Button
31 android:id="@+id/check"
32 android:layout_width="match_parent"
33 android:layout_height="wrap_content"
34 android:text="check payemnt state"/>
35
36 <Button
37 android:id="@+id/bind"
38 android:layout_width="match_parent"
39 android:layout_height="wrap_content"
40 android:text="Bind Gump account"/>
41
42 <Button
43 android:id="@+id/switch_acc"
44 android:layout_width="match_parent"
45 android:layout_height="wrap_content"
46 android:text="Switch to games player"/>
47
48 <Button
49 android:id="@+id/switch_gump"
50 android:layout_width="match_parent"
51 android:layout_height="wrap_content"
52 android:text="Switch to gump player"/>
53
54 <Button
55 android:id="@+id/iab"
56 android:layout_width="match_parent"
57 android:layout_height="wrap_content"
58 android:enabled="false"
59 android:text="Iab"/>
33 60
61 <Button
62 android:id="@+id/pay"
app/src/main/res/menu/main.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <menu xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto">
4
5 <item
6 android:id="@+id/setting"
7 android:title="设置"
8 app:showAsAction="always"/>
9 </menu>
app/src/main/res/values/strings.xml
1 <resources> 1 <resources>
2 <string name="app_name">PassportDemo</string> 2 <string name="app_name">PassportDemo</string>
3
4 <!-- TODO: Remove or change this placeholder text -->
5 <string name="title_activity_settings">设置</string>
6
7 <!-- Strings related to Settings -->
8
9 <!-- SDK settings -->
10 <string name="pref_header_general">SDK设置</string>
11
12 <string name="pref_title_mode">线上环境</string>
13 <string name="pref_description_mode">SDK是否使用线上正式服务器环境?</string>
14
15 <string name="pref_title_orientation">支付界面方向</string>
16 <string name="pref_description_orientation">是否使用横屏?</string>
17
18 <string name="pref_title_payment_version">支付版本</string>
19
20 <string-array name="pref_payment_version_titles">
21 <item>V3版本</item>
22 <item>V4版本</item>
23 </string-array>
24 <string-array name="pref_payment_version_values">
25 <item>V3</item>
26 <item>V4</item>
27 </string-array>
28
29
30 <!--基础参数设置-->
31 <string name="pref_header_param">基础参数设置</string>
32 <string name="pref_title_appid">appId</string>
33 <string name="pref_description_appid">应用使用的appId</string>
34 <string name="pref_title_channel">ChannelId</string>
35 <string name="pref_description_channel">应用使用的channelId</string>
36 <!--支付参数-->
37 <string name="payment">支付参数</string>
38 <string name="pref_description_server_id">区服id</string>
39 <string name="pref_title_server_id">serverId</string>
40 <string name="pref_description_role_id">角色id</string>
41 <string name="pref_title_role_id">roleId</string>
42 <string name="pref_description_product">商品名/商品id</string>
43 <string name="pref_title_product">product</string>
44 <string name="pref_description_amount">金额</string>
45 <string name="pref_title_amount">支付金额</string>
46 <string name="pref_description_extra">游戏透传参数</string>
47 <string name="pref_title_extra">extra_info</string>
48 <string name="pref_description_currency">支付显示货币</string>
49 <string name="pref_title_currency">currency</string>
50
51
3 </resources> 52 </resources>
4 53
app/src/main/res/xml/pref_general.xml
File was created 1 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
2
3 <SwitchPreference
4 android:defaultValue="true"
5 android:key="key_mode"
6 android:summary="@string/pref_description_mode"
7 android:title="@string/pref_title_mode"/>
8
9
10 <!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
11 dismiss it. -->
12 <!--NOTE: ListPreference's summary should be set to its value by the activity code. -->
13 <ListPreference
14 android:defaultValue="V3"
15 android:entries="@array/pref_payment_version_titles"
16 android:entryValues="@array/pref_payment_version_values"
17 android:key="key_pay_version"
18 android:negativeButtonText="@null"
19 android:positiveButtonText="@null"
20 android:title="@string/pref_title_payment_version"/>
21
22 </PreferenceScreen>
23
app/src/main/res/xml/pref_headers.xml
File was created 1 <preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
2
3 <!-- These settings headers are only used on tablets. -->
4
5 <header
6 android:fragment="com.gump.passport.demo.SettingsActivity$ParamPreferenceFragment"
7 android:icon="@drawable/ic_text_fields_black_24dp"
8 android:title="@string/pref_header_param"/>
9 <header
10 android:fragment="com.gump.passport.demo.SettingsActivity$GeneralPreferenceFragment"
11 android:icon="@drawable/ic_build_black_24dp"
12 android:title="@string/pref_header_general"/>
13 <header
14 android:fragment="com.gump.passport.demo.SettingsActivity$PaymentPreferenceFragment"
15 android:icon="@drawable/ic_attach_money_black_24dp"
16 android:title="@string/payment"/>
17
18 </preference-headers>
19
app/src/main/res/xml/pref_param.xml
File was created 1 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
2
3 <EditTextPreference
4 android:defaultValue="100"
5 android:key="key_appid"
6 android:summary="@string/pref_description_appid"
7 android:title="@string/pref_title_appid"/>
8
9 <!-- NOTE: EditTextPreference accepts EditText attributes. -->
10 <!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
11 <EditTextPreference
12 android:defaultValue="1000"
13 android:key="key_channel"
14 android:summary="@string/pref_description_channel"
15 android:title="@string/pref_title_channel"/>
16
17 <!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
18 dismiss it. -->
19 <!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
20 <!--<ListPreference-->
21 <!--android:defaultValue="-1"-->
22 <!--android:entries="@array/pref_example_list_titles"-->
23 <!--android:entryValues="@array/pref_example_list_values"-->
24 <!--android:key="example_list"-->
25 <!--android:negativeButtonText="@null"-->
26 <!--android:positiveButtonText="@null"-->
27 <!--android:title="@string/pref_title_add_friends_to_messages"/>-->
28
29 </PreferenceScreen>
30
app/src/main/res/xml/pref_payment.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
3
4 <EditTextPreference
5 android:defaultValue="100"
6 android:key="key_server_id"
7 android:summary="@string/pref_description_server_id"
8 android:title="@string/pref_title_server_id"/>
9 <EditTextPreference
10 android:defaultValue="41080"
11 android:key="key_role_id"
12 android:summary="@string/pref_description_role_id"
13 android:title="@string/pref_title_role_id"/>
14 <EditTextPreference
15 android:defaultValue="180010"
16 android:key="key_product"
17 android:summary="@string/pref_description_product"
18 android:title="@string/pref_title_product"/>
19 <EditTextPreference
20 android:defaultValue="0.1"
21 android:key="key_amount"
22 android:summary="@string/pref_description_amount"
23 android:title="@string/pref_title_amount"/>
24 <EditTextPreference
25 android:defaultValue="THB"
26 android:key="key_currency"
27 android:summary="@string/pref_description_currency"
28 android:title="@string/pref_title_currency"/>
29 <EditTextPreference
30 android:defaultValue="test"
31 android:key="key_extra_info"
32 android:summary="@string/pref_description_extra"
33 android:title="@string/pref_title_extra"/>
34 </PreferenceScreen>