Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26514] Android: Custom theme applied to ActionBar/Toolbar title is lost when changing orientation as of 7.5.0.RC

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2018-11-07T00:31:43.000+0000
Affected Version/sRelease 7.5.0
Fix Version/sRelease 7.5.0
ComponentsAndroid
Labelsactionbar, android, orientation, theme, toolbar
ReporterJoshua Quick
AssigneeJoshua Quick
Created2018-11-02T23:43:46.000+0000
Updated2018-11-07T23:19:38.000+0000

Description

*Summary:* When applying a custom theme to an Android app or activity, the theme applied to an ActionBar or Toolbar title is lost when changing app orientation. It ends up resetting back to the default theme. This bug was introduced into 7.5.0.RC. *Steps to reproduce:*

Download "kitchensink-v2" project from: [here](https://github.com/appcelerator/kitchensink-v2)

Set up project to build with 7.5.0.RC.

Build and run to an Android device.

Clear the alert dialog displayed on app startup.

Notice that the top ActionBar title has white text.

Rotate the device from portrait to landscape.

Notice that the top ActionBar title now has black text. (This is the bug.)

*Result:* Before rotating device. Notice the title text is white. !Good.png|thumbnail! After rotating, notice the title is now black. This is the bug. _(The white gap on left side is an Android P notch, which can't be captured. This is not an issue.)_ !Bad.png|thumbnail! *Cause:* The new [TiToolbarStyleHandler.java](https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/view/TiToolbarStyleHandler.java) class added to 7.5.0.RC is hard-coded to use the "style.Widget_AppCompat_Toolbar" theme. We need to find a way to acquire the theme resource ID applied to the activity and use that instead. This will solve it for the ActionBar as well since it's internally implemented as a Toolbar on Google's end.

Attachments

FileDateSize
Bad.png2018-11-02T23:47:00.000+000068273
Good.png2018-11-02T23:47:00.000+000078192

Comments

  1. Joshua Quick 2018-11-06

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10431 PR (7.5.x): https://github.com/appcelerator/titanium_mobile/pull/10432
  2. Lokesh Choudhary 2018-11-07

    FR Passed. PR Merged.
  3. Lokesh Choudhary 2018-11-07

    Verified the fix in SDK 7.5.0.v20181107142952. Closing.

JSON Source