Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Customize Emoji Background Color
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedmozaffariGithub committed Jul 22, 2018
1 parent 3d68057 commit 790eb8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 13 additions & 4 deletions emoji/src/main/java/com/vanniktech/emoji/EmojiPopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public final class EmojiPopup {

final View rootView;
final Activity context;
private int color;

@NonNull final RecentEmoji recentEmoji;
@NonNull final VariantEmoji variantEmoji;
Expand Down Expand Up @@ -83,13 +84,14 @@ public final class EmojiPopup {
}
};

EmojiPopup(@NonNull final View rootView, @NonNull final EmojiEditText emojiEditText,
@Nullable final RecentEmoji recent, @Nullable final VariantEmoji variant) {
public EmojiPopup(@NonNull final View rootView, @NonNull final EmojiEditText emojiEditText,
@Nullable final RecentEmoji recent, @Nullable final VariantEmoji variant, int color) {
this.context = Utils.asActivity(rootView.getContext());
this.rootView = rootView.getRootView();
this.emojiEditText = emojiEditText;
this.recentEmoji = recent != null ? recent : new RecentEmojiManager(context);
this.variantEmoji = variant != null ? variant : new VariantEmojiManager(context);
this.color = color;

popupWindow = new PopupWindow(context);

Expand Down Expand Up @@ -117,7 +119,7 @@ public final class EmojiPopup {

variantPopup = new EmojiVariantPopup(this.rootView, clickListener);

final EmojiView emojiView = new EmojiView(context, clickListener, longClickListener, recentEmoji, variantEmoji);
final EmojiView emojiView = new EmojiView(context, clickListener, longClickListener, recentEmoji, variantEmoji, color);
emojiView.setOnEmojiBackspaceClickListener(new OnEmojiBackspaceClickListener() {
@Override public void onEmojiBackspaceClick(final View v) {
emojiEditText.backspace();
Expand Down Expand Up @@ -199,6 +201,7 @@ private void showAtBottomPending() {

public static final class Builder {
@NonNull private final View rootView;
@NonNull private int color;
@Nullable private OnEmojiPopupShownListener onEmojiPopupShownListener;
@Nullable private OnSoftKeyboardCloseListener onSoftKeyboardCloseListener;
@Nullable private OnSoftKeyboardOpenListener onSoftKeyboardOpenListener;
Expand Down Expand Up @@ -273,17 +276,23 @@ private Builder(final View rootView) {
return this;
}

@CheckResult public Builder setColor(final int color) {
this.color = color;
return this;
}

@CheckResult public EmojiPopup build(@NonNull final EmojiEditText emojiEditText) {
EmojiManager.getInstance().verifyInstalled();
checkNotNull(emojiEditText, "EmojiEditText can't be null");

final EmojiPopup emojiPopup = new EmojiPopup(rootView, emojiEditText, recentEmoji, variantEmoji);
final EmojiPopup emojiPopup = new EmojiPopup(rootView, emojiEditText, recentEmoji, variantEmoji, color);
emojiPopup.onSoftKeyboardCloseListener = onSoftKeyboardCloseListener;
emojiPopup.onEmojiClickListener = onEmojiClickListener;
emojiPopup.onSoftKeyboardOpenListener = onSoftKeyboardOpenListener;
emojiPopup.onEmojiPopupShownListener = onEmojiPopupShownListener;
emojiPopup.onEmojiPopupDismissListener = onEmojiPopupDismissListener;
emojiPopup.onEmojiBackspaceClickListener = onEmojiBackspaceClickListener;
emojiPopup.color = color;
return emojiPopup;
}
}
Expand Down
4 changes: 2 additions & 2 deletions emoji/src/main/java/com/vanniktech/emoji/EmojiView.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@

EmojiView(final Context context, final OnEmojiClickListener onEmojiClickListener,
final OnEmojiLongClickListener onEmojiLongClickListener, @NonNull final RecentEmoji recentEmoji,
@NonNull final VariantEmoji variantManager) {
@NonNull final VariantEmoji variantManager, int color) {
super(context);

View.inflate(context, R.layout.emoji_view, this);

setOrientation(VERTICAL);
setBackgroundColor(ContextCompat.getColor(context, R.color.emoji_background));
setBackgroundColor(color);

themeIconColor = ContextCompat.getColor(context, R.color.emoji_icons);
final TypedValue value = new TypedValue();
Expand Down

0 comments on commit 790eb8d

Please sign in to comment.