From f3d05f82f9de3c25e9513bf366f7cbe60a03fcd4 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sat, 18 Apr 2020 13:45:19 +0200 Subject: [PATCH] fix toot sending twice when using a hardware keyboard (#1758) --- .../components/compose/ComposeActivity.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt index dfb812de5..d5d20d3da 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt @@ -907,19 +907,20 @@ class ComposeActivity : BaseActivity(), override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { Log.d(TAG, event.toString()) - if (event.isCtrlPressed) { - if (keyCode == KeyEvent.KEYCODE_ENTER) { - // send toot by pressing CTRL + ENTER - this.onSendClicked() + if(event.action == KeyEvent.ACTION_DOWN) { + if (event.isCtrlPressed) { + if (keyCode == KeyEvent.KEYCODE_ENTER) { + // send toot by pressing CTRL + ENTER + this.onSendClicked() + return true + } + } + + if (keyCode == KeyEvent.KEYCODE_BACK) { + onBackPressed() return true } } - - if (keyCode == KeyEvent.KEYCODE_BACK) { - onBackPressed() - return true - } - return super.onKeyDown(keyCode, event) }