Skip to content

Various improvements - #1

Open
roptat wants to merge 4 commits into
b84330808:masterfrom
roptat:master
Open

roptat wants to merge 4 commits into
b84330808:masterfrom
roptat:master

Conversation

@roptat

@roptat roptat commented Jul 31, 2021

Copy link
Copy Markdown

Hi!

I've started using your RubyTextView recently and found a few issues that I fixed in this PR. First, my app used to target API 15 and above, but your library targets 21 or above. There's really no reason why it can't target 16, and the first commit ensures it can even target 15 like my app (lineSpacingExtra was added in 16).

Then, I set the text programmatically, not statically in the XML, which lead to a crash which I fixed in the second commit.

I also use a dark theme, so the hard-coded black color for the ruby text was almost not visible. Instead, the third patch replaces it to default to the default text color, just like the rest of the text.

Finally, I had a few issues with measurement and the way the text was painted. First, I needed to use the widget with width="wrapContent", but the measurement always returns the parent size, so the widget took all the space, leaving no space for the rest of my layout on the right. I fixed that by returning instead the width of the largest line. I also have some furigana that exceeds the size of the kanji it is related to, and this presents two issues: it can overflow on the left and be hidden, and it can be overwritten by the next furigana block. I fixed that by creating additional spacing between text blocks when the ruby text is longer than the text it is related to.

Julien Lepiller added 4 commits July 31, 2021 15:15
This ensures the right color is used by default even with dark theme.
This makes the widget respect `width=wrapContent` and prevents ruby text
from overflowing on the left.
ContextCompat.getColor(getContext(), R.color.black));
rubyTextColor = ta.getColor(R.styleable.RubyTextView_rubyTextColor, rubyTextColor);
spacing = ta.getDimension(R.styleable.RubyTextView_spacing, 0);
lineSpacingExtra = ta.getDimension(R.styleable.RubyTextView_lineSpacingExtra, 0);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please define lineSpacingExtra in attrs.xml

@b84330808 b84330808 left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

There is a missing value. I will approve the PR after updating, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants