[TIMOB-27501] Android: Be able to determine dark / light theme, as well as changes on it
GitHub Issue | n/a |
Type | Improvement |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-08-03T20:42:58.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.1.0 |
Components | n/a |
Labels | n/a |
Reporter | Sergey Volkov |
Assignee | Christopher Williams |
Created | 2019-10-01T16:11:31.000+0000 |
Updated | 2020-08-03T20:42:58.000+0000 |
Description
A developer should be able to check the current Configuration.UI_MODE_NIGHT_MASK
, i.e. dark theme vs light theme.
Attachments
Documentation: https://developer.android.com/guide/topics/ui/look-and-feel/darktheme Sample code for the patch:
Also patch provides additional build step for android: color resources (xml) are generated from "semantic.colors.json" (
res/values/values.xml
for "light" colors andres/values-night/values-night.xml
for "dark"). This allows to define colors one time in "semantic.colors.json" and then use them in android xml-theme.I've started to look into this, because the iOS side had some funkiness to it as well. We should have a cross-platform API to query for whether we're in dark/night mode versus normal/light mode. We had a property off the
Ti.App.iOS
namesake for iOS. We also had an API inTi.UI.fetchSemanticColor
that was problematic as it'd return different types based on OS/OS version - and one of the types was entirely undocumented. I'm in the process of trying to cleaning that up, incorporating [~s.volkov]'s PR changes for Android support, and trying to get the docs right around the previously undocumented proxy type it returns.WIP PR: https://github.com/appcelerator/titanium_mobile/pull/11457
WIP PR: https://github.com/appcelerator/titanium_mobile/pull/11457
FR Passed.
Verified on: Mac OS: 10.15.4 SDK: 9.1.0.v20200727104531 Appc CLI: 8.1.0-master.7 JDK: 11.0.4 Node: 10.17.0 Studio: 6.0.0.202005141803 Xcode: 12.0 beta Device: iPhone X(v13.4), iOS simulator 13.5, Pixel 3(v10.0), Pixel 2 emulator(v10.0)