mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-22 05:16:08 +03:00
add asn import (#333)
This commit is contained in:
parent
3cc77c7c95
commit
fb1c6a2cc3
@ -38,6 +38,7 @@ task("downloadGeoFiles") {
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb" to "geoip.metadb",
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat" to "geosite.dat",
|
||||
// "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country.mmdb" to "country.mmdb",
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb" to "ASN.mmdb",
|
||||
)
|
||||
|
||||
doLast {
|
||||
|
@ -54,6 +54,13 @@ class MainApplication : Application() {
|
||||
assets.open("geosite.dat").copyTo(it);
|
||||
}
|
||||
}
|
||||
|
||||
val ASNFile = File(clashDir, "ASN.mmdb")
|
||||
if(!ASNFile.exists()) {
|
||||
FileOutputStream(ASNFile).use {
|
||||
assets.open("ASN.mmdb").copyTo(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun finalize() {
|
||||
|
@ -70,6 +70,12 @@ class MetaFeatureSettingsActivity : BaseActivity<MetaFeatureSettingsDesign>() {
|
||||
"*/*")
|
||||
importGeoFile(uri, MetaFeatureSettingsDesign.Request.ImportCountry)
|
||||
}
|
||||
MetaFeatureSettingsDesign.Request.ImportASN -> {
|
||||
val uri = startActivityForResult(
|
||||
ActivityResultContracts.GetContent(),
|
||||
"*/*")
|
||||
importGeoFile(uri, MetaFeatureSettingsDesign.Request.ImportASN)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,6 +113,8 @@ class MetaFeatureSettingsActivity : BaseActivity<MetaFeatureSettingsDesign>() {
|
||||
"geosite$ext"
|
||||
MetaFeatureSettingsDesign.Request.ImportCountry ->
|
||||
"country$ext"
|
||||
MetaFeatureSettingsDesign.Request.ImportASN ->
|
||||
"ASN$ext"
|
||||
else -> ""
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ class MetaFeatureSettingsDesign(
|
||||
configuration: ConfigurationOverride
|
||||
) : Design<MetaFeatureSettingsDesign.Request>(context) {
|
||||
enum class Request {
|
||||
ResetOverride, ImportGeoIp, ImportGeoSite, ImportCountry
|
||||
ResetOverride, ImportGeoIp, ImportGeoSite, ImportCountry, ImportASN
|
||||
}
|
||||
|
||||
private val binding = DesignSettingsMetaFeatureBinding
|
||||
@ -255,6 +255,15 @@ class MetaFeatureSettingsDesign(
|
||||
requests.trySend(Request.ImportCountry)
|
||||
}
|
||||
}
|
||||
|
||||
clickable (
|
||||
title = R.string.import_asn_file,
|
||||
summary = R.string.press_to_import,
|
||||
){
|
||||
clicked {
|
||||
requests.trySend(Request.ImportASN)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.content.addView(screen.root)
|
||||
|
@ -316,6 +316,7 @@
|
||||
<string name="press_to_import">Press to import...</string>
|
||||
<string name="import_geosite_file">Import GeoSite Database</string>
|
||||
<string name="import_country_file">Import Country Database</string>
|
||||
<string name="import_asn_file">Import ASN Database</string>
|
||||
<string name="geofile_import_failed">Import failed</string>
|
||||
<string name="geofile_unknown_db_format">Unknown Database format</string>
|
||||
<string name="geofile_unknown_db_format_message">Only %1$s are supported</string>
|
||||
|
Loading…
Reference in New Issue
Block a user