Commit 7bb9515948d8419847e511aad620031c73b1ff4a

Authored by 赵康
1 parent 6cda3647ed
Exists in master

add sample project

Showing 14 changed files with 333 additions and 0 deletions Inline Diff

android/GameSDKSample/.classpath
File was created 1 <?xml version="1.0" encoding="UTF-8"?>
2 <classpath>
3 <classpathentry kind="src" path="src"/>
4 <classpathentry kind="src" path="gen"/>
5 <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6 <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7 <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
8 <classpathentry kind="output" path="bin/classes"/>
9 </classpath>
10
android/GameSDKSample/.project
File was created 1 <?xml version="1.0" encoding="UTF-8"?>
2 <projectDescription>
3 <name>GameSDKSample</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.jdt.core.javabuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>com.android.ide.eclipse.adt.ApkBuilder</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 </buildSpec>
29 <natures>
30 <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31 <nature>org.eclipse.jdt.core.javanature</nature>
32 </natures>
33 </projectDescription>
34
android/GameSDKSample/AndroidManifest.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.gumptech.loginsdk.sample"
4 android:versionCode="4"
5 android:versionName="1.4" >
6
7 <uses-sdk
8 android:minSdkVersion="8"
9 android:targetSdkVersion="8" />
10
11 <uses-permission android:name="android.permission.INTERNET" />
12 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
13 <uses-permission android:name="android.permission.BLUETOOTH" />
14 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
15 <uses-permission android:name="android.permission.WRITE_SETTINGS" />
16 <uses-permission android:name="android.permission.GET_ACCOUNTS" />
17 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
18 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
19 <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
20 <!-- for card.io card scanning -->
21 <uses-permission android:name="android.permission.CAMERA" />
22 <uses-permission android:name="android.permission.VIBRATE" />
23
24 <uses-feature
25 android:name="android.hardware.camera"
26 android:required="false" />
27 <uses-feature
28 android:name="android.hardware.camera.autofocus"
29 android:required="false" />
30 <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. -->
31 <uses-permission android:name="com.android.vending.BILLING" />
32
33 <application
34 android:allowBackup="true"
35 android:icon="@drawable/ic_launcher"
36 android:label="@string/app_name" >
37 <activity
38 android:name="com.gumptech.loginsdk.sample.MainActivity"
39 android:configChanges="navigation|orientation|keyboard"
40 android:label="@string/app_name"
41 android:screenOrientation="portrait" >
42 <intent-filter>
43 <action android:name="android.intent.action.MAIN" />
44
45 <category android:name="android.intent.category.LAUNCHER" />
46 </intent-filter>
47 </activity>
48 <activity
49 android:name="com.gumptech.sdk.ContainerActivity"
50 android:configChanges="orientation|screenLayout"
51 android:screenOrientation="portrait"
52 android:theme="@style/container_dialog" >
53 </activity>
54 <activity
55 android:name="com.facebook.LoginActivity"
56 android:theme="@android:style/Theme.Translucent.NoTitleBar" >
57 </activity>
58 <activity
59 android:name="com.gumptech.sdk.PaymentActivity"
60 android:configChanges="orientation|screenLayout"
61 android:theme="@android:style/Theme.Translucent.NoTitleBar" >
62 </activity>
63
64 <activity
65 android:name="com.gumptech.sdk.ExchangeWindow"
66 android:configChanges="orientation|screenLayout"
67 android:theme="@style/ex_win" >
68 </activity>
69 <!-- paypal -->
70 <service
71 android:name="com.paypal.android.sdk.payments.PayPalService"
72 android:exported="false" />
73
74 <activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
75 <activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
76 <activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
77 <activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
78 <activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" />
79 <activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" />
80 <activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" />
81 <activity
82 android:name="io.card.payment.CardIOActivity"
83 android:configChanges="keyboardHidden|orientation" />
84 <activity android:name="io.card.payment.DataEntryActivity" />
85 </application>
86
87 </manifest>
android/GameSDKSample/lint.xml
File was created 1 <?xml version="1.0" encoding="UTF-8"?>
2 <lint>
3 <issue id="MissingTranslation" severity="warning" />
4 </lint>
android/GameSDKSample/proguard-project.txt
File was created 1 # To enable ProGuard in your project, edit project.properties
2 # to define the proguard.config property as described in that file.
3 #
4 # Add project specific ProGuard rules here.
5 # By default, the flags in this file are appended to flags specified
6 # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 # You can edit the include path and order by changing the ProGuard
8 # include property in project.properties.
9 #
10 # For more details, see
11 # http://developer.android.com/guide/developing/tools/proguard.html
12
13 # Add any project specific keep options here:
14
15 # If your project uses WebView with JS, uncomment the following
16 # and specify the fully qualified class name to the JavaScript interface
17 # class:
18 #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 # public *;
20 #}
21
android/GameSDKSample/project.properties
File was created 1 # This file is automatically generated by Android Tools.
2 # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 #
4 # This file must be checked in Version Control Systems.
5 #
6 # To customize properties used by the Ant build system edit
7 # "ant.properties", and override values to adapt the script to your
8 # project structure.
9 #
10 # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12
13 # Project target.
14
15 target=android-18
16 android.library.reference.1=../GameSDKRelease
17
android/GameSDKSample/res/drawable-hdpi/ic_launcher.png

