diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/AppConfig.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/AppConfig.kt index aa4e802b..af13115d 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/AppConfig.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/AppConfig.kt @@ -58,6 +58,7 @@ object AppConfig { const val PREF_MODE = "pref_mode" const val PREF_IS_BOOTED = "pref_is_booted" const val PREF_CHECK_UPDATE_PRE_RELEASE = "pref_check_update_pre_release" + const val PREF_GEO_FILES_SOURCES = "pref_geo_files_sources" /** Cache keys. */ const val CACHE_SUBSCRIPTION_ID = "cache_subscription_id" @@ -89,17 +90,13 @@ object AppConfig { const val DOWNLINK = "downlink" /** URLs for various resources. */ - const val androidpackagenamelistUrl = - "https://raw.githubusercontent.com/2dust/androidpackagenamelist/master/proxy.txt" - const val v2rayCustomRoutingListUrl = - "https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/" + const val androidpackagenamelistUrl = "https://raw.githubusercontent.com/2dust/androidpackagenamelist/master/proxy.txt" const val v2rayNGUrl = "https://github.com/2dust/v2rayNG" const val v2rayNGAPIUrl = "https://api.github.com/repos/2dust/v2rayNG/releases" const val v2rayNGIssues = "$v2rayNGUrl/issues" const val v2rayNGWikiMode = "$v2rayNGUrl/wiki/Mode" const val v2rayNGPrivacyPolicy = "https://raw.githubusercontent.com/2dust/v2rayNG/master/CR.md" const val PromotionUrl = "aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw=" - const val GeoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/" const val TgChannelUrl = "https://t.me/github_2dust" const val DelayTestUrl = "https://www.gstatic.com/generate_204" const val DelayTestUrl2 = "https://www.google.com/generate_204" @@ -202,5 +199,10 @@ object AppConfig { "224.0.0.0/4", "240.0.0.0/4" ) + val GEO_FILES_SOURCES = arrayListOf( + "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/", + "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/", + "https://github.com/Chocolate4U/Iran-v2ray-rules/releases/latest/download/" + ) } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/UserAssetActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/UserAssetActivity.kt index f911bd89..41cad466 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/UserAssetActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/UserAssetActivity.kt @@ -21,7 +21,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.v2ray.ang.AppConfig import com.v2ray.ang.R -import com.v2ray.ang.databinding.ActivitySubSettingBinding +import com.v2ray.ang.databinding.ActivityUserAssetBinding import com.v2ray.ang.databinding.ItemRecyclerUserAssetBinding import com.v2ray.ang.dto.AssetUrlItem import com.v2ray.ang.extension.toTrafficString @@ -42,7 +42,7 @@ import java.text.DateFormat import java.util.Date class UserAssetActivity : BaseActivity() { - private val binding by lazy { ActivitySubSettingBinding.inflate(layoutInflater) } + private val binding by lazy { ActivityUserAssetBinding.inflate(layoutInflater) } val extDir by lazy { File(Utils.userAssetPath(this)) } @@ -90,6 +90,11 @@ class UserAssetActivity : BaseActivity() { binding.recyclerView.layoutManager = LinearLayoutManager(this) addCustomDividerToRecyclerView(binding.recyclerView, this, R.drawable.custom_divider) binding.recyclerView.adapter = UserAssetAdapter() + + binding.tvGeoFilesSourcesSummary.text = getGeoFilesSources() + binding.layoutGeoFilesSources.setOnClickListener { + setGeoFilesSources() + } } override fun onResume() { @@ -111,6 +116,23 @@ class UserAssetActivity : BaseActivity() { else -> super.onOptionsItemSelected(item) } + private fun getGeoFilesSources(): String { + return MmkvManager.decodeSettingsString(AppConfig.PREF_GEO_FILES_SOURCES) ?: AppConfig.GEO_FILES_SOURCES.first() + } + + private fun setGeoFilesSources() { + AlertDialog.Builder(this).setItems(AppConfig.GEO_FILES_SOURCES + .toTypedArray()) { _, i -> + try { + val value = AppConfig.GEO_FILES_SOURCES[i] + MmkvManager.encodeSettings(AppConfig.PREF_GEO_FILES_SOURCES, value) + binding.tvGeoFilesSourcesSummary.text = value + } catch (e: Exception) { + Log.e(AppConfig.TAG, "Failed to set geo files sources", e) + } + }.show() + } + private fun showFileChooser() { val permission = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { Manifest.permission.READ_MEDIA_IMAGES @@ -264,7 +286,7 @@ class UserAssetActivity : BaseActivity() { list.add( Utils.getUuid() to AssetUrlItem( it, - AppConfig.GeoUrl + it + getGeoFilesSources() + it ) ) } @@ -315,7 +337,7 @@ class UserAssetActivity : BaseActivity() { holder.itemUserAssetBinding.assetProperties.text = getString(R.string.msg_file_not_found) } - if (item.second.remarks in builtInGeoFiles && item.second.url == AppConfig.GeoUrl + item.second.remarks) { + if (item.second.remarks in builtInGeoFiles && item.second.url == getGeoFilesSources() + item.second.remarks) { holder.itemUserAssetBinding.layoutEdit.visibility = GONE //holder.itemUserAssetBinding.layoutRemove.visibility = GONE } else { diff --git a/V2rayNG/app/src/main/res/layout/activity_user_asset.xml b/V2rayNG/app/src/main/res/layout/activity_user_asset.xml new file mode 100644 index 00000000..5977bdd0 --- /dev/null +++ b/V2rayNG/app/src/main/res/layout/activity_user_asset.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/V2rayNG/app/src/main/res/values-ar/strings.xml b/V2rayNG/app/src/main/res/values-ar/strings.xml index 74a963a3..117ba59c 100644 --- a/V2rayNG/app/src/main/res/values-ar/strings.xml +++ b/V2rayNG/app/src/main/res/values-ar/strings.xml @@ -122,6 +122,7 @@ إضافة عنوان URL للأصل الملف غير موجود الملاحظات موجودة بالفعل + Geo files source (optional) جار التحميل diff --git a/V2rayNG/app/src/main/res/values-bn/strings.xml b/V2rayNG/app/src/main/res/values-bn/strings.xml index 9c6e7d7c..d0aac251 100644 --- a/V2rayNG/app/src/main/res/values-bn/strings.xml +++ b/V2rayNG/app/src/main/res/values-bn/strings.xml @@ -121,6 +121,7 @@ অ্যাসেট URL যোগ করুন ফাইল খুঁজে পাওয়া যায়নি মন্তব্য ইতিমধ্যে বিদ্যমান + Geo files source (optional) লোড হচ্ছে diff --git a/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml b/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml index 0257338c..fcae3c0a 100644 --- a/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml +++ b/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml @@ -121,6 +121,7 @@ نشۊوی اینترنتی دارایین ازاف کۊنین فایلن نجوست ائزارات ز زیتر بیڌسۉݩ + Geo files source (optional) هون بار ونی بۊ diff --git a/V2rayNG/app/src/main/res/values-fa/strings.xml b/V2rayNG/app/src/main/res/values-fa/strings.xml index 3c0598f0..eecc95ac 100644 --- a/V2rayNG/app/src/main/res/values-fa/strings.xml +++ b/V2rayNG/app/src/main/res/values-fa/strings.xml @@ -119,6 +119,7 @@ آدرس اینترنتی را اضافه کنید فایل پیدا نشد نام قبلاً وجود دارد + Geo files source (optional) بارگذاری diff --git a/V2rayNG/app/src/main/res/values-ru/strings.xml b/V2rayNG/app/src/main/res/values-ru/strings.xml index 2950d1a5..a2ce4afd 100644 --- a/V2rayNG/app/src/main/res/values-ru/strings.xml +++ b/V2rayNG/app/src/main/res/values-ru/strings.xml @@ -121,6 +121,7 @@ Добавить URL ресурса Файл не найден Название уже существует + Geo files source (optional) Загрузка… diff --git a/V2rayNG/app/src/main/res/values-vi/strings.xml b/V2rayNG/app/src/main/res/values-vi/strings.xml index 8e3d7c2a..a7a1c3b3 100644 --- a/V2rayNG/app/src/main/res/values-vi/strings.xml +++ b/V2rayNG/app/src/main/res/values-vi/strings.xml @@ -119,6 +119,7 @@ Thêm URL nội dung Không tìm thấy tập tin! Nhận xét đã tồn tại! + Geo files source (optional) Đang tải... 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 44ec4fa8..7df88c31 100644 --- a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml @@ -119,6 +119,7 @@ 添加资产网址 文件未找到 备注已经存在 + Geo 文件来源 (可选) 正在加载 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 f6abbdcf..e046ba7a 100644 --- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml @@ -119,6 +119,7 @@ 新增資產網址 文件未找到 備註已經存在 + Geo 檔案來源 (可選) 載入 diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index a9570d42..803f1ef3 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -122,6 +122,7 @@ Add asset URL File not found The remarks already exists + Geo files source (optional) Loading