From 4e76a5e83eb36fff84b1cf9f05b408ff7145220e Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Tue, 3 Sep 2019 10:11:40 +0200 Subject: [PATCH] Fix #612 Signed-off-by: Mario Danic --- .../bottomsheet/EntryMenuController.java | 45 +++++++++++++++++++ .../main/res/layout/controller_entry_menu.xml | 18 +++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java index cfe7c2c28..8e067977a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java @@ -22,6 +22,7 @@ package com.nextcloud.talk.controllers.bottomsheet; import android.content.ComponentName; import android.content.Intent; +import android.graphics.PorterDuff; import android.os.Bundle; import android.text.Editable; import android.text.InputType; @@ -32,6 +33,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.widget.Button; +import android.widget.ImageView; + import androidx.annotation.NonNull; import autodagger.AutoInjector; import butterknife.BindView; @@ -49,6 +52,13 @@ import com.nextcloud.talk.utils.ShareUtils; import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.database.user.UserUtils; import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder; +import com.vanniktech.emoji.EmojiImageView; +import com.vanniktech.emoji.EmojiPopup; +import com.vanniktech.emoji.emoji.Emoji; +import com.vanniktech.emoji.listeners.OnEmojiClickListener; +import com.vanniktech.emoji.listeners.OnEmojiPopupDismissListener; +import com.vanniktech.emoji.listeners.OnEmojiPopupShownListener; + import org.greenrobot.eventbus.EventBus; import org.parceler.Parcels; @@ -66,6 +76,9 @@ public class EntryMenuController extends BaseController { @BindView(R.id.text_input_layout) TextInputLayout textInputLayout; + @BindView(R.id.smileyButton) + ImageView smileyButton; + @Inject EventBus eventBus; @@ -79,6 +92,9 @@ public class EntryMenuController extends BaseController { private String name; private String callUrl; + private EmojiPopup emojiPopup; + + private Bundle originalBundle; public EntryMenuController(Bundle args) { @@ -104,6 +120,11 @@ public class EntryMenuController extends BaseController { return inflater.inflate(R.layout.controller_entry_menu, container, false); } + @OnClick(R.id.smileyButton) + void onSmileyClick() { + emojiPopup.toggle(); + } + @Override protected void onAttach(@NonNull View view) { super.onAttach(view); @@ -260,6 +281,30 @@ public class EntryMenuController extends BaseController { case 2: labelText = getResources().getString(R.string.nc_call_name); editText.setInputType(InputType.TYPE_CLASS_TEXT); + smileyButton.setVisibility(View.VISIBLE); + emojiPopup = EmojiPopup.Builder.fromRootView(view).setOnEmojiPopupShownListener(new OnEmojiPopupShownListener() { + @Override + public void onEmojiPopupShown() { + if (getResources() != null) { + smileyButton.setColorFilter(getResources().getColor(R.color.colorPrimary), + PorterDuff.Mode.SRC_IN); + } + } + }).setOnEmojiPopupDismissListener(new OnEmojiPopupDismissListener() { + @Override + public void onEmojiPopupDismiss() { + if (smileyButton != null) { + smileyButton.setColorFilter(getResources().getColor(R.color.emoji_icons), + PorterDuff.Mode.SRC_IN); + } + } + }).setOnEmojiClickListener(new OnEmojiClickListener() { + @Override + public void onEmojiClick(@NonNull EmojiImageView emoji, @NonNull Emoji imageView) { + editText.getEditableText().append(" "); + } + }).build(editText); + break; case 4: labelText = getResources().getString(R.string.nc_new_password); diff --git a/app/src/main/res/layout/controller_entry_menu.xml b/app/src/main/res/layout/controller_entry_menu.xml index 6e6a3ddd5..5a8283c71 100644 --- a/app/src/main/res/layout/controller_entry_menu.xml +++ b/app/src/main/res/layout/controller_entry_menu.xml @@ -44,7 +44,11 @@ android:id="@+id/text_input_layout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="@dimen/activity_horizontal_margin" + android:layout_marginStart="@dimen/activity_horizontal_margin" + android:layout_marginTop="@dimen/activity_horizontal_margin" + android:layout_marginBottom="@dimen/activity_horizontal_margin" + android:layout_marginEnd="8dp" + android:layout_toStartOf="@id/smileyButton" app:errorTextAppearance="@style/ErrorAppearance" app:helperText="" app:passwordToggleDrawable="@drawable/asl_password_visibility" @@ -61,4 +65,16 @@ + +