From 8cbf8b59bda075ae4d4dd723063a05b5afce006e Mon Sep 17 00:00:00 2001 From: Gyuhwan Park Date: Thu, 30 May 2019 20:32:18 +0900 Subject: [PATCH] feature(MainActivity): add shortcut for compose new toot (SHIFT + N or CTRL + N) [#505] --- .../com/keylesspalace/tusky/MainActivity.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 993113072..9e3a58f65 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -280,9 +280,26 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut return true; } } + return super.onKeyDown(keyCode, event); } + @Override + public boolean onKeyShortcut(int keyCode, KeyEvent event) { + if (event.isCtrlPressed() || event.isShiftPressed()) { + // FIXME: blackberry keyONE raises SHIFT key event even CTRL IS PRESSED + switch (keyCode) { + case KeyEvent.KEYCODE_N: { + // open compose activity by pressing SHIFT + N (or CTRL + N) + Intent composeIntent = new Intent(getApplicationContext(), ComposeActivity.class); + startActivity(composeIntent); + return true; + } + } + } + return super.onKeyShortcut(keyCode, event); + } + @Override public void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState);