Browse Source

demo开发

#Suyghur 3 years ago
parent
commit
78cd6f9bb6

+ 8 - 2
.gitignore

@@ -1,3 +1,10 @@
+# IDEA
+*.iml
+.gradle
+.idea
+/local.properties
+.DS_Store
+
 # ---> Android
 # Built application files
 *.apk
@@ -30,5 +37,4 @@ proguard/
 .navigation/
 
 # Android Studio captures folder
-captures/
-
+captures/

+ 33 - 0
build.gradle

@@ -0,0 +1,33 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+
+    ext {
+        kotlin_version = '1.5.30'
+    }
+
+    repositories {
+        mavenCentral()
+        google()
+        maven { url 'https://jitpack.io' }
+        maven { url 'https://maven.aliyun.com/repository/public' }
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:4.1.3'
+        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        mavenCentral()
+        google()
+        maven { url 'https://jitpack.io' }
+        maven { url 'https://maven.aliyun.com/repository/public' }
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 1 - 0
demo/.gitignore

@@ -0,0 +1 @@
+/build

+ 80 - 0
demo/build.gradle

@@ -0,0 +1,80 @@
+plugins {
+    id 'com.android.application'
+    id 'kotlin-android'
+}
+
+def keystorePropertiesFile = rootProject.file("keystore.properties")
+def keystoreProperties = new Properties()
+keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
+
+android {
+    compileSdkVersion 30
+    buildToolsVersion '30.0.3'
+
+    defaultConfig {
+        applicationId "com.gamesdk.qingshi"
+        minSdkVersion 16
+        targetSdkVersion 30
+        versionCode 1
+        versionName "1.0.0"
+        ndk {
+            // 设置支持的SO库架构
+            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
+        }
+    }
+
+    signingConfigs {
+        config {
+            keyAlias keystoreProperties['keyAlias']
+            keyPassword keystoreProperties['keyPassword']
+            storeFile file(keystoreProperties['storeFile'])
+            storePassword keystoreProperties['storePassword']
+            v1SigningEnabled true
+            v2SigningEnabled true
+        }
+    }
+
+    buildTypes {
+        debug {
+            minifyEnabled false
+            signingConfig signingConfigs.config
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+
+        release {
+            minifyEnabled false
+            signingConfig signingConfigs.config
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+
+    lintOptions {
+        abortOnError false
+    }
+
+    repositories {
+        flatDir {
+            dirs 'libs'
+        }
+    }
+
+    dexOptions {
+        preDexLibraries = false
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+
+    kotlinOptions {
+        jvmTarget = '1.8'
+    }
+}
+
+dependencies {
+    implementation 'io.github.yyxxgame.sdk:qingshi-gamesdk-core:2.0.0-alpah1'
+    implementation 'io.github.yyxxgame.sdk:qingshi-gamesdk-analytics:2.0.0-alpah1'
+    implementation 'io.github.yyxxgame.sdk:qingshi-gamesdk-billing:2.0.0-alpah1'
+    implementation 'io.github.yyxxgame.sdk:qingshi-gamesdk-login:2.0.0-alpah2'
+}

+ 21 - 0
demo/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

+ 55 - 0
demo/src/main/AndroidManifest.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.gamesdk.qingshi">
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+
+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
+    <uses-permission android:name="android.permission.CAMERA" />
+
+    <application
+        android:name=".DemoApplication"
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:requestLegacyExternalStorage="true"
+        android:resizeableActivity="false"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme"
+        android:usesCleartextTraffic="true">
+
+        <activity
+            android:name="cn.qingshi.gamesdk.base.WelcomeActivity"
+            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
+            android:launchMode="standard"
+            android:screenOrientation="sensorLandscape"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <activity
+            android:name=".DemoActivity"
+            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
+            android:exported="true"
+            android:launchMode="singleTask"
+            android:screenOrientation="sensorLandscape">
+            <intent-filter>
+                <action android:name="${applicationId}" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>

+ 80 - 0
demo/src/main/assets/qs_game/qs_cfg.properties

@@ -0,0 +1,80 @@
+#出包版本
+QS_PACKAGE_VERSION=20201010
+#分包标识
+QS_CAMPAIGN_ID=9y12un3y
+#应用ID
+QS_APP_ID=21
+#应用秘钥
+QS_APP_KEY=efe5a67ad0c9bdead320a19ce76cc569
+#debug模式(cp出正式包请关闭)
+QS_OWN_DEBUG=true
+
+#头条
+#出包版本
+#QS_PACKAGE_VERSION=20200812
+##分包标识
+#QS_CAMPAIGN_ID=r69k81rl
+##应用ID
+#QS_APP_ID=21
+##应用秘钥
+#QS_APP_KEY=efe5a67ad0c9bdead320a19ce76cc569
+##debug模式(cp出正式包请关闭)
+#QS_OWN_DEBUG=true
+##投放SDK
+#QS_ANALYTICS_ID=1
+
+##广点通
+##出包版本
+#QS_PACKAGE_VERSION=20201204
+##分包标识
+#QS_CAMPAIGN_ID=ir6h266f
+##应用ID
+#QS_APP_ID=21
+##应用秘钥
+#QS_APP_KEY=efe5a67ad0c9bdead320a19ce76cc569
+##debug模式(cp出正式包请关闭)
+#QS_OWN_DEBUG=true
+##投放SDK
+#QS_ANALYTICS_ID=2
+
+##快手
+##出包版本
+#QS_PACKAGE_VERSION=20210507
+##分包标识
+#QS_CAMPAIGN_ID=9y12un3y
+##应用ID
+#QS_APP_ID=21
+##应用秘钥
+#QS_APP_KEY=efe5a67ad0c9bdead320a19ce76cc569
+##debug模式(cp出正式包请关闭)
+#QS_OWN_DEBUG=true
+##投放SDK
+#QS_ANALYTICS_ID=3
+
+##UC
+##出包版本
+#QS_PACKAGE_VERSION=20201126
+##分包标识
+#QS_CAMPAIGN_ID=g799dk6x
+##应用ID
+#QS_APP_ID=21
+##应用秘钥
+#QS_APP_KEY=efe5a67ad0c9bdead320a19ce76cc569
+##debug模式(cp出正式包请关闭)
+#QS_OWN_DEBUG=true
+##投放SDK
+#QS_ANALYTICS_ID=4
+
+##Baidu
+##出包版本
+#QS_PACKAGE_VERSION=20201126
+##分包标识
+#QS_CAMPAIGN_ID=638r0azz
+##应用ID
+#QS_APP_ID=21
+##应用秘钥
+#QS_APP_KEY=efe5a67ad0c9bdead320a19ce76cc569
+##debug模式(cp出正式包请关闭)
+#QS_OWN_DEBUG=true
+##投放SDK
+#QS_ANALYTICS_ID=5

+ 98 - 0
demo/src/main/java/com/gamesdk/qingshi/CacheRoleInfo.kt

@@ -0,0 +1,98 @@
+package com.gamesdk.qingshi
+
+import android.content.Context
+import android.text.TextUtils
+import org.json.JSONException
+import org.json.JSONObject
+
+/**
+ * @author #Suyghur.
+ * Created on 2020/12/7
+ */
+class CacheRoleInfo {
+
+    data class RoleInfo(
+        var roleId: String = "", var roleName: String = "", var roleLevel: String = "",
+        var serverCode: String = "", var serverName: String = "", var vipLevel: String = "",
+        var balance: String = "", var power: String = "0", var roleCTime: String = "0",
+        var roleGender: String = ""
+    ) {
+
+
+        fun toJsonString(): String {
+            try {
+                val jsonObject = JSONObject()
+                jsonObject.put("role_id", roleId)
+                jsonObject.put("role_name", roleName)
+                jsonObject.put("role_level", roleLevel)
+                jsonObject.put("server_code", serverCode)
+                jsonObject.put("server_name", serverName)
+                jsonObject.put("vip_level", vipLevel)
+                jsonObject.put("balance", balance)
+                jsonObject.put("role_gender", roleGender)
+                jsonObject.put("role_ctime", roleCTime)
+                jsonObject.put("power", power)
+                return jsonObject.toString()
+            } catch (e: JSONException) {
+                e.printStackTrace()
+            }
+            return ""
+        }
+    }
+
+    companion object {
+
+        @JvmStatic
+        fun setDemoRoleInfo(context: Context, userId: String): RoleInfo {
+            val ts = System.currentTimeMillis() / 1000
+            val roleInfo = RoleInfo(
+                roleId = "aaa$ts",
+                roleName = "角色名123",
+                roleLevel = "110",
+                serverCode = "333",
+                serverName = "服务器名333",
+                vipLevel = "1",
+                balance = "600",
+                roleGender = "男",
+                roleCTime = "$ts",
+                power = "0"
+            )
+            val info = roleInfo.toJsonString()
+            val sp = context.getSharedPreferences("app_role_info", Context.MODE_PRIVATE)
+            val editor = sp.edit()
+            editor.putString(userId, info)
+            editor.apply()
+            return roleInfo
+        }
+
+        @JvmStatic
+        fun getDemoRoleInfo(context: Context, userId: String): RoleInfo? {
+            try {
+                val sp = context.getSharedPreferences("app_role_info", Context.MODE_PRIVATE)
+                val info = sp.getString(userId, "")
+                return if (TextUtils.isEmpty(info)) {
+                    //没有则创建
+                    setDemoRoleInfo(context, userId)
+                } else {
+                    val jsonObject = JSONObject(info!!)
+                    RoleInfo(
+                        roleId = jsonObject.getString("role_id"),
+                        roleName = jsonObject.getString("role_name"),
+                        roleLevel = jsonObject.getString("role_level"),
+                        serverCode = jsonObject.getString("server_code"),
+                        serverName = jsonObject.getString("server_name"),
+                        vipLevel = jsonObject.getString("vip_level"),
+                        balance = jsonObject.getString("balance"),
+                        roleGender = jsonObject.getString("role_gender"),
+                        roleCTime = jsonObject.getString("role_ctime"),
+                        power = jsonObject.getString("power")
+                    )
+                }
+
+            } catch (e: Exception) {
+                e.printStackTrace()
+            }
+            return null
+        }
+    }
+}

+ 308 - 0
demo/src/main/java/com/gamesdk/qingshi/DemoActivity.java

@@ -0,0 +1,308 @@
+package com.gamesdk.qingshi;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.InputType;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.ScrollView;
+import android.widget.Toast;
+
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.qingshi.gamesdk.base.QSGameSdk;
+import cn.qingshi.gamesdk.base.entity.QSChargeInfo;
+import cn.qingshi.gamesdk.base.entity.QSRoleInfo;
+import cn.qingshi.gamesdk.base.internal.ICallback;
+import cn.yyxx.support.permission.Permission;
+
+/**
+ * @author #Suyghur.
+ * Created on 2021/05/24
+ */
+public class DemoActivity extends Activity implements View.OnClickListener {
+
+
+    private final List<Item> events = new ArrayList<Item>() {{
+        add(new Item(0, "00 账号登录"));
+        add(new Item(1, "01 账号登出"));
+        add(new Item(2, "02 角色创建上报"));
+        add(new Item(3, "03 角色登录上报"));
+        add(new Item(4, "04 角色升级上报"));
+        add(new Item(5, "05 定额充值"));
+        add(new Item(6, "06 权限申请"));
+    }};
+
+    private EditText editText;
+    private CacheRoleInfo.RoleInfo cacheRoleInfo = null;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        initView();
+        QSGameSdk.getInstance().initialize(this, true, new ICallback() {
+            @Override
+            public void onResult(int code, String result) {
+                Toast.makeText(DemoActivity.this, result, Toast.LENGTH_SHORT).show();
+            }
+        });
+    }
+
+    private void initView() {
+        LinearLayout layout = new LinearLayout(this);
+        layout.setOrientation(LinearLayout.VERTICAL);
+        for (Item event : events) {
+            if (event.getId() == 5) {
+                editText = new EditText(this);
+                editText.setHint("请输入金额,单位分");
+                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_CLASS_PHONE);
+                editText.setText("100");
+                layout.addView(editText);
+            }
+
+            Button button = new Button(this);
+            button.setTag(event.getId());
+            button.setText(event.getName());
+            button.setOnClickListener(this);
+            layout.addView(button);
+        }
+
+        ScrollView scrollView = new ScrollView(this);
+        scrollView.addView(layout);
+        setContentView(scrollView);
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (v == null) {
+            return;
+        }
+        switch ((Integer) v.getTag()) {
+            case 0:
+                QSGameSdk.getInstance().login(this, new ICallback() {
+                    @Override
+                    public void onResult(int code, String result) {
+                        if (code == 0) {
+                            try {
+                                JSONObject jsonObject = new JSONObject(result);
+                                String openId = jsonObject.getString("open_id");
+                                String gameToken = jsonObject.getString("game_token");
+                                Toast.makeText(DemoActivity.this, "SDK登录成功\nopen id: " + openId + "\ngame token: " + gameToken, Toast.LENGTH_SHORT).show();
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                            cacheRoleInfo = CacheRoleInfo.getDemoRoleInfo(DemoActivity.this, QSGameSdk.getInstance().getCurrentOpenId());
+                        } else {
+                            Toast.makeText(DemoActivity.this, "账号登录失败", Toast.LENGTH_SHORT).show();
+                        }
+                    }
+                });
+                break;
+            case 1:
+                QSGameSdk.getInstance().logout(this, new ICallback() {
+                    @Override
+                    public void onResult(int code, String result) {
+                        if (code == 0) {
+                            Toast.makeText(DemoActivity.this, "账号登出成功", Toast.LENGTH_SHORT).show();
+                        } else {
+                            Toast.makeText(DemoActivity.this, "账号登出失败", Toast.LENGTH_SHORT).show();
+                        }
+                    }
+                });
+                break;
+            case 2:
+                if (QSGameSdk.getInstance().getCurrentOpenId().equals("")) {
+                    Toast.makeText(DemoActivity.this, "请先登录账号", Toast.LENGTH_SHORT).show();
+                    return;
+                }
+                cacheRoleInfo = null;
+                cacheRoleInfo = CacheRoleInfo.setDemoRoleInfo(this, QSGameSdk.getInstance().getCurrentOpenId());
+                QSGameSdk.getInstance().roleCreate(this, getQSRoleInfo(), new ICallback() {
+                    @Override
+                    public void onResult(int code, String result) {
+                        if (code == 0) {
+                            Toast.makeText(DemoActivity.this, "角色信息上报成功", Toast.LENGTH_SHORT).show();
+                        } else {
+                            Toast.makeText(DemoActivity.this, "角色信息上报失败", Toast.LENGTH_SHORT).show();
+                        }
+                    }
+                });
+                break;
+            case 3:
+                if (QSGameSdk.getInstance().getCurrentOpenId().equals("")) {
+                    Toast.makeText(DemoActivity.this, "请先登录账号", Toast.LENGTH_SHORT).show();
+                    return;
+                }
+                QSGameSdk.getInstance().roleLauncher(this, getQSRoleInfo(), new ICallback() {
+                    @Override
+                    public void onResult(int code, String result) {
+                        if (code == 0) {
+                            Toast.makeText(DemoActivity.this, "角色信息上报成功", Toast.LENGTH_SHORT).show();
+                        } else {
+                            Toast.makeText(DemoActivity.this, "角色信息上报失败", Toast.LENGTH_SHORT).show();
+                        }
+                    }
+                });
+                break;
+            case 4:
+                if (QSGameSdk.getInstance().getCurrentOpenId().equals("")) {
+                    Toast.makeText(DemoActivity.this, "请先登录账号", Toast.LENGTH_SHORT).show();
+                    return;
+                }
+                QSGameSdk.getInstance().roleUpgrade(this, getQSRoleInfo(), new ICallback() {
+                    @Override
+                    public void onResult(int code, String result) {
+                        if (code == 0) {
+                            Toast.makeText(DemoActivity.this, "角色信息上报成功", Toast.LENGTH_SHORT).show();
+                        } else {
+                            Toast.makeText(DemoActivity.this, "角色信息上报失败", Toast.LENGTH_SHORT).show();
+                        }
+                    }
+                });
+                break;
+            case 5:
+                if (QSGameSdk.getInstance().getCurrentOpenId().equals("")) {
+                    Toast.makeText(DemoActivity.this, "请先登录账号", Toast.LENGTH_SHORT).show();
+                    return;
+                }
+                if (cacheRoleInfo == null) {
+                    Toast.makeText(DemoActivity.this, "请先创建/登录角色", Toast.LENGTH_SHORT).show();
+                    return;
+                }
+                QSGameSdk.getInstance().charge(this, getQSChargeInfo(), new ICallback() {
+                    @Override
+                    public void onResult(int code, String result) {
+                        if (code == 0) {
+                            Toast.makeText(DemoActivity.this, "支付流程完成", Toast.LENGTH_SHORT).show();
+                        } else {
+                            Toast.makeText(DemoActivity.this, "支付失败", Toast.LENGTH_SHORT).show();
+                        }
+                    }
+                });
+                break;
+            case 6:
+                List<String> permissions = new ArrayList<String>() {{
+                    add(Permission.CAMERA);
+                }};
+                QSGameSdk.getInstance().requestPermission(DemoActivity.this, permissions, new ICallback() {
+
+                    @Override
+                    public void onResult(int code, String result) {
+                        Toast.makeText(DemoActivity.this, "requestPermission code: " + code + ", result: " + result, Toast.LENGTH_SHORT).show();
+
+                    }
+                });
+                break;
+        }
+
+    }
+
+    private QSRoleInfo getQSRoleInfo() {
+        QSRoleInfo roleInfo = new QSRoleInfo();
+        roleInfo.setOpenId(QSGameSdk.getInstance().getCurrentOpenId());
+        roleInfo.setRoleId(cacheRoleInfo.getRoleId());
+        roleInfo.setRoleName(cacheRoleInfo.getRoleName());
+        roleInfo.setRoleGender(cacheRoleInfo.getRoleGender());
+        roleInfo.setRoleLevel(cacheRoleInfo.getRoleLevel());
+        roleInfo.setServerNo(cacheRoleInfo.getServerName());
+        roleInfo.setServerName(cacheRoleInfo.getServerName());
+        roleInfo.setRoleCTime(cacheRoleInfo.getRoleCTime());
+        roleInfo.setBalance(cacheRoleInfo.getBalance());
+        roleInfo.setPower(cacheRoleInfo.getPower());
+        roleInfo.setVipLevel(cacheRoleInfo.getVipLevel());
+        roleInfo.setRoleLevelMTime(System.currentTimeMillis() / 1000 + "");
+        return roleInfo;
+    }
+
+    private QSChargeInfo getQSChargeInfo() {
+        QSChargeInfo chargeInfo = new QSChargeInfo();
+        String ts = System.currentTimeMillis() / 1000 + "";
+        chargeInfo.setOpenId(QSGameSdk.getInstance().getCurrentOpenId());
+        chargeInfo.setRoleId(cacheRoleInfo.getRoleId());
+        chargeInfo.setRoleName(cacheRoleInfo.getRoleName());
+        chargeInfo.setRoleGender(cacheRoleInfo.getRoleGender());
+        chargeInfo.setRoleLevel(cacheRoleInfo.getRoleLevel());
+        chargeInfo.setServerNo(cacheRoleInfo.getServerCode());
+        chargeInfo.setServerName(cacheRoleInfo.getServerName());
+        chargeInfo.setBalance(cacheRoleInfo.getBalance());
+        chargeInfo.setVipLevel(cacheRoleInfo.getVipLevel());
+        chargeInfo.setCpOrderId("order_" + ts);
+        chargeInfo.setProductName("元宝");
+        chargeInfo.setAmount(Integer.parseInt(editText.getText().toString()));
+        chargeInfo.setCpCallbackInfo("cp_callback_info||order_" + ts);
+        return chargeInfo;
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        if (keyCode == KeyEvent.KEYCODE_BACK) {
+            QSGameSdk.getInstance().openExitView(this, new ICallback() {
+                @Override
+                public void onResult(int code, String result) {
+                    if (code == 0) {
+                        DemoActivity.this.finish();
+                    }
+                }
+            });
+            return true;
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        QSGameSdk.getInstance().onStart(this);
+    }
+
+    @Override
+    protected void onRestart() {
+        super.onRestart();
+        QSGameSdk.getInstance().onRestart(this);
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        QSGameSdk.getInstance().onResume(this);
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        QSGameSdk.getInstance().onPause(this);
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        QSGameSdk.getInstance().onStop(this);
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        QSGameSdk.getInstance().onDestroy(this);
+        //注意不能在sdk的退出回调中直接杀掉进程等方式退出,不然不会走Activity的onDestroy回调
+        System.exit(0);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        QSGameSdk.getInstance().onActivityResult(this, resultCode, resultCode, data);
+    }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        QSGameSdk.getInstance().onNewIntent(this, intent);
+    }
+}

+ 24 - 0
demo/src/main/java/com/gamesdk/qingshi/DemoApplication.java

@@ -0,0 +1,24 @@
+package com.gamesdk.qingshi;
+
+import android.app.Application;
+import android.content.Context;
+
+import cn.qingshi.gamesdk.base.QSGameSdk;
+
+/**
+ * @author #Suyghur.
+ * Created on 2021/11/01
+ */
+public class DemoApplication extends Application {
+    @Override
+    protected void attachBaseContext(Context base) {
+        super.attachBaseContext(base);
+        QSGameSdk.getInstance().attachBaseContext(this, base);
+    }
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        QSGameSdk.getInstance().initApplication(this);
+    }
+}

+ 7 - 0
demo/src/main/java/com/gamesdk/qingshi/Item.kt

@@ -0,0 +1,7 @@
+package com.gamesdk.qingshi
+
+/**
+ * @author #Suyghur.
+ * Created on 2021/11/01
+ */
+data class Item(var id: Int, var name: String)

BIN
demo/src/main/res/mipmap-xhdpi/ic_launcher.png


+ 10 - 0
demo/src/main/res/values/colors.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="purple_200">#FFBB86FC</color>
+    <color name="purple_500">#FF6200EE</color>
+    <color name="purple_700">#FF3700B3</color>
+    <color name="teal_200">#FF03DAC5</color>
+    <color name="teal_700">#FF018786</color>
+    <color name="black">#FF000000</color>
+    <color name="white">#FFFFFFFF</color>
+</resources>

+ 3 - 0
demo/src/main/res/values/strings.xml

@@ -0,0 +1,3 @@
+<resources>
+    <string name="app_name">青时游戏</string>
+</resources>

+ 5 - 0
demo/src/main/res/values/styles.xml

@@ -0,0 +1,5 @@
+<resources>
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="android:Theme.Light.NoTitleBar.Fullscreen" />
+
+</resources>

+ 4 - 0
demo/src/main/res/xml/network_security_config.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<network-security-config>
+    <base-config cleartextTrafficPermitted="true" />
+</network-security-config>

+ 17 - 0
gradle.properties

@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+android.injected.testOnly=false
+android.useAndroidX=false
+android.enableJetifier=false
+kotlin.code.style=official

BIN
gradle/wrapper/gradle-wrapper.jar


+ 5 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists

+ 185 - 0
gradlew

@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=`expr $i + 1`
+    done
+    case $i in
+        0) set -- ;;
+        1) set -- "$args0" ;;
+        2) set -- "$args0" "$args1" ;;
+        3) set -- "$args0" "$args1" "$args2" ;;
+        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"

+ 89 - 0
gradlew.bat

@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem      https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 15 - 0
keystore.properties

@@ -0,0 +1,15 @@
+#demo
+#storePassword=demozoojv_ffg2020
+#keyPassword=demozoojv_ffg2020
+#keyAlias=alias.demo_ffg2020
+#storeFile=../zkeystore/demo_ffg.keystore
+
+#storePassword=snmjr81j_ffg2021
+#keyPassword=snmjr81j_ffg2021
+#keyAlias=alias.snmj_ffg2021
+#storeFile=../zkeystore/snmj_ffg.keystore
+
+storePassword=susu123
+keyPassword=susu123
+keyAlias=susu
+storeFile=../zkeystore/susu.keystore

+ 2 - 0
settings.gradle

@@ -0,0 +1,2 @@
+include ':demo'
+rootProject.name = 'QSGameSdkDemo'

BIN
zkeystore/demo_ffg.keystore


BIN
zkeystore/snmj_ffg.keystore


BIN
zkeystore/susu.keystore