From c8784680460fe29c72d597cb04554ad93f742be6 Mon Sep 17 00:00:00 2001 From: Dimo Karaivanov Date: Mon, 28 Aug 2023 10:11:11 +0300 Subject: [PATCH] prevent unnecessary double ENTER event for sending messages, when there is no message to send --- src/io/github/sspanak/tt9/ime/helpers/AppHacks.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/io/github/sspanak/tt9/ime/helpers/AppHacks.java b/src/io/github/sspanak/tt9/ime/helpers/AppHacks.java index 1020735d..3de1f582 100644 --- a/src/io/github/sspanak/tt9/ime/helpers/AppHacks.java +++ b/src/io/github/sspanak/tt9/ime/helpers/AppHacks.java @@ -148,6 +148,12 @@ public class AppHacks { sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_CENTER); + // If there is no text, there is nothing to send, so there is no need to attempt any hacks. + // We just pass through DPAD_CENTER and finish as if the key press was handled by the system. + if (oldText.isEmpty()) { + return true; + } + try { // In Android there is no strictly defined confirmation key, hence DPAD_CENTER may have done nothing. // If so, send an alternative key code as a final resort.