Browse Source

处理语言

wbspool 1 year ago
parent
commit
565b06b38b
33 changed files with 415 additions and 29 deletions
  1. 179 0
      BusinessAirFryer/src/main/assets/lang_config.json
  2. 179 0
      BusinessAirFryer/src/main/assets/lang_config_036.json
  3. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_ar.png
  4. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_cz.png
  5. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_de.png
  6. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_dk.png
  7. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_ee.png
  8. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_en.png
  9. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_es.png
  10. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_fi.png
  11. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_fr.png
  12. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_gr.png
  13. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_ir.png
  14. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_it.png
  15. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_ja.png
  16. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_kz.png
  17. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_lt.png
  18. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_nl.png
  19. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_no.png
  20. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_pl.png
  21. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_pt.png
  22. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_ro.png
  23. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_ru.png
  24. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_se.png
  25. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_sk.png
  26. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_uk.png
  27. BIN
      BusinessAirFryer/src/main/res/drawable/icon_lang_zh.png
  28. 8 0
      BusinessCommon/src/main/java/com/develop/common/data_repo/db/DataFactory.kt
  29. 35 0
      BusinessCommon/src/main/java/com/develop/common/utils/ConfigUtils.kt
  30. 6 5
      BusinessSetting/src/main/java/com/develop/setting/ui/LanguageActivity.kt
  31. 3 1
      app/build.gradle
  32. 2 2
      app/src/main/AndroidManifest.xml
  33. 3 21
      libBase/src/main/java/com/develop/base/ext/GlobaExt.kt

+ 179 - 0
BusinessAirFryer/src/main/assets/lang_config.json

@@ -0,0 +1,179 @@
+{
+  "langs": [
+    {
+      "name": "Polish(波兰语)",
+      "value": "PL",
+      "icon": "icon_lang_pl",
+      "showName": "Polski",
+      "show": false
+    },
+    {
+      "name": "German(德语)",
+      "value": "DE",
+      "icon": "icon_lang_de",
+      "showName": "Deutsch",
+      "show": false
+    },
+    {
+      "name": "French(法语)",
+      "value": "FR",
+      "icon": "icon_lang_fr",
+      "showName": "Français",
+      "show": false
+    },
+    {
+      "name": "Dutch(荷兰语)",
+      "value": "NL",
+      "icon": "icon_lang_nl",
+      "showName": "Nederlands",
+      "show": false
+    },
+    {
+      "name": "Portuguese(葡萄牙语)",
+      "value": "PT",
+      "icon": "icon_lang_pt",
+      "showName": "Português",
+      "show": false
+    },
+    {
+      "name": "Spanish(西班牙语)",
+      "value": "ES",
+      "icon": "icon_lang_es",
+      "showName": "Español",
+      "show": false
+    },
+    {
+      "name": "Italiano(意大利语)",
+      "value": "IT",
+      "icon": "icon_lang_it",
+      "showName": "Italiano",
+      "show": false
+    },
+    {
+      "name": "English(英语)",
+      "value": "EN",
+      "icon": "icon_lang_en",
+      "showName": "English",
+      "show": true
+    },
+    {
+      "name": "Greek(希腊语)",
+      "value": "GR",
+      "icon": "icon_lang_gr",
+      "showName": "Ελληνικά",
+      "show": false
+    },
+    {
+      "name": "Russian(俄语)",
+      "value": "RU",
+      "icon": "icon_lang_ru",
+      "showName": "Русский",
+      "show": true
+    },
+    {
+      "name": "Romanian(罗马尼亚语)",
+      "value": "RO",
+      "icon": "icon_lang_ro",
+      "showName": "Română",
+      "show": false
+    },
+    {
+      "name": "Finnish(芬兰语)",
+      "value": "FI",
+      "icon": "icon_lang_fi",
+      "showName": "Suomi",
+      "show": false
+    },
+    {
+      "name": "Norsk(挪威语)",
+      "value": "NO",
+      "icon": "icon_lang_no",
+      "showName": "Norsk",
+      "show": false
+    },
+    {
+      "name": "Swedish(瑞典语)",
+      "value": "SE",
+      "icon": "icon_lang_se",
+      "showName": "Svenska",
+      "show": false
+    },
+    {
+      "name": "Danish(丹麦语)",
+      "value": "DK",
+      "icon": "icon_lang_dk",
+      "showName": "Dansk",
+      "show": false
+    },
+    {
+      "name": "Czech(捷克语)",
+      "value": "CZ",
+      "icon": "icon_lang_cz",
+      "showName": "Čeština",
+      "show": false
+    },
+    {
+      "name": "Estonki(爱沙尼亚语)",
+      "value": "EE",
+      "icon": "icon_lang_ee",
+      "showName": "Eesti keel",
+      "show": false
+    },
+    {
+      "name": "Slovak(斯洛伐克语)",
+      "value": "SK",
+      "icon": "icon_lang_sk",
+      "showName": "Slovenčina",
+      "show": false
+    },
+    {
+      "name": "Ukrainian(乌克兰语)",
+      "value": "UK",
+      "icon": "icon_lang_uk",
+      "showName": "Українська",
+      "show": false
+    },
+    {
+      "name": "Arabic(阿拉伯语)",
+      "value": "AR",
+      "icon": "icon_lang_ar",
+      "showName": "العربية",
+      "show": false
+    },
+    {
+      "name": "Lithuanian(立陶宛语)",
+      "value": "LT",
+      "icon": "icon_lang_lt",
+      "showName": "Lietuvių kalba",
+      "show": false
+    },
+    {
+      "name": "Farsi(波斯语)",
+      "value": "IR",
+      "icon": "icon_lang_ir",
+      "showName": "فارسی",
+      "show": false
+    },
+    {
+      "name": "Kazakh(哈萨克语)",
+      "value": "KZ",
+      "icon": "icon_lang_kz",
+      "showName": "Қазақша",
+      "show": false
+    },
+    {
+      "name": "Chinese(中文)",
+      "value": "ZH",
+      "icon": "icon_lang_zh",
+      "showName": "中文",
+      "show": false
+    },
+    {
+      "name": "Japanese(日语)",
+      "value": "JA",
+      "icon": "icon_lang_ja",
+      "showName": "日本語",
+      "show": false
+    }
+  ]
+}

+ 179 - 0
BusinessAirFryer/src/main/assets/lang_config_036.json

@@ -0,0 +1,179 @@
+{
+  "langs": [
+    {
+      "name": "Polish(波兰语)",
+      "value": "PL",
+      "icon": "icon_lang_pl",
+      "showName": "Polski",
+      "show": false
+    },
+    {
+      "name": "German(德语)",
+      "value": "DE",
+      "icon": "icon_lang_de",
+      "showName": "Deutsch",
+      "show": false
+    },
+    {
+      "name": "French(法语)",
+      "value": "FR",
+      "icon": "icon_lang_fr",
+      "showName": "Français",
+      "show": true
+    },
+    {
+      "name": "Dutch(荷兰语)",
+      "value": "NL",
+      "icon": "icon_lang_nl",
+      "showName": "Nederlands",
+      "show": false
+    },
+    {
+      "name": "Portuguese(葡萄牙语)",
+      "value": "PT",
+      "icon": "icon_lang_pt",
+      "showName": "Português",
+      "show": false
+    },
+    {
+      "name": "Spanish(西班牙语)",
+      "value": "ES",
+      "icon": "icon_lang_es",
+      "showName": "Español",
+      "show": false
+    },
+    {
+      "name": "Italiano(意大利语)",
+      "value": "IT",
+      "icon": "icon_lang_it",
+      "showName": "Italiano",
+      "show": false
+    },
+    {
+      "name": "English(英语)",
+      "value": "EN",
+      "icon": "icon_lang_en",
+      "showName": "English",
+      "show": false
+    },
+    {
+      "name": "Greek(希腊语)",
+      "value": "GR",
+      "icon": "icon_lang_gr",
+      "showName": "Ελληνικά",
+      "show": false
+    },
+    {
+      "name": "Russian(俄语)",
+      "value": "RU",
+      "icon": "icon_lang_ru",
+      "showName": "Русский",
+      "show": false
+    },
+    {
+      "name": "Romanian(罗马尼亚语)",
+      "value": "RO",
+      "icon": "icon_lang_ro",
+      "showName": "Română",
+      "show": false
+    },
+    {
+      "name": "Finnish(芬兰语)",
+      "value": "FI",
+      "icon": "icon_lang_fi",
+      "showName": "Suomi",
+      "show": false
+    },
+    {
+      "name": "Norsk(挪威语)",
+      "value": "NO",
+      "icon": "icon_lang_no",
+      "showName": "Norsk",
+      "show": false
+    },
+    {
+      "name": "Swedish(瑞典语)",
+      "value": "SE",
+      "icon": "icon_lang_se",
+      "showName": "Svenska",
+      "show": false
+    },
+    {
+      "name": "Danish(丹麦语)",
+      "value": "DK",
+      "icon": "icon_lang_dk",
+      "showName": "Dansk",
+      "show": false
+    },
+    {
+      "name": "Czech(捷克语)",
+      "value": "CZ",
+      "icon": "icon_lang_cz",
+      "showName": "Čeština",
+      "show": false
+    },
+    {
+      "name": "Estonki(爱沙尼亚语)",
+      "value": "EE",
+      "icon": "icon_lang_ee",
+      "showName": "Eesti keel",
+      "show": false
+    },
+    {
+      "name": "Slovak(斯洛伐克语)",
+      "value": "SK",
+      "icon": "icon_lang_sk",
+      "showName": "Slovenčina",
+      "show": false
+    },
+    {
+      "name": "Ukrainian(乌克兰语)",
+      "value": "UK",
+      "icon": "icon_lang_uk",
+      "showName": "Українська",
+      "show": false
+    },
+    {
+      "name": "Arabic(阿拉伯语)",
+      "value": "AR",
+      "icon": "icon_lang_ar",
+      "showName": "العربية",
+      "show": false
+    },
+    {
+      "name": "Lithuanian(立陶宛语)",
+      "value": "LT",
+      "icon": "icon_lang_lt",
+      "showName": "Lietuvių kalba",
+      "show": false
+    },
+    {
+      "name": "Farsi(波斯语)",
+      "value": "IR",
+      "icon": "icon_lang_ir",
+      "showName": "فارسی",
+      "show": false
+    },
+    {
+      "name": "Kazakh(哈萨克语)",
+      "value": "KZ",
+      "icon": "icon_lang_kz",
+      "showName": "Қазақша",
+      "show": false
+    },
+    {
+      "name": "Chinese(中文)",
+      "value": "ZH",
+      "icon": "icon_lang_zh",
+      "showName": "中文",
+      "show": false
+    },
+    {
+      "name": "Japanese(日语)",
+      "value": "JA",
+      "icon": "icon_lang_ja",
+      "showName": "日本語",
+      "show": false
+    }
+  ]
+}

BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_ar.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_cz.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_de.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_dk.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_ee.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_en.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_es.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_fi.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_fr.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_gr.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_ir.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_it.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_ja.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_kz.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_lt.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_nl.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_no.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_pl.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_pt.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_ro.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_ru.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_se.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_sk.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_uk.png


BIN
BusinessAirFryer/src/main/res/drawable/icon_lang_zh.png


+ 8 - 0
BusinessCommon/src/main/java/com/develop/common/data_repo/db/DataFactory.kt

@@ -7,16 +7,24 @@ import com.develop.base.util.MMkvUtils
 import com.develop.common.R
 import com.develop.common.data_repo.db.entity.DevRecipe
 import com.develop.common.data_repo.db.entity.UserFavoriteRecipes
+import com.develop.common.utils.ConfigUtils
 import com.develop.common.widget.EntranceData
 import com.develop.common.widget.EntranceType
 import com.drake.brv.item.ItemHover
 import com.google.gson.Gson
 import com.google.gson.reflect.TypeToken
 import java.lang.reflect.Type
+import java.util.*
+import kotlin.Comparator
 
 
 object DataFactory {
 
+
+    fun createLanguageDataV2(resource: Resources): List<ConfigUtils.Lang> {
+        return ConfigUtils.loadLangConfig()?.langs?.filter {  it.show == true } ?: Collections.emptyList();
+    }
+
     fun createLanguageData(resource: Resources): MutableList<LanguageModel> {
         val languageList = mutableListOf<LanguageModel>()
         val strList = if (isNightTheme()|| isBrand036I()) {

+ 35 - 0
BusinessCommon/src/main/java/com/develop/common/utils/ConfigUtils.kt

@@ -14,6 +14,11 @@ import java.nio.charset.Charset
 object ConfigUtils {
 
 
+    data class Lang(val name: String?, val value: String, val icon: String?,val show:Boolean?,val showName:String)
+
+    data class LangConfig(var langs: ArrayList<Lang>)
+
+
     fun loadConfig(): CfConfig? {
         return try {
             var sn = getSN()
@@ -43,6 +48,36 @@ object ConfigUtils {
         }
     }
 
+
+    fun loadLangConfig(): LangConfig? {
+        return try {
+
+            var sn = getSN()
+            var brandNum = sn.substring(0,3)
+
+            val fileList = GlobalApp().assets.list("") ?: arrayOf()
+            var inputStream: InputStream? = null
+            if(fileList.contains("config_${brandNum}.json")){
+                inputStream = GlobalApp().assets.open("lang_config_${brandNum}.json")
+            }else{
+                inputStream = GlobalApp().assets.open("lang_config.json")
+            }
+
+            val size = inputStream.available()
+            val buffer = ByteArray(size)
+            inputStream.read(buffer)
+            inputStream.close()
+
+            val jsonString = String(buffer, Charset.defaultCharset())
+            val gson = Gson()
+            val cfConfig = gson.fromJson(jsonString, LangConfig::class.java)
+            return cfConfig
+        } catch (ex: IOException) {
+            ex.printStackTrace()
+            null
+        }
+    }
+
     fun getMode(type: String): WorkMode? {
         return loadConfig()?.workModes?.find { it.type == type }?.copy()
     }

+ 6 - 5
BusinessSetting/src/main/java/com/develop/setting/ui/LanguageActivity.kt

@@ -24,6 +24,7 @@ import com.develop.common.event.FinishAtyEvent
 import com.develop.common.router.Screens
 import com.develop.common.tag.*
 import com.develop.common.dialog.CancelConfirmDialog
+import com.develop.common.utils.ConfigUtils
 import com.develop.setting.R
 import com.develop.setting.databinding.ActivityLanguageBinding
 import com.drake.brv.utils.bindingAdapter
@@ -79,7 +80,7 @@ class LanguageActivity : BaseBindingActivity<ActivityLanguageBinding>() {
         binding.languageRecycle.apply {
             linear()
             setup {
-                addType<LanguageModel>(R.layout.item_language_view)
+                addType<ConfigUtils.Lang>(R.layout.item_language_view)
                 onBind {
                     val ivIcon = findView<ImageView>(R.id.ic_icon)
                     val tvTitle = findView<AppCompatTextView>(R.id.tv_title)
@@ -91,15 +92,15 @@ class LanguageActivity : BaseBindingActivity<ActivityLanguageBinding>() {
                         tvTitle.setTextColor(context.resources.getColor(com.develop.common.R.color.color_1A1A1A))
                         cardView.setBackgroundResource(com.develop.common.R.drawable.shape_44pxffffff_stoke)
                     }
-                    val model = getModel<LanguageModel>()
-                    ivIcon.load(model.icon)
-                    tvTitle.updateText(model.languageName)
+                    val model = getModel<ConfigUtils.Lang>()
+                    ivIcon.load(context.resources.getIdentifier(model.icon,"drawable","com.develop.foodcooking"))
+                    model.showName?.let { it1 -> tvTitle.updateText(it1) }
                 }
                 R.id.content_layout.onClick {
                     updateSelectionPos(absoluteAdapterPosition)
                 }
             }
-        }.models = DataFactory.createLanguageData(resources)
+        }.models = DataFactory.createLanguageDataV2(resources)
 
         selectedPosition = getSelectedPos()
 

+ 3 - 1
app/build.gradle

@@ -58,19 +58,21 @@ android {
             dimension "platform"
             applicationId "com.develop.foodcooking"
             buildConfigField("String", "UpdatePlatform", "\"night\"")
-
+            resValue("string", "app_theme", "@style/SplashNightTheme")
         }
 
         brand030A {
             dimension "platform"
             applicationId "com.develop.foodcooking"
             buildConfigField("String", "UpdatePlatform", "\"normal\"")
+            resValue("string", "app_theme", "@style/SplashTheme")
         }
 
         brand036I {
             dimension "platform"
             applicationId "com.develop.foodcooking"
             buildConfigField("String", "UpdatePlatform", "\"036I\"")
+            resValue("string", "app_theme", "@style/Splash036IDTheme")
         }
 
     }

+ 2 - 2
app/src/main/AndroidManifest.xml

@@ -42,14 +42,14 @@
         android:requestLegacyExternalStorage="true"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
-        android:theme="@style/Splash036IDTheme"
+        android:theme="@string/app_theme"
         android:largeHeap="true"
         tools:targetApi="31">
         <activity
             android:screenOrientation="landscape"
             android:name=".MainActivity"
             android:exported="true"
-            android:theme="@style/Splash036IDTheme">
+            android:theme="@string/app_theme">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.HOME" />

+ 3 - 21
libBase/src/main/java/com/develop/base/ext/GlobaExt.kt

@@ -188,26 +188,8 @@ fun getBrandNum(): String {
  */
 fun getSN(): String {
     var serial: String
-//    //通过android.os获取sn号
-////    val append = "03403015"
-//    var append = "01703015"
-//    val plInfo = GlobalApp().applicationContext.packageManager.getPackageInfo(
-//        GlobalApp().applicationContext.packageName,
-//        PackageManager.GET_META_DATA
-//    )
-//    var vi = plInfo.versionName.split(".");
-//    append = (vi[1] + vi[0])
-//    try {
-//        serial = getWifiMacAddress(globalApp().applicationContext).uppercase()
-//        return if (serial != "" && serial != "unknown") "${append}${
-//            serial.replace3
-//                ":",
-//                ""
-//            )
-//        }" else "${append}8888"
-//    } catch (e: java.lang.Exception) {
-//        serial = "${append}8888"
-//    }
+
+    return "036I21060020123010190001"
 
     //通过反射获取sn号
     try {
@@ -221,7 +203,7 @@ fun getSN(): String {
     } catch (e: java.lang.Exception) {
         serial = "unknown"
     }
-    return serial
+    return "036I21060020123010190001"
 }
 
 fun ImageView.load(data: Any?) {