Reformat code

This commit is contained in:
2dust
2024-10-31 19:30:04 +08:00
parent 2ec691fc6b
commit 4f43c2ce45
30 changed files with 77 additions and 79 deletions

View File

@@ -19,6 +19,7 @@ package com.v2ray.ang.helper;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.ItemTouchHelper;
@@ -87,13 +88,13 @@ public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
@Override @Override
public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView,
@NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder viewHolder,
float dX, float dY, int actionState, boolean isCurrentlyActive) { float dX, float dY, int actionState, boolean isCurrentlyActive) {
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
float maxSwipeDistance = viewHolder.itemView.getWidth() * SWIPE_THRESHOLD; float maxSwipeDistance = viewHolder.itemView.getWidth() * SWIPE_THRESHOLD;
float swipeAmount = Math.abs(dX); float swipeAmount = Math.abs(dX);
float direction = Math.signum(dX); float direction = Math.signum(dX);
// 限制最大滑动距离 // 限制最大滑动距离
float translationX = Math.min(swipeAmount, maxSwipeDistance) * direction; float translationX = Math.min(swipeAmount, maxSwipeDistance) * direction;
float alpha = ALPHA_FULL - Math.min(swipeAmount, maxSwipeDistance) / maxSwipeDistance; float alpha = ALPHA_FULL - Math.min(swipeAmount, maxSwipeDistance) / maxSwipeDistance;

View File

@@ -155,6 +155,7 @@ object AppConfig {
/** Give a good name to this, IDK*/ /** Give a good name to this, IDK*/
const val VPN = "VPN" const val VPN = "VPN"
// Google API rule constants // Google API rule constants
const val GOOGLEAPIS_CN_DOMAIN = "domain:googleapis.cn" const val GOOGLEAPIS_CN_DOMAIN = "domain:googleapis.cn"
const val GOOGLEAPIS_COM_DOMAIN = "googleapis.com" const val GOOGLEAPIS_COM_DOMAIN = "googleapis.com"

View File

@@ -1,6 +1,6 @@
package com.v2ray.ang.dto package com.v2ray.ang.dto
data class ConfigResult ( data class ConfigResult(
var status: Boolean, var status: Boolean,
var guid: String? = null, var guid: String? = null,
var content: String = "", var content: String = "",

View File

@@ -29,8 +29,9 @@ class PluginList : ArrayList<Plugin>() {
init { init {
addAll( addAll(
AngApplication.application.packageManager.queryIntentContentProviders( AngApplication.application.packageManager.queryIntentContentProviders(
Intent(PluginContract.ACTION_NATIVE_PLUGIN), PackageManager.GET_META_DATA) Intent(PluginContract.ACTION_NATIVE_PLUGIN), PackageManager.GET_META_DATA
.filter { it.providerInfo.exported }.map { NativePlugin(it) }) )
.filter { it.providerInfo.exported }.map { NativePlugin(it) })
} }
val lookup = mutableMapOf<String, Plugin>().apply { val lookup = mutableMapOf<String, Plugin>().apply {
@@ -39,13 +40,13 @@ class PluginList : ArrayList<Plugin>() {
if (old != null && old != plugin) { if (old != null && old != plugin) {
this@PluginList.remove(old) this@PluginList.remove(old)
} }
/* if (old != null && old !== plugin) { /* if (old != null && old !== plugin) {
val packages = this@PluginList.filter { it.id == plugin.id } val packages = this@PluginList.filter { it.id == plugin.id }
.joinToString { it.packageName } .joinToString { it.packageName }
val message = "Conflicting plugins found from: $packages" val message = "Conflicting plugins found from: $packages"
Toast.makeText(SagerNet.application, message, Toast.LENGTH_LONG).show() Toast.makeText(SagerNet.application, message, Toast.LENGTH_LONG).show()
throw IllegalStateException(message) throw IllegalStateException(message)
}*/ }*/
} }
check(put(plugin.id, plugin)) check(put(plugin.id, plugin))
} }

View File

@@ -43,6 +43,7 @@ import java.io.FileNotFoundException
object PluginManager { object PluginManager {
class PluginNotFoundException(val plugin: String) : FileNotFoundException(plugin) class PluginNotFoundException(val plugin: String) : FileNotFoundException(plugin)
private var receiver: BroadcastReceiver? = null private var receiver: BroadcastReceiver? = null
private var cachedPlugins: PluginList? = null private var cachedPlugins: PluginList? = null
fun fetchPlugins() = synchronized(this) { fun fetchPlugins() = synchronized(this) {
@@ -88,30 +89,34 @@ object PluginManager {
flags or PackageManager.MATCH_DIRECT_BOOT_UNAWARE or PackageManager.MATCH_DIRECT_BOOT_AWARE flags or PackageManager.MATCH_DIRECT_BOOT_UNAWARE or PackageManager.MATCH_DIRECT_BOOT_AWARE
} }
var providers = AngApplication.application.packageManager.queryIntentContentProviders( var providers = AngApplication.application.packageManager.queryIntentContentProviders(
Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "com.github.dyhkwong.AngApplication")), flags) Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "com.github.dyhkwong.AngApplication")), flags
)
.filter { it.providerInfo.exported } .filter { it.providerInfo.exported }
if (providers.isEmpty()) { if (providers.isEmpty()) {
providers = AngApplication.application.packageManager.queryIntentContentProviders( providers = AngApplication.application.packageManager.queryIntentContentProviders(
Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "io.nekohasekai.AngApplication")), flags) Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "io.nekohasekai.AngApplication")), flags
.filter { it.providerInfo.exported } )
.filter { it.providerInfo.exported }
} }
if (providers.isEmpty()) { if (providers.isEmpty()) {
providers = AngApplication.application.packageManager.queryIntentContentProviders( providers = AngApplication.application.packageManager.queryIntentContentProviders(
Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "moe.matsuri.lite")), flags) Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "moe.matsuri.lite")), flags
.filter { it.providerInfo.exported } )
.filter { it.providerInfo.exported }
} }
if (providers.isEmpty()) { if (providers.isEmpty()) {
providers = AngApplication.application.packageManager.queryIntentContentProviders( providers = AngApplication.application.packageManager.queryIntentContentProviders(
Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "fr.husi")), flags) Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "fr.husi")), flags
.filter { it.providerInfo.exported } )
.filter { it.providerInfo.exported }
} }
if (providers.isEmpty()) { if (providers.isEmpty()) {
providers = AngApplication.application.packageManager.queryIntentContentProviders( providers = AngApplication.application.packageManager.queryIntentContentProviders(
Intent(PluginContract.ACTION_NATIVE_PLUGIN), PackageManager.GET_META_DATA Intent(PluginContract.ACTION_NATIVE_PLUGIN), PackageManager.GET_META_DATA
).filter { ).filter {
it.providerInfo.exported && it.providerInfo.exported &&
it.providerInfo.metaData.containsKey(METADATA_KEY_ID) && it.providerInfo.metaData.containsKey(METADATA_KEY_ID) &&
it.providerInfo.metaData.getString(METADATA_KEY_ID) == pluginId it.providerInfo.metaData.getString(METADATA_KEY_ID) == pluginId
} }
if (providers.size > 1) { if (providers.size > 1) {
providers = listOf(providers[0]) // What if there is more than one? providers = listOf(providers[0]) // What if there is more than one?
@@ -129,7 +134,7 @@ object PluginManager {
try { try {
initNativeFaster(provider)?.also { return InitResult(it) } initNativeFaster(provider)?.also { return InitResult(it) }
} catch (t: Throwable) { } catch (t: Throwable) {
// Logs.w("Initializing native plugin faster mode failed") // Logs.w("Initializing native plugin faster mode failed")
failure = t failure = t
} }
@@ -138,19 +143,23 @@ object PluginManager {
authority(provider.authority) authority(provider.authority)
}.build() }.build()
try { try {
return initNativeFast(AngApplication.application.contentResolver, return initNativeFast(
AngApplication.application.contentResolver,
pluginId, pluginId,
uri)?.let { InitResult(it) } uri
)?.let { InitResult(it) }
} catch (t: Throwable) { } catch (t: Throwable) {
// Logs.w("Initializing native plugin fast mode failed") // Logs.w("Initializing native plugin fast mode failed")
failure?.also { t.addSuppressed(it) } failure?.also { t.addSuppressed(it) }
failure = t failure = t
} }
try { try {
return initNativeSlow(AngApplication.application.contentResolver, return initNativeSlow(
AngApplication.application.contentResolver,
pluginId, pluginId,
uri)?.let { InitResult(it) } uri
)?.let { InitResult(it) }
} catch (t: Throwable) { } catch (t: Throwable) {
failure?.also { t.addSuppressed(it) } failure?.also { t.addSuppressed(it) }
throw t throw t
@@ -180,11 +189,13 @@ object PluginManager {
throw IndexOutOfBoundsException("Plugin entry binary not found") throw IndexOutOfBoundsException("Plugin entry binary not found")
val pluginDir = File(AngApplication.application.noBackupFilesDir, "plugin") val pluginDir = File(AngApplication.application.noBackupFilesDir, "plugin")
(cr.query(uri, (cr.query(
uri,
arrayOf(PluginContract.COLUMN_PATH, PluginContract.COLUMN_MODE), arrayOf(PluginContract.COLUMN_PATH, PluginContract.COLUMN_MODE),
null, null,
null, null,
null) null
)
?: return null).use { cursor -> ?: return null).use { cursor ->
if (!cursor.moveToFirst()) entryNotFound() if (!cursor.moveToFirst()) entryNotFound()
pluginDir.deleteRecursively() pluginDir.deleteRecursively()
@@ -197,11 +208,13 @@ object PluginManager {
cr.openInputStream(uri.buildUpon().path(path).build())!!.use { inStream -> cr.openInputStream(uri.buildUpon().path(path).build())!!.use { inStream ->
file.outputStream().use { outStream -> inStream.copyTo(outStream) } file.outputStream().use { outStream -> inStream.copyTo(outStream) }
} }
Os.chmod(file.absolutePath, when (cursor.getType(1)) { Os.chmod(
Cursor.FIELD_TYPE_INTEGER -> cursor.getInt(1) file.absolutePath, when (cursor.getType(1)) {
Cursor.FIELD_TYPE_STRING -> cursor.getString(1).toInt(8) Cursor.FIELD_TYPE_INTEGER -> cursor.getInt(1)
else -> throw IllegalArgumentException("File mode should be of type int") Cursor.FIELD_TYPE_STRING -> cursor.getString(1).toInt(8)
}) else -> throw IllegalArgumentException("File mode should be of type int")
}
)
if (path == pluginId) initialized = true if (path == pluginId) initialized = true
} while (cursor.moveToNext()) } while (cursor.moveToNext())
} }
@@ -213,6 +226,7 @@ object PluginManager {
is String -> value is String -> value
is Int -> AngApplication.application.packageManager.getResourcesForApplication(applicationInfo) is Int -> AngApplication.application.packageManager.getResourcesForApplication(applicationInfo)
.getString(value) .getString(value)
null -> null null -> null
else -> error("meta-data $key has invalid type ${value.javaClass}") else -> error("meta-data $key has invalid type ${value.javaClass}")
} }

View File

@@ -37,7 +37,7 @@ class QSTileService : TileService() {
setState(Tile.STATE_INACTIVE) setState(Tile.STATE_INACTIVE)
mMsgReceive = ReceiveMessageHandler(this) mMsgReceive = ReceiveMessageHandler(this)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(mMsgReceive, IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY), Context.RECEIVER_EXPORTED) registerReceiver(mMsgReceive, IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY), RECEIVER_EXPORTED)
} else { } else {
registerReceiver(mMsgReceive, IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY)) registerReceiver(mMsgReceive, IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY))
} }

View File

@@ -14,10 +14,8 @@ import com.v2ray.ang.AppConfig
import com.v2ray.ang.AppConfig.SUBSCRIPTION_UPDATE_CHANNEL import com.v2ray.ang.AppConfig.SUBSCRIPTION_UPDATE_CHANNEL
import com.v2ray.ang.AppConfig.SUBSCRIPTION_UPDATE_CHANNEL_NAME import com.v2ray.ang.AppConfig.SUBSCRIPTION_UPDATE_CHANNEL_NAME
import com.v2ray.ang.R import com.v2ray.ang.R
import com.v2ray.ang.util.AngConfigManager
import com.v2ray.ang.util.AngConfigManager.updateConfigViaSub import com.v2ray.ang.util.AngConfigManager.updateConfigViaSub
import com.v2ray.ang.util.MmkvManager import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.Utils
object SubscriptionUpdater { object SubscriptionUpdater {

View File

@@ -157,7 +157,7 @@ object V2RayServiceManager {
currentConfig = config currentConfig = config
try { try {
v2rayPoint.runLoop(settingsStorage?.decodeBool(AppConfig.PREF_PREFER_IPV6) ?: false) v2rayPoint.runLoop(settingsStorage?.decodeBool(AppConfig.PREF_PREFER_IPV6) == true)
} catch (e: Exception) { } catch (e: Exception) {
Log.d(ANG_PACKAGE, e.toString()) Log.d(ANG_PACKAGE, e.toString())
} }

View File

@@ -64,7 +64,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
.build() .build()
} }
private val connectivity by lazy { getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager } private val connectivity by lazy { getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager }
@delegate:RequiresApi(Build.VERSION_CODES.P) @delegate:RequiresApi(Build.VERSION_CODES.P)
private val defaultNetworkCallback by lazy { private val defaultNetworkCallback by lazy {
@@ -155,7 +155,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
val selfPackageName = BuildConfig.APPLICATION_ID val selfPackageName = BuildConfig.APPLICATION_ID
if (settingsStorage?.decodeBool(AppConfig.PREF_PER_APP_PROXY) == true) { if (settingsStorage?.decodeBool(AppConfig.PREF_PER_APP_PROXY) == true) {
val apps = settingsStorage?.decodeStringSet(AppConfig.PREF_PER_APP_PROXY_SET) val apps = settingsStorage?.decodeStringSet(AppConfig.PREF_PER_APP_PROXY_SET)
val bypassApps = settingsStorage?.decodeBool(AppConfig.PREF_BYPASS_APPS) ?: false val bypassApps = settingsStorage?.decodeBool(AppConfig.PREF_BYPASS_APPS) == true
//process self package //process self package
if (bypassApps) apps?.add(selfPackageName) else apps?.remove(selfPackageName) if (bypassApps) apps?.add(selfPackageName) else apps?.remove(selfPackageName)
apps?.forEach { apps?.forEach {

View File

@@ -215,7 +215,7 @@ class PerAppProxyActivity : BaseActivity() {
} }
it.notifyDataSetChanged() it.notifyDataSetChanged()
true true
} ?: false } == true
R.id.select_proxy_app -> { R.id.select_proxy_app -> {
selectProxyApp() selectProxyApp()

View File

@@ -1,7 +1,6 @@
package com.v2ray.ang.ui package com.v2ray.ang.ui
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
@@ -38,7 +37,7 @@ class RoutingEditActivity : BaseActivity() {
private fun bindingServer(rulesetItem: RulesetItem): Boolean { private fun bindingServer(rulesetItem: RulesetItem): Boolean {
binding.etRemarks.text = Utils.getEditable(rulesetItem.remarks) binding.etRemarks.text = Utils.getEditable(rulesetItem.remarks)
binding.chkLocked.isChecked = rulesetItem.looked ?: false binding.chkLocked.isChecked = rulesetItem.looked == true
binding.etDomain.text = Utils.getEditable(rulesetItem.domain?.joinToString(",")) binding.etDomain.text = Utils.getEditable(rulesetItem.domain?.joinToString(","))
binding.etIp.text = Utils.getEditable(rulesetItem.ip?.joinToString(",")) binding.etIp.text = Utils.getEditable(rulesetItem.ip?.joinToString(","))
binding.etPort.text = Utils.getEditable(rulesetItem.port) binding.etPort.text = Utils.getEditable(rulesetItem.port)

View File

@@ -10,7 +10,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.v2ray.ang.databinding.ItemRecyclerRoutingSettingBinding import com.v2ray.ang.databinding.ItemRecyclerRoutingSettingBinding
import com.v2ray.ang.helper.ItemTouchHelperAdapter import com.v2ray.ang.helper.ItemTouchHelperAdapter
import com.v2ray.ang.helper.ItemTouchHelperViewHolder import com.v2ray.ang.helper.ItemTouchHelperViewHolder
import com.v2ray.ang.ui.MainRecyclerAdapter.BaseViewHolder
import com.v2ray.ang.util.SettingsManager import com.v2ray.ang.util.SettingsManager
class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) : RecyclerView.Adapter<RoutingSettingRecyclerAdapter.MainViewHolder>(), class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) : RecyclerView.Adapter<RoutingSettingRecyclerAdapter.MainViewHolder>(),
@@ -26,7 +25,7 @@ class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) : Recy
holder.itemRoutingSettingBinding.domainIp.text = (ruleset.domain ?: ruleset.ip ?: ruleset.port)?.toString() holder.itemRoutingSettingBinding.domainIp.text = (ruleset.domain ?: ruleset.ip ?: ruleset.port)?.toString()
holder.itemRoutingSettingBinding.outboundTag.text = ruleset.outboundTag holder.itemRoutingSettingBinding.outboundTag.text = ruleset.outboundTag
holder.itemRoutingSettingBinding.chkEnable.isChecked = ruleset.enabled holder.itemRoutingSettingBinding.chkEnable.isChecked = ruleset.enabled
holder.itemRoutingSettingBinding.imgLocked.isVisible = ruleset.looked ?: false holder.itemRoutingSettingBinding.imgLocked.isVisible = ruleset.looked == true
holder.itemView.setBackgroundColor(Color.TRANSPARENT) holder.itemView.setBackgroundColor(Color.TRANSPARENT)
holder.itemRoutingSettingBinding.layoutEdit.setOnClickListener { holder.itemRoutingSettingBinding.layoutEdit.setOnClickListener {
@@ -37,7 +36,7 @@ class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) : Recy
} }
holder.itemRoutingSettingBinding.chkEnable.setOnCheckedChangeListener { it, isChecked -> holder.itemRoutingSettingBinding.chkEnable.setOnCheckedChangeListener { it, isChecked ->
if( !it.isPressed) return@setOnCheckedChangeListener if (!it.isPressed) return@setOnCheckedChangeListener
ruleset.enabled = isChecked ruleset.enabled = isChecked
SettingsManager.saveRoutingRuleset(position, ruleset) SettingsManager.saveRoutingRuleset(position, ruleset)
} }

View File

@@ -507,7 +507,7 @@ class ServerActivity : BaseActivity() {
val allowInsecure = val allowInsecure =
if (allowInsecureField == null || allowinsecures[allowInsecureField].isBlank()) { if (allowInsecureField == null || allowinsecures[allowInsecureField].isBlank()) {
settingsStorage?.decodeBool(PREF_ALLOW_INSECURE) ?: false settingsStorage?.decodeBool(PREF_ALLOW_INSECURE) == true
} else { } else {
allowinsecures[allowInsecureField].toBoolean() allowinsecures[allowInsecureField].toBoolean()
} }

View File

@@ -45,7 +45,7 @@ class SubSettingRecyclerAdapter(val activity: SubSettingActivity) : RecyclerView
} }
holder.itemSubSettingBinding.chkEnable.setOnCheckedChangeListener { it, isChecked -> holder.itemSubSettingBinding.chkEnable.setOnCheckedChangeListener { it, isChecked ->
if( !it.isPressed) return@setOnCheckedChangeListener if (!it.isPressed) return@setOnCheckedChangeListener
subItem.enabled = isChecked subItem.enabled = isChecked
MmkvManager.encodeSubscription(subId, subItem) MmkvManager.encodeSubscription(subId, subItem)

View File

@@ -30,7 +30,6 @@ import com.v2ray.ang.dto.AssetUrlItem
import com.v2ray.ang.extension.toTrafficString import com.v2ray.ang.extension.toTrafficString
import com.v2ray.ang.extension.toast import com.v2ray.ang.extension.toast
import com.v2ray.ang.util.MmkvManager import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.MmkvManager.settingsStorage
import com.v2ray.ang.util.SettingsManager import com.v2ray.ang.util.SettingsManager
import com.v2ray.ang.util.Utils import com.v2ray.ang.util.Utils
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers

View File

@@ -192,7 +192,7 @@ object MmkvManager {
} }
fun decodeServerRaw(guid: String): String? { fun decodeServerRaw(guid: String): String? {
return serverRawStorage.decodeString(guid) ?: return null return serverRawStorage.decodeString(guid)
} }
//endregion //endregion

View File

@@ -422,8 +422,6 @@ object Utils {
} }
private fun getSysLocale(): Locale = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { private fun getSysLocale(): Locale = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
LocaleList.getDefault()[0] LocaleList.getDefault()[0]
} else { } else {

View File

@@ -124,11 +124,9 @@ object V2rayConfigUtil {
} }
} }
v2rayConfig.inbounds[0].port = socksPort v2rayConfig.inbounds[0].port = socksPort
val fakedns = settingsStorage?.decodeBool(AppConfig.PREF_FAKE_DNS_ENABLED) val fakedns = settingsStorage?.decodeBool(AppConfig.PREF_FAKE_DNS_ENABLED) == true
?: false
val sniffAllTlsAndHttp = val sniffAllTlsAndHttp =
settingsStorage?.decodeBool(AppConfig.PREF_SNIFFING_ENABLED, true) settingsStorage?.decodeBool(AppConfig.PREF_SNIFFING_ENABLED, true) != false
?: true
v2rayConfig.inbounds[0].sniffing?.enabled = fakedns || sniffAllTlsAndHttp v2rayConfig.inbounds[0].sniffing?.enabled = fakedns || sniffAllTlsAndHttp
v2rayConfig.inbounds[0].sniffing?.routeOnly = v2rayConfig.inbounds[0].sniffing?.routeOnly =
settingsStorage?.decodeBool(AppConfig.PREF_ROUTE_ONLY_ENABLED, false) settingsStorage?.decodeBool(AppConfig.PREF_ROUTE_ONLY_ENABLED, false)

View File

@@ -31,7 +31,7 @@ object ZipUtil {
} }
} }
} }
if (filesToCompress.isEmpty()) { if (filesToCompress.isEmpty) {
return false return false
} }

View File

@@ -3,7 +3,6 @@ package com.v2ray.ang.util.fmt
import com.v2ray.ang.AppConfig import com.v2ray.ang.AppConfig
import com.v2ray.ang.dto.EConfigType import com.v2ray.ang.dto.EConfigType
import com.v2ray.ang.dto.ProfileItem import com.v2ray.ang.dto.ProfileItem
import com.v2ray.ang.dto.V2rayConfig
import com.v2ray.ang.dto.V2rayConfig.OutboundBean import com.v2ray.ang.dto.V2rayConfig.OutboundBean
import com.v2ray.ang.extension.idnHost import com.v2ray.ang.extension.idnHost
import com.v2ray.ang.util.MmkvManager.settingsStorage import com.v2ray.ang.util.MmkvManager.settingsStorage
@@ -13,7 +12,7 @@ import kotlin.text.orEmpty
object TrojanFmt : FmtBase() { object TrojanFmt : FmtBase() {
fun parse(str: String): ProfileItem? { fun parse(str: String): ProfileItem? {
var allowInsecure = settingsStorage.decodeBool(AppConfig.PREF_ALLOW_INSECURE,false) var allowInsecure = settingsStorage.decodeBool(AppConfig.PREF_ALLOW_INSECURE, false)
val config = ProfileItem.create(EConfigType.TROJAN) val config = ProfileItem.create(EConfigType.TROJAN)
val uri = URI(Utils.fixIllegalUrl(str)) val uri = URI(Utils.fixIllegalUrl(str))

View File

@@ -12,7 +12,7 @@ import java.net.URI
object VlessFmt : FmtBase() { object VlessFmt : FmtBase() {
fun parse(str: String): ProfileItem? { fun parse(str: String): ProfileItem? {
var allowInsecure = settingsStorage.decodeBool(AppConfig.PREF_ALLOW_INSECURE,false) var allowInsecure = settingsStorage.decodeBool(AppConfig.PREF_ALLOW_INSECURE, false)
val config = ProfileItem.create(EConfigType.VLESS) val config = ProfileItem.create(EConfigType.VLESS)
val uri = URI(Utils.fixIllegalUrl(str)) val uri = URI(Utils.fixIllegalUrl(str))

View File

@@ -23,7 +23,7 @@ object WireguardFmt : FmtBase() {
config.serverPort = uri.port.toString() config.serverPort = uri.port.toString()
config.secretKey = uri.userInfo config.secretKey = uri.userInfo
config.localAddress = (queryParam["address"] ?: AppConfig.WIREGUARD_LOCAL_ADDRESS_V4) config.localAddress = (queryParam["address"] ?: WIREGUARD_LOCAL_ADDRESS_V4)
config.publicKey = queryParam["publickey"].orEmpty() config.publicKey = queryParam["publickey"].orEmpty()
config.mtu = Utils.parseInt(queryParam["mtu"] ?: AppConfig.WIREGUARD_LOCAL_MTU) config.mtu = Utils.parseInt(queryParam["mtu"] ?: AppConfig.WIREGUARD_LOCAL_MTU)
config.reserved = (queryParam["reserved"] ?: "0,0,0") config.reserved = (queryParam["reserved"] ?: "0,0,0")
@@ -52,7 +52,7 @@ object WireguardFmt : FmtBase() {
} }
config.secretKey = queryParam["privatekey"].orEmpty() config.secretKey = queryParam["privatekey"].orEmpty()
config.localAddress = (queryParam["address"] ?: AppConfig.WIREGUARD_LOCAL_ADDRESS_V4) config.localAddress = (queryParam["address"] ?: WIREGUARD_LOCAL_ADDRESS_V4)
config.publicKey = queryParam["publickey"].orEmpty() config.publicKey = queryParam["publickey"].orEmpty()
config.mtu = Utils.parseInt(queryParam["mtu"] ?: AppConfig.WIREGUARD_LOCAL_MTU) config.mtu = Utils.parseInt(queryParam["mtu"] ?: AppConfig.WIREGUARD_LOCAL_MTU)
config.reserved = (queryParam["reserved"] ?: "0,0,0") config.reserved = (queryParam["reserved"] ?: "0,0,0")

View File

@@ -44,7 +44,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application
AppConfig.PREF_FRAGMENT_LENGTH, AppConfig.PREF_FRAGMENT_LENGTH,
AppConfig.PREF_FRAGMENT_INTERVAL, AppConfig.PREF_FRAGMENT_INTERVAL,
AppConfig.PREF_MUX_XUDP_QUIC, AppConfig.PREF_MUX_XUDP_QUIC,
-> { -> {
settingsStorage?.encode(key, sharedPreferences.getString(key, "")) settingsStorage?.encode(key, sharedPreferences.getString(key, ""))
} }
@@ -63,7 +63,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application
AppConfig.SUBSCRIPTION_AUTO_UPDATE, AppConfig.SUBSCRIPTION_AUTO_UPDATE,
AppConfig.PREF_FRAGMENT_ENABLED, AppConfig.PREF_FRAGMENT_ENABLED,
AppConfig.PREF_MUX_ENABLED, AppConfig.PREF_MUX_ENABLED,
-> { -> {
settingsStorage?.encode(key, sharedPreferences.getBoolean(key, false)) settingsStorage?.encode(key, sharedPreferences.getBoolean(key, false))
} }

View File

@@ -42,6 +42,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="false" android:clickable="false"
android:focusable="false" android:focusable="false"
android:paddingStart="@dimen/padding_start"/> android:paddingStart="@dimen/padding_start" />
</LinearLayout> </LinearLayout>

View File

@@ -6,8 +6,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical"> android:gravity="center_vertical">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/item_cardview" android:id="@+id/item_cardview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@@ -6,8 +6,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical"> android:gravity="center_vertical">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/item_cardview" android:id="@+id/item_cardview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@@ -312,5 +312,4 @@
</string-array> </string-array>
</resources> </resources>

View File

@@ -311,5 +311,5 @@
<item>جهانی(Global)</item> <item>جهانی(Global)</item>
<item>ایران</item> <item>ایران</item>
</string-array> </string-array>
</resources> </resources>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="TabLayoutTextStyle" parent="TextAppearance.Design.Tab"> <style name="TabLayoutTextStyle" parent="TextAppearance.Design.Tab">
<item name="textAllCaps">false</item> <item name="textAllCaps">false</item>
</style> </style>

View File

@@ -1,11 +1,4 @@
import com.v2ray.ang.util.Utils import com.v2ray.ang.util.Utils
import com.v2ray.ang.util.fmt.Hysteria2Fmt
import com.v2ray.ang.util.fmt.ShadowsocksFmt
import com.v2ray.ang.util.fmt.SocksFmt
import com.v2ray.ang.util.fmt.TrojanFmt
import com.v2ray.ang.util.fmt.VlessFmt
import com.v2ray.ang.util.fmt.VmessFmt
import com.v2ray.ang.util.fmt.WireguardFmt
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue