Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nairobi IO Extended Dark Theme

Nairobi IO Extended Dark Theme

A brief overview of Androids Dark theme from Google IO 2019.

David Odari

June 15, 2019
Tweet

More Decks by David Odari

Other Decks in Programming

Transcript

  1. Available Modes //Always Dark Themed MODE_NIGHT_YES //Always Light Themed MODE_NIGHT_NO

    //Uses Current System Setting ( For Q and Above) MODE_NIGHT_FOLLOW_SYSTEM //Switches to dark theme when battery saver is activated MODE_NIGHT_AUTO_BATTERY
  2. Elevation will not work on Dark Theme. Elevation overlays solve

    this by applying the concept of surfaces becoming lighter with higher elevation. Overlays surface of components with colorSurface attribute.
  3. Triggers the uiMode configuration change Activity declares it can handle

    <activity ... android:configChanges="uiMode" /> onConfigurationChanged() method will be called
  4. fun checkDarkThemeMode(context: Context) : String { val mode = context.resources.configuration.uiMode.and(

    Configuration.UI_MODE_NIGHT_MASK) return when(mode){ Configuration.UI_MODE_NIGHT_NO -> “Light Theme” Configuration.UI_MODE_NIGHT_YES -> “Dark Theme” Configuration.UI_MODE_NIGHT_UNDEFINED -> “Unknown Mode” } }