Support mux
This commit is contained in:
parent
3958af5a6f
commit
6304e31227
2 changed files with 17 additions and 0 deletions
|
@ -23,6 +23,8 @@ package com.github.shadowsocks.plugin.v2ray
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.InputFilter
|
||||||
|
import android.text.InputType
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.preference.EditTextPreference
|
import androidx.preference.EditTextPreference
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
|
@ -40,6 +42,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
||||||
private val mode by lazy { findPreference<ListPreference>("mode") }
|
private val mode by lazy { findPreference<ListPreference>("mode") }
|
||||||
private val host by lazy { findPreference<EditTextPreference>("host") }
|
private val host by lazy { findPreference<EditTextPreference>("host") }
|
||||||
private val path by lazy { findPreference<EditTextPreference>("path") }
|
private val path by lazy { findPreference<EditTextPreference>("path") }
|
||||||
|
private val mux by lazy { findPreference<EditTextPreference>("mux") }
|
||||||
private val certRaw by lazy { findPreference<EditTextPreference>("certRaw") }
|
private val certRaw by lazy { findPreference<EditTextPreference>("certRaw") }
|
||||||
private val loglevel by lazy { findPreference<ListPreference>("loglevel") }
|
private val loglevel by lazy { findPreference<ListPreference>("loglevel") }
|
||||||
|
|
||||||
|
@ -59,6 +62,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
||||||
if (tls) this["tls"] = null
|
if (tls) this["tls"] = null
|
||||||
putWithDefault("host", host.text, "cloudfront.com")
|
putWithDefault("host", host.text, "cloudfront.com")
|
||||||
putWithDefault("path", path.text, "/")
|
putWithDefault("path", path.text, "/")
|
||||||
|
putWithDefault("mux", mux.text, "1")
|
||||||
putWithDefault("certRaw", certRaw.text?.replace("\n", ""), "")
|
putWithDefault("certRaw", certRaw.text?.replace("\n", ""), "")
|
||||||
putWithDefault("loglevel", loglevel.value, "warning")
|
putWithDefault("loglevel", loglevel.value, "warning")
|
||||||
}
|
}
|
||||||
|
@ -71,6 +75,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
||||||
}.also { onPreferenceChange(null, it) }
|
}.also { onPreferenceChange(null, it) }
|
||||||
host.text = options["host"] ?: "cloudfront.com"
|
host.text = options["host"] ?: "cloudfront.com"
|
||||||
path.text = options["path"] ?: "/"
|
path.text = options["path"] ?: "/"
|
||||||
|
mux.text = options["mux"] ?: "1"
|
||||||
certRaw.text = options["certRaw"]
|
certRaw.text = options["certRaw"]
|
||||||
loglevel.value = options["loglevel"] ?: "warning"
|
loglevel.value = options["loglevel"] ?: "warning"
|
||||||
}
|
}
|
||||||
|
@ -78,11 +83,18 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
addPreferencesFromResource(R.xml.config)
|
addPreferencesFromResource(R.xml.config)
|
||||||
mode.onPreferenceChangeListener = this
|
mode.onPreferenceChangeListener = this
|
||||||
|
host.setOnBindEditTextListener { it.inputType = InputType.TYPE_TEXT_VARIATION_URI }
|
||||||
|
path.setOnBindEditTextListener { it.inputType = InputType.TYPE_TEXT_VARIATION_URI }
|
||||||
|
mux.setOnBindEditTextListener {
|
||||||
|
it.inputType = InputType.TYPE_CLASS_NUMBER
|
||||||
|
it.filters = arrayOf(InputFilter.LengthFilter(4))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
|
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
|
||||||
val (mode, tls) = readMode(newValue as String)
|
val (mode, tls) = readMode(newValue as String)
|
||||||
path.isEnabled = mode == null
|
path.isEnabled = mode == null
|
||||||
|
mux.isEnabled = mode == null
|
||||||
certRaw.isEnabled = mode != null || tls
|
certRaw.isEnabled = mode != null || tls
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
app:persistent="false"
|
app:persistent="false"
|
||||||
app:title="Path"
|
app:title="Path"
|
||||||
app:useSimpleSummaryProvider="true"/>
|
app:useSimpleSummaryProvider="true"/>
|
||||||
|
<EditTextPreference
|
||||||
|
app:key="mux"
|
||||||
|
app:persistent="false"
|
||||||
|
app:title="Concurrent connections"
|
||||||
|
app:useSimpleSummaryProvider="true"/>
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
app:key="certRaw"
|
app:key="certRaw"
|
||||||
app:persistent="false"
|
app:persistent="false"
|
||||||
|
|
Loading…
Reference in a new issue