Skip to content

Commit 6304e31

Browse files
committed
Support mux
1 parent 3958af5 commit 6304e31

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigFragment.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ package com.github.shadowsocks.plugin.v2ray
2323
import android.app.Activity
2424
import android.content.Intent
2525
import android.os.Bundle
26+
import android.text.InputFilter
27+
import android.text.InputType
2628
import android.view.View
2729
import androidx.preference.EditTextPreference
2830
import androidx.preference.ListPreference
@@ -40,6 +42,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
4042
private val mode by lazy { findPreference<ListPreference>("mode") }
4143
private val host by lazy { findPreference<EditTextPreference>("host") }
4244
private val path by lazy { findPreference<EditTextPreference>("path") }
45+
private val mux by lazy { findPreference<EditTextPreference>("mux") }
4346
private val certRaw by lazy { findPreference<EditTextPreference>("certRaw") }
4447
private val loglevel by lazy { findPreference<ListPreference>("loglevel") }
4548

@@ -59,6 +62,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
5962
if (tls) this["tls"] = null
6063
putWithDefault("host", host.text, "cloudfront.com")
6164
putWithDefault("path", path.text, "/")
65+
putWithDefault("mux", mux.text, "1")
6266
putWithDefault("certRaw", certRaw.text?.replace("\n", ""), "")
6367
putWithDefault("loglevel", loglevel.value, "warning")
6468
}
@@ -71,18 +75,26 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
7175
}.also { onPreferenceChange(null, it) }
7276
host.text = options["host"] ?: "cloudfront.com"
7377
path.text = options["path"] ?: "/"
78+
mux.text = options["mux"] ?: "1"
7479
certRaw.text = options["certRaw"]
7580
loglevel.value = options["loglevel"] ?: "warning"
7681
}
7782

7883
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
7984
addPreferencesFromResource(R.xml.config)
8085
mode.onPreferenceChangeListener = this
86+
host.setOnBindEditTextListener { it.inputType = InputType.TYPE_TEXT_VARIATION_URI }
87+
path.setOnBindEditTextListener { it.inputType = InputType.TYPE_TEXT_VARIATION_URI }
88+
mux.setOnBindEditTextListener {
89+
it.inputType = InputType.TYPE_CLASS_NUMBER
90+
it.filters = arrayOf(InputFilter.LengthFilter(4))
91+
}
8192
}
8293

8394
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
8495
val (mode, tls) = readMode(newValue as String)
8596
path.isEnabled = mode == null
97+
mux.isEnabled = mode == null
8698
certRaw.isEnabled = mode != null || tls
8799
return true
88100
}

app/src/main/res/xml/config.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
app:persistent="false"
1818
app:title="Path"
1919
app:useSimpleSummaryProvider="true"/>
20+
<EditTextPreference
21+
app:key="mux"
22+
app:persistent="false"
23+
app:title="Concurrent connections"
24+
app:useSimpleSummaryProvider="true"/>
2025
<EditTextPreference
2126
app:key="certRaw"
2227
app:persistent="false"

0 commit comments

Comments
 (0)