Skip to content

Commit

Permalink
fix(android): toolbar items dark/light theme change support
Browse files Browse the repository at this point in the history
Fixes TIMOB-28434
  • Loading branch information
jquick-axway authored and sgtcoolguy committed May 24, 2021
1 parent 765a1ec commit babc993
Showing 1 changed file with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiToolbarProxy;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.widget.TiToolbar;

@Kroll.proxy(creatableInModule = UIModule.class,
Expand All @@ -28,7 +28,6 @@
})
public class ToolbarProxy extends TiToolbarProxy
{

private static final java.lang.String TAG = "Toolbar";

public View getToolbarInstance()
Expand All @@ -51,7 +50,25 @@ public TiUIView createView(Activity activity)
return new TiToolbar(this);
}

//region Android only methods
/**
* Sets the activity this proxy's view should be attached to.
* @param activity The activity this proxy's view should be attached to.
*/
@Override
public void setActivity(Activity activity)
{
super.setActivity(activity);

Object value = getProperty(TiC.PROPERTY_ITEMS);
if ((value != null) && value.getClass().isArray()) {
for (Object nextObject : (Object[]) value) {
if (nextObject instanceof TiViewProxy) {
((TiViewProxy) nextObject).setActivity(activity);
}
}
}
}

@Kroll.method
public void collapseActionView()
{
Expand Down Expand Up @@ -157,7 +174,21 @@ public void showOverflowMenu()
{
getTiToolbarView().showOverFlowMenu();
}
//endregion

@Override
public void releaseViews()
{
super.releaseViews();

Object value = getProperty(TiC.PROPERTY_ITEMS);
if ((value != null) && value.getClass().isArray()) {
for (Object nextObject : (Object[]) value) {
if (nextObject instanceof TiViewProxy) {
((TiViewProxy) nextObject).releaseViews();
}
}
}
}

@Override
public String getApiName()
Expand Down

0 comments on commit babc993

Please sign in to comment.