Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): restore "res/drawable" support to Ti.UI.Button images #13148

Merged
merged 2 commits into from
Oct 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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