mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-22 05:16:08 +03:00
feat: add some override options about sniffing
This commit is contained in:
parent
e47dca02cf
commit
a58af39fae
@ -2,7 +2,6 @@ package com.github.kr328.clash
|
||||
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.OpenableColumns
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
@ -13,7 +12,6 @@ import com.github.kr328.clash.util.withClash
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.selects.select
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
@ -58,19 +56,19 @@ class MetaFeatureSettingsActivity : BaseActivity<MetaFeatureSettingsDesign>() {
|
||||
val uri = startActivityForResult(
|
||||
ActivityResultContracts.GetContent(),
|
||||
"*/*")
|
||||
geoFilesImported(uri, MetaFeatureSettingsDesign.Request.ImportGeoIp)
|
||||
importGeoFile(uri, MetaFeatureSettingsDesign.Request.ImportGeoIp)
|
||||
}
|
||||
MetaFeatureSettingsDesign.Request.ImportGeoSite -> {
|
||||
val uri = startActivityForResult(
|
||||
ActivityResultContracts.GetContent(),
|
||||
"*/*")
|
||||
geoFilesImported(uri, MetaFeatureSettingsDesign.Request.ImportGeoSite)
|
||||
importGeoFile(uri, MetaFeatureSettingsDesign.Request.ImportGeoSite)
|
||||
}
|
||||
MetaFeatureSettingsDesign.Request.ImportCountry -> {
|
||||
val uri = startActivityForResult(
|
||||
ActivityResultContracts.GetContent(),
|
||||
"*/*")
|
||||
geoFilesImported(uri, MetaFeatureSettingsDesign.Request.ImportCountry)
|
||||
importGeoFile(uri, MetaFeatureSettingsDesign.Request.ImportCountry)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,7 +80,7 @@ class MetaFeatureSettingsActivity : BaseActivity<MetaFeatureSettingsDesign>() {
|
||||
".metadb", ".db", ".dat", ".mmdb"
|
||||
)
|
||||
|
||||
private suspend fun geoFilesImported(uri: Uri?, importType: MetaFeatureSettingsDesign.Request) {
|
||||
private suspend fun importGeoFile(uri: Uri?, importType: MetaFeatureSettingsDesign.Request) {
|
||||
val cursor: Cursor? = uri?.let {
|
||||
contentResolver.query(it, null, null, null, null, null)
|
||||
}
|
||||
|
@ -159,6 +159,15 @@ data class ConfigurationOverride(
|
||||
@SerialName("sniffing")
|
||||
var sniffing: List<String>? = null,
|
||||
|
||||
@SerialName("force-dns-mapping")
|
||||
var forceDnsMapping: Boolean? = null,
|
||||
|
||||
@SerialName("parse-pure-ip")
|
||||
var parsePureIp: Boolean? = null,
|
||||
|
||||
@SerialName("override-destination")
|
||||
var overrideDestination: Boolean? = null,
|
||||
|
||||
@SerialName("force-domain")
|
||||
var forceDomain: List<String>? = null,
|
||||
|
||||
|
@ -117,9 +117,9 @@ class MetaFeatureSettingsDesign(
|
||||
false
|
||||
),
|
||||
valuesText = arrayOf(
|
||||
R.string.sniffer_config,
|
||||
R.string.sniffer_override,
|
||||
R.string.disable_sniffer,
|
||||
R.string.dont_modify,
|
||||
R.string.enabled,
|
||||
R.string.disabled
|
||||
),
|
||||
title = R.string.strategy
|
||||
) {
|
||||
@ -144,6 +144,30 @@ class MetaFeatureSettingsDesign(
|
||||
configure = snifferDependencies::add,
|
||||
)
|
||||
|
||||
selectableList(
|
||||
value = configuration.sniffer::forceDnsMapping,
|
||||
values = booleanValues,
|
||||
valuesText = booleanValuesText,
|
||||
title = R.string.force_dns_mapping,
|
||||
configure = snifferDependencies::add,
|
||||
)
|
||||
|
||||
selectableList(
|
||||
value = configuration.sniffer::parsePureIp,
|
||||
values = booleanValues,
|
||||
valuesText = booleanValuesText,
|
||||
title = R.string.parse_pure_ip,
|
||||
configure = snifferDependencies::add,
|
||||
)
|
||||
|
||||
selectableList(
|
||||
value = configuration.sniffer::overrideDestination,
|
||||
values = booleanValues,
|
||||
valuesText = booleanValuesText,
|
||||
title = R.string.override_destination,
|
||||
configure = snifferDependencies::add,
|
||||
)
|
||||
|
||||
editableTextList(
|
||||
value = configuration.sniffer::forceDomain,
|
||||
adapter = TextAdapter.String,
|
||||
@ -170,6 +194,39 @@ class MetaFeatureSettingsDesign(
|
||||
|
||||
sniffer.listener?.onChanged()
|
||||
|
||||
/*
|
||||
category(R.string.geox_url_setting)
|
||||
|
||||
val geoxUrlDependencies: MutableList<Preference> = mutableListOf()
|
||||
|
||||
editableText(
|
||||
value = configuration.geoxurl::geoip,
|
||||
adapter = NullableTextAdapter.String,
|
||||
title = R.string.geox_geoip,
|
||||
placeholder = R.string.dont_modify,
|
||||
empty = R.string.geoip_url,
|
||||
configure = geoxUrlDependencies::add,
|
||||
)
|
||||
|
||||
editableText(
|
||||
value = configuration.geoxurl::mmdb,
|
||||
adapter = NullableTextAdapter.String,
|
||||
title = R.string.geox_mmdb,
|
||||
placeholder = R.string.dont_modify,
|
||||
empty = R.string.mmdb_url,
|
||||
configure = geoxUrlDependencies::add,
|
||||
)
|
||||
|
||||
editableText(
|
||||
value = configuration.geoxurl::geosite,
|
||||
adapter = NullableTextAdapter.String,
|
||||
title = R.string.geox_geosite,
|
||||
placeholder = R.string.dont_modify,
|
||||
empty = R.string.geosite_url,
|
||||
configure = geoxUrlDependencies::add,
|
||||
)
|
||||
*/
|
||||
|
||||
category(R.string.geox_files)
|
||||
|
||||
clickable (
|
||||
@ -198,38 +255,6 @@ class MetaFeatureSettingsDesign(
|
||||
requests.trySend(Request.ImportCountry)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
category(R.string.geox_url_setting)
|
||||
|
||||
val geoxurlDependencies: MutableList<Preference> = mutableListOf()
|
||||
|
||||
editableText(
|
||||
value = configuration.geoxurl::geoip,
|
||||
adapter = NullableTextAdapter.String,
|
||||
title = R.string.geox_geoip,
|
||||
placeholder = R.string.dont_modify,
|
||||
empty = R.string.geoip_url,
|
||||
configure = geoxurlDependencies::add,
|
||||
)
|
||||
|
||||
editableText(
|
||||
value = configuration.geoxurl::mmdb,
|
||||
adapter = NullableTextAdapter.String,
|
||||
title = R.string.geox_mmdb,
|
||||
placeholder = R.string.dont_modify,
|
||||
empty = R.string.mmdb_url,
|
||||
configure = geoxurlDependencies::add,
|
||||
)
|
||||
|
||||
editableText(
|
||||
value = configuration.geoxurl::geosite,
|
||||
adapter = NullableTextAdapter.String,
|
||||
title = R.string.geox_geosite,
|
||||
placeholder = R.string.dont_modify,
|
||||
empty = R.string.geosite_url,
|
||||
configure = geoxurlDependencies::add,
|
||||
) */
|
||||
}
|
||||
|
||||
binding.content.addView(screen.root)
|
||||
|
@ -251,4 +251,7 @@
|
||||
<string name="external_control_activity">External Control</string>
|
||||
<string name="external_control_started">Clash.Meta service started</string>
|
||||
<string name="external_control_stopped">Clash.Meta service stopped</string>
|
||||
<string name="force_dns_mapping">Force DNS Mapping</string>
|
||||
<string name="parse_pure_ip">Parse Pure IP</string>
|
||||
<string name="override_destination">Override Destination</string>
|
||||
</resources>
|
@ -251,4 +251,7 @@
|
||||
<string name="external_control_activity">External Control</string>
|
||||
<string name="external_control_started">Clash.Meta service started</string>
|
||||
<string name="external_control_stopped">Clash.Meta service stopped</string>
|
||||
<string name="force_dns_mapping">Force DNS Mapping</string>
|
||||
<string name="parse_pure_ip">Parse Pure IP</string>
|
||||
<string name="override_destination">Override Destination</string>
|
||||
</resources>
|
@ -316,4 +316,7 @@
|
||||
<string name="external_control_activity">External Control</string>
|
||||
<string name="external_control_started">Clash.Meta service started</string>
|
||||
<string name="external_control_stopped">Clash.Meta service stopped</string>
|
||||
<string name="force_dns_mapping">Force DNS Mapping</string>
|
||||
<string name="parse_pure_ip">Parse Pure IP</string>
|
||||
<string name="override_destination">Override Destination</string>
|
||||
</resources>
|
||||
|
@ -248,4 +248,7 @@
|
||||
<string name="external_control_activity">External Control</string>
|
||||
<string name="external_control_started">Clash.Meta service started</string>
|
||||
<string name="external_control_stopped">Clash.Meta service stopped</string>
|
||||
<string name="force_dns_mapping">Force DNS Mapping</string>
|
||||
<string name="parse_pure_ip">Parse Pure IP</string>
|
||||
<string name="override_destination">Override Destination</string>
|
||||
</resources>
|
@ -248,4 +248,7 @@
|
||||
<string name="external_control_activity">External Control</string>
|
||||
<string name="external_control_started">Clash.Meta service started</string>
|
||||
<string name="external_control_stopped">Clash.Meta service stopped</string>
|
||||
<string name="force_dns_mapping">Force DNS Mapping</string>
|
||||
<string name="parse_pure_ip">Parse Pure IP</string>
|
||||
<string name="override_destination">Override Destination</string>
|
||||
</resources>
|
||||
|
@ -251,4 +251,7 @@
|
||||
<string name="external_control_activity">External Control</string>
|
||||
<string name="external_control_started">Clash.Meta 服务已启动</string>
|
||||
<string name="external_control_stopped">Clash.Meta 服务已停止</string>
|
||||
<string name="force_dns_mapping">Force DNS Mapping</string>
|
||||
<string name="parse_pure_ip">Parse Pure IP</string>
|
||||
<string name="override_destination">Override Destination</string>
|
||||
</resources>
|
@ -317,4 +317,7 @@
|
||||
<string name="external_control_activity">External Control</string>
|
||||
<string name="external_control_started">Clash.Meta service started</string>
|
||||
<string name="external_control_stopped">Clash.Meta service stopped</string>
|
||||
<string name="force_dns_mapping">Force DNS Mapping</string>
|
||||
<string name="parse_pure_ip">Parse Pure IP</string>
|
||||
<string name="override_destination">Override Destination</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user