From de7dad9fc8f146458e33d03d69e7db64ae77aa01 Mon Sep 17 00:00:00 2001 From: Janne Koschinski <janne@kuschku.de> Date: Wed, 4 Apr 2018 19:02:29 +0200 Subject: [PATCH] Fixing bug where enter lost focus --- .../quasseldroid/ui/chat/input/Editor.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/input/Editor.kt b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/input/Editor.kt index 2beb67c10..d23eed62b 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/input/Editor.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/input/Editor.kt @@ -334,6 +334,19 @@ class Editor( } TooltipCompat.setTooltipText(clearButton, clearButton.contentDescription) + chatline.setOnEditorActionListener { _, actionId, event -> + if (event.action == KeyEvent.ACTION_DOWN) { + when (actionId) { + EditorInfo.IME_ACTION_SEND, + EditorInfo.IME_ACTION_DONE -> { + send() + true + } + else -> false + } + } else false + } + chatline.setOnKeyListener { _, keyCode, event -> if (event.action == KeyEvent.ACTION_DOWN) { if (event.isCtrlPressed && !event.isAltPressed) when (keyCode) { @@ -371,7 +384,11 @@ class Editor( } else -> false } - } else false + } else if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) { + !event.isShiftPressed + } else { + false + } } } -- GitLab