Explorar o código

feat: 简繁中文上报

tongmengxiao hai 6 meses
pai
achega
5ba12cb55e

+ 2 - 0
baseswago/src/main/java/com/swago/baseswago/http/SwagoInterceptor.kt

@@ -8,6 +8,7 @@ import com.swago.baseswago.util.UserInfo.getLoginModel
 import okhttp3.Interceptor
 import okhttp3.Request
 import okhttp3.Response
+import java.net.URLEncoder
 import java.util.*
 
 /**
@@ -55,6 +56,7 @@ class SwagoInterceptor : Interceptor {
             .addHeader("app-secret", secret)
             .addHeader("app-client-device-id",SwagoInfo.getIMEI())
             .addHeader("app-os",SwagoInfo.getAndroidOS())
+            .addHeader("app-client-operate" , URLEncoder.encode(SwagoInfo.getNetworkOperatorName(),"utf-8"))
             .build()
         return chain.proceed(finalRequest)
     }

+ 20 - 1
baseswago/src/main/java/com/swago/baseswago/util/SwagoInfo.kt

@@ -1,7 +1,9 @@
 package com.swago.baseswago.util
 
 import android.Manifest
+import android.content.Context
 import android.os.Build
+import android.telephony.TelephonyManager
 import android.text.TextUtils
 import com.permissionx.guolindev.PermissionX
 import java.io.*
@@ -44,7 +46,17 @@ object SwagoInfo {
                 languageId = 5
             }
             "zh" -> {
-                languageCode = "zh"
+                val country = Locale.getDefault().country
+                languageCode = when(country){
+                    "CN" ->{
+                        "zh-t"
+                    }
+
+                    else ->{
+                        "zh"
+                    }
+                }
+
                 languageId = 1
             }
             else -> {
@@ -99,6 +111,13 @@ object SwagoInfo {
         return "Android ${Build.VERSION.RELEASE}"
     }
 
+    fun getNetworkOperatorName(): String {
+        val context = AppContext.getContext()
+        val telephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
+        val networkOperatorName = telephonyManager.networkOperatorName
+        return networkOperatorName
+    }
+
     private fun getUniqueDeviceId():String{
         if (PermissionX.isGranted(AppContext.getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)){
            if (AppContext.getContext().getExternalFilesDir(null) == null){