Selaa lähdekoodia

v1.0.0开发:浮标切换账号开发

#Suyghur 2 vuotta sitten
vanhempi
commit
83c09b8376
34 muutettua tiedostoa jossa 518 lisäystä ja 326 poistoa
  1. 5 9
      demo/src/main/assets/yyxx_game/sdk_log.json
  2. 1 1
      demo/src/main/assets/yyxx_game/yyxx_comm.properties
  3. 9 3
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/EYuanCommInstaller.kt
  4. 23 10
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/impl/CommSdkImpl.kt
  5. 75 1
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/TraceEventManager.kt
  6. 164 39
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/AdjustEventTrace.kt
  7. 3 3
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/utils/MMKVManager.kt
  8. 15 5
      library_impl/src/main/java/cn/yyxx/eyuancomm/impl/channel/eyuangame/ChannelSdkEYuanGame.kt
  9. 7 0
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/EYuanGameSdk.kt
  10. 2 1
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/entity/FloatFeature.kt
  11. 9 12
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/entity/bean/FloatCfg.kt
  12. 1 1
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/entity/bean/InitBean.kt
  13. 24 18
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/GameSdkImpl.kt
  14. 1 1
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/center/HybridFeatureContainer.kt
  15. 20 5
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/floatball/FloatCenterService.kt
  16. 4 6
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/login/LoginActivity.kt
  17. 7 4
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/login/UserSignInImpl.kt
  18. 101 101
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/trace/TraceEventManager.kt
  19. 5 5
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/trace/channel/TraceAdjustImpl.kt
  20. 5 5
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/trace/channel/TraceFacebookImpl.kt
  21. 5 5
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/trace/channel/TraceFirebaseImpl.kt
  22. 4 4
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/utils/SessionUtils.kt
  23. 0 1
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/widget/dialog/AgreementDialog.kt
  24. 0 67
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/widget/dialog/ScaleLoadingDialog.kt
  25. 10 4
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/widget/dialog/TipsDialog.kt
  26. 14 5
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/widget/floatview/FloatingBallMenu.kt
  27. BIN
      module_eyuan/library_eyuan/src/main/res/drawable-xhdpi/yyxx_float_logo_img.png
  28. BIN
      module_eyuan/library_eyuan/src/main/res/drawable-xhdpi/yyxx_float_logo_left_img.png
  29. BIN
      module_eyuan/library_eyuan/src/main/res/drawable-xhdpi/yyxx_float_logo_right_img.png
  30. BIN
      module_eyuan/library_eyuan/src/main/res/drawable-xhdpi/yyxx_float_switch_img.png
  31. 1 1
      module_eyuan/library_eyuan/src/main/res/layout/yyxx_floating_ball_item.xml
  32. 1 3
      module_eyuan/library_eyuan/src/main/res/layout/yyxx_tips_dialog.xml
  33. 1 5
      module_eyuan/library_hk_language/src/main/res/values/yyxx_strings.xml
  34. 1 1
      module_eyuan/library_vn_language/src/main/res/values/yyxx_strings.xml

+ 5 - 9
demo/src/main/assets/yyxx_game/sdk_log.json

@@ -1,11 +1,7 @@
 {
-  "open_app": "9titg2",
-  "choose_login_page": "l68ap0",
-  "sign_up": "oycdb6",
-  "login_success_quick": "sjxw4u",
-  "login_success_fb": "aorps6",
-  "login_success_google": "opymbu",
-  "login_success_account": "lmngli",
-  "ecommerce_purchase": "na9zu3",
-  "first_purchase": "6tgkgk"
+  "open_app": "iwgqu5",
+  "sign_up": "lo5o9s",
+  "login_success_account": "2j2gqs",
+  "ecommerce_purchase": "p4sqr7",
+  "first_purchase": "e3yw8i"
 }

+ 1 - 1
demo/src/main/assets/yyxx_game/yyxx_comm.properties

@@ -6,6 +6,6 @@ YYXX_CHANNEL_ID=4
 # Google Server Client Id
 YYXX_GOOGLE_CLIENT_ID=70429070957-7clr9u565jrjgbgg474ksg8q2esq2okj.apps.googleusercontent.com
 # 事件打点应用ID
-YYXX_ADJUST_APP_ID=q1lh43zvrv9c
+YYXX_ADJUST_APP_ID=ymyq28xetdkw
 # debug模式(cp出正式包请关闭)
 YYXX_OWN_DEBUG=true

+ 9 - 3
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/EYuanCommInstaller.kt

@@ -7,8 +7,9 @@ import android.database.Cursor
 import android.net.Uri
 import cn.yyxx.eyuancomm.comm.impl.CommSdkDrive
 import cn.yyxx.eyuancomm.comm.network.Host
+import cn.yyxx.eyuancomm.comm.trace.TraceEventManager
 import cn.yyxx.eyuancomm.comm.utils.Logger
-import cn.yyxx.eyuancomm.comm.utils.MMKVHandler
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
 import cn.yyxx.support.device.DeviceInfoUtils
 import cn.yyxx.support.gaid.GAIDUtils
 import cn.yyxx.support.msa.MsaDeviceIdsHandler
@@ -25,11 +26,16 @@ internal class EYuanCommInstaller : ContentProvider() {
 
     override fun onCreate(): Boolean {
         val application = context!!.applicationContext as Application
-        initGaid(application)
         Logger.initZap(application)
-        MMKVHandler.instance.init(application)
         CommSdkDrive.instance.initSdkDrive(application)
+        initGaid(application)
+        MMKVManager.instance.init(application)
         Host.initHostModel(application)
+        TraceEventManager.instance.initialize(application) { id ->
+            Logger.d("onTraceIdRead: $id")
+            CommSdkDrive.instance.setCommParam("aid", id)
+            MMKVManager.instance.eventKV.encode("adjust_id", id)
+        }
         return true
     }
 

+ 23 - 10
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/impl/CommSdkImpl.kt

@@ -12,8 +12,9 @@ import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkRoleInfo
 import cn.yyxx.eyuancomm.comm.internal.ICallback
 import cn.yyxx.eyuancomm.comm.network.SdkRequest
+import cn.yyxx.eyuancomm.comm.trace.TraceEventManager
 import cn.yyxx.eyuancomm.comm.utils.Logger
-import cn.yyxx.eyuancomm.comm.utils.MMKVHandler
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
 import cn.yyxx.eyuancomm.comm.utils.ParamsUtils
 import cn.yyxx.eyuancomm.comm.widget.ScaleLoadingDialog
 import cn.yyxx.support.BeanUtils
@@ -106,14 +107,13 @@ internal class CommSdkImpl(context: Context) {
         //获取当前屏幕尺寸
         CommSdkDrive.instance.setCommParam("screen", DensityUtils.getResolutionByFullScreen(activity))
 
-        val adjustId = MMKVHandler.instance.eventKV.decodeString("adjust_id")
+        val adjustId = MMKVManager.instance.eventKV.decodeString("adjust_id")
         if (TextUtils.isEmpty(adjustId)) {
             CommSdkDrive.instance.setCommParam("aid", "")
         } else {
             CommSdkDrive.instance.setCommParam("aid", adjustId!!)
         }
 
-
         // 有些CP在资源再加时候回重复调用初始化,这里拦截一下
         if (hasSdkInit) {
             Logger.e("Sdk初始化已经执行,拦截此次调用")
@@ -136,13 +136,13 @@ internal class CommSdkImpl(context: Context) {
                 }
                 activity.runOnUiThread {
                     if (EYuanCommInstaller.hasReadDeviceId) {
-                        Logger.i("加载deviceI完成,共延迟${timeCount}s初始化,将进行初始化操作...")
+                        Logger.i("加载deviceId完成,共延迟${timeCount}s初始化,将进行初始化操作...")
                         startSdkInit(activity, isLandscape, callback)
                     }
                 }
             }.start()
         } else {
-            Logger.i("加载deviceI完成,开始初始化...")
+            Logger.i("加载deviceId完成,开始初始化...")
             startSdkInit(activity, isLandscape, callback)
         }
     }
@@ -221,6 +221,11 @@ internal class CommSdkImpl(context: Context) {
                                 val jsonObject = JSONObject(resultInfo.data)
                                 SdkLoginInfo.instance.userId = jsonObject.getString("uid")
                                 SdkLoginInfo.instance.token = jsonObject.getString("token")
+                                SdkLoginInfo.instance.isRegUser = jsonObject.getInt("is_reg_user") == 1
+                                if (SdkLoginInfo.instance.isRegUser) {
+                                    TraceEventManager.instance.register(activity)
+                                }
+                                TraceEventManager.instance.login(activity)
                             }
                             showFloatBall(activity)
                             callback.onResult(0, SdkLoginInfo.instance.toJsonString())
@@ -250,7 +255,6 @@ internal class CommSdkImpl(context: Context) {
         if (checkSdkNonInit(Function.LOGOUT, callback)) {
             return
         }
-
         val channelCallback = object : ICallback {
             override fun onResult(code: Int, result: String) {
                 if (code == 0) {
@@ -285,6 +289,15 @@ internal class CommSdkImpl(context: Context) {
             return
         }
 
+        val channelCallback = object : ICallback {
+            override fun onResult(code: Int, result: String) {
+                if (code == 0) {
+                    TraceEventManager.instance.charge(activity, innerChargeInfo)
+                }
+                callback.onResult(code, result)
+            }
+        }
+
         showPayLoadingDialog(activity)
 
         SdkRequest.instance.createOrder(activity, "", innerChargeInfo) { resultInfo ->
@@ -310,7 +323,7 @@ internal class CommSdkImpl(context: Context) {
                 SdkProxyManager.call(
                     Function.CHARGE,
                     arrayOf(Activity::class.java, SdkChargeInfo::class.java, ICallback::class.java),
-                    arrayOf(activity, innerChargeInfo, callback)
+                    arrayOf(activity, innerChargeInfo, channelCallback)
                 )
             } else {
                 callback.onResult(-1, resultInfo.msg)
@@ -417,7 +430,7 @@ internal class CommSdkImpl(context: Context) {
         if (checkSdkProxyNull(Function.ON_RESUME, null)) {
             return
         }
-
+        TraceEventManager.instance.resume(activity)
         SdkProxyManager.call(Function.ON_RESUME, arrayOf(Activity::class.java), arrayOf(activity))
     }
 
@@ -425,7 +438,7 @@ internal class CommSdkImpl(context: Context) {
         if (checkSdkProxyNull(Function.ON_PAUSE, null)) {
             return
         }
-
+        TraceEventManager.instance.pause(activity)
         SdkProxyManager.call(Function.ON_PAUSE, arrayOf(Activity::class.java), arrayOf(activity))
     }
 
@@ -441,7 +454,7 @@ internal class CommSdkImpl(context: Context) {
         if (checkSdkProxyNull(Function.ON_DESTROY, null)) {
             return
         }
-
+        TraceEventManager.instance.release()
         SdkProxyManager.call(Function.ON_DESTROY, arrayOf(Activity::class.java), arrayOf(activity))
     }
 

+ 75 - 1
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/TraceEventManager.kt

@@ -1,17 +1,91 @@
 package cn.yyxx.eyuancomm.comm.trace
 
+import android.app.Activity
+import android.app.Application
+import android.content.Context
+import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
+import cn.yyxx.eyuancomm.comm.entity.SdkEvent
+import cn.yyxx.eyuancomm.comm.internal.ITrace
+import cn.yyxx.eyuancomm.comm.trace.channel.AdjustEventTrace
+
 /**
  * @author #Suyghur.
  * Created on 2022/03/08
  */
 class TraceEventManager private constructor() {
 
-
     companion object {
         val instance: TraceEventManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
             TraceEventManager()
         }
     }
 
+    private val observers: MutableList<ITrace> = mutableListOf()
+
+    fun initialize(application: Application, callback: (String) -> Unit) {
+        observers.add(AdjustEventTrace { id ->
+            callback(id)
+        })
+//        observers.add(TraceFirebaseImpl())
+//        observers.add(TraceFacebookImpl())
+
+        for (ob in observers) {
+            ob.onInitialize(application)
+        }
+    }
+
+    fun release() {
+        if (!observers.isNullOrEmpty()) {
+            observers.clear()
+        }
+    }
 
+
+    fun login(context: Context) {
+        for (ob in observers) {
+            ob.onLogin(context)
+        }
+    }
+
+    fun register(context: Context) {
+        for (ob in observers) {
+            ob.onRegister(context)
+        }
+    }
+
+    fun charge(context: Context, chargeInfo: SdkChargeInfo) {
+        for (ob in observers) {
+            ob.onCharge(context, chargeInfo)
+        }
+    }
+
+    fun create(activity: Activity) {
+        for (ob in observers) {
+            ob.onCreate(activity)
+        }
+    }
+
+    fun resume(activity: Activity) {
+        for (ob in observers) {
+            ob.onResume(activity)
+        }
+    }
+
+    fun pause(activity: Activity) {
+        for (ob in observers) {
+            ob.onPause(activity)
+        }
+    }
+
+    fun sdkEvent(context: Context, sdkEvent: SdkEvent) {
+        for (ob in observers) {
+            ob.onSdkEvent(context, sdkEvent)
+        }
+    }
+
+    fun extEvent(context: Context, sdkEvent: SdkEvent) {
+        for (ob in observers) {
+            ob.onExtEvent(context, sdkEvent)
+        }
+    }
 }

+ 164 - 39
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/AdjustEventTrace.kt

@@ -6,7 +6,17 @@ import android.content.Context
 import android.text.TextUtils
 import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkEvent
+import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
 import cn.yyxx.eyuancomm.comm.internal.ITrace
+import cn.yyxx.eyuancomm.comm.utils.Logger
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
+import cn.yyxx.eyuancomm.comm.utils.ParamsUtils
+import cn.yyxx.support.JsonUtils
+import cn.yyxx.support.hawkeye.LogUtils
+import com.adjust.sdk.Adjust
+import com.adjust.sdk.AdjustConfig
+import com.adjust.sdk.AdjustEvent
+import com.adjust.sdk.LogLevel
 import org.json.JSONObject
 import java.io.BufferedReader
 import java.io.InputStreamReader
@@ -22,69 +32,184 @@ class AdjustEventTrace(private val onIdRead: (String) -> Unit) : ITrace {
     private var extConfig: JSONObject? = null
 
     override fun onInitialize(application: Application) {
-//        this.sdkConfig = getSdkLogJson(application)
-//        this.extConfig = getExtLogJson(application)
-//
-//        if (sdkConfig == null) {
-//            Logger.e("adjust log 初始化失败,读取sdk_log.json异常")
-//            return
-//        }
-//
-//        val appId = ParamsUtils.getAdjustAppId(application)
-//        if (TextUtils.isEmpty(appId)) {
-//            Logger.e("adjust log 初始化失败,app id为空")
-//            isInitSuccess = false
-//            return
-//        }
-//
-//        val environment = if (LogUtils.DEBUG) {
-//            AdjustConfig.ENVIRONMENT_SANDBOX
-//        } else {
-//            AdjustConfig.ENVIRONMENT_PRODUCTION
-//        }
-//
-//        val config = AdjustConfig(application, appId, environment, true)
-//        config.setLogLevel(LogLevel.VERBOSE)
-//        config.setOnAttributionChangedListener {
-//            onIdRead(it.adid)
-//        }
-//        Adjust.onCreate(config)
-//        if (MMKVUtils.instance.eventKV.decodeBool("adjust_activities")) {
-//            isInitSuccess = true
-//            return
-//        }
-//        sdkConfig?.apply {
-//            if (JsonUtils.hasJsonKey(this, "open_app")) {
-//                Adjust.trackEvent(AdjustEvent(this.getString("open_app")))
-//                Logger.d("adjust log open app success")
-//                MMKVUtils.instance.eventKV.encode("adjust_activities", true)
-//                isInitSuccess = true
-//            }
-//        }
+        this.sdkConfig = getSdkLogJson(application)
+        this.extConfig = getExtLogJson(application)
+
+        if (sdkConfig == null) {
+            Logger.e("adjust log 初始化失败,读取sdk_log.json异常")
+            return
+        }
+
+        val appId = ParamsUtils.getAdjustAppId(application)
+        if (TextUtils.isEmpty(appId)) {
+            Logger.e("adjust log 初始化失败,app id为空")
+            isInitSuccess = false
+            return
+        }
+
+        val environment = if (LogUtils.DEBUG) {
+            AdjustConfig.ENVIRONMENT_SANDBOX
+        } else {
+            AdjustConfig.ENVIRONMENT_PRODUCTION
+        }
+
+        val config = AdjustConfig(application, appId, environment, true)
+        config.setLogLevel(LogLevel.VERBOSE)
+        config.setOnAttributionChangedListener {
+            onIdRead(it.adid)
+        }
+        Adjust.onCreate(config)
+        if (MMKVManager.instance.eventKV.decodeBool("adjust_activities")) {
+            isInitSuccess = true
+            return
+        }
+        sdkConfig?.apply {
+            if (JsonUtils.hasJsonKey(this, "open_app")) {
+                Adjust.trackEvent(AdjustEvent(this.getString("open_app")))
+                Logger.d("adjust log open app success")
+                MMKVManager.instance.eventKV.encode("adjust_activities", true)
+                isInitSuccess = true
+            }
+        }
     }
 
     override fun onLogin(context: Context) {
+        if (!isInitSuccess) {
+            Logger.e("adjust log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("adjust log failed , user is null")
+            return
+        }
+
+        sdkConfig?.apply {
+            if (JsonUtils.hasJsonKey(this, "login_success_account")) {
+                Adjust.trackEvent(AdjustEvent(this.getString("login_success_account")))
+                Logger.d("adjust log account login success")
+            }
+        }
     }
 
     override fun onRegister(context: Context) {
+        if (!isInitSuccess) {
+            Logger.e("adjust log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("adjust log failed , user is null")
+            return
+        }
+
+        sdkConfig?.apply {
+            if (JsonUtils.hasJsonKey(this, "sign_up")) {
+                Adjust.trackEvent(AdjustEvent(this.getString("sign_up")))
+                Logger.d("adjust log register success")
+            }
+        }
     }
 
     override fun onCharge(context: Context, chargeInfo: SdkChargeInfo) {
+        if (!isInitSuccess) {
+            Logger.e("adjust log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("adjust log failed , user is null")
+            return
+        }
+
+        sdkConfig?.apply {
+            if (!MMKVManager.instance.eventKV.decodeBool("adjust_first_purchase")) {
+                if (JsonUtils.hasJsonKey(this, "first_purchase")) {
+                    val event = AdjustEvent(this.getString("first_purchase"))
+                    event.setRevenue(chargeInfo.amount.toDouble() / 100, "USD")
+//                    event.setOrderId(chargeInfo.orderId)
+                    Adjust.trackEvent(event)
+                    Logger.d("adjust log first charge success")
+                    MMKVManager.instance.eventKV.encode("adjust_first_purchase", true)
+                }
+            }
+
+            if (JsonUtils.hasJsonKey(this, "ecommerce_purchase")) {
+                val event = AdjustEvent(this.getString("ecommerce_purchase"))
+                event.setRevenue(chargeInfo.amount.toDouble() / 100, "USD")
+//                event.setOrderId(chargeInfo.orderId)
+                Adjust.trackEvent(event)
+                Logger.d("adjust log charge success")
+            }
+        }
     }
 
     override fun onCreate(activity: Activity) {
     }
 
     override fun onResume(activity: Activity) {
+        if (!isInitSuccess) {
+            Logger.e("adjust log failed , component initialize failed")
+            return
+        }
+        Adjust.onResume()
     }
 
     override fun onPause(activity: Activity) {
+        if (!isInitSuccess) {
+            Logger.e("adjust log failed , component initialize failed")
+            return
+        }
+        Adjust.onPause()
     }
 
     override fun onSdkEvent(context: Context, sdkEvent: SdkEvent) {
+        if (!isInitSuccess) {
+            Logger.e("adjust log failed , component initialize failed")
+            return
+        }
+
+        sdkConfig?.apply {
+            if (JsonUtils.hasJsonKey(this, sdkEvent.eventName)) {
+                Adjust.trackEvent(AdjustEvent(this.getString(sdkEvent.eventName)))
+                Logger.d("adjust log sdk event ${sdkEvent.eventName} success")
+            }
+        }
     }
 
     override fun onExtEvent(context: Context, sdkEvent: SdkEvent) {
+        if (!isInitSuccess) {
+            Logger.e("adjust log failed , component initialize failed")
+            return
+        }
+
+        extConfig?.apply {
+            if (JsonUtils.hasJsonKey(this, sdkEvent.eventName)) {
+                Adjust.trackEvent(AdjustEvent(this.getString(sdkEvent.eventName)))
+                Logger.d("adjust log ext event ${sdkEvent.eventName} success")
+            }
+        }
+    }
+
+    private fun getSdkLogJson(context: Context): JSONObject? {
+        val path = "yyxx_game/sdk_log.json"
+        val sb = StringBuilder()
+        try {
+            val assetManager = context.assets
+            BufferedReader(InputStreamReader(assetManager.open(path))).use {
+                var line = ""
+                while (true) {
+                    line = it.readLine() ?: break
+                    sb.append(line)
+                }
+            }
+            if (!TextUtils.isEmpty(sb.toString())) {
+                return JSONObject(sb.toString())
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+        return null
     }
 
     private fun getExtLogJson(context: Context): JSONObject? {

+ 3 - 3
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/utils/MMKVHandler.kt → library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/utils/MMKVManager.kt

@@ -12,11 +12,11 @@ import java.io.File
  * @author #Suyghur.
  * Created on 2021/06/25
  */
-class MMKVHandler private constructor() : MMKVHandler {
+class MMKVManager private constructor() : MMKVHandler {
 
     companion object {
-        val instance: cn.yyxx.eyuancomm.comm.utils.MMKVHandler by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
-            MMKVHandler()
+        val instance: MMKVManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
+            MMKVManager()
         }
     }
 

+ 15 - 5
library_impl/src/main/java/cn/yyxx/eyuancomm/impl/channel/eyuangame/ChannelSdkEYuanGame.kt

@@ -5,10 +5,7 @@ import android.content.Intent
 import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkRoleInfo
 import cn.yyxx.eyuancomm.comm.internal.ICallback
-import cn.yyxx.eyuancomm.comm.internal.feature.IConfig
-import cn.yyxx.eyuancomm.comm.internal.feature.IFeature
-import cn.yyxx.eyuancomm.comm.internal.feature.ILifeCycle
-import cn.yyxx.eyuancomm.comm.internal.feature.IRoleData
+import cn.yyxx.eyuancomm.comm.internal.feature.*
 import cn.yyxx.eyuancomm.comm.network.SdkRequest
 import cn.yyxx.eyuancomm.core.EYuanGameSdk
 import org.json.JSONObject
@@ -17,7 +14,7 @@ import org.json.JSONObject
  * @author #Suyghur.
  * Created on 2022/01/17
  */
-internal class ChannelSdkEYuanGame : IFeature, ILifeCycle, IConfig, IRoleData {
+internal class ChannelSdkEYuanGame : IFeature, ILifeCycle, IConfig, IRoleData, IFloatBall {
 
     override fun initialize(activity: Activity, isLandscape: Boolean, callback: ICallback) {
         EYuanGameSdk.getInstance().initialize(activity, isLandscape) { code, result ->
@@ -124,4 +121,17 @@ internal class ChannelSdkEYuanGame : IFeature, ILifeCycle, IConfig, IRoleData {
     override fun roleUpgrade(activity: Activity, roleInfo: SdkRoleInfo) {
         EYuanGameSdk.getInstance().roleLevelUp(activity, roleInfo)
     }
+
+    override fun showFloatBall(activity: Activity) {
+
+    }
+
+    override fun hideFloatBall(activity: Activity) {
+    }
+
+    override fun onFloatBallLogout(callback: ICallback) {
+        EYuanGameSdk.getInstance().setOnFloatBallLogoutCallback { code, result ->
+            callback.onResult(code, result)
+        }
+    }
 }

+ 7 - 0
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/EYuanGameSdk.kt

@@ -65,6 +65,13 @@ class EYuanGameSdk private constructor() {
         impl.installConfig(activity, config)
     }
 
+    fun setOnFloatBallLogoutCallback(callback: (Int, String) -> Unit) {
+        if (checkSdkNonInit("setOnFloatBallLogoutCallback", null)) {
+            return
+        }
+        impl.setOnFloatBallLogoutCallback(callback)
+    }
+
     /**
      * SDK用户登录
      *

+ 2 - 1
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/entity/FloatFeature.kt

@@ -9,5 +9,6 @@ enum class FloatFeature {
     FEATURE_GIF,
     FEATURE_GM,
     FEATURE_CHARGE,
-    FEATURE_INVITE
+    FEATURE_INVITE,
+    FEATURE_LOGOUT
 }

+ 9 - 12
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/entity/bean/init/FloatCfg.kt → module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/entity/bean/FloatCfg.kt

@@ -1,4 +1,4 @@
-package cn.yyxx.eyuancomm.core.entity.bean.init
+package cn.yyxx.eyuancomm.core.entity.bean
 
 import cn.yyxx.support.JsonUtils
 import org.json.JSONObject
@@ -18,19 +18,10 @@ class FloatCfg {
     lateinit var gmCfg: FeatureCfg
     lateinit var chargeCfg: FeatureCfg
     lateinit var inviteCfg: FeatureCfg
+    lateinit var logoutCfg: FeatureCfg
 
     override fun toString(): String {
-        return "FloatCfg(" +
-                "switch=$switch, " +
-                "floatIconUrl='$floatIconUrl', " +
-                "floatIconLeftUrl='$floatIconLeftUrl', " +
-                "floatIconRightUrl='$floatIconRightUrl', " +
-                "memberCfg=$memberCfg, " +
-                "gifCfg=$gifCfg, " +
-                "gmCfg=$gmCfg, " +
-                "chargeCfg=$chargeCfg, " +
-                "inviteCfg=$inviteCfg" +
-                ")"
+        return "FloatCfg(switch=$switch, floatIconUrl='$floatIconUrl', floatIconLeftUrl='$floatIconLeftUrl', floatIconRightUrl='$floatIconRightUrl', memberCfg=$memberCfg, gifCfg=$gifCfg, gmCfg=$gmCfg, chargeCfg=$chargeCfg, inviteCfg=$inviteCfg, switchCfg=$logoutCfg)"
     }
 
     companion object {
@@ -42,6 +33,7 @@ class FloatCfg {
             bean.gmCfg = FeatureCfg()
             bean.chargeCfg = FeatureCfg()
             bean.inviteCfg = FeatureCfg()
+            bean.logoutCfg = FeatureCfg()
             if (JsonUtils.hasJsonKey(floatCfg, "cfg_s")) {
                 bean.switch = floatCfg.getInt("cfg_s")
             }
@@ -78,6 +70,10 @@ class FloatCfg {
                 bean.inviteCfg = FeatureCfg.toBean(floatCfg.getJSONObject("invite_cfg"))
             }
 
+            if (JsonUtils.hasJsonKey(floatCfg, "logout_cfg")) {
+                bean.logoutCfg = FeatureCfg.toBean(floatCfg.getJSONObject("logout_cfg"))
+            }
+
             return bean
         }
     }
@@ -112,4 +108,5 @@ class FloatCfg {
 
     }
 
+
 }

+ 1 - 1
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/entity/bean/init/InitBean.kt → module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/entity/bean/InitBean.kt

@@ -1,4 +1,4 @@
-package cn.yyxx.eyuancomm.core.entity.bean.init
+package cn.yyxx.eyuancomm.core.entity.bean
 
 import android.text.TextUtils
 import cn.yyxx.support.JsonUtils

+ 24 - 18
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/GameSdkImpl.kt

@@ -9,20 +9,18 @@ import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkRoleInfo
 import cn.yyxx.eyuancomm.comm.utils.Logger
-import cn.yyxx.eyuancomm.comm.utils.MMKVHandler
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
 import cn.yyxx.eyuancomm.core.entity.SdkEvent
-import cn.yyxx.eyuancomm.core.entity.bean.init.InitBean
+import cn.yyxx.eyuancomm.core.entity.bean.InitBean
 import cn.yyxx.eyuancomm.core.impl.center.HybridFeatureContainer
 import cn.yyxx.eyuancomm.core.impl.floatball.FloatCenterServiceManager
 import cn.yyxx.eyuancomm.core.impl.login.LoginActivity
 import cn.yyxx.eyuancomm.core.impl.share.ShareImpl
 import cn.yyxx.eyuancomm.core.internal.IOrder
 import cn.yyxx.eyuancomm.core.network.SdkRequest
-import cn.yyxx.eyuancomm.core.trace.TraceEventManager
 import cn.yyxx.eyuancomm.core.widget.dialog.TipsDialog
 import cn.yyxx.support.ResUtils
 import cn.yyxx.support.device.DeviceInfoUtils
-import com.google.firebase.crashlytics.FirebaseCrashlytics
 
 
 /**
@@ -37,9 +35,13 @@ class GameSdkImpl {
 
     private var exitDialog: TipsDialog? = null
 
+    private var floatBallLogoutCallback: ((Int, String) -> Unit)? = null
+
     companion object {
         var isLandscape = false
         lateinit var initBean: InitBean
+        var floatBallLogoutCallback: ((Int, String) -> Unit)? = null
+
     }
 
     fun initialize(activity: Activity, isLandscape: Boolean, callback: (Int, String) -> Unit) {
@@ -55,6 +57,10 @@ class GameSdkImpl {
         FloatCenterServiceManager.instance.init(activity)
     }
 
+    fun setOnFloatBallLogoutCallback(callback: (Int, String) -> Unit) {
+        Companion.floatBallLogoutCallback = callback
+    }
+
     private fun cacheImageResource(activity: Activity) {
         //全图标
         SdkRequest.instance.downloadImageFile(activity, initBean.floatCfg.floatIconUrl)
@@ -85,13 +91,13 @@ class GameSdkImpl {
         SdkLoginInfo.instance.reset()
 
         LoginActivity.login(activity, isAutoLogin) { code, result ->
-            if (code == 0) {
-                if (SdkLoginInfo.instance.isRegUser) {
-                    TraceEventManager.instance.register(activity)
-                }
-                FirebaseCrashlytics.getInstance().setUserId(SdkLoginInfo.instance.userId)
-                TraceEventManager.instance.login(activity)
-            }
+//            if (code == 0) {
+//                if (SdkLoginInfo.instance.isRegUser) {
+//                    TraceEventManager.instance.register(activity)
+//                }
+//                FirebaseCrashlytics.getInstance().setUserId(SdkLoginInfo.instance.userId)
+//                TraceEventManager.instance.login(activity)
+//            }
             callback(code, result)
         }
     }
@@ -99,7 +105,7 @@ class GameSdkImpl {
     fun logout(activity: Activity, callback: (Int, String) -> Unit) {
         Logger.i("EYuanGameSdk logout ...")
         SdkLoginInfo.instance.reset()
-        FirebaseCrashlytics.getInstance().setUserId("")
+//        FirebaseCrashlytics.getInstance().setUserId("")
         FloatCenterServiceManager.instance.detach()
         callback(0, "用户登出成功")
     }
@@ -180,7 +186,7 @@ class GameSdkImpl {
             exitDialog = null
         }
 
-        exitDialog = TipsDialog(activity, true)
+        exitDialog = TipsDialog(activity, isLandscape, true)
         exitDialog?.apply {
             textView.text = ResUtils.getResString(activity, "yyxx_tv_exit_content")
             leftButton.text = ResUtils.getResString(activity, "yyxx_tv_exit_left")
@@ -214,13 +220,13 @@ class GameSdkImpl {
     fun onResume(activity: Activity) {
         Logger.i("EYuanGameSdk onResume ...")
         FloatCenterServiceManager.instance.attach()
-        TraceEventManager.instance.resume(activity)
+//        TraceEventManager.instance.resume(activity)
     }
 
     fun onPause(activity: Activity) {
         Logger.i("EYuanGameSdk onPause ...")
         FloatCenterServiceManager.instance.detach()
-        TraceEventManager.instance.pause(activity)
+//        TraceEventManager.instance.pause(activity)
     }
 
     fun onStop(activity: Activity) {
@@ -230,8 +236,8 @@ class GameSdkImpl {
     fun onDestroy(activity: Activity) {
         Logger.i("EYuanGameSdk onDestroy ...")
         FloatCenterServiceManager.instance.release()
-        TraceEventManager.instance.release()
-        MMKVHandler.instance.release()
+//        TraceEventManager.instance.release()
+        MMKVManager.instance.release()
     }
 
     fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
@@ -265,7 +271,7 @@ class GameSdkImpl {
 
     fun traceEvent(context: Context, sdkEvent: SdkEvent) {
         Logger.i("EYuanGameSdk linkingEvent ...")
-        TraceEventManager.instance.extEvent(context, sdkEvent)
+//        TraceEventManager.instance.extEvent(context, sdkEvent)
     }
 
     fun share(activity: Activity, line: String, tag: String, quote: String, callback: (Int, String) -> Unit) {

+ 1 - 1
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/center/HybridFeatureContainer.kt

@@ -17,11 +17,11 @@ import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
 import cn.yyxx.eyuancomm.comm.impl.CommSdkDrive
 import cn.yyxx.eyuancomm.comm.network.Host
 import cn.yyxx.eyuancomm.comm.utils.Logger
+import cn.yyxx.eyuancomm.comm.widget.ScaleLoadingDialog
 import cn.yyxx.eyuancomm.core.impl.GameSdkImpl
 import cn.yyxx.eyuancomm.core.impl.SdkJsImpl
 import cn.yyxx.eyuancomm.core.impl.share.ShareImpl
 import cn.yyxx.eyuancomm.core.network.SdkRequest
-import cn.yyxx.eyuancomm.core.widget.dialog.ScaleLoadingDialog
 import cn.yyxx.support.DensityUtils
 import cn.yyxx.support.JsonUtils
 import cn.yyxx.support.ResUtils

+ 20 - 5
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/floatball/FloatCenterService.kt

@@ -62,7 +62,13 @@ class FloatCenterService : Service() {
         override fun onInitMenuData(): MutableList<FloatingBallMenu.FloatingBallMenuItem> {
             val items = mutableListOf<FloatingBallMenu.FloatingBallMenuItem>()
             if (GameSdkImpl.initBean.floatCfg.memberCfg.switch == 1) {
-                items.add(FloatingBallMenu.FloatingBallMenuItem(FloatFeature.FEATURE_MEMBER, GameSdkImpl.initBean.floatCfg.memberCfg.iconUrl, ""))
+                items.add(
+                    FloatingBallMenu.FloatingBallMenuItem(
+                        FloatFeature.FEATURE_MEMBER,
+                        GameSdkImpl.initBean.floatCfg.memberCfg.iconUrl,
+                        ""
+                    )
+                )
             }
             if (GameSdkImpl.initBean.floatCfg.gifCfg.switch == 1 && !TextUtils.isEmpty(GameSdkImpl.initBean.floatCfg.gifCfg.url)) {
                 items.add(
@@ -100,14 +106,23 @@ class FloatCenterService : Service() {
                     )
                 )
             }
+            if (GameSdkImpl.initBean.floatCfg.logoutCfg.switch == 1) {
+                items.add(
+                    FloatingBallMenu.FloatingBallMenuItem(
+                        FloatFeature.FEATURE_LOGOUT,
+                        GameSdkImpl.initBean.floatCfg.logoutCfg.iconUrl,
+                        ""
+                    )
+                )
+            }
             return items
         }
 
         override fun onMenuItemClick(item: FloatingBallMenu.FloatingBallMenuItem, pos: Int) {
-            if (item.type == FloatFeature.FEATURE_MEMBER) {
-                MemberCenterContainer(mActivity!!).show()
-            } else {
-                HybridFeatureContainer(mActivity!!, item.url).show()
+            when (item.type) {
+                FloatFeature.FEATURE_MEMBER -> MemberCenterContainer(mActivity!!).show()
+                FloatFeature.FEATURE_LOGOUT -> GameSdkImpl.floatBallLogoutCallback?.apply { this(0, "浮标切换账号") }
+                else -> HybridFeatureContainer(mActivity!!, item.url).show()
             }
         }
 

+ 4 - 6
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/login/LoginActivity.kt

@@ -19,13 +19,11 @@ import androidx.viewpager2.widget.ViewPager2
 import cn.yyxx.eyuancomm.comm.utils.Logger
 import cn.yyxx.eyuancomm.core.entity.ClickType
 import cn.yyxx.eyuancomm.core.entity.LoginType
-import cn.yyxx.eyuancomm.core.entity.SdkEvent
 import cn.yyxx.eyuancomm.core.entity.Session
 import cn.yyxx.eyuancomm.core.ext.countDownCoroutines
 import cn.yyxx.eyuancomm.core.impl.GameSdkImpl
 import cn.yyxx.eyuancomm.core.impl.login.fragment.LauncherFragment
 import cn.yyxx.eyuancomm.core.impl.login.fragment.RegisterFragment
-import cn.yyxx.eyuancomm.core.trace.TraceEventManager
 import cn.yyxx.eyuancomm.core.utils.SessionUtils
 import cn.yyxx.eyuancomm.core.widget.dialog.AutoLoginDialog
 import cn.yyxx.eyuancomm.core.widget.dialog.ChooseLoginDialog
@@ -221,10 +219,10 @@ class LoginActivity : FragmentActivity(), View.OnClickListener {
 
             })
             show()
-            with(SdkEvent()) {
-                eventName = "choose_login_page"
-                TraceEventManager.instance.sdkEvent(this@LoginActivity, this)
-            }
+//            with(SdkEvent()) {
+//                eventName = "choose_login_page"
+//                TraceEventManager.instance.sdkEvent(this@LoginActivity, this)
+//            }
         }
     }
 

+ 7 - 4
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/impl/login/UserSignInImpl.kt

@@ -7,11 +7,11 @@ import android.text.TextUtils
 import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
 import cn.yyxx.eyuancomm.comm.utils.Logger
 import cn.yyxx.eyuancomm.comm.utils.ParamsUtils
+import cn.yyxx.eyuancomm.comm.widget.ScaleLoadingDialog
 import cn.yyxx.eyuancomm.core.entity.LoginType
 import cn.yyxx.eyuancomm.core.entity.Session
 import cn.yyxx.eyuancomm.core.network.SdkRequest
 import cn.yyxx.eyuancomm.core.utils.SessionUtils
-import cn.yyxx.eyuancomm.core.widget.dialog.ScaleLoadingDialog
 import cn.yyxx.support.ResUtils
 import cn.yyxx.support.hawkeye.ToastUtils
 import com.facebook.*
@@ -25,7 +25,10 @@ import com.google.android.gms.common.ConnectionResult
 import com.google.android.gms.common.GoogleApiAvailability
 import com.google.android.gms.common.api.ApiException
 import com.google.android.gms.tasks.Task
-import kotlinx.coroutines.*
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.cancel
+import kotlinx.coroutines.launch
 import org.json.JSONException
 import org.json.JSONObject
 import java.util.*
@@ -183,7 +186,7 @@ class UserSignInImpl constructor(val activity: LoginActivity, private val callba
                                 cancel()
                             }
                         }
-                        callback.onSuccess(SdkLoginInfo.instance.toJsonString())
+                        callback.onSuccess(resultInfo.data)
                     } catch (e: JSONException) {
                         e.printStackTrace()
                         val msg = if (TextUtils.isEmpty(resultInfo.msg)) {
@@ -242,7 +245,7 @@ class UserSignInImpl constructor(val activity: LoginActivity, private val callba
                             cancel()
                         }
                     }
-                    callback.onSuccess(SdkLoginInfo.instance.toJsonString())
+                    callback.onSuccess(resultInfo.data)
                 } catch (e: JSONException) {
                     e.printStackTrace()
                     val msg = if (TextUtils.isEmpty(resultInfo.msg)) {

+ 101 - 101
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/trace/TraceEventManager.kt

@@ -1,101 +1,101 @@
-package cn.yyxx.eyuancomm.core.trace
-
-import android.app.Activity
-import android.app.Application
-import android.content.Context
-import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
-import cn.yyxx.eyuancomm.core.entity.SdkEvent
-import cn.yyxx.eyuancomm.core.internal.ITrace
-import cn.yyxx.eyuancomm.core.trace.channel.TraceAdjustImpl
-import cn.yyxx.eyuancomm.core.trace.channel.TraceFacebookImpl
-import cn.yyxx.eyuancomm.core.trace.channel.TraceFirebaseImpl
-
-/**
- * @author #Suyghur.
- * Created on 2021/06/17
- */
-class TraceEventManager private constructor() {
-
-    companion object {
-        val instance: TraceEventManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
-            TraceEventManager()
-        }
-    }
-
-    private val observers: MutableList<ITrace> = mutableListOf()
-
-    fun initialize(application: Application, callback: OnTraceIdRead) {
-        observers.add(TraceAdjustImpl(object : TraceAdjustImpl.OnAdjustIdRead {
-            override fun onRead(id: String) {
-                callback.onAdjustIdRead(id)
-            }
-
-        }))
-        observers.add(TraceFirebaseImpl())
-        observers.add(TraceFacebookImpl())
-
-        for (ob in observers) {
-            ob.onInitialize(application)
-        }
-    }
-
-
-    fun release() {
-        if (!observers.isNullOrEmpty()) {
-            observers.clear()
-        }
-    }
-
-
-    fun login(context: Context) {
-        for (ob in observers) {
-            ob.onLogin(context)
-        }
-    }
-
-    fun register(context: Context) {
-        for (ob in observers) {
-            ob.onRegister(context)
-        }
-    }
-
-    fun charge(context: Context, chargeInfo: SdkChargeInfo) {
-        for (ob in observers) {
-            ob.onCharge(context, chargeInfo)
-        }
-    }
-
-    fun create(activity: Activity) {
-        for (ob in observers) {
-            ob.onCreate(activity)
-        }
-    }
-
-    fun resume(activity: Activity) {
-        for (ob in observers) {
-            ob.onResume(activity)
-        }
-    }
-
-    fun pause(activity: Activity) {
-        for (ob in observers) {
-            ob.onPause(activity)
-        }
-    }
-
-    fun sdkEvent(context: Context, sdkEvent: SdkEvent) {
-        for (ob in observers) {
-            ob.onSdkEvent(context, sdkEvent)
-        }
-    }
-
-    fun extEvent(context: Context, sdkEvent: SdkEvent) {
-        for (ob in observers) {
-            ob.onExtEvent(context, sdkEvent)
-        }
-    }
-
-    interface OnTraceIdRead {
-        fun onAdjustIdRead(id: String)
-    }
-}
+//package cn.yyxx.eyuancomm.core.trace
+//
+//import android.app.Activity
+//import android.app.Application
+//import android.content.Context
+//import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
+//import cn.yyxx.eyuancomm.core.entity.SdkEvent
+//import cn.yyxx.eyuancomm.core.internal.ITrace
+//import cn.yyxx.eyuancomm.core.trace.channel.TraceAdjustImpl
+//import cn.yyxx.eyuancomm.core.trace.channel.TraceFacebookImpl
+//import cn.yyxx.eyuancomm.core.trace.channel.TraceFirebaseImpl
+//
+///**
+// * @author #Suyghur.
+// * Created on 2021/06/17
+// */
+//class TraceEventManager private constructor() {
+//
+//    companion object {
+//        val instance: TraceEventManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
+//            TraceEventManager()
+//        }
+//    }
+//
+//    private val observers: MutableList<ITrace> = mutableListOf()
+//
+//    fun initialize(application: Application, callback: OnTraceIdRead) {
+//        observers.add(TraceAdjustImpl(object : TraceAdjustImpl.OnAdjustIdRead {
+//            override fun onRead(id: String) {
+//                callback.onAdjustIdRead(id)
+//            }
+//
+//        }))
+//        observers.add(TraceFirebaseImpl())
+//        observers.add(TraceFacebookImpl())
+//
+//        for (ob in observers) {
+//            ob.onInitialize(application)
+//        }
+//    }
+//
+//
+//    fun release() {
+//        if (!observers.isNullOrEmpty()) {
+//            observers.clear()
+//        }
+//    }
+//
+//
+//    fun login(context: Context) {
+//        for (ob in observers) {
+//            ob.onLogin(context)
+//        }
+//    }
+//
+//    fun register(context: Context) {
+//        for (ob in observers) {
+//            ob.onRegister(context)
+//        }
+//    }
+//
+//    fun charge(context: Context, chargeInfo: SdkChargeInfo) {
+//        for (ob in observers) {
+//            ob.onCharge(context, chargeInfo)
+//        }
+//    }
+//
+//    fun create(activity: Activity) {
+//        for (ob in observers) {
+//            ob.onCreate(activity)
+//        }
+//    }
+//
+//    fun resume(activity: Activity) {
+//        for (ob in observers) {
+//            ob.onResume(activity)
+//        }
+//    }
+//
+//    fun pause(activity: Activity) {
+//        for (ob in observers) {
+//            ob.onPause(activity)
+//        }
+//    }
+//
+//    fun sdkEvent(context: Context, sdkEvent: SdkEvent) {
+//        for (ob in observers) {
+//            ob.onSdkEvent(context, sdkEvent)
+//        }
+//    }
+//
+//    fun extEvent(context: Context, sdkEvent: SdkEvent) {
+//        for (ob in observers) {
+//            ob.onExtEvent(context, sdkEvent)
+//        }
+//    }
+//
+//    interface OnTraceIdRead {
+//        fun onAdjustIdRead(id: String)
+//    }
+//}

+ 5 - 5
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/trace/channel/TraceAdjustImpl.kt

@@ -7,7 +7,7 @@ import android.text.TextUtils
 import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
 import cn.yyxx.eyuancomm.comm.utils.Logger
-import cn.yyxx.eyuancomm.comm.utils.MMKVHandler
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
 import cn.yyxx.eyuancomm.comm.utils.ParamsUtils
 import cn.yyxx.eyuancomm.core.entity.LoginType
 import cn.yyxx.eyuancomm.core.entity.SdkEvent
@@ -62,7 +62,7 @@ class TraceAdjustImpl(val callback: OnAdjustIdRead) : ITrace {
             callback.onRead(it.adid)
         }
         Adjust.onCreate(config)
-        if (MMKVHandler.instance.eventKV.decodeBool("adjust_activities")) {
+        if (MMKVManager.instance.eventKV.decodeBool("adjust_activities")) {
             isInitSuccess = true
             return
         }
@@ -70,7 +70,7 @@ class TraceAdjustImpl(val callback: OnAdjustIdRead) : ITrace {
             if (JsonUtils.hasJsonKey(this, "open_app")) {
                 Adjust.trackEvent(AdjustEvent(this.getString("open_app")))
                 Logger.d("adjust log open app success")
-                MMKVHandler.instance.eventKV.encode("adjust_activities", true)
+                MMKVManager.instance.eventKV.encode("adjust_activities", true)
                 isInitSuccess = true
             }
         }
@@ -148,14 +148,14 @@ class TraceAdjustImpl(val callback: OnAdjustIdRead) : ITrace {
         }
 
         sdkConfig?.apply {
-            if (!MMKVHandler.instance.eventKV.decodeBool("adjust_first_purchase")) {
+            if (!MMKVManager.instance.eventKV.decodeBool("adjust_first_purchase")) {
                 if (JsonUtils.hasJsonKey(this, "first_purchase")) {
                     val event = AdjustEvent(this.getString("first_purchase"))
                     event.setRevenue(chargeInfo.amount.toDouble() / 100, "USD")
                     event.setOrderId(chargeInfo.orderId)
                     Adjust.trackEvent(event)
                     Logger.d("adjust log first charge success")
-                    MMKVHandler.instance.eventKV.encode("adjust_first_purchase", true)
+                    MMKVManager.instance.eventKV.encode("adjust_first_purchase", true)
                 }
             }
 

+ 5 - 5
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/trace/channel/TraceFacebookImpl.kt

@@ -8,7 +8,7 @@ import android.text.TextUtils
 import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
 import cn.yyxx.eyuancomm.comm.utils.Logger
-import cn.yyxx.eyuancomm.comm.utils.MMKVHandler
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
 import cn.yyxx.eyuancomm.core.entity.LoginType
 import cn.yyxx.eyuancomm.core.entity.SdkEvent
 import cn.yyxx.eyuancomm.core.internal.ITrace
@@ -35,14 +35,14 @@ class TraceFacebookImpl : ITrace {
 
         fbLogger = AppEventsLogger.newLogger(application)
 
-        if (MMKVHandler.instance.eventKV.decodeBool("facebook_activities")) {
+        if (MMKVManager.instance.eventKV.decodeBool("facebook_activities")) {
             isInitSuccess = true
             return
         }
         //open_app
         Logger.d("facebook log open app success")
         fbLogger.logEvent("open_app")
-        MMKVHandler.instance.eventKV.encode("facebook_activities", true)
+        MMKVManager.instance.eventKV.encode("facebook_activities", true)
         isInitSuccess = true
     }
 
@@ -106,10 +106,10 @@ class TraceFacebookImpl : ITrace {
         params.putDouble("price", chargeInfo.amount.toDouble() / 100)
         params.putString("order", chargeInfo.orderId)
 
-        if (!MMKVHandler.instance.eventKV.decodeBool("facebook_first_purchase")) {
+        if (!MMKVManager.instance.eventKV.decodeBool("facebook_first_purchase")) {
             fbLogger.logEvent("first_purchase", params)
             Logger.d("facebook log first charge success")
-            MMKVHandler.instance.eventKV.encode("facebook_first_purchase", true)
+            MMKVManager.instance.eventKV.encode("facebook_first_purchase", true)
         }
 
         fbLogger.logPurchase(BigDecimal.valueOf(chargeInfo.amount.toDouble() / 100), Currency.getInstance("USD"), params)

+ 5 - 5
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/trace/channel/TraceFirebaseImpl.kt

@@ -7,7 +7,7 @@ import android.text.TextUtils
 import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
 import cn.yyxx.eyuancomm.comm.utils.Logger
-import cn.yyxx.eyuancomm.comm.utils.MMKVHandler
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
 import cn.yyxx.eyuancomm.core.entity.LoginType
 import cn.yyxx.eyuancomm.core.entity.SdkEvent
 import cn.yyxx.eyuancomm.core.internal.ITrace
@@ -25,13 +25,13 @@ class TraceFirebaseImpl : ITrace {
     private var isInitSuccess = false
 
     override fun onInitialize(application: Application) {
-        if (MMKVHandler.instance.eventKV.decodeBool("firebase_activities")) {
+        if (MMKVManager.instance.eventKV.decodeBool("firebase_activities")) {
             isInitSuccess = true
             return
         }
         Firebase.analytics.logEvent("open_app", null)
         Logger.d("firebase log open app success")
-        MMKVHandler.instance.eventKV.encode("firebase_activities", true)
+        MMKVManager.instance.eventKV.encode("firebase_activities", true)
         isInitSuccess = true
     }
 
@@ -92,13 +92,13 @@ class TraceFirebaseImpl : ITrace {
             return
         }
 
-        if (!MMKVHandler.instance.eventKV.decodeBool("firebase_first_purchase")) {
+        if (!MMKVManager.instance.eventKV.decodeBool("firebase_first_purchase")) {
             Firebase.analytics.logEvent("first_purchase") {
                 param(FirebaseAnalytics.Param.PRICE, (chargeInfo.amount.toDouble() / 100).toString())
                 param("order_id", chargeInfo.orderId)
             }
             Logger.d("firebase log first charge success")
-            MMKVHandler.instance.eventKV.encode("firebase_first_purchase", true)
+            MMKVManager.instance.eventKV.encode("firebase_first_purchase", true)
         }
 
         Firebase.analytics.logEvent("ecommerce_purchase") {

+ 4 - 4
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/utils/SessionUtils.kt

@@ -3,7 +3,7 @@ package cn.yyxx.eyuancomm.core.utils
 import android.text.TextUtils
 import cn.yyxx.eyuancomm.comm.network.Host
 import cn.yyxx.eyuancomm.comm.utils.Logger
-import cn.yyxx.eyuancomm.comm.utils.MMKVHandler
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
 import cn.yyxx.eyuancomm.core.entity.LoginType
 import cn.yyxx.eyuancomm.core.entity.Session
 import cn.yyxx.support.HostModelUtils
@@ -61,7 +61,7 @@ class SessionUtils private constructor() {
                 HostModelUtils.ENV_TEST -> "test"
                 else -> "online"
             }
-            MMKVHandler.instance.userKV.encode(keyName, jsonObject.toString())
+            MMKVManager.instance.userKV.encode(keyName, jsonObject.toString())
         }
     }
 
@@ -105,7 +105,7 @@ class SessionUtils private constructor() {
             HostModelUtils.ENV_TEST -> "test"
             else -> "online"
         }
-        val json = MMKVHandler.instance.userKV.decodeString(keyName)
+        val json = MMKVManager.instance.userKV.decodeString(keyName)
         return if (TextUtils.isEmpty(json)) {
             mutableListOf()
         } else {
@@ -151,7 +151,7 @@ class SessionUtils private constructor() {
             HostModelUtils.ENV_TEST -> "test"
             else -> "online"
         }
-        MMKVHandler.instance.userKV.encode(keyName, jsonObject.toString())
+        MMKVManager.instance.userKV.encode(keyName, jsonObject.toString())
     }
 
     private fun toList(json: String): MutableList<Session> {

+ 0 - 1
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/widget/dialog/AgreementDialog.kt

@@ -44,7 +44,6 @@ class AgreementDialog constructor(context: Context, url: String, private val isL
         } else {
             attr.width = DensityUtils.getHeightAndWidth(context)[0] - 80
         }
-        attr.width = ViewGroup.LayoutParams.WRAP_CONTENT
         attr.gravity = Gravity.CENTER
 
         ivReturn = findViewById(ResUtils.getResId(context, "yyxx_iv_return", "id"))

+ 0 - 67
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/widget/dialog/ScaleLoadingDialog.kt

@@ -1,67 +0,0 @@
-package cn.yyxx.eyuancomm.core.widget.dialog
-
-import android.app.Dialog
-import android.content.Context
-import android.content.DialogInterface
-import android.graphics.Color
-import android.graphics.drawable.ColorDrawable
-import android.text.TextUtils
-import android.view.*
-import android.widget.LinearLayout
-import android.widget.TextView
-import cn.yyxx.support.DensityUtils
-import cn.yyxx.support.ui.scaleprogress.ScaleLoadingView
-
-/**
- * @author #Suyghur.
- * Created on 2021/07/01
- */
-class ScaleLoadingDialog constructor(context: Context, desc: String) : Dialog(context), DialogInterface.OnKeyListener {
-
-    private lateinit var layout: LinearLayout
-
-    private var loadingView: ScaleLoadingView? = null
-
-    init {
-        setCanceledOnTouchOutside(false)
-        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
-        requestWindowFeature(Window.FEATURE_NO_TITLE)
-        initView(context, desc)
-    }
-
-    private fun initView(context: Context, desc: String) {
-        val attr = window?.attributes as WindowManager.LayoutParams
-        //设置dialog在布局中的位置
-        attr.gravity = Gravity.CENTER
-
-        val params = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
-        layout = LinearLayout(context)
-        layout.orientation = LinearLayout.VERTICAL
-
-        val viewSize = DensityUtils.dip2px(context, 60f)
-        val divideSize = DensityUtils.dip2px(context, 3f)
-        val count = 5
-        val startColor = Color.parseColor("#7EB944")
-        val endColor = Color.parseColor("#1DB1AD")
-        loadingView = ScaleLoadingView(context, viewSize, divideSize, count, startColor, endColor)
-        val loadingViewParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
-        loadingViewParams.gravity = Gravity.CENTER
-        layout.addView(loadingView, loadingViewParams)
-
-        if (!TextUtils.isEmpty(desc)) {
-            val textView = TextView(context)
-            textView.text = desc
-            textView.setTextColor(Color.WHITE)
-            val textViewParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
-            textViewParams.gravity = Gravity.CENTER
-            layout.addView(textView, textViewParams)
-        }
-
-        addContentView(layout, params)
-        setOnKeyListener(this)
-    }
-
-    override fun onKey(dialog: DialogInterface?, keyCode: Int, event: KeyEvent): Boolean {
-        return keyCode == KeyEvent.KEYCODE_BACK && event.repeatCount == 0
-    }
-}

+ 10 - 4
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/widget/dialog/TipsDialog.kt

@@ -7,6 +7,7 @@ import android.graphics.drawable.ColorDrawable
 import android.view.*
 import android.widget.Button
 import android.widget.TextView
+import cn.yyxx.support.DensityUtils
 import cn.yyxx.support.ResUtils
 
 /**
@@ -23,7 +24,7 @@ import cn.yyxx.support.ResUtils
  * @author #Suyghur.
  * Created on 2020/12/10
  */
-class TipsDialog(context: Context, doubleButton: Boolean) : Dialog(context) {
+class TipsDialog(context: Context,private val isLandscape:Boolean,private val doubleButton: Boolean) : Dialog(context) {
 
     lateinit var textView: TextView
         private set
@@ -36,15 +37,20 @@ class TipsDialog(context: Context, doubleButton: Boolean) : Dialog(context) {
         setCanceledOnTouchOutside(false)
         window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
         requestWindowFeature(Window.FEATURE_NO_TITLE)
-        initView(context, doubleButton)
+        initView()
     }
 
-    private fun initView(context: Context, doubleButton: Boolean) {
+    private fun initView() {
         val view = LayoutInflater.from(context).inflate(ResUtils.getResId(context, "yyxx_tips_dialog", "layout"), null)
         setContentView(view)
 
         val attr = window?.attributes as WindowManager.LayoutParams
-        //设置dialog在布局中的位置
+        attr.height = ViewGroup.LayoutParams.WRAP_CONTENT
+        if (isLandscape) {
+            attr.width = DensityUtils.getHeightAndWidth(context)[0] / 2
+        } else {
+            attr.width = DensityUtils.getHeightAndWidth(context)[0] - 80
+        }
         attr.gravity = Gravity.CENTER
 
         textView = view.findViewById(ResUtils.getResId(context, "yyxx_dialog_content", "id"))

+ 14 - 5
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/widget/floatview/FloatingBallMenu.kt

@@ -91,7 +91,7 @@ class FloatingBallMenu(val context: Context, private val callback: FloatingBallM
             when (item.type) {
                 FloatFeature.FEATURE_MEMBER -> {
                     if (TextUtils.isEmpty(item.iconUrl)) {
-                        ivIcon.setBackgroundResource(ResUtils.getResId(context, "yyxx_float_member_img", "drawable"))
+                        ivIcon.setImageResource(ResUtils.getResId(context, "yyxx_float_member_img", "drawable"))
                     } else {
                         val name = Md5Utils.encodeByMD5(item.iconUrl)
                         ivIcon.setImageBitmap(LocalCacheUtils.getLocalBitmap(context, name))
@@ -101,7 +101,7 @@ class FloatingBallMenu(val context: Context, private val callback: FloatingBallM
 
                 FloatFeature.FEATURE_GIF -> {
                     if (TextUtils.isEmpty(item.iconUrl)) {
-                        ivIcon.setBackgroundResource(ResUtils.getResId(context, "yyxx_float_gif_img", "drawable"))
+                        ivIcon.setImageResource(ResUtils.getResId(context, "yyxx_float_gif_img", "drawable"))
                     } else {
                         val name = Md5Utils.encodeByMD5(item.iconUrl)
                         ivIcon.setImageBitmap(LocalCacheUtils.getLocalBitmap(context, name))
@@ -111,7 +111,7 @@ class FloatingBallMenu(val context: Context, private val callback: FloatingBallM
 
                 FloatFeature.FEATURE_GM -> {
                     if (TextUtils.isEmpty(item.iconUrl)) {
-                        ivIcon.setBackgroundResource(ResUtils.getResId(context, "yyxx_float_gm_img", "drawable"))
+                        ivIcon.setImageResource(ResUtils.getResId(context, "yyxx_float_gm_img", "drawable"))
                     } else {
                         val name = Md5Utils.encodeByMD5(item.iconUrl)
                         ivIcon.setImageBitmap(LocalCacheUtils.getLocalBitmap(context, name))
@@ -121,7 +121,7 @@ class FloatingBallMenu(val context: Context, private val callback: FloatingBallM
 
                 FloatFeature.FEATURE_CHARGE -> {
                     if (TextUtils.isEmpty(item.iconUrl)) {
-                        ivIcon.setBackgroundResource(ResUtils.getResId(context, "yyxx_float_charge_img", "drawable"))
+                        ivIcon.setImageResource(ResUtils.getResId(context, "yyxx_float_charge_img", "drawable"))
                     } else {
                         val name = Md5Utils.encodeByMD5(item.iconUrl)
                         ivIcon.setImageBitmap(LocalCacheUtils.getLocalBitmap(context, name))
@@ -131,13 +131,22 @@ class FloatingBallMenu(val context: Context, private val callback: FloatingBallM
 
                 FloatFeature.FEATURE_INVITE -> {
                     if (TextUtils.isEmpty(item.iconUrl)) {
-                        ivIcon.setBackgroundResource(ResUtils.getResId(context, "yyxx_float_invite_img", "drawable"))
+                        ivIcon.setImageResource(ResUtils.getResId(context, "yyxx_float_invite_img", "drawable"))
                     } else {
                         val name = Md5Utils.encodeByMD5(item.iconUrl)
                         ivIcon.setImageBitmap(LocalCacheUtils.getLocalBitmap(context, name))
                     }
                     tvDesc.text = ResUtils.getResString(context, "yyxx_tv_float_invite_desc")
                 }
+                FloatFeature.FEATURE_LOGOUT -> {
+                    if (TextUtils.isEmpty(item.iconUrl)) {
+                        ivIcon.setImageResource(ResUtils.getResId(context, "yyxx_float_switch_img", "drawable"))
+                    } else {
+                        val name = Md5Utils.encodeByMD5(item.iconUrl)
+                        ivIcon.setImageBitmap(LocalCacheUtils.getLocalBitmap(context, name))
+                    }
+                    tvDesc.text = ResUtils.getResString(context, "yyxx_tv_float_switch_desc")
+                }
             }
             view.setOnClickListener {
                 callback.onMenuItemClick(item, position)

BIN
module_eyuan/library_eyuan/src/main/res/drawable-xhdpi/yyxx_float_logo_img.png


BIN
module_eyuan/library_eyuan/src/main/res/drawable-xhdpi/yyxx_float_logo_left_img.png


BIN
module_eyuan/library_eyuan/src/main/res/drawable-xhdpi/yyxx_float_logo_right_img.png


BIN
module_eyuan/library_eyuan/src/main/res/drawable-xhdpi/yyxx_float_switch_img.png


+ 1 - 1
module_eyuan/library_eyuan/src/main/res/layout/yyxx_floating_ball_item.xml

@@ -10,7 +10,7 @@
         android:id="@+id/yyxx_iv_icon"
         android:layout_width="20dp"
         android:layout_height="20dp"
-        android:background="@drawable/yyxx_float_logo_img" />
+        android:src="@drawable/yyxx_float_logo_img" />
 
     <TextView
         android:id="@+id/yyxx_tv_desc"

+ 1 - 3
module_eyuan/library_eyuan/src/main/res/layout/yyxx_tips_dialog.xml

@@ -1,9 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="350dp"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_marginLeft="10dp"
-    android:layout_marginRight="10dp"
     android:background="@drawable/yyxx_white_panel_bg"
     android:gravity="center"
     android:orientation="vertical">

+ 1 - 5
module_eyuan/library_hk_language/src/main/res/values/yyxx_strings.xml

@@ -6,11 +6,6 @@
         <item>註冊</item>
     </string-array>
 
-    <!--    <string-array name="yyxx_forget_pwd_tab">-->
-    <!--        <item>通過手機門號找回</item>-->
-    <!--        <item>通過電子郵件找回</item>-->
-    <!--    </string-array>-->
-
     <string name="yyxx_login_tab_launcher">登入</string>
     <string name="yyxx_login_tab_register">註冊</string>
 
@@ -55,6 +50,7 @@
     <string name="yyxx_tv_float_gm_desc">客服</string>
     <string name="yyxx_tv_float_charge_desc">儲值</string>
     <string name="yyxx_tv_float_invite_desc">邀請好友</string>
+    <string name="yyxx_tv_float_switch_desc">切換</string>
 
     <string name="yyxx_title_forget">忘記密碼</string>
     <string name="yyxx_title_agreement">會員條款及管理規章</string>

+ 1 - 1
module_eyuan/library_vn_language/src/main/res/values/yyxx_strings.xml

@@ -54,7 +54,7 @@
     <string name="yyxx_tv_float_gm_desc">CSKH</string>
     <string name="yyxx_tv_float_charge_desc">Nạp</string>
     <string name="yyxx_tv_float_invite_desc">Mời Bạn Bè</string>
-
+    <string name="yyxx_tv_float_switch_desc">Chuyển đổi</string>
 
     <string name="yyxx_title_forget">Quên Mật Khẩu</string>
     <string name="yyxx_title_agreement">Điều Khoản Sử Dụng</string>