Add serviceName for grpc mode

https://github.com/teddysun/xray-plugin-android/pull/4

Signed-off-by: Teddysun <i@teddysun.com>
This commit is contained in:
Teddysun 2021-10-17 12:32:00 +09:00
parent 4fe9b10179
commit 1dbc70596c
No known key found for this signature in database
GPG key ID: 09BD4C080AD6C46D
2 changed files with 9 additions and 0 deletions

View file

@ -42,6 +42,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
private val mode by lazy { findPreference<ListPreference>("mode")!! }
private val host by lazy { findPreference<EditTextPreference>("host")!! }
private val path by lazy { findPreference<EditTextPreference>("path")!! }
private val serviceName by lazy { findPreference<EditTextPreference>("serviceName")!! }
private val mux by lazy { findPreference<EditTextPreference>("mux")!! }
private val certRaw by lazy { findPreference<EditTextPreference>("certRaw")!! }
private val loglevel by lazy { findPreference<ListPreference>("loglevel")!! }
@ -65,6 +66,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
putWithDefault("host", host.text, "cloudfront.com")
putWithDefault("path", path.text, "/")
putWithDefault("mux", mux.text, "1")
putWithDefault("serviceName", serviceName.text, "")
putWithDefault("certRaw", certRaw.text?.replace("\n", ""), "")
putWithDefault("loglevel", loglevel.value, "warning")
}
@ -81,6 +83,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
path.text = options["path"] ?: "/"
mux.text = options["mux"] ?: "1"
certRaw.text = options["certRaw"]
serviceName.text = options["serviceName"]
loglevel.value = options["loglevel"] ?: "warning"
}
@ -106,6 +109,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
val (mode, tls) = readMode(newValue as String)
path.isEnabled = mode == null
mux.isEnabled = mode == null
serviceName.isEnabled = mode == "grpc"
certRaw.isEnabled = mode != null || tls
return true
}

View file

@ -17,6 +17,11 @@
app:persistent="false"
app:title="Path"
app:useSimpleSummaryProvider="true"/>
<EditTextPreference
app:key="serviceName"
app:persistent="false"
app:title="Service name"
app:useSimpleSummaryProvider="true"/>
<EditTextPreference
app:key="mux"
app:persistent="false"