diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/TestEditView.java b/app/src/main/java/gr/thmmy/mthmmy/activities/TestEditView.java index 875efb7c..657143da 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/TestEditView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/TestEditView.java @@ -45,7 +45,7 @@ public class TestEditView extends AppCompatActivity implements EmojiKeyboard.Emo public void onBackPressed() { if (emojiKeyboard.getVisibility() == View.VISIBLE) { emojiKeyboard.setVisibility(View.GONE); - editorView.setEmojiKeyboardVisible(false); + editorView.updateEmojiKeyboardVisibility(); } else { super.onBackPressed(); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 1acb6ae7..3e386994 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -462,7 +462,7 @@ class TopicAdapter extends RecyclerView.Adapter { holder.replyEditor.setEmojiKeyboardOwner(emojiKeyboardOwner); InputConnection ic = holder.replyEditor.getInputConnection(); emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic); - holder.replyEditor.setEmojiKeyboardVisible(emojiKeyboardOwner.isEmojiKeyboardVisible()); + holder.replyEditor.updateEmojiKeyboardVisibility(); holder.replyEditor.setText(viewModel.getBuildedQuotes()); holder.replyEditor.setOnSubmitListener(view -> { diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java b/app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java index 6ee24b8b..5c8bbab9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java @@ -34,7 +34,6 @@ public class EditorView extends LinearLayout { private AppCompatImageButton emojiButton; private AppCompatImageButton submitButton; private EmojiKeyboard.EmojiKeyboardOwner emojiKeyboardOwner; - private boolean emojiKeyboardVisible = false; public EditorView(Context context) { super(context); @@ -74,14 +73,14 @@ public class EditorView extends LinearLayout { emojiButton = findViewById(R.id.emoji_keyboard_button); editText.setOnTouchListener((v, event) -> { - if (emojiKeyboardVisible) return true; + if (emojiKeyboardOwner.isEmojiKeyboardVisible()) return true; return false; }); emojiButton.setOnClickListener(view -> { InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE); assert imm != null; - if (emojiKeyboardVisible) { + if (emojiKeyboardOwner.isEmojiKeyboardVisible()) { editText.requestFocus(); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); emojiButton.setImageResource(R.drawable.ic_tag_faces_grey_24dp); @@ -90,8 +89,7 @@ public class EditorView extends LinearLayout { view.clearFocus(); emojiButton.setImageResource(R.drawable.ic_keyboard_grey_24dp); } - emojiKeyboardVisible = !emojiKeyboardVisible; - emojiKeyboardOwner.setEmojiKeyboardVisible(emojiKeyboardVisible); + emojiKeyboardOwner.setEmojiKeyboardVisible(!emojiKeyboardOwner.isEmojiKeyboardVisible()); }); submitButton = findViewById(R.id.submit_button); @@ -271,11 +269,10 @@ public class EditorView extends LinearLayout { return editText.onCreateInputConnection(new EditorInfo()); } - public void setEmojiKeyboardVisible(boolean visible) { - if (visible) + public void updateEmojiKeyboardVisibility() { + if (emojiKeyboardOwner.isEmojiKeyboardVisible()) emojiButton.setImageResource(R.drawable.ic_keyboard_grey_24dp); else emojiButton.setImageResource(R.drawable.ic_tag_faces_grey_24dp); - emojiKeyboardVisible = visible; } }