diff --git a/V2rayNG/app/src/main/assets/custom_routing_block b/V2rayNG/app/src/main/assets/custom_routing_block deleted file mode 100644 index a6ebf394..00000000 --- a/V2rayNG/app/src/main/assets/custom_routing_block +++ /dev/null @@ -1 +0,0 @@ -geosite:category-ads-all, \ No newline at end of file diff --git a/V2rayNG/app/src/main/assets/custom_routing_direct b/V2rayNG/app/src/main/assets/custom_routing_direct deleted file mode 100644 index 083428bf..00000000 --- a/V2rayNG/app/src/main/assets/custom_routing_direct +++ /dev/null @@ -1 +0,0 @@ -geosite:cn \ No newline at end of file diff --git a/V2rayNG/app/src/main/assets/custom_routing_proxy b/V2rayNG/app/src/main/assets/custom_routing_proxy deleted file mode 100644 index 618b1401..00000000 --- a/V2rayNG/app/src/main/assets/custom_routing_proxy +++ /dev/null @@ -1 +0,0 @@ -geosite:geolocation-!cn \ No newline at end of file diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingSettingActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingSettingActivity.kt index 22eb5de3..13d0cb71 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingSettingActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingSettingActivity.kt @@ -29,6 +29,9 @@ class RoutingSettingActivity : BaseActivity() { private val routing_domain_strategy: Array by lazy { resources.getStringArray(R.array.routing_domain_strategy) } + private val preset_rulesets: Array by lazy { + resources.getStringArray(R.array.preset_rulesets) + } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -76,13 +79,21 @@ class RoutingSettingActivity : BaseActivity() { R.id.import_rulesets -> { AlertDialog.Builder(this).setMessage(R.string.routing_settings_import_rulesets_tip) .setPositiveButton(android.R.string.ok) { _, _ -> - lifecycleScope.launch(Dispatchers.IO) { - SettingsManager.resetRoutingRulesets(this@RoutingSettingActivity) - launch(Dispatchers.Main) { - refreshData() - toast(R.string.toast_success) + AlertDialog.Builder(this).setItems(preset_rulesets.asList().toTypedArray()) { _, i -> + try { + lifecycleScope.launch(Dispatchers.IO) { + SettingsManager.resetRoutingRulesets(this@RoutingSettingActivity, i) + launch(Dispatchers.Main) { + refreshData() + toast(R.string.toast_success) + } + } + } catch (e: Exception) { + e.printStackTrace() } - } + }.show() + + } .setNegativeButton(android.R.string.no) { _, _ -> //do noting diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/SettingsManager.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/SettingsManager.kt index c05422bb..c6489db4 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/SettingsManager.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/SettingsManager.kt @@ -2,32 +2,34 @@ package com.v2ray.ang.util import android.content.Context import android.text.TextUtils -import android.util.Log import com.google.gson.Gson import com.v2ray.ang.dto.RulesetItem object SettingsManager { - fun initRoutingRulesets(context: Context) { - Log.d("=====", "initRoutingRuleset") + fun initRoutingRulesets(context: Context, index: Int = 0) { val exist = MmkvManager.decodeRoutingRulesets() + val fileName = when (index) { + 0 -> "custom_routing_white" + 1 -> "custom_routing_black" + 2 -> "custom_routing_global" + else -> "custom_routing_white" + } if (exist.isNullOrEmpty()) { - Log.d("=====", "isNullOrEmpty") - val assets = Utils.readTextFromAssets(context, "custom_routing_white") + val assets = Utils.readTextFromAssets(context, fileName) if (TextUtils.isEmpty(assets)) { return } val rulesetList = Gson().fromJson(assets, Array::class.java).toMutableList() - Log.d("=====", "rulesetList==" + rulesetList.count()) MmkvManager.encodeRoutingRulesets(rulesetList) } } - fun resetRoutingRulesets(context: Context) { + fun resetRoutingRulesets(context: Context, index: Int) { MmkvManager.encodeRoutingRulesets(null) - initRoutingRulesets(context) + initRoutingRulesets(context, index) } fun getRoutingRuleset(index: Int): RulesetItem? { diff --git a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml index f3d12d6c..6b41cc65 100644 --- a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml @@ -294,4 +294,10 @@ 深色 + + 绕过大陆(Whitelist) + 黑名单(Blacklist) + 全局(Global) + + diff --git a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml index c80ed2c1..d408e904 100644 --- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml @@ -295,4 +295,10 @@ 深色 + + 繞過大陸(Whitelist) + 黑名單(Blacklist) + 全域(Global) + + diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index fae291f1..060d10f8 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -306,4 +306,10 @@ Dark + + China Whitelist + China Blacklist + Global + +