Commit 064eb2054994613924aae1966899abf5c04eda24
1 parent
656f5f9fdd
Exists in
master
分离iap支付方法
Showing 11 changed files with 77 additions and 50 deletions Side-by-side Diff
- GameSDK-release4.1.3.aar
- GameSDK-release4.1.4.aar
- GameSDKDemo/GameSDKDemo.iml
- GameSDKDemo/build.gradle
- GameSDKDemo/libs/GameSDK-release4.1.3.aar
- GameSDKDemo/libs/GameSDK-release4.1.4.aar
- GameSDKDemo/src/main/AndroidManifest.xml
- GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
- GameSDKDemo/src/main/res/layout/activity_main.xml
- GameSDKDemo/src/main/res/values/colors.xml
- GameSDKDemo/src/main/res/values/styles.xml
GameSDK-release4.1.3.aar
No preview for this file type
GameSDK-release4.1.4.aar
No preview for this file type
GameSDKDemo/GameSDKDemo.iml
| ... | ... | @@ -66,14 +66,6 @@ |
| 66 | 66 | <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> |
| 67 | 67 | <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> |
| 68 | 68 | <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> |
| 69 | - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> | |
| 70 | - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> | |
| 71 | - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> | |
| 72 | - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" /> | |
| 73 | - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> | |
| 74 | - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> | |
| 75 | - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> | |
| 76 | - <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> | |
| 77 | 69 | <sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" /> |
| 78 | 70 | <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> |
| 79 | 71 | <sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" /> |
| ... | ... | @@ -82,11 +74,19 @@ |
| 82 | 74 | <sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" /> |
| 83 | 75 | <sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" /> |
| 84 | 76 | <sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" /> |
| 77 | + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> | |
| 78 | + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> | |
| 79 | + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> | |
| 80 | + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" /> | |
| 81 | + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> | |
| 82 | + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> | |
| 83 | + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> | |
| 84 | + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> | |
| 85 | 85 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" /> |
| 86 | 86 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> |
| 87 | - <excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" /> | |
| 88 | 87 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> |
| 89 | 88 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" /> |
| 89 | + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/GameSDK-release4.1.4/jars" /> | |
| 90 | 90 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" /> |
| 91 | 91 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" /> |
| 92 | 92 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> |
| ... | ... | @@ -98,6 +98,7 @@ |
| 98 | 98 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" /> |
| 99 | 99 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" /> |
| 100 | 100 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> |
| 101 | + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" /> | |
| 101 | 102 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" /> |
| 102 | 103 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> |
| 103 | 104 | <excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" /> |
| ... | ... | @@ -114,9 +115,7 @@ |
| 114 | 115 | <orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" /> |
| 115 | 116 | <orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" /> |
| 116 | 117 | <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" /> |
| 118 | + <orderEntry type="library" exported="" name="GameSDK-release4.1.4-" level="project" /> | |
| 117 | 119 | <orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" /> |
| 118 | - <orderEntry type="module" module-name="GameSDK" exported="" /> | |
| 119 | - <orderEntry type="library" exported="" name="image-cache" level="project" /> | |
| 120 | - <orderEntry type="library" exported="" name="BluePay_3.6.2.0414pro" level="project" /> | |
| 121 | 120 | </component> |
| 122 | 121 | </module> |
| 123 | 122 | \ No newline at end of file |
GameSDKDemo/build.gradle
| ... | ... | @@ -14,8 +14,8 @@ android { |
| 14 | 14 | defaultConfig { |
| 15 | 15 | minSdkVersion 9 |
| 16 | 16 | targetSdkVersion 22 |
| 17 | - versionCode 1 | |
| 18 | - versionName "1.0" | |
| 17 | + versionCode 2 | |
| 18 | + versionName "1.1" | |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | buildTypes { |
| ... | ... | @@ -33,6 +33,6 @@ dependencies { |
| 33 | 33 | compile fileTree(dir: 'libs', include: ['*.jar']) |
| 34 | 34 | testCompile 'junit:junit:4.12' |
| 35 | 35 | compile 'com.android.support:appcompat-v7:22.2.0' |
| 36 | - compile project(':GameSDK') | |
| 37 | -// compile(name:'GameSDK-release4.1.3',ext:'aar') | |
| 36 | +// compile project(':GameSDK') | |
| 37 | + compile(name:'GameSDK-release4.1.4',ext:'aar') | |
| 38 | 38 | } |
GameSDKDemo/libs/GameSDK-release4.1.3.aar
No preview for this file type
GameSDKDemo/libs/GameSDK-release4.1.4.aar
No preview for this file type
GameSDKDemo/src/main/AndroidManifest.xml
| ... | ... | @@ -7,14 +7,15 @@ |
| 7 | 7 | android:targetSdkVersion="20" /> |
| 8 | 8 | |
| 9 | 9 | <uses-permission android:name="android.permission.INTERNET" /> |
| 10 | - <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |
| 11 | 10 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
| 12 | 11 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
| 13 | 12 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> |
| 14 | - <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | |
| 15 | 13 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
| 16 | - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
| 17 | 14 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> |
| 15 | + <!-- Danger Level permission--> | |
| 16 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
| 17 | + <uses-permission android:name="android.permission.GET_ACCOUNTS" /> | |
| 18 | + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |
| 18 | 19 | <uses-permission android:name="android.permission.SEND_SMS"/> |
| 19 | 20 | |
| 20 | 21 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
| ... | ... | @@ -23,6 +24,7 @@ |
| 23 | 24 | <application |
| 24 | 25 | android:allowBackup="true" |
| 25 | 26 | android:icon="@drawable/ic_launcher" |
| 27 | + | |
| 26 | 28 | android:label="@string/app_name" > |
| 27 | 29 | <activity |
| 28 | 30 | android:name="com.gumptech.sdk.demo.MainActivity" |
GameSDKDemo/src/main/java/com/gumptech/sdk/demo/MainActivity.java
| ... | ... | @@ -20,7 +20,7 @@ import com.gumptech.sdk.callback.LoginStateListener; |
| 20 | 20 | import com.gumptech.sdk.callback.PurchaseCallback; |
| 21 | 21 | import com.gumptech.sdk.passport.fb.FBAccessToken; |
| 22 | 22 | |
| 23 | -public class MainActivity extends Activity implements PurchaseCallback{ | |
| 23 | +public class MainActivity extends Activity implements PurchaseCallback { | |
| 24 | 24 | |
| 25 | 25 | private static final String TAG = "MainActivity"; |
| 26 | 26 | |
| ... | ... | @@ -33,6 +33,7 @@ public class MainActivity extends Activity implements PurchaseCallback{ |
| 33 | 33 | private String appKey = "93a27b0bd99bac3e68a440b48aa421ab"; |
| 34 | 34 | private String sessionKey; |
| 35 | 35 | |
| 36 | + | |
| 36 | 37 | @Override |
| 37 | 38 | protected void onCreate(Bundle savedInstanceState) { |
| 38 | 39 | super.onCreate(savedInstanceState); |
| ... | ... | @@ -59,10 +60,23 @@ public class MainActivity extends Activity implements PurchaseCallback{ |
| 59 | 60 | payInfo.putFloat("amount", 0.1f); |
| 60 | 61 | payInfo.putString("extraInfo", "This is demo!"); |
| 61 | 62 | payInfo.putString("serverId", "100"); |
| 63 | + payInfo.putString("roleId","100123"); | |
| 62 | 64 | payInfo.putString("sessionKey", sessionKey); |
| 63 | 65 | GumpSDK.pay(MainActivity.this, payInfo, MainActivity.this); |
| 64 | 66 | } |
| 65 | 67 | }); |
| 68 | + findViewById(R.id.iap).setOnClickListener(new View.OnClickListener() { | |
| 69 | + @Override | |
| 70 | + public void onClick(View v) { | |
| 71 | + Bundle payInfo = new Bundle(); | |
| 72 | + payInfo.putString("product", "gp_skuId"); | |
| 73 | + payInfo.putFloat("amount", 0.1f); | |
| 74 | + payInfo.putString("extraInfo", "This is demo!"); | |
| 75 | + payInfo.putString("serverId", "100"); | |
| 76 | + payInfo.putString("roleId","100123"); | |
| 77 | + GumpSDK.iap(MainActivity.this, payInfo, MainActivity.this); | |
| 78 | + } | |
| 79 | + }); | |
| 66 | 80 | /** |
| 67 | 81 | * 设置否是打印debug日志 |
| 68 | 82 | */ |
| ... | ... | @@ -88,39 +102,39 @@ public class MainActivity extends Activity implements PurchaseCallback{ |
| 88 | 102 | /** |
| 89 | 103 | * 设置用户登录状态监听器 |
| 90 | 104 | */ |
| 91 | - | |
| 105 | + | |
| 92 | 106 | GumpSDK.setUserStateListener(new LoginStateListener() { |
| 93 | 107 | @Override |
| 94 | 108 | public void onLoginSuccess(GumpUser user) { |
| 95 | - ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | |
| 96 | - cm.setText(user.getSessionKey()); | |
| 109 | + ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | |
| 110 | + cm.setText(user.getSessionKey()); | |
| 97 | 111 | sessionKey = user.getSessionKey(); |
| 98 | - String userType=null; | |
| 99 | - switch(user.getAccountType()){ | |
| 100 | - case GumpPreference.ACCOUNT_TYPE_FB: | |
| 101 | - userType = "Facebook登录"; | |
| 102 | - String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | |
| 103 | - Log.d(TAG,"FBAccessToken:"+fbToken); | |
| 104 | - break; | |
| 105 | - case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | |
| 106 | - userType = "快速登录"; | |
| 107 | - break; | |
| 108 | - case GumpPreference.ACCOUNT_TYPE_REG: | |
| 109 | - userType = "gump注册用户"; | |
| 110 | - break; | |
| 111 | - case GumpPreference.ACCOUNT_TYPE_VK: | |
| 112 | - userType = "vk登录"; | |
| 113 | - break; | |
| 112 | + String userType = null; | |
| 113 | + switch (user.getAccountType()) { | |
| 114 | + case GumpPreference.ACCOUNT_TYPE_FB: | |
| 115 | + userType = "Facebook登录"; | |
| 116 | + String fbToken = FBAccessToken.getCurrentAccessToken().getToken(); | |
| 117 | + Log.d(TAG, "FBAccessToken:" + fbToken); | |
| 118 | + break; | |
| 119 | + case GumpPreference.ACCOUNT_TYPE_QUICK_REG: | |
| 120 | + userType = "快速登录"; | |
| 121 | + break; | |
| 122 | + case GumpPreference.ACCOUNT_TYPE_REG: | |
| 123 | + userType = "gump注册用户"; | |
| 124 | + break; | |
| 125 | + case GumpPreference.ACCOUNT_TYPE_VK: | |
| 126 | + userType = "vk登录"; | |
| 127 | + break; | |
| 114 | 128 | } |
| 115 | - userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType()+") "+userType + "\n sessionKey:" + user.getSessionKey()); | |
| 129 | + userInfo.setText(" Userid:" + user.getUid() + "\n accountType:(" + user.getAccountType() + ") " + userType + "\n sessionKey:" + user.getSessionKey()); | |
| 116 | 130 | btnLoginOrLogout.setText("Logout"); |
| 117 | 131 | btnLoginOrLogout.setTag(1); |
| 118 | 132 | } |
| 119 | 133 | |
| 120 | 134 | @Override |
| 121 | - public void onLoginFailed(int code, String msg) { | |
| 135 | + public void onLoginFailed(int code, String msg) { | |
| 122 | 136 | userInfo.setText(msg); |
| 123 | - Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | |
| 137 | + Toast.makeText(MainActivity.this, "Login failed:code=" + code + ",message=" + msg, Toast.LENGTH_SHORT).show(); | |
| 124 | 138 | } |
| 125 | 139 | |
| 126 | 140 | @Override |
| ... | ... | @@ -148,20 +162,23 @@ public class MainActivity extends Activity implements PurchaseCallback{ |
| 148 | 162 | }); |
| 149 | 163 | |
| 150 | 164 | tvVersion.setText("SDK Version:" + GumpSDK.getVersion()); |
| 165 | + | |
| 151 | 166 | } |
| 152 | 167 | |
| 153 | 168 | @Override |
| 154 | 169 | public void onPurchaseCompleted(PurchaseResult result) { |
| 155 | - Log.i(TAG,"purchase completed"); | |
| 170 | + Log.i(TAG, "purchase completed"); | |
| 156 | 171 | } |
| 157 | 172 | |
| 158 | 173 | @Override |
| 159 | 174 | public void onPurchaseError(int code, String msg) { |
| 160 | - Log.i(TAG,"purchase error"); | |
| 175 | + Log.i(TAG, "purchase error"); | |
| 161 | 176 | } |
| 162 | 177 | |
| 163 | 178 | @Override |
| 164 | 179 | public void onPurchaseCanceled() { |
| 165 | - Log.i(TAG,"purchase canceled"); | |
| 180 | + Log.i(TAG, "purchase canceled"); | |
| 166 | 181 | } |
| 182 | + | |
| 183 | + | |
| 167 | 184 | } |
GameSDKDemo/src/main/res/layout/activity_main.xml
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | android:layout_width="match_parent" |
| 3 | 3 | android:layout_height="match_parent" |
| 4 | 4 | android:background="@android:color/white" |
| 5 | - android:orientation="vertical" > | |
| 5 | + android:orientation="vertical"> | |
| 6 | 6 | |
| 7 | 7 | <TextView |
| 8 | 8 | android:id="@+id/version" |
| ... | ... | @@ -13,21 +13,29 @@ |
| 13 | 13 | |
| 14 | 14 | <TextView |
| 15 | 15 | android:id="@+id/user_info" |
| 16 | - android:layout_width="wrap_content" | |
| 16 | + android:layout_width="match_parent" | |
| 17 | 17 | android:layout_height="wrap_content" |
| 18 | 18 | android:textColor="@android:color/black" /> |
| 19 | 19 | |
| 20 | 20 | <Button |
| 21 | 21 | android:id="@+id/login_or_logout" |
| 22 | - android:layout_width="wrap_content" | |
| 22 | + android:layout_width="match_parent" | |
| 23 | 23 | android:layout_height="wrap_content" |
| 24 | + android:backgroundTint="@color/g_color" | |
| 24 | 25 | android:enabled="false" |
| 25 | 26 | android:text="Login" /> |
| 27 | + <Button | |
| 28 | + android:id="@+id/iap" | |
| 29 | + android:layout_width="match_parent" | |
| 30 | + android:layout_height="wrap_content" | |
| 31 | + android:backgroundTint="@color/g_color" | |
| 32 | + android:text="IAP"/> | |
| 26 | 33 | |
| 27 | 34 | <Button |
| 28 | 35 | android:id="@+id/pay" |
| 29 | - android:layout_width="wrap_content" | |
| 36 | + android:layout_width="match_parent" | |
| 30 | 37 | android:layout_height="wrap_content" |
| 38 | + android:backgroundTint="@color/g_color" | |
| 31 | 39 | android:text="pay" /> |
| 32 | 40 | |
| 33 | 41 | </LinearLayout> |
| 34 | 42 | \ No newline at end of file |
GameSDKDemo/src/main/res/values/colors.xml
GameSDKDemo/src/main/res/values/styles.xml
| 1 | 1 | <resources> |
| 2 | 2 | |
| 3 | 3 | <!-- Base application theme. --> |
| 4 | - <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
| 4 | + <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | |
| 5 | 5 | <!-- Customize your theme here. --> |
| 6 | 6 | <item name="colorPrimary">@color/colorPrimary</item> |
| 7 | 7 | <item name="colorPrimaryDark">@color/colorPrimaryDark</item> |