[TIMOB-28301] Android: Use the material DayNight theme by default
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2021-03-05T15:57:52.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 10.0.0 |
| Components | Android |
| Labels | android, breaking-change, darkmode, material-theme, theme |
| Reporter | Joshua Quick |
| Assignee | Joshua Quick |
| Created | 2020-12-19T05:19:06.000+0000 |
| Updated | 2021-04-01T20:59:40.000+0000 |
Description
*Summary:*
As of Titanium 9.3.0, apps use the
Theme.MaterialComponents.Bridge by default.
We should change it to Theme.MaterialComponents.DayNight.DarkActionBar.
*Reason:*
This would allow us to support Android 10's light/dark mode feature. A Titanium app would then be able to change between the 2 modes dynamically.
https://developer.android.com/guide/topics/ui/look-and-feel/darktheme
*New Titanium Themes:*
The following themes support dynamic switching between Day/Night (ie: Light/Dark) themes.
Note that OS versions older than Android 10 will use the Day (ie: Light) theme by default.
* Theme.Titanium.DayNight // This is the default.
* Theme.Titanium.DayNight.NoTitleBar
* Theme.Titanium.DayNight.Fullscreen
Titanium Dark-only themes.
* Theme.Titanium.Dark
* Theme.Titanium.Dark.NoTitleBar
* Theme.Titanium.Dark.Fullscreen
Titanium Light-only themes.
* Theme.Titanium.Light
* Theme.Titanium.Light.NoTitleBar
* Theme.Titanium.Light.Fullscreen
The above themes can be applied the AndroidManifest.xml <application/> element and/or to an Ti.UI.Window via its creation-only "theme" property. Titanium will assign the "Theme.Titanium.DayNight" to the application by default unless overriden in the "tiapp.xml" via the <applicaiton/> element.
The above Dark and Light themes are for app developers who want to opt-out of Light/Dark theme switching. This is especially useful for apps which hard-code colors.
*New AppDerived Themes:*
The following themes will be derived from the theme assigned to the AndroidManifest.xml <application/> element. If you do not set a custom theme there, then they will derive from the default Theme.Titanium.DayNight. These themes are intended to be passed to a Ti.UI.Window/Ti.UI.TabGroup "theme" property when wanting to remove the titlebar, show the window fullscreen, etc. and maintain the current app theme.
* Theme.AppDerived.NoTitleBar
* Theme.AppDerived.Fullscreen
* Theme.AppDerived.Translucent
* Theme.AppDerived.Translucent.NoTitleBar
* Theme.AppDerived.Translucent.Fullscreen
*Deprecated Themes:*
The following themes are also deprecated, but will still work. These themes have been replaced by the above mentioned Theme.AppDerived.\* themes.
* Theme.Titanium.NoTitleBar
* Theme.Titanium.Fullscreen
* Theme.Titanium.Translucent
* Theme.Titanium.Translucent.NoTitleBar
* Theme.Titanium.Translucent.Fullscreen
Do not use the following themes. These may cause errors or exceptions with the new material widgets that Titanium 10.0.0 uses. Custom themes must derive from Theme.MaterialComponents.\*, but not the Bridge derived material themes.
* Theme.AppCompat.\*
* Theme.MaterialComponents.Bridge.\*
*Breaking-Change:*
This means we would be dropping the old "holo dark" theme as shown below.
https://developer.android.com/guide/topics/ui/look-and-feel/themes
We would end up using Google's modern material design theme where the "light" theme uses a white background instead of the old dark gray background.
Attachments
| File | Date | Size |
|---|---|---|
| material.gif | 2021-02-26T00:12:58.000+0000 | 4318999 |
PR (master): https://github.com/appcelerator/titanium_mobile/pull/12353
merged to master and 10_0_X for 10.0.0 release target.
merged follow-on PR (https://github.com/appcelerator/titanium_mobile/pull/12537) to master and 10_0_X for 10.0.0 target (https://github.com/appcelerator/titanium_mobile/pull/12592).
[~lchoudhary] There's another follow-on PR here: https://github.com/appcelerator/titanium_mobile/pull/12622
follow-on PR #12622 merged to master, backport merged to 10_0_X
Follow-up PR to improve TabGroup material color and ripple handling. PR (master): https://github.com/appcelerator/titanium_mobile/pull/12679
merged following to master, manually cherry-picked to 10_0_X