Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Feb 14, 2024
1 parent c243fad commit 3cd95fb
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 109 deletions.
6 changes: 4 additions & 2 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ object AppConfig {
const val PREF_FRAGMENT_LENGTH = "pref_fragment_length"
const val PREF_FRAGMENT_INTERVAL = "pref_fragment_interval"

const val HTTP_PROTOCOL: String = "http://"
const val HTTPS_PROTOCOL: String = "https://"
const val PROTOCOL_HTTP: String = "http://"
const val PROTOCOL_HTTPS: String = "https://"
const val PROTOCOL_FREEDOM: String = "freedom"

const val BROADCAST_ACTION_SERVICE = "com.v2ray.ang.action.service"
const val BROADCAST_ACTION_ACTIVITY = "com.v2ray.ang.action.activity"
Expand All @@ -65,6 +66,7 @@ object AppConfig {
const val TAG_AGENT = "proxy"
const val TAG_DIRECT = "direct"
const val TAG_BLOCKED = "block"
const val TAG_FRAGMENT = "fragment"

const val androidpackagenamelistUrl =
"https://raw.githubusercontent.com/2dust/androidpackagenamelist/master/proxy.txt"
Expand Down
4 changes: 0 additions & 4 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ServerConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ data class ServerConfig(
return fullConfig?.getProxyOutbound()
}

fun getFragmentOutbound(): V2rayConfig.OutboundBean? {
return fullConfig?.getFragmentOutbound()
}

fun getAllOutboundTags(): MutableList<String> {
if (configType != EConfigType.CUSTOM) {
return mutableListOf(TAG_AGENT, TAG_DIRECT, TAG_BLOCKED)
Expand Down
9 changes: 0 additions & 9 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,6 @@ data class V2rayConfig(
return null
}

fun getFragmentOutbound(): OutboundBean? {
outbounds.forEach { outbound ->
if (outbound.protocol == "freedom" && outbound.tag == "fragment") {
return outbound
}
}
return null
}

fun toPrettyPrinting(): String {
return GsonBuilder()
.setPrettyPrinting()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class UrlSchemeActivity : BaseActivity() {
if ("text/plain" == type) {
intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
val uri = Uri.parse(it)
if (uri.scheme?.startsWith(AppConfig.HTTPS_PROTOCOL) == true || uri.scheme?.startsWith(
AppConfig.HTTP_PROTOCOL
if (uri.scheme?.startsWith(AppConfig.PROTOCOL_HTTPS) == true || uri.scheme?.startsWith(
AppConfig.PROTOCOL_HTTP
) == true
) {
val name = uri.getQueryParameter("name") ?: "Subscription"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import com.google.gson.GsonBuilder
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.AppConfig.ANG_CONFIG
import com.v2ray.ang.AppConfig.HTTPS_PROTOCOL
import com.v2ray.ang.AppConfig.HTTP_PROTOCOL
import com.v2ray.ang.AppConfig.PROTOCOL_HTTPS
import com.v2ray.ang.AppConfig.PROTOCOL_HTTP
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V4
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_MTU
import com.v2ray.ang.R
Expand All @@ -24,7 +24,6 @@ import java.net.URI
import java.util.*
import com.v2ray.ang.extension.idnHost
import com.v2ray.ang.extension.removeWhiteSpace
import com.v2ray.ang.extension.toast

object AngConfigManager {
private val mainStorage by lazy {
Expand Down Expand Up @@ -216,8 +215,8 @@ object AngConfigManager {
}

//maybe sub
if (TextUtils.isEmpty(subid) && (str.startsWith(HTTP_PROTOCOL) || str.startsWith(
HTTPS_PROTOCOL
if (TextUtils.isEmpty(subid) && (str.startsWith(PROTOCOL_HTTP) || str.startsWith(
PROTOCOL_HTTPS
))
) {
MmkvManager.importUrlAsSubscription(str)
Expand Down
Loading

0 comments on commit 3cd95fb

Please sign in to comment.