Mercurial > 510Connectbot
comparison app/src/main/java/com/five_ten_sg/connectbot/service/TerminalKeyListener.java @ 465:7c8aebcc882a
request permissions if not already granted
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 19 Aug 2019 11:12:40 -0700 |
parents | d29cce60f393 |
children |
comparison
equal
deleted
inserted
replaced
464:3ebfae9bc0bd | 465:7c8aebcc882a |
---|---|
140 */ | 140 */ |
141 public boolean onKey(View v, int keyCode, KeyEvent event) { | 141 public boolean onKey(View v, int keyCode, KeyEvent event) { |
142 try { | 142 try { |
143 int repeat = event.getRepeatCount(); | 143 int repeat = event.getRepeatCount(); |
144 | 144 |
145 // if keycode debugging enabled, log and print the pressed key | |
146 if (prefs.getBoolean(PreferenceConstants.DEBUG_KEYCODES, false)) { | |
147 String keyCodeString = String.format(": %d %d %d", keyCode, repeat, event.getAction()); | |
148 String toastText = v.getContext().getString(R.string.keycode_pressed) + keyCodeString; | |
149 Log.d(TAG, toastText); | |
150 } | |
151 | |
145 // skip keys if we aren't connected yet or have been disconnected | 152 // skip keys if we aren't connected yet or have been disconnected |
146 if (bridge.isDisconnected()) return false; | 153 if (bridge.isDisconnected()) return false; |
147 | 154 |
148 // short cuts can see repeat counts and key up/down | 155 // short cuts can see repeat counts and key up/down |
149 if (handleShortcuts(v, keyCode, event, repeat, (event.getAction() == KeyEvent.ACTION_DOWN))) return true; | 156 if (handleShortcuts(v, keyCode, event, repeat, (event.getAction() == KeyEvent.ACTION_DOWN))) return true; |
150 | 157 |
151 // Ignore all key-up events except for the special keys | 158 // Ignore all key-up events except for the special keys |
152 if (event.getAction() == KeyEvent.ACTION_UP) { | 159 if (event.getAction() == KeyEvent.ACTION_UP) { |
153 // There's nothing else here for virtual keyboard users. | 160 // There's nothing else here for virtual keyboard users. |
154 if (!hardKeyboard || hardKeyboardHidden) return false; | 161 if (!hardKeyboard || hardKeyboardHidden) return false; |
155 | |
156 // if keycode debugging enabled, log and print the pressed key | |
157 if (prefs.getBoolean(PreferenceConstants.DEBUG_KEYCODES, false)) { | |
158 String keyCodeString = String.format(": %d", keyCode); | |
159 String toastText = v.getContext().getString(R.string.keycode_pressed) + keyCodeString; | |
160 Log.d(TAG, toastText); | |
161 } | |
162 | 162 |
163 if (fullKeyboard()) { | 163 if (fullKeyboard()) { |
164 switch (keyCode) { | 164 switch (keyCode) { |
165 case KeyEvent.KEYCODE_CTRL_LEFT: | 165 case KeyEvent.KEYCODE_CTRL_LEFT: |
166 case KeyEvent.KEYCODE_CTRL_RIGHT: | 166 case KeyEvent.KEYCODE_CTRL_RIGHT: |
571 PreferenceConstants.CAMERA, | 571 PreferenceConstants.CAMERA, |
572 PreferenceConstants.HWBUTTON_SCREEN_CAPTURE); | 572 PreferenceConstants.HWBUTTON_SCREEN_CAPTURE); |
573 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); | 573 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); |
574 | 574 |
575 case KeyEvent.KEYCODE_VOLUME_UP: | 575 case KeyEvent.KEYCODE_VOLUME_UP: |
576 // check to see which shortcut the volume button triggers | 576 // check to see which shortcut the volume up button triggers |
577 hwbuttonShortcut = manager.prefs.getString( | 577 hwbuttonShortcut = manager.prefs.getString( |
578 PreferenceConstants.VOLUP, | 578 PreferenceConstants.VOLUP, |
579 PreferenceConstants.HWBUTTON_FUNCTION_KEYS); | 579 PreferenceConstants.HWBUTTON_FUNCTION_KEYS); |
580 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); | 580 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); |
581 | 581 |
582 case KeyEvent.KEYCODE_VOLUME_DOWN: | 582 case KeyEvent.KEYCODE_VOLUME_DOWN: |
583 // check to see which shortcut the camera button triggers | 583 // check to see which shortcut the volume down button triggers |
584 hwbuttonShortcut = manager.prefs.getString( | 584 hwbuttonShortcut = manager.prefs.getString( |
585 PreferenceConstants.VOLDN, | 585 PreferenceConstants.VOLDN, |
586 PreferenceConstants.HWBUTTON_TAB); | 586 PreferenceConstants.HWBUTTON_TAB); |
587 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); | 587 return (handleShortcut(v, hwbuttonShortcut, repeat, down)); |
588 | 588 |