Skip to content

Commit 6ceb5da

Browse files
committed
Make loglevel configurable
1 parent afd51b4 commit 6ceb5da

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
4141
private val host by lazy { findPreference<EditTextPreference>("host") }
4242
private val path by lazy { findPreference<EditTextPreference>("path") }
4343
private val certRaw by lazy { findPreference<EditTextPreference>("certRaw") }
44+
private val loglevel by lazy { findPreference<ListPreference>("loglevel") }
4445

4546
private fun readMode(value: String = mode.value) = when (value) {
4647
"websocket-http" -> Pair(null, null)
@@ -59,6 +60,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
5960
putWithDefault("host", host.text, "cloudfront.com")
6061
putWithDefault("path", path.text, "/")
6162
putWithDefault("certRaw", certRaw.text.replace("\n", ""), "")
63+
putWithDefault("loglevel", loglevel.value, "warning")
6264
}
6365

6466
fun onInitializePluginOptions(options: PluginOptions) {
@@ -70,6 +72,7 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
7072
host.text = options["host"] ?: "cloudfront.com"
7173
path.text = options["path"] ?: "/"
7274
certRaw.text = options["certRaw"]
75+
loglevel.value = options["loglevel"] ?: "warning"
7376
}
7477

7578
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {

app/src/main/res/values/arrays.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55
<item>websocket-tls</item>
66
<item>quic-tls</item>
77
</string-array>
8+
<string-array name="loglevels">
9+
<item>debug</item>
10+
<item>info</item>
11+
<item>warning</item>
12+
<item>error</item>
13+
<item>none</item>
14+
</string-array>
815
</resources>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,14 @@
2222
app:persistent="false"
2323
app:title="Certificate for TLS verification"
2424
app:useSimpleSummaryProvider="true"/>
25+
<PreferenceCategory
26+
app:title="Debug">
27+
<com.takisoft.preferencex.SimpleMenuPreference
28+
app:key="loglevel"
29+
app:persistent="false"
30+
app:entries="@array/loglevels"
31+
app:entryValues="@array/loglevels"
32+
app:title="Logcat level"
33+
app:useSimpleSummaryProvider="true"/>
34+
</PreferenceCategory>
2535
</PreferenceScreen>

0 commit comments

Comments
 (0)