Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28369] Android: Add Ti.UI.overrideUserInterfaceStyle property

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2021-06-10T17:17:43.000+0000
Affected Version/sn/a
Fix Version/sRelease 10.0.1
ComponentsAndroid, iOS, Mac
Labelsandroid, iOS, theme
ReporterJoshua Quick
AssigneeJoshua Quick
Created2021-02-25T03:57:15.000+0000
Updated2021-06-10T17:17:43.000+0000

Description

*Summary:* We should add a new writable Ti.UI.overrideUserInterfaceStyle property that allows you to force the app to use a dark or light theme instead of using the system assigned theme. If this property is assigned the [Ti.UI.USER_INTERFACE_STYLE_UNSPECIFIED](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI-property-USER_INTERFACE_STYLE_UNSPECIFIED) constant (the default), then the app will use the system theme instead. The existing read-only [Ti.UI.userInterfaceStyle](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI-property-userInterfaceStyle) property needs to be its own property. If the overrideUserInterfaceStyle is set to unspecified, then the userInterfaceStyle property will reveal if the system is using the dark or light theme. *Native Implementation:* On iOS, this can be implemented via the native [UIView.overrideUserInterfaceStyle](https://developer.apple.com/documentation/uikit/uiview/3238086-overrideuserinterfacestyle?language=objc) property. On Android, this can be implemented via the Java [AppCompatDelegate.setNightMode()](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)) method. *Android Example:* !AndroidExample.gif!

Attachments

FileDateSize
AndroidExample.gif2021-02-27T05:44:51.000+00004318999
ThemeOverrideTest.js2021-02-25T04:49:44.000+00001914

Comments

  1. Joshua Quick 2021-02-25

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12353
  2. Samir Mohammed 2021-03-04

    FR Passed, waiting on Jenkins build and Backport.
  3. Christopher Williams 2021-03-05

    merged to master and 10_0_X for 10.0.0 release target.
  4. Joshua Quick 2021-06-09

    This change didn't get back-ported and is missing in the 10_0_X branch. We'll have to back-port the following commit. https://github.com/appcelerator/titanium_mobile/pull/12353/commits/40166f6ffbafd8a82a21ea3e4a4108aff8e22b3e
  5. Joshua Quick 2021-06-09

    PR (10_0_X): https://github.com/appcelerator/titanium_mobile/pull/12876

JSON Source