diff --git a/app/src/main/java/com/pic/catcher/config/AppConfigUtil.kt b/app/src/main/java/com/pic/catcher/config/AppConfigUtil.kt index d0ab52f..21a3da2 100644 --- a/app/src/main/java/com/pic/catcher/config/AppConfigUtil.kt +++ b/app/src/main/java/com/pic/catcher/config/AppConfigUtil.kt @@ -4,15 +4,28 @@ import android.net.Uri import com.lu.magic.util.AppUtil import com.lu.magic.util.log.LogUtil import com.pic.catcher.R +import com.pic.catcher.util.LanguageUtil import com.pic.catcher.util.TimeExpiredCalculator import com.pic.catcher.util.http.HttpConnectUtil import org.json.JSONArray import org.json.JSONObject import java.io.File +import java.io.InputStream class AppConfigUtil { companion object { - private val configFilePath = "res/raw/app_config.json" + private val configFilePath_zh = "res/raw/app_config.json" + private val configFilePath_en = "res/raw/app_config_en.json" + private var configFilePath = configFilePath_zh + get() { + LogUtil.d("configFilePath: $field isEnglish", LanguageUtil.isEnglish()) + if (LanguageUtil.isEnglish()) { + return configFilePath_en + } + return configFilePath_zh + + } + val githubMainUrl = "https://raw.githubusercontent.com/Mingyueyixi/PicCatcher/main" //@main分支 或者@v1.6, commit id之类的,直接在写/main有时候不行 @@ -27,12 +40,17 @@ class AppConfigUtil { load() checkRemoteUpdate() } - + private fun openAppConfigFromRawResource(): InputStream { + if (LanguageUtil.isEnglish()) { + return AppUtil.getContext().resources.openRawResource(R.raw.app_config_en) + } + return AppUtil.getContext().resources.openRawResource(R.raw.app_config) + } fun load() { val file = getLocalFile(configFilePath) var rawBin: ByteArray - val rawConfig: JSONObject = AppUtil.getContext().resources.openRawResource(R.raw.app_config).use { + val rawConfig: JSONObject = openAppConfigFromRawResource().use { rawBin = it.readBytes() JSONObject(rawBin.toString(Charsets.UTF_8)) } diff --git a/app/src/main/java/com/pic/catcher/util/LanguageUtil.java b/app/src/main/java/com/pic/catcher/util/LanguageUtil.java new file mode 100644 index 0000000..2c880a3 --- /dev/null +++ b/app/src/main/java/com/pic/catcher/util/LanguageUtil.java @@ -0,0 +1,13 @@ +package com.pic.catcher.util; + +/** + * @author Lu + * @date 2025/1/6 0:47 + * @description + */ +public class LanguageUtil { + public static boolean isEnglish() { + // 获取当前设备的语言设置 + return "en".equals(java.util.Locale.getDefault().getLanguage()); + } +} diff --git a/app/src/main/res/raw/app_config_en.json b/app/src/main/res/raw/app_config_en.json new file mode 100644 index 0000000..48c6d96 --- /dev/null +++ b/app/src/main/res/raw/app_config_en.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "mainUi": { + "menuList": [ + { + "title": "Feedback", + "link": "https://github.com/Mingyueyixi/PicCatcher/issues" + }, + { + "title": "Communication Group", + "link": "https://t.me/MaskWechatX", + "appLink": { + "links": [ + "tg:resolve?domain=MaskWechatX" + ] + } + }, + { + "title": "About", + "link": "https://github.com/Mingyueyixi/PicCatcher" + } + ] + } +} \ No newline at end of file diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml new file mode 100644 index 0000000..ebc4feb --- /dev/null +++ b/app/src/main/res/values-en/strings.xml @@ -0,0 +1,27 @@ + + Picture Catcher + App Image Grabber + Module Not Active + Module Active + Module Version + Donate + Usage Instructions + Click here to view usage instructions + Your support means a lot to us + Do not show again + Update Notification + New version detected: %s, would you like to update? + Failed to open download link + No new version detected + This module will grab images from the target app and save them to \"%1$s/app_package_name\". Please make sure to disable the LSP Manager option when not in use to avoid continuous image grabbing, which may affect app performance. + Code Branch: %s + Commit Hash: %s + Build Time: %s + App Configuration + Click here to edit configuration + Configuration + Catch Network Images + Image size not less than (unit/kb) + Catch WebView Images + Catch Glide Framework Images + \ No newline at end of file