diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09b993d --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..950eef7 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1,2 @@ +/build +release diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..47df5b7 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,39 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 27 + defaultConfig { + applicationId "com.gump.passport.demo" + minSdkVersion 14 + targetSdkVersion 27 + versionCode 2 + versionName "1.0.1" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + applicationVariants.all{ + variant-> + variant.outputs.all{ + outputFileName = "SDKDemo-"+variant.name+defaultConfig.versionName+".apk" + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + + implementation project(':base') + implementation project(':passport') + implementation project(':payment') +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/gump/passport/demo/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/gump/passport/demo/ExampleInstrumentedTest.java new file mode 100644 index 0000000..81cd09f --- /dev/null +++ b/app/src/androidTest/java/com/gump/passport/demo/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.gump.passport.demo; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.gump.passport.demo", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9bc1a29 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/gump/passport/demo/MainActivity.java b/app/src/main/java/com/gump/passport/demo/MainActivity.java new file mode 100644 index 0000000..ccaa5bf --- /dev/null +++ b/app/src/main/java/com/gump/passport/demo/MainActivity.java @@ -0,0 +1,111 @@ +package com.gump.passport.demo; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; +import android.view.View; +import android.widget.TextView; + +import com.gump.PaymentVersion; +import com.gump.SDKAgent; +import com.gump.gpassport.Actions; +import com.gump.gpassport.GamePlayer; +import com.gump.gpassport.Passport; +import com.gump.gpassport.StateListener; +import com.gump.payment.Payment; +import com.gump.payment.PurchaseCallback; + +public class MainActivity extends AppCompatActivity implements StateListener, PurchaseCallback { + + private static final String TAG = "Gump Demo"; + + private Passport passport; + + private TextView tvInfo; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + SDKAgent.init(getApplicationContext(), "100", "1000"); + + SDKAgent.getSettings().setDebug(true); + SDKAgent.getSettings().setScreenLandscape(true); + SDKAgent.getSettings().setPaymentVersion(PaymentVersion.V4); + + tvInfo = findViewById(R.id.info); + passport = new Passport.Builder().context(this).setListener(this).build(); + findViewById(R.id.login).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + passport.signIn(MainActivity.this); + } + }); + + + findViewById(R.id.iab).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Bundle payInfo = new Bundle(); + payInfo.putString("product", "180010"); + payInfo.putFloat("amount", 0.1f); + payInfo.putString("extraInfo", "This is demo!"); + payInfo.putString("serverId", "100"); + payInfo.putString("roleId", "41080"); + Payment.launchIAP(MainActivity.this, payInfo, MainActivity.this); + } + }); + + findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Bundle payInfo = new Bundle(); + payInfo.putString("product", "wa2"); + payInfo.putFloat("amount", 0.1f); + payInfo.putString("extraInfo", "This is demo!"); + payInfo.putString("serverId", "100"); + payInfo.putString("roleId", "41080"); + Payment.pay(MainActivity.this, payInfo, MainActivity.this); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + passport.onResume(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (!passport.onActivityResult(requestCode, resultCode, data)) + super.onActivityResult(requestCode, resultCode, data); + } + + @Override + public void onActionSucced(Actions action, GamePlayer player) { + tvInfo.setText("login succed! gump id=" + player.getId() + ",playerType=" + player.getPlayerType()); + } + + @Override + public void onActionFailured() { + tvInfo.setText("login has error"); + } + + @Override + public void onPurchaseCompleted() { + Log.i(TAG, "purchase completed"); + } + + @Override + public void onPurchaseError(int code, String msg) { + Log.i(TAG, "purchase error"); + } + + @Override + public void onPurchaseCanceled() { + Log.i(TAG, "purchase canceled"); + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..485bbd3 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..7ca0909 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..8436d9c --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + + +