add the default tab settings

This commit is contained in:
Relwi
2022-02-14 15:22:32 +01:00
committed by machiav3lli
parent afd6f21613
commit 41d85d7309
4 changed files with 51 additions and 13 deletions

View File

@ -35,6 +35,7 @@ object Preferences {
Key.RootPermission,
Key.SortOrder,
Key.Theme,
Key.DefaultTab,
Key.UpdateNotify,
Key.UpdateUnstable
).map { Pair(it.name, it) }.toMap()
@ -169,6 +170,12 @@ object Preferences {
)
)
object DefaultTab : Key<Preferences.DefaultTab>(
"default_tab", Value.EnumerationValue(
Preferences.DefaultTab.Explore
)
)
object UpdateNotify : Key<Boolean>("update_notify", Value.BooleanValue(true))
object UpdateUnstable : Key<Boolean>("update_unstable", Value.BooleanValue(false))
}
@ -237,6 +244,25 @@ object Preferences {
}
}
sealed class DefaultTab(override val valueString: String) : Enumeration<DefaultTab> {
override val values: List<DefaultTab>
get() = listOf(Explore, Latest, Installed)
abstract fun getResId(configuration: Configuration): Int
object Explore : DefaultTab("explore") {
override fun getResId(configuration: Configuration): Int = R.id.exploreTab
}
object Latest : DefaultTab("latest") {
override fun getResId(configuration: Configuration): Int = R.id.latestTab
}
object Installed : DefaultTab("installed") {
override fun getResId(configuration: Configuration): Int = R.id.installedTab
}
}
operator fun <T> get(key: Key<T>): T {
return key.default.get(preferences, key.name, key.default)
}