Night Modes ● MODE_NIGHT_NO // LIGHT ● MODE_NIGHT_YES // DARK ● MODE_NIGHT_AUTO_BATTERY // DARK IN BATTERY SAVE MODE ● MODE_NIGHT_FOLLOW_SYSTEM // SYSTEM PREFERENCE
Sum up ● Extend DayNight Theme ● Provide additional -night resources for Dark Theme ● Add preference for changing mode inside Application ● Persist preference choice ● Work with designer for the rest
Check is Dark theme applied fun Context.isDarkTheme(): Boolean { val mode = this.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK return mode == Configuration.UI_MODE_NIGHT_YES }
Elevation val bg = MaterialShapeDrawable .createWithElevationOverlay(this, 32.0f) // OR val color = ElevationOverlayProvider(this) .getSurfaceColorWithOverlayIfNeeded(32.0f)