Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
object ThemeManager {
const val LIGHT_MODE = "Light"
const val DARK_MODE = "Dark"
private const val AUTO_BATTERY_MODE = "Auto-battery"
private const val FOLLOW_SYSTEM_MODE = "System"
fun applyTheme(themePreference: String) {
when (themePreference) {
LIGHT_MODE -> setDefaultNightMode(MODE_NIGHT_NO)
DARK_MODE -> setDefaultNightMode(MODE_NIGHT_YES)
AUTO_BATTERY_MODE -> setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY)
FOLLOW_SYSTEM_MODE -> setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment