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

Add infrastructure to let the provider perform emoji span replacements and utilize in emoji-google-compat #198

Merged
merged 30 commits into from
Sep 14, 2017

Conversation

stefanhaustein
Copy link
Contributor

@stefanhaustein stefanhaustein commented Aug 30, 2017

Add an interface to enable the provider to do the spanning
Use support library spanning if available
Avoid empty array allocation

Includes fixes from PR #199, which probably should go in first.

stefanhaustein and others added 22 commits August 23, 2017 00:01
…ode to use the drawable. Allows providers to provide optimized / not 1:1 resource based emoji
…port library spanning functionality when available.
…port library spanning functionality when available.
@codecov
Copy link

codecov bot commented Aug 31, 2017

Codecov Report

Merging #198 into master will increase coverage by 0.11%.
The diff coverage is 45.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #198      +/-   ##
==========================================
+ Coverage   27.93%   28.04%   +0.11%     
==========================================
  Files          22       22              
  Lines         809      820      +11     
  Branches       89       90       +1     
==========================================
+ Hits          226      230       +4     
- Misses        565      571       +6     
- Partials       18       19       +1
Impacted Files Coverage Δ
.../main/java/com/vanniktech/emoji/EmojiEditText.java 0% <0%> (ø) ⬆️
...rc/main/java/com/vanniktech/emoji/EmojiButton.java 0% <0%> (ø) ⬆️
.../main/java/com/vanniktech/emoji/EmojiTextView.java 0% <0%> (ø) ⬆️
...c/main/java/com/vanniktech/emoji/EmojiManager.java 85.89% <73.33%> (-0.41%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b95744...4bf57e1. Read the comment docs.

@stefanhaustein stefanhaustein changed the title Don't crash when the emoji support libraray is not ready yet Add infrastructure to let the provider perform emoji span replacements and utilize in emoji-google-compat Aug 31, 2017
@vanniktech
Copy link
Owner

I'll look at this PR shortly. I'm rather busy at the moment.

Copy link
Owner

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

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

A few questions.

I really like the asList optimization

}

/**
* Internal fallback method.
Copy link
Owner

Choose a reason for hiding this comment

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

Does not really seem internal since it's public.

/**
* Internal fallback method.
*/
public static void replaceWithImagesImpl(final Context context, final Spannable text, final float emojiSize) {
Copy link
Owner

Choose a reason for hiding this comment

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

Is it possible to keep this internal?

import android.content.Context;
import android.text.Spannable;

public interface EmojiReplacer {
Copy link
Owner

Choose a reason for hiding this comment

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

some java doc what it can be used for and also that it'll be there since version 0.6.0

@@ -174,7 +174,7 @@ public void noProviderInstalled() {

final Spannable text = new SpannableString(new String(new int[] { 0x1234, 0x4321 }, 0, 1));

EmojiManager.replaceWithImages(RuntimeEnvironment.application, text, 22);
EmojiManager.replaceWithImagesImpl(RuntimeEnvironment.application, text, 22);
Copy link
Owner

Choose a reason for hiding this comment

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

why the function name change?

@@ -134,7 +134,7 @@ public void noProviderInstalled() {

final Spannable text = new SpannableString(new String(new int[] { 0x1234 }, 0, 1));

EmojiManager.replaceWithImages(RuntimeEnvironment.application, text, 22);
EmojiManager.replaceWithImagesImpl(RuntimeEnvironment.application, text, 22);
Copy link
Owner

Choose a reason for hiding this comment

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

why the function name change

@vanniktech
Copy link
Owner

I updated this PR for you. Is there anything that's missing in this branch now?

@@ -32,4 +36,13 @@ public GoogleCompatEmojiProvider(@NonNull final EmojiCompat emojiCompat) {
new FlagsCategory()
};
}

@Override
Copy link
Owner

Choose a reason for hiding this comment

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

nit: same line as the method

@stefanhaustein
Copy link
Contributor Author

Hi, sorry for the delay. The extra method is needed to fall back to the default after giving the manager an option to intercept. Maybe replaceWithImagesDefault would be a better name?

@vanniktech
Copy link
Owner

Yup replaceWithImagesDefault is better.

@stefanhaustein
Copy link
Contributor Author

stefanhaustein commented Sep 14, 2017

I have changed the code to avoid a public method using a fallback replacer.
The PR still contains an unrelated test app change, can pull this out into a separate PR, too, if you prefer.

PTAL

Copy link
Owner

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

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

Thank you 👍

@vanniktech vanniktech merged commit ebe1cb0 into vanniktech:master Sep 14, 2017
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