Refactor code
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
android:shortcutLongLabel="@string/app_widget_name"
|
||||
android:shortcutShortLabel="@string/app_widget_name">
|
||||
|
||||
<!--suppress AndroidDomInspection -->
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetClass="com.v2ray.ang.ui.ScSwitchActivity"
|
||||
@@ -22,6 +23,7 @@
|
||||
android:shortcutLongLabel="@string/menu_item_import_config_qrcode"
|
||||
android:shortcutShortLabel="@string/menu_item_import_config_qrcode">
|
||||
|
||||
<!--suppress AndroidDomInspection -->
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetClass="com.v2ray.ang.ui.ScScannerActivity"
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<!-- https://developer.android.com/about/versions/11/privacy/package-visibility -->
|
||||
<uses-permission
|
||||
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
tools:ignore="PackageVisibilityPolicy,QueryAllPackagesPermission" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
@@ -158,7 +158,8 @@
|
||||
android:foregroundServiceType="specialUse"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
||||
android:process=":RunSoLibV2RayDaemon">
|
||||
android:process=":RunSoLibV2RayDaemon"
|
||||
tools:ignore="VpnServicePolicy">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.VpnService" />
|
||||
</intent-filter>
|
||||
|
||||
@@ -246,9 +246,9 @@ data class V2rayConfig(
|
||||
var mark: Int? = null,
|
||||
var dialerProxy: String? = null,
|
||||
var domainStrategy: String? = null,
|
||||
var happyEyeballs: happyEyeballsBean? = null,
|
||||
var happyEyeballs: HappyEyeballsBean? = null,
|
||||
)
|
||||
data class happyEyeballsBean(
|
||||
data class HappyEyeballsBean(
|
||||
var prioritizeIPv6: Boolean? = null,
|
||||
var maxConcurrentTry: Int? = 4,
|
||||
var tryDelayMs: Int? = 250, // ms
|
||||
|
||||
@@ -29,8 +29,8 @@ enum class VpnInterfaceAddressConfig(
|
||||
* or OPTION_1 (default) if the index is out of bounds
|
||||
*/
|
||||
fun getConfigByIndex(index: Int): VpnInterfaceAddressConfig {
|
||||
return if (index in values().indices) {
|
||||
values()[index]
|
||||
return if (index in entries.toTypedArray().indices) {
|
||||
entries[index]
|
||||
} else {
|
||||
OPTION_1 // Default to the first configuration
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ object SettingsManager {
|
||||
*/
|
||||
fun swapSubscriptions(fromPosition: Int, toPosition: Int) {
|
||||
val subsList = MmkvManager.decodeSubsList()
|
||||
if (subsList.isNullOrEmpty()) return
|
||||
if (subsList.isEmpty()) return
|
||||
|
||||
Collections.swap(subsList, fromPosition, toPosition)
|
||||
MmkvManager.encodeSubsList(subsList)
|
||||
|
||||
@@ -10,13 +10,13 @@ import com.v2ray.ang.dto.IPAPIInfo
|
||||
import com.v2ray.ang.extension.responseLength
|
||||
import com.v2ray.ang.util.HttpUtil
|
||||
import com.v2ray.ang.util.JsonUtil
|
||||
import kotlinx.coroutines.currentCoroutineContext
|
||||
import kotlinx.coroutines.isActive
|
||||
import libv2ray.Libv2ray
|
||||
import java.io.IOException
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.Socket
|
||||
import java.net.UnknownHostException
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
object SpeedtestManager {
|
||||
|
||||
@@ -33,7 +33,7 @@ object SpeedtestManager {
|
||||
var time = -1L
|
||||
for (k in 0 until 2) {
|
||||
val one = socketConnectTime(url, port)
|
||||
if (!coroutineContext.isActive) {
|
||||
if (!currentCoroutineContext().isActive) {
|
||||
break
|
||||
}
|
||||
if (one != -1L && (time == -1L || one < time)) {
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.v2ray.ang.dto.V2rayConfig.OutboundBean.OutSettingsBean
|
||||
import com.v2ray.ang.dto.V2rayConfig.OutboundBean.StreamSettingsBean
|
||||
import com.v2ray.ang.dto.V2rayConfig.RoutingBean.RulesBean
|
||||
import com.v2ray.ang.extension.isNotNullEmpty
|
||||
import com.v2ray.ang.fmt.CustomFmt
|
||||
import com.v2ray.ang.fmt.HttpFmt
|
||||
import com.v2ray.ang.fmt.ShadowsocksFmt
|
||||
import com.v2ray.ang.fmt.SocksFmt
|
||||
@@ -1011,7 +1010,7 @@ object V2rayConfigManager {
|
||||
|
||||
if (newHosts.containsKey(domain)) {
|
||||
item.ensureSockopt().domainStrategy = "UseIP"
|
||||
item.ensureSockopt().happyEyeballs = StreamSettingsBean.happyEyeballsBean(
|
||||
item.ensureSockopt().happyEyeballs = StreamSettingsBean.HappyEyeballsBean(
|
||||
prioritizeIPv6 = preferIpv6,
|
||||
interleave = 2
|
||||
)
|
||||
@@ -1022,7 +1021,7 @@ object V2rayConfigManager {
|
||||
if (resolvedIps.isNullOrEmpty()) continue
|
||||
|
||||
item.ensureSockopt().domainStrategy = "UseIP"
|
||||
item.ensureSockopt().happyEyeballs = StreamSettingsBean.happyEyeballsBean(
|
||||
item.ensureSockopt().happyEyeballs = StreamSettingsBean.HappyEyeballsBean(
|
||||
prioritizeIPv6 = preferIpv6,
|
||||
interleave = 2
|
||||
)
|
||||
|
||||
@@ -62,7 +62,7 @@ class TProxyService(
|
||||
appendLine(" mtu: ${SettingsManager.getVpnMtu()}")
|
||||
appendLine(" ipv4: ${vpnConfig.ipv4Client}")
|
||||
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_PREFER_IPV6) == true) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_PREFER_IPV6)) {
|
||||
appendLine(" ipv6: '${vpnConfig.ipv6Client}'")
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
|
||||
*/
|
||||
private fun removeServer(guid: String, position: Int) {
|
||||
if (guid != MmkvManager.getSelectServer()) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_CONFIRM_REMOVE) == true) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_CONFIRM_REMOVE)) {
|
||||
AlertDialog.Builder(mActivity).setMessage(R.string.del_config_comfirm)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
removeServerSub(guid, position)
|
||||
|
||||
@@ -208,7 +208,7 @@ class PerAppProxyActivity : BaseActivity() {
|
||||
var lst = binding.switchBypassApps.isChecked.toString()
|
||||
|
||||
adapter?.blacklist?.forEach block@{
|
||||
lst = lst + System.getProperty("line.separator") + it
|
||||
lst = lst + System.lineSeparator() + it
|
||||
}
|
||||
Utils.setClipboard(applicationContext, lst)
|
||||
toastSuccess(R.string.toast_success)
|
||||
|
||||
@@ -106,10 +106,10 @@ class RoutingEditActivity : BaseActivity() {
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.action_server, menu)
|
||||
val del_config = menu.findItem(R.id.del_config)
|
||||
val delConfig = menu.findItem(R.id.del_config)
|
||||
|
||||
if (position < 0) {
|
||||
del_config?.isVisible = false
|
||||
delConfig?.isVisible = false
|
||||
}
|
||||
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
|
||||
@@ -59,7 +59,7 @@ class ScannerActivity : BaseActivity() {
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_START_SCAN_IMMEDIATE) == true) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_START_SCAN_IMMEDIATE)) {
|
||||
launchScan()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,7 +617,7 @@ class ServerActivity : BaseActivity() {
|
||||
private fun deleteServer(): Boolean {
|
||||
if (editGuid.isNotEmpty()) {
|
||||
if (editGuid != MmkvManager.getSelectServer()) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_CONFIRM_REMOVE) == true) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_CONFIRM_REMOVE)) {
|
||||
AlertDialog.Builder(this).setMessage(R.string.del_config_comfirm)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
MmkvManager.removeServer(editGuid)
|
||||
|
||||
@@ -115,7 +115,7 @@ class SubEditActivity : BaseActivity() {
|
||||
*/
|
||||
private fun deleteServer(): Boolean {
|
||||
if (editSubId.isNotEmpty()) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_CONFIRM_REMOVE) == true) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_CONFIRM_REMOVE)) {
|
||||
AlertDialog.Builder(this).setMessage(R.string.del_config_comfirm)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
|
||||
@@ -100,7 +100,7 @@ class SubSettingRecyclerAdapter(val activity: SubSettingActivity) : RecyclerView
|
||||
}
|
||||
|
||||
private fun removeSubscription(subId: String, position: Int) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_CONFIRM_REMOVE) == true) {
|
||||
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_CONFIRM_REMOVE)) {
|
||||
AlertDialog.Builder(mActivity).setMessage(R.string.del_config_comfirm)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
removeSubscriptionSub(subId, position)
|
||||
|
||||
@@ -92,8 +92,8 @@ class TaskerActivity : BaseActivity() {
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.action_server, menu)
|
||||
val del_config = menu.findItem(R.id.del_config)
|
||||
del_config?.isVisible = false
|
||||
val delConfig = menu.findItem(R.id.del_config)
|
||||
delConfig?.isVisible = false
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"></RelativeLayout>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="navigation_drawer_open">فتح درج التنقل</string>
|
||||
<string name="navigation_drawer_close">إغلاق درج التنقل</string>
|
||||
<string name="migration_success">نجحت عملية ترحيل البيانات!</string>
|
||||
<string name="action_stop_service">Stop service</string>
|
||||
<string name="migration_fail">فشلت عملية ترحيل البيانات!</string>
|
||||
<string name="pull_down_to_refresh">Please pull down to refresh!</string>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="navigation_drawer_open">নেভিগেশন ড্রয়ার খোলুন</string>
|
||||
<string name="navigation_drawer_close">নেভিগেশন ড্রয়ার বন্ধ করুন</string>
|
||||
<string name="migration_success">ডেটা স্থানান্তর সফল!</string>
|
||||
<string name="action_stop_service">Stop service</string>
|
||||
<string name="migration_fail">ডেটা স্থানান্তর ব্যর্থ!</string>
|
||||
<string name="pull_down_to_refresh">Please pull down to refresh!</string>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="navigation_drawer_open">گۊشیڌن نومگه کشاری</string>
|
||||
<string name="navigation_drawer_close">بستن نومگه کشاری</string>
|
||||
<string name="migration_success">مووفقیت من جاگورویی داده</string>
|
||||
<string name="action_stop_service">Stop service</string>
|
||||
<string name="migration_fail">جاگورویی داده ٱنجوم نگرؽڌ</string>
|
||||
<string name="pull_down_to_refresh">سی وانۊ کردن، بکشینس بلم!</string>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="navigation_drawer_open">باز کردن منو کشویی</string>
|
||||
<string name="navigation_drawer_close">بستن منو کشویی</string>
|
||||
<string name="migration_success">موفقیت در انتقال داده</string>
|
||||
<string name="action_stop_service">Stop service</string>
|
||||
<string name="migration_fail">انتقال داده انجام نشد!</string>
|
||||
<string name="pull_down_to_refresh">لطفاً برای تازه کردن، پایین بکشید!</string>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="navigation_drawer_open">Открыть панель навигации</string>
|
||||
<string name="navigation_drawer_close">Закрыть панель навигации</string>
|
||||
<string name="migration_success">Успешный перенос данных!</string>
|
||||
<string name="action_stop_service">Stop service</string>
|
||||
<string name="migration_fail">Перенос данных не выполнен!</string>
|
||||
<string name="pull_down_to_refresh">Потяните вниз для обновления!</string>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="navigation_drawer_open">Mở Menu ứng dụng</string>
|
||||
<string name="navigation_drawer_close">Đóng Menu ứng dụng</string>
|
||||
<string name="migration_success">Đã chuyển dữ liệu!</string>
|
||||
<string name="action_stop_service">Stop service</string>
|
||||
<string name="migration_fail">Không thể chuyển dữ liệu!</string>
|
||||
<string name="pull_down_to_refresh">Please pull down to refresh!</string>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<string name="navigation_drawer_open">開啟導覽匣</string>
|
||||
<string name="navigation_drawer_close">關閉導覽匣</string>
|
||||
<string name="migration_success">資料遷移成功!</string>
|
||||
<string name="action_stop_service">Stop service</string>
|
||||
<string name="migration_fail">資料遷移失敗!</string>
|
||||
<string name="pull_down_to_refresh">請下拉刷新!</string>
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="streamsecuritys" translatable="false">
|
||||
<item></item>
|
||||
<item />
|
||||
<item>tls</item>
|
||||
</string-array>
|
||||
<string-array name="streamsecurityxs" translatable="false">
|
||||
<item></item>
|
||||
<item />
|
||||
<item>tls</item>
|
||||
<item>reality</item>
|
||||
</string-array>
|
||||
@@ -70,7 +70,7 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="streamsecurity_utls" translatable="false">
|
||||
<item></item>
|
||||
<item />
|
||||
<item>chrome</item>
|
||||
<item>firefox</item>
|
||||
<item>safari</item>
|
||||
@@ -84,7 +84,7 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="streamsecurity_alpn" translatable="false">
|
||||
<item></item>
|
||||
<item />
|
||||
<item>h3</item>
|
||||
<item>h2</item>
|
||||
<item>http/1.1</item>
|
||||
@@ -94,7 +94,7 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="allowinsecures" translatable="false">
|
||||
<item></item>
|
||||
<item />
|
||||
<item>true</item>
|
||||
<item>false</item>
|
||||
</string-array>
|
||||
@@ -126,7 +126,7 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="flows" translatable="false">
|
||||
<item></item>
|
||||
<item />
|
||||
<item>xtls-rprx-vision</item>
|
||||
<item>xtls-rprx-vision-udp443</item>
|
||||
</string-array>
|
||||
|
||||
Reference in New Issue
Block a user