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

Commit

Permalink
Customize Emoji Icon Tabbars & Divider Color
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedmozaffariGithub committed Jul 23, 2018
1 parent 790eb8d commit 935a6fa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
34 changes: 25 additions & 9 deletions emoji/src/main/java/com/vanniktech/emoji/EmojiPopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public final class EmojiPopup {

final View rootView;
final Activity context;
private int color;
private int backgroundColor,iconColor,dividerColor;

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

public EmojiPopup(@NonNull final View rootView, @NonNull final EmojiEditText emojiEditText,
@Nullable final RecentEmoji recent, @Nullable final VariantEmoji variant, int color) {
@Nullable final RecentEmoji recent, @Nullable final VariantEmoji variant, int backgroundColor, int iconColor,int dividerColor) {
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;
this.backgroundColor=backgroundColor;
this.iconColor=iconColor;
this.dividerColor=dividerColor;

popupWindow = new PopupWindow(context);

Expand Down Expand Up @@ -119,7 +121,7 @@ public EmojiPopup(@NonNull final View rootView, @NonNull final EmojiEditText emo

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

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

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

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

@CheckResult public Builder setIconColor(final int iconColor) {
this.iconColor = iconColor;
return this;
}

@CheckResult public Builder setDividerColor(final int dividerColor) {
this.dividerColor = dividerColor;
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, color);
final EmojiPopup emojiPopup = new EmojiPopup(rootView, emojiEditText, recentEmoji, variantEmoji, backgroundColor,iconColor,dividerColor);
emojiPopup.onSoftKeyboardCloseListener = onSoftKeyboardCloseListener;
emojiPopup.onEmojiClickListener = onEmojiClickListener;
emojiPopup.onSoftKeyboardOpenListener = onSoftKeyboardOpenListener;
emojiPopup.onEmojiPopupShownListener = onEmojiPopupShownListener;
emojiPopup.onEmojiPopupDismissListener = onEmojiPopupDismissListener;
emojiPopup.onEmojiBackspaceClickListener = onEmojiBackspaceClickListener;
emojiPopup.color = color;
emojiPopup.backgroundColor = backgroundColor;
emojiPopup.iconColor=iconColor;
emojiPopup.dividerColor=dividerColor;
return emojiPopup;
}
}
Expand Down
9 changes: 6 additions & 3 deletions emoji/src/main/java/com/vanniktech/emoji/EmojiView.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@

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

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

setOrientation(VERTICAL);
setBackgroundColor(color);
setBackgroundColor(backgroundColor);

themeIconColor = ContextCompat.getColor(context, R.color.emoji_icons);
themeIconColor = iconColor;
final TypedValue value = new TypedValue();
context.getTheme().resolveAttribute(R.attr.colorAccent, value, true);
themeAccentColor = value.data;

final ViewPager emojisPager = findViewById(R.id.emojis_pager);
final View emojiDivider = findViewById(R.id.emoji_divider);
emojiDivider.setBackgroundColor(dividerColor);

final LinearLayout emojisTab = findViewById(R.id.emojis_tab);
emojisPager.addOnPageChangeListener(this);

Expand Down
1 change: 1 addition & 0 deletions emoji/src/main/res/layout/emoji_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/>

<View
android:id="@+id/emoji_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/emoji_divider"
Expand Down

0 comments on commit 935a6fa

Please sign in to comment.