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

[TIMOB-25985] iOS/Android: Add "attributedString" API to Ti.UI.Button #10010

Merged
merged 12 commits into from Jun 21, 2018

Conversation

hansemannn
Copy link
Collaborator

@hansemannn hansemannn commented Apr 25, 2018

@build
Copy link
Contributor

build commented Apr 25, 2018

Messages
📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS

if (bundleText.containsKey(TiC.PROPERTY_ATTRIBUTED_STRING)) {
btn.setText((Spannable) bundleText.getCharSequence(TiC.PROPERTY_ATTRIBUTED_STRING));
}
}
Copy link
Contributor

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);
}

Copy link
Collaborator Author

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!

Copy link
Contributor

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Will change now.

Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: Pass (Android)

Copy link
Contributor

@vijaysingh-axway vijaysingh-axway left a 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.

@build
Copy link
Contributor

build commented Jun 21, 2018

Messages
📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS

@hansemannn hansemannn merged commit 1307a32 into tidev:master Jun 21, 2018
@hansemannn hansemannn modified the milestones: 7.4.0, 7.5.0 Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants