From a1e47865c57bb6d336a0fd191877f5ed675bda6a Mon Sep 17 00:00:00 2001 From: adbenitez Date: Mon, 16 Dec 2024 15:27:13 +0100 Subject: [PATCH 1/2] improve emoji pickers --- .../securesms/ConversationActivity.java | 25 +++++++++++++------ ...conversation_activity_emojidrawer_stub.xml | 18 +++++++++++++ src/main/res/layout-land/reaction_picker.xml | 14 +++++++++++ src/main/res/layout/conversation_activity.xml | 7 +++--- ...conversation_activity_emojidrawer_stub.xml | 1 + src/main/res/layout/reaction_picker.xml | 1 + 6 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 src/main/res/layout-land/conversation_activity_emojidrawer_stub.xml create mode 100644 src/main/res/layout-land/reaction_picker.xml diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java index 62a2b3f31a..95c08acd4f 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java @@ -42,6 +42,7 @@ import android.util.Log; import android.util.Pair; import android.view.KeyEvent; +import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -50,6 +51,7 @@ import android.view.View.OnKeyListener; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; +import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; @@ -177,7 +179,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity private AttachmentTypeSelector attachmentTypeSelector; private AttachmentManager attachmentManager; private AudioRecorder audioRecorder; - private Stub emojiDrawerStub; + private FrameLayout emojiPickerContainer; + private MediaKeyboard emojiPicker; protected HidingLinearLayout quickAttachmentToggle; private QuickAttachmentDrawer quickAttachmentDrawer; private InputPanel inputPanel; @@ -321,10 +324,11 @@ public void onConfigurationChanged(Configuration newConfig) { composeText.setTransport(sendButton.getSelectedTransport()); quickAttachmentDrawer.onConfigurationChanged(); - if (emojiDrawerStub.resolved() && container.getCurrentInput() == emojiDrawerStub.get()) { + if (emojiPicker != null && container.getCurrentInput() == emojiPicker) { container.hideAttachedInput(true); } + reloadEmojiPicker(); initializeBackground(); } @@ -812,7 +816,7 @@ private void initializeViews() { sendButton = ViewUtil.findById(this, R.id.send_button); attachButton = ViewUtil.findById(this, R.id.attach_button); composeText = ViewUtil.findById(this, R.id.embedded_text_editor); - emojiDrawerStub = ViewUtil.findStubById(this, R.id.emoji_drawer_stub); + emojiPickerContainer = ViewUtil.findById(this, R.id.emoji_picker_container); composePanel = ViewUtil.findById(this, R.id.bottom_panel); container = ViewUtil.findById(this, R.id.layout_container); quickAttachmentDrawer = ViewUtil.findById(this, R.id.quick_attachment_drawer); @@ -1277,16 +1281,23 @@ public void onFailure(ExecutionException e) {} }); } + private void reloadEmojiPicker() { + emojiPickerContainer.removeAllViews(); + emojiPicker = (MediaKeyboard) LayoutInflater.from(this).inflate(R.layout.conversation_activity_emojidrawer_stub, emojiPickerContainer, false); + emojiPickerContainer.addView(emojiPicker); + inputPanel.setMediaKeyboard(emojiPicker); + } + @Override public void onEmojiToggle() { - if (!emojiDrawerStub.resolved()) { - inputPanel.setMediaKeyboard(emojiDrawerStub.get()); + if (emojiPicker == null) { + reloadEmojiPicker(); } - if (container.getCurrentInput() == emojiDrawerStub.get()) { + if (container.getCurrentInput() == emojiPicker) { container.showSoftkey(composeText); } else { - container.show(composeText, emojiDrawerStub.get()); + container.show(composeText, emojiPicker); } } diff --git a/src/main/res/layout-land/conversation_activity_emojidrawer_stub.xml b/src/main/res/layout-land/conversation_activity_emojidrawer_stub.xml new file mode 100644 index 0000000000..9417360bfb --- /dev/null +++ b/src/main/res/layout-land/conversation_activity_emojidrawer_stub.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/main/res/layout-land/reaction_picker.xml b/src/main/res/layout-land/reaction_picker.xml new file mode 100644 index 0000000000..0115e91faf --- /dev/null +++ b/src/main/res/layout-land/reaction_picker.xml @@ -0,0 +1,14 @@ + + + + + diff --git a/src/main/res/layout/conversation_activity.xml b/src/main/res/layout/conversation_activity.xml index 84dbe644c8..c775db8277 100644 --- a/src/main/res/layout/conversation_activity.xml +++ b/src/main/res/layout/conversation_activity.xml @@ -57,12 +57,11 @@ - + /> diff --git a/src/main/res/layout/conversation_activity_emojidrawer_stub.xml b/src/main/res/layout/conversation_activity_emojidrawer_stub.xml index 390d150113..742adefaf6 100644 --- a/src/main/res/layout/conversation_activity_emojidrawer_stub.xml +++ b/src/main/res/layout/conversation_activity_emojidrawer_stub.xml @@ -1,4 +1,5 @@ + + Date: Mon, 16 Dec 2024 17:19:34 +0100 Subject: [PATCH 2/2] optimize onConfigurationChanged() --- .../java/org/thoughtcrime/securesms/ConversationActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java index 95c08acd4f..0e5af41ec1 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationActivity.java @@ -328,7 +328,7 @@ public void onConfigurationChanged(Configuration newConfig) { container.hideAttachedInput(true); } - reloadEmojiPicker(); + emojiPicker = null; // force reloading next time onEmojiToggle() is called initializeBackground(); }