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
[TIMOB-25985] iOS/Android: Add "attributedString" API to Ti.UI.Button #10010
Conversation
Generated by 🚫 dangerJS |
if (bundleText.containsKey(TiC.PROPERTY_ATTRIBUTED_STRING)) { | ||
btn.setText((Spannable) bundleText.getCharSequence(TiC.PROPERTY_ATTRIBUTED_STRING)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to call toSpannableInBundle()
do you? We don't need to for labels, which uses Android's TextView
Java class... andr Android Button
class inherits from TextView
as well. Also, the setText()
method accepts a CharSequence
type that a Spannable
type inherits from. So, no casting should be needed. How about something like this?
AppCompatButton btn = (AppCompatButton) getNativeView();
if (btn != null) {
CharSequence text = AttributedStringProxy.toSpannable(attrString, TiApplication.getAppCurrentActivity());
if (text == null) {
text = "";
}
btn.setText(text);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was basically copied from the label implementation, but I could change it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. You copied it from "TiUIText.java" which is our TextField/TextArea code (seems to be doing an unnecessary step). The way I'm doing it is based on the "TiUILabel.java" code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Will change now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: Pass (Android)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR approved for iOS.
Generated by 🚫 dangerJS |
JIRA: https://jira.appcelerator.org/browse/TIMOB-25985