Skip to content

Commit

Permalink
fix(android): restore res/drawable support for Ti.UI.Button (#13148)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28558
  • Loading branch information
jquick-axway committed Oct 28, 2021
1 parent 471036e commit 11dc187
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -17,7 +17,6 @@
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.view.TiDrawableReference;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.AttributedStringProxy;
Expand Down Expand Up @@ -311,18 +310,17 @@ private void updateButtonImage()
}

// Fetch the image.
TiDrawableReference drawableRef = null;
Drawable drawable = null;
Object imageObject = this.proxy.getProperty(TiC.PROPERTY_IMAGE);
if (imageObject != null) {
drawableRef = TiDrawableReference.fromObject(this.proxy.getActivity(), imageObject);
drawable = TiUIHelper.getResourceDrawable(imageObject);
}

// Update button's image/icon.
if (drawableRef != null) {
if (drawable != null) {
boolean imageIsMask = TiConvert.toBoolean(this.proxy.getProperty(TiC.PROPERTY_IMAGE_IS_MASK), true);
String colorString = TiConvert.toString(this.proxy.getProperty(TiC.PROPERTY_TINT_COLOR));
int colorValue = (colorString != null) ? TiConvert.toColor(colorString) : this.defaultColor;
Drawable drawable = drawableRef.getDensityScaledDrawable();
if (button instanceof MaterialButton) {
MaterialButton materialButton = (MaterialButton) button;
materialButton.setIcon(drawable);
Expand Down

0 comments on commit 11dc187

Please sign in to comment.