9.18 KB

android/GameSDKSample/res/drawable-mdpi/ic_launcher.png

5.11 KB

android/GameSDKSample/res/drawable-xhdpi/ic_launcher.png

14 KB

android/GameSDKSample/res/layout/activity_main.xml
File was created 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="match_parent"
3 android:layout_height="match_parent"
4 android:background="@android:color/white"
5 android:orientation="vertical" >
6
7 <TextView
8 android:id="@+id/user_info"
9 android:layout_width="wrap_content"
10 android:layout_height="wrap_content" />
11
12 <Button
13 android:id="@+id/logout"
14 android:layout_width="wrap_content"
15 android:layout_height="wrap_content"
16 android:text="logout"
17 android:visibility="gone" />
18
19 <Button
20 android:id="@+id/bind"
21 android:layout_width="wrap_content"
22 android:layout_height="wrap_content"
23 android:text="bound"
24 android:visibility="gone" />
25
26 <Button
27 android:id="@+id/pay"
28 android:layout_width="wrap_content"
29 android:layout_height="wrap_content"
30 android:text="pay" />
31
32 </LinearLayout>
android/GameSDKSample/res/values-w820dp/dimens.xml
File was created 1 <resources>
2
3 <!--
4 Example customization of dimensions originally defined in res/values/dimens.xml
5 (such as screen margins) for screens with more than 820dp of available width. This
6 would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
7 -->
8 <dimen name="activity_horizontal_margin">64dp</dimen>
9
10 </resources>
11
android/GameSDKSample/res/values/dimens.xml
File was created 1 <resources>
2
3 <!-- Default screen margins, per the Android Design guidelines. -->
4 <dimen name="activity_horizontal_margin">16dp</dimen>
5 <dimen name="activity_vertical_margin">16dp</dimen>
6
7 </resources>
8
android/GameSDKSample/res/values/strings.xml
File was created 1 <?xml version="1.0" encoding="utf-8"?>
2 <resources>
3
4 <string name="app_name">LoginSDKSample</string>
5 <string name="hello_world">Hello world!</string>
6 <string name="action_settings">Settings</string>
7
8 </resources>
9
android/GameSDKSample/src/com/gumptech/loginsdk/sample/MainActivity.java
File was created 1 package com.gumptech.loginsdk.sample;
2
3 import android.app.Activity;
4 import android.content.Intent;
5 import android.os.Bundle;
6 import android.util.Log;
7 import android.view.View;
8 import android.widget.Button;
9 import android.widget.TextView;
10 import android.widget.Toast;
11
12 import com.gumptech.sdk.GumpPreference;
13 import com.gumptech.sdk.GumpSDK;
14
15 public class MainActivity extends Activity implements GumpSDK.Callback {
16
17 private TextView userInfo;
18
19 private Button btnLogout;
20 private Button btnBind;
21
22 @Override
23 protected void onCreate(Bundle savedInstanceState) {
24 super.onCreate(savedInstanceState);
25 setContentView(R.layout.activity_main);
26 userInfo = (TextView) findViewById(R.id.user_info);
27 btnLogout = (Button) findViewById(R.id.logout);
28 btnBind = (Button) findViewById(R.id.bind);
29 btnLogout.setOnClickListener(new View.OnClickListener() {
30
31 @Override
32 public void onClick(View v) {
33 GumpSDK.logout(MainActivity.this, MainActivity.this);
34 }
35 });
36 btnBind.setOnClickListener(new View.OnClickListener() {
37
38 @Override
39 public void onClick(View v) {
40 GumpSDK.boundMail(MainActivity.this);
41 }
42 });
43 findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() {
44
45 @Override
46 public void onClick(View v) {
47 Bundle payInfo = new Bundle();
48 payInfo.putString("nick", "thi");
49 payInfo.putString("product", "元宝");
50 payInfo.putFloat("amount", 0.0f);
51 payInfo.putString("extraInfo", "This is demo!");
52 GumpSDK.pay(MainActivity.this, payInfo);
53 }
54 });
55 GumpSDK.init("10009", "483d8df877b31405c1e8fe4247f02d86", "301596413332339", "1000", "4003", "120");
56 GumpSDK.start(this);
57 }
58
59 @Override
60 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
61 Log.d("Main", "activity requestCode:" + requestCode + ",resultCode:" + resultCode);
62 if (requestCode == GumpSDK.LOGIN_REQUEST_CODE) {
63 if (resultCode == RESULT_OK) {
64 int uid = data.getIntExtra("userId", -1);
65 int accountType = data.getIntExtra("accountType", -1);
66 String sessionkey = data.getStringExtra("sessionKey");
67 userInfo.setText("userid:" + uid + ",accountType:" + accountType + ",sessionKey:" + sessionkey);
68 btnLogout.setVisibility(View.VISIBLE);
69 if (accountType == GumpPreference.ACCOUNT_TYPE_QUICK_REG)
70 btnBind.setVisibility(View.VISIBLE);
71 } else if (resultCode == RESULT_CANCELED) {
72 Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show();
73 }
74 } else if (requestCode == GumpSDK.BOUND_REQUEST_CODE) {
75 if (resultCode == RESULT_OK) {
76 int uid = data.getIntExtra("userId", -1);
77 int accountType = data.getIntExtra("accountType", -1);
78 String sessionkey = data.getStringExtra("sessionKey");
79 userInfo.setText("userid:" + uid + ",accountType:" + accountType + ",sessionKey:" + sessionkey);
80 btnBind.setVisibility(View.GONE);
81 } else if (resultCode == RESULT_CANCELED) {
82 Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show();
83 }
84 } else if (requestCode == GumpSDK.PAY_REQUEST_CODE) {
85 if (resultCode == RESULT_OK) {
86 int code = data.getIntExtra("code", -1);
87 String msg = data.getStringExtra("msg");
88 int orderId = data.getIntExtra("orderId", -1);
89 String extraInfo = data.getStringExtra("extraInfo");
90 Toast.makeText(this, "pay result: " + code + "," + msg + ",orderId:" + orderId + ",extraInfo:" + extraInfo, Toast.LENGTH_SHORT).show();
91 } else if (resultCode == RESULT_CANCELED) {
92 Toast.makeText(this, "operate be canceled", Toast.LENGTH_SHORT).show();
93 }
94 }
95 super.onActivityResult(requestCode, resultCode, data);
96 }
97
98 @Override
99 public void onLogout() {
100 btnLogout.setVisibility(View.GONE);
101 if (btnBind.getVisibility() == View.VISIBLE)
102 btnBind.setVisibility(View.GONE);
103 userInfo.append(" is logout");
104 }
105
106 }
107