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

Emoji Support Library integration #196

Merged
merged 18 commits into from
Aug 30, 2017
Merged

Conversation

stefanhaustein
Copy link
Contributor

Quite minimal

Potential followups:

  • Emoji API and class hierarchy cleanup
  • Generator support
  • Route span generation through the provider to reduce wrapping levels
  • readme.md

@codecov
Copy link

codecov bot commented Aug 26, 2017

Codecov Report

Merging #196 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #196   +/-   ##
=======================================
  Coverage   27.93%   27.93%           
=======================================
  Files          22       22           
  Lines         809      809           
  Branches       88       88           
=======================================
  Hits          226      226           
  Misses        565      565           
  Partials       18       18
Impacted Files Coverage Δ
...rc/main/java/com/vanniktech/emoji/emoji/Emoji.java 88.57% <ø> (ø) ⬆️

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 f207fe7...6d3f61d. Read the comment docs.

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.

Looking good so far. Found a few small things 👍

How did you generate the categories? Did you adjust the generator?

@@ -17,6 +19,10 @@
return;
}

final EmojiCompat.Config config = new BundledEmojiCompatConfig(this);
Copy link
Owner

Choose a reason for hiding this comment

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

can we move this into the Activity where we'll also install the provider?

@@ -39,9 +39,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:imeOptions="actionSend"
android:inputType="textCapSentences|textMultiLine"
android:maxLines="3"/>
Copy link
Owner

Choose a reason for hiding this comment

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

can you restore the max lines?

}

android {
compileSdkVersion rootProject.ext.compileSdkVersion as int
Copy link
Owner

Choose a reason for hiding this comment

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

can you do 2 tabs instead of 4?

import android.support.annotation.NonNull;
import com.vanniktech.emoji.emoji.Emoji;

public class GoogleCompatEmoji extends Emoji {
Copy link
Owner

Choose a reason for hiding this comment

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

let's make it final so others can't extend it

}

@NonNull
@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: sameline as the method

textPaint.setColor(0x0ffffffff);
}

@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

/**
* An emoji drawable backed by a span generated by the Google emoji support library.
*/
public class GoogleCompatEmojiDrawable extends Drawable {
Copy link
Owner

Choose a reason for hiding this comment

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

final & package private so others can't use it and we won't have to support it in the public API

}
}

@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 method function

textPaint.setAlpha(alpha);
}

@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 method function

textPaint.setColorFilter(colorFilter);
}

@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 method function

@stefanhaustein
Copy link
Contributor Author

Done. Have created the categories manually by changing the generated google categories. Wanted to look into how sprite sheet metadata is handled for EmonjiOne etc. before changing the generator (and don't have nodejs installed on the laptop).

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.

Oh nice I like. I also tested it locally and everything seems to work so far. 👍

Regarding the automatic generation, we can take care of that later.

Should we do the EmojiCompat.init(config); in the provider itself or should the user do this? I'm not that familiar with the google emoji api. If we let the user do it we should somehow check in GoogleCompatEmojiProvider that EmojiCompat was initialized. Another option would be to pass the EmojiCompatConfig into the Provider but then the module would need to bundle the support library.

@rubengees
Copy link
Collaborator

@stefanhaustein This is great 👍! How do the categories differ from the normal Google ones?
@vanniktech I could follow up with the generator adjustments once EmojiOne pushes fixes for their emoji.json which we are using for generation (There is a problem with the ordering currently).

@vanniktech
Copy link
Owner

The categories should not differ at all it's just that for this artifact the google support library will take care of the images and provide them lazily via fonts so they won't blow up the apk.

Adjusting the generator sounds perfect! Yup watched that issue regarding the ordering and there's no progress yet.

@stefanhaustein
Copy link
Contributor Author

The categories should be identical to the regular Google categories.

The support library can be used either with bundled emoji (as currently in the demo app), or the initialization can download the font as needed (= not on Oreo). Both setup methods have different dependencies, which makes it tricky to include the library setup, see https://developer.android.com/guide/topics/ui/look-and-feel/emoji-compat.html

@rubengees
Copy link
Collaborator

@stefanhaustein Thanks for the clarification.

I think we could also implement the lazy approach of the emoji-compat lib in the long run and move away from our strict initialization (With warnings to avoid developers not calling init!).

EmojiTextView and the other views would then simply leave the String untouched (or cut out emojis to avoid the missing font characters), if uninitialized. This would also not change the behaviour of current Providers because initialization is instantious for them.

I think this would require separate modules for emoji-compat and emoji-compat-bundled though.

Thoughts?

@stefanhaustein
Copy link
Contributor Author

I think it would be fine to leave the support lib setup to the user. The download case requires some download key metadata in the manifest anyway IIRC, and users might also want to use the support lib elsewhere, which might make full wrapping awkward.

One option to make the dependency more explicit might be to hand in the emoji support lib config object to the GoogleCompatEmojiProvider constructor (and just make sure it's not null).

We could still add emoji-compat-bundled on demand later if the extra setup really turns out to be a problem for users.

To me, the most important next step seems to be moving span generation to the provider, so we can avoid the span -> drawable -> span indirection in the support library case.

@rubengees
Copy link
Collaborator

@stefanhaustein Ah sorry, I misunderstood how the emoji-support lib works, we actually already have the behaviour I was thinking of.

Concerning the dependency explicity: I think there is room for improvements (The setup could be plug-and-play with optional configuration if wanted/needed), but you are right, other things like lib size and the span code are more important for now.

Involving this PR, I have found an issue while testing it locally. Consider these screenshots:

emoji-compat Existing google
screenshot_20170830-000128 screenshot_20170830-000138

The new Provider seems to be missing some emojis. Is this intentional (Maybe these are unsupported by emoji-compat)?

@vanniktech
Copy link
Owner

One option to make the dependency more explicit might be to hand in the emoji support lib config object to the GoogleCompatEmojiProvider constructor (and just make sure it's not null).

I think that's the best way to go for now.

The emoji support lib config object is available via the emoji library so we don't need to depend on the bundled one right? If so we should change this to be more explicit.

@stefanhaustein
Copy link
Contributor Author

Missing Emoji & Ctor parameter should be fixed now O:)

public GoogleCompatEmojiProvider(@NonNull final EmojiCompat.Config emojiCompatConfig) {
if (emojiCompatConfig == null) {
throw new NullPointerException();
}
Copy link
Owner

Choose a reason for hiding this comment

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

Let's also call the install function?

@vanniktech
Copy link
Owner

Let's also call the install function?

@stefanhaustein
Copy link
Contributor Author

stefanhaustein commented Aug 30, 2017

Distributing the initialization seems confusing to me. How about changing the ctor param from Config to EmojiCompat instead, i.e. the result of EmojiCompat.init(config)?

@vanniktech
Copy link
Owner

Let's do that I didn't know the init method returns something.

@stefanhaustein
Copy link
Contributor Author

Done! Merge? O:)

@vanniktech
Copy link
Owner

Thanks a lot for all the good work :)

@vanniktech vanniktech merged commit f44ad22 into vanniktech:master Aug 30, 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.

None yet

3 participants