-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Better emoji height management #117
Conversation
The EmojiSpan is now drawn with the exact line height of the TextView it is in. This avoids jumping lines when typing in an EditText or weird visuals when having a line with and one without emojis in a TextView. Furthermore the custom attr "emojiSize" was removed, as it is now automatically calculated. To still be able to choose the size, the textAppearance of the TextView should be changed. Another change is a large textAppearance for the adapter items, to showcase different heights.
Codecov Report
@@ Coverage Diff @@
## master #117 +/- ##
==========================================
+ Coverage 23.93% 24.49% +0.56%
==========================================
Files 19 19
Lines 656 641 -15
Branches 71 69 -2
==========================================
Hits 157 157
+ Misses 486 471 -15
Partials 13 13 |
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 like it. This bit of moving up and down has always bothered me. About backwards compatible, that's not a problem since we're still PRE v1.
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:context=".MainActivity"> | ||
xmlns:app="http://schemas.android.com/apk/res-auto" |
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.
can you revert those changes?
android:textIsSelectable="true" | ||
tools:text="my text" | ||
/> | ||
<com.vanniktech.emoji.EmojiTextView |
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.
also here please revert the white space changes
android:layout_height="wrap_content" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Large" | ||
android:textIsSelectable="true" | ||
tools:text="my 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.
also here revert the />
change
@@ -3,14 +3,13 @@ | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical" | |||
> | |||
android:orientation="vertical"> |
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.
>
should go on the same line
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
tools:context=".MainDialog"> | ||
xmlns:app="http://schemas.android.com/apk/res-auto" |
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.
same
@@ -39,8 +39,7 @@ | |||
android:layout_weight="1" | |||
android:imeOptions="actionSend" | |||
android:inputType="textCapSentences|textMultiLine" | |||
android:maxLines="3" | |||
app:emojiSize="26sp"/> | |||
android:maxLines="3"/> |
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.
same
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.
Don't know what to do about this one...
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.
Yup this one is okay. Sorry for the confusion
@@ -30,4 +31,9 @@ | |||
|
|||
return drawable; | |||
} | |||
|
|||
@Override public int getSize(final Paint paint, final CharSequence text, final int start, |
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.
why all of the parameters if all they do is just nothing?
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.
Well that's the signature of the base method, so we have to specify all of these parameters.
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 okay, didn't see the @Override
Everything done! I intuitively hit |
@@ -30,4 +31,9 @@ | |||
|
|||
return drawable; | |||
} | |||
|
|||
@Override public int getSize(final Paint paint, final CharSequence text, final int start, |
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 think this method can be just deleted right?
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.
No, we need it to specify the size of the Span
to the plattform.
@rubengees no worries about the formatting. There's still the |
I tried it without the method just now and it did not work. |
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.
Thanks a lot for this one :)
@@ -30,4 +31,9 @@ | |||
|
|||
return drawable; | |||
} | |||
|
|||
@Override public int getSize(final Paint paint, final CharSequence text, final int start, |
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 okay, didn't see the @Override
This would fix #116.
This change is not backwards-compatible.
Contents of this Pull Request
The
EmojiSpan
now automatically calculates it's size based on the line height of theTextView
it resides in. This has the advantage that there is no "jumping" when typing and weird visuals as described in #116.This removes the custom
emojiSize
attr; The user is expected to change text size by the normal methods (textAppearance
ortextSize
)If you look closely, you can see the "jump" at the left GIF.
(Sorry about the bad quality of the GIFs...)
Code changes to achieve this
EmojiSpan
now gets thelineHeight
of theEmojiTextView
orEmojiEditText
passed as the size. ThegetSize
method was overriden to make this work.emojiSize
attr and all associated methods have been removed.textAppearance
set toTextAppearance.AppCompat.Large
for showcasing how to change the size.