diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/helper/SimpleItemTouchHelperCallback.java b/V2rayNG/app/src/main/java/com/v2ray/ang/helper/SimpleItemTouchHelperCallback.java index 36474fb8..e4e5845d 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/helper/SimpleItemTouchHelperCallback.java +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/helper/SimpleItemTouchHelperCallback.java @@ -19,6 +19,7 @@ package com.v2ray.ang.helper; import android.animation.ValueAnimator; import android.graphics.Canvas; import android.view.animation.DecelerateInterpolator; + import androidx.annotation.NonNull; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.ItemTouchHelper; @@ -87,13 +88,13 @@ public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback { @Override public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, - @NonNull RecyclerView.ViewHolder viewHolder, - float dX, float dY, int actionState, boolean isCurrentlyActive) { + @NonNull RecyclerView.ViewHolder viewHolder, + float dX, float dY, int actionState, boolean isCurrentlyActive) { if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { float maxSwipeDistance = viewHolder.itemView.getWidth() * SWIPE_THRESHOLD; float swipeAmount = Math.abs(dX); float direction = Math.signum(dX); - + // 限制最大滑动距离 float translationX = Math.min(swipeAmount, maxSwipeDistance) * direction; float alpha = ALPHA_FULL - Math.min(swipeAmount, maxSwipeDistance) / maxSwipeDistance; diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt index 9bf73892..8276d394 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt @@ -155,6 +155,7 @@ object AppConfig { /** Give a good name to this, IDK*/ const val VPN = "VPN" + // Google API rule constants const val GOOGLEAPIS_CN_DOMAIN = "domain:googleapis.cn" const val GOOGLEAPIS_COM_DOMAIN = "googleapis.com" diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ConfigResult.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ConfigResult.kt index 1c3d97ff..c0b70c6a 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ConfigResult.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ConfigResult.kt @@ -1,6 +1,6 @@ package com.v2ray.ang.dto -data class ConfigResult ( +data class ConfigResult( var status: Boolean, var guid: String? = null, var content: String = "", diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/plugin/PluginList.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/plugin/PluginList.kt index 9c247286..2495eb45 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/plugin/PluginList.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/plugin/PluginList.kt @@ -29,8 +29,9 @@ class PluginList : ArrayList() { init { addAll( AngApplication.application.packageManager.queryIntentContentProviders( - Intent(PluginContract.ACTION_NATIVE_PLUGIN), PackageManager.GET_META_DATA) - .filter { it.providerInfo.exported }.map { NativePlugin(it) }) + Intent(PluginContract.ACTION_NATIVE_PLUGIN), PackageManager.GET_META_DATA + ) + .filter { it.providerInfo.exported }.map { NativePlugin(it) }) } val lookup = mutableMapOf().apply { @@ -39,13 +40,13 @@ class PluginList : ArrayList() { if (old != null && old != plugin) { this@PluginList.remove(old) } - /* if (old != null && old !== plugin) { - val packages = this@PluginList.filter { it.id == plugin.id } - .joinToString { it.packageName } - val message = "Conflicting plugins found from: $packages" - Toast.makeText(SagerNet.application, message, Toast.LENGTH_LONG).show() - throw IllegalStateException(message) - }*/ + /* if (old != null && old !== plugin) { + val packages = this@PluginList.filter { it.id == plugin.id } + .joinToString { it.packageName } + val message = "Conflicting plugins found from: $packages" + Toast.makeText(SagerNet.application, message, Toast.LENGTH_LONG).show() + throw IllegalStateException(message) + }*/ } check(put(plugin.id, plugin)) } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/plugin/PluginManager.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/plugin/PluginManager.kt index 19fb6f2e..072b1c32 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/plugin/PluginManager.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/plugin/PluginManager.kt @@ -43,6 +43,7 @@ import java.io.FileNotFoundException object PluginManager { class PluginNotFoundException(val plugin: String) : FileNotFoundException(plugin) + private var receiver: BroadcastReceiver? = null private var cachedPlugins: PluginList? = null fun fetchPlugins() = synchronized(this) { @@ -88,30 +89,34 @@ object PluginManager { flags or PackageManager.MATCH_DIRECT_BOOT_UNAWARE or PackageManager.MATCH_DIRECT_BOOT_AWARE } 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 } if (providers.isEmpty()) { providers = AngApplication.application.packageManager.queryIntentContentProviders( - Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "io.nekohasekai.AngApplication")), flags) - .filter { it.providerInfo.exported } + Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "io.nekohasekai.AngApplication")), flags + ) + .filter { it.providerInfo.exported } } if (providers.isEmpty()) { providers = AngApplication.application.packageManager.queryIntentContentProviders( - Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "moe.matsuri.lite")), flags) - .filter { it.providerInfo.exported } + Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "moe.matsuri.lite")), flags + ) + .filter { it.providerInfo.exported } } if (providers.isEmpty()) { providers = AngApplication.application.packageManager.queryIntentContentProviders( - Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "fr.husi")), flags) - .filter { it.providerInfo.exported } + Intent(PluginContract.ACTION_NATIVE_PLUGIN, buildUri(pluginId, "fr.husi")), flags + ) + .filter { it.providerInfo.exported } } if (providers.isEmpty()) { providers = AngApplication.application.packageManager.queryIntentContentProviders( Intent(PluginContract.ACTION_NATIVE_PLUGIN), PackageManager.GET_META_DATA ).filter { it.providerInfo.exported && - it.providerInfo.metaData.containsKey(METADATA_KEY_ID) && - it.providerInfo.metaData.getString(METADATA_KEY_ID) == pluginId + it.providerInfo.metaData.containsKey(METADATA_KEY_ID) && + it.providerInfo.metaData.getString(METADATA_KEY_ID) == pluginId } if (providers.size > 1) { providers = listOf(providers[0]) // What if there is more than one? @@ -129,7 +134,7 @@ object PluginManager { try { initNativeFaster(provider)?.also { return InitResult(it) } } catch (t: Throwable) { - // Logs.w("Initializing native plugin faster mode failed") + // Logs.w("Initializing native plugin faster mode failed") failure = t } @@ -138,19 +143,23 @@ object PluginManager { authority(provider.authority) }.build() try { - return initNativeFast(AngApplication.application.contentResolver, + return initNativeFast( + AngApplication.application.contentResolver, pluginId, - uri)?.let { InitResult(it) } + uri + )?.let { InitResult(it) } } 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 = t } try { - return initNativeSlow(AngApplication.application.contentResolver, + return initNativeSlow( + AngApplication.application.contentResolver, pluginId, - uri)?.let { InitResult(it) } + uri + )?.let { InitResult(it) } } catch (t: Throwable) { failure?.also { t.addSuppressed(it) } throw t @@ -180,11 +189,13 @@ object PluginManager { throw IndexOutOfBoundsException("Plugin entry binary not found") val pluginDir = File(AngApplication.application.noBackupFilesDir, "plugin") - (cr.query(uri, + (cr.query( + uri, arrayOf(PluginContract.COLUMN_PATH, PluginContract.COLUMN_MODE), null, null, - null) + null + ) ?: return null).use { cursor -> if (!cursor.moveToFirst()) entryNotFound() pluginDir.deleteRecursively() @@ -197,11 +208,13 @@ object PluginManager { cr.openInputStream(uri.buildUpon().path(path).build())!!.use { inStream -> file.outputStream().use { outStream -> inStream.copyTo(outStream) } } - Os.chmod(file.absolutePath, when (cursor.getType(1)) { - Cursor.FIELD_TYPE_INTEGER -> cursor.getInt(1) - Cursor.FIELD_TYPE_STRING -> cursor.getString(1).toInt(8) - else -> throw IllegalArgumentException("File mode should be of type int") - }) + Os.chmod( + file.absolutePath, when (cursor.getType(1)) { + Cursor.FIELD_TYPE_INTEGER -> cursor.getInt(1) + Cursor.FIELD_TYPE_STRING -> cursor.getString(1).toInt(8) + else -> throw IllegalArgumentException("File mode should be of type int") + } + ) if (path == pluginId) initialized = true } while (cursor.moveToNext()) } @@ -213,6 +226,7 @@ object PluginManager { is String -> value is Int -> AngApplication.application.packageManager.getResourcesForApplication(applicationInfo) .getString(value) + null -> null else -> error("meta-data $key has invalid type ${value.javaClass}") } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/QSTileService.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/QSTileService.kt index 1c9afe6c..e9ff99dd 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/QSTileService.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/QSTileService.kt @@ -37,7 +37,7 @@ class QSTileService : TileService() { setState(Tile.STATE_INACTIVE) mMsgReceive = ReceiveMessageHandler(this) 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 { registerReceiver(mMsgReceive, IntentFilter(AppConfig.BROADCAST_ACTION_ACTIVITY)) } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/SubscriptionUpdater.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/SubscriptionUpdater.kt index 587fb5ef..7779260c 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/SubscriptionUpdater.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/SubscriptionUpdater.kt @@ -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_NAME import com.v2ray.ang.R -import com.v2ray.ang.util.AngConfigManager import com.v2ray.ang.util.AngConfigManager.updateConfigViaSub import com.v2ray.ang.util.MmkvManager -import com.v2ray.ang.util.Utils object SubscriptionUpdater { diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt index 159e4ad2..8033e636 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt @@ -157,7 +157,7 @@ object V2RayServiceManager { currentConfig = config try { - v2rayPoint.runLoop(settingsStorage?.decodeBool(AppConfig.PREF_PREFER_IPV6) ?: false) + v2rayPoint.runLoop(settingsStorage?.decodeBool(AppConfig.PREF_PREFER_IPV6) == true) } catch (e: Exception) { Log.d(ANG_PACKAGE, e.toString()) } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt index fc33653d..beeb27fe 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt @@ -64,7 +64,7 @@ class V2RayVpnService : VpnService(), ServiceControl { .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) private val defaultNetworkCallback by lazy { @@ -155,7 +155,7 @@ class V2RayVpnService : VpnService(), ServiceControl { val selfPackageName = BuildConfig.APPLICATION_ID if (settingsStorage?.decodeBool(AppConfig.PREF_PER_APP_PROXY) == true) { 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 if (bypassApps) apps?.add(selfPackageName) else apps?.remove(selfPackageName) apps?.forEach { diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/PerAppProxyActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/PerAppProxyActivity.kt index ecca716c..7f98f050 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/PerAppProxyActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/PerAppProxyActivity.kt @@ -215,7 +215,7 @@ class PerAppProxyActivity : BaseActivity() { } it.notifyDataSetChanged() true - } ?: false + } == true R.id.select_proxy_app -> { selectProxyApp() diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingEditActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingEditActivity.kt index 22986f3e..96f9ddae 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingEditActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingEditActivity.kt @@ -1,7 +1,6 @@ package com.v2ray.ang.ui import android.os.Bundle -import android.text.TextUtils import android.view.Menu import android.view.MenuItem import androidx.appcompat.app.AlertDialog @@ -38,7 +37,7 @@ class RoutingEditActivity : BaseActivity() { private fun bindingServer(rulesetItem: RulesetItem): Boolean { 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.etIp.text = Utils.getEditable(rulesetItem.ip?.joinToString(",")) binding.etPort.text = Utils.getEditable(rulesetItem.port) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingSettingRecyclerAdapter.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingSettingRecyclerAdapter.kt index 41b1c50a..a93be15b 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingSettingRecyclerAdapter.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/RoutingSettingRecyclerAdapter.kt @@ -10,7 +10,6 @@ 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(), @@ -26,7 +25,7 @@ class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) : Recy holder.itemRoutingSettingBinding.domainIp.text = (ruleset.domain ?: ruleset.ip ?: ruleset.port)?.toString() holder.itemRoutingSettingBinding.outboundTag.text = ruleset.outboundTag 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.itemRoutingSettingBinding.layoutEdit.setOnClickListener { @@ -37,7 +36,7 @@ class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) : Recy } holder.itemRoutingSettingBinding.chkEnable.setOnCheckedChangeListener { it, isChecked -> - if( !it.isPressed) return@setOnCheckedChangeListener + if (!it.isPressed) return@setOnCheckedChangeListener ruleset.enabled = isChecked SettingsManager.saveRoutingRuleset(position, ruleset) } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt index 7adaa88b..01d48773 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt @@ -507,7 +507,7 @@ class ServerActivity : BaseActivity() { val allowInsecure = if (allowInsecureField == null || allowinsecures[allowInsecureField].isBlank()) { - settingsStorage?.decodeBool(PREF_ALLOW_INSECURE) ?: false + settingsStorage?.decodeBool(PREF_ALLOW_INSECURE) == true } else { allowinsecures[allowInsecureField].toBoolean() } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/SubSettingRecyclerAdapter.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/SubSettingRecyclerAdapter.kt index 8186c71d..63466327 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/SubSettingRecyclerAdapter.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/SubSettingRecyclerAdapter.kt @@ -45,7 +45,7 @@ class SubSettingRecyclerAdapter(val activity: SubSettingActivity) : RecyclerView } holder.itemSubSettingBinding.chkEnable.setOnCheckedChangeListener { it, isChecked -> - if( !it.isPressed) return@setOnCheckedChangeListener + if (!it.isPressed) return@setOnCheckedChangeListener subItem.enabled = isChecked MmkvManager.encodeSubscription(subId, subItem) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/UserAssetActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/UserAssetActivity.kt index d2e317c5..cfe15aa3 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/UserAssetActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/UserAssetActivity.kt @@ -30,7 +30,6 @@ 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.SettingsManager import com.v2ray.ang.util.Utils import kotlinx.coroutines.Dispatchers diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/MmkvManager.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/MmkvManager.kt index 5c966276..24d10d66 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/MmkvManager.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/MmkvManager.kt @@ -192,7 +192,7 @@ object MmkvManager { } fun decodeServerRaw(guid: String): String? { - return serverRawStorage.decodeString(guid) ?: return null + return serverRawStorage.decodeString(guid) } //endregion diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt index bb559aaf..078f7798 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt @@ -422,8 +422,6 @@ object Utils { } - - private fun getSysLocale(): Locale = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { LocaleList.getDefault()[0] } else { diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt index 30942bf1..ed6a32ed 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt @@ -124,11 +124,9 @@ object V2rayConfigUtil { } } v2rayConfig.inbounds[0].port = socksPort - val fakedns = settingsStorage?.decodeBool(AppConfig.PREF_FAKE_DNS_ENABLED) - ?: false + val fakedns = settingsStorage?.decodeBool(AppConfig.PREF_FAKE_DNS_ENABLED) == true val sniffAllTlsAndHttp = - settingsStorage?.decodeBool(AppConfig.PREF_SNIFFING_ENABLED, true) - ?: true + settingsStorage?.decodeBool(AppConfig.PREF_SNIFFING_ENABLED, true) != false v2rayConfig.inbounds[0].sniffing?.enabled = fakedns || sniffAllTlsAndHttp v2rayConfig.inbounds[0].sniffing?.routeOnly = settingsStorage?.decodeBool(AppConfig.PREF_ROUTE_ONLY_ENABLED, false) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/ZipUtil.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/ZipUtil.kt index 5343f6d8..f0283701 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/ZipUtil.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/ZipUtil.kt @@ -31,7 +31,7 @@ object ZipUtil { } } } - if (filesToCompress.isEmpty()) { + if (filesToCompress.isEmpty) { return false } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/TrojanFmt.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/TrojanFmt.kt index 3bea8e26..949c2997 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/TrojanFmt.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/TrojanFmt.kt @@ -3,7 +3,6 @@ package com.v2ray.ang.util.fmt import com.v2ray.ang.AppConfig import com.v2ray.ang.dto.EConfigType import com.v2ray.ang.dto.ProfileItem -import com.v2ray.ang.dto.V2rayConfig import com.v2ray.ang.dto.V2rayConfig.OutboundBean import com.v2ray.ang.extension.idnHost import com.v2ray.ang.util.MmkvManager.settingsStorage @@ -13,7 +12,7 @@ import kotlin.text.orEmpty object TrojanFmt : FmtBase() { 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 uri = URI(Utils.fixIllegalUrl(str)) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/VlessFmt.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/VlessFmt.kt index 1168ef19..6f49ebad 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/VlessFmt.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/VlessFmt.kt @@ -12,7 +12,7 @@ import java.net.URI object VlessFmt : FmtBase() { 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 uri = URI(Utils.fixIllegalUrl(str)) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/WireguardFmt.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/WireguardFmt.kt index 283c8112..07d103f5 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/WireguardFmt.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/fmt/WireguardFmt.kt @@ -23,7 +23,7 @@ object WireguardFmt : FmtBase() { config.serverPort = uri.port.toString() 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.mtu = Utils.parseInt(queryParam["mtu"] ?: AppConfig.WIREGUARD_LOCAL_MTU) config.reserved = (queryParam["reserved"] ?: "0,0,0") @@ -52,7 +52,7 @@ object WireguardFmt : FmtBase() { } 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.mtu = Utils.parseInt(queryParam["mtu"] ?: AppConfig.WIREGUARD_LOCAL_MTU) config.reserved = (queryParam["reserved"] ?: "0,0,0") diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/SettingsViewModel.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/SettingsViewModel.kt index cbeb2dc5..2d19199b 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/SettingsViewModel.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/SettingsViewModel.kt @@ -44,7 +44,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application AppConfig.PREF_FRAGMENT_LENGTH, AppConfig.PREF_FRAGMENT_INTERVAL, AppConfig.PREF_MUX_XUDP_QUIC, - -> { + -> { settingsStorage?.encode(key, sharedPreferences.getString(key, "")) } @@ -63,7 +63,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application AppConfig.SUBSCRIPTION_AUTO_UPDATE, AppConfig.PREF_FRAGMENT_ENABLED, AppConfig.PREF_MUX_ENABLED, - -> { + -> { settingsStorage?.encode(key, sharedPreferences.getBoolean(key, false)) } diff --git a/V2rayNG/app/src/main/res/layout/item_recycler_bypass_list.xml b/V2rayNG/app/src/main/res/layout/item_recycler_bypass_list.xml index 5a1540be..f074f9ff 100644 --- a/V2rayNG/app/src/main/res/layout/item_recycler_bypass_list.xml +++ b/V2rayNG/app/src/main/res/layout/item_recycler_bypass_list.xml @@ -42,6 +42,6 @@ android:layout_height="wrap_content" android:clickable="false" android:focusable="false" - android:paddingStart="@dimen/padding_start"/> + android:paddingStart="@dimen/padding_start" /> \ No newline at end of file diff --git a/V2rayNG/app/src/main/res/layout/item_recycler_routing_setting.xml b/V2rayNG/app/src/main/res/layout/item_recycler_routing_setting.xml index fcfbc4b2..c36eb795 100644 --- a/V2rayNG/app/src/main/res/layout/item_recycler_routing_setting.xml +++ b/V2rayNG/app/src/main/res/layout/item_recycler_routing_setting.xml @@ -6,8 +6,7 @@ android:layout_height="wrap_content" android:gravity="center_vertical"> - - - \ No newline at end of file diff --git a/V2rayNG/app/src/main/res/values-fa/strings.xml b/V2rayNG/app/src/main/res/values-fa/strings.xml index 530fca6c..e0a2e317 100644 --- a/V2rayNG/app/src/main/res/values-fa/strings.xml +++ b/V2rayNG/app/src/main/res/values-fa/strings.xml @@ -311,5 +311,5 @@ جهانی(Global) ایران - + diff --git a/V2rayNG/app/src/main/res/values/attrs.xml b/V2rayNG/app/src/main/res/values/attrs.xml index 52069cfb..0df1370f 100644 --- a/V2rayNG/app/src/main/res/values/attrs.xml +++ b/V2rayNG/app/src/main/res/values/attrs.xml @@ -1,5 +1,6 @@ + diff --git a/V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt b/V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt index d7cb42bd..08872d0c 100644 --- a/V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt +++ b/V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt @@ -1,11 +1,4 @@ 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.assertFalse import org.junit.Assert.assertTrue