소스 검색

v1.0.3开发:
1)工具库更新1.0.2
2)demo使用compose ui重构

#Suyghur 3 년 전
부모
커밋
e3e964c5c3

+ 17 - 5
build.gradle

@@ -1,22 +1,34 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
-apply from: 'config.gradle'
+apply from: "config.gradle"
+
 buildscript {
     ext {
         kotlin_version = '1.6.0'
+        coroutines_version = '1.5.2'
+        compose_version = '1.1.0-rc01'
     }
-
-
     repositories {
         google()
         mavenCentral()
         jcenter()
+        maven { url 'https://maven.aliyun.com/repository/public' }
+        maven { url 'https://jitpack.io' }
+    }
+    allprojects {
+        repositories {
+            google()
+            mavenCentral()
+            jcenter()
+            maven { url 'https://maven.aliyun.com/repository/public' }
+            maven { url 'https://jitpack.io' }
+        }
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:7.0.4'
+        classpath 'com.android.tools.build:gradle:7.0.2'
         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
-
     }
 }
 

+ 33 - 5
config.gradle

@@ -3,14 +3,42 @@ ext {
     module = [
             remoteLib    : false,
             minifyEnabled: true,
-            publish      : true,
-            language     : 2
+            publish      : false,
+            language     : 1
     ]
 
     android = [
-            compileSdk: 31,
+            compileSdk       : 31,
             buildToolsVersion: '31.0.0',
-            minSdk    : 21,
-            targetSdk : 31,
+            minSdk           : 21,
+            targetSdk        : 31,
     ]
+
+    ktx = [
+            stdlib         : "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
+            coroutines     : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version",
+            core           : "androidx.core:core-ktx:1.7.0",
+            legacySupportV4: "androidx.legacy:legacy-support-v4:1.0.0"
+    ]
+
+    ui = [
+            appcompat         : "androidx.appcompat:appcompat:1.4.0",
+            material          : "com.google.android.material:material:1.4.0",
+            constraintlayout  : "androidx.constraintlayout:constraintlayout:2.1.0",
+            swiperefreshlayout: "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0",
+            recyclerview      : "androidx.recyclerview:recyclerview:1.2.1",
+            cardview          : "androidx.cardview:cardview:1.0.0"
+    ]
+
+    jetpack = [
+            viewmodel: "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0",
+            livedata : "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0",
+            extension: "androidx.lifecycle:lifecycle-extensions:2.2.0",
+            activity : "androidx.activity:activity-ktx:1.4.0",
+            fragment : "androidx.fragment:fragment-ktx:1.4.0"
+    ]
+
+    ktxLibs = ktx.values()
+    jetpackLibs = jetpack.values()
+    uiLibs = ui.values()
 }

+ 36 - 39
demo/build.gradle

@@ -22,6 +22,11 @@ android {
 
     }
 
+    buildFeatures {
+        viewBinding true
+        compose true
+        buildConfig false
+    }
     signingConfigs {
         config {
             keyAlias keystoreProperties['keyAlias']
@@ -32,7 +37,6 @@ android {
             v2SigningEnabled true
         }
     }
-
     buildTypes {
         debug {
             minifyEnabled false
@@ -46,59 +50,52 @@ android {
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
     }
-
     lintOptions {
         abortOnError false
     }
-
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
-
+    composeOptions {
+        kotlinCompilerExtensionVersion compose_version
+        kotlinCompilerVersion kotlin_version
+    }
     kotlinOptions {
-        jvmTarget = "1.8"
+        jvmTarget = '1.8'
+        useIR = true
+    }
+    packagingOptions {
+        resources {
+            excludes += '/META-INF/{AL2.0,LGPL2.1}'
+        }
     }
 }
 
 dependencies {
     if (rootProject.ext.module.publish) {
-        if (rootProject.ext.module.remoteLib) {
-            implementation 'io.github.yyxxgame.sdk:eyuangame-sdk-ktx:1.0.2'
-            implementation 'io.github.yyxxgame.sdk:eyuangame-component-lang-vn:1.0.2'
-        } else {
-            implementation files('libs/library_core-release.aar')
-            implementation project(':library_vn_language')
-
-            //mmkv
-            implementation 'com.tencent:mmkv-static:1.2.10'
-
-            //日志采集框架
-            implementation 'io.github.suyghur.dolin:zap:1.0.0'
-
-            implementation 'androidx.core:core-ktx:1.6.0'
-            implementation 'androidx.fragment:fragment-ktx:1.3.6'
-            implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
-            implementation 'com.google.android.material:material:1.4.0'
-            implementation 'com.android.installreferrer:installreferrer:2.2'
-
-            //google
-            implementation 'com.google.android.play:core:1.10.2'
-            implementation 'com.google.android.gms:play-services-auth:19.2.0'
-            //4.0.0的billing库消耗商品会回调两次,后续在排查,先用3.0.3
-            implementation "com.android.billingclient:billing-ktx:3.0.3"
-            implementation 'com.google.firebase:firebase-analytics-ktx:19.0.2'
-            implementation 'com.google.firebase:firebase-crashlytics-ktx:18.2.3'
-            implementation 'com.google.firebase:firebase-crashlytics-ndk:18.2.3'
-
-            //facebook
-            implementation 'com.facebook.android:facebook-android-sdk:11.2.0'
-
-            //adjust
-            implementation 'com.adjust.sdk:adjust-android:4.28.2'
-        }
+        implementation 'io.github.yyxxgame.sdk:eyuangame-sdk-ktx:1.0.2-fix1'
+        implementation 'io.github.yyxxgame.sdk:eyuangame-component-lang-vn:1.0.2'
     } else {
         api project(':library_core')
     }
+
+    // ktx
+    api rootProject.ext.ktxLibs
+    // jetpack
+    api rootProject.ext.jetpackLibs
+    // ui
+    api rootProject.ext.uiLibs
+
+    implementation "androidx.compose.material:material:$compose_version"
+    implementation 'androidx.activity:activity-compose:1.4.0'
+    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
+    implementation "androidx.compose.ui:ui:$compose_version"
+    implementation "androidx.compose.ui:ui-tooling:$compose_version"
+    implementation "androidx.compose.runtime:runtime:$compose_version"
+    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
+    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0"
+
+    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
     debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
 }

+ 128 - 112
demo/src/main/java/com/eyuangame/demo/DemoActivity.kt

@@ -1,25 +1,35 @@
 package com.eyuangame.demo
 
-import android.app.Activity
 import android.content.Intent
 import android.os.Bundle
 import android.os.Handler
 import android.os.Looper
 import android.os.Message
-import android.view.Gravity
 import android.view.KeyEvent
-import android.view.View
 import android.widget.*
+import androidx.activity.compose.setContent
+import androidx.appcompat.app.AppCompatActivity
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.Button
+import androidx.compose.material.MaterialTheme
+import androidx.compose.material.Surface
+import androidx.compose.material.Text
+import androidx.compose.runtime.*
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.tooling.preview.Preview
+import androidx.compose.ui.unit.dp
 import cn.yyxx.eyuangame.base.EYuanGame
 import cn.yyxx.eyuangame.base.entity.SdkChargeInfo
 import cn.yyxx.eyuangame.base.entity.SdkEvent
 import cn.yyxx.eyuangame.base.entity.SdkRoleInfo
 import cn.yyxx.eyuangame.base.internal.ICallback
-import cn.yyxx.support.DensityUtils
-import cn.yyxx.support.ResUtils
 import cn.yyxx.support.hawkeye.LogUtils
 import cn.yyxx.support.hawkeye.ToastUtils
-import cn.yyxx.support.ui.GifView
+import com.eyuangame.demo.ui.theme.EYuanGameSdkKTXTheme
 import kotlin.system.exitProcess
 
 
@@ -27,7 +37,7 @@ import kotlin.system.exitProcess
  * @author #Suyghur.
  * Created on 2021/06/09
  */
-class DemoActivity : Activity(), View.OnClickListener {
+class DemoActivity : AppCompatActivity() {
 
     private val events = mutableListOf(
         Item(0, "00 接口环境切换"),
@@ -41,23 +51,21 @@ class DemoActivity : Activity(), View.OnClickListener {
         Item(8, "08 模拟CP打点(玩家首次完成新手引导)"),
         Item(0, "09 模拟CP打点(玩家首次完成结缘)"),
         Item(10, "10 crashlytics崩溃测试"),
-        Item(11, "11 Facebook分享测试")
+        Item(11, "11 Facebook分享测试"),
+        Item(12, "12 sdk日志上报测试")
     )
 
-
-    private lateinit var layout: LinearLayout
-    private lateinit var mTextView: TextView
-    private lateinit var gifView: GifView
-
     private var cacheRoleInfo: CacheRoleInfo.RoleInfo? = null
-
+    private val messageBuffer by lazy {
+        StringBuilder()
+    }
+    private var message by mutableStateOf("")
     private val handler = object : Handler(Looper.getMainLooper()) {
         override fun handleMessage(msg: Message) {
             when (msg.what) {
                 10001 -> {
-                    with(mTextView) {
-                        text = text.toString() + msg.obj.toString()
-                    }
+                    messageBuffer.append(msg.obj.toString())
+                    message = messageBuffer.toString()
                 }
             }
         }
@@ -65,7 +73,14 @@ class DemoActivity : Activity(), View.OnClickListener {
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
-        initView()
+
+        setContent {
+            EYuanGameSdkKTXTheme {
+                Surface(color = MaterialTheme.colors.background) {
+                    DemoPage()
+                }
+            }
+        }
         LogUtils.handler = handler
         EYuanGame.getInstance().initialize(this, true, object : ICallback {
             override fun onResult(code: Int, result: String) {
@@ -74,112 +89,112 @@ class DemoActivity : Activity(), View.OnClickListener {
         })
     }
 
-    private fun initView() {
-        layout = LinearLayout(this)
-        layout.orientation = LinearLayout.VERTICAL
 
-        val gifLayoutParams = LinearLayout.LayoutParams(DensityUtils.dip2px(this, 100f), DensityUtils.dip2px(this, 100f))
-        gifLayoutParams.gravity = Gravity.CENTER
-        gifView = GifView(this)
-        gifView.setGifResource(ResUtils.getResId(this, "cpp", "drawable"))
-        gifView.layoutParams = gifLayoutParams
-        layout.addView(gifView)
-
-        initButton()
-        mTextView = TextView(this)
-        with(mTextView) {
-            text = ""
-            this@DemoActivity.layout.addView(this)
+    @Composable
+    fun DemoPage() {
+        Column(
+            modifier = Modifier
+                .fillMaxSize()
+                .verticalScroll(rememberScrollState()),
+        ) {
+            events.forEach {
+                Button(
+                    modifier = Modifier
+                        .fillMaxSize()
+                        .padding(start = 10.dp, end = 10.dp),
+                    onClick = { onClick(it.id) }
+                ) {
+                    Text(text = it.name)
+                }
+            }
+            Text(text = message)
         }
-        val scrollView = ScrollView(this)
-        scrollView.addView(layout)
-        setContentView(scrollView)
     }
 
-    private fun initButton() {
-        for (event in events) {
-            with(Button(this)) {
-                text = event.name
-                tag = event.id
-                id = event.id
-                setOnClickListener(this@DemoActivity)
-                this@DemoActivity.layout.addView(this)
+    @Preview
+    @Composable
+    fun PreviewDemoPage() {
+        EYuanGameSdkKTXTheme {
+            Surface(color = MaterialTheme.colors.background) {
+                DemoPage()
             }
         }
     }
 
-    override fun onClick(v: View?) {
-        v?.apply {
-            mTextView.text = ""
-            when (tag as Int) {
-                0 -> EnvActivity.start(this@DemoActivity)
-                1 -> {
-                    EYuanGame.getInstance().login(this@DemoActivity, true, object : ICallback {
-                        override fun onResult(code: Int, result: String) {
-                            ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
-                            if (code == 0) {
-                                cacheRoleInfo = CacheRoleInfo.getDemoRoleInfo(this@DemoActivity, EYuanGame.getInstance().getCurrentUserId())
-                            }
-                        }
-                    })
-                }
-                2 -> {
-                    EYuanGame.getInstance().logout(this@DemoActivity, object : ICallback {
-                        override fun onResult(code: Int, result: String) {
-                            if (code == 0) {
-                                EYuanGame.getInstance().login(this@DemoActivity, false, object : ICallback {
-                                    override fun onResult(code: Int, result: String) {
-                                        ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
-                                    }
-                                })
-                            }
-                        }
-                    })
-                }
-                3 -> {
-                    cacheRoleInfo = null
-                    cacheRoleInfo = CacheRoleInfo.setDemoRoleInfo(this@DemoActivity, EYuanGame.getInstance().getCurrentUserId())
-                    EYuanGame.getInstance().roleCreate(this@DemoActivity, getGameRoleInfo())
-                }
-                4 -> EYuanGame.getInstance().roleLauncher(this@DemoActivity, getGameRoleInfo())
-                5 -> EYuanGame.getInstance().roleLevelUp(this@DemoActivity, getGameRoleInfo())
-                6 -> {
-                    EYuanGame.getInstance().charge(this@DemoActivity, getGameChargeInfo(), true, object : ICallback {
-                        override fun onResult(code: Int, result: String) {
-                            ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
+    private fun onClick(action: Int) {
+        messageBuffer.clear()
+        when (action) {
+            0 -> EnvActivity.start(this@DemoActivity)
+            1 -> {
+                EYuanGame.getInstance().login(this@DemoActivity, true, object : ICallback {
+                    override fun onResult(code: Int, result: String) {
+                        ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
+                        if (code == 0) {
+                            cacheRoleInfo = CacheRoleInfo.getDemoRoleInfo(this@DemoActivity, EYuanGame.getInstance().getCurrentUserId())
                         }
-
-                    })
-                }
-                7 -> {
-                    EYuanGame.getInstance().charge(this@DemoActivity, getGameChargeInfo(), false, object : ICallback {
-                        override fun onResult(code: Int, result: String) {
-                            ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
+                    }
+                })
+            }
+            2 -> {
+                EYuanGame.getInstance().logout(this@DemoActivity, object : ICallback {
+                    override fun onResult(code: Int, result: String) {
+                        if (code == 0) {
+                            EYuanGame.getInstance().login(this@DemoActivity, false, object : ICallback {
+                                override fun onResult(code: Int, result: String) {
+                                    ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
+                                }
+                            })
                         }
-
-                    })
-                }
-                8 -> {
-                    val sdkEvent = SdkEvent()
-                    sdkEvent.eventName = "tutorial"
-                    sdkEvent.standard = true
-                    sdkEvent.fbAliasName = "fb_mobile_tutorial_completion"
-                    EYuanGame.getInstance().linkingEvent(this@DemoActivity, sdkEvent)
-                }
-                9 -> {
-                    val sdkEvent = SdkEvent()
-                    sdkEvent.eventName = "finish_marry"
-                    sdkEvent.standard = false
-                    EYuanGame.getInstance().linkingEvent(this@DemoActivity, sdkEvent)
-                }
-                10 -> throw RuntimeException("Test Crashlytics Feature")
-                11 -> EYuanGame.getInstance().share(this@DemoActivity, "https://www.baidu.com", "#测试标签", "测试引文", object : ICallback {
+                    }
+                })
+            }
+            3 -> {
+                cacheRoleInfo = null
+                cacheRoleInfo = CacheRoleInfo.setDemoRoleInfo(this@DemoActivity, EYuanGame.getInstance().getCurrentUserId())
+                EYuanGame.getInstance().roleCreate(this@DemoActivity, getGameRoleInfo())
+            }
+            4 -> EYuanGame.getInstance().roleLauncher(this@DemoActivity, getGameRoleInfo())
+            5 -> EYuanGame.getInstance().roleLevelUp(this@DemoActivity, getGameRoleInfo())
+            6 -> {
+                EYuanGame.getInstance().charge(this@DemoActivity, getGameChargeInfo(), true, object : ICallback {
                     override fun onResult(code: Int, result: String) {
+                        ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
+                    }
 
+                })
+            }
+            7 -> {
+                EYuanGame.getInstance().charge(this@DemoActivity, getGameChargeInfo(), false, object : ICallback {
+                    override fun onResult(code: Int, result: String) {
+                        ToastUtils.toastInfo(this@DemoActivity, "---- demo提示不做翻译 ----\ncode : $code\n msg : $result\n ---- demo提示不做翻译 ----")
                     }
 
                 })
             }
+            8 -> {
+                val sdkEvent = SdkEvent()
+                sdkEvent.eventName = "tutorial"
+                sdkEvent.standard = true
+                sdkEvent.fbAliasName = "fb_mobile_tutorial_completion"
+                EYuanGame.getInstance().linkingEvent(this@DemoActivity, sdkEvent)
+            }
+            9 -> {
+                val sdkEvent = SdkEvent()
+                sdkEvent.eventName = "finish_marry"
+                sdkEvent.standard = false
+                EYuanGame.getInstance().linkingEvent(this@DemoActivity, sdkEvent)
+            }
+            10 -> throw RuntimeException("Test Crashlytics Feature")
+            11 -> EYuanGame.getInstance().share(this@DemoActivity, "https://www.baidu.com", "#测试标签", "测试引文", object : ICallback {
+                override fun onResult(code: Int, result: String) {
+
+                }
+
+            })
+            12 -> {
+                val zapPath = getExternalFilesDir("dolin/zap")!!.absolutePath
+                ZipUtils.zipAll(zapPath, "$zapPath/test.zip")
+            }
         }
     }
 
@@ -266,13 +281,11 @@ class DemoActivity : Activity(), View.OnClickListener {
 
     override fun onResume() {
         super.onResume()
-        gifView.setPaused(false)
         EYuanGame.getInstance().onResume(this)
     }
 
     override fun onRestart() {
         super.onRestart()
-        gifView.setPaused(true)
         EYuanGame.getInstance().onRestart(this)
     }
 
@@ -292,7 +305,8 @@ class DemoActivity : Activity(), View.OnClickListener {
         exitProcess(0)
     }
 
-    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
+
+    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
         super.onActivityResult(requestCode, resultCode, data)
         EYuanGame.getInstance().onActivityResult(this, requestCode, resultCode, data)
     }
@@ -301,5 +315,7 @@ class DemoActivity : Activity(), View.OnClickListener {
         super.onNewIntent(intent)
         EYuanGame.getInstance().onNewIntent(this, intent)
     }
+}
+
+data class Item(val id: Int, val name: String)
 
-}

+ 60 - 30
demo/src/main/java/com/eyuangame/demo/EnvActivity.kt

@@ -3,53 +3,83 @@ package com.eyuangame.demo
 import android.app.Activity
 import android.content.Intent
 import android.os.Bundle
-import android.view.View
-import android.widget.Button
-import android.widget.LinearLayout
+import androidx.activity.compose.setContent
+import androidx.appcompat.app.AppCompatActivity
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.*
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.tooling.preview.Preview
+import androidx.compose.ui.unit.dp
+import androidx.core.view.WindowCompat
 import cn.yyxx.support.HostModelUtils
 import cn.yyxx.support.hawkeye.ToastUtils
+import com.eyuangame.demo.ui.theme.EYuanGameSdkKTXTheme
 
 /**
  * @author #Suyghur.
  * Created on 2021/06/17
  */
-class EnvActivity : Activity(), View.OnClickListener {
+class EnvActivity : AppCompatActivity() {
+
+    companion object {
+        fun start(activity: Activity) {
+            activity.startActivity(Intent(activity, EnvActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
+        }
+    }
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
-
-        with(LinearLayout(this)) {
-
-            orientation = LinearLayout.VERTICAL
-
-            val btnTest = Button(this@EnvActivity)
-            btnTest.text = "00 测试环境"
-            btnTest.tag = HostModelUtils.ENV_TEST
-            btnTest.setOnClickListener(this@EnvActivity)
-            addView(btnTest)
-
-            val btnOnline = Button(this@EnvActivity)
-            btnOnline.text = "01 线上环境"
-            btnOnline.tag = HostModelUtils.ENV_ONLINE
-            btnOnline.setOnClickListener(this@EnvActivity)
-            addView(btnOnline)
-
-            setContentView(this)
+        WindowCompat.setDecorFitsSystemWindows(window, false)
+        setContent {
+            EYuanGameSdkKTXTheme {
+                Surface(color = MaterialTheme.colors.background) {
+                    EnvPage()
+                }
+            }
         }
-
     }
 
-    override fun onClick(v: View?) {
-        v?.apply {
-            HostModelUtils.setHostModel(this@EnvActivity, tag as Int)
-            ToastUtils.toastInfo(this@EnvActivity, "接口环境切换成功,重启应用后生效")
+    @Composable
+    fun EnvPage() {
+        Column(
+            modifier = Modifier
+                .fillMaxSize()
+                .verticalScroll(rememberScrollState()),
+        ) {
+            Button(
+                modifier = Modifier
+                    .fillMaxSize()
+                    .padding(start = 10.dp, end = 10.dp),
+                onClick = { changeModel(HostModelUtils.ENV_TEST) }
+            ) {
+                Text(text = "00 测试环境")
+            }
+            Button(modifier = Modifier
+                .fillMaxSize()
+                .padding(start = 10.dp, end = 10.dp),
+                onClick = { changeModel(HostModelUtils.ENV_ONLINE) }
+            ) {
+                Text(text = "01 正式环境")
+            }
         }
     }
 
-    companion object {
-        fun start(activity: Activity) {
-            activity.startActivity(Intent(activity, EnvActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
+    @Preview
+    @Composable
+    fun PreviewEnv() {
+        Surface {
+            EnvPage()
         }
     }
 
+    private fun changeModel(model: Int) {
+        HostModelUtils.setHostModel(this, model)
+        ToastUtils.toastInfo(this, "接口环境切换成功,重启应用后生效")
+    }
 }

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

@@ -1,7 +0,0 @@
-package com.eyuangame.demo
-
-/**
- * @author #Suyghur,
- * Created on 2021/3/22
- */
-class Item constructor(val id: Int, val name: String)

+ 69 - 0
demo/src/main/java/com/eyuangame/demo/ZipUtils.kt

@@ -0,0 +1,69 @@
+package com.eyuangame.demo
+
+import cn.yyxx.eyuangame.base.utils.Logger
+import java.io.*
+import java.util.zip.ZipEntry
+import java.util.zip.ZipOutputStream
+
+/**
+ * @author #Suyghur.
+ * Created on 2022/01/11
+ */
+object ZipUtils {
+
+    fun zipAll(directory: String, zipFile: String) {
+        val sourceFile = File(directory)
+
+        ZipOutputStream(BufferedOutputStream(FileOutputStream(zipFile))).use {
+            it.use { zos ->
+                zipFiles(zos, sourceFile, "")
+            }
+        }
+    }
+
+    private fun zipFiles(zipOut: ZipOutputStream, sourceFile: File, parentDirPath: String) {
+
+        val data = ByteArray(2048)
+
+        for (f in sourceFile.listFiles()) {
+
+            if (f.isDirectory) {
+                val entry = ZipEntry(f.name + File.separator)
+                entry.time = f.lastModified()
+                entry.isDirectory
+                entry.size = f.length()
+
+                Logger.d("Adding Directory: " + f.name)
+                zipOut.putNextEntry(entry)
+
+                //Call recursively to add files within this directory
+                zipFiles(zipOut, f, f.name)
+            } else {
+
+                if (!f.name.contains(".zip")) { //If folder contains a file with extension ".zip", skip it
+                    FileInputStream(f).use { fi ->
+                        BufferedInputStream(fi).use { origin ->
+                            val path = parentDirPath + File.separator + f.name
+                            Logger.d("Adding file: $path")
+                            val entry = ZipEntry(path)
+                            entry.time = f.lastModified()
+                            entry.isDirectory
+                            entry.size = f.length()
+                            zipOut.putNextEntry(entry)
+                            while (true) {
+                                val readBytes = origin.read(data)
+                                if (readBytes == -1) {
+                                    break
+                                }
+                                zipOut.write(data, 0, readBytes)
+                            }
+                        }
+                    }
+                } else {
+                    zipOut.closeEntry()
+                    zipOut.close()
+                }
+            }
+        }
+    }
+}

+ 8 - 0
demo/src/main/java/com/eyuangame/demo/ui/theme/Color.kt

@@ -0,0 +1,8 @@
+package com.eyuangame.demo.ui.theme
+
+import androidx.compose.ui.graphics.Color
+
+val Purple200 = Color(0xFFBB86FC)
+val Purple500 = Color(0xFF6200EE)
+val Purple700 = Color(0xFF3700B3)
+val Teal200 = Color(0xFF03DAC5)

+ 11 - 0
demo/src/main/java/com/eyuangame/demo/ui/theme/Shape.kt

@@ -0,0 +1,11 @@
+package com.eyuangame.demo.ui.theme
+
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.Shapes
+import androidx.compose.ui.unit.dp
+
+val Shapes = Shapes(
+    small = RoundedCornerShape(4.dp),
+    medium = RoundedCornerShape(4.dp),
+    large = RoundedCornerShape(0.dp)
+)

+ 44 - 0
demo/src/main/java/com/eyuangame/demo/ui/theme/Theme.kt

@@ -0,0 +1,44 @@
+package com.eyuangame.demo.ui.theme
+
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material.MaterialTheme
+import androidx.compose.material.darkColors
+import androidx.compose.material.lightColors
+import androidx.compose.runtime.Composable
+
+private val DarkColorPalette = darkColors(
+    primary = Purple200,
+    primaryVariant = Purple700,
+    secondary = Teal200
+)
+
+private val LightColorPalette = lightColors(
+    primary = Purple500,
+    primaryVariant = Purple700,
+    secondary = Teal200
+
+    /* Other default colors to override
+    background = Color.White,
+    surface = Color.White,
+    onPrimary = Color.White,
+    onSecondary = Color.Black,
+    onBackground = Color.Black,
+    onSurface = Color.Black,
+    */
+)
+
+@Composable
+fun EYuanGameSdkKTXTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
+    val colors = if (darkTheme) {
+        DarkColorPalette
+    } else {
+        LightColorPalette
+    }
+
+    MaterialTheme(
+        colors = colors,
+        typography = Typography,
+        shapes = Shapes,
+        content = content
+    )
+}

+ 28 - 0
demo/src/main/java/com/eyuangame/demo/ui/theme/Type.kt

@@ -0,0 +1,28 @@
+package com.eyuangame.demo.ui.theme
+
+import androidx.compose.material.Typography
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.sp
+
+// Set of Material typography styles to start with
+val Typography = Typography(
+    body1 = TextStyle(
+        fontFamily = FontFamily.Default,
+        fontWeight = FontWeight.Normal,
+        fontSize = 16.sp
+    )
+    /* Other default text styles to override
+    button = TextStyle(
+        fontFamily = FontFamily.Default,
+        fontWeight = FontWeight.W500,
+        fontSize = 14.sp
+    ),
+    caption = TextStyle(
+        fontFamily = FontFamily.Default,
+        fontWeight = FontWeight.Normal,
+        fontSize = 12.sp
+    )
+    */
+)

+ 11 - 2
demo/src/main/res/values/styles.xml

@@ -1,5 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <!-- Base application theme. -->
-    <style name="AppTheme" parent="android:Theme.Light.NoTitleBar.Fullscreen" />
+    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
+        <item name="windowNoTitle">true</item>
+        <item name="windowActionBar">false</item>
+        <item name="android:statusBarColor">@android:color/transparent</item>
+        <item name="android:windowFullscreen">true</item>
+        <item name="android:windowContentOverlay">@null</item>
+<!--        <item name="android:windowBackground">@null</item>-->
+<!--        <item name="android:windowDisablePreview">true</item>-->
+<!--        <item name="android:windowIsTranslucent">true</item>-->
+<!--        <item name="android:windowDrawsSystemBarBackgrounds">false</item>-->
+    </style>
 </resources>

+ 2 - 2
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
-#Thu Dec 23 09:49:40 CST 2021
+#Tue Jan 11 09:39:31 CST 2022
 distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME

+ 1 - 1
library_base/build.gradle

@@ -48,7 +48,7 @@ android {
 }
 
 dependencies {
-    api files('../libs/yyxx_support_1.0.1.jar')
+    api files('../libs/yyxx_support_1.0.2.jar')
     implementation 'androidx.core:core-ktx:1.7.0'
     implementation 'io.github.suyghur.dolin:zap:1.0.0'
 }

+ 1 - 1
library_core/build.gradle

@@ -76,7 +76,7 @@ dependencies {
 
     //google
     implementation 'com.google.android.play:core:1.10.2'
-    implementation 'com.google.android.gms:play-services-auth:20.0.0'
+    implementation 'com.google.android.gms:play-services-auth:20.0.1'
     //4.0.0的billing库消耗商品会回调两次,后续在排查,先用3.0.3
     implementation "com.android.billingclient:billing-ktx:3.0.3"
     implementation 'com.google.firebase:firebase-analytics-ktx:20.0.2'

+ 2 - 2
library_core/publish.gradle

@@ -4,7 +4,7 @@ apply plugin: 'signing'
 ext {
     PUBLISH_GROUP_ID = 'io.github.yyxxgame.sdk'
     PUBLISH_ARTIFACT_ID = 'eyuangame-sdk-ktx'
-    PUBLISH_VERSION = '1.0.2'
+    PUBLISH_VERSION = '1.0.2-fix1'
 }
 
 Properties properties = new Properties()
@@ -45,7 +45,7 @@ publishing {
                 url = 'https://github.com/yyxxgame'
                 licenses {
                     license {
-                        //协议类型,一般默认Apache License2.0的话不用改:
+                        // 协议类型,一般默认Apache License2.0的话不用改:
                         name = 'The Apache License, Version 2.0'
                         url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                     }

+ 0 - 2
library_core/src/main/java/cn/yyxx/eyuangame/core/impl/iab/ChargeImpl.kt

@@ -288,12 +288,10 @@ class ChargeImpl : InAppBilling() {
             orderId = if (!TextUtils.isEmpty(obfuscatedAccountId)) {
                 obfuscatedAccountId!!
             } else {
-                //TODO getLocalOrderId
                 getOrderInfo(purchase.orderId)
             }
         }
         notifyOrder2Backend(activity, orderId, purchase, true)
-//        consumeAsync(activity, purchase.purchaseToken, true)
     }
 
     /**

+ 1 - 0
library_core/src/main/java/cn/yyxx/eyuangame/core/impl/login/fragment/LauncherFragment.kt

@@ -377,6 +377,7 @@ class LauncherFragment : Fragment(), View.OnClickListener {
                         if (resultInfo.code == 1) {
                             ToastUtils.toastInfo(requireActivity(), resultInfo.msg)
                             this@apply.dismiss()
+                            loginImpl.showLoginView()
                         } else {
                             ToastUtils.toastInfo(requireActivity(), resultInfo.msg)
                         }

+ 1 - 0
library_core/src/main/java/cn/yyxx/eyuangame/core/network/Host.kt

@@ -44,6 +44,7 @@ object Host {
     const val BASIC_ROUTE_NOTIFY_ORDER = "iap_notify"
     const val BASIC_ROUTE_NOTIFY_REWARD = ""
     const val BASIC_ROUTE_SUBMIT_ROLE_INFO = "game_role_report"
+    const val BASIC_ROUTE_UPLOAD_SDK_LOG = "upload_log"
 
 
     fun initHostModel(context: Context) {

+ 10 - 0
library_core/src/main/java/cn/yyxx/eyuangame/core/network/SdkRequest.kt

@@ -6,6 +6,7 @@ import cn.yyxx.eyuangame.base.entity.SdkRoleInfo
 import cn.yyxx.eyuangame.base.utils.Logger
 import cn.yyxx.eyuangame.core.entity.LoginType
 import cn.yyxx.eyuangame.core.entity.SdkBackLoginInfo
+import cn.yyxx.eyuangame.core.impl.SdkDrive
 import cn.yyxx.eyuangame.core.internal.IFileRequestCallback
 import cn.yyxx.eyuangame.core.internal.IRequestCallback
 import cn.yyxx.support.volley.source.VolleyError
@@ -169,6 +170,15 @@ class SdkRequest {
         })
     }
 
+
+//    fun uploadLogFile(context: Context) {
+//        val params = HashMap<String, Any>()
+//        params["common"] = SdkDrive.instance.getComm(context)
+//        params["upload_type"] = "log"
+//        params[""]
+//        VolleyRequest.uploadFile(context)
+//    }
+
     companion object {
         val instance: SdkRequest by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
             SdkRequest()

+ 21 - 0
library_core/src/main/java/cn/yyxx/eyuangame/core/network/VolleyRequest.kt

@@ -14,7 +14,9 @@ import cn.yyxx.support.StrUtils
 import cn.yyxx.support.encryption.Base64Utils
 import cn.yyxx.support.encryption.HexUtils
 import cn.yyxx.support.encryption.Md5Utils
+import cn.yyxx.support.volley.MultipartRequest
 import cn.yyxx.support.volley.VolleySingleton
+import cn.yyxx.support.volley.entity.FileEntity
 import cn.yyxx.support.volley.source.*
 import cn.yyxx.support.volley.source.toolbox.HttpHeaderParser
 import cn.yyxx.support.volley.source.toolbox.JsonObjectRequest
@@ -160,6 +162,25 @@ object VolleyRequest {
         VolleySingleton.getInstance(context.applicationContext).addToRequestQueue(context.applicationContext, request)
     }
 
+    fun uploadFile(context: Context, url: String, file: File, params: HashMap<String, Any>, callback: IRequestCallback) {
+        if (!file.exists()) {
+            Logger.e("${file.name}不存在请检查")
+            return
+        }
+        Logger.d("上传文件: ${file.name} ...")
+        val fileEntity = FileEntity()
+        fileEntity.mName = "upload_file"
+        fileEntity.mFileName = file.name
+        fileEntity.mFile = file
+
+        val request = MultipartRequest(url, params, fileEntity, {
+            Logger.d("upload file result: $it")
+        }) {
+            Logger.d("upload file onError: ${it.message}")
+        }
+        VolleySingleton.getInstance(context.applicationContext).addToRequestQueue(context.applicationContext, request)
+    }
+
     private fun parseResponse(context: Context, data: JSONObject): String {
         try {
             val ts = data.getString("ts")

BIN
libs/yyxx_support_1.0.2.jar


+ 0 - 9
settings.gradle

@@ -1,12 +1,3 @@
-dependencyResolutionManagement {
-    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
-    repositories {
-        google()
-        mavenCentral()
-        jcenter()
-    }
-}
-
 rootProject.name = "EYuanGameSdk-KTX"
 include ':demo'
 include ':library_base'