Skip to content

Commit

Permalink
fix(android): menu and toolbar icons to use ActionBar style colors (#…
Browse files Browse the repository at this point in the history
…13147)

Co-authored-by: Gary Mathews <contact@garymathews.com>
  • Loading branch information
jquick-axway and garymathews committed Oct 29, 2021
1 parent 11dc187 commit 2052f78
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiColorHelper;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.view.TiCompositeLayout;
import org.appcelerator.titanium.view.TiDrawableReference;
import org.appcelerator.titanium.view.TiToolbarStyleHandler;
Expand Down Expand Up @@ -256,9 +257,15 @@ public Object getLogo()
*/
public void setNavigationIcon(Object object)
{
navigationIcon = object;
TiDrawableReference tiDrawableReference = TiDrawableReference.fromObject(proxy, object);
((MaterialToolbar) getNativeView()).setNavigationIcon(tiDrawableReference.getDrawable());
this.navigationIcon = object;
if (object instanceof Number) {
this.toolbar.setNavigationIcon(TiConvert.toInt(object));
} else if (object != null) {
TiDrawableReference tiDrawableReference = TiDrawableReference.fromObject(proxy, object);
this.toolbar.setNavigationIcon(tiDrawableReference.getDrawable());
} else {
this.toolbar.setNavigationIcon(null);
}
}

/**
Expand All @@ -276,9 +283,13 @@ public Object getNavigationIcon()
*/
public void setOverflowMenuIcon(Object object)
{
overflowMenuIcon = object;
TiDrawableReference tiDrawableReference = TiDrawableReference.fromObject(proxy, object);
((MaterialToolbar) getNativeView()).setOverflowIcon(tiDrawableReference.getDrawable());
this.overflowMenuIcon = object;
if (object != null) {
TiDrawableReference tiDrawableReference = TiDrawableReference.fromObject(proxy, object);
this.toolbar.setOverflowIcon(tiDrawableReference.getDrawable());
} else {
this.toolbar.setOverflowIcon(null);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiFileHelper;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.util.TiUrl;
import org.appcelerator.titanium.view.TiUIView;

Expand Down Expand Up @@ -233,10 +232,7 @@ public MenuItemProxy setIcon(Object icon)
}
}
} else if (icon instanceof Number) {
Drawable d = TiUIHelper.getResourceDrawable(TiConvert.toInt(icon));
if (d != null) {
item.setIcon(d);
}
item.setIcon(TiConvert.toInt(icon));
}
}
return this;
Expand Down

0 comments on commit 2052f78

Please sign in to comment.