Simplify UpdateChannel

This commit is contained in:
vvb2060 2021-02-22 01:21:41 +08:00 committed by John Wu
parent 8bb2f356c0
commit 860a05abf2
2 changed files with 5 additions and 4 deletions

View File

@ -144,12 +144,12 @@ object UpdateChannel : BaseSettingsItem.Selector() {
} }
override val title = R.string.settings_update_channel_title.asTransitive() override val title = R.string.settings_update_channel_title.asTransitive()
override val entries: Array<String> = resources.getStringArray(R.array.update_channel).let { override val entries: Array<String> = resources.getStringArray(R.array.update_channel).apply {
if (BuildConfig.DEBUG) it.toMutableList().apply { add("Canary") }.toTypedArray() else it if (BuildConfig.VERSION_CODE % 100 == 0)
toMutableList().apply { removeAt(Config.Value.CANARY_CHANNEL) }.toTypedArray()
} }
override val description override val description
get() = entries.getOrNull(value)?.asTransitive() get() = entries.getOrNull(value)?.asTransitive() ?: TransitiveText.String(entries[0])
?: TransitiveText.String(if (value == -1) entries[0] else "Canary")
} }
object UpdateChannelUrl : BaseSettingsItem.Input() { object UpdateChannelUrl : BaseSettingsItem.Input() {

View File

@ -73,6 +73,7 @@
<item>@string/settings_update_stable</item> <item>@string/settings_update_stable</item>
<item>@string/settings_update_beta</item> <item>@string/settings_update_beta</item>
<item>@string/settings_update_custom</item> <item>@string/settings_update_custom</item>
<item>Canary</item>
</string-array> </string-array>
</resources> </resources>