-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package com.vanniktech.emoji; | ||
|
||
import android.content.Context; | ||
import android.graphics.Paint; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.annotation.DrawableRes; | ||
import android.support.annotation.NonNull; | ||
|
@@ -30,4 +31,9 @@ final class EmojiSpan extends DynamicDrawableSpan { | |
|
||
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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Oh okay, didn't see the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. No, we need it to specify the size of the |
||
final int end, final Paint.FontMetricsInt fm) { | ||
return size; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,33 @@ | ||
package com.vanniktech.emoji; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.widget.AppCompatTextView; | ||
import android.text.SpannableStringBuilder; | ||
import android.util.AttributeSet; | ||
|
||
public class EmojiTextView extends AppCompatTextView { | ||
private int emojiSize; | ||
|
||
public EmojiTextView(final Context context) { | ||
this(context, null); | ||
} | ||
|
||
public EmojiTextView(final Context context, final AttributeSet attrs) { | ||
super(context, attrs); | ||
init(attrs); | ||
|
||
init(); | ||
} | ||
|
||
private void init(@Nullable final AttributeSet attrs) { | ||
private void init() { | ||
if (!isInEditMode()) { | ||
EmojiManager.getInstance().verifyInstalled(); | ||
} | ||
|
||
if (attrs == null) { | ||
emojiSize = (int) getTextSize(); | ||
} else { | ||
final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.emoji); | ||
|
||
try { | ||
emojiSize = (int) a.getDimension(R.styleable.emoji_emojiSize, getTextSize()); | ||
} finally { | ||
a.recycle(); | ||
} | ||
} | ||
|
||
setText(getText()); | ||
} | ||
|
||
@Override public void setText(final CharSequence rawText, final BufferType type) { | ||
final CharSequence text = rawText == null ? "" : rawText; | ||
final SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text); | ||
EmojiHandler.addEmojis(getContext(), spannableStringBuilder, emojiSize); | ||
EmojiHandler.addEmojis(getContext(), spannableStringBuilder, getLineHeight()); | ||
super.setText(spannableStringBuilder, type); | ||
} | ||
|
||
public void setEmojiSize(final int pixels) { | ||
emojiSize = pixels; | ||
} | ||
} |
This file was deleted.
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