Skip to content

Commit

Permalink
[feat] 添加英文支持,使用智障ai
Browse files Browse the repository at this point in the history
  • Loading branch information
vitvm committed Jan 5, 2025
1 parent 1f16949 commit c63cd1b
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 3 deletions.
24 changes: 21 additions & 3 deletions app/src/main/java/com/pic/catcher/config/AppConfigUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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有时候不行
Expand All @@ -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))
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/pic/catcher/util/LanguageUtil.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
24 changes: 24 additions & 0 deletions app/src/main/res/raw/app_config_en.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
27 changes: 27 additions & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<resources>
<string name="app_name">Picture Catcher</string>
<string name="app_xposed_description">App Image Grabber</string>
<string name="module_not_active">Module Not Active</string>
<string name="module_have_active">Module Active</string>
<string name="module_version">Module Version</string>
<string name="donate">Donate</string>
<string name="app_use_help">Usage Instructions</string>
<string name="click_here_to_des">Click here to view usage instructions</string>
<string name="donate_description">Your support means a lot to us</string>
<string name="app_update_not_tip">Do not show again</string>
<string name="app_update_dialog_title">Update Notification</string>
<string name="app_update_confirm_tip_format">New version detected: %s, would you like to update?</string>
<string name="app_toast_open_download_url_fail">Failed to open download link</string>
<string name="app_update_not_found">No new version detected</string>
<string name="app_module_des_format">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.</string>
<string name="app_code_branch">Code Branch: %s</string>
<string name="app_commit_hash_format">Commit Hash: %s</string>
<string name="app_build_time_format">Build Time: %s</string>
<string name="app_config">App Configuration</string>
<string name="click_here_to_edit_config">Click here to edit configuration</string>
<string name="app_title_config">Configuration</string>
<string name="config_catch_net_pic">Catch Network Images</string>
<string name="config_min_space_size">Image size not less than (unit/kb)</string>
<string name="config_catch_webview_pic">Catch WebView Images</string>
<string name="config_catch_glide_pic">Catch Glide Framework Images</string>
</resources>

0 comments on commit c63cd1b

Please sign in to comment.