Android Q’s Dark Mode: How Google’s next Android OS will tackle blindingly light themes
In our first post detailing the changes we found from the in-development Android Q build we obtained, we spoke briefly about the dark mode that has everyone all excited. To recap, Google’s built-in dark mode in Android Q can be enabled via a new “Dark Mode” option in Display Settings. Dark mode can either be always off, always on, or enabled automatically at night and disabled in the morning. Dark mode themes the SystemUI (volume panel, power menu, Quick Settings panel, notifications), Settings app, and framework (accent color, etc.).
Google doesn’t just want system elements to be dark themed, however. They’re also working to make sure all their first-party apps support dark mode when the user flips the switch. Google apps like Messages, Phone, Contacts, News, Play Games, YouTube, Maps, and more have been updated with user-facing dark mode toggles, while other apps like Google Chrome are still ironing out any kinks before Google I/O 2019. Google has also started encouraging third-party app developers to embrace dark themes in their apps because the company admits they’re great for battery life (at least on smartphones with OLED displays.)
To help developers update their apps with support for Android Q’s dark mode, Google is providing a new Developer Option that seems to force all apps to change to dark mode. This option isn’t intended for users who want to dark mode all the things, because it’s difficult for the system to pick the right colors for all apps that don’t have a native dark mode. Fortunately, Google already laid the groundwork for apps to support dark modes, and there are already many apps that look fine with Android Q’s override dark mode option enabled even if the app doesn’t have a user-facing dark mode toggle. Here’s a collection of screenshots from 24 different apps showing how they look when a dark mode is forced upon them using Android Q’s override dark mode toggle. Not every app will look as good, as I’ll show you below.
Implementing Dark Mode in Android Q
In API level 8 (Android 2.2 Froyo), Google introduced -night qualifiers for resources. App developers could switch between day and night mode using setNightMode in UiModeManager. However, setNightMode requires the device be in car mode or in docked mode if the device is on API level 22 or below. AppCompat v23.2 brought the DayNight implementation, letting apps like Reddit clients automatically switch between their day and night themes based on the time of day using AppCompatDeletegate.setDefaultNightMode(). API level 28 (Android 9 Pie) made MODE_NIGHT_FOLLOW_SYSTEM (the default value of setDefaultNightMode()) follow the user-defined system setting in Settings –> Developer Options –> Night mode. Google is working on improvements to the DayNight API in AppCompat, especially in regards to “frequently-encountered issues” such as problems with WebView. Lastly, Google has enabled night mode detection and has blocked apps without the MODIFY_DAY_NIGHT_MODE signature/privileged permission in Android Q’s framework. The latter change means apps can’t modify the system-wide night mode anymore, which is what allowed for a recent Messages’ bug to confuse users in Android Pie.
Forcing Dark Mode in Android Q
Applications like Snapchat, Slack, AOSP Email, AOSP Messaging, AOSP Dialer, and many more have -night resource qualifiers, even if they don’t provide the user a way to use the app with the night mode. Other apps which don’t have hard-coded -night resource qualifiers, like Facebook and Instagram, may or may not look good with Android Q’s override dark theme turned on. Instagram looks fine, while Facebook needs a lot of work. From my testing, the override night mode Developer Option is very distinct from color inversion in Accessibility Settings—perhaps Google intends for this feature to help developers create dark modes for their apps while the Android Q Developer Previews are ongoing. We won’t know exactly how this feature works until the source code for Android Q is released or Google publishes documentation for it, though.
Override dark mode in Android Q is most broken in apps that use WebViews.
In the “Cost of a Pixel Color” talk presented by Chris Banes and Alan Viverette from Google, the duo encourages developers to implement dark themes by:
- Using the DayNight API in AppCompat. Stock widgets respond automatically to changes in night mode, or you can add a switch in your app too.
- Applying overlay themes dynamically at runtime by calling getTheme().applyStyle(). More information can be found in this earlier talk here.
- Structuring your app to rely on using theme attributes like colorForeground, colorControlNormal, colorAccent, etc.
- Adding -night qualifiers for your resources. -night qualifiers should be used for resources that have difficult to extract theme colors.
- Enabling the inverted colors mode (Settings –> Colors –> Color inversion) to get a quick idea of how your app will look in dark mode. If you want to take a screenshot of your app with inverted colors, you should be aware that the color inversion won’t show up in the screenshot.
At release, Android Q’s dark mode will extend to first-party Google apps, but we’re hoping that third-party apps quickly adopt dark themes into their apps. Furthermore, we hope to see more apps automatically change to their night themes when the user enables the system-wide setting. Right now, the only app I’ve seen that automatically changes themes when Android Q’s system-wide dark mode is enabled is Google Contacts. We’ll see how things turn out in a couple of months when Android Q is released, but to all developers who are reading this: embrace the dark side!
Want more posts like this delivered to your inbox? Enter your email to be subscribed to our newsletter.