[TIMOB-28547] Android: Menu item icon ignores theme if assigned a resource ID
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-10-29T03:39:10.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 10.2.0 |
Components | Android |
Labels | android, drawable, menu, menuitem, resource, theme |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2021-10-06T23:49:56.000+0000 |
Updated | 2021-10-29T03:39:10.000+0000 |
Description
*Summary:*
When assigning a Copy [^ic_baseline_delete_24.xml] to folder:
MenuItem
"icon" property a res drawable integer ID, the app's theme is wrongly ignored. This is only an issue if the drawable uses a color attribute/style.
*Notes:*
This is not an issue if the resource drawable has hard-coded colors.
*Steps to reproduce:*
Use the below code as the "app.js".
Copy [^ic_baseline_delete_24.xml] to folder: ./platform/android/res/drawable
Build and run on Android.
const window = Ti.UI.createWindow();
window.activity.onCreateOptionsMenu = (e) => {
const menuItem = e.menu.add({
icon: Ti.App.Android.R.drawable.ic_baseline_delete_24,
showAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS,
});
menuItem.addEventListener("click", () => {
alert("Menu item clicked on.");
});
};
window.open();
*Result:*
In the top-right corner, notice the delete/trash icon is always displayed white. When the "light" theme is shown, the menu item can't be seen. It shouldn't be shown as white in the dark theme either and should be gray like bottom navigation icons.
!MenuIconLight-Bad.png|thumbnail! !MenuItemDark-Bad.png|thumbnail!
*Expected Result:*
For the default Titanium light theme, the icon should be gray.
!MenuIconLight-Good.png|thumbnail! !MenuItemDark-Good.png|thumbnail!
Attachments
File | Date | Size |
---|---|---|
ic_baseline_close_24.xml | 2021-10-27T20:40:03.000+0000 | 420 |
ic_baseline_delete_24.xml | 2021-10-06T23:42:56.000+0000 | 402 |
MenuIconLight-Bad.png | 2021-10-06T23:52:20.000+0000 | 397133 |
MenuIconLight-Good.png | 2021-10-06T23:52:20.000+0000 | 398571 |
MenuItemDark-Bad.png | 2021-10-06T23:57:34.000+0000 | 401287 |
MenuItemDark-Good.png | 2021-10-06T23:57:34.000+0000 | 401203 |
PR (master): https://github.com/appcelerator/titanium_mobile/pull/13106
There's still an issue where menu icon wrongly uses the activity context's theme, when it should use the ActionBar context theme instead. This is an issue if you use the
Theme.Titanium.Light
theme because it uses theTheme.MaterialComponents.Light.DarkActionBar
which sets the "attr/colorControlNormal" differently than the activity.PR (master): https://github.com/appcelerator/titanium_mobile/pull/13147