Compare commits

...

25 Commits

Author SHA1 Message Date
2dust
842c32f29f up 1.9.2 2024-09-24 09:41:16 +08:00
2dust
0501de1658 Bug fix 2024-09-23 09:59:25 +08:00
xubeiyan
dbe26847c7 fix(MainRecyclerAdapter.kt): 将原有的主界面中服务器IP隐藏的逻辑中的1.23.45.67替换为1.23.45***更新为1.23.45.*** (#3585)
Co-authored-by: xubeiyan <yuyeyongdong@gmail.com>
2024-09-23 09:36:13 +08:00
2dust
806290f0a5 Remove no internet permission restrictions when apps are selected
https://github.com/2dust/v2rayNG/issues/3581
2024-09-23 09:33:21 +08:00
2dust
325c643314 Adjusting the text display 2024-09-22 17:05:17 +08:00
2dust
4adc0affbe Add HTTP protocol 2024-09-22 16:54:38 +08:00
solokot
b5026095a0 Update Russian translation (#3583)
* Update Russian translation

* Update Russian translation
2024-09-22 16:51:17 +08:00
2dust
fa7da3be10 Optimize Storage 2024-09-22 14:30:27 +08:00
2dust
35b44f1955 Add drag-and-drop sorting to grouping 2024-09-22 13:20:32 +08:00
2dust
4708ee8823 Add preset ruleset routing 2024-09-21 16:44:15 +08:00
2dust
52471f2ace Optimize UI 2024-09-21 16:02:25 +08:00
2dust
0b065c745d Refactor routing function 2024-09-21 15:36:45 +08:00
2dust
9ce8244065 Optimize UI 2024-09-20 15:06:27 +08:00
2dust
b7fafa1bf9 Optimize MmkvManager 2024-09-20 09:33:07 +08:00
2dust
114c974ce5 Improvements MmkvManager 2024-09-19 19:43:13 +08:00
solokot
e035925d25 Update Russian translation (#3570) 2024-09-19 15:04:38 +08:00
2dust
c0fda6fcba up 1.9.1 2024-09-19 14:54:17 +08:00
2dust
75c90e3c45 Resolving pre-proxy domain issues 2024-09-19 13:45:28 +08:00
2dust
9960f49698 Adding pre-proxy to group 2024-09-19 09:11:42 +08:00
2dust
1a2c4cc9a1 Adding pre-proxy setting to group 2024-09-19 09:09:04 +08:00
2dust
ee4f05b07d up 1.9.0 2024-09-17 13:47:21 +08:00
2dust
17ef476ede Bug fix 2024-09-17 13:39:02 +08:00
2dust
141b98631c Update libs.versions.toml 2024-09-17 11:08:49 +08:00
2dust
845562bca3 adapter noises 2024-09-17 11:02:13 +08:00
2dust
105a41eeea up 1.8.40 2024-09-08 08:44:21 +08:00
90 changed files with 1820 additions and 1460 deletions

View File

@@ -11,8 +11,8 @@ android {
applicationId = "com.v2ray.ang"
minSdk = 21
targetSdk = 34
versionCode = 585
versionName = "1.8.39"
versionCode = 593
versionName = "1.9.2"
multiDexEnabled = true
splits {
abi {

View File

@@ -98,8 +98,10 @@
android:name=".ui.LogcatActivity" />
<activity
android:exported="false"
android:name=".ui.RoutingSettingsActivity"
android:windowSoftInputMode="stateUnchanged" />
android:name=".ui.RoutingSettingActivity" />
<activity
android:exported="false"
android:name=".ui.RoutingEditActivity" />
<activity
android:exported="false"
android:name=".ui.SubSettingActivity" />

View File

@@ -0,0 +1,73 @@
[
{
"remarks": "绕过bittorrent",
"outboundTag": "direct",
"protocol": [
"bittorrent"
]
},
{
"remarks": "Google cn",
"outboundTag": "proxy",
"domain": [
"domain:googleapis.cn",
"domain:gstatic.com"
]
},
{
"remarks": "阻断udp443",
"outboundTag": "block",
"port": "443",
"network": "udp"
},
{
"remarks": "阻断广告",
"outboundTag": "block",
"domain": [
"geosite:category-ads-all"
]
},
{
"remarks": "绕过局域网域名",
"outboundTag": "direct",
"domain": [
"geosite:private"
]
},
{
"remarks": "绕过局域网IP",
"outboundTag": "direct",
"ip": [
"geoip:private"
]
},
{
"remarks": "代理GFW",
"outboundTag": "proxy",
"domain": [
"geosite:gfw",
"geosite:greatfire"
]
},
{
"remarks": "代理Google等",
"outboundTag": "proxy",
"ip": [
"1.0.0.1",
"1.1.1.1",
"8.8.8.8",
"8.8.4.4",
"geoip:facebook",
"geoip:fastly",
"geoip:google",
"geoip:netflix",
"geoip:telegram",
"geoip:twitter"
]
},
{
"remarks": "最终直连",
"port": "0-65535",
"outboundTag": "direct"
}
]

View File

@@ -1 +0,0 @@
geosite:category-ads-all,

View File

@@ -1 +0,0 @@
geosite:cn

View File

@@ -0,0 +1,34 @@
[
{
"remarks": "阻断udp443",
"outboundTag": "block",
"port": "443",
"network": "udp"
},
{
"remarks": "阻断广告",
"outboundTag": "block",
"domain": [
"geosite:category-ads-all"
]
},
{
"remarks": "绕过局域网域名",
"outboundTag": "direct",
"domain": [
"geosite:private"
]
},
{
"remarks": "绕过局域网IP",
"outboundTag": "direct",
"ip": [
"geoip:private"
]
},
{
"remarks": "最终代理",
"port": "0-65535",
"outboundTag": "proxy"
}
]

View File

@@ -1 +0,0 @@
geosite:geolocation-!cn

View File

@@ -0,0 +1,81 @@
[
{
"remarks": "Google cn",
"outboundTag": "proxy",
"domain": [
"domain:googleapis.cn",
"domain:gstatic.com"
]
},
{
"remarks": "阻断udp443",
"outboundTag": "block",
"port": "443",
"network": "udp"
},
{
"remarks": "阻断广告",
"outboundTag": "block",
"domain": [
"geosite:category-ads-all"
]
},
{
"remarks": "绕过局域网域名",
"outboundTag": "direct",
"domain": [
"geosite:private"
]
},
{
"remarks": "绕过局域网IP",
"outboundTag": "direct",
"ip": [
"geoip:private"
]
},
{
"remarks": "绕过中国域名",
"outboundTag": "direct",
"domain": [
"domain:dns.alidns.com",
"domain:doh.pub",
"domain:dot.pub",
"domain:doh.360.cn",
"domain:dot.360.cn",
"geosite:cn",
"geosite:geolocation-cn"
]
},
{
"remarks": "绕过中国IP",
"outboundTag": "direct",
"ip": [
"223.5.5.5/32",
"223.6.6.6/32",
"2400:3200::1/128",
"2400:3200:baba::1/128",
"119.29.29.29/32",
"1.12.12.12/32",
"120.53.53.53/32",
"2402:4e00::/128",
"2402:4e00:1::/128",
"180.76.76.76/32",
"2400:da00::6666/128",
"114.114.114.114/32",
"114.114.115.115/32",
"180.184.1.1/32",
"180.184.2.2/32",
"101.226.4.6/32",
"218.30.118.6/32",
"123.125.81.6/32",
"140.207.198.6/32",
"geoip:cn"
]
},
{
"remarks": "最终代理",
"port": "0-65535",
"outboundTag": "proxy"
}
]

View File

@@ -1,33 +0,0 @@
/*
* Copyright (C) 2015 Paul Burke
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.v2ray.ang.helper;
import androidx.recyclerview.widget.RecyclerView;
/**
* Listener for manual initiation of a drag.
*/
public interface OnStartDragListener {
/**
* Called when a view is requesting a start of a drag.
*
* @param viewHolder The holder of the view to drag.
*/
void onStartDrag(RecyclerView.ViewHolder viewHolder);
}

View File

@@ -5,6 +5,7 @@ import androidx.multidex.MultiDexApplication
import androidx.work.Configuration
import androidx.work.WorkManager
import com.tencent.mmkv.MMKV
import com.v2ray.ang.util.SettingsManager
import com.v2ray.ang.util.Utils
class AngApplication : MultiDexApplication() {
@@ -38,5 +39,7 @@ class AngApplication : MultiDexApplication() {
Utils.setNightMode(application)
// Initialize WorkManager with the custom configuration
WorkManager.initialize(this, workManagerConfiguration)
SettingsManager.initRoutingRulesets(this)
}
}

View File

@@ -25,11 +25,7 @@ object AppConfig {
const val PREF_LOCAL_DNS_PORT = "pref_local_dns_port"
const val PREF_VPN_DNS = "pref_vpn_dns"
const val PREF_ROUTING_DOMAIN_STRATEGY = "pref_routing_domain_strategy"
const val PREF_ROUTING_MODE = "pref_routing_mode"
const val PREF_V2RAY_ROUTING_AGENT = "pref_v2ray_routing_agent"
const val PREF_V2RAY_ROUTING_DIRECT = "pref_v2ray_routing_direct"
const val PREF_V2RAY_ROUTING_BLOCKED = "pref_v2ray_routing_blocked"
const val PREF_ROUTING_CUSTOM = "pref_routing_custom"
const val PREF_ROUTING_RULESET = "pref_routing_ruleset"
const val PREF_MUX_ENABLED = "pref_mux_enabled"
const val PREF_MUX_CONCURRENCY = "pref_mux_concurrency"
const val PREF_MUX_XUDP_CONCURRENCY = "pref_mux_xudp_concurrency"
@@ -137,7 +133,7 @@ object AppConfig {
/** Notification channel IDs and names. */
const val RAY_NG_CHANNEL_ID = "RAY_NG_M_CH_ID"
const val RAY_NG_CHANNEL_NAME = "V2rayNG Background Service"
const val RAY_NG_CHANNEL_NAME = "v2rayNG Background Service"
const val SUBSCRIPTION_UPDATE_CHANNEL = "subscription_update_channel"
const val SUBSCRIPTION_UPDATE_CHANNEL_NAME = "Subscription Update Service"
@@ -146,6 +142,7 @@ object AppConfig {
const val CUSTOM = ""
const val SHADOWSOCKS = "ss://"
const val SOCKS = "socks://"
const val HTTP = "http://"
const val VLESS = "vless://"
const val TROJAN = "trojan://"
const val WIREGUARD = "wireguard://"

View File

@@ -10,7 +10,8 @@ enum class EConfigType(val value: Int, val protocolScheme: String) {
SOCKS(4, AppConfig.SOCKS),
VLESS(5, AppConfig.VLESS),
TROJAN(6, AppConfig.TROJAN),
WIREGUARD(7, AppConfig.WIREGUARD);
WIREGUARD(7, AppConfig.WIREGUARD),
HTTP(10, AppConfig.HTTP);
companion object {
fun fromInt(value: Int) = values().firstOrNull { it.value == value }

View File

@@ -1,9 +0,0 @@
package com.v2ray.ang.dto
enum class ERoutingMode(val value: String) {
GLOBAL_PROXY("0"),
BYPASS_LAN("1"),
BYPASS_MAINLAND("2"),
BYPASS_LAN_MAINLAND("3"),
GLOBAL_DIRECT("4");
}

View File

@@ -0,0 +1,12 @@
package com.v2ray.ang.dto
data class RulesetItem(
var remarks: String? = "",
var ip: List<String>? = null,
var domain: List<String>? = null,
var outboundTag: String = "",
var port: String? = null,
var network: String? = null,
var protocol: List<String>? = null,
var enabled: Boolean = true,
)

View File

@@ -3,7 +3,6 @@ package com.v2ray.ang.dto
import com.v2ray.ang.AppConfig.TAG_BLOCKED
import com.v2ray.ang.AppConfig.TAG_DIRECT
import com.v2ray.ang.AppConfig.TAG_PROXY
import com.v2ray.ang.util.Utils
data class ServerConfig(
val configVersion: Int = 3,
@@ -36,7 +35,10 @@ data class ServerConfig(
EConfigType.CUSTOM ->
return ServerConfig(configType = configType)
EConfigType.SHADOWSOCKS, EConfigType.SOCKS, EConfigType.TROJAN ->
EConfigType.SHADOWSOCKS,
EConfigType.SOCKS,
EConfigType.HTTP,
EConfigType.TROJAN ->
return ServerConfig(
configType = configType,
outboundBean = V2rayConfig.OutboundBean(
@@ -79,10 +81,4 @@ data class ServerConfig(
}
return mutableListOf()
}
fun getV2rayPointDomainAndPort(): String {
val address = getProxyOutbound()?.getServerAddress().orEmpty()
val port = getProxyOutbound()?.getServerPort()
return Utils.getIpv6Address(address) + ":" + port
}
}

View File

@@ -8,5 +8,7 @@ data class SubscriptionItem(
var lastUpdated: Long = -1,
var autoUpdate: Boolean = false,
val updateInterval: Int? = null,
var prevProfile: String? = null,
var nextProfile: String? = null,
)

View File

@@ -7,6 +7,7 @@ import com.google.gson.JsonSerializationContext
import com.google.gson.JsonSerializer
import com.google.gson.annotations.SerializedName
import com.google.gson.reflect.TypeToken
import com.v2ray.ang.util.Utils
import java.lang.reflect.Type
data class V2rayConfig(
@@ -85,7 +86,7 @@ data class V2rayConfig(
data class OutSettingsBean(
var vnext: List<VnextBean>? = null,
var fragment: FragmentBean? = null,
var noise: NoiseBean? = null,
var noises: List<NoiseBean>? = null,
var servers: List<ServersBean>? = null,
/*Blackhole*/
var response: Response? = null,
@@ -129,15 +130,16 @@ data class V2rayConfig(
)
data class NoiseBean(
var type: String? = null,
var packet: String? = null,
var delay: String? = null
)
data class ServersBean(
var address: String = "",
var method: String = "chacha20-poly1305",
var method: String? = null,
var ota: Boolean = false,
var password: String = "",
var password: String? = null,
var port: Int = DEFAULT_PORT,
var level: Int = DEFAULT_LEVEL,
val email: String? = null,
@@ -423,6 +425,7 @@ data class V2rayConfig(
return settings?.vnext?.get(0)?.address
} else if (protocol.equals(EConfigType.SHADOWSOCKS.name, true)
|| protocol.equals(EConfigType.SOCKS.name, true)
|| protocol.equals(EConfigType.HTTP.name, true)
|| protocol.equals(EConfigType.TROJAN.name, true)
) {
return settings?.servers?.get(0)?.address
@@ -439,6 +442,7 @@ data class V2rayConfig(
return settings?.vnext?.get(0)?.port
} else if (protocol.equals(EConfigType.SHADOWSOCKS.name, true)
|| protocol.equals(EConfigType.SOCKS.name, true)
|| protocol.equals(EConfigType.HTTP.name, true)
|| protocol.equals(EConfigType.TROJAN.name, true)
) {
return settings?.servers?.get(0)?.port
@@ -448,6 +452,12 @@ data class V2rayConfig(
return null
}
fun getServerAddressAndPort(): String {
val address = getServerAddress().orEmpty()
val port = getServerPort()
return Utils.getIpv6Address(address) + ":" + port
}
fun getPassword(): String? {
if (protocol.equals(EConfigType.VMESS.name, true)
|| protocol.equals(EConfigType.VLESS.name, true)
@@ -457,7 +467,8 @@ data class V2rayConfig(
|| protocol.equals(EConfigType.TROJAN.name, true)
) {
return settings?.servers?.get(0)?.password
} else if (protocol.equals(EConfigType.SOCKS.name, true)) {
} else if (protocol.equals(EConfigType.SOCKS.name, true)
|| protocol.equals(EConfigType.HTTP.name, true)) {
return settings?.servers?.get(0)?.users?.get(0)?.pass
} else if (protocol.equals(EConfigType.WIREGUARD.name, true)) {
return settings?.secretKey

View File

@@ -54,4 +54,6 @@ val URLConnection.responseLength: Long
val URI.idnHost: String
get() = host?.replace("[", "")?.replace("]", "").orEmpty()
fun String.removeWhiteSpace(): String = replace("\\s+".toRegex(), "")
fun String.removeWhiteSpace(): String = replace("\\s+".toRegex(), "")
fun String.toLongEx(): Long = toLongOrNull() ?: 0

View File

@@ -4,15 +4,12 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.text.TextUtils
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.service.V2RayServiceManager
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.Utils
class TaskerReceiver : BroadcastReceiver() {
private val mainStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
override fun onReceive(context: Context, intent: Intent?) {
@@ -27,7 +24,7 @@ class TaskerReceiver : BroadcastReceiver() {
if (guid == AppConfig.TASKER_DEFAULT_GUID) {
Utils.startVServiceFromToggle(context)
} else {
mainStorage?.encode(MmkvManager.KEY_SELECTED_SERVER, guid)
MmkvManager.setSelectServer(guid)
V2RayServiceManager.startV2Ray(context)
}
} else {

View File

@@ -13,7 +13,6 @@ import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.AppConfig.ANG_PACKAGE
import com.v2ray.ang.AppConfig.TAG_DIRECT
@@ -24,6 +23,7 @@ import com.v2ray.ang.extension.toast
import com.v2ray.ang.ui.MainActivity
import com.v2ray.ang.util.MessageUtil
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import com.v2ray.ang.util.V2rayConfigUtil
import go.Seq
@@ -46,8 +46,6 @@ object V2RayServiceManager {
val v2rayPoint: V2RayPoint = Libv2ray.newV2RayPoint(V2RayCallback(), Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
private val mMsgReceive = ReceiveMessageHandler()
private val mainStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
var serviceControl: SoftReference<ServiceControl>? = null
set(value) {
@@ -64,7 +62,7 @@ object V2RayServiceManager {
fun startV2Ray(context: Context) {
if (v2rayPoint.isRunning) return
val guid = mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER) ?: return
val guid = MmkvManager.getSelectServer() ?: return
val result = V2rayConfigUtil.getV2rayConfig(context, guid)
if (!result.status) return
@@ -129,7 +127,7 @@ object V2RayServiceManager {
fun startV2rayPoint() {
val service = serviceControl?.get()?.getService() ?: return
val guid = mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER) ?: return
val guid = MmkvManager.getSelectServer() ?: return
val config = MmkvManager.decodeServerConfig(guid) ?: return
if (v2rayPoint.isRunning) {
return
@@ -153,7 +151,7 @@ object V2RayServiceManager {
}
v2rayPoint.configureFileContent = result.content
v2rayPoint.domainName = config.getV2rayPointDomainAndPort()
v2rayPoint.domainName = result.domainPort
currentConfig = config
try {

View File

@@ -16,12 +16,11 @@ import android.os.ParcelFileDescriptor
import android.os.StrictMode
import android.util.Log
import androidx.annotation.RequiresApi
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.dto.ERoutingMode
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.MyContextWrapper
import com.v2ray.ang.util.SettingsManager
import com.v2ray.ang.util.Utils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -39,7 +38,6 @@ class V2RayVpnService : VpnService(), ServiceControl {
private const val TUN2SOCKS = "libtun2socks.so"
}
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
private lateinit var mInterface: ParcelFileDescriptor
private var isRunning = false
@@ -117,13 +115,11 @@ class V2RayVpnService : VpnService(), ServiceControl {
val builder = Builder()
//val enableLocalDns = defaultDPreference.getPrefBoolean(AppConfig.PREF_LOCAL_DNS_ENABLED, false)
val routingMode = settingsStorage?.decodeString(AppConfig.PREF_ROUTING_MODE)
?: ERoutingMode.BYPASS_LAN_MAINLAND.value
builder.setMtu(VPN_MTU)
builder.addAddress(PRIVATE_VLAN4_CLIENT, 30)
//builder.addDnsServer(PRIVATE_VLAN4_ROUTER)
if (routingMode == ERoutingMode.BYPASS_LAN.value || routingMode == ERoutingMode.BYPASS_LAN_MAINLAND.value) {
val bypassLan = SettingsManager.routingRulesetsBypassLan()
if (bypassLan) {
resources.getStringArray(R.array.bypass_private_ip_address).forEach {
val addr = it.split('/')
builder.addRoute(addr[0], addr[1].toInt())
@@ -134,7 +130,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
if (settingsStorage?.decodeBool(AppConfig.PREF_PREFER_IPV6) == true) {
builder.addAddress(PRIVATE_VLAN6_CLIENT, 126)
if (routingMode == ERoutingMode.BYPASS_LAN.value || routingMode == ERoutingMode.BYPASS_LAN_MAINLAND.value) {
if (bypassLan) {
builder.addRoute("2000::", 3) //currently only 1/8 of total ipV6 is in use
} else {
builder.addRoute("::", 0)

View File

@@ -37,6 +37,7 @@ import com.v2ray.ang.helper.SimpleItemTouchHelperCallback
import com.v2ray.ang.service.V2RayServiceManager
import com.v2ray.ang.util.AngConfigManager
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import com.v2ray.ang.viewmodel.MainViewModel
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
@@ -87,7 +88,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
binding.fab.setOnClickListener {
if (mainViewModel.isRunning.value == true) {
Utils.stopVService(this)
} else if ((MmkvManager.settingsStorage?.decodeString(AppConfig.PREF_MODE) ?: "VPN") == "VPN") {
} else if ((settingsStorage?.decodeString(AppConfig.PREF_MODE) ?: "VPN") == "VPN") {
val intent = VpnService.prepare(this)
if (intent == null) {
startV2Ray()
@@ -111,11 +112,9 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
binding.recyclerView.layoutManager = LinearLayoutManager(this)
binding.recyclerView.adapter = adapter
val callback = SimpleItemTouchHelperCallback(adapter)
mItemTouchHelper = ItemTouchHelper(callback)
mItemTouchHelper = ItemTouchHelper(SimpleItemTouchHelperCallback(adapter))
mItemTouchHelper?.attachToRecyclerView(binding.recyclerView)
val toggle = ActionBarDrawerToggle(
this, binding.drawerLayout, binding.toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
)
@@ -198,7 +197,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
}
fun startV2Ray() {
if (MmkvManager.mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER).isNullOrEmpty()) {
if (MmkvManager.getSelectServer().isNullOrEmpty()) {
return
}
V2RayServiceManager.startV2Ray(this)
@@ -278,6 +277,11 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
true
}
R.id.import_manually_http -> {
importManually(EConfigType.HTTP.value)
true
}
R.id.import_manually_trojan -> {
importManually(EConfigType.TROJAN.value)
true
@@ -706,10 +710,11 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
)
}
R.id.user_asset_setting -> {
startActivity(Intent(this, UserAssetActivity::class.java))
R.id.routing_setting -> {
requestSubSettingActivity.launch(Intent(this, RoutingSettingActivity::class.java))
}
R.id.promotion -> {
Utils.openUri(this, "${Utils.decode(AppConfig.PromotionUrl)}?t=${System.currentTimeMillis()}")
}

View File

@@ -9,7 +9,6 @@ import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import com.v2ray.ang.AngApplication.Companion.application
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
@@ -17,13 +16,13 @@ import com.v2ray.ang.databinding.ItemQrcodeBinding
import com.v2ray.ang.databinding.ItemRecyclerFooterBinding
import com.v2ray.ang.databinding.ItemRecyclerMainBinding
import com.v2ray.ang.dto.EConfigType
import com.v2ray.ang.dto.SubscriptionItem
import com.v2ray.ang.extension.toast
import com.v2ray.ang.helper.ItemTouchHelperAdapter
import com.v2ray.ang.helper.ItemTouchHelperViewHolder
import com.v2ray.ang.service.V2RayServiceManager
import com.v2ray.ang.util.AngConfigManager
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Observable
@@ -66,17 +65,12 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
} else {
holder.itemMainBinding.tvTestResult.setTextColor(ContextCompat.getColor(mActivity, R.color.colorPing))
}
if (guid == MmkvManager.mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER)) {
if (guid == MmkvManager.getSelectServer()) {
holder.itemMainBinding.layoutIndicator.setBackgroundResource(R.color.colorAccent)
} else {
holder.itemMainBinding.layoutIndicator.setBackgroundResource(0)
}
holder.itemMainBinding.tvSubscription.text = ""
val json = MmkvManager.subStorage?.decodeString(profile.subscriptionId)
if (!json.isNullOrBlank()) {
val sub = Gson().fromJson(json, SubscriptionItem::class.java)
holder.itemMainBinding.tvSubscription.text = sub.remarks
}
holder.itemMainBinding.tvSubscription.text = MmkvManager.decodeSubscription(profile.subscriptionId)?.remarks ?: ""
var shareOptions = share_method.asList()
when (profile.configType) {
@@ -85,16 +79,15 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
shareOptions = shareOptions.takeLast(1)
}
EConfigType.VLESS -> {
holder.itemMainBinding.tvType.text = profile.configType.name
}
else -> {
holder.itemMainBinding.tvType.text = profile.configType.name.lowercase()
holder.itemMainBinding.tvType.text = profile.configType.name
}
}
val strState = "${profile.server?.dropLast(3)}*** : ${profile.serverPort}"
// 替换服务器地址的'.'之后的内容为'***',例如将'1.23.45.67'替换为'1.23.45.***'
val modifiedServer = profile.server?.split('.')?.dropLast(1)?.joinToString(".", postfix = ".***")
val strState = "$modifiedServer : ${profile.serverPort}"
holder.itemMainBinding.tvStatistics.text = strState
@@ -139,8 +132,8 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
}
}
holder.itemMainBinding.layoutRemove.setOnClickListener {
if (guid != MmkvManager.mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER)) {
if (MmkvManager.settingsStorage?.decodeBool(AppConfig.PREF_CONFIRM_REMOVE) == true) {
if (guid != MmkvManager.getSelectServer()) {
if (settingsStorage?.decodeBool(AppConfig.PREF_CONFIRM_REMOVE) == true) {
AlertDialog.Builder(mActivity).setMessage(R.string.del_config_comfirm)
.setPositiveButton(android.R.string.ok) { _, _ ->
removeServer(guid, position)
@@ -158,9 +151,9 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
}
holder.itemMainBinding.infoContainer.setOnClickListener {
val selected = MmkvManager.mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER)
val selected = MmkvManager.getSelectServer()
if (guid != selected) {
MmkvManager.mainStorage?.encode(MmkvManager.KEY_SELECTED_SERVER, guid)
MmkvManager.setSelectServer(guid)
if (!TextUtils.isEmpty(selected)) {
notifyItemChanged(mActivity.mainViewModel.getPosition(selected.orEmpty()))
}
@@ -236,31 +229,16 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
class FooterViewHolder(val itemFooterBinding: ItemRecyclerFooterBinding) :
BaseViewHolder(itemFooterBinding.root)
override fun onItemDismiss(position: Int) {
val guid = mActivity.mainViewModel.serversCache.getOrNull(position)?.guid ?: return
if (guid != MmkvManager.mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER)) {
// mActivity.alert(R.string.del_config_comfirm) {
// positiveButton(android.R.string.ok) {
mActivity.mainViewModel.removeServer(guid)
notifyItemRemoved(position)
// }
// show()
// }
}
}
override fun onItemMove(fromPosition: Int, toPosition: Int): Boolean {
mActivity.mainViewModel.swapServer(fromPosition, toPosition)
notifyItemMoved(fromPosition, toPosition)
// position is changed, since position is used by click callbacks, need to update range
if (toPosition > fromPosition)
notifyItemRangeChanged(fromPosition, toPosition - fromPosition + 1)
else
notifyItemRangeChanged(toPosition, fromPosition - toPosition + 1)
return true
}
override fun onItemMoveCompleted() {
// do nothing
}
override fun onItemDismiss(position: Int) {
}
}

View File

@@ -10,7 +10,6 @@ import androidx.appcompat.widget.SearchView
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.AppConfig.ANG_PACKAGE
import com.v2ray.ang.R
@@ -19,7 +18,7 @@ import com.v2ray.ang.dto.AppInfo
import com.v2ray.ang.extension.toast
import com.v2ray.ang.extension.v2RayApplication
import com.v2ray.ang.util.AppManagerUtil
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
@@ -34,7 +33,6 @@ class PerAppProxyActivity : BaseActivity() {
private var adapter: PerAppProxyAdapter? = null
private var appsAll: List<AppInfo>? = null
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View File

@@ -0,0 +1,126 @@
package com.v2ray.ang.ui
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.lifecycleScope
import com.google.gson.Gson
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivityRoutingEditBinding
import com.v2ray.ang.dto.RulesetItem
import com.v2ray.ang.extension.toast
import com.v2ray.ang.util.SettingsManager
import com.v2ray.ang.util.Utils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class RoutingEditActivity : BaseActivity() {
private val binding by lazy { ActivityRoutingEditBinding.inflate(layoutInflater) }
private val position by lazy { intent.getIntExtra("position", -1) }
private val outbound_tag: Array<out String> by lazy {
resources.getStringArray(R.array.outbound_tag)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
title = getString(R.string.routing_settings_rule_title)
val rulesetItem = SettingsManager.getRoutingRuleset(position)
if (rulesetItem != null) {
bindingServer(rulesetItem)
} else {
clearServer()
}
}
private fun bindingServer(rulesetItem: RulesetItem): Boolean {
binding.etRemarks.text = Utils.getEditable(rulesetItem.remarks)
binding.etDomain.text = Utils.getEditable(rulesetItem.domain?.joinToString())
binding.etIp.text = Utils.getEditable(rulesetItem.ip?.joinToString())
binding.etPort.text = Utils.getEditable(rulesetItem.port)
binding.etProtocol.text = Utils.getEditable(rulesetItem.protocol?.joinToString())
binding.etNetwork.text = Utils.getEditable(rulesetItem.network)
val outbound = Utils.arrayFind(outbound_tag, rulesetItem.outboundTag)
binding.spOutboundTag.setSelection(outbound)
return true
}
private fun clearServer(): Boolean {
binding.etRemarks.text = null
binding.spOutboundTag.setSelection(0)
return true
}
private fun saveServer(): Boolean {
val rulesetItem = SettingsManager.getRoutingRuleset(position) ?: RulesetItem()
rulesetItem.remarks = binding.etRemarks.text.toString()
binding.etDomain.text.toString().let { rulesetItem.domain = if (it.isEmpty()) null else it.split(',') }
binding.etIp.text.toString().let { rulesetItem.ip = if (it.isEmpty()) null else it.split(',') }
binding.etProtocol.text.toString().let { rulesetItem.protocol = if (it.isEmpty()) null else it.split(',') }
binding.etPort.text.toString().let { rulesetItem.port = it.ifEmpty { null } }
binding.etNetwork.text.toString().let { rulesetItem.network = it.ifEmpty { null } }
rulesetItem.outboundTag = outbound_tag[binding.spOutboundTag.selectedItemPosition]
if (TextUtils.isEmpty(rulesetItem.remarks)) {
toast(R.string.sub_setting_remarks)
return false
}
SettingsManager.saveRoutingRuleset(position, rulesetItem)
toast(R.string.toast_success)
finish()
return true
}
private fun deleteServer(): Boolean {
if (position >= 0) {
AlertDialog.Builder(this).setMessage(R.string.del_config_comfirm)
.setPositiveButton(android.R.string.ok) { _, _ ->
lifecycleScope.launch(Dispatchers.IO) {
SettingsManager.removeRoutingRuleset(position)
launch(Dispatchers.Main) {
finish()
}
}
}
.setNegativeButton(android.R.string.no) { _, _ ->
// do nothing
}
.show()
}
return true
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.action_server, menu)
val del_config = menu.findItem(R.id.del_config)
if (position < 0) {
del_config?.isVisible = false
}
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.del_config -> {
deleteServer()
true
}
R.id.save_config -> {
saveServer()
true
}
else -> super.onOptionsItemSelected(item)
}
}

View File

@@ -0,0 +1,118 @@
package com.v2ray.ang.ui
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.AdapterView
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivityRoutingSettingBinding
import com.v2ray.ang.dto.RulesetItem
import com.v2ray.ang.extension.toast
import com.v2ray.ang.helper.SimpleItemTouchHelperCallback
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.SettingsManager
import com.v2ray.ang.util.Utils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class RoutingSettingActivity : BaseActivity() {
private val binding by lazy { ActivityRoutingSettingBinding.inflate(layoutInflater) }
var rulesets: MutableList<RulesetItem> = mutableListOf()
private val adapter by lazy { RoutingSettingRecyclerAdapter(this) }
private var mItemTouchHelper: ItemTouchHelper? = null
private val routing_domain_strategy: Array<out String> by lazy {
resources.getStringArray(R.array.routing_domain_strategy)
}
private val preset_rulesets: Array<out String> by lazy {
resources.getStringArray(R.array.preset_rulesets)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
title = getString(R.string.routing_settings_title)
binding.recyclerView.setHasFixedSize(true)
binding.recyclerView.layoutManager = LinearLayoutManager(this)
binding.recyclerView.adapter = adapter
mItemTouchHelper = ItemTouchHelper(SimpleItemTouchHelperCallback(adapter))
mItemTouchHelper?.attachToRecyclerView(binding.recyclerView)
val found = Utils.arrayFind(routing_domain_strategy, settingsStorage?.decodeString(AppConfig.PREF_ROUTING_DOMAIN_STRATEGY) ?: "")
found.let { binding.spDomainStrategy.setSelection(if (it >= 0) it else 0) }
binding.spDomainStrategy.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onNothingSelected(parent: AdapterView<*>?) {
}
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
settingsStorage.encode(AppConfig.PREF_ROUTING_DOMAIN_STRATEGY, routing_domain_strategy[position])
}
}
}
override fun onResume() {
super.onResume()
refreshData()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_routing_setting, menu)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.add_rule -> {
startActivity(Intent(this, RoutingEditActivity::class.java))
true
}
R.id.user_asset_setting -> {
startActivity(Intent(this, UserAssetActivity::class.java))
true
}
R.id.import_rulesets -> {
AlertDialog.Builder(this).setMessage(R.string.routing_settings_import_rulesets_tip)
.setPositiveButton(android.R.string.ok) { _, _ ->
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
}
.show()
true
}
else -> super.onOptionsItemSelected(item)
}
fun refreshData() {
rulesets = MmkvManager.decodeRoutingRulesets() ?: mutableListOf()
adapter.notifyDataSetChanged()
}
}

View File

@@ -0,0 +1,78 @@
package com.v2ray.ang.ui
import android.content.Intent
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.v2ray.ang.databinding.ItemRecyclerRoutingSettingBinding
import com.v2ray.ang.helper.ItemTouchHelperAdapter
import com.v2ray.ang.helper.ItemTouchHelperViewHolder
import com.v2ray.ang.ui.MainRecyclerAdapter.BaseViewHolder
import com.v2ray.ang.util.SettingsManager
class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) : RecyclerView.Adapter<RoutingSettingRecyclerAdapter.MainViewHolder>(),
ItemTouchHelperAdapter {
private var mActivity: RoutingSettingActivity = activity
override fun getItemCount() = mActivity.rulesets.size
override fun onBindViewHolder(holder: MainViewHolder, position: Int) {
val ruleset = mActivity.rulesets[position]
holder.itemRoutingSettingBinding.remarks.text = ruleset.remarks
holder.itemRoutingSettingBinding.domainIp.text = (ruleset.domain ?: ruleset.ip ?: ruleset.port)?.toString()
holder.itemRoutingSettingBinding.outboundTag.text = ruleset.outboundTag
holder.itemRoutingSettingBinding.chkEnable.isChecked = ruleset.enabled
holder.itemView.setBackgroundColor(Color.TRANSPARENT)
holder.itemRoutingSettingBinding.layoutEdit.setOnClickListener {
mActivity.startActivity(
Intent(mActivity, RoutingEditActivity::class.java)
.putExtra("position", position)
)
}
holder.itemRoutingSettingBinding.chkEnable.setOnCheckedChangeListener { _, isChecked ->
ruleset.enabled = isChecked
SettingsManager.saveRoutingRuleset(position, ruleset)
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MainViewHolder {
return MainViewHolder(
ItemRecyclerRoutingSettingBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
)
}
class MainViewHolder(val itemRoutingSettingBinding: ItemRecyclerRoutingSettingBinding) :
BaseViewHolder(itemRoutingSettingBinding.root), ItemTouchHelperViewHolder
open class BaseViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun onItemSelected() {
itemView.setBackgroundColor(Color.LTGRAY)
}
fun onItemClear() {
itemView.setBackgroundColor(0)
}
}
override fun onItemMove(fromPosition: Int, toPosition: Int): Boolean {
SettingsManager.swapRoutingRuleset(fromPosition, toPosition)
notifyItemMoved(fromPosition, toPosition)
return true
}
override fun onItemMoveCompleted() {
mActivity.refreshData()
}
override fun onItemDismiss(position: Int) {
}
}

View File

@@ -1,35 +0,0 @@
package com.v2ray.ang.ui
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.google.android.material.tabs.TabLayoutMediator
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivityRoutingSettingsBinding
class RoutingSettingsActivity : BaseActivity() {
private val binding by lazy { ActivityRoutingSettingsBinding.inflate(layoutInflater) }
private val titles: Array<out String> by lazy {
resources.getStringArray(R.array.routing_tag)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
title = getString(R.string.title_pref_routing_custom)
val fragments = ArrayList<Fragment>()
fragments.add(RoutingSettingsFragment().newInstance(AppConfig.PREF_V2RAY_ROUTING_AGENT))
fragments.add(RoutingSettingsFragment().newInstance(AppConfig.PREF_V2RAY_ROUTING_DIRECT))
fragments.add(RoutingSettingsFragment().newInstance(AppConfig.PREF_V2RAY_ROUTING_BLOCKED))
val adapter = FragmentAdapter(this, fragments)
binding.viewpager.adapter = adapter
//tablayout.setTabTextColors(Color.BLACK, Color.RED)
TabLayoutMediator(binding.tablayout, binding.viewpager) { tab, position ->
tab.text = titles[position]
}.attach()
}
}

View File

@@ -1,172 +0,0 @@
package com.v2ray.ang.ui
import android.Manifest
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity.RESULT_OK
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.tbruyelle.rxpermissions3.RxPermissions
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.databinding.FragmentRoutingSettingsBinding
import com.v2ray.ang.extension.toast
import com.v2ray.ang.extension.v2RayApplication
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.Utils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class RoutingSettingsFragment : Fragment() {
private val binding by lazy { FragmentRoutingSettingsBinding.inflate(layoutInflater) }
companion object {
private const val routing_arg = "routing_arg"
}
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
// Inflate the layout for this fragment
return binding.root// inflater.inflate(R.layout.fragment_routing_settings, container, false)
}
fun newInstance(arg: String): Fragment {
val fragment = RoutingSettingsFragment()
val bundle = Bundle()
bundle.putString(routing_arg, arg)
fragment.arguments = bundle
return fragment
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val content = settingsStorage?.getString(requireArguments().getString(routing_arg), "")
binding.etRoutingContent.text = Utils.getEditable(content)
setHasOptionsMenu(true)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_routing, menu)
return super.onCreateOptionsMenu(menu, inflater)
}
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.save_routing -> {
saveRouting()
true
}
R.id.del_routing -> {
binding.etRoutingContent.text = null
true
}
R.id.scan_replace -> {
scanQRcode(true)
true
}
R.id.scan_append -> {
scanQRcode(false)
true
}
R.id.default_rules -> {
setDefaultRules()
true
}
else -> super.onOptionsItemSelected(item)
}
private fun saveRouting() {
val content = binding.etRoutingContent.text.toString()
settingsStorage?.encode(requireArguments().getString(routing_arg), content)
activity?.toast(R.string.toast_success)
}
fun scanQRcode(forReplace: Boolean): Boolean {
// try {
// startActivityForResult(Intent("com.google.zxing.client.android.SCAN")
// .addCategory(Intent.CATEGORY_DEFAULT)
// .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP), requestCode)
// } catch (e: Exception) {
RxPermissions(requireActivity())
.request(Manifest.permission.CAMERA)
.subscribe {
if (it)
if (forReplace)
scanQRCodeForReplace.launch(Intent(activity, ScannerActivity::class.java))
else
scanQRCodeForAppend.launch(Intent(activity, ScannerActivity::class.java))
else
activity?.toast(R.string.toast_permission_denied)
}
// }
return true
}
private val scanQRCodeForReplace = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == RESULT_OK) {
val content = it.data?.getStringExtra("SCAN_RESULT")
binding.etRoutingContent.text = Utils.getEditable(content)
}
}
private val scanQRCodeForAppend = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == RESULT_OK) {
val content = it.data?.getStringExtra("SCAN_RESULT")
binding.etRoutingContent.text = Utils.getEditable("${binding.etRoutingContent.text},$content")
}
}
fun setDefaultRules(): Boolean {
var url = AppConfig.v2rayCustomRoutingListUrl
var tag = ""
when (requireArguments().getString(routing_arg)) {
AppConfig.PREF_V2RAY_ROUTING_AGENT -> {
tag = AppConfig.TAG_PROXY
}
AppConfig.PREF_V2RAY_ROUTING_DIRECT -> {
tag = AppConfig.TAG_DIRECT
}
AppConfig.PREF_V2RAY_ROUTING_BLOCKED -> {
tag = AppConfig.TAG_BLOCKED
}
}
url += tag
activity?.toast(R.string.msg_downloading_content)
lifecycleScope.launch(Dispatchers.IO) {
val content = Utils.getUrlContext(url, 5000)
launch(Dispatchers.Main) {
val routingList = if (TextUtils.isEmpty(content)) {
Utils.readTextFromAssets(activity?.v2RayApplication, "custom_routing_$tag")
} else {
content
}
binding.etRoutingContent.text = Utils.getEditable(routingList)
saveRouting()
//toast(R.string.toast_success)
}
}
return true
}
}

View File

@@ -9,11 +9,10 @@ import android.view.Menu
import android.view.MenuItem
import androidx.activity.result.contract.ActivityResultContracts
import com.tbruyelle.rxpermissions3.RxPermissions
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.extension.toast
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.QRCodeDecoder
import io.github.g00fy2.quickie.QRResult
import io.github.g00fy2.quickie.ScanCustomCode
@@ -22,7 +21,6 @@ import io.github.g00fy2.quickie.config.ScannerConfig
class ScannerActivity : BaseActivity() {
private val scanQrCode = registerForActivityResult(ScanCustomCode(), ::handleResult)
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View File

@@ -12,7 +12,6 @@ import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.AppConfig.PREF_ALLOW_INSECURE
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V4
@@ -27,25 +26,17 @@ import com.v2ray.ang.dto.V2rayConfig.Companion.TLS
import com.v2ray.ang.extension.removeWhiteSpace
import com.v2ray.ang.extension.toast
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.ID_MAIN
import com.v2ray.ang.util.MmkvManager.KEY_SELECTED_SERVER
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import com.v2ray.ang.util.Utils.getIpv6Address
class ServerActivity : BaseActivity() {
private val mainStorage by lazy { MMKV.mmkvWithID(ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
private val settingsStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SETTING,
MMKV.MULTI_PROCESS_MODE
)
}
private val editGuid by lazy { intent.getStringExtra("guid").orEmpty() }
private val isRunning by lazy {
intent.getBooleanExtra("isRunning", false)
&& editGuid.isNotEmpty()
&& editGuid == mainStorage?.decodeString(KEY_SELECTED_SERVER)
&& editGuid == MmkvManager.getSelectServer()
}
private val createConfigType by lazy {
EConfigType.fromInt(intent.getIntExtra("createConfigType", EConfigType.VMESS.value))
@@ -139,6 +130,7 @@ class ServerActivity : BaseActivity() {
EConfigType.CUSTOM -> return
EConfigType.SHADOWSOCKS -> setContentView(R.layout.activity_server_shadowsocks)
EConfigType.SOCKS -> setContentView(R.layout.activity_server_socks)
EConfigType.HTTP -> setContentView(R.layout.activity_server_socks)
EConfigType.VLESS -> setContentView(R.layout.activity_server_vless)
EConfigType.TROJAN -> setContentView(R.layout.activity_server_trojan)
EConfigType.WIREGUARD -> setContentView(R.layout.activity_server_wireguard)
@@ -258,7 +250,9 @@ class ServerActivity : BaseActivity() {
et_id.text = Utils.getEditable(outbound.getPassword().orEmpty())
et_alterId?.text =
Utils.getEditable(outbound.settings?.vnext?.get(0)?.users?.get(0)?.alterId.toString())
if (config.configType == EConfigType.SOCKS) {
if (config.configType == EConfigType.SOCKS
|| config.configType == EConfigType.HTTP
) {
et_security?.text =
Utils.getEditable(outbound.settings?.servers?.get(0)?.users?.get(0)?.user.orEmpty())
} else if (config.configType == EConfigType.VLESS) {
@@ -413,7 +407,10 @@ class ServerActivity : BaseActivity() {
}
val config =
MmkvManager.decodeServerConfig(editGuid) ?: ServerConfig.create(createConfigType)
if (config.configType != EConfigType.SOCKS && TextUtils.isEmpty(et_id.text.toString())) {
if (config.configType != EConfigType.SOCKS
&& config.configType != EConfigType.HTTP
&& TextUtils.isEmpty(et_id.text.toString())
) {
if (config.configType == EConfigType.TROJAN || config.configType == EConfigType.SHADOWSOCKS) {
toast(R.string.server_lab_id3)
} else {
@@ -486,7 +483,7 @@ class ServerActivity : BaseActivity() {
if (config.configType == EConfigType.SHADOWSOCKS) {
server.password = et_id.text.toString().trim()
server.method = shadowsocksSecuritys[sp_security?.selectedItemPosition ?: 0]
} else if (config.configType == EConfigType.SOCKS) {
} else if (config.configType == EConfigType.SOCKS || config.configType == EConfigType.HTTP) {
if (TextUtils.isEmpty(et_security?.text) && TextUtils.isEmpty(et_id.text)) {
server.users = null
} else {
@@ -590,7 +587,7 @@ class ServerActivity : BaseActivity() {
*/
private fun deleteServer(): Boolean {
if (editGuid.isNotEmpty()) {
if (editGuid != mainStorage?.decodeString(KEY_SELECTED_SERVER)) {
if (editGuid != MmkvManager.getSelectServer()) {
if (settingsStorage?.decodeBool(AppConfig.PREF_CONFIRM_REMOVE) == true) {
AlertDialog.Builder(this).setMessage(R.string.del_config_comfirm)
.setPositiveButton(android.R.string.ok) { _, _ ->

View File

@@ -9,7 +9,6 @@ import androidx.appcompat.app.AlertDialog
import com.blacksquircle.ui.editorkit.utils.EditorTheme
import com.blacksquircle.ui.language.json.JsonLanguage
import com.google.gson.Gson
import com.tencent.mmkv.MMKV
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivityServerCustomConfigBinding
import com.v2ray.ang.dto.EConfigType
@@ -23,13 +22,11 @@ import me.drakeet.support.toast.ToastCompat
class ServerCustomConfigActivity : BaseActivity() {
private val binding by lazy { ActivityServerCustomConfigBinding.inflate(layoutInflater) }
private val mainStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
private val serverRawStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SERVER_RAW, MMKV.MULTI_PROCESS_MODE) }
private val editGuid by lazy { intent.getStringExtra("guid").orEmpty() }
private val isRunning by lazy {
intent.getBooleanExtra("isRunning", false)
&& editGuid.isNotEmpty()
&& editGuid == mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER)
&& editGuid == MmkvManager.getSelectServer()
}
override fun onCreate(savedInstanceState: Bundle?) {
@@ -54,7 +51,7 @@ class ServerCustomConfigActivity : BaseActivity() {
*/
private fun bindingServer(config: ServerConfig): Boolean {
binding.etRemarks.text = Utils.getEditable(config.remarks)
val raw = serverRawStorage?.decodeString(editGuid)
val raw = MmkvManager.decodeServerRaw(editGuid)
if (raw.isNullOrBlank()) {
binding.editor.setTextContent(Utils.getEditable(config.fullConfig?.toPrettyPrinting().orEmpty()))
} else {
@@ -93,7 +90,7 @@ class ServerCustomConfigActivity : BaseActivity() {
config.fullConfig = v2rayConfig
MmkvManager.encodeServerConfig(editGuid, config)
serverRawStorage?.encode(editGuid, binding.editor.text.toString())
MmkvManager.encodeServerRaw(editGuid, binding.editor.text.toString())
toast(R.string.toast_success)
finish()
return true

View File

@@ -13,12 +13,12 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.PeriodicWorkRequest
import androidx.work.multiprocess.RemoteWorkManager
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AngApplication
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.extension.toLongEx
import com.v2ray.ang.service.SubscriptionUpdater
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import com.v2ray.ang.viewmodel.SettingsViewModel
import java.util.concurrent.TimeUnit
@@ -36,7 +36,6 @@ class SettingsActivity : BaseActivity() {
}
class SettingsFragment : PreferenceFragmentCompat() {
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
private val perAppProxy by lazy { findPreference<CheckBoxPreference>(AppConfig.PREF_PER_APP_PROXY) }
private val localDns by lazy { findPreference<CheckBoxPreference>(AppConfig.PREF_LOCAL_DNS_ENABLED) }
@@ -44,8 +43,6 @@ class SettingsActivity : BaseActivity() {
private val localDnsPort by lazy { findPreference<EditTextPreference>(AppConfig.PREF_LOCAL_DNS_PORT) }
private val vpnDns by lazy { findPreference<EditTextPreference>(AppConfig.PREF_VPN_DNS) }
private val routingCustom by lazy { findPreference<Preference>(AppConfig.PREF_ROUTING_CUSTOM) }
private val mux by lazy { findPreference<CheckBoxPreference>(AppConfig.PREF_MUX_ENABLED) }
private val muxConcurrency by lazy { findPreference<EditTextPreference>(AppConfig.PREF_MUX_CONCURRENCY) }
private val muxXudpConcurrency by lazy { findPreference<EditTextPreference>(AppConfig.PREF_MUX_XUDP_CONCURRENCY) }
@@ -89,11 +86,6 @@ class SettingsActivity : BaseActivity() {
true
}
routingCustom?.setOnPreferenceClickListener {
startActivity(Intent(activity, RoutingSettingsActivity::class.java))
false
}
mux?.setOnPreferenceChangeListener { _, newValue ->
updateMux(newValue as Boolean)
true
@@ -128,7 +120,7 @@ class SettingsActivity : BaseActivity() {
val value = newValue as Boolean
autoUpdateCheck?.isChecked = value
autoUpdateInterval?.isEnabled = value
autoUpdateInterval?.text?.toLong()?.let {
autoUpdateInterval?.text?.toLongEx()?.let {
if (newValue) configureUpdateTask(it) else cancelUpdateTask()
}
true
@@ -138,9 +130,9 @@ class SettingsActivity : BaseActivity() {
// It must be greater than 15 minutes because WorkManager couldn't run tasks under 15 minutes intervals
nval =
if (TextUtils.isEmpty(nval) || nval.toLong() < 15) AppConfig.SUBSCRIPTION_DEFAULT_UPDATE_INTERVAL else nval
if (TextUtils.isEmpty(nval) || nval.toLongEx() < 15) AppConfig.SUBSCRIPTION_DEFAULT_UPDATE_INTERVAL else nval
autoUpdateInterval?.summary = nval
configureUpdateTask(nval.toLong())
configureUpdateTask(nval.toLongEx())
true
}
@@ -252,7 +244,6 @@ class SettingsActivity : BaseActivity() {
listOf(
AppConfig.PREF_ROUTING_DOMAIN_STRATEGY,
AppConfig.PREF_ROUTING_MODE,
AppConfig.PREF_MUX_XUDP_QUIC,
AppConfig.PREF_FRAGMENT_PACKETS,
AppConfig.PREF_LANGUAGE,

View File

@@ -6,8 +6,6 @@ import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.lifecycleScope
import com.google.gson.Gson
import com.tencent.mmkv.MMKV
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivitySubEditBinding
import com.v2ray.ang.dto.SubscriptionItem
@@ -23,7 +21,6 @@ class SubEditActivity : BaseActivity() {
var del_config: MenuItem? = null
var save_config: MenuItem? = null
private val subStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SUB, MMKV.MULTI_PROCESS_MODE) }
private val editSubId by lazy { intent.getStringExtra("subId").orEmpty() }
override fun onCreate(savedInstanceState: Bundle?) {
@@ -31,9 +28,9 @@ class SubEditActivity : BaseActivity() {
setContentView(binding.root)
title = getString(R.string.title_sub_setting)
val json = subStorage?.decodeString(editSubId)
if (!json.isNullOrBlank()) {
bindingServer(Gson().fromJson(json, SubscriptionItem::class.java))
val subItem = MmkvManager.decodeSubscription(editSubId)
if (subItem != null) {
bindingServer(subItem)
} else {
clearServer()
}
@@ -47,6 +44,8 @@ class SubEditActivity : BaseActivity() {
binding.etUrl.text = Utils.getEditable(subItem.url)
binding.chkEnable.isChecked = subItem.enabled
binding.autoUpdateCheck.isChecked = subItem.autoUpdate
binding.etPreProfile.text = Utils.getEditable(subItem.prevProfile)
binding.etNextProfile.text = Utils.getEditable(subItem.nextProfile)
return true
}
@@ -57,6 +56,8 @@ class SubEditActivity : BaseActivity() {
binding.etRemarks.text = null
binding.etUrl.text = null
binding.chkEnable.isChecked = true
binding.etPreProfile.text = null
binding.etNextProfile.text = null
return true
}
@@ -64,20 +65,14 @@ class SubEditActivity : BaseActivity() {
* save server config
*/
private fun saveServer(): Boolean {
val subItem: SubscriptionItem
val json = subStorage?.decodeString(editSubId)
var subId = editSubId
if (!json.isNullOrBlank()) {
subItem = Gson().fromJson(json, SubscriptionItem::class.java)
} else {
subId = Utils.getUuid()
subItem = SubscriptionItem()
}
val subItem = MmkvManager.decodeSubscription(editSubId)?:SubscriptionItem()
subItem.remarks = binding.etRemarks.text.toString()
subItem.url = binding.etUrl.text.toString()
subItem.enabled = binding.chkEnable.isChecked
subItem.autoUpdate = binding.autoUpdateCheck.isChecked
subItem.prevProfile = binding.etPreProfile.text.toString()
subItem.nextProfile = binding.etNextProfile.text.toString()
if (TextUtils.isEmpty(subItem.remarks)) {
toast(R.string.sub_setting_remarks)
@@ -88,7 +83,7 @@ class SubEditActivity : BaseActivity() {
// return false
// }
subStorage?.encode(subId, Gson().toJson(subItem))
MmkvManager.encodeSubscription(editSubId, subItem)
toast(R.string.toast_success)
finish()
return true

View File

@@ -6,12 +6,14 @@ import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivitySubSettingBinding
import com.v2ray.ang.databinding.LayoutProgressBinding
import com.v2ray.ang.dto.SubscriptionItem
import com.v2ray.ang.extension.toast
import com.v2ray.ang.helper.SimpleItemTouchHelperCallback
import com.v2ray.ang.util.AngConfigManager
import com.v2ray.ang.util.MmkvManager
import kotlinx.coroutines.Dispatchers
@@ -23,6 +25,7 @@ class SubSettingActivity : BaseActivity() {
var subscriptions: List<Pair<String, SubscriptionItem>> = listOf()
private val adapter by lazy { SubSettingRecyclerAdapter(this) }
private var mItemTouchHelper: ItemTouchHelper? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -33,12 +36,14 @@ class SubSettingActivity : BaseActivity() {
binding.recyclerView.setHasFixedSize(true)
binding.recyclerView.layoutManager = LinearLayoutManager(this)
binding.recyclerView.adapter = adapter
mItemTouchHelper = ItemTouchHelper(SimpleItemTouchHelperCallback(adapter))
mItemTouchHelper?.attachToRecyclerView(binding.recyclerView)
}
override fun onResume() {
super.onResume()
subscriptions = MmkvManager.decodeSubscriptions()
adapter.notifyDataSetChanged()
refreshData()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
@@ -77,4 +82,9 @@ class SubSettingActivity : BaseActivity() {
else -> super.onOptionsItemSelected(item)
}
fun refreshData() {
subscriptions = MmkvManager.decodeSubscriptions()
adapter.notifyDataSetChanged()
}
}

View File

@@ -8,21 +8,20 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import com.tencent.mmkv.MMKV
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ItemQrcodeBinding
import com.v2ray.ang.databinding.ItemRecyclerSubSettingBinding
import com.v2ray.ang.extension.toast
import com.v2ray.ang.helper.ItemTouchHelperAdapter
import com.v2ray.ang.helper.ItemTouchHelperViewHolder
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.QRCodeDecoder
import com.v2ray.ang.util.SettingsManager
import com.v2ray.ang.util.Utils
class SubSettingRecyclerAdapter(val activity: SubSettingActivity) :
RecyclerView.Adapter<SubSettingRecyclerAdapter.MainViewHolder>() {
class SubSettingRecyclerAdapter(val activity: SubSettingActivity) : RecyclerView.Adapter<SubSettingRecyclerAdapter.MainViewHolder>(), ItemTouchHelperAdapter {
private var mActivity: SubSettingActivity = activity
private val subStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SUB, MMKV.MULTI_PROCESS_MODE) }
private val share_method: Array<out String> by lazy {
mActivity.resources.getStringArray(R.array.share_sub_method)
@@ -35,11 +34,7 @@ class SubSettingRecyclerAdapter(val activity: SubSettingActivity) :
val subItem = mActivity.subscriptions[position].second
holder.itemSubSettingBinding.tvName.text = subItem.remarks
holder.itemSubSettingBinding.tvUrl.text = subItem.url
if (subItem.enabled) {
holder.itemSubSettingBinding.chkEnable.setBackgroundResource(R.color.colorAccent)
} else {
holder.itemSubSettingBinding.chkEnable.setBackgroundResource(0)
}
holder.itemSubSettingBinding.chkEnable.isChecked = subItem.enabled
holder.itemView.setBackgroundColor(Color.TRANSPARENT)
holder.itemSubSettingBinding.layoutEdit.setOnClickListener {
@@ -48,10 +43,11 @@ class SubSettingRecyclerAdapter(val activity: SubSettingActivity) :
.putExtra("subId", subId)
)
}
holder.itemSubSettingBinding.infoContainer.setOnClickListener {
subItem.enabled = !subItem.enabled
subStorage?.encode(subId, Gson().toJson(subItem))
notifyItemChanged(position)
holder.itemSubSettingBinding.chkEnable.setOnCheckedChangeListener { _, isChecked ->
subItem.enabled = isChecked
MmkvManager.encodeSubscription(subId, subItem)
}
if (TextUtils.isEmpty(subItem.url)) {
@@ -99,5 +95,28 @@ class SubSettingRecyclerAdapter(val activity: SubSettingActivity) :
}
class MainViewHolder(val itemSubSettingBinding: ItemRecyclerSubSettingBinding) :
RecyclerView.ViewHolder(itemSubSettingBinding.root)
BaseViewHolder(itemSubSettingBinding.root), ItemTouchHelperViewHolder
open class BaseViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun onItemSelected() {
itemView.setBackgroundColor(Color.LTGRAY)
}
fun onItemClear() {
itemView.setBackgroundColor(0)
}
}
override fun onItemMove(fromPosition: Int, toPosition: Int): Boolean {
SettingsManager.swapSubscriptions(fromPosition, toPosition)
notifyItemMoved(fromPosition, toPosition)
return true
}
override fun onItemMoveCompleted() {
mActivity.refreshData()
}
override fun onItemDismiss(position: Int) {
}
}

View File

@@ -8,7 +8,6 @@ import android.view.MenuItem
import android.view.View
import android.widget.ArrayAdapter
import android.widget.ListView
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivityTaskerBinding
@@ -21,8 +20,6 @@ class TaskerActivity : BaseActivity() {
private var lstData: ArrayList<String> = ArrayList()
private var lstGuid: ArrayList<String> = ArrayList()
private val serverStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SERVER_CONFIG, MMKV.MULTI_PROCESS_MODE) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
@@ -31,7 +28,7 @@ class TaskerActivity : BaseActivity() {
lstData.add("Default")
lstGuid.add(AppConfig.TASKER_DEFAULT_GUID)
serverStorage?.allKeys()?.forEach { key ->
MmkvManager.decodeServerList()?.forEach { key ->
MmkvManager.decodeServerConfig(key)?.let { config ->
lstData.add(config.remarks)
lstGuid.add(key)

View File

@@ -19,9 +19,7 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import com.tbruyelle.rxpermissions3.RxPermissions
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivitySubSettingBinding
@@ -31,6 +29,7 @@ import com.v2ray.ang.dto.AssetUrlItem
import com.v2ray.ang.extension.toTrafficString
import com.v2ray.ang.extension.toast
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -45,8 +44,6 @@ import java.util.Date
class UserAssetActivity : BaseActivity() {
private val binding by lazy { ActivitySubSettingBinding.inflate(layoutInflater) }
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
private val assetStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_ASSET, MMKV.MULTI_PROCESS_MODE) }
val extDir by lazy { File(Utils.userAssetPath(this)) }
val builtInGeoFiles = arrayOf("geosite.dat", "geoip.dat")
@@ -138,7 +135,7 @@ class UserAssetActivity : BaseActivity() {
toast(R.string.msg_remark_is_duplicate)
return@registerForActivityResult
}
assetStorage?.encode(assetId, Gson().toJson(assetItem))
MmkvManager.encodeAsset(assetId, assetItem)
copyFile(uri)
} catch (e: Exception) {
toast(R.string.toast_asset_copy_failed)

View File

@@ -5,8 +5,6 @@ import android.text.TextUtils
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import com.google.gson.Gson
import com.tencent.mmkv.MMKV
import com.v2ray.ang.R
import com.v2ray.ang.databinding.ActivityUserAssetUrlBinding
import com.v2ray.ang.dto.AssetUrlItem
@@ -22,7 +20,6 @@ class UserAssetUrlActivity : BaseActivity() {
var save_config: MenuItem? = null
val extDir by lazy { File(Utils.userAssetPath(this)) }
private val assetStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_ASSET, MMKV.MULTI_PROCESS_MODE) }
private val editAssetId by lazy { intent.getStringExtra("assetId").orEmpty() }
override fun onCreate(savedInstanceState: Bundle?) {
@@ -30,9 +27,9 @@ class UserAssetUrlActivity : BaseActivity() {
setContentView(binding.root)
title = getString(R.string.title_user_asset_add_url)
val json = assetStorage?.decodeString(editAssetId)
if (!json.isNullOrBlank()) {
bindingAsset(Gson().fromJson(json, AssetUrlItem::class.java))
val assetItem = MmkvManager.decodeAsset(editAssetId)
if (assetItem != null) {
bindingAsset(assetItem)
} else {
clearAsset()
}
@@ -60,12 +57,9 @@ class UserAssetUrlActivity : BaseActivity() {
* save asset config
*/
private fun saveServer(): Boolean {
val assetItem: AssetUrlItem
val json = assetStorage?.decodeString(editAssetId)
var assetItem = MmkvManager.decodeAsset(editAssetId)
var assetId = editAssetId
if (!json.isNullOrBlank()) {
assetItem = Gson().fromJson(json, AssetUrlItem::class.java)
if (assetItem != null) {
// remove file associated with the asset
val file = extDir.resolve(assetItem.remarks)
if (file.exists()) {
@@ -96,7 +90,7 @@ class UserAssetUrlActivity : BaseActivity() {
return false
}
assetStorage?.encode(assetId, Gson().toJson(assetItem))
MmkvManager.encodeAsset(assetId, assetItem)
toast(R.string.toast_success)
finish()
return true

View File

@@ -10,11 +10,10 @@ import com.google.gson.JsonPrimitive
import com.google.gson.JsonSerializationContext
import com.google.gson.JsonSerializer
import com.google.gson.reflect.TypeToken
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.dto.*
import com.v2ray.ang.util.MmkvManager.KEY_SELECTED_SERVER
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.fmt.ShadowsocksFmt
import com.v2ray.ang.util.fmt.SocksFmt
import com.v2ray.ang.util.fmt.TrojanFmt
@@ -22,185 +21,10 @@ import com.v2ray.ang.util.fmt.VlessFmt
import com.v2ray.ang.util.fmt.VmessFmt
import com.v2ray.ang.util.fmt.WireguardFmt
import java.lang.reflect.Type
import java.net.URI
import java.util.*
object AngConfigManager {
private val mainStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_MAIN,
MMKV.MULTI_PROCESS_MODE
)
}
private val serverRawStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SERVER_RAW,
MMKV.MULTI_PROCESS_MODE
)
}
private val settingsStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SETTING,
MMKV.MULTI_PROCESS_MODE
)
}
private val subStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SUB, MMKV.MULTI_PROCESS_MODE) }
/**
* Legacy loading config
*/
// fun migrateLegacyConfig(c: Context): Boolean? {
// try {
// val defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(c)
// val context = defaultSharedPreferences.getString(ANG_CONFIG, "")
// if (context.isNullOrBlank()) {
// return null
// }
// val angConfig = Gson().fromJson(context, AngConfig::class.java)
// for (i in angConfig.vmess.indices) {
// upgradeServerVersion(angConfig.vmess[i])
// }
//
// copyLegacySettings(defaultSharedPreferences)
// migrateVmessBean(angConfig, defaultSharedPreferences)
// migrateSubItemBean(angConfig)
//
// defaultSharedPreferences.edit().remove(ANG_CONFIG).apply()
// return true
// } catch (e: Exception) {
// e.printStackTrace()
// }
// return false
// }
//
// private fun copyLegacySettings(sharedPreferences: SharedPreferences) {
// listOf(
// AppConfig.PREF_MODE,
// AppConfig.PREF_REMOTE_DNS,
// AppConfig.PREF_DOMESTIC_DNS,
// AppConfig.PREF_LOCAL_DNS_PORT,
// AppConfig.PREF_SOCKS_PORT,
// AppConfig.PREF_HTTP_PORT,
// AppConfig.PREF_LOGLEVEL,
// AppConfig.PREF_ROUTING_DOMAIN_STRATEGY,
// AppConfig.PREF_ROUTING_MODE,
// AppConfig.PREF_V2RAY_ROUTING_AGENT,
// AppConfig.PREF_V2RAY_ROUTING_BLOCKED,
// AppConfig.PREF_V2RAY_ROUTING_DIRECT,
// ).forEach { key ->
// settingsStorage?.encode(key, sharedPreferences.getString(key, null))
// }
// listOf(
// AppConfig.PREF_SPEED_ENABLED,
// AppConfig.PREF_PROXY_SHARING,
// AppConfig.PREF_LOCAL_DNS_ENABLED,
// AppConfig.PREF_ALLOW_INSECURE,
// AppConfig.PREF_PREFER_IPV6,
// AppConfig.PREF_PER_APP_PROXY,
// AppConfig.PREF_BYPASS_APPS,
// ).forEach { key ->
// settingsStorage?.encode(key, sharedPreferences.getBoolean(key, false))
// }
// settingsStorage?.encode(
// AppConfig.PREF_SNIFFING_ENABLED,
// sharedPreferences.getBoolean(AppConfig.PREF_SNIFFING_ENABLED, true)
// )
// settingsStorage?.encode(
// AppConfig.PREF_PER_APP_PROXY_SET,
// sharedPreferences.getStringSet(AppConfig.PREF_PER_APP_PROXY_SET, setOf())
// )
// }
//
// private fun migrateVmessBean(angConfig: AngConfig, sharedPreferences: SharedPreferences) {
// angConfig.vmess.forEachIndexed { index, vmessBean ->
// val type = EConfigType.fromInt(vmessBean.configType) ?: return@forEachIndexed
// val config = ServerConfig.create(type)
// config.remarks = vmessBean.remarks
// config.subscriptionId = vmessBean.subid
// if (type == EConfigType.CUSTOM) {
// val jsonConfig = sharedPreferences.getString(ANG_CONFIG + vmessBean.guid, "")
// val v2rayConfig = try {
// Gson().fromJson(jsonConfig, V2rayConfig::class.java)
// } catch (e: Exception) {
// e.printStackTrace()
// return@forEachIndexed
// }
// config.fullConfig = v2rayConfig
// serverRawStorage?.encode(vmessBean.guid, jsonConfig)
// } else {
// config.outboundBean?.settings?.vnext?.get(0)?.let { vnext ->
// vnext.address = vmessBean.address
// vnext.port = vmessBean.port
// vnext.users[0].id = vmessBean.id
// if (config.configType == EConfigType.VMESS) {
// vnext.users[0].alterId = vmessBean.alterId
// vnext.users[0].security = vmessBean.security
// } else if (config.configType == EConfigType.VLESS) {
// vnext.users[0].encryption = vmessBean.security
// vnext.users[0].flow = vmessBean.flow
// }
// }
// config.outboundBean?.settings?.servers?.get(0)?.let { server ->
// server.address = vmessBean.address
// server.port = vmessBean.port
// if (config.configType == EConfigType.SHADOWSOCKS) {
// server.password = vmessBean.id
// server.method = vmessBean.security
// } else if (config.configType == EConfigType.SOCKS) {
// if (TextUtils.isEmpty(vmessBean.security) && TextUtils.isEmpty(vmessBean.id)) {
// server.users = null
// } else {
// val socksUsersBean =
// V2rayConfig.OutboundBean.OutSettingsBean.ServersBean.SocksUsersBean()
// socksUsersBean.user = vmessBean.security
// socksUsersBean.pass = vmessBean.id
// server.users = listOf(socksUsersBean)
// }
// } else if (config.configType == EConfigType.TROJAN) {
// server.password = vmessBean.id
// }
// }
// config.outboundBean?.streamSettings?.let { streamSetting ->
// val sni = streamSetting.populateTransportSettings(
// vmessBean.network,
// vmessBean.headerType,
// vmessBean.requestHost,
// vmessBean.path,
// vmessBean.path,
// vmessBean.requestHost,
// vmessBean.path,
// vmessBean.headerType,
// vmessBean.path,
// vmessBean.requestHost,
// )
// val allowInsecure = if (vmessBean.allowInsecure.isBlank()) {
// settingsStorage?.decodeBool(AppConfig.PREF_ALLOW_INSECURE) ?: false
// } else {
// vmessBean.allowInsecure.toBoolean()
// }
// var fingerprint = streamSetting.tlsSettings?.fingerprint
// streamSetting.populateTlsSettings(
// vmessBean.streamSecurity, allowInsecure,
// vmessBean.sni.ifBlank { sni }, fingerprint, null, null, null, null
// )
// }
// }
// val key = MmkvManager.encodeServerConfig(vmessBean.guid, config)
// if (index == angConfig.index) {
// mainStorage?.encode(KEY_SELECTED_SERVER, key)
// }
// }
// }
//
// private fun migrateSubItemBean(angConfig: AngConfig) {
// angConfig.subItem.forEach {
// val subItem = SubscriptionItem()
// subItem.remarks = it.remarks
// subItem.url = it.url
// subItem.enabled = it.enabled
// subStorage?.encode(it.id, Gson().toJson(subItem))
// }
// }
/**
* parse config form qrcode or...
*/
@@ -243,7 +67,7 @@ object AngConfigManager {
?.getServerPort() == removedSelectedServer.getProxyOutbound()
?.getServerPort()
) {
mainStorage?.encode(KEY_SELECTED_SERVER, guid)
MmkvManager.setSelectServer(guid)
}
} catch (e: Exception) {
e.printStackTrace()
@@ -264,6 +88,7 @@ object AngConfigManager {
EConfigType.CUSTOM -> ""
EConfigType.SHADOWSOCKS -> ShadowsocksFmt.toUri(config)
EConfigType.SOCKS -> SocksFmt.toUri(config)
EConfigType.HTTP -> ""
EConfigType.VLESS -> VlessFmt.toUri(config)
EConfigType.TROJAN -> TrojanFmt.toUri(config)
EConfigType.WIREGUARD -> WireguardFmt.toUri(config)
@@ -353,39 +178,6 @@ object AngConfigManager {
return 0
}
// /**
// * upgrade
// */
// private fun upgradeServerVersion(vmess: AngConfig.VmessBean): Int {
// try {
// if (vmess.configVersion == 2) {
// return 0
// }
//
// when (vmess.network) {
// "ws", "h2" -> {
// var path = ""
// var host = ""
// val lstParameter = vmess.requestHost.split(";")
// if (lstParameter.isNotEmpty()) {
// path = lstParameter[0].trim()
// }
// if (lstParameter.size > 1) {
// path = lstParameter[0].trim()
// host = lstParameter[1].trim()
// }
// vmess.path = path
// vmess.requestHost = host
// }
// }
// vmess.configVersion = 2
// return 0
// } catch (e: Exception) {
// e.printStackTrace()
// return -1
// }
// }
fun importBatchConfig(server: String?, subid: String, append: Boolean): Pair<Int, Int> {
var count = parseBatchConfig(Utils.decode(server), subid, append)
if (count <= 0) {
@@ -416,7 +208,7 @@ object AngConfigManager {
servers.lines()
.forEach { str ->
if (str.startsWith(AppConfig.PROTOCOL_HTTP) || str.startsWith(AppConfig.PROTOCOL_HTTPS)) {
count += MmkvManager.importUrlAsSubscription(str)
count += importUrlAsSubscription(str)
}
}
return count
@@ -434,7 +226,7 @@ object AngConfigManager {
val removedSelectedServer =
if (!TextUtils.isEmpty(subid) && !append) {
MmkvManager.decodeServerConfig(
mainStorage?.decodeString(KEY_SELECTED_SERVER).orEmpty()
MmkvManager.getSelectServer().orEmpty()
)?.let {
if (it.subscriptionId == subid) {
return@let it
@@ -500,7 +292,7 @@ object AngConfigManager {
.toString())
config.subscriptionId = subid
val key = MmkvManager.encodeServerConfig("", config)
serverRawStorage?.encode(key, gson.toJson(srv))
MmkvManager.encodeServerRaw(key, gson.toJson(srv))
count += 1
}
return count
@@ -515,14 +307,14 @@ object AngConfigManager {
config.fullConfig = Gson().fromJson(server, V2rayConfig::class.java)
config.remarks = config.fullConfig?.remarks ?: System.currentTimeMillis().toString()
val key = MmkvManager.encodeServerConfig("", config)
serverRawStorage?.encode(key, server)
MmkvManager.encodeServerRaw(key, server)
return 1
} else if (server.startsWith("[Interface]") && server.contains("[Peer]")) {
val config = WireguardFmt.parseWireguardConfFile(server)
?: return R.string.toast_incorrect_protocol
config.fullConfig?.remarks ?: System.currentTimeMillis().toString()
val key = MmkvManager.encodeServerConfig("", config)
serverRawStorage?.encode(key, server)
MmkvManager.encodeServerRaw(key, server)
return 1
} else {
return 0
@@ -596,4 +388,19 @@ object AngConfigManager {
}
return count
}
private fun importUrlAsSubscription(url: String): Int {
val subscriptions = MmkvManager.decodeSubscriptions()
subscriptions.forEach {
if (it.second.url == url) {
return 0
}
}
val uri = URI(Utils.fixIllegalUrl(url))
val subItem = SubscriptionItem()
subItem.remarks = uri.fragment ?: "import sub"
subItem.url = url
MmkvManager.encodeSubscription("", subItem)
return 1
}
}

View File

@@ -1,21 +1,19 @@
package com.v2ray.ang.util
import android.Manifest
import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import com.v2ray.ang.dto.AppInfo
import io.reactivex.rxjava3.core.Observable
object AppManagerUtil {
fun loadNetworkAppList(ctx: Context): ArrayList<AppInfo> {
private fun loadNetworkAppList(ctx: Context): ArrayList<AppInfo> {
val packageManager = ctx.packageManager
val packages = packageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS)
val apps = ArrayList<AppInfo>()
for (pkg in packages) {
if (!pkg.hasInternetPermission && pkg.packageName != "android") continue
//if (!pkg.hasInternetPermission && pkg.packageName != "android") continue
val applicationInfo = pkg.applicationInfo
@@ -35,9 +33,9 @@ object AppManagerUtil {
it.onNext(loadNetworkAppList(ctx))
}
val PackageInfo.hasInternetPermission: Boolean
get() {
val permissions = requestedPermissions
return permissions?.any { it == Manifest.permission.INTERNET } ?: false
}
// val PackageInfo.hasInternetPermission: Boolean
// get() {
// val permissions = requestedPermissions
// return permissions?.any { it == Manifest.permission.INTERNET } ?: false
// }
}

View File

@@ -2,36 +2,57 @@ package com.v2ray.ang.util
import com.google.gson.Gson
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig.PREF_ROUTING_RULESET
import com.v2ray.ang.dto.AssetUrlItem
import com.v2ray.ang.dto.ProfileItem
import com.v2ray.ang.dto.RulesetItem
import com.v2ray.ang.dto.ServerAffiliationInfo
import com.v2ray.ang.dto.ServerConfig
import com.v2ray.ang.dto.SubscriptionItem
import java.net.URI
object MmkvManager {
const val ID_MAIN = "MAIN"
const val ID_SERVER_CONFIG = "SERVER_CONFIG"
const val ID_PROFILE_CONFIG = "PROFILE_CONFIG"
const val ID_SERVER_RAW = "SERVER_RAW"
const val ID_SERVER_AFF = "SERVER_AFF"
const val ID_SUB = "SUB"
const val ID_ASSET = "ASSET"
const val ID_SETTING = "SETTING"
const val KEY_SELECTED_SERVER = "SELECTED_SERVER"
const val KEY_ANG_CONFIGS = "ANG_CONFIGS"
val mainStorage by lazy { MMKV.mmkvWithID(ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
//region private
private const val ID_MAIN = "MAIN"
private const val ID_SERVER_CONFIG = "SERVER_CONFIG"
private const val ID_PROFILE_CONFIG = "PROFILE_CONFIG"
private const val ID_SERVER_RAW = "SERVER_RAW"
private const val ID_SERVER_AFF = "SERVER_AFF"
private const val ID_SUB = "SUB"
private const val ID_ASSET = "ASSET"
private const val ID_SETTING = "SETTING"
private const val KEY_SELECTED_SERVER = "SELECTED_SERVER"
private const val KEY_ANG_CONFIGS = "ANG_CONFIGS"
private const val KEY_SUB_IDS = "SUB_IDS"
private val mainStorage by lazy { MMKV.mmkvWithID(ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
val settingsStorage by lazy { MMKV.mmkvWithID(ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
private val serverStorage by lazy { MMKV.mmkvWithID(ID_SERVER_CONFIG, MMKV.MULTI_PROCESS_MODE) }
private val profileStorage by lazy { MMKV.mmkvWithID(ID_PROFILE_CONFIG, MMKV.MULTI_PROCESS_MODE) }
private val serverAffStorage by lazy { MMKV.mmkvWithID(ID_SERVER_AFF, MMKV.MULTI_PROCESS_MODE) }
val subStorage by lazy { MMKV.mmkvWithID(ID_SUB, MMKV.MULTI_PROCESS_MODE) }
private val subStorage by lazy { MMKV.mmkvWithID(ID_SUB, MMKV.MULTI_PROCESS_MODE) }
private val assetStorage by lazy { MMKV.mmkvWithID(ID_ASSET, MMKV.MULTI_PROCESS_MODE) }
val serverRawStorage by lazy { MMKV.mmkvWithID(ID_SERVER_RAW, MMKV.MULTI_PROCESS_MODE) }
private val serverRawStorage by lazy { MMKV.mmkvWithID(ID_SERVER_RAW, MMKV.MULTI_PROCESS_MODE) }
//endregion
//region Server
fun getSelectServer(): String? {
return mainStorage.decodeString(KEY_SELECTED_SERVER)
}
fun setSelectServer(guid: String) {
mainStorage.encode(KEY_SELECTED_SERVER, guid)
}
fun encodeServerList(serverList: MutableList<String>) {
mainStorage.encode(KEY_ANG_CONFIGS, Gson().toJson(serverList))
}
fun decodeServerList(): MutableList<String> {
val json = mainStorage?.decodeString(KEY_ANG_CONFIGS)
val json = mainStorage.decodeString(KEY_ANG_CONFIGS)
return if (json.isNullOrBlank()) {
mutableListOf()
} else {
@@ -43,7 +64,7 @@ object MmkvManager {
if (guid.isBlank()) {
return null
}
val json = serverStorage?.decodeString(guid)
val json = serverStorage.decodeString(guid)
if (json.isNullOrBlank()) {
return null
}
@@ -54,7 +75,7 @@ object MmkvManager {
if (guid.isBlank()) {
return null
}
val json = profileStorage?.decodeString(guid)
val json = profileStorage.decodeString(guid)
if (json.isNullOrBlank()) {
return null
}
@@ -63,13 +84,13 @@ object MmkvManager {
fun encodeServerConfig(guid: String, config: ServerConfig): String {
val key = guid.ifBlank { Utils.getUuid() }
serverStorage?.encode(key, Gson().toJson(config))
serverStorage.encode(key, Gson().toJson(config))
val serverList = decodeServerList()
if (!serverList.contains(key)) {
serverList.add(0, key)
mainStorage?.encode(KEY_ANG_CONFIGS, Gson().toJson(serverList))
if (mainStorage?.decodeString(KEY_SELECTED_SERVER).isNullOrBlank()) {
mainStorage?.encode(KEY_SELECTED_SERVER, key)
encodeServerList(serverList)
if (getSelectServer().isNullOrBlank()) {
mainStorage.encode(KEY_SELECTED_SERVER, key)
}
}
val profile = ProfileItem(
@@ -79,7 +100,7 @@ object MmkvManager {
server = config.getProxyOutbound()?.getServerAddress(),
serverPort = config.getProxyOutbound()?.getServerPort(),
)
profileStorage?.encode(key, Gson().toJson(profile))
profileStorage.encode(key, Gson().toJson(profile))
return key
}
@@ -87,22 +108,22 @@ object MmkvManager {
if (guid.isBlank()) {
return
}
if (mainStorage?.decodeString(KEY_SELECTED_SERVER) == guid) {
mainStorage?.remove(KEY_SELECTED_SERVER)
if (getSelectServer() == guid) {
mainStorage.remove(KEY_SELECTED_SERVER)
}
val serverList = decodeServerList()
serverList.remove(guid)
mainStorage?.encode(KEY_ANG_CONFIGS, Gson().toJson(serverList))
serverStorage?.remove(guid)
profileStorage?.remove(guid)
serverAffStorage?.remove(guid)
encodeServerList(serverList)
serverStorage.remove(guid)
profileStorage.remove(guid)
serverAffStorage.remove(guid)
}
fun removeServerViaSubid(subid: String) {
if (subid.isBlank()) {
return
}
serverStorage?.allKeys()?.forEach { key ->
serverStorage.allKeys()?.forEach { key ->
decodeServerConfig(key)?.let { config ->
if (config.subscriptionId == subid) {
removeServer(key)
@@ -115,7 +136,7 @@ object MmkvManager {
if (guid.isBlank()) {
return null
}
val json = serverAffStorage?.decodeString(guid)
val json = serverAffStorage.decodeString(guid)
if (json.isNullOrBlank()) {
return null
}
@@ -128,69 +149,23 @@ object MmkvManager {
}
val aff = decodeServerAffiliationInfo(guid) ?: ServerAffiliationInfo()
aff.testDelayMillis = testResult
serverAffStorage?.encode(guid, Gson().toJson(aff))
serverAffStorage.encode(guid, Gson().toJson(aff))
}
fun clearAllTestDelayResults(keys: List<String>?) {
keys?.forEach { key ->
decodeServerAffiliationInfo(key)?.let { aff ->
aff.testDelayMillis = 0
serverAffStorage?.encode(key, Gson().toJson(aff))
serverAffStorage.encode(key, Gson().toJson(aff))
}
}
}
fun importUrlAsSubscription(url: String): Int {
val subscriptions = decodeSubscriptions()
subscriptions.forEach {
if (it.second.url == url) {
return 0
}
}
val uri = URI(Utils.fixIllegalUrl(url))
val subItem = SubscriptionItem()
subItem.remarks = uri.fragment ?: "import sub"
subItem.url = url
subStorage?.encode(Utils.getUuid(), Gson().toJson(subItem))
return 1
}
fun decodeSubscriptions(): List<Pair<String, SubscriptionItem>> {
val subscriptions = mutableListOf<Pair<String, SubscriptionItem>>()
subStorage?.allKeys()?.forEach { key ->
val json = subStorage?.decodeString(key)
if (!json.isNullOrBlank()) {
subscriptions.add(Pair(key, Gson().fromJson(json, SubscriptionItem::class.java)))
}
}
return subscriptions.sortedBy { (_, value) -> value.addedTime }
}
fun removeSubscription(subid: String) {
subStorage?.remove(subid)
removeServerViaSubid(subid)
}
fun decodeAssetUrls(): List<Pair<String, AssetUrlItem>> {
val assetUrlItems = mutableListOf<Pair<String, AssetUrlItem>>()
assetStorage?.allKeys()?.forEach { key ->
val json = assetStorage?.decodeString(key)
if (!json.isNullOrBlank()) {
assetUrlItems.add(Pair(key, Gson().fromJson(json, AssetUrlItem::class.java)))
}
}
return assetUrlItems.sortedBy { (_, value) -> value.addedTime }
}
fun removeAssetUrl(assetid: String) {
assetStorage?.remove(assetid)
}
fun removeAllServer() {
mainStorage?.clearAll()
serverStorage?.clearAll()
profileStorage?.clearAll()
serverAffStorage?.clearAll()
mainStorage.clearAll()
serverStorage.clearAll()
profileStorage.clearAll()
serverAffStorage.clearAll()
}
fun removeInvalidServer(guid: String) {
@@ -201,7 +176,7 @@ object MmkvManager {
}
}
} else {
serverAffStorage?.allKeys()?.forEach { key ->
serverAffStorage.allKeys()?.forEach { key ->
decodeServerAffiliationInfo(key)?.let { aff ->
if (aff.testDelayMillis < 0L) {
removeServer(key)
@@ -211,22 +186,125 @@ object MmkvManager {
}
}
fun sortByTestResults() {
data class ServerDelay(var guid: String, var testDelayMillis: Long)
val serverDelays = mutableListOf<ServerDelay>()
val serverList = decodeServerList()
serverList.forEach { key ->
val delay = decodeServerAffiliationInfo(key)?.testDelayMillis ?: 0L
serverDelays.add(ServerDelay(key, if (delay <= 0L) 999999 else delay))
}
serverDelays.sortBy { it.testDelayMillis }
serverDelays.forEach {
serverList.remove(it.guid)
serverList.add(it.guid)
}
mainStorage?.encode(KEY_ANG_CONFIGS, Gson().toJson(serverList))
fun encodeServerRaw(guid: String, config: String) {
serverRawStorage.encode(guid, config)
}
fun decodeServerRaw(guid: String): String? {
return serverRawStorage.decodeString(guid) ?: return null
}
//endregion
//region Subscriptions
private fun initSubsList() {
val subsList = decodeSubsList()
if (subsList.isNotEmpty()) {
return
}
subStorage.allKeys()?.forEach { key ->
subsList.add(key)
}
encodeSubsList(subsList)
}
fun decodeSubscriptions(): List<Pair<String, SubscriptionItem>> {
initSubsList()
val subscriptions = mutableListOf<Pair<String, SubscriptionItem>>()
decodeSubsList().forEach { key ->
val json = subStorage.decodeString(key)
if (!json.isNullOrBlank()) {
subscriptions.add(Pair(key, Gson().fromJson(json, SubscriptionItem::class.java)))
}
}
return subscriptions
}
fun removeSubscription(subid: String) {
subStorage.remove(subid)
val subsList = decodeSubsList()
subsList.remove(subid)
encodeSubsList(subsList)
removeServerViaSubid(subid)
}
fun encodeSubscription(guid: String, subItem: SubscriptionItem) {
val key = guid.ifBlank { Utils.getUuid() }
subStorage.encode(key, Gson().toJson(subItem))
val subsList = decodeSubsList()
if (!subsList.contains(key)) {
subsList.add(key)
encodeSubsList(subsList)
}
}
fun decodeSubscription(subscriptionId: String): SubscriptionItem? {
val json = subStorage.decodeString(subscriptionId) ?: return null
return Gson().fromJson(json, SubscriptionItem::class.java)
}
fun encodeSubsList(subsList: MutableList<String>) {
mainStorage.encode(KEY_SUB_IDS, Gson().toJson(subsList))
}
fun decodeSubsList(): MutableList<String> {
val json = mainStorage.decodeString(KEY_SUB_IDS)
return if (json.isNullOrBlank()) {
mutableListOf()
} else {
Gson().fromJson(json, Array<String>::class.java).toMutableList()
}
}
//endregion
//region Asset
fun decodeAssetUrls(): List<Pair<String, AssetUrlItem>> {
val assetUrlItems = mutableListOf<Pair<String, AssetUrlItem>>()
assetStorage.allKeys()?.forEach { key ->
val json = assetStorage.decodeString(key)
if (!json.isNullOrBlank()) {
assetUrlItems.add(Pair(key, Gson().fromJson(json, AssetUrlItem::class.java)))
}
}
return assetUrlItems.sortedBy { (_, value) -> value.addedTime }
}
fun removeAssetUrl(assetid: String) {
assetStorage.remove(assetid)
}
fun encodeAsset(assetid: String, assetItem: AssetUrlItem) {
val key = assetid.ifBlank { Utils.getUuid() }
assetStorage.encode(key, Gson().toJson(assetItem))
}
fun decodeAsset(assetid: String): AssetUrlItem? {
val json = assetStorage.decodeString(assetid) ?: return null
return Gson().fromJson(json, AssetUrlItem::class.java)
}
//endregion
//region Routing
fun decodeRoutingRulesets(): MutableList<RulesetItem>? {
val ruleset = settingsStorage.decodeString(PREF_ROUTING_RULESET)
if (ruleset.isNullOrEmpty()) return null
return Gson().fromJson(ruleset, Array<RulesetItem>::class.java).toMutableList()
}
fun encodeRoutingRulesets(rulesetList: MutableList<RulesetItem>?) {
if (rulesetList.isNullOrEmpty())
settingsStorage.encode(PREF_ROUTING_RULESET, "")
else
settingsStorage.encode(PREF_ROUTING_RULESET, Gson().toJson(rulesetList))
}
//endregion
}

View File

@@ -0,0 +1,109 @@
package com.v2ray.ang.util
import android.content.Context
import android.text.TextUtils
import com.google.gson.Gson
import com.v2ray.ang.dto.RulesetItem
import com.v2ray.ang.dto.ServerConfig
import com.v2ray.ang.util.MmkvManager.decodeProfileConfig
import com.v2ray.ang.util.MmkvManager.decodeServerConfig
import com.v2ray.ang.util.MmkvManager.decodeServerList
import java.util.Collections
object SettingsManager {
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()) {
val assets = Utils.readTextFromAssets(context, fileName)
if (TextUtils.isEmpty(assets)) {
return
}
val rulesetList = Gson().fromJson(assets, Array<RulesetItem>::class.java).toMutableList()
MmkvManager.encodeRoutingRulesets(rulesetList)
}
}
fun resetRoutingRulesets(context: Context, index: Int) {
MmkvManager.encodeRoutingRulesets(null)
initRoutingRulesets(context, index)
}
fun getRoutingRuleset(index: Int): RulesetItem? {
if (index < 0) return null
val rulesetList = MmkvManager.decodeRoutingRulesets()
if (rulesetList.isNullOrEmpty()) return null
return rulesetList[index]
}
fun saveRoutingRuleset(index: Int, ruleset: RulesetItem?) {
if (ruleset == null) return
val rulesetList = MmkvManager.decodeRoutingRulesets()
if (rulesetList.isNullOrEmpty()) return
if (index < 0 || index >= rulesetList.count()) {
rulesetList.add(ruleset)
} else {
rulesetList[index] = ruleset
}
MmkvManager.encodeRoutingRulesets(rulesetList)
}
fun removeRoutingRuleset(index: Int) {
if (index < 0) return
val rulesetList = MmkvManager.decodeRoutingRulesets()
if (rulesetList.isNullOrEmpty()) return
rulesetList.removeAt(index)
MmkvManager.encodeRoutingRulesets(rulesetList)
}
fun routingRulesetsBypassLan(): Boolean {
val rulesetItems = MmkvManager.decodeRoutingRulesets()
val exist = rulesetItems?.any { it.enabled && it.domain?.contains(":private") == true }
return exist == true
}
fun swapRoutingRuleset(fromPosition: Int, toPosition: Int) {
val rulesetList = MmkvManager.decodeRoutingRulesets()
if (rulesetList.isNullOrEmpty()) return
Collections.swap(rulesetList, fromPosition, toPosition)
MmkvManager.encodeRoutingRulesets(rulesetList)
}
fun swapSubscriptions(fromPosition: Int, toPosition: Int) {
val subsList = MmkvManager.decodeSubsList()
if (subsList.isNullOrEmpty()) return
Collections.swap(subsList, fromPosition, toPosition)
MmkvManager.encodeSubsList(subsList)
}
fun getServerViaRemarks(remarks: String?): ServerConfig? {
if (remarks == null) {
return null
}
val serverList = decodeServerList()
for (guid in serverList) {
val profile = decodeProfileConfig(guid)
if (profile != null && profile.remarks == remarks) {
return decodeServerConfig(guid)
}
}
return null
}
}

View File

@@ -17,22 +17,19 @@ import android.util.Log
import android.util.Patterns
import android.webkit.URLUtil
import androidx.appcompat.app.AppCompatDelegate
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.AppConfig.ANG_PACKAGE
import com.v2ray.ang.BuildConfig
import com.v2ray.ang.R
import com.v2ray.ang.extension.toast
import com.v2ray.ang.service.V2RayServiceManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import java.io.IOException
import java.net.*
import java.util.*
object Utils {
private val mainStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
/**
* convert string to editalbe for kotlin
*
@@ -246,7 +243,7 @@ object Utils {
}
fun startVServiceFromToggle(context: Context): Boolean {
if (mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER).isNullOrEmpty()) {
if (MmkvManager.getSelectServer().isNullOrEmpty()) {
context.toast(R.string.app_tile_first_use)
return false
}

View File

@@ -4,7 +4,6 @@ import android.content.Context
import android.text.TextUtils
import android.util.Log
import com.google.gson.Gson
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.AppConfig.ANG_PACKAGE
import com.v2ray.ang.AppConfig.PROTOCOL_FREEDOM
@@ -15,88 +14,67 @@ import com.v2ray.ang.AppConfig.TAG_PROXY
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V4
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V6
import com.v2ray.ang.dto.EConfigType
import com.v2ray.ang.dto.ERoutingMode
import com.v2ray.ang.dto.RulesetItem
import com.v2ray.ang.dto.ServerConfig
import com.v2ray.ang.dto.V2rayConfig
import com.v2ray.ang.dto.V2rayConfig.Companion.DEFAULT_NETWORK
import com.v2ray.ang.dto.V2rayConfig.Companion.HTTP
import com.v2ray.ang.dto.V2rayConfig.RoutingBean.RulesBean
import com.v2ray.ang.util.MmkvManager.settingsStorage
object V2rayConfigUtil {
private val serverRawStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SERVER_RAW,
MMKV.MULTI_PROCESS_MODE
)
}
private val settingsStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SETTING,
MMKV.MULTI_PROCESS_MODE
)
}
data class Result(var status: Boolean, var content: String)
data class Result(var status: Boolean, var content: String = "", var domainPort: String? = null)
/**
* 生成v2ray的客户端配置文件
*/
fun getV2rayConfig(context: Context, guid: String): Result {
try {
val config = MmkvManager.decodeServerConfig(guid) ?: return Result(false, "")
val config = MmkvManager.decodeServerConfig(guid) ?: return Result(false)
if (config.configType == EConfigType.CUSTOM) {
val raw = serverRawStorage?.decodeString(guid)
val raw = MmkvManager.decodeServerRaw(guid)
val customConfig = if (raw.isNullOrBlank()) {
config.fullConfig?.toPrettyPrinting() ?: return Result(false, "")
config.fullConfig?.toPrettyPrinting() ?: return Result(false)
} else {
raw
}
//Log.d(ANG_PACKAGE, customConfig)
return Result(true, customConfig)
}
val outbound = config.getProxyOutbound() ?: return Result(false, "")
val address = outbound.getServerAddress() ?: return Result(false, "")
if (!Utils.isIpAddress(address)) {
if (!Utils.isValidUrl(address)) {
Log.d(ANG_PACKAGE, "$address is an invalid ip or domain")
return Result(false, "")
}
val domainPort = config.getProxyOutbound()?.getServerAddressAndPort()
return Result(true, customConfig, domainPort)
}
val result = getV2rayNonCustomConfig(context, outbound, config.remarks)
//Log.d(ANG_PACKAGE, result.content)
val result = getV2rayNonCustomConfig(context, config)
Log.d(ANG_PACKAGE, result.content)
return result
} catch (e: Exception) {
e.printStackTrace()
return Result(false, "")
return Result(false)
}
}
/**
* 生成v2ray的客户端配置文件
*/
private fun getV2rayNonCustomConfig(
context: Context,
outbound: V2rayConfig.OutboundBean,
remarks: String,
): Result {
val result = Result(false, "")
private fun getV2rayNonCustomConfig(context: Context, config: ServerConfig): Result {
val result = Result(false)
val outbound = config.getProxyOutbound() ?: return result
val address = outbound.getServerAddress() ?: return result
if (!Utils.isIpAddress(address)) {
if (!Utils.isValidUrl(address)) {
Log.d(ANG_PACKAGE, "$address is an invalid ip or domain")
return result
}
}
//取得默认配置
val assets = Utils.readTextFromAssets(context, "v2ray_config.json")
if (TextUtils.isEmpty(assets)) {
return result
}
//转成Json
val v2rayConfig = Gson().fromJson(assets, V2rayConfig::class.java) ?: return result
v2rayConfig.log.loglevel = settingsStorage?.decodeString(AppConfig.PREF_LOGLEVEL)
?: "warning"
v2rayConfig.log.loglevel = settingsStorage?.decodeString(AppConfig.PREF_LOGLEVEL) ?: "warning"
v2rayConfig.remarks = config.remarks
inbounds(v2rayConfig)
updateOutboundWithGlobalSettings(outbound)
v2rayConfig.outbounds[0] = outbound
outbounds(v2rayConfig, outbound)
updateOutboundFragment(v2rayConfig)
val retMore = moreOutbounds(v2rayConfig, config.subscriptionId)
routing(v2rayConfig)
@@ -112,16 +90,12 @@ object V2rayConfigUtil {
v2rayConfig.policy = null
}
v2rayConfig.remarks = remarks
result.status = true
result.content = v2rayConfig.toPrettyPrinting()
result.domainPort = if (retMore.first) retMore.second else outbound.getServerAddressAndPort()
return result
}
/**
*
*/
private fun inbounds(v2rayConfig: V2rayConfig): Boolean {
try {
val socksPort = Utils.parseInt(
@@ -170,6 +144,20 @@ object V2rayConfigUtil {
return true
}
private fun outbounds(v2rayConfig: V2rayConfig, outbound: V2rayConfig.OutboundBean): Boolean {
val ret = updateOutboundWithGlobalSettings(outbound)
if (!ret) return false
if (v2rayConfig.outbounds.isNotEmpty()) {
v2rayConfig.outbounds[0] = outbound
} else {
v2rayConfig.outbounds.add(outbound)
}
updateOutboundFragment(v2rayConfig)
return true
}
private fun fakedns(v2rayConfig: V2rayConfig) {
if (settingsStorage?.decodeBool(AppConfig.PREF_LOCAL_DNS_ENABLED) == true
&& settingsStorage?.decodeBool(AppConfig.PREF_FAKE_DNS_ENABLED) == true
@@ -178,89 +166,15 @@ object V2rayConfigUtil {
}
}
/**
* routing
*/
private fun routing(v2rayConfig: V2rayConfig): Boolean {
try {
val routingMode = settingsStorage?.decodeString(AppConfig.PREF_ROUTING_MODE)
?: ERoutingMode.BYPASS_LAN_MAINLAND.value
routingUserRule(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_BLOCKED)
.orEmpty(), TAG_BLOCKED, v2rayConfig
)
if (routingMode == ERoutingMode.GLOBAL_DIRECT.value) {
routingUserRule(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_DIRECT)
.orEmpty(), TAG_DIRECT, v2rayConfig
)
routingUserRule(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_AGENT)
.orEmpty(), TAG_PROXY, v2rayConfig
)
} else {
routingUserRule(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_AGENT)
.orEmpty(), TAG_PROXY, v2rayConfig
)
routingUserRule(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_DIRECT)
.orEmpty(), TAG_DIRECT, v2rayConfig
)
v2rayConfig.routing.domainStrategy = settingsStorage?.decodeString(AppConfig.PREF_ROUTING_DOMAIN_STRATEGY) ?: "IPIfNonMatch"
val rulesetItems = MmkvManager.decodeRoutingRulesets()
rulesetItems?.forEach { key ->
routingUserRule(key, v2rayConfig)
}
v2rayConfig.routing.domainStrategy =
settingsStorage?.decodeString(AppConfig.PREF_ROUTING_DOMAIN_STRATEGY)
?: "IPIfNonMatch"
// Hardcode googleapis.cn gstatic.com
val googleapisRoute = V2rayConfig.RoutingBean.RulesBean(
outboundTag = TAG_PROXY,
domain = arrayListOf("domain:googleapis.cn", "domain:gstatic.com")
)
when (routingMode) {
ERoutingMode.BYPASS_LAN.value -> {
routingGeo("", "private", TAG_DIRECT, v2rayConfig)
}
ERoutingMode.BYPASS_MAINLAND.value -> {
routingGeo("", "cn", TAG_DIRECT, v2rayConfig)
v2rayConfig.routing.rules.add(0, googleapisRoute)
}
ERoutingMode.BYPASS_LAN_MAINLAND.value -> {
routingGeo("", "private", TAG_DIRECT, v2rayConfig)
routingGeo("", "cn", TAG_DIRECT, v2rayConfig)
v2rayConfig.routing.rules.add(0, googleapisRoute)
}
ERoutingMode.GLOBAL_DIRECT.value -> {
val globalDirect = V2rayConfig.RoutingBean.RulesBean(
outboundTag = TAG_DIRECT,
)
if (v2rayConfig.routing.domainStrategy != "IPIfNonMatch") {
globalDirect.port = "0-65535"
} else {
globalDirect.ip = arrayListOf("0.0.0.0/0", "::/0")
}
v2rayConfig.routing.rules.add(globalDirect)
}
}
if (routingMode != ERoutingMode.GLOBAL_DIRECT.value) {
val globalProxy = V2rayConfig.RoutingBean.RulesBean(
outboundTag = TAG_PROXY,
)
if (v2rayConfig.routing.domainStrategy != "IPIfNonMatch") {
globalProxy.port = "0-65535"
} else {
globalProxy.ip = arrayListOf("0.0.0.0/0", "::/0")
}
v2rayConfig.routing.rules.add(globalProxy)
}
} catch (e: Exception) {
e.printStackTrace()
return false
@@ -268,96 +182,44 @@ object V2rayConfigUtil {
return true
}
private fun routingGeo(
ipOrDomain: String,
code: String,
tag: String,
v2rayConfig: V2rayConfig
) {
private fun routingUserRule(item: RulesetItem?, v2rayConfig: V2rayConfig) {
try {
if (!TextUtils.isEmpty(code)) {
//IP
if (ipOrDomain == "ip" || ipOrDomain == "") {
val rulesIP = V2rayConfig.RoutingBean.RulesBean()
rulesIP.outboundTag = tag
rulesIP.ip = ArrayList()
rulesIP.ip?.add("geoip:$code")
v2rayConfig.routing.rules.add(rulesIP)
}
if (ipOrDomain == "domain" || ipOrDomain == "") {
//Domain
val rulesDomain = V2rayConfig.RoutingBean.RulesBean()
rulesDomain.outboundTag = tag
rulesDomain.domain = ArrayList()
rulesDomain.domain?.add("geosite:$code")
v2rayConfig.routing.rules.add(rulesDomain)
}
if (item == null || !item.enabled) {
return
}
val rule = Gson().fromJson(Gson().toJson(item), RulesBean::class.java) ?: return
v2rayConfig.routing.rules.add(rule)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun routingUserRule(userRule: String, tag: String, v2rayConfig: V2rayConfig) {
try {
if (!TextUtils.isEmpty(userRule)) {
//Domain
val rulesDomain = V2rayConfig.RoutingBean.RulesBean()
rulesDomain.outboundTag = tag
rulesDomain.domain = ArrayList()
private fun userRule2Domain(tag: String): ArrayList<String> {
val domain = ArrayList<String>()
//IP
val rulesIP = V2rayConfig.RoutingBean.RulesBean()
rulesIP.outboundTag = tag
rulesIP.ip = ArrayList()
userRule.split(",").map { it.trim() }.forEach {
if (it.startsWith("ext:") && it.contains("geoip")) {
rulesIP.ip?.add(it)
} else if (Utils.isIpAddress(it) || it.startsWith("geoip:")) {
rulesIP.ip?.add(it)
} else if (it.isNotEmpty()) {
rulesDomain.domain?.add(it)
val rulesetItems = MmkvManager.decodeRoutingRulesets()
rulesetItems?.forEach { key ->
if (key != null && key.enabled && key.outboundTag == tag && !key.domain.isNullOrEmpty()) {
key.domain?.forEach {
if (it.startsWith("geosite:") || it.startsWith("domain:")) {
domain.add(it)
}
}
if ((rulesDomain.domain?.size ?: 0) > 0) {
v2rayConfig.routing.rules.add(rulesDomain)
}
if ((rulesIP.ip?.size ?: 0) > 0) {
v2rayConfig.routing.rules.add(rulesIP)
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun userRule2Domain(userRule: String): ArrayList<String> {
val domain = ArrayList<String>()
userRule.split(",").map { it.trim() }.forEach {
if (it.startsWith("geosite:") || it.startsWith("domain:")) {
domain.add(it)
}
}
return domain
}
/**
* Custom Dns
*/
private fun customLocalDns(v2rayConfig: V2rayConfig): Boolean {
try {
if (settingsStorage?.decodeBool(AppConfig.PREF_FAKE_DNS_ENABLED) == true) {
val geositeCn = arrayListOf("geosite:cn")
val proxyDomain = userRule2Domain(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_AGENT)
.orEmpty()
)
val directDomain = userRule2Domain(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_DIRECT)
.orEmpty()
)
val proxyDomain = userRule2Domain(TAG_PROXY)
val directDomain = userRule2Domain(TAG_DIRECT)
// fakedns with all domains to make it always top priority
v2rayConfig.dns.servers?.add(
0,
@@ -428,10 +290,7 @@ object V2rayConfigUtil {
//remote Dns
val remoteDns = Utils.getRemoteDnsServers()
val proxyDomain = userRule2Domain(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_AGENT)
.orEmpty()
)
val proxyDomain = userRule2Domain(TAG_PROXY)
remoteDns.forEach {
servers.add(it)
}
@@ -448,16 +307,9 @@ object V2rayConfigUtil {
// domestic DNS
val domesticDns = Utils.getDomesticDnsServers()
val directDomain = userRule2Domain(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_DIRECT)
.orEmpty()
)
val routingMode = settingsStorage?.decodeString(AppConfig.PREF_ROUTING_MODE)
?: ERoutingMode.BYPASS_LAN_MAINLAND.value
val isCnRoutingMode =
(routingMode == ERoutingMode.BYPASS_MAINLAND.value || routingMode == ERoutingMode.BYPASS_LAN_MAINLAND.value)
val directDomain = userRule2Domain(TAG_DIRECT)
val isCnRoutingMode = directDomain.contains("geosite:cn")
val geoipCn = arrayListOf("geoip:cn")
if (directDomain.size > 0) {
servers.add(
V2rayConfig.DnsBean.ServersBean(
@@ -468,17 +320,6 @@ object V2rayConfigUtil {
)
)
}
if (isCnRoutingMode) {
val geositeCn = arrayListOf("geosite:cn")
servers.add(
V2rayConfig.DnsBean.ServersBean(
domesticDns.first(),
53,
geositeCn,
geoipCn
)
)
}
if (Utils.isPureIpAddress(domesticDns.first())) {
v2rayConfig.routing.rules.add(
@@ -492,10 +333,7 @@ object V2rayConfigUtil {
}
//block dns
val blkDomain = userRule2Domain(
settingsStorage?.decodeString(AppConfig.PREF_V2RAY_ROUTING_BLOCKED)
.orEmpty()
)
val blkDomain = userRule2Domain(TAG_BLOCKED)
if (blkDomain.size > 0) {
hosts.putAll(blkDomain.map { it to "127.0.0.1" })
}
@@ -539,6 +377,7 @@ object V2rayConfigUtil {
val protocol = outbound.protocol
if (protocol.equals(EConfigType.SHADOWSOCKS.name, true)
|| protocol.equals(EConfigType.SOCKS.name, true)
|| protocol.equals(EConfigType.HTTP.name, true)
|| protocol.equals(EConfigType.TROJAN.name, true)
|| protocol.equals(EConfigType.WIREGUARD.name, true)
) {
@@ -641,9 +480,12 @@ object V2rayConfigUtil {
interval = settingsStorage?.decodeString(AppConfig.PREF_FRAGMENT_INTERVAL)
?: "10-20"
),
noise = V2rayConfig.OutboundBean.OutSettingsBean.NoiseBean(
packet = "rand:100-200",
delay = "10-20",
noises = listOf(
V2rayConfig.OutboundBean.OutSettingsBean.NoiseBean(
type = "rand",
packet = "100-200",
delay = "10-20",
)
),
)
fragmentOutbound.streamSettings = V2rayConfig.OutboundBean.StreamSettingsBean(
@@ -665,4 +507,64 @@ object V2rayConfigUtil {
}
return true
}
}
private fun moreOutbounds(v2rayConfig: V2rayConfig, subscriptionId: String): Pair<Boolean, String> {
val returnPair = Pair(false, "")
var domainPort: String = ""
//fragment proxy
if (settingsStorage?.decodeBool(AppConfig.PREF_FRAGMENT_ENABLED, false) == true) {
return returnPair
}
if (subscriptionId.isNullOrEmpty()) {
return returnPair
}
try {
val subItem = MmkvManager.decodeSubscription(subscriptionId) ?: return returnPair
//current proxy
val outbound = v2rayConfig.outbounds[0]
//Previous proxy
val prevNode = SettingsManager.getServerViaRemarks(subItem.prevProfile)
if (prevNode != null) {
val prevOutbound = prevNode.getProxyOutbound()
if (prevOutbound != null) {
updateOutboundWithGlobalSettings(prevOutbound)
prevOutbound.tag = TAG_PROXY + "2"
v2rayConfig.outbounds.add(prevOutbound)
outbound.streamSettings?.sockopt =
V2rayConfig.OutboundBean.StreamSettingsBean.SockoptBean(
dialerProxy = prevOutbound.tag
)
domainPort = prevOutbound.getServerAddressAndPort()
}
}
//Next proxy
val nextNode = SettingsManager.getServerViaRemarks(subItem.nextProfile)
if (nextNode != null) {
val nextOutbound = nextNode.getProxyOutbound()
if (nextOutbound != null) {
updateOutboundWithGlobalSettings(nextOutbound)
nextOutbound.tag = TAG_PROXY
v2rayConfig.outbounds.add(0, nextOutbound)
outbound.tag = TAG_PROXY + "1"
nextOutbound.streamSettings?.sockopt =
V2rayConfig.OutboundBean.StreamSettingsBean.SockoptBean(
dialerProxy = outbound.tag
)
}
}
} catch (e: Exception) {
e.printStackTrace()
return returnPair
}
if (domainPort.isNotEmpty()) {
return Pair(true, domainPort)
}
return returnPair
}
}

View File

@@ -1,23 +1,16 @@
package com.v2ray.ang.util.fmt
import android.text.TextUtils
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.dto.EConfigType
import com.v2ray.ang.dto.ServerConfig
import com.v2ray.ang.dto.V2rayConfig
import com.v2ray.ang.extension.idnHost
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import java.net.URI
object TrojanFmt {
private val settingsStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SETTING,
MMKV.MULTI_PROCESS_MODE
)
}
fun parseTrojan(str: String): ServerConfig {
var allowInsecure = settingsStorage?.decodeBool(AppConfig.PREF_ALLOW_INSECURE) ?: false

View File

@@ -1,23 +1,16 @@
package com.v2ray.ang.util.fmt
import android.text.TextUtils
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.dto.EConfigType
import com.v2ray.ang.dto.ServerConfig
import com.v2ray.ang.dto.V2rayConfig
import com.v2ray.ang.extension.idnHost
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import java.net.URI
object VlessFmt {
private val settingsStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SETTING,
MMKV.MULTI_PROCESS_MODE
)
}
fun parseVless(str: String): ServerConfig? {
var allowInsecure = settingsStorage?.decodeBool(AppConfig.PREF_ALLOW_INSECURE) ?: false

View File

@@ -3,23 +3,17 @@ package com.v2ray.ang.util.fmt
import android.text.TextUtils
import android.util.Log
import com.google.gson.Gson
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.dto.EConfigType
import com.v2ray.ang.dto.ServerConfig
import com.v2ray.ang.dto.V2rayConfig
import com.v2ray.ang.dto.VmessQRCode
import com.v2ray.ang.extension.idnHost
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
import java.net.URI
object VmessFmt {
private val settingsStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE
)
}
fun parseVmess(str: String): ServerConfig? {
if (str.indexOf('?') > 0 && str.indexOf('&') > 0) {

View File

@@ -20,15 +20,12 @@ import com.v2ray.ang.dto.EConfigType
import com.v2ray.ang.dto.ProfileItem
import com.v2ray.ang.dto.ServerConfig
import com.v2ray.ang.dto.ServersCache
import com.v2ray.ang.dto.SubscriptionItem
import com.v2ray.ang.dto.V2rayConfig
import com.v2ray.ang.extension.toast
import com.v2ray.ang.util.AngConfigManager
import com.v2ray.ang.util.AngConfigManager.updateConfigViaSub
import com.v2ray.ang.util.MessageUtil
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.KEY_ANG_CONFIGS
import com.v2ray.ang.util.MmkvManager.subStorage
import com.v2ray.ang.util.SpeedtestUtil
import com.v2ray.ang.util.Utils
import com.v2ray.ang.util.V2rayConfigUtil
@@ -104,7 +101,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
config.fullConfig = Gson().fromJson(server, V2rayConfig::class.java)
config.remarks = config.fullConfig?.remarks ?: System.currentTimeMillis().toString()
val key = MmkvManager.encodeServerConfig("", config)
MmkvManager.serverRawStorage?.encode(key, server)
MmkvManager.encodeServerRaw(key, server)
serverList.add(0, key)
val profile = ProfileItem(
configType = config.configType,
@@ -125,7 +122,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
fun swapServer(fromPosition: Int, toPosition: Int) {
Collections.swap(serverList, fromPosition, toPosition)
Collections.swap(serversCache, fromPosition, toPosition)
MmkvManager.mainStorage?.encode(KEY_ANG_CONFIGS, Gson().toJson(serverList))
MmkvManager.encodeServerList(serverList)
}
@Synchronized
@@ -159,12 +156,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
if (subscriptionId.isNullOrEmpty()) {
return AngConfigManager.updateConfigViaSubAll()
} else {
val json = subStorage?.decodeString(subscriptionId)
if (!json.isNullOrBlank()) {
return updateConfigViaSub(Pair(subscriptionId, Gson().fromJson(json, SubscriptionItem::class.java)))
} else {
return 0
}
val subItem = MmkvManager.decodeSubscription(subscriptionId) ?: return 0
return updateConfigViaSub(Pair(subscriptionId, subItem))
}
}
@@ -317,7 +310,22 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
}
fun sortByTestResults() {
MmkvManager.sortByTestResults()
data class ServerDelay(var guid: String, var testDelayMillis: Long)
val serverDelays = mutableListOf<ServerDelay>()
val serverList = MmkvManager.decodeServerList()
serverList.forEach { key ->
val delay = MmkvManager.decodeServerAffiliationInfo(key)?.testDelayMillis ?: 0L
serverDelays.add(ServerDelay(key, if (delay <= 0L) 999999 else delay))
}
serverDelays.sortBy { it.testDelayMillis }
serverDelays.forEach {
serverList.remove(it.guid)
serverList.add(it.guid)
}
MmkvManager.encodeServerList(serverList)
}

View File

@@ -5,21 +5,13 @@ import android.content.SharedPreferences
import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.preference.PreferenceManager
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.Utils
class SettingsViewModel(application: Application) : AndroidViewModel(application),
SharedPreferences.OnSharedPreferenceChangeListener {
private val settingsStorage by lazy {
MMKV.mmkvWithID(
MmkvManager.ID_SETTING,
MMKV.MULTI_PROCESS_MODE
)
}
fun startListenPreferenceChange() {
PreferenceManager.getDefaultSharedPreferences(getApplication())
.registerOnSharedPreferenceChangeListener(this)
@@ -47,10 +39,6 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application
AppConfig.PREF_LANGUAGE,
AppConfig.PREF_UI_MODE_NIGHT,
AppConfig.PREF_ROUTING_DOMAIN_STRATEGY,
AppConfig.PREF_ROUTING_MODE,
AppConfig.PREF_V2RAY_ROUTING_AGENT,
AppConfig.PREF_V2RAY_ROUTING_BLOCKED,
AppConfig.PREF_V2RAY_ROUTING_DIRECT,
AppConfig.SUBSCRIPTION_AUTO_UPDATE_INTERVAL,
AppConfig.PREF_FRAGMENT_PACKETS,
AppConfig.PREF_FRAGMENT_LENGTH,

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M740,161a112.1,112.1 0,0 0,-33.5 218.9v95.9L320,602.4L320,318.1a112.1,112.1 0,1 0,-148 -106.1c0,49.3 31.8,91 76,106.1v387.9a112.1,112.1 0,1 0,148 106.1c0,-49.2 -31.8,-91 -76,-106.1v-27.8l423.5,-138.7a50.6,50.6 0,0 0,34.9 -48.2L778.4,378.2c42.9,-15.8 73.6,-57 73.6,-105.2 0,-61.8 -50.2,-112 -112,-112zM236,212a48,48 0,1 1,96 0,48 48,0 0,1 -96,0zM332,812a48,48 0,1 1,-96 0,48 48,0 0,1 96,0zM740,321a48,48 0,1 1,0 -96,48 48,0 0,1 0,96z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="#FF000000"
android:pathData="M740,161a112.1,112.1 0,0 0,-33.5 218.9v95.9L320,602.4L320,318.1a112.1,112.1 0,1 0,-148 -106.1c0,49.3 31.8,91 76,106.1v387.9a112.1,112.1 0,1 0,148 106.1c0,-49.2 -31.8,-91 -76,-106.1v-27.8l423.5,-138.7a50.6,50.6 0,0 0,34.9 -48.2L778.4,378.2c42.9,-15.8 73.6,-57 73.6,-105.2 0,-61.8 -50.2,-112 -112,-112zM236,212a48,48 0,1 1,96 0,48 48,0 0,1 -96,0zM332,812a48,48 0,1 1,-96 0,48 48,0 0,1 96,0zM740,321a48,48 0,1 1,0 -96,48 48,0 0,1 0,96z" />
</vector>

View File

@@ -23,7 +23,7 @@
android:background="?attr/selectableItemBackground"
android:gravity="center|start"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<ImageView
android:layout_width="@dimen/png_height"
@@ -34,7 +34,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="16dp">
android:paddingStart="@dimen/padding_start">
<TextView
android:layout_width="wrap_content"
@@ -46,7 +46,7 @@
android:id="@+id/tv_backup_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:maxLines="4"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
@@ -63,7 +63,7 @@
android:background="?attr/selectableItemBackground"
android:gravity="center|start"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<ImageView
android:layout_width="@dimen/png_height"
@@ -73,7 +73,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingStart="@dimen/padding_start"
android:text="@string/title_configuration_share"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
@@ -87,7 +87,7 @@
android:background="?attr/selectableItemBackground"
android:gravity="center|start"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<ImageView
android:layout_width="@dimen/png_height"
@@ -97,7 +97,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingStart="@dimen/padding_start"
android:text="@string/title_configuration_restore"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
@@ -108,7 +108,7 @@
android:layout_height="match_parent"
android:gravity="top"
android:orientation="vertical"
android:paddingTop="16dp">
android:paddingTop="@dimen/padding_start">
<LinearLayout
android:id="@+id/layout_soure_ccode"
@@ -119,7 +119,7 @@
android:background="?attr/selectableItemBackground"
android:gravity="center|start"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<ImageView
android:layout_width="@dimen/png_height"
@@ -129,7 +129,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingStart="@dimen/padding_start"
android:text="@string/title_source_code"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
@@ -143,7 +143,7 @@
android:background="?attr/selectableItemBackground"
android:gravity="center|start"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<ImageView
android:layout_width="@dimen/png_height"
@@ -153,7 +153,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingStart="@dimen/padding_start"
android:text="@string/title_pref_feedback"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
@@ -168,7 +168,7 @@
android:background="?attr/selectableItemBackground"
android:gravity="center|start"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<ImageView
android:layout_width="@dimen/png_height"
@@ -178,7 +178,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingStart="@dimen/padding_start"
android:text="@string/title_tg_channel"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
@@ -192,7 +192,7 @@
android:background="?attr/selectableItemBackground"
android:gravity="center|start"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<ImageView
android:layout_width="@dimen/png_height"
@@ -202,7 +202,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingStart="@dimen/padding_start"
android:text="@string/title_privacy_policy"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
@@ -212,7 +212,7 @@
android:layout_height="@dimen/server_height"
android:gravity="center"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<TextView
android:id="@+id/tv_version"

View File

@@ -11,8 +11,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="20dp"
android:paddingEnd="20dp">
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end">
<LinearLayout
android:layout_width="match_parent"
@@ -43,7 +43,7 @@
android:id="@+id/switch_per_app_proxy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp" />
android:paddingStart="@dimen/padding_start" />
</LinearLayout>
@@ -67,7 +67,7 @@
android:id="@+id/switch_bypass_apps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp" />
android:paddingStart="@dimen/padding_start" />
</LinearLayout>
</LinearLayout>

View File

@@ -3,8 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end"
tools:context=".ui.LogcatActivity">
<ProgressBar

View File

@@ -77,7 +77,7 @@
android:layout_height="wrap_content"
android:maxLines="2"
android:minLines="1"
android:paddingStart="16dp"
android:paddingStart="@dimen/padding_start"
android:text="@string/connection_test_pending"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />

View File

@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.SubSettingActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/layout_margin_top_height">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_setting_remarks" />
<EditText
android:id="@+id/et_remarks"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_rule_title"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_domain" />
<EditText
android:id="@+id/et_domain"
android:layout_width="match_parent"
android:maxLines="10"
android:hint="@string/routing_settings_tips"
android:layout_height="wrap_content"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_ip" />
<EditText
android:id="@+id/et_ip"
android:maxLines="10"
android:hint="@string/routing_settings_tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_port" />
<EditText
android:id="@+id/et_port"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_protocol" />
<EditText
android:id="@+id/et_protocol"
android:layout_width="match_parent"
android:hint="@string/routing_settings_protocol_tip"
android:layout_height="@dimen/edit_height"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_network" />
<EditText
android:id="@+id/et_network"
android:layout_width="match_parent"
android:hint="@string/routing_settings_network_tip"
android:layout_height="@dimen/edit_height"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_outbound_tag" />
<Spinner
android:id="@+id/sp_outbound_tag"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/outbound_tag" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/layout_margin_top_height"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical" />
</LinearLayout>
</ScrollView>

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ui.RoutingSettingActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/cardview_margin"
android:orientation="horizontal"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_domain_strategy" />
<Spinner
android:id="@+id/sp_domain_strategy"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/routing_domain_strategy" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/padding_start"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:layout_marginBottom="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_rule_title"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/item_recycler_routing_setting" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>

View File

@@ -1,16 +0,0 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@@ -47,6 +47,31 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sub_setting_url" />
<EditText
android:id="@+id/et_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textMultiLine"
android:maxLines="10"
android:minLines="2"
android:scrollbars="vertical"
tools:ignore="TextFields" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -54,18 +79,17 @@
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="@string/sub_setting_enable" />
<androidx.appcompat.widget.AppCompatCheckBox
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/chk_enable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="2dp"
android:paddingEnd="6dp" />
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end" />
</LinearLayout>
@@ -82,12 +106,12 @@
android:text="@string/sub_auto_update" />
<androidx.appcompat.widget.AppCompatCheckBox
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/auto_update_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="2dp"
android:paddingEnd="6dp" />
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end" />
</LinearLayout>
@@ -98,25 +122,38 @@
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_setting_url" />
android:text="@string/sub_setting_pre_profile" />
<EditText
android:id="@+id/et_url"
android:id="@+id/et_pre_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="top"
android:inputType="textMultiLine"
android:maxLines="10"
android:minLines="5"
android:scrollbars="vertical" />
android:layout_height="@dimen/edit_height"
android:inputType="text"
android:hint="@string/sub_setting_pre_profile_tip" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_setting_next_profile" />
<EditText
android:id="@+id/et_next_profile"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:inputType="text"
android:hint="@string/sub_setting_pre_profile_tip" />
</LinearLayout>
</LinearLayout>
<LinearLayout

View File

@@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:padding="@dimen/padding"
tools:context=".ui.TaskerActivity">
<RelativeLayout

View File

@@ -63,11 +63,10 @@
android:id="@+id/et_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="top"
android:inputType="textMultiLine"
android:maxLines="10"
android:minLines="5"
android:minLines="2"
android:scrollbars="vertical" />
</LinearLayout>

View File

@@ -1,39 +0,0 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.v2ray.ang.ui.RoutingSettingsFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_tips"
android:textColor="@color/color_secondary" />
<EditText
android:id="@+id/et_routing_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="top"
android:inputType="textMultiLine"
android:maxLines="1000"
android:minLines="20"
android:scrollbars="vertical" />
</LinearLayout>
</ScrollView>
</FrameLayout>

View File

@@ -11,10 +11,8 @@
android:id="@+id/icon"
android:layout_width="60dp"
android:layout_height="60dp"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:paddingEnd="10dp"
android:paddingRight="10dp" />
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end" />
<LinearLayout
android:layout_width="0dp"
@@ -22,8 +20,8 @@
android:layout_weight="1.0"
android:gravity="center"
android:orientation="vertical"
android:paddingStart="@dimen/layout_margin_right_height"
android:paddingEnd="@dimen/layout_margin_right_height">
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/name"
@@ -44,9 +42,6 @@
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:paddingStart="2dp"
android:paddingLeft="2dp"
android:paddingEnd="6dp"
android:paddingRight="6dp" />
android:paddingStart="@dimen/padding_start"/>
</LinearLayout>

View File

@@ -12,7 +12,7 @@
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp">
android:padding="@dimen/padding">
<LinearLayout
android:layout_width="match_parent"

View File

@@ -11,7 +11,7 @@
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_margin="@dimen/cardview_margin"
app:cardCornerRadius="5dp">
<LinearLayout
@@ -38,7 +38,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingStart="9dp">
android:paddingStart="@dimen/padding_start">
<LinearLayout
android:layout_width="wrap_content"
@@ -80,7 +80,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingEnd="5dp">
android:paddingEnd="@dimen/padding_end">
<TextView
android:id="@+id/tv_subscription"
@@ -172,7 +172,7 @@
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical"
android:paddingEnd="5dp">
android:paddingEnd="@dimen/padding_end">
<TextView
android:id="@+id/tv_type"

View File

@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/item_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/item_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/cardview_margin"
android:orientation="horizontal"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:id="@+id/info_container"
android:layout_width="match_parent"
android:layout_height="@dimen/sub_height"
android:layout_gravity="center"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:nextFocusRight="@+id/layout_edit"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingStart="@dimen/padding_start">
<TextView
android:id="@+id/remarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
<TextView
android:id="@+id/domainIp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_spacing"
android:lines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<TextView
android:id="@+id/outboundTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_spacing"
android:lines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/sub_height"
android:gravity="center"
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layout_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:nextFocusLeft="@+id/info_container"
android:orientation="vertical"
android:padding="@dimen/layout_margin_spacing">
<ImageView
android:layout_width="@dimen/png_height"
android:layout_height="@dimen/png_height"
app:srcCompat="@drawable/ic_edit_24dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="horizontal">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/chk_enable"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

View File

@@ -6,18 +6,19 @@
android:layout_height="wrap_content"
android:gravity="center_vertical">
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/item_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_margin="@dimen/cardview_margin"
android:orientation="horizontal"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:id="@+id/info_container"
android:layout_width="match_parent"
android:layout_height="@dimen/server_height"
android:layout_height="@dimen/sub_height"
android:layout_gravity="center"
android:clickable="true"
android:focusable="true"
@@ -26,19 +27,12 @@
android:nextFocusRight="@+id/layout_edit"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/chk_enable"
android:layout_width="6dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingStart="9dp">
android:paddingStart="@dimen/padding_start">
<TextView
android:id="@+id/tv_name"
@@ -50,16 +44,29 @@
android:id="@+id/tv_url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="@dimen/layout_margin_spacing"
android:lines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_spacing"
android:orientation="horizontal">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/chk_enable"
android:text="@string/sub_setting_enable"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/server_height"
android:layout_height="@dimen/sub_height"
android:gravity="center"
android:orientation="horizontal">

View File

@@ -8,7 +8,7 @@
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_margin="@dimen/cardview_margin"
app:cardCornerRadius="5dp">
<LinearLayout
@@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingStart="9dp">
android:paddingStart="@dimen/padding_start">
<LinearLayout
android:layout_width="wrap_content"

View File

@@ -5,7 +5,7 @@
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp">
android:padding="@dimen/padding">
<ProgressBar
android:id="@+id/pb_waiting"

View File

@@ -5,10 +5,7 @@
android:background="@drawable/nav_header_bg"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
android:padding="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"

View File

@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:orientation="vertical">
<LinearLayout

View File

@@ -18,7 +18,7 @@
android:id="@+id/image_switch"
android:layout_width="45dp"
android:layout_height="45dp"
android:padding="12dp"
android:padding="@dimen/padding"
app:srcCompat="@drawable/ic_stat_name" />
</LinearLayout>

View File

@@ -13,9 +13,9 @@
android:icon="@drawable/ic_settings_24dp"
android:title="@string/title_settings" />
<item
android:id="@+id/user_asset_setting"
android:icon="@drawable/ic_file_24dp"
android:title="@string/title_user_asset_setting" />
android:id="@+id/routing_setting"
android:icon="@drawable/ic_routing_24dp"
android:title="@string/routing_settings_title" />
</group>
<group android:id="@+id/group_id2">

View File

@@ -36,6 +36,10 @@
android:id="@+id/import_manually_socks"
android:title="@string/menu_item_import_config_manually_socks"
app:showAsAction="never" />
<item
android:id="@+id/import_manually_http"
android:title="@string/menu_item_import_config_manually_http"
app:showAsAction="never" />
<item
android:id="@+id/import_manually_trojan"
android:title="@string/menu_item_import_config_manually_trojan"

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/save_routing"
android:icon="@drawable/ic_action_done"
android:title="@string/routing_settings_save"
app:showAsAction="always" />
<item
android:id="@+id/del_routing"
android:icon="@drawable/ic_delete_24dp"
android:title="@string/routing_settings_delete"
app:showAsAction="never" />
<item
android:id="@+id/scan_replace"
android:title="@string/routing_settings_scan_replace"
app:showAsAction="never" />
<item
android:id="@+id/scan_append"
android:title="@string/routing_settings_scan_append"
app:showAsAction="never" />
<item
android:id="@+id/default_rules"
android:title="@string/routing_settings_default_rules"
app:showAsAction="never" />
</menu>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/add_rule"
android:icon="@drawable/ic_add_24dp"
android:title="@string/routing_settings_add_rule"
app:showAsAction="ifRoom" />
<item
android:id="@+id/user_asset_setting"
android:icon="@drawable/ic_file_24dp"
android:title="@string/title_user_asset_setting" />
<item
android:id="@+id/import_rulesets"
android:title="@string/routing_settings_import_rulesets"
app:showAsAction="never" />
</menu>

View File

@@ -25,10 +25,11 @@
<string name="menu_item_del_config">حذف التكوين</string>
<string name="menu_item_import_config_qrcode">استيراد التكوين من رمز الاستجابة السريعة (QRcode)</string>
<string name="menu_item_import_config_clipboard">استيراد التكوين من الحافظة</string>
<string name="menu_item_import_config_manually_vmess">الكتابة يدويًا [Vmess]</string>
<string name="menu_item_import_config_manually_vmess">الكتابة يدويًا [VMess]</string>
<string name="menu_item_import_config_manually_vless">الكتابة يدويًا [VLESS]</string>
<string name="menu_item_import_config_manually_ss">الكتابة يدويًا [Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">الكتابة يدويًا [Socks]</string>
<string name="menu_item_import_config_manually_socks">الكتابة يدويًا [SOCKS]</string>
<string name="menu_item_import_config_manually_http">Type manually[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">الكتابة يدويًا [Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">الكتابة يدويًا [Wireguard]</string>
<string name="menu_item_import_config_custom">تكوين مخصص</string>
@@ -158,11 +159,6 @@
<string name="title_pref_prefer_ipv6">تفضيل IPv6</string>
<string name="summary_pref_prefer_ipv6">تفضيل عنوان IPv6 وطرق التوجيه</string>
<string name="title_pref_routing">التوجيه</string>
<string name="title_pref_routing_domain_strategy">استراتيجية النطاق</string>
<string name="title_pref_routing_mode">قواعد محددة مسبقًا</string>
<string name="title_pref_routing_custom">قواعد مخصصة</string>
<string name="title_pref_remote_dns">DNS البعيد (udp/tcp/https/quic) (اختياري)</string>
<string name="summary_pref_remote_dns">DNS</string>
@@ -236,6 +232,9 @@
<string name="sub_setting_url">عنوان URL اختياري</string>
<string name="sub_setting_enable">تفعيل التحديث</string>
<string name="sub_auto_update">تفعيل التحديث التلقائي</string>
<string name="sub_setting_pre_profile">Previous proxy remarks</string>
<string name="sub_setting_next_profile">Next proxy remarks</string>
<string name="sub_setting_pre_profile_tip">The remarks exists and is unique</string>
<string name="title_sub_update">تحديث الاشتراك (أول خطوة)</string>
<string name="title_ping_all_server">Tcping لجميع الإعدادات</string>
<string name="title_real_ping_all_server"> اختبر جميع الإعدادات (3)</string>
@@ -248,13 +247,15 @@
<string name="tasker_start_service">بدء الخدمة</string>
<string name="tasker_setting_confirm">تأكيد</string>
<string name="routing_settings_domain_strategy">استراتيجية النطاق</string>
<string name="routing_settings_title">إعدادات التوجيه</string>
<string name="routing_settings_tips">مفصولة بفواصل (،)، تذكر الحفظ</string>
<string name="routing_settings_save">حفظ</string>
<string name="routing_settings_delete">مسح</string>
<string name="routing_settings_scan_replace">فحص واستبدال</string>
<string name="routing_settings_scan_append">فحص وإضافة</string>
<string name="routing_settings_default_rules"> تعيين قواعد توجيه افتراضية</string>
<string name="routing_settings_rule_title">Routing Rule Settings</string>
<string name="routing_settings_add_rule">Add rule</string>
<string name="routing_settings_import_rulesets">Import ruleset</string>
<string name="routing_settings_import_rulesets_tip">Existing rulesets will be deleted, are you sure to continue?</string>
<string name="connection_test_pending">التحقق من الاتصال</string>
<string name="connection_test_testing">يجري الاختبار…</string>
@@ -284,20 +285,6 @@
<item>تصدير إلى الحافظة</item>
</string-array>
<string-array name="routing_tag">
<item>عنوان URL أو IP الوكيل</item>
<item>عنوان URL أو IP المباشر</item>
<item>عنوان URL أو IP المحظور</item>
</string-array>
<string-array name="routing_mode">
<item>وكيل عام</item>
<item>تجاوز عنوان الشبكة المحلية ثم الوكيل</item>
<item>تجاوز عنوان البر الرئيسي ثم الوكيل</item>
<item>تجاوز عنوان الشبكة المحلية والبر الرئيسي ثم الوكيل</item>
<item>مباشر عام</item>
</string-array>
<string-array name="mode_entries">
<item>VPN</item>
<item>بروكسي فقط</item>

View File

@@ -25,10 +25,11 @@
<string name="menu_item_del_config">কনফিগারেশন মুছুন</string>
<string name="menu_item_import_config_qrcode">QR কোড থেকে কনফিগারেশন আমদানি করুন</string>
<string name="menu_item_import_config_clipboard">ক্লিপবোর্ড থেকে কনফিগারেশন আমদানি করুন</string>
<string name="menu_item_import_config_manually_vmess">ম্যানুয়ালি টাইপ করুন [Vmess]</string>
<string name="menu_item_import_config_manually_vmess">ম্যানুয়ালি টাইপ করুন [VMess]</string>
<string name="menu_item_import_config_manually_vless">ম্যানুয়ালি টাইপ করুন [VLESS]</string>
<string name="menu_item_import_config_manually_ss">ম্যানুয়ালি টাইপ করুন [Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">ম্যানুয়ালি টাইপ করুন [Socks]</string>
<string name="menu_item_import_config_manually_socks">ম্যানুয়ালি টাইপ করুন [SOCKS]</string>
<string name="menu_item_import_config_manually_http">Type manually[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">ম্যানুয়ালি টাইপ করুন [Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">ম্যানুয়ালি টাইপ করুন [Wireguard]</string>
<string name="menu_item_import_config_custom">কাস্টম কনফিগারেশন</string>
@@ -157,11 +158,6 @@
<string name="title_pref_prefer_ipv6">IPv6 অগ্রাধিকার দিন</string>
<string name="summary_pref_prefer_ipv6">IPv6 ঠিকানা এবং রুটকে অগ্রাধিকার দিন</string>
<string name="title_pref_routing">রাউটিং</string>
<string name="title_pref_routing_domain_strategy">ডোমেইন কৌশল</string>
<string name="title_pref_routing_mode">পূর্বনির্ধারিত নিয়ম</string>
<string name="title_pref_routing_custom">কাস্টম নিয়ম</string>
<string name="title_pref_remote_dns">রিমোট DNS (udp/tcp/https/quic)(ঐচ্ছিক)</string>
<string name="summary_pref_remote_dns">DNS</string>
@@ -234,6 +230,9 @@
<string name="sub_setting_url">ঐচ্ছিক URL</string>
<string name="sub_setting_enable">আপডেট সক্রিয় করুন</string>
<string name="sub_auto_update">স্বয়ংক্রিয় আপডেট সক্রিয় করুন</string>
<string name="sub_setting_pre_profile">Previous proxy remarks</string>
<string name="sub_setting_next_profile">Next proxy remarks</string>
<string name="sub_setting_pre_profile_tip">The remarks exists and is unique</string>
<string name="title_sub_update">সাবস্ক্রিপশন আপডেট</string>
<string name="title_ping_all_server">সব কনফিগারেশন TCPing</string>
<string name="title_real_ping_all_server">সব কনফিগারেশন প্রকৃত বিলম্ব</string>
@@ -245,13 +244,15 @@
<string name="tasker_start_service">সার্ভিস শুরু করুন</string>
<string name="tasker_setting_confirm">নিশ্চিত করুন</string>
<string name="routing_settings_domain_strategy">ডোমেইন কৌশল</string>
<string name="routing_settings_title">রাউটিং সেটিংস</string>
<string name="routing_settings_tips">কমা (,) দ্বারা আলাদা করুন, মনে রাখবেন সেভ করতে</string>
<string name="routing_settings_save">সেভ করুন</string>
<string name="routing_settings_delete">মুছে ফেলুন</string>
<string name="routing_settings_scan_replace">স্ক্যান করুন এবং প্রতিস্থাপন করুন</string>
<string name="routing_settings_scan_append">স্ক্যান করুন এবং যোগ করুন</string>
<string name="routing_settings_default_rules"> ডিফল্ট রাউটিং নিয়ম সেট করুন</string>
<string name="routing_settings_rule_title">Routing Rule Settings</string>
<string name="routing_settings_add_rule">Add rule</string>
<string name="routing_settings_import_rulesets">Import ruleset</string>
<string name="routing_settings_import_rulesets_tip">Existing rulesets will be deleted, are you sure to continue?</string>
<string name="connection_test_pending">সংযোগ পরীক্ষা করুন</string>
<string name="connection_test_testing">পরীক্ষা চলছে…</string>
@@ -280,20 +281,6 @@
<item>ক্লিপবোর্ডে রপ্তানি করুন</item>
</string-array>
<string-array name="routing_tag">
<item>প্রক্সি URL বা IP</item>
<item>ডাইরেক্ট URL বা IP</item>
<item>ব্লকড URL বা IP</item>
</string-array>
<string-array name="routing_mode">
<item>গ্লোবাল প্রোক্সি</item>
<item>LAN ঠিকানা বাইপাস করে তারপর প্রোক্সি</item>
<item>মেইনল্যান্ড ঠিকানা বাইপাস করে তারপর প্রোক্সি</item>
<item>LAN এবং মেইনল্যান্ড ঠিকানা বাইপাস করে তারপর প্রোক্সি</item>
<item>গ্লোবাল ডাইরেক্ট</item>
</string-array>
<string-array name="mode_entries">
<item>VPN</item>
<item>শুধুমাত্র প্রোক্সি</item>

View File

@@ -24,10 +24,11 @@
<string name="menu_item_del_config">حذف کانفیگ</string>
<string name="menu_item_import_config_qrcode">کانفیگ را از QRcode وارد کنید</string>
<string name="menu_item_import_config_clipboard">کانفیگ را از کلیپ‌بورد وارد کنید</string>
<string name="menu_item_import_config_manually_vmess">تایپ دستی[Vmess]</string>
<string name="menu_item_import_config_manually_vmess">تایپ دستی[VMess]</string>
<string name="menu_item_import_config_manually_vless">تایپ دستی[VLESS]</string>
<string name="menu_item_import_config_manually_ss">تایپ دستی[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">تایپ دستی[Socks]</string>
<string name="menu_item_import_config_manually_socks">تایپ دستی[SOCKS]</string>
<string name="menu_item_import_config_manually_http">Type manually[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">تایپ دستی[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">[Wireguard]تایپ دستی</string>
<string name="menu_item_import_config_custom">کانفیگ سفارشی</string>
@@ -155,11 +156,6 @@
<string name="title_pref_prefer_ipv6">ترجیح دادن IPv6</string>
<string name="summary_pref_prefer_ipv6">ترجیح دادن نشانی و مسیر های IPv6</string>
<string name="title_pref_routing">مسیریابی</string>
<string name="title_pref_routing_domain_strategy">استراتژی دامنه</string>
<string name="title_pref_routing_mode">قوانین از پیش تعریف شده</string>
<string name="title_pref_routing_custom">قوانین سفارشی</string>
<string name="title_pref_remote_dns">DNS از راه دور (اختیاری)</string>
<string name="summary_pref_remote_dns">DNS</string>
@@ -232,6 +228,9 @@
<string name="sub_setting_url">نشانی اینترنتی اختیاری</string>
<string name="sub_setting_enable">فعال کردن به‌روزرسانی</string>
<string name="sub_auto_update">فعال سازی به‌روزرسانی خودکار</string>
<string name="sub_setting_pre_profile">Previous proxy remarks</string>
<string name="sub_setting_next_profile">Next proxy remarks</string>
<string name="sub_setting_pre_profile_tip">The remarks exists and is unique</string>
<string name="title_sub_update">به‌روزرسانی اشتراک</string>
<string name="title_ping_all_server">Tcping همه کانفیگ</string>
<string name="title_real_ping_all_server">تاخیر واقعی همه کانفیگ</string>
@@ -244,13 +243,15 @@
<string name="tasker_start_service">شروع خدمات</string>
<string name="tasker_setting_confirm">تایید</string>
<string name="routing_settings_domain_strategy">استراتژی دامنه</string>
<string name="routing_settings_title">تنظیمات مسیریابی</string>
<string name="routing_settings_tips">با کاما (,) از هم جدا شوند، ذخیره کردن فراموش نشود</string>
<string name="routing_settings_save">ذخیره</string>
<string name="routing_settings_delete">پاک کردن</string>
<string name="routing_settings_scan_replace">اسکن و جایگزین کنید</string>
<string name="routing_settings_scan_append">اسکن و اضافه کنید</string>
<string name="routing_settings_default_rules">قوانین مسیریابی پیش‌فرض را تنظیم کنید</string>
<string name="routing_settings_rule_title">Routing Rule Settings</string>
<string name="routing_settings_add_rule">Add rule</string>
<string name="routing_settings_import_rulesets">Import ruleset</string>
<string name="routing_settings_import_rulesets_tip">Existing rulesets will be deleted, are you sure to continue?</string>
<string name="connection_test_pending">اتصال را بررسی کنید</string>
<string name="connection_test_testing">در حال آزمایش...</string>
@@ -279,20 +280,6 @@
<item>خروجی گرفتن در کلیپ‌بورد</item>
</string-array>
<string-array name="routing_tag">
<item>نشانی اینترنتی یا آی‌پی پروکسی</item>
<item>نشانی اینترنتی یا آی‌پی مستقیم</item>
<item>نشانی اینترنتی یا آی‌پی مسدود شده</item>
</string-array>
<string-array name="routing_mode">
<item>پروکسی سراسری</item>
<item>دور زدن آدرس LAN و سپس پروکسی</item>
<item>دور زدن آدرس mainland و سپس پروکسی</item>
<item>دور زدن LAN و آدرس mainland و سپس پروکسی</item>
<item>مستقیم سراسری</item>
</string-array>
<string-array name="mode_entries">
<item>VPN</item>
<item>فقط پروکسی</item>

View File

@@ -28,6 +28,7 @@
<string name="menu_item_import_config_manually_vless">Ручной ввод VLESS</string>
<string name="menu_item_import_config_manually_ss">Ручной ввод Shadowsocks</string>
<string name="menu_item_import_config_manually_socks">Ручной ввод Socks</string>
<string name="menu_item_import_config_manually_http">Type manually[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Ручной ввод Trojan</string>
<string name="menu_item_import_config_manually_wireguard">Ручной ввод Wireguard</string>
<string name="menu_item_import_config_custom">Другой профиль</string>
@@ -76,10 +77,10 @@
<string name="server_lab_security4">Пользователь (необязательно)</string>
<string name="server_lab_encryption">Шифрование</string>
<string name="server_lab_flow">Поток</string>
<string name="server_lab_public_key">PublicKey</string>
<string name="server_lab_public_key">Открытый ключ</string>
<string name="server_lab_short_id">ShortID</string>
<string name="server_lab_spider_x">SpiderX</string>
<string name="server_lab_secret_key">SecretKey</string>
<string name="server_lab_secret_key">Закрытый ключ</string>
<string name="server_lab_reserved">Reserved (необязательно)</string>
<string name="server_lab_local_address">Локальный адрес (необязательно, IPv4/IPv6 через запятую)</string>
<string name="server_lab_local_mtu">MTU (необязательно, по умолчанию 1420)</string>
@@ -106,7 +107,7 @@
<string name="menu_item_download_file">Загрузить файлы</string>
<string name="title_user_asset_add_url">Добавить URL ресурса</string>
<string name="msg_file_not_found">Файл не найден</string>
<string name="msg_remark_is_duplicate">Описание уже существует</string>
<string name="msg_remark_is_duplicate">Название уже существует</string>
<string name="toast_action_not_allowed">Это действие запрещено</string>
@@ -158,11 +159,6 @@
<string name="title_pref_prefer_ipv6">Предпочитать IPv6</string>
<string name="summary_pref_prefer_ipv6">Предпочитать IPv6-адреса и маршрутизацию</string>
<string name="title_pref_routing">Маршрутизация</string>
<string name="title_pref_routing_domain_strategy">Доменная стратегия</string>
<string name="title_pref_routing_mode">Режим маршрутизации</string>
<string name="title_pref_routing_custom">Пользовательские правила</string>
<string name="title_pref_remote_dns">Удалённая DNS (UDP/TCP/HTTPS/QUIC) (необязательно)</string>
<string name="summary_pref_remote_dns">DNS</string>
@@ -236,6 +232,9 @@
<string name="sub_setting_url">URL (необязательно)</string>
<string name="sub_setting_enable">Использовать обновление</string>
<string name="sub_auto_update">Использовать автоматическое обновление</string>
<string name="sub_setting_pre_profile">Название предыдущего прокси</string>
<string name="sub_setting_next_profile">Название следующего прокси</string>
<string name="sub_setting_pre_profile_tip">Убедитесь, что название существует и является уникальным</string>
<string name="title_sub_update">Обновить подписку группы</string>
<string name="title_ping_all_server">Проверка профилей группы</string>
<string name="title_real_ping_all_server">Время отклика профилей группы</string>
@@ -248,13 +247,15 @@
<string name="tasker_start_service">Запуск службы</string>
<string name="tasker_setting_confirm">Подтвердить</string>
<string name="routing_settings_domain_strategy">Доменная стратегия</string>
<string name="routing_settings_title">Настройки маршрутизации</string>
<string name="routing_settings_tips">Введите требуемые IP/URL через запятую. Не забудьте сохранить изменения.</string>
<string name="routing_settings_save">Сохранить</string>
<string name="routing_settings_delete">Очистить</string>
<string name="routing_settings_scan_replace">Сканировать и заменить</string>
<string name="routing_settings_scan_append">Сканировать и добавить</string>
<string name="routing_settings_default_rules">Правила по умолчанию</string>
<string name="routing_settings_rule_title">Настройка правил маршрутизации</string>
<string name="routing_settings_add_rule">Добавить правило</string>
<string name="routing_settings_import_rulesets">Импорт правил</string>
<string name="routing_settings_import_rulesets_tip">Существующие правила будут удалены. Продолжить?</string>
<string name="connection_test_pending">Проверить подключение</string>
<string name="connection_test_testing">Проверка…</string>
@@ -284,20 +285,6 @@
<item>Экспорт в буфер обмена</item>
</string-array>
<string-array name="routing_tag">
<item>Проксируемые</item>
<item>Прямые</item>
<item>Блокируемые</item>
</string-array>
<string-array name="routing_mode">
<item>Все через прокси</item>
<item>Все, кроме LAN через прокси</item>
<item>Все, кроме Китая через прокси</item>
<item>Все, кроме LAN и Китая через прокси</item>
<item>Все напрямую</item>
</string-array>
<string-array name="mode_entries">
<item>VPN</item>
<item>Только прокси</item>
@@ -309,4 +296,10 @@
<item>Тёмная</item>
</string-array>
<string-array name="preset_rulesets">
<item>Белый список Китая</item>
<item>Чёрный список Китая</item>
<item>Общие</item>
</string-array>
</resources>

View File

@@ -24,10 +24,11 @@
<string name="menu_item_del_config">Xoá cấu hình</string>
<string name="menu_item_import_config_qrcode">Nhập cấu hình từ mã QR</string>
<string name="menu_item_import_config_clipboard">Nhập cấu hình từ Clipboard</string>
<string name="menu_item_import_config_manually_vmess">Nhập thủ công [VMESS]</string>
<string name="menu_item_import_config_manually_vmess">Nhập thủ công [VMess]</string>
<string name="menu_item_import_config_manually_vless">Nhập thủ công [VLESS]</string>
<string name="menu_item_import_config_manually_ss">Nhập thủ công [ShadowSocks]</string>
<string name="menu_item_import_config_manually_socks">Nhập thủ công [Socks]</string>
<string name="menu_item_import_config_manually_socks">Nhập thủ công [SOCKS]</string>
<string name="menu_item_import_config_manually_http">Type manually[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Nhập thủ công [Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">Nhập thủ công [WireGuard]</string>
<string name="menu_item_import_config_custom">Nâng cao / Cấu hình tùy chỉnh</string>
@@ -157,11 +158,6 @@
<string name="title_pref_prefer_ipv6">Ưu tiên IPv6</string>
<string name="summary_pref_prefer_ipv6">Ưu tiên sử dụng địa chỉ IPv6 cho kết nối và định tuyến.</string>
<string name="title_pref_routing">Định tuyến</string>
<string name="title_pref_routing_domain_strategy">Chiến lược tên miền (DomainStrategy)</string>
<string name="title_pref_routing_mode">Quy tắc được định nghĩa trước</string>
<string name="title_pref_routing_custom">Quy tắc tùy chỉnh</string>
<string name="title_pref_remote_dns">DNS ngoại quốc (UDP / TCP / HTTPS / QUIC) (Không bắt buộc)</string>
<string name="summary_pref_remote_dns">DNS</string>
@@ -235,6 +231,9 @@
<string name="sub_setting_url">URL gói đăng ký</string>
<string name="sub_setting_enable">Sử dụng gói đăng ký này</string>
<string name="sub_auto_update">Bật tự động cập nhật</string>
<string name="sub_setting_pre_profile">Previous proxy remarks</string>
<string name="sub_setting_next_profile">Next proxy remarks</string>
<string name="sub_setting_pre_profile_tip">The remarks exists and is unique</string>
<string name="title_sub_update">Cập nhật các gói đăng ký</string>
<string name="title_ping_all_server">Ping tất cả máy chủ</string>
<string name="title_real_ping_all_server">Kiểm tra HTTP tất cả máy chủ</string>
@@ -247,13 +246,15 @@
<string name="tasker_start_service">Khởi động v2rayNG</string>
<string name="tasker_setting_confirm">Xác nhận</string>
<string name="routing_settings_domain_strategy">Chiến lược tên miền (DomainStrategy)</string>
<string name="routing_settings_title">Cài đặt định tuyến</string>
<string name="routing_settings_tips">Phân cách bằng dấu phẩy (,). Có thể tải xuống Rules mặc định để tham khảo ở menu ba chấm.</string>
<string name="routing_settings_save">Lưu lại</string>
<string name="routing_settings_delete">Xoá</string>
<string name="routing_settings_scan_replace">Quét QR và Thay thế</string>
<string name="routing_settings_scan_append">Quét QR và Nối thêm</string>
<string name="routing_settings_default_rules">Tải xuống Rules mặc định cho Trung Quốc</string>
<string name="routing_settings_rule_title">Routing Rule Settings</string>
<string name="routing_settings_add_rule">Add rule</string>
<string name="routing_settings_import_rulesets">Import ruleset</string>
<string name="routing_settings_import_rulesets_tip">Existing rulesets will be deleted, are you sure to continue?</string>
<string name="connection_test_pending">Kiểm tra kết nối</string>
<string name="connection_test_testing">Đang kiểm tra kết nối mạng...</string>
@@ -278,20 +279,6 @@
<item>Xuất gói vào Clipboard</item>
</string-array>
<string-array name="routing_tag">
<item>Proxy</item>
<item>Direct</item>
<item>Blocked</item>
</string-array>
<string-array name="routing_mode">
<item>Proxy toàn cầu</item>
<item>Bỏ qua địa chỉ LAN rồi Proxy</item>
<item>Bỏ qua địa chỉ nội địa rồi Proxy</item>
<item>Bỏ qua LAN và địa chỉ nội địa rồi Proxy</item>
<item>Kết nối trực tiếp toàn cầu</item>
</string-array>
<string-array name="mode_entries">
<item>Chế độ VPN</item>
<item>Chế độ Proxy</item>

View File

@@ -24,10 +24,11 @@
<string name="menu_item_del_config">删除配置</string>
<string name="menu_item_import_config_qrcode">扫描二维码</string>
<string name="menu_item_import_config_clipboard">从剪贴板导入</string>
<string name="menu_item_import_config_manually_vmess">手动输入[Vmess]</string>
<string name="menu_item_import_config_manually_vmess">手动输入[VMess]</string>
<string name="menu_item_import_config_manually_vless">手动输入[VLESS]</string>
<string name="menu_item_import_config_manually_ss">手动输入[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">手动输入[Socks]</string>
<string name="menu_item_import_config_manually_socks">手动输入[SOCKS]</string>
<string name="menu_item_import_config_manually_http">手动输入[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">手动输入[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">手动输入[Wireguard]</string>
<string name="menu_item_import_config_custom">自定义配置</string>
@@ -155,11 +156,6 @@
<string name="title_pref_prefer_ipv6">IPv6优先</string>
<string name="summary_pref_prefer_ipv6">App优先使用IPv6地址连接服务器,同时开启VPN的IPv6路由</string>
<string name="title_pref_routing">路由设置</string>
<string name="title_pref_routing_domain_strategy">域名策略</string>
<string name="title_pref_routing_mode">预定义规则</string>
<string name="title_pref_routing_custom">自定义规则</string>
<string name="title_pref_remote_dns">远程DNS (udp/tcp/https/quic)(可选)</string>
<string name="summary_pref_remote_dns">DNS</string>
@@ -233,6 +229,9 @@
<string name="sub_setting_url">可选地址(url)</string>
<string name="sub_setting_enable">启用更新</string>
<string name="sub_auto_update">启用自动更新</string>
<string name="sub_setting_pre_profile">前置代理别名</string>
<string name="sub_setting_next_profile">落地代理別名</string>
<string name="sub_setting_pre_profile_tip">请确保别名存在并唯一</string>
<string name="title_sub_update">更新当前组订阅</string>
<string name="title_ping_all_server">测试当前组配置Tcping</string>
<string name="title_real_ping_all_server">测试当前组配置真连接</string>
@@ -245,13 +244,15 @@
<string name="tasker_start_service">启动服务</string>
<string name="tasker_setting_confirm">确定</string>
<string name="routing_settings_domain_strategy">域名策略</string>
<string name="routing_settings_title">路由设置</string>
<string name="routing_settings_tips">用逗号(,)隔开,可以一行多个,记得保存</string>
<string name="routing_settings_tips">用逗号(,)隔开,可以一行多个</string>
<string name="routing_settings_save">保存</string>
<string name="routing_settings_delete">清空</string>
<string name="routing_settings_scan_replace">扫描并替换</string>
<string name="routing_settings_scan_append">扫描并追加</string>
<string name="routing_settings_default_rules">置默认路由规则</string>
<string name="routing_settings_rule_title">路由规则设置</string>
<string name="routing_settings_add_rule">添加规则</string>
<string name="routing_settings_import_rulesets">导入预设规则</string>
<string name="routing_settings_import_rulesets_tip">将删除现有的规则集,是否确定继续?</string>
<string name="connection_test_pending">"检查网络连接"</string>
<string name="connection_test_testing">"测试中…"</string>
@@ -283,21 +284,6 @@
<item>导出至剪贴板</item>
</string-array>
share_method
<string-array name="routing_tag">
<item>代理的网址或IP</item>
<item>直连的网址或IP</item>
<item>阻止的网址或IP</item>
</string-array>
<string-array name="routing_mode">
<item>全局代理</item>
<item>绕过局域网地址而后代理</item>
<item>绕过大陆地址而后代理</item>
<item>绕过局域网及大陆地址而后代理</item>
<item>全局直连</item>
</string-array>
<string-array name="mode_entries">
<item>VPN</item>
<item>仅代理</item>
@@ -309,4 +295,10 @@
<item>深色</item>
</string-array>
<string-array name="preset_rulesets">
<item>绕过大陆(Whitelist)</item>
<item>黑名单(Blacklist)</item>
<item>全局(Global)</item>
</string-array>
</resources>

View File

@@ -24,10 +24,11 @@
<string name="menu_item_del_config">刪除配置</string>
<string name="menu_item_import_config_qrcode">從 QR Code 匯入配置</string>
<string name="menu_item_import_config_clipboard">從剪貼簿匯入配置</string>
<string name="menu_item_import_config_manually_vmess">手動鍵入 [Vmess]</string>
<string name="menu_item_import_config_manually_vmess">手動鍵入 [VMess]</string>
<string name="menu_item_import_config_manually_vless">手動鍵入 [VLESS]</string>
<string name="menu_item_import_config_manually_ss">手動鍵入 [Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">手動鍵入 [Socks]</string>
<string name="menu_item_import_config_manually_socks">手動鍵入 [SOCKS]</string>
<string name="menu_item_import_config_manually_http">手動鍵入 [HTTP]</string>
<string name="menu_item_import_config_manually_trojan">手動鍵入 [Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">手動鍵入 [Wireguard]</string>
<string name="menu_item_import_config_custom">自訂配置</string>
@@ -156,11 +157,6 @@
<string name="title_pref_prefer_ipv6">IPv6 偏好</string>
<string name="summary_pref_prefer_ipv6">App 優先使用 IPv6 位址連線伺服器,同时開啟 VPN 的 IPv6 路由</string>
<string name="title_pref_routing">轉送設定</string>
<string name="title_pref_routing_domain_strategy">網域策略</string>
<string name="title_pref_routing_mode">轉送模式</string>
<string name="title_pref_routing_custom">自訂轉送</string>
<string name="title_pref_remote_dns">遠端DNS (udp/tcp/https/quic)(可選)</string>
<string name="summary_pref_remote_dns">DNS</string>
@@ -234,6 +230,9 @@
<string name="sub_setting_url">Optional URL</string>
<string name="sub_setting_enable">啟用更新</string>
<string name="sub_auto_update">啟用自動更新</string>
<string name="sub_setting_pre_profile">前置代理别名</string>
<string name="sub_setting_next_profile">落地代理別名</string>
<string name="sub_setting_pre_profile_tip">请确保别名存在并唯一</string>
<string name="title_sub_update">更新目前群組訂閱</string>
<string name="title_ping_all_server">偵測目前群組配置 Tcping</string>
<string name="title_real_ping_all_server">偵測目前群組配置真延遲</string>
@@ -246,13 +245,15 @@
<string name="tasker_start_service">啟動服務</string>
<string name="tasker_setting_confirm">確定</string>
<string name="routing_settings_domain_strategy">網域策略</string>
<string name="routing_settings_title">轉送設定</string>
<string name="routing_settings_tips">以半形逗號「,」分隔,並手動儲存</string>
<string name="routing_settings_tips">以半形逗號「,」分隔</string>
<string name="routing_settings_save">儲存</string>
<string name="routing_settings_delete">清除</string>
<string name="routing_settings_scan_replace">掃描並取代</string>
<string name="routing_settings_scan_append">掃描並附加</string>
<string name="routing_settings_default_rules">定預設轉送規則</string>
<string name="routing_settings_rule_title">路由規則設定</string>
<string name="routing_settings_add_rule">新增規則</string>
<string name="routing_settings_import_rulesets">匯入預設規則</string>
<string name="routing_settings_import_rulesets_tip">將刪除現有的規則集,是否確定繼續? </string>
<string name="connection_test_pending">"測試連線能力"</string>
<string name="connection_test_testing">"測試中……"</string>
@@ -284,20 +285,6 @@
<item>匯出至剪貼簿</item>
</string-array>
<string-array name="routing_tag">
<item>Proxy URL 或 IP</item>
<item>直接連線 URL 或 IP</item>
<item>已封鎖的 URL 或 IP</item>
</string-array>
<string-array name="routing_mode">
<item>全域 Proxy</item>
<item>略過區域網路的 Proxy</item>
<item>略過中國大陸的 Proxy</item>
<item>略過區域網路及中國大陸的 Proxy</item>
<item>直接連線</item>
</string-array>
<string-array name="mode_entries">
<item>VPN</item>
<item>僅 Proxy</item>
@@ -309,4 +296,10 @@
<item>深色</item>
</string-array>
<string-array name="preset_rulesets">
<item>繞過大陸(Whitelist)</item>
<item>黑名單(Blacklist)</item>
<item>全域(Global)</item>
</string-array>
</resources>

View File

@@ -99,14 +99,6 @@
<item>false</item>
</string-array>
<string-array name="routing_mode_value" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
<string-array name="routing_domain_strategy" translatable="false">
<item>AsIs</item>
<item>IPIfNonMatch</item>
@@ -205,4 +197,10 @@
<item>1</item>
<item>2</item>
</string-array>
<string-array name="outbound_tag" translatable="false">
<item>proxy</item>
<item>direct</item>
<item>block</item>
</string-array>
</resources>

View File

@@ -7,7 +7,12 @@
<dimen name="edit_height">50dp</dimen>
<dimen name="png_height">24dp</dimen>
<dimen name="server_height">72dp</dimen>
<dimen name="sub_height">90dp</dimen>
<dimen name="connection_test_height">60dp</dimen>
<dimen name="padding_start">16dp</dimen>
<dimen name="padding_end">16dp</dimen>
<dimen name="padding">16dp</dimen>
<dimen name="cardview_margin">3dp</dimen>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>

View File

@@ -25,10 +25,11 @@
<string name="menu_item_del_config">Delete config</string>
<string name="menu_item_import_config_qrcode">Import config from QRcode</string>
<string name="menu_item_import_config_clipboard">Import config from Clipboard</string>
<string name="menu_item_import_config_manually_vmess">Type manually[Vmess]</string>
<string name="menu_item_import_config_manually_vmess">Type manually[VMess]</string>
<string name="menu_item_import_config_manually_vless">Type manually[VLESS]</string>
<string name="menu_item_import_config_manually_ss">Type manually[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">Type manually[Socks]</string>
<string name="menu_item_import_config_manually_socks">Type manually[SOCKS]</string>
<string name="menu_item_import_config_manually_http">Type manually[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Type manually[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">Type manually[Wireguard]</string>
<string name="menu_item_import_config_custom">Custom config</string>
@@ -161,11 +162,6 @@
<string name="title_pref_prefer_ipv6">Prefer IPv6</string>
<string name="summary_pref_prefer_ipv6">Prefer IPv6 address and routes</string>
<string name="title_pref_routing">Routing</string>
<string name="title_pref_routing_domain_strategy">Domain strategy</string>
<string name="title_pref_routing_mode">Predefined rules</string>
<string name="title_pref_routing_custom">Custom rules</string>
<string name="title_pref_remote_dns">Remote DNS (udp/tcp/https/quic)(Optional)</string>
<string name="summary_pref_remote_dns">DNS</string>
@@ -239,6 +235,9 @@
<string name="sub_setting_url">Optional URL</string>
<string name="sub_setting_enable">Enable update</string>
<string name="sub_auto_update">Enable automatic update</string>
<string name="sub_setting_pre_profile">Previous proxy remarks</string>
<string name="sub_setting_next_profile">Next proxy remarks</string>
<string name="sub_setting_pre_profile_tip">The remarks exists and is unique</string>
<string name="title_sub_update">Update current group subscription</string>
<string name="title_ping_all_server">Tcping current group configuration</string>
<string name="title_real_ping_all_server">Real delay current group configuration</string>
@@ -251,13 +250,23 @@
<string name="tasker_start_service">Start Service</string>
<string name="tasker_setting_confirm">Confirm</string>
<string name="routing_settings_domain_strategy">Domain strategy</string>
<string name="routing_settings_title">Routing Settings</string>
<string name="routing_settings_tips">Separated by commas(,),remember to save</string>
<string name="routing_settings_tips">Separated by commas(,)</string>
<string name="routing_settings_save">Save</string>
<string name="routing_settings_delete">Clear</string>
<string name="routing_settings_scan_replace">Scan and replace</string>
<string name="routing_settings_scan_append">Scan and append</string>
<string name="routing_settings_default_rules"> set default routing rules</string>
<string name="routing_settings_rule_title">Routing Rule Settings</string>
<string name="routing_settings_add_rule">Add rule</string>
<string name="routing_settings_import_rulesets">Import ruleset</string>
<string name="routing_settings_import_rulesets_tip">Existing rulesets will be deleted, are you sure to continue?</string>
<string name="routing_settings_domain" translatable="false">domain</string>
<string name="routing_settings_ip" translatable="false">ip</string>
<string name="routing_settings_port" translatable="false">port</string>
<string name="routing_settings_protocol" translatable="false">protocol</string>
<string name="routing_settings_protocol_tip" translatable="false">[http,tls,bittorrent]</string>
<string name="routing_settings_network" translatable="false">network</string>"[udp|tcp]"
<string name="routing_settings_network_tip" translatable="false">[udp|tcp]</string>
<string name="routing_settings_outbound_tag" translatable="false">outboundTag</string>
<string name="connection_test_pending">Check Connectivity</string>
<string name="connection_test_testing">Testing…</string>
@@ -287,20 +296,6 @@
<item>Export to clipboard</item>
</string-array>
<string-array name="routing_tag">
<item>proxy URL or IP</item>
<item>direct URL or IP</item>
<item>blocked URL or IP</item>
</string-array>
<string-array name="routing_mode">
<item>Global proxy</item>
<item>Bypassing the LAN address then proxy</item>
<item>Bypass mainland address then proxy</item>
<item>Bypassing LAN and mainland address then proxy</item>
<item>Global direct</item>
</string-array>
<string-array name="mode_entries">
<item>VPN</item>
<item>Proxy only</item>
@@ -312,4 +307,10 @@
<item>Dark</item>
</string-array>
<string-array name="preset_rulesets">
<item>China Whitelist</item>
<item>China Blacklist</item>
<item>Global</item>
</string-array>
</resources>

View File

@@ -42,30 +42,6 @@
android:title="@string/title_pref_vpn_dns" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/title_pref_routing">
<ListPreference
android:defaultValue="IPIfNonMatch"
android:entries="@array/routing_domain_strategy"
android:entryValues="@array/routing_domain_strategy"
android:key="pref_routing_domain_strategy"
android:summary="%s"
android:title="@string/title_pref_routing_domain_strategy" />
<ListPreference
android:defaultValue="3"
android:entries="@array/routing_mode"
android:entryValues="@array/routing_mode_value"
android:key="pref_routing_mode"
android:summary="%s"
android:title="@string/title_pref_routing_mode" />
<Preference
android:key="pref_routing_custom"
android:summary="@string/title_pref_routing_custom"
android:title="@string/title_pref_routing_custom" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/title_ui_settings">
<CheckBoxPreference
android:key="pref_speed_enabled"

View File

@@ -1,26 +1,26 @@
[versions]
activityKtx = "1.9.1"
activityKtx = "1.9.2"
appcompat = "1.7.0"
cardview = "1.0.0"
constraintlayout = "2.1.4"
core = "3.5.3"
editorkit = "2.9.0"
flexbox = "3.0.0"
fragmentKtx = "1.8.2"
fragmentKtx = "1.8.3"
gson = "2.11.0"
junit = "4.13.2"
kotlinReflect = "2.0.0"
kotlinxCoroutinesCore = "1.8.1"
kotlinReflect = "2.0.20"
kotlinxCoroutinesCore = "1.9.0"
legacySupportV4 = "1.0.0"
lifecycleViewmodelKtx = "2.8.4"
lifecycleViewmodelKtx = "2.8.5"
material = "1.12.0"
mmkvStatic = "1.3.4"
mmkvStatic = "1.3.9"
multidex = "2.0.1"
preferenceKtx = "1.2.1"
quickieBundled = "1.9.0"
quickieBundled = "1.10.0"
recyclerview = "1.3.2"
rxandroid = "3.0.2"
rxjava = "3.1.8"
rxjava = "3.1.9"
rxpermissions = "0.12"
toastcompat = "1.1.0"
viewpager2 = "1.1.0"

View File

@@ -14,5 +14,5 @@ dependencyResolutionManagement {
maven { url = uri("https://jitpack.io") }
}
}
rootProject.name = "V2rayNG"
rootProject.name = "v2rayNG"
include(":app")