Background
On recent Android versions, ever since Android 8.1, the OS got more and more support for themes. More specifically dark theme.
The problem
Even though there is a lot of talk about dark mode in the point-of-view for users, there is almost nothing that's written for developers.
What I've found
Starting from Android 8.1, Google provided some sort of dark theme . If the user chooses to have a dark wallpaper, some UI components of the OS would turn black (article here).
In addition, if you developed a live wallpaper app, you could tell the OS which colors it has (3 types of colors), which affected the OS colors too (at least on Vanilla based ROMs and on Google devices). That's why I even made an app that lets you have any wallpaper while still be able to choose the colors (here). This is done by calling notifyColorsChanged and then provide them using onComputeColors
Starting from Android 9.0, it is now possible to choose which theme to have: light, dark or automatic (based on wallpaper) :
And now on the near Android Q , it seems it went further, yet it's still unclear to what extent. Somehow a launcher called "Smart Launcher" has ridden on it, offering to use the theme right on itself (article here). So, if you enable dark mode (manually, as written here) , you get the app's settings screen as such:
The only thing I've found so far is the above articles, and that I'm following this kind of topic.
I also know how to request the OS to change color using the live wallpaper, but this seems to be changing on Android Q, at least according to what I've seen when trying it (I think it's more based on time-of-day, but not sure).
The questions
Is there an API to get which colors the OS is set to use ?
Is there any kind of API to get the theme of the OS ? From which version?
Is the new API somehow related to night mode too? How do those work together?
Is there a nice API for apps to handle the chosen theme? Meaning that if the OS is in certain theme, so will the current app?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…