diff options
author | Jack Palevich <jackpal@google.com> | 2012-09-27 18:49:27 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2012-09-27 18:49:27 -0700 |
commit | 8ca143a5d8ee8a4649907288ee26bee568db3fd3 (patch) | |
tree | 736ed1f278b625aa906dfc2d02119bbdc211788d | |
parent | 2a7803017fb1cdc46914912077003fb285d20d99 (diff) | |
download | AndroidTerm-8ca143a5d8ee8a4649907288ee26bee568db3fd3.tar.gz |
Revert "robewald alt-sends-esc"
This reverts commit fd719e10d6b542ebf0be28cb58bbda484c5834b7, reversing
changes made to 113d77e5fa711cfcdc50953b70a7df6803a467d8.
This change was reverted because it caused a regression in the way soft
keyboard modifier keys worked. (e.g. using the volume keys as control
keys.) I think the regression happened because the change introduced
multiple copies of TermKeyListener. There should be only one instance
of TermKeyListener for each terminal window.
I would still like the feature (of having Alt send Esc), but without the
regression to the soft keyboard.
21 files changed, 863 insertions, 1236 deletions
diff --git a/libraries/emulatorview/AndroidManifest.xml b/libraries/emulatorview/AndroidManifest.xml index 756e88e..babfb6d 100644 --- a/libraries/emulatorview/AndroidManifest.xml +++ b/libraries/emulatorview/AndroidManifest.xml @@ -3,5 +3,4 @@ package="jackpal.androidterm.emulatorview" android:versionCode="43" android:versionName="1.0.42"> - <uses-sdk android:minSdkVersion="3"/> </manifest> diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/C.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/C.java deleted file mode 100644 index f1a6c00..0000000 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/C.java +++ /dev/null @@ -1,566 +0,0 @@ -package jackpal.androidterm.emulatorview; - -/* This class is a dump for constants used throughout the code. The name is short so that it doesn't clutter the code. - * - */ - -public final class C { - /** - * Android key codes that are defined in the Android 2.3 API. - * We want to recognize these codes, because they will be sent to our - * app when we run on Android 2.3 systems. - * But we don't want to accidentally use 2.3-specific APIs. - * So we compile against the Android 1.6 APIs, and have a copy of the codes here. - */ - - /** Key code constant: Unknown key code. */ - public static final int KEYCODE_UNKNOWN = 0; - /** Key code constant: Soft Left key. - * Usually situated below the display on phones and used as a multi-function - * feature key for selecting a software defined function shown on the bottom left - * of the display. */ - public static final int KEYCODE_SOFT_LEFT = 1; - /** Key code constant: Soft Right key. - * Usually situated below the display on phones and used as a multi-function - * feature key for selecting a software defined function shown on the bottom right - * of the display. */ - public static final int KEYCODE_SOFT_RIGHT = 2; - /** Key code constant: Home key. - * This key is handled by the framework and is never delivered to applications. */ - public static final int KEYCODE_HOME = 3; - /** Key code constant: Back key. */ - public static final int KEYCODE_BACK = 4; - /** Key code constant: Call key. */ - public static final int KEYCODE_CALL = 5; - /** Key code constant: End Call key. */ - public static final int KEYCODE_ENDCALL = 6; - /** Key code constant: '0' key. */ - public static final int KEYCODE_0 = 7; - /** Key code constant: '1' key. */ - public static final int KEYCODE_1 = 8; - /** Key code constant: '2' key. */ - public static final int KEYCODE_2 = 9; - /** Key code constant: '3' key. */ - public static final int KEYCODE_3 = 10; - /** Key code constant: '4' key. */ - public static final int KEYCODE_4 = 11; - /** Key code constant: '5' key. */ - public static final int KEYCODE_5 = 12; - /** Key code constant: '6' key. */ - public static final int KEYCODE_6 = 13; - /** Key code constant: '7' key. */ - public static final int KEYCODE_7 = 14; - /** Key code constant: '8' key. */ - public static final int KEYCODE_8 = 15; - /** Key code constant: '9' key. */ - public static final int KEYCODE_9 = 16; - /** Key code constant: '*' key. */ - public static final int KEYCODE_STAR = 17; - /** Key code constant: '#' key. */ - public static final int KEYCODE_POUND = 18; - /** Key code constant: Directional Pad Up key. - * May also be synthesized from trackball motions. */ - public static final int KEYCODE_DPAD_UP = 19; - /** Key code constant: Directional Pad Down key. - * May also be synthesized from trackball motions. */ - public static final int KEYCODE_DPAD_DOWN = 20; - /** Key code constant: Directional Pad Left key. - * May also be synthesized from trackball motions. */ - public static final int KEYCODE_DPAD_LEFT = 21; - /** Key code constant: Directional Pad Right key. - * May also be synthesized from trackball motions. */ - public static final int KEYCODE_DPAD_RIGHT = 22; - /** Key code constant: Directional Pad Center key. - * May also be synthesized from trackball motions. */ - public static final int KEYCODE_DPAD_CENTER = 23; - /** Key code constant: Volume Up key. - * Adjusts the speaker volume up. */ - public static final int KEYCODE_VOLUME_UP = 24; - /** Key code constant: Volume Down key. - * Adjusts the speaker volume down. */ - public static final int KEYCODE_VOLUME_DOWN = 25; - /** Key code constant: Power key. */ - public static final int KEYCODE_POWER = 26; - /** Key code constant: Camera key. - * Used to launch a camera application or take pictures. */ - public static final int KEYCODE_CAMERA = 27; - /** Key code constant: Clear key. */ - public static final int KEYCODE_CLEAR = 28; - /** Key code constant: 'A' key. */ - public static final int KEYCODE_A = 29; - /** Key code constant: 'B' key. */ - public static final int KEYCODE_B = 30; - /** Key code constant: 'C' key. */ - public static final int KEYCODE_C = 31; - /** Key code constant: 'D' key. */ - public static final int KEYCODE_D = 32; - /** Key code constant: 'E' key. */ - public static final int KEYCODE_E = 33; - /** Key code constant: 'F' key. */ - public static final int KEYCODE_F = 34; - /** Key code constant: 'G' key. */ - public static final int KEYCODE_G = 35; - /** Key code constant: 'H' key. */ - public static final int KEYCODE_H = 36; - /** Key code constant: 'I' key. */ - public static final int KEYCODE_I = 37; - /** Key code constant: 'J' key. */ - public static final int KEYCODE_J = 38; - /** Key code constant: 'K' key. */ - public static final int KEYCODE_K = 39; - /** Key code constant: 'L' key. */ - public static final int KEYCODE_L = 40; - /** Key code constant: 'M' key. */ - public static final int KEYCODE_M = 41; - /** Key code constant: 'N' key. */ - public static final int KEYCODE_N = 42; - /** Key code constant: 'O' key. */ - public static final int KEYCODE_O = 43; - /** Key code constant: 'P' key. */ - public static final int KEYCODE_P = 44; - /** Key code constant: 'Q' key. */ - public static final int KEYCODE_Q = 45; - /** Key code constant: 'R' key. */ - public static final int KEYCODE_R = 46; - /** Key code constant: 'S' key. */ - public static final int KEYCODE_S = 47; - /** Key code constant: 'T' key. */ - public static final int KEYCODE_T = 48; - /** Key code constant: 'U' key. */ - public static final int KEYCODE_U = 49; - /** Key code constant: 'V' key. */ - public static final int KEYCODE_V = 50; - /** Key code constant: 'W' key. */ - public static final int KEYCODE_W = 51; - /** Key code constant: 'X' key. */ - public static final int KEYCODE_X = 52; - /** Key code constant: 'Y' key. */ - public static final int KEYCODE_Y = 53; - /** Key code constant: 'Z' key. */ - public static final int KEYCODE_Z = 54; - /** Key code constant: ',' key. */ - public static final int KEYCODE_COMMA = 55; - /** Key code constant: '.' key. */ - public static final int KEYCODE_PERIOD = 56; - /** Key code constant: Left Alt modifier key. */ - public static final int KEYCODE_ALT_LEFT = 57; - /** Key code constant: Right Alt modifier key. */ - public static final int KEYCODE_ALT_RIGHT = 58; - /** Key code constant: Left Shift modifier key. */ - public static final int KEYCODE_SHIFT_LEFT = 59; - /** Key code constant: Right Shift modifier key. */ - public static final int KEYCODE_SHIFT_RIGHT = 60; - /** Key code constant: Tab key. */ - public static final int KEYCODE_TAB = 61; - /** Key code constant: Space key. */ - public static final int KEYCODE_SPACE = 62; - /** Key code constant: Symbol modifier key. - * Used to enter alternate symbols. */ - public static final int KEYCODE_SYM = 63; - /** Key code constant: Explorer special function key. - * Used to launch a browser application. */ - public static final int KEYCODE_EXPLORER = 64; - /** Key code constant: Envelope special function key. - * Used to launch a mail application. */ - public static final int KEYCODE_ENVELOPE = 65; - /** Key code constant: Enter key. */ - public static final int KEYCODE_ENTER = 66; - /** Key code constant: Backspace key. - * Deletes characters before the insertion point, unlike {@link #KEYCODE_FORWARD_DEL}. */ - public static final int KEYCODE_DEL = 67; - /** Key code constant: '`' (backtick) key. */ - public static final int KEYCODE_GRAVE = 68; - /** Key code constant: '-'. */ - public static final int KEYCODE_MINUS = 69; - /** Key code constant: '=' key. */ - public static final int KEYCODE_EQUALS = 70; - /** Key code constant: '[' key. */ - public static final int KEYCODE_LEFT_BRACKET = 71; - /** Key code constant: ']' key. */ - public static final int KEYCODE_RIGHT_BRACKET = 72; - /** Key code constant: '\' key. */ - public static final int KEYCODE_BACKSLASH = 73; - /** Key code constant: ';' key. */ - public static final int KEYCODE_SEMICOLON = 74; - /** Key code constant: ''' (apostrophe) key. */ - public static final int KEYCODE_APOSTROPHE = 75; - /** Key code constant: '/' key. */ - public static final int KEYCODE_SLASH = 76; - /** Key code constant: '@' key. */ - public static final int KEYCODE_AT = 77; - /** Key code constant: Number modifier key. - * Used to enter numeric symbols. - * This key is not Num Lock; it is more like {@link #KEYCODE_ALT_LEFT} and is - * interpreted as an ALT key by {@link android.text.method.MetaKeyKeyListener}. */ - public static final int KEYCODE_NUM = 78; - /** Key code constant: Headset Hook key. - * Used to hang up calls and stop media. */ - public static final int KEYCODE_HEADSETHOOK = 79; - /** Key code constant: Camera Focus key. - * Used to focus the camera. */ - public static final int KEYCODE_FOCUS = 80; // *Camera* focus - /** Key code constant: '+' key. */ - public static final int KEYCODE_PLUS = 81; - /** Key code constant: Menu key. */ - public static final int KEYCODE_MENU = 82; - /** Key code constant: Notification key. */ - public static final int KEYCODE_NOTIFICATION = 83; - /** Key code constant: Search key. */ - public static final int KEYCODE_SEARCH = 84; - /** Key code constant: Play/Pause media key. */ - public static final int KEYCODE_MEDIA_PLAY_PAUSE= 85; - /** Key code constant: Stop media key. */ - public static final int KEYCODE_MEDIA_STOP = 86; - /** Key code constant: Play Next media key. */ - public static final int KEYCODE_MEDIA_NEXT = 87; - /** Key code constant: Play Previous media key. */ - public static final int KEYCODE_MEDIA_PREVIOUS = 88; - /** Key code constant: Rewind media key. */ - public static final int KEYCODE_MEDIA_REWIND = 89; - /** Key code constant: Fast Forward media key. */ - public static final int KEYCODE_MEDIA_FAST_FORWARD = 90; - /** Key code constant: Mute key. - * Mutes the microphone, unlike {@link #KEYCODE_VOLUME_MUTE}. */ - public static final int KEYCODE_MUTE = 91; - /** Key code constant: Page Up key. */ - public static final int KEYCODE_PAGE_UP = 92; - /** Key code constant: Page Down key. */ - public static final int KEYCODE_PAGE_DOWN = 93; - /** Key code constant: Picture Symbols modifier key. - * Used to switch symbol sets (Emoji, Kao-moji). */ - public static final int KEYCODE_PICTSYMBOLS = 94; // switch symbol-sets (Emoji,Kao-moji) - /** Key code constant: Switch Charset modifier key. - * Used to switch character sets (Kanji, Katakana). */ - public static final int KEYCODE_SWITCH_CHARSET = 95; // switch char-sets (Kanji,Katakana) - /** Key code constant: A Button key. - * On a game controller, the A button should be either the button labeled A - * or the first button on the upper row of controller buttons. */ - public static final int KEYCODE_BUTTON_A = 96; - /** Key code constant: B Button key. - * On a game controller, the B button should be either the button labeled B - * or the second button on the upper row of controller buttons. */ - public static final int KEYCODE_BUTTON_B = 97; - /** Key code constant: C Button key. - * On a game controller, the C button should be either the button labeled C - * or the third button on the upper row of controller buttons. */ - public static final int KEYCODE_BUTTON_C = 98; - /** Key code constant: X Button key. - * On a game controller, the X button should be either the button labeled X - * or the first button on the lower row of controller buttons. */ - public static final int KEYCODE_BUTTON_X = 99; - /** Key code constant: Y Button key. - * On a game controller, the Y button should be either the button labeled Y - * or the second button on the lower row of controller buttons. */ - public static final int KEYCODE_BUTTON_Y = 100; - /** Key code constant: Z Button key. - * On a game controller, the Z button should be either the button labeled Z - * or the third button on the lower row of controller buttons. */ - public static final int KEYCODE_BUTTON_Z = 101; - /** Key code constant: L1 Button key. - * On a game controller, the L1 button should be either the button labeled L1 (or L) - * or the top left trigger button. */ - public static final int KEYCODE_BUTTON_L1 = 102; - /** Key code constant: R1 Button key. - * On a game controller, the R1 button should be either the button labeled R1 (or R) - * or the top right trigger button. */ - public static final int KEYCODE_BUTTON_R1 = 103; - /** Key code constant: L2 Button key. - * On a game controller, the L2 button should be either the button labeled L2 - * or the bottom left trigger button. */ - public static final int KEYCODE_BUTTON_L2 = 104; - /** Key code constant: R2 Button key. - * On a game controller, the R2 button should be either the button labeled R2 - * or the bottom right trigger button. */ - public static final int KEYCODE_BUTTON_R2 = 105; - /** Key code constant: Left Thumb Button key. - * On a game controller, the left thumb button indicates that the left (or only) - * joystick is pressed. */ - public static final int KEYCODE_BUTTON_THUMBL = 106; - /** Key code constant: Right Thumb Button key. - * On a game controller, the right thumb button indicates that the right - * joystick is pressed. */ - public static final int KEYCODE_BUTTON_THUMBR = 107; - /** Key code constant: Start Button key. - * On a game controller, the button labeled Start. */ - public static final int KEYCODE_BUTTON_START = 108; - /** Key code constant: Select Button key. - * On a game controller, the button labeled Select. */ - public static final int KEYCODE_BUTTON_SELECT = 109; - /** Key code constant: Mode Button key. - * On a game controller, the button labeled Mode. */ - public static final int KEYCODE_BUTTON_MODE = 110; - /** Key code constant: Escape key. */ - public static final int KEYCODE_ESCAPE = 111; - /** Key code constant: Forward Delete key. - * Deletes characters ahead of the insertion point, unlike {@link #KEYCODE_DEL}. */ - public static final int KEYCODE_FORWARD_DEL = 112; - /** Key code constant: Left Control modifier key. */ - public static final int KEYCODE_CTRL_LEFT = 113; - /** Key code constant: Right Control modifier key. */ - public static final int KEYCODE_CTRL_RIGHT = 114; - /** Key code constant: Caps Lock modifier key. */ - public static final int KEYCODE_CAPS_LOCK = 115; - /** Key code constant: Scroll Lock key. */ - public static final int KEYCODE_SCROLL_LOCK = 116; - /** Key code constant: Left Meta modifier key. */ - public static final int KEYCODE_META_LEFT = 117; - /** Key code constant: Right Meta modifier key. */ - public static final int KEYCODE_META_RIGHT = 118; - /** Key code constant: Function modifier key. */ - public static final int KEYCODE_FUNCTION = 119; - /** Key code constant: System Request / Print Screen key. */ - public static final int KEYCODE_SYSRQ = 120; - /** Key code constant: Break / Pause key. */ - public static final int KEYCODE_BREAK = 121; - /** Key code constant: Home Movement key. - * Used for scrolling or moving the cursor around to the start of a line - * or to the top of a list. */ - public static final int KEYCODE_MOVE_HOME = 122; - /** Key code constant: End Movement key. - * Used for scrolling or moving the cursor around to the end of a line - * or to the bottom of a list. */ - public static final int KEYCODE_MOVE_END = 123; - /** Key code constant: Insert key. - * Toggles insert / overwrite edit mode. */ - public static final int KEYCODE_INSERT = 124; - /** Key code constant: Forward key. - * Navigates forward in the history stack. Complement of {@link #KEYCODE_BACK}. */ - public static final int KEYCODE_FORWARD = 125; - /** Key code constant: Play media key. */ - public static final int KEYCODE_MEDIA_PLAY = 126; - /** Key code constant: Pause media key. */ - public static final int KEYCODE_MEDIA_PAUSE = 127; - /** Key code constant: Close media key. - * May be used to close a CD tray, for example. */ - public static final int KEYCODE_MEDIA_CLOSE = 128; - /** Key code constant: Eject media key. - * May be used to eject a CD tray, for example. */ - public static final int KEYCODE_MEDIA_EJECT = 129; - /** Key code constant: Record media key. */ - public static final int KEYCODE_MEDIA_RECORD = 130; - /** Key code constant: F1 key. */ - public static final int KEYCODE_F1 = 131; - /** Key code constant: F2 key. */ - public static final int KEYCODE_F2 = 132; - /** Key code constant: F3 key. */ - public static final int KEYCODE_F3 = 133; - /** Key code constant: F4 key. */ - public static final int KEYCODE_F4 = 134; - /** Key code constant: F5 key. */ - public static final int KEYCODE_F5 = 135; - /** Key code constant: F6 key. */ - public static final int KEYCODE_F6 = 136; - /** Key code constant: F7 key. */ - public static final int KEYCODE_F7 = 137; - /** Key code constant: F8 key. */ - public static final int KEYCODE_F8 = 138; - /** Key code constant: F9 key. */ - public static final int KEYCODE_F9 = 139; - /** Key code constant: F10 key. */ - public static final int KEYCODE_F10 = 140; - /** Key code constant: F11 key. */ - public static final int KEYCODE_F11 = 141; - /** Key code constant: F12 key. */ - public static final int KEYCODE_F12 = 142; - /** Key code constant: Num Lock modifier key. - * This is the Num Lock key; it is different from {@link #KEYCODE_NUM}. - * This key generally modifies the behavior of other keys on the numeric keypad. */ - public static final int KEYCODE_NUM_LOCK = 143; - /** Key code constant: Numeric keypad '0' key. */ - public static final int KEYCODE_NUMPAD_0 = 144; - /** Key code constant: Numeric keypad '1' key. */ - public static final int KEYCODE_NUMPAD_1 = 145; - /** Key code constant: Numeric keypad '2' key. */ - public static final int KEYCODE_NUMPAD_2 = 146; - /** Key code constant: Numeric keypad '3' key. */ - public static final int KEYCODE_NUMPAD_3 = 147; - /** Key code constant: Numeric keypad '4' key. */ - public static final int KEYCODE_NUMPAD_4 = 148; - /** Key code constant: Numeric keypad '5' key. */ - public static final int KEYCODE_NUMPAD_5 = 149; - /** Key code constant: Numeric keypad '6' key. */ - public static final int KEYCODE_NUMPAD_6 = 150; - /** Key code constant: Numeric keypad '7' key. */ - public static final int KEYCODE_NUMPAD_7 = 151; - /** Key code constant: Numeric keypad '8' key. */ - public static final int KEYCODE_NUMPAD_8 = 152; - /** Key code constant: Numeric keypad '9' key. */ - public static final int KEYCODE_NUMPAD_9 = 153; - /** Key code constant: Numeric keypad '/' key (for division). */ - public static final int KEYCODE_NUMPAD_DIVIDE = 154; - /** Key code constant: Numeric keypad '*' key (for multiplication). */ - public static final int KEYCODE_NUMPAD_MULTIPLY = 155; - /** Key code constant: Numeric keypad '-' key (for subtraction). */ - public static final int KEYCODE_NUMPAD_SUBTRACT = 156; - /** Key code constant: Numeric keypad '+' key (for addition). */ - public static final int KEYCODE_NUMPAD_ADD = 157; - /** Key code constant: Numeric keypad '.' key (for decimals or digit grouping). */ - public static final int KEYCODE_NUMPAD_DOT = 158; - /** Key code constant: Numeric keypad ',' key (for decimals or digit grouping). */ - public static final int KEYCODE_NUMPAD_COMMA = 159; - /** Key code constant: Numeric keypad Enter key. */ - public static final int KEYCODE_NUMPAD_ENTER = 160; - /** Key code constant: Numeric keypad '=' key. */ - public static final int KEYCODE_NUMPAD_EQUALS = 161; - /** Key code constant: Numeric keypad '(' key. */ - public static final int KEYCODE_NUMPAD_LEFT_PAREN = 162; - /** Key code constant: Numeric keypad ')' key. */ - public static final int KEYCODE_NUMPAD_RIGHT_PAREN = 163; - /** Key code constant: Volume Mute key. - * Mutes the speaker, unlike {@link #KEYCODE_MUTE}. - * This key should normally be implemented as a toggle such that the first press - * mutes the speaker and the second press restores the original volume. */ - public static final int KEYCODE_VOLUME_MUTE = 164; - /** Key code constant: Info key. - * Common on TV remotes to show additional information related to what is - * currently being viewed. */ - public static final int KEYCODE_INFO = 165; - /** Key code constant: Channel up key. - * On TV remotes, increments the television channel. */ - public static final int KEYCODE_CHANNEL_UP = 166; - /** Key code constant: Channel down key. - * On TV remotes, decrements the television channel. */ - public static final int KEYCODE_CHANNEL_DOWN = 167; - /** Key code constant: Zoom in key. */ - public static final int KEYCODE_ZOOM_IN = 168; - /** Key code constant: Zoom out key. */ - public static final int KEYCODE_ZOOM_OUT = 169; - /** Key code constant: TV key. - * On TV remotes, switches to viewing live TV. */ - public static final int KEYCODE_TV = 170; - /** Key code constant: Window key. - * On TV remotes, toggles picture-in-picture mode or other windowing functions. */ - public static final int KEYCODE_WINDOW = 171; - /** Key code constant: Guide key. - * On TV remotes, shows a programming guide. */ - public static final int KEYCODE_GUIDE = 172; - /** Key code constant: DVR key. - * On some TV remotes, switches to a DVR mode for recorded shows. */ - public static final int KEYCODE_DVR = 173; - /** Key code constant: Bookmark key. - * On some TV remotes, bookmarks content or web pages. */ - public static final int KEYCODE_BOOKMARK = 174; - /** Key code constant: Toggle captions key. - * Switches the mode for closed-captioning text, for example during television shows. */ - public static final int KEYCODE_CAPTIONS = 175; - /** Key code constant: Settings key. - * Starts the system settings activity. */ - public static final int KEYCODE_SETTINGS = 176; - /** Key code constant: TV power key. - * On TV remotes, toggles the power on a television screen. */ - public static final int KEYCODE_TV_POWER = 177; - /** Key code constant: TV input key. - * On TV remotes, switches the input on a television screen. */ - public static final int KEYCODE_TV_INPUT = 178; - /** Key code constant: Set-top-box power key. - * On TV remotes, toggles the power on an external Set-top-box. */ - public static final int KEYCODE_STB_POWER = 179; - /** Key code constant: Set-top-box input key. - * On TV remotes, switches the input mode on an external Set-top-box. */ - public static final int KEYCODE_STB_INPUT = 180; - /** Key code constant: A/V Receiver power key. - * On TV remotes, toggles the power on an external A/V Receiver. */ - public static final int KEYCODE_AVR_POWER = 181; - /** Key code constant: A/V Receiver input key. - * On TV remotes, switches the input mode on an external A/V Receiver. */ - public static final int KEYCODE_AVR_INPUT = 182; - /** Key code constant: Red "programmable" key. - * On TV remotes, acts as a contextual/programmable key. */ - public static final int KEYCODE_PROG_RED = 183; - /** Key code constant: Green "programmable" key. - * On TV remotes, actsas a contextual/programmable key. */ - public static final int KEYCODE_PROG_GREEN = 184; - /** Key code constant: Yellow "programmable" key. - * On TV remotes, acts as a contextual/programmable key. */ - public static final int KEYCODE_PROG_YELLOW = 185; - /** Key code constant: Blue "programmable" key. - * On TV remotes, acts as a contextual/programmable key. */ - public static final int KEYCODE_PROG_BLUE = 186; - - // Map keycodes out of (above) the Unicode code point space. - static public final int KEYCODE_OFFSET = 0xA00000; - - public static final String[] specialKeyCharSeq = new String[256]; - public static final String[] appSpecialKeyCharSeq = new String[256]; - - /** - * These sequences are intended to match the sequences generated by - * XFree86 xterm and/or GNU screen. - */ - static { - specialKeyCharSeq[KEYCODE_DPAD_CENTER] = "\015"; - specialKeyCharSeq[KEYCODE_DPAD_UP] = "\033[A"; - specialKeyCharSeq[KEYCODE_DPAD_DOWN] = "\033[B"; - specialKeyCharSeq[KEYCODE_DPAD_RIGHT] = "\033[C"; - specialKeyCharSeq[KEYCODE_DPAD_LEFT] = "\033[D"; - specialKeyCharSeq[KEYCODE_F1] = "\033OP"; - specialKeyCharSeq[KEYCODE_F2] = "\033OQ"; - specialKeyCharSeq[KEYCODE_F3] = "\033OR"; - specialKeyCharSeq[KEYCODE_F4] = "\033OS"; - specialKeyCharSeq[KEYCODE_F5] = "\033[15~"; - specialKeyCharSeq[KEYCODE_F6] = "\033[17~"; - specialKeyCharSeq[KEYCODE_F7] = "\033[18~"; - specialKeyCharSeq[KEYCODE_F8] = "\033[19~"; - specialKeyCharSeq[KEYCODE_F9] = "\033[20~"; - specialKeyCharSeq[KEYCODE_F10] = "\033[21~"; - specialKeyCharSeq[KEYCODE_F11] = "\033[23~"; - specialKeyCharSeq[KEYCODE_F12] = "\033[24~"; - specialKeyCharSeq[KEYCODE_SYSRQ] = "\033[32~"; // Sys Request / Print - // Is this Scroll lock? mKeyCodes[Cancel] = "\033[33~"; - specialKeyCharSeq[KEYCODE_BREAK] = "\033[34~"; // Pause/Break - - specialKeyCharSeq[KEYCODE_TAB] = "\011"; - specialKeyCharSeq[KEYCODE_ENTER] = "\015"; - specialKeyCharSeq[KEYCODE_ESCAPE] = "\033"; - - specialKeyCharSeq[KEYCODE_INSERT] = "\033[2~"; - specialKeyCharSeq[KEYCODE_FORWARD_DEL] = "\033[3~"; - specialKeyCharSeq[KEYCODE_MOVE_HOME] = "\033[1~"; - specialKeyCharSeq[KEYCODE_MOVE_END] = "\033[4~"; - specialKeyCharSeq[KEYCODE_PAGE_UP] = "\033[5~"; - specialKeyCharSeq[KEYCODE_PAGE_DOWN] = "\033[6~"; - specialKeyCharSeq[KEYCODE_DEL]= "\177"; - specialKeyCharSeq[KEYCODE_NUM_LOCK] = "\033OP"; - specialKeyCharSeq[KEYCODE_NUMPAD_DIVIDE] = "/"; - specialKeyCharSeq[KEYCODE_NUMPAD_MULTIPLY] = "*"; - specialKeyCharSeq[KEYCODE_NUMPAD_SUBTRACT] = "-"; - specialKeyCharSeq[KEYCODE_NUMPAD_ADD] = "+"; - specialKeyCharSeq[KEYCODE_NUMPAD_ENTER] = "\015"; - specialKeyCharSeq[KEYCODE_NUMPAD_EQUALS] = "="; - specialKeyCharSeq[KEYCODE_NUMPAD_DOT] = "."; - specialKeyCharSeq[KEYCODE_NUMPAD_COMMA] = ","; - specialKeyCharSeq[KEYCODE_NUMPAD_0] = "0"; - specialKeyCharSeq[KEYCODE_NUMPAD_1] = "1"; - specialKeyCharSeq[KEYCODE_NUMPAD_2] = "2"; - specialKeyCharSeq[KEYCODE_NUMPAD_3] = "3"; - specialKeyCharSeq[KEYCODE_NUMPAD_4] = "4"; - specialKeyCharSeq[KEYCODE_NUMPAD_5] = "5"; - specialKeyCharSeq[KEYCODE_NUMPAD_6] = "6"; - specialKeyCharSeq[KEYCODE_NUMPAD_7] = "7"; - specialKeyCharSeq[KEYCODE_NUMPAD_8] = "8"; - specialKeyCharSeq[KEYCODE_NUMPAD_9] = "9"; - - appSpecialKeyCharSeq[KEYCODE_DPAD_UP] = "\033OA"; - appSpecialKeyCharSeq[KEYCODE_DPAD_DOWN] = "\033OB"; - appSpecialKeyCharSeq[KEYCODE_DPAD_RIGHT] = "\033OC"; - appSpecialKeyCharSeq[KEYCODE_DPAD_LEFT] = "\033OD"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_DIVIDE] = "\033Oo"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_MULTIPLY] = "\033Oj"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_SUBTRACT] = "\033Om"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_ADD] = "\033Ok"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_ENTER] = "\033OM"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_EQUALS] = "\033OX"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_DOT] = "\033On"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_COMMA] = "\033Ol"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_0] = "\033Op"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_1] = "\033Oq"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_2] = "\033Or"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_3] = "\033Os"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_4] = "\033Ot"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_5] = "\033Ou"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_6] = "\033Ov"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_7] = "\033Ow"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_8] = "\033Ox"; - appSpecialKeyCharSeq[KEYCODE_NUMPAD_9] = "\033Oy"; - } -} diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java index 0fc5b07..466a269 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java @@ -17,10 +17,7 @@ package jackpal.androidterm.emulatorview; import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; @@ -42,7 +39,6 @@ import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; import android.widget.Scroller; -import jackpal.androidterm.emulatorview.compat.AndroidCompat; /** * A view on a {@link TermSession}. Displays the terminal emulator's screen, @@ -212,6 +208,7 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe } }; private float mScrollRemainder; + private TermKeyListener mKeyListener; private String mImeBuffer = ""; @@ -236,12 +233,6 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe invalidate(); } }; - private int mBackKeyCharacter = 0; - - private boolean mAltSendsEsc = false; - private TermKeyListener mTermKeyListener = null; - - /** * Create an <code>EmulatorView</code> for a {@link TermSession}. @@ -309,6 +300,7 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe mTermSession = session; + mKeyListener = new TermKeyListener(session); // Do init now if it was deferred until a TermSession was attached if (mDeferInit) { @@ -381,8 +373,6 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe EditorInfo.TYPE_CLASS_TEXT : EditorInfo.TYPE_NULL; return new BaseInputConnection(this, true) { - TermKeyListener mKeyListener = new TermKeyListener(mControlKeyCode, mFnKeyCode, mBackKeyCharacter, mAltSendsEsc, getKeypadApplicationMode()); - private boolean mInBatchEdit; /** * Used to handle composing text requests */ @@ -417,9 +407,12 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe } private void mapAndSend(int c) throws IOException { - int charCode = mKeyListener.mapControlChars(c); - byte[] charCodes = TermKeyListener.lookupDirectMap(charCode, getKeypadApplicationMode(), false); - mTermSession.write(charCodes,0,charCodes.length); + int result = mKeyListener.mapControlChar(c); + if (result < TermKeyListener.KEYCODE_OFFSET) { + mTermSession.write(result); + } else { + mKeyListener.handleKeyCode(result - TermKeyListener.KEYCODE_OFFSET, getKeypadApplicationMode()); + } clearSpecialKeyStatus(); } @@ -525,7 +518,6 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe return true; } - @TargetApi(11) public boolean commitCorrection (CorrectionInfo correctionInfo) { if (LOG_IME) { Log.w(TAG, "commitCorrection"); @@ -673,7 +665,7 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe * Get the terminal emulator's keypad application mode. */ public boolean getKeypadApplicationMode() { - return (mEmulator != null) ? mEmulator.getKeypadApplicationMode() : false; + return mEmulator.getKeypadApplicationMode(); } /** @@ -967,39 +959,25 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe if (LOG_KEY_EVENTS) { Log.w(TAG, "onKeyDown " + keyCode); } - if (keyCode == KeyEvent.KEYCODE_MENU) { - return super.onKeyDown(keyCode, event); - } - if (mTermKeyListener == null) { - mTermKeyListener = new TermKeyListener(mControlKeyCode, mFnKeyCode, mBackKeyCharacter, mAltSendsEsc, getKeypadApplicationMode()); - } - boolean isHandled = mTermKeyListener.keyDown(event); - if (isHandled) { - byte[] seq = mTermKeyListener.extractCharSequence(); - if (seq != null) { - mTermSession.write(seq, 0, seq.length); - } + if (handleControlKey(keyCode, true)) { + return true; + } else if (handleFnKey(keyCode, true)) { + return true; } else if (isSystemKey(keyCode, event)) { if (! isInterceptedSystemKey(keyCode) ) { // Don't intercept the system keys - isHandled = super.onKeyDown(keyCode, event); + return super.onKeyDown(keyCode, event); } } - return isHandled; - } - public boolean onKeyPreIme(int keycode, KeyEvent event) { - //capture the metakeys. - int preImeMetastate = event.getMetaState(); - if (mAltSendsEsc && ((preImeMetastate & KeyEvent.META_ALT_ON) != 0)) { - if (event.getAction() == KeyEvent.ACTION_DOWN) { - return onKeyDown(keycode, event); - } else { - return onKeyUp(keycode, event); - } - } else { - return false; + // Translate the keyCode into an ASCII character. + + try { + mKeyListener.keyDown(keyCode, event, getKeypadApplicationMode()); + } catch (IOException e) { + // Ignore I/O exceptions } + return true; } /** Do we want to intercept this system key? */ @@ -1007,7 +985,6 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe return keyCode == KeyEvent.KEYCODE_BACK && mBackKeySendsCharacter; } - /** * Called when a key is released in the view. * @@ -1020,21 +997,20 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe if (LOG_KEY_EVENTS) { Log.w(TAG, "onKeyUp " + keyCode); } - if (keyCode == KeyEvent.KEYCODE_MENU) { - return super.onKeyUp(keyCode, event); - } - //MetaKeyKeyListener.handleKeyDown(metaState, keyCode, event) - boolean isHandled = mTermKeyListener.keyUp(event); - if (isHandled) { - //noop; + if (handleControlKey(keyCode, false)) { + return true; + } else if (handleFnKey(keyCode, false)) { + return true; } else if (isSystemKey(keyCode, event)) { - if ( ! isInterceptedSystemKey(keyCode)) { + // Don't intercept the system keys + if ( ! isInterceptedSystemKey(keyCode) ) { return super.onKeyUp(keyCode, event); } } + mKeyListener.keyUp(keyCode, event); clearSpecialKeyStatus(); - return isHandled; + return true; } @@ -1043,7 +1019,7 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe if (LOG_KEY_EVENTS) { Log.w(TAG, "handleControlKey " + keyCode); } - mTermKeyListener.handleControlKey(down); + mKeyListener.handleControlKey(down); return true; } return false; @@ -1054,7 +1030,7 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe if (LOG_KEY_EVENTS) { Log.w(TAG, "handleFnKey " + keyCode); } - mTermKeyListener.handleFnKey(down); + mKeyListener.handleFnKey(down); return true; } return false; @@ -1067,11 +1043,11 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe private void clearSpecialKeyStatus() { if (mIsControlKeySent) { mIsControlKeySent = false; - mTermKeyListener.handleControlKey(false); + mKeyListener.handleControlKey(false); } if (mIsFnKeySent) { mIsFnKeySent = false; - mTermKeyListener.handleFnKey(false); + mKeyListener.handleFnKey(false); } } @@ -1245,7 +1221,7 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe */ public void sendControlKey() { mIsControlKeySent = true; - mTermKeyListener.handleControlKey(true); + mKeyListener.handleControlKey(true); } /** @@ -1254,15 +1230,14 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe */ public void sendFnKey() { mIsFnKeySent = true; - mTermKeyListener.handleFnKey(true); + mKeyListener.handleFnKey(true); } /** * Set the key code to be sent when the Back key is pressed. */ public void setBackKeyCharacter(int keyCode) { - mBackKeyCharacter = keyCode; - mTermKeyListener = new TermKeyListener(mControlKeyCode, mFnKeyCode, mBackKeyCharacter, mAltSendsEsc, getKeypadApplicationMode()); + mKeyListener.setBackKeyCharacter(keyCode); mBackKeySendsCharacter = (keyCode != 0); } @@ -1271,7 +1246,6 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe */ public void setControlKeyCode(int keyCode) { mControlKeyCode = keyCode; - mTermKeyListener = new TermKeyListener(mControlKeyCode, mFnKeyCode, mBackKeyCharacter, mAltSendsEsc, getKeypadApplicationMode()); } /** @@ -1279,11 +1253,5 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe */ public void setFnKeyCode(int keyCode) { mFnKeyCode = keyCode; - mTermKeyListener = new TermKeyListener(mControlKeyCode, mFnKeyCode, mBackKeyCharacter, mAltSendsEsc, getKeypadApplicationMode()); - } - - public void setAltSendsEsc(boolean flag) { - mAltSendsEsc = flag; - mTermKeyListener = new TermKeyListener(mControlKeyCode, mFnKeyCode, mBackKeyCharacter, mAltSendsEsc, getKeypadApplicationMode()); } } diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TermKeyListener.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TermKeyListener.java index 8d914fc..f8ca207 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TermKeyListener.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TermKeyListener.java @@ -1,7 +1,9 @@ package jackpal.androidterm.emulatorview; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; +import jackpal.androidterm.emulatorview.compat.AndroidCompat; +import jackpal.androidterm.emulatorview.compat.KeyCharacterMapCompat; + +import java.io.IOException; import android.view.KeyCharacterMap; import android.view.KeyEvent; @@ -11,432 +13,898 @@ import android.view.KeyEvent; * An ASCII key listener. Supports control characters and escape. Keeps track of * the current state of the alt, shift, and control keys. */ - class TermKeyListener { /** - * This class is responsible for the handling of key events. It consumes - * key events and when the key events generate characters, then one or more are made - * available for consumption. + * Android key codes that are defined in the Android 2.3 API. + * We want to recognize these codes, because they will be sent to our + * app when we run on Android 2.3 systems. + * But we don't want to accidentally use 2.3-specific APIs. + * So we compile against the Android 1.6 APIs, and have a copy of the codes here. */ - private final ModifierKey mControlKey; - private final ModifierKey mFnKey; - private final ModifierKey mCapsKey; - private final ModifierKey mAltKey; - private final int mBackBehavior; - private final boolean mAllowToggle; - private final boolean mAppMode; - private byte[] mCharSequence; - private boolean mAltSendsEscape; - private Integer mDeadChar; - - /** - * Are any of the alt or meta keys pressed? - */ - private final static int META_ALT_OR_META_MASK = - KeyEvent.META_ALT_MASK | KeyEvent.META_META_MASK; - - TermKeyListener(int controlKey, int fnKey, int backBehavior, boolean altSendsEscape, boolean appMode) { - mAppMode = appMode; - mControlKey = new ModifierKey(controlKey); - mFnKey = new ModifierKey(fnKey); - mAltKey = new ModifierKey(KeyEvent.KEYCODE_ALT_LEFT); - mCapsKey = new ModifierKey(KeyEvent.KEYCODE_CAPS_LOCK); - mBackBehavior = backBehavior; - mAllowToggle = false; - mAltSendsEscape = altSendsEscape; - this.resetKeys(); - } - - public void handleControlKey(boolean down) { - mControlKey.handleModifierKey(down); + /** Key code constant: Unknown key code. */ + public static final int KEYCODE_UNKNOWN = 0; + /** Key code constant: Soft Left key. + * Usually situated below the display on phones and used as a multi-function + * feature key for selecting a software defined function shown on the bottom left + * of the display. */ + public static final int KEYCODE_SOFT_LEFT = 1; + /** Key code constant: Soft Right key. + * Usually situated below the display on phones and used as a multi-function + * feature key for selecting a software defined function shown on the bottom right + * of the display. */ + public static final int KEYCODE_SOFT_RIGHT = 2; + /** Key code constant: Home key. + * This key is handled by the framework and is never delivered to applications. */ + public static final int KEYCODE_HOME = 3; + /** Key code constant: Back key. */ + public static final int KEYCODE_BACK = 4; + /** Key code constant: Call key. */ + public static final int KEYCODE_CALL = 5; + /** Key code constant: End Call key. */ + public static final int KEYCODE_ENDCALL = 6; + /** Key code constant: '0' key. */ + public static final int KEYCODE_0 = 7; + /** Key code constant: '1' key. */ + public static final int KEYCODE_1 = 8; + /** Key code constant: '2' key. */ + public static final int KEYCODE_2 = 9; + /** Key code constant: '3' key. */ + public static final int KEYCODE_3 = 10; + /** Key code constant: '4' key. */ + public static final int KEYCODE_4 = 11; + /** Key code constant: '5' key. */ + public static final int KEYCODE_5 = 12; + /** Key code constant: '6' key. */ + public static final int KEYCODE_6 = 13; + /** Key code constant: '7' key. */ + public static final int KEYCODE_7 = 14; + /** Key code constant: '8' key. */ + public static final int KEYCODE_8 = 15; + /** Key code constant: '9' key. */ + public static final int KEYCODE_9 = 16; + /** Key code constant: '*' key. */ + public static final int KEYCODE_STAR = 17; + /** Key code constant: '#' key. */ + public static final int KEYCODE_POUND = 18; + /** Key code constant: Directional Pad Up key. + * May also be synthesized from trackball motions. */ + public static final int KEYCODE_DPAD_UP = 19; + /** Key code constant: Directional Pad Down key. + * May also be synthesized from trackball motions. */ + public static final int KEYCODE_DPAD_DOWN = 20; + /** Key code constant: Directional Pad Left key. + * May also be synthesized from trackball motions. */ + public static final int KEYCODE_DPAD_LEFT = 21; + /** Key code constant: Directional Pad Right key. + * May also be synthesized from trackball motions. */ + public static final int KEYCODE_DPAD_RIGHT = 22; + /** Key code constant: Directional Pad Center key. + * May also be synthesized from trackball motions. */ + public static final int KEYCODE_DPAD_CENTER = 23; + /** Key code constant: Volume Up key. + * Adjusts the speaker volume up. */ + public static final int KEYCODE_VOLUME_UP = 24; + /** Key code constant: Volume Down key. + * Adjusts the speaker volume down. */ + public static final int KEYCODE_VOLUME_DOWN = 25; + /** Key code constant: Power key. */ + public static final int KEYCODE_POWER = 26; + /** Key code constant: Camera key. + * Used to launch a camera application or take pictures. */ + public static final int KEYCODE_CAMERA = 27; + /** Key code constant: Clear key. */ + public static final int KEYCODE_CLEAR = 28; + /** Key code constant: 'A' key. */ + public static final int KEYCODE_A = 29; + /** Key code constant: 'B' key. */ + public static final int KEYCODE_B = 30; + /** Key code constant: 'C' key. */ + public static final int KEYCODE_C = 31; + /** Key code constant: 'D' key. */ + public static final int KEYCODE_D = 32; + /** Key code constant: 'E' key. */ + public static final int KEYCODE_E = 33; + /** Key code constant: 'F' key. */ + public static final int KEYCODE_F = 34; + /** Key code constant: 'G' key. */ + public static final int KEYCODE_G = 35; + /** Key code constant: 'H' key. */ + public static final int KEYCODE_H = 36; + /** Key code constant: 'I' key. */ + public static final int KEYCODE_I = 37; + /** Key code constant: 'J' key. */ + public static final int KEYCODE_J = 38; + /** Key code constant: 'K' key. */ + public static final int KEYCODE_K = 39; + /** Key code constant: 'L' key. */ + public static final int KEYCODE_L = 40; + /** Key code constant: 'M' key. */ + public static final int KEYCODE_M = 41; + /** Key code constant: 'N' key. */ + public static final int KEYCODE_N = 42; + /** Key code constant: 'O' key. */ + public static final int KEYCODE_O = 43; + /** Key code constant: 'P' key. */ + public static final int KEYCODE_P = 44; + /** Key code constant: 'Q' key. */ + public static final int KEYCODE_Q = 45; + /** Key code constant: 'R' key. */ + public static final int KEYCODE_R = 46; + /** Key code constant: 'S' key. */ + public static final int KEYCODE_S = 47; + /** Key code constant: 'T' key. */ + public static final int KEYCODE_T = 48; + /** Key code constant: 'U' key. */ + public static final int KEYCODE_U = 49; + /** Key code constant: 'V' key. */ + public static final int KEYCODE_V = 50; + /** Key code constant: 'W' key. */ + public static final int KEYCODE_W = 51; + /** Key code constant: 'X' key. */ + public static final int KEYCODE_X = 52; + /** Key code constant: 'Y' key. */ + public static final int KEYCODE_Y = 53; + /** Key code constant: 'Z' key. */ + public static final int KEYCODE_Z = 54; + /** Key code constant: ',' key. */ + public static final int KEYCODE_COMMA = 55; + /** Key code constant: '.' key. */ + public static final int KEYCODE_PERIOD = 56; + /** Key code constant: Left Alt modifier key. */ + public static final int KEYCODE_ALT_LEFT = 57; + /** Key code constant: Right Alt modifier key. */ + public static final int KEYCODE_ALT_RIGHT = 58; + /** Key code constant: Left Shift modifier key. */ + public static final int KEYCODE_SHIFT_LEFT = 59; + /** Key code constant: Right Shift modifier key. */ + public static final int KEYCODE_SHIFT_RIGHT = 60; + /** Key code constant: Tab key. */ + public static final int KEYCODE_TAB = 61; + /** Key code constant: Space key. */ + public static final int KEYCODE_SPACE = 62; + /** Key code constant: Symbol modifier key. + * Used to enter alternate symbols. */ + public static final int KEYCODE_SYM = 63; + /** Key code constant: Explorer special function key. + * Used to launch a browser application. */ + public static final int KEYCODE_EXPLORER = 64; + /** Key code constant: Envelope special function key. + * Used to launch a mail application. */ + public static final int KEYCODE_ENVELOPE = 65; + /** Key code constant: Enter key. */ + public static final int KEYCODE_ENTER = 66; + /** Key code constant: Backspace key. + * Deletes characters before the insertion point, unlike {@link #KEYCODE_FORWARD_DEL}. */ + public static final int KEYCODE_DEL = 67; + /** Key code constant: '`' (backtick) key. */ + public static final int KEYCODE_GRAVE = 68; + /** Key code constant: '-'. */ + public static final int KEYCODE_MINUS = 69; + /** Key code constant: '=' key. */ + public static final int KEYCODE_EQUALS = 70; + /** Key code constant: '[' key. */ + public static final int KEYCODE_LEFT_BRACKET = 71; + /** Key code constant: ']' key. */ + public static final int KEYCODE_RIGHT_BRACKET = 72; + /** Key code constant: '\' key. */ + public static final int KEYCODE_BACKSLASH = 73; + /** Key code constant: ';' key. */ + public static final int KEYCODE_SEMICOLON = 74; + /** Key code constant: ''' (apostrophe) key. */ + public static final int KEYCODE_APOSTROPHE = 75; + /** Key code constant: '/' key. */ + public static final int KEYCODE_SLASH = 76; + /** Key code constant: '@' key. */ + public static final int KEYCODE_AT = 77; + /** Key code constant: Number modifier key. + * Used to enter numeric symbols. + * This key is not Num Lock; it is more like {@link #KEYCODE_ALT_LEFT} and is + * interpreted as an ALT key by {@link android.text.method.MetaKeyKeyListener}. */ + public static final int KEYCODE_NUM = 78; + /** Key code constant: Headset Hook key. + * Used to hang up calls and stop media. */ + public static final int KEYCODE_HEADSETHOOK = 79; + /** Key code constant: Camera Focus key. + * Used to focus the camera. */ + public static final int KEYCODE_FOCUS = 80; // *Camera* focus + /** Key code constant: '+' key. */ + public static final int KEYCODE_PLUS = 81; + /** Key code constant: Menu key. */ + public static final int KEYCODE_MENU = 82; + /** Key code constant: Notification key. */ + public static final int KEYCODE_NOTIFICATION = 83; + /** Key code constant: Search key. */ + public static final int KEYCODE_SEARCH = 84; + /** Key code constant: Play/Pause media key. */ + public static final int KEYCODE_MEDIA_PLAY_PAUSE= 85; + /** Key code constant: Stop media key. */ + public static final int KEYCODE_MEDIA_STOP = 86; + /** Key code constant: Play Next media key. */ + public static final int KEYCODE_MEDIA_NEXT = 87; + /** Key code constant: Play Previous media key. */ + public static final int KEYCODE_MEDIA_PREVIOUS = 88; + /** Key code constant: Rewind media key. */ + public static final int KEYCODE_MEDIA_REWIND = 89; + /** Key code constant: Fast Forward media key. */ + public static final int KEYCODE_MEDIA_FAST_FORWARD = 90; + /** Key code constant: Mute key. + * Mutes the microphone, unlike {@link #KEYCODE_VOLUME_MUTE}. */ + public static final int KEYCODE_MUTE = 91; + /** Key code constant: Page Up key. */ + public static final int KEYCODE_PAGE_UP = 92; + /** Key code constant: Page Down key. */ + public static final int KEYCODE_PAGE_DOWN = 93; + /** Key code constant: Picture Symbols modifier key. + * Used to switch symbol sets (Emoji, Kao-moji). */ + public static final int KEYCODE_PICTSYMBOLS = 94; // switch symbol-sets (Emoji,Kao-moji) + /** Key code constant: Switch Charset modifier key. + * Used to switch character sets (Kanji, Katakana). */ + public static final int KEYCODE_SWITCH_CHARSET = 95; // switch char-sets (Kanji,Katakana) + /** Key code constant: A Button key. + * On a game controller, the A button should be either the button labeled A + * or the first button on the upper row of controller buttons. */ + public static final int KEYCODE_BUTTON_A = 96; + /** Key code constant: B Button key. + * On a game controller, the B button should be either the button labeled B + * or the second button on the upper row of controller buttons. */ + public static final int KEYCODE_BUTTON_B = 97; + /** Key code constant: C Button key. + * On a game controller, the C button should be either the button labeled C + * or the third button on the upper row of controller buttons. */ + public static final int KEYCODE_BUTTON_C = 98; + /** Key code constant: X Button key. + * On a game controller, the X button should be either the button labeled X + * or the first button on the lower row of controller buttons. */ + public static final int KEYCODE_BUTTON_X = 99; + /** Key code constant: Y Button key. + * On a game controller, the Y button should be either the button labeled Y + * or the second button on the lower row of controller buttons. */ + public static final int KEYCODE_BUTTON_Y = 100; + /** Key code constant: Z Button key. + * On a game controller, the Z button should be either the button labeled Z + * or the third button on the lower row of controller buttons. */ + public static final int KEYCODE_BUTTON_Z = 101; + /** Key code constant: L1 Button key. + * On a game controller, the L1 button should be either the button labeled L1 (or L) + * or the top left trigger button. */ + public static final int KEYCODE_BUTTON_L1 = 102; + /** Key code constant: R1 Button key. + * On a game controller, the R1 button should be either the button labeled R1 (or R) + * or the top right trigger button. */ + public static final int KEYCODE_BUTTON_R1 = 103; + /** Key code constant: L2 Button key. + * On a game controller, the L2 button should be either the button labeled L2 + * or the bottom left trigger button. */ + public static final int KEYCODE_BUTTON_L2 = 104; + /** Key code constant: R2 Button key. + * On a game controller, the R2 button should be either the button labeled R2 + * or the bottom right trigger button. */ + public static final int KEYCODE_BUTTON_R2 = 105; + /** Key code constant: Left Thumb Button key. + * On a game controller, the left thumb button indicates that the left (or only) + * joystick is pressed. */ + public static final int KEYCODE_BUTTON_THUMBL = 106; + /** Key code constant: Right Thumb Button key. + * On a game controller, the right thumb button indicates that the right + * joystick is pressed. */ + public static final int KEYCODE_BUTTON_THUMBR = 107; + /** Key code constant: Start Button key. + * On a game controller, the button labeled Start. */ + public static final int KEYCODE_BUTTON_START = 108; + /** Key code constant: Select Button key. + * On a game controller, the button labeled Select. */ + public static final int KEYCODE_BUTTON_SELECT = 109; + /** Key code constant: Mode Button key. + * On a game controller, the button labeled Mode. */ + public static final int KEYCODE_BUTTON_MODE = 110; + /** Key code constant: Escape key. */ + public static final int KEYCODE_ESCAPE = 111; + /** Key code constant: Forward Delete key. + * Deletes characters ahead of the insertion point, unlike {@link #KEYCODE_DEL}. */ + public static final int KEYCODE_FORWARD_DEL = 112; + /** Key code constant: Left Control modifier key. */ + public static final int KEYCODE_CTRL_LEFT = 113; + /** Key code constant: Right Control modifier key. */ + public static final int KEYCODE_CTRL_RIGHT = 114; + /** Key code constant: Caps Lock modifier key. */ + public static final int KEYCODE_CAPS_LOCK = 115; + /** Key code constant: Scroll Lock key. */ + public static final int KEYCODE_SCROLL_LOCK = 116; + /** Key code constant: Left Meta modifier key. */ + public static final int KEYCODE_META_LEFT = 117; + /** Key code constant: Right Meta modifier key. */ + public static final int KEYCODE_META_RIGHT = 118; + /** Key code constant: Function modifier key. */ + public static final int KEYCODE_FUNCTION = 119; + /** Key code constant: System Request / Print Screen key. */ + public static final int KEYCODE_SYSRQ = 120; + /** Key code constant: Break / Pause key. */ + public static final int KEYCODE_BREAK = 121; + /** Key code constant: Home Movement key. + * Used for scrolling or moving the cursor around to the start of a line + * or to the top of a list. */ + public static final int KEYCODE_MOVE_HOME = 122; + /** Key code constant: End Movement key. + * Used for scrolling or moving the cursor around to the end of a line + * or to the bottom of a list. */ + public static final int KEYCODE_MOVE_END = 123; + /** Key code constant: Insert key. + * Toggles insert / overwrite edit mode. */ + public static final int KEYCODE_INSERT = 124; + /** Key code constant: Forward key. + * Navigates forward in the history stack. Complement of {@link #KEYCODE_BACK}. */ + public static final int KEYCODE_FORWARD = 125; + /** Key code constant: Play media key. */ + public static final int KEYCODE_MEDIA_PLAY = 126; + /** Key code constant: Pause media key. */ + public static final int KEYCODE_MEDIA_PAUSE = 127; + /** Key code constant: Close media key. + * May be used to close a CD tray, for example. */ + public static final int KEYCODE_MEDIA_CLOSE = 128; + /** Key code constant: Eject media key. + * May be used to eject a CD tray, for example. */ + public static final int KEYCODE_MEDIA_EJECT = 129; + /** Key code constant: Record media key. */ + public static final int KEYCODE_MEDIA_RECORD = 130; + /** Key code constant: F1 key. */ + public static final int KEYCODE_F1 = 131; + /** Key code constant: F2 key. */ + public static final int KEYCODE_F2 = 132; + /** Key code constant: F3 key. */ + public static final int KEYCODE_F3 = 133; + /** Key code constant: F4 key. */ + public static final int KEYCODE_F4 = 134; + /** Key code constant: F5 key. */ + public static final int KEYCODE_F5 = 135; + /** Key code constant: F6 key. */ + public static final int KEYCODE_F6 = 136; + /** Key code constant: F7 key. */ + public static final int KEYCODE_F7 = 137; + /** Key code constant: F8 key. */ + public static final int KEYCODE_F8 = 138; + /** Key code constant: F9 key. */ + public static final int KEYCODE_F9 = 139; + /** Key code constant: F10 key. */ + public static final int KEYCODE_F10 = 140; + /** Key code constant: F11 key. */ + public static final int KEYCODE_F11 = 141; + /** Key code constant: F12 key. */ + public static final int KEYCODE_F12 = 142; + /** Key code constant: Num Lock modifier key. + * This is the Num Lock key; it is different from {@link #KEYCODE_NUM}. + * This key generally modifies the behavior of other keys on the numeric keypad. */ + public static final int KEYCODE_NUM_LOCK = 143; + /** Key code constant: Numeric keypad '0' key. */ + public static final int KEYCODE_NUMPAD_0 = 144; + /** Key code constant: Numeric keypad '1' key. */ + public static final int KEYCODE_NUMPAD_1 = 145; + /** Key code constant: Numeric keypad '2' key. */ + public static final int KEYCODE_NUMPAD_2 = 146; + /** Key code constant: Numeric keypad '3' key. */ + public static final int KEYCODE_NUMPAD_3 = 147; + /** Key code constant: Numeric keypad '4' key. */ + public static final int KEYCODE_NUMPAD_4 = 148; + /** Key code constant: Numeric keypad '5' key. */ + public static final int KEYCODE_NUMPAD_5 = 149; + /** Key code constant: Numeric keypad '6' key. */ + public static final int KEYCODE_NUMPAD_6 = 150; + /** Key code constant: Numeric keypad '7' key. */ + public static final int KEYCODE_NUMPAD_7 = 151; + /** Key code constant: Numeric keypad '8' key. */ + public static final int KEYCODE_NUMPAD_8 = 152; + /** Key code constant: Numeric keypad '9' key. */ + public static final int KEYCODE_NUMPAD_9 = 153; + /** Key code constant: Numeric keypad '/' key (for division). */ + public static final int KEYCODE_NUMPAD_DIVIDE = 154; + /** Key code constant: Numeric keypad '*' key (for multiplication). */ + public static final int KEYCODE_NUMPAD_MULTIPLY = 155; + /** Key code constant: Numeric keypad '-' key (for subtraction). */ + public static final int KEYCODE_NUMPAD_SUBTRACT = 156; + /** Key code constant: Numeric keypad '+' key (for addition). */ + public static final int KEYCODE_NUMPAD_ADD = 157; + /** Key code constant: Numeric keypad '.' key (for decimals or digit grouping). */ + public static final int KEYCODE_NUMPAD_DOT = 158; + /** Key code constant: Numeric keypad ',' key (for decimals or digit grouping). */ + public static final int KEYCODE_NUMPAD_COMMA = 159; + /** Key code constant: Numeric keypad Enter key. */ + public static final int KEYCODE_NUMPAD_ENTER = 160; + /** Key code constant: Numeric keypad '=' key. */ + public static final int KEYCODE_NUMPAD_EQUALS = 161; + /** Key code constant: Numeric keypad '(' key. */ + public static final int KEYCODE_NUMPAD_LEFT_PAREN = 162; + /** Key code constant: Numeric keypad ')' key. */ + public static final int KEYCODE_NUMPAD_RIGHT_PAREN = 163; + /** Key code constant: Volume Mute key. + * Mutes the speaker, unlike {@link #KEYCODE_MUTE}. + * This key should normally be implemented as a toggle such that the first press + * mutes the speaker and the second press restores the original volume. */ + public static final int KEYCODE_VOLUME_MUTE = 164; + /** Key code constant: Info key. + * Common on TV remotes to show additional information related to what is + * currently being viewed. */ + public static final int KEYCODE_INFO = 165; + /** Key code constant: Channel up key. + * On TV remotes, increments the television channel. */ + public static final int KEYCODE_CHANNEL_UP = 166; + /** Key code constant: Channel down key. + * On TV remotes, decrements the television channel. */ + public static final int KEYCODE_CHANNEL_DOWN = 167; + /** Key code constant: Zoom in key. */ + public static final int KEYCODE_ZOOM_IN = 168; + /** Key code constant: Zoom out key. */ + public static final int KEYCODE_ZOOM_OUT = 169; + /** Key code constant: TV key. + * On TV remotes, switches to viewing live TV. */ + public static final int KEYCODE_TV = 170; + /** Key code constant: Window key. + * On TV remotes, toggles picture-in-picture mode or other windowing functions. */ + public static final int KEYCODE_WINDOW = 171; + /** Key code constant: Guide key. + * On TV remotes, shows a programming guide. */ + public static final int KEYCODE_GUIDE = 172; + /** Key code constant: DVR key. + * On some TV remotes, switches to a DVR mode for recorded shows. */ + public static final int KEYCODE_DVR = 173; + /** Key code constant: Bookmark key. + * On some TV remotes, bookmarks content or web pages. */ + public static final int KEYCODE_BOOKMARK = 174; + /** Key code constant: Toggle captions key. + * Switches the mode for closed-captioning text, for example during television shows. */ + public static final int KEYCODE_CAPTIONS = 175; + /** Key code constant: Settings key. + * Starts the system settings activity. */ + public static final int KEYCODE_SETTINGS = 176; + /** Key code constant: TV power key. + * On TV remotes, toggles the power on a television screen. */ + public static final int KEYCODE_TV_POWER = 177; + /** Key code constant: TV input key. + * On TV remotes, switches the input on a television screen. */ + public static final int KEYCODE_TV_INPUT = 178; + /** Key code constant: Set-top-box power key. + * On TV remotes, toggles the power on an external Set-top-box. */ + public static final int KEYCODE_STB_POWER = 179; + /** Key code constant: Set-top-box input key. + * On TV remotes, switches the input mode on an external Set-top-box. */ + public static final int KEYCODE_STB_INPUT = 180; + /** Key code constant: A/V Receiver power key. + * On TV remotes, toggles the power on an external A/V Receiver. */ + public static final int KEYCODE_AVR_POWER = 181; + /** Key code constant: A/V Receiver input key. + * On TV remotes, switches the input mode on an external A/V Receiver. */ + public static final int KEYCODE_AVR_INPUT = 182; + /** Key code constant: Red "programmable" key. + * On TV remotes, acts as a contextual/programmable key. */ + public static final int KEYCODE_PROG_RED = 183; + /** Key code constant: Green "programmable" key. + * On TV remotes, actsas a contextual/programmable key. */ + public static final int KEYCODE_PROG_GREEN = 184; + /** Key code constant: Yellow "programmable" key. + * On TV remotes, acts as a contextual/programmable key. */ + public static final int KEYCODE_PROG_YELLOW = 185; + /** Key code constant: Blue "programmable" key. + * On TV remotes, acts as a contextual/programmable key. */ + public static final int KEYCODE_PROG_BLUE = 186; + + private static final int LAST_KEYCODE = KEYCODE_PROG_BLUE; + + private static final int META_ALT_ON = 2; + private static final int META_CAPS_LOCK_ON = 0x00100000; + private static final int META_CTRL_ON = 0x1000; + private static final int META_SHIFT_ON = 1; + private static final int META_CTRL_MASK = 0x7000; + + private String[] mKeyCodes = new String[256]; + private String[] mAppKeyCodes = new String[256]; + + private void initKeyCodes() { + mKeyCodes[KEYCODE_DPAD_CENTER] = "\015"; + mKeyCodes[KEYCODE_DPAD_UP] = "\033[A"; + mKeyCodes[KEYCODE_DPAD_DOWN] = "\033[B"; + mKeyCodes[KEYCODE_DPAD_RIGHT] = "\033[C"; + mKeyCodes[KEYCODE_DPAD_LEFT] = "\033[D"; + mKeyCodes[KEYCODE_F1] = "\033[OP"; + mKeyCodes[KEYCODE_F2] = "\033[OQ"; + mKeyCodes[KEYCODE_F3] = "\033[OR"; + mKeyCodes[KEYCODE_F4] = "\033[OS"; + mKeyCodes[KEYCODE_F5] = "\033[15~"; + mKeyCodes[KEYCODE_F6] = "\033[17~"; + mKeyCodes[KEYCODE_F7] = "\033[18~"; + mKeyCodes[KEYCODE_F8] = "\033[19~"; + mKeyCodes[KEYCODE_F9] = "\033[20~"; + mKeyCodes[KEYCODE_F10] = "\033[21~"; + mKeyCodes[KEYCODE_F11] = "\033[23~"; + mKeyCodes[KEYCODE_F12] = "\033[24~"; + mKeyCodes[KEYCODE_SYSRQ] = "\033[32~"; // Sys Request / Print + // Is this Scroll lock? mKeyCodes[Cancel] = "\033[33~"; + mKeyCodes[KEYCODE_BREAK] = "\033[34~"; // Pause/Break + + mKeyCodes[KEYCODE_TAB] = "\011"; + mKeyCodes[KEYCODE_ENTER] = "\015"; + mKeyCodes[KEYCODE_ESCAPE] = "\033"; + + mKeyCodes[KEYCODE_INSERT] = "\033[2~"; + mKeyCodes[KEYCODE_FORWARD_DEL] = "\033[3~"; + mKeyCodes[KEYCODE_MOVE_HOME] = "\033[1~"; + mKeyCodes[KEYCODE_MOVE_END] = "\033[4~"; + mKeyCodes[KEYCODE_PAGE_UP] = "\033[5~"; + mKeyCodes[KEYCODE_PAGE_DOWN] = "\033[6~"; + mKeyCodes[KEYCODE_DEL]= "\177"; + mKeyCodes[KEYCODE_NUM_LOCK] = "\033OP"; + mKeyCodes[KEYCODE_NUMPAD_DIVIDE] = "/"; + mKeyCodes[KEYCODE_NUMPAD_MULTIPLY] = "*"; + mKeyCodes[KEYCODE_NUMPAD_SUBTRACT] = "-"; + mKeyCodes[KEYCODE_NUMPAD_ADD] = "+"; + mKeyCodes[KEYCODE_NUMPAD_ENTER] = "\015"; + mKeyCodes[KEYCODE_NUMPAD_EQUALS] = "="; + mKeyCodes[KEYCODE_NUMPAD_DOT] = "."; + mKeyCodes[KEYCODE_NUMPAD_COMMA] = ","; + mKeyCodes[KEYCODE_NUMPAD_0] = "0"; + mKeyCodes[KEYCODE_NUMPAD_1] = "1"; + mKeyCodes[KEYCODE_NUMPAD_2] = "2"; + mKeyCodes[KEYCODE_NUMPAD_3] = "3"; + mKeyCodes[KEYCODE_NUMPAD_4] = "4"; + mKeyCodes[KEYCODE_NUMPAD_5] = "5"; + mKeyCodes[KEYCODE_NUMPAD_6] = "6"; + mKeyCodes[KEYCODE_NUMPAD_7] = "7"; + mKeyCodes[KEYCODE_NUMPAD_8] = "8"; + mKeyCodes[KEYCODE_NUMPAD_9] = "9"; + + mAppKeyCodes[KEYCODE_DPAD_UP] = "\033OA"; + mAppKeyCodes[KEYCODE_DPAD_DOWN] = "\033OB"; + mAppKeyCodes[KEYCODE_DPAD_RIGHT] = "\033OC"; + mAppKeyCodes[KEYCODE_DPAD_LEFT] = "\033OD"; + mAppKeyCodes[KEYCODE_NUMPAD_DIVIDE] = "\033Oo"; + mAppKeyCodes[KEYCODE_NUMPAD_MULTIPLY] = "\033Oj"; + mAppKeyCodes[KEYCODE_NUMPAD_SUBTRACT] = "\033Om"; + mAppKeyCodes[KEYCODE_NUMPAD_ADD] = "\033Ok"; + mAppKeyCodes[KEYCODE_NUMPAD_ENTER] = "\033OM"; + mAppKeyCodes[KEYCODE_NUMPAD_EQUALS] = "\033OX"; + mAppKeyCodes[KEYCODE_NUMPAD_DOT] = "\033On"; + mAppKeyCodes[KEYCODE_NUMPAD_COMMA] = "\033Ol"; + mAppKeyCodes[KEYCODE_NUMPAD_0] = "\033Op"; + mAppKeyCodes[KEYCODE_NUMPAD_1] = "\033Oq"; + mAppKeyCodes[KEYCODE_NUMPAD_2] = "\033Or"; + mAppKeyCodes[KEYCODE_NUMPAD_3] = "\033Os"; + mAppKeyCodes[KEYCODE_NUMPAD_4] = "\033Ot"; + mAppKeyCodes[KEYCODE_NUMPAD_5] = "\033Ou"; + mAppKeyCodes[KEYCODE_NUMPAD_6] = "\033Ov"; + mAppKeyCodes[KEYCODE_NUMPAD_7] = "\033Ow"; + mAppKeyCodes[KEYCODE_NUMPAD_8] = "\033Ox"; + mAppKeyCodes[KEYCODE_NUMPAD_9] = "\033Oy"; } - public void handleFnKey(boolean down) { - mFnKey.handleModifierKey(down); - } /** - * Resets the KeyStateMachine into its default state + * The state engine for a modifier key. Can be pressed, released, locked, + * and so on. * */ - public void resetKeys() { - mControlKey.reset(); - mFnKey.reset(); - mCapsKey.reset(); - mAltKey.reset(); - mCharSequence = null; - } + private class ModifierKey { - /** - * Returns the effective state of the metakeys as a bitvector. - * - * This method does not change the state of the KeyStateMachine. It strictly - * combines the stored modifier key state with the MetaState bitvector - * passed in. - */ + private int mState; - public int getEffectiveMetaState(int metaState) { - boolean effectiveCaps = mAllowToggle && mCapsKey.isActive(); - boolean effectiveAlt = mAllowToggle && mAltKey.isActive(); - boolean effectiveCtrl = mAllowToggle && mControlKey.isActive(); - boolean effectiveFn = mAllowToggle && mFnKey.isActive(); - // this construct ors the META states together depending on the booleans - // for google foo the ? is called the ternary operator. - // I prefer it because it forces me to supply an alternative to the - // consequence - // of the condition. - return metaState | (effectiveCaps ? KeyEvent.META_SHIFT_MASK : 0) - | (effectiveAlt ? KeyEvent.META_ALT_MASK : 0) - | (effectiveCtrl ? KeyEvent.META_CTRL_MASK : 0) - | (effectiveFn ? KeyEvent.META_FUNCTION_ON : 0); - } + private static final int UNPRESSED = 0; - /** - * returns true when the KeyEvent e is the conclusion of a key sequence and - * a character sequence can be generated. The character sequence is then - * stored in mCharSequence. When a new KeyEvent sequenced has commenced then - * mCharSequence is truncated. - * - * @return boolean. - */ + private static final int PRESSED = 1; -// private static final ByteBuffer BYTE_TO_INT = ByteBuffer.allocate(8); - private static final byte ESC = 0x1b; + private static final int RELEASED = 2; + private static final int USED = 3; - private static int packKeyCode(int keyCode) { - return keyCode + C.KEYCODE_OFFSET; - } + private static final int LOCKED = 4; - private static int unpackCharCode(int charCode) { - return charCode - C.KEYCODE_OFFSET; - } + /** + * Construct a modifier key. UNPRESSED by default. + * + */ + public ModifierKey() { + mState = UNPRESSED; + } - private static boolean isPackedCharCode(int charCode) { - return (charCode >= C.KEYCODE_OFFSET); - } + public void onPress() { + switch (mState) { + case PRESSED: + // This is a repeat before use + break; + case RELEASED: + mState = LOCKED; + break; + case USED: + // This is a repeat after use + break; + case LOCKED: + mState = UNPRESSED; + break; + default: + mState = PRESSED; + break; + } + } - private static String handleSpecialKeyCode(int packedCharCode, boolean appMode) { - //the keycode is packed by mapControlChar(). Since it doesn't map to a single char, but to a - //String it needs to be handled here. - //Depending on the app mode. - String code = null; - int specialKeyCode = unpackCharCode(packedCharCode) ; - if (specialKeyCode >= 0 && specialKeyCode < C.specialKeyCharSeq.length) { - if (appMode) { - code = C.appSpecialKeyCharSeq[specialKeyCode]; + public void onRelease() { + switch (mState) { + case USED: + mState = UNPRESSED; + break; + case PRESSED: + mState = RELEASED; + break; + default: + // Leave state alone + break; } - if (code == null) { - code = C.specialKeyCharSeq[specialKeyCode]; + } + + public void adjustAfterKeypress() { + switch (mState) { + case PRESSED: + mState = USED; + break; + case RELEASED: + mState = UNPRESSED; + break; + default: + // Leave state alone + break; } } - return code; - } - public int mapControlChars(int c) { - int effectiveChar; - if (mControlKey.isActive()) { - effectiveChar = mapControlChar(c); - } else if (mFnKey.isActive()) { - effectiveChar = mapFnChar(c); - } else { - effectiveChar = c; + public boolean isActive() { + return mState != UNPRESSED; } - return effectiveChar; } - public int mapControlChar(int charCode) { - // Search is the control key. - return - (charCode >= 'a' && charCode <= 'z') ? - (char) (charCode - 'a' + '\001') : - (charCode >= 'A' && charCode <= 'Z') ? - (char) (charCode - 'A' + '\001') : - (charCode == ' ' || charCode == '2') ? - 0 : - (charCode == '[' || charCode == '3') ? - 27 : // ^[ (Esc) - (charCode == '\\' || charCode == '4') ? - 28 : - (charCode == ']' || charCode == '5') ? - 29 : - (charCode == '^' || charCode == '6') ? - 30 : // control-^ - (charCode == '_' || charCode == '7') ? - 31 : - (charCode == '8') ? - 127 : // DEL - (charCode == '9') ? - C.KEYCODE_OFFSET + C.KEYCODE_F11: - (charCode == '0') ? - C.KEYCODE_OFFSET + C.KEYCODE_F12: - charCode; - } + private ModifierKey mAltKey = new ModifierKey(); - private int mapFnChar(int charCode) { - return (charCode == 'w' || charCode == 'W') ? - C.KEYCODE_OFFSET + KeyEvent.KEYCODE_DPAD_UP: - (charCode == 'a' || charCode == 'A') ? - C.KEYCODE_OFFSET + KeyEvent.KEYCODE_DPAD_LEFT: - (charCode == 's' || charCode == 'S') ? - C.KEYCODE_OFFSET + KeyEvent.KEYCODE_DPAD_DOWN: - (charCode == 'd' || charCode == 'D') ? - C.KEYCODE_OFFSET + KeyEvent.KEYCODE_DPAD_RIGHT: - (charCode == 'p' || charCode == 'P') ? - C.KEYCODE_OFFSET + C.KEYCODE_PAGE_UP: - (charCode == 'n' || charCode == 'N') ? - C.KEYCODE_OFFSET + C.KEYCODE_PAGE_DOWN: - (charCode == 't' || charCode == 'T') ? - C.KEYCODE_OFFSET + KeyEvent.KEYCODE_TAB: - (charCode == 'l' || charCode == 'L') ? - '|': - (charCode == 'u' || charCode == 'U') ? - '_': - (charCode == 'e' || charCode == 'E') ? - 27: // ^[ (Esc) - (charCode == '.') ? - 28: // ^\ - (charCode > '0' && charCode <= '9') ? - // F1-F9 - (char)(charCode + C.KEYCODE_OFFSET + C.KEYCODE_F1 - 1): - (charCode == '0') ? - C.KEYCODE_OFFSET + C.KEYCODE_F10: - (charCode == 'i' || charCode == 'I') ? - C.KEYCODE_OFFSET + C.KEYCODE_INSERT: - (charCode == 'x' || charCode == 'X') ? - C.KEYCODE_OFFSET + C.KEYCODE_FORWARD_DEL: - (charCode == 'h' || charCode == 'H') ? - C.KEYCODE_OFFSET + C.KEYCODE_MOVE_HOME: - (charCode == 'f' || charCode == 'F') ? - C.KEYCODE_OFFSET + C.KEYCODE_MOVE_END: - charCode; - } + private ModifierKey mCapKey = new ModifierKey(); + + private ModifierKey mControlKey = new ModifierKey(); + + private ModifierKey mFnKey = new ModifierKey(); - private boolean ctrlActive(int metaState) { - return mControlKey.isActive() || ((metaState & KeyEvent.META_CTRL_ON) != 0); + private TermSession mTermSession; + + private int mBackKeyCode; + + // Map keycodes out of (above) the Unicode code point space. + static public final int KEYCODE_OFFSET = 0xA00000; + + /** + * Construct a term key listener. + * + */ + public TermKeyListener(TermSession termSession) { + mTermSession = termSession; + initKeyCodes(); } - private boolean fnActive(int metaState) { - return mFnKey.isActive() || ((metaState & KeyEvent.META_FUNCTION_ON) != 0); + public void setBackKeyCharacter(int code) { + mBackKeyCode = code; } - private static final int NO_CHAR = KeyCharacterMap.COMBINING_ACCENT; - - private int handleDeadKey(KeyEvent e, int metaState, int masks) { - int charcode; - int charCode = e.getUnicodeChar(metaState & (~masks)); - if ((charCode & KeyCharacterMap.COMBINING_ACCENT) != 0) { - mDeadChar = charCode; - charcode = NO_CHAR; - } else if (mDeadChar != null) { - int c = KeyEvent.getDeadChar(mDeadChar, charCode); - charcode = (c != 0) ? NO_CHAR : c; - mDeadChar = null; - } else if (charCode == 0) { - charcode = NO_CHAR; + public void handleControlKey(boolean down) { + if (down) { + mControlKey.onPress(); } else { - charcode = (ctrlActive(metaState) ? - mapControlChar(charCode) : - fnActive(metaState) ? mapFnChar(charCode) : - charCode); - assert(charcode != NO_CHAR); + mControlKey.onRelease(); } - return charcode; } - private boolean handleCharEvent(KeyEvent e) { - int metaState = getEffectiveMetaState(e.getMetaState()); - // The CTRL Key must be masked when using e.getUnicodeChar(). - // FIXME Please document why CTRL must be masked. - - // We want to mask the Alt key because of the mAltSendsEscape flag, - // but only when Alt is pressed. - - // Some keyboards/IMEs (e.g. Hacker Keyboard IME) will set "Meta" - // key down mask bits instead of "Alt" key down mask bits. - boolean prefixEscFlag = - (mAltSendsEscape && ((metaState & META_ALT_OR_META_MASK) != 0)); - int unicodeMask = KeyEvent.META_CTRL_MASK - | (prefixEscFlag ? META_ALT_OR_META_MASK : 0); - byte[] directMapping = lookupDirectMap( - packKeyCode(e.getKeyCode()), mAppMode, prefixEscFlag); - if (directMapping != null) { - // don't handle the key event any further when there is a direct map - // entry. - mCharSequence = directMapping; - } else if (e.getKeyCode() == KeyEvent.KEYCODE_BACK) { - mCharSequence = new byte[] { (byte) mBackBehavior }; + public void handleFnKey(boolean down) { + if (down) { + mFnKey.onPress(); } else { - int charCode = handleDeadKey(e, metaState, unicodeMask); - mCharSequence = lookupDirectMap(charCode, mAppMode, prefixEscFlag); + mFnKey.onRelease(); } - return true; } - public static byte[] lookupDirectMap(int charCode, boolean appMode, - boolean prefixEsc) { - ArrayList<Byte> escSeq = new ArrayList<Byte>(); - if (isPackedCharCode(charCode)) { - String data = handleSpecialKeyCode(charCode, appMode); - if (data != null) { - try { - byte[] x = data.getBytes("UTF-8"); - if (prefixEsc) { escSeq.add(ESC); } - for (int i=0; i<x.length; i++) { - escSeq.add(x[i]); - } - } catch (UnsupportedEncodingException ex) { - //ignore - } - } else { - escSeq = null; + public int mapControlChar(int ch) { + return mapControlChar(mControlKey.isActive(), mFnKey.isActive(), ch); + } + + public int mapControlChar(boolean control, boolean fn, int ch) { + int result = ch; + if (control) { + // Search is the control key. + if (result >= 'a' && result <= 'z') { + result = (char) (result - 'a' + '\001'); + } else if (result >= 'A' && result <= 'Z') { + result = (char) (result - 'A' + '\001'); + } else if (result == ' ' || result == '2') { + result = 0; + } else if (result == '[' || result == '3') { + result = 27; // ^[ (Esc) + } else if (result == '\\' || result == '4') { + result = 28; + } else if (result == ']' || result == '5') { + result = 29; + } else if (result == '^' || result == '6') { + result = 30; // control-^ + } else if (result == '_' || result == '7') { + result = 31; + } else if (result == '8') { + result = 127; // DEL + } else if (result == '9') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_F11; + } else if (result == '0') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_F12; } - } else if (charCode != NO_CHAR) { - if (prefixEsc) { escSeq.add(ESC); } - escSeq.add((byte) charCode); - } else { - escSeq = null; - } - byte[] data = null; - if (escSeq != null) { - data = new byte[escSeq.size()]; - int i = 0; - for (byte e: escSeq) { - data[i++] = e; + } else if (fn) { + if (result == 'w' || result == 'W') { + result = KEYCODE_OFFSET + KeyEvent.KEYCODE_DPAD_UP; + } else if (result == 'a' || result == 'A') { + result = KEYCODE_OFFSET + KeyEvent.KEYCODE_DPAD_LEFT; + } else if (result == 's' || result == 'S') { + result = KEYCODE_OFFSET + KeyEvent.KEYCODE_DPAD_DOWN; + } else if (result == 'd' || result == 'D') { + result = KEYCODE_OFFSET + KeyEvent.KEYCODE_DPAD_RIGHT; + } else if (result == 'p' || result == 'P') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_PAGE_UP; + } else if (result == 'n' || result == 'N') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_PAGE_DOWN; + } else if (result == 't' || result == 'T') { + result = KEYCODE_OFFSET + KeyEvent.KEYCODE_TAB; + } else if (result == 'l' || result == 'L') { + result = '|'; + } else if (result == 'u' || result == 'U') { + result = '_'; + } else if (result == 'e' || result == 'E') { + result = 27; // ^[ (Esc) + } else if (result == '.') { + result = 28; // ^\ + } else if (result > '0' && result <= '9') { + // F1-F9 + result = (char)(result + KEYCODE_OFFSET + TermKeyListener.KEYCODE_F1 - 1); + } else if (result == '0') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_F10; + } else if (result == 'i' || result == 'I') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_INSERT; + } else if (result == 'x' || result == 'X') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_FORWARD_DEL; + } else if (result == 'h' || result == 'H') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_MOVE_HOME; + } else if (result == 'f' || result == 'F') { + result = KEYCODE_OFFSET + TermKeyListener.KEYCODE_MOVE_END; } } - return data; - } - /** - * extracts the current character sequence from the key listener. - * Automatically resets the character sequence to null. - * @return the current character sequence - */ - public byte[] extractCharSequence() { - byte[] result = mCharSequence; - mCharSequence = null; - return result; - } + if (result > -1) { + mAltKey.adjustAfterKeypress(); + mCapKey.adjustAfterKeypress(); + mControlKey.adjustAfterKeypress(); + mFnKey.adjustAfterKeypress(); + } - public boolean keyDown(KeyEvent e) { - final int keycode = e.getKeyCode(); - return mCapsKey.handleModifierKey(keycode, true) - || mAltKey.handleModifierKey(keycode, true) - || mFnKey.handleModifierKey(keycode, true) - || mControlKey.handleModifierKey(keycode, true) - || handleCharEvent(e); + return result; } - public boolean keyUp(KeyEvent e) { - final int keycode = e.getKeyCode(); - return mCapsKey.handleModifierKey(keycode, false) - || mAltKey.handleModifierKey(keycode, false) - || mFnKey.handleModifierKey(keycode, false) - || mControlKey.handleModifierKey(keycode, false); - } -} - -/** - * The state engine for a modifier key. Can be pressed, released, locked, and so - * on. - * - */ -class ModifierKey { + /** + * Handle a keyDown event. + * + * @param keyCode the keycode of the keyDown event + * + */ + public void keyDown(int keyCode, KeyEvent event, boolean appMode) throws IOException { + if (handleKeyCode(keyCode, appMode)) { + return; + } + int result = -1; + boolean allowToggle = isEventFromToggleDevice(event); + boolean chordedCtrl = false; + switch (keyCode) { + case KeyEvent.KEYCODE_ALT_RIGHT: + case KeyEvent.KEYCODE_ALT_LEFT: + if (allowToggle) { + mAltKey.onPress(); + } + break; - private int mState; + case KeyEvent.KEYCODE_SHIFT_LEFT: + case KeyEvent.KEYCODE_SHIFT_RIGHT: + if (allowToggle) { + mCapKey.onPress(); + } + break; - private static final int UNPRESSED = 0; + case KEYCODE_CTRL_LEFT: + case KEYCODE_CTRL_RIGHT: + // Ignore the control key. + return; - private static final int PRESSED = 1; + case KEYCODE_CAPS_LOCK: + // Ignore the capslock key. + return; - private static final int RELEASED = 2; + case KeyEvent.KEYCODE_BACK: + result = mBackKeyCode; + break; - private static final int USED = 3; + default: { + int metaState = event.getMetaState(); + chordedCtrl = ((META_CTRL_ON & metaState) != 0); + boolean effectiveCaps = allowToggle && + (mCapKey.isActive()); + boolean effectiveAlt = allowToggle && mAltKey.isActive(); + int effectiveMetaState = metaState & (~META_CTRL_MASK); + if (effectiveCaps) { + effectiveMetaState |= KeyEvent.META_SHIFT_ON; + } + if (effectiveAlt) { + effectiveMetaState |= KeyEvent.META_ALT_ON; + } + result = event.getUnicodeChar(effectiveMetaState); + break; + } + } - private static final int LOCKED = 4; + boolean effectiveControl = chordedCtrl || (allowToggle && mControlKey.isActive()); + boolean effectiveFn = allowToggle && mFnKey.isActive(); - private final int mKeyCode; + result = mapControlChar(effectiveControl, effectiveFn, result); - /** - * Construct a modifier key. UNPRESSED by default. - * - */ - public ModifierKey(int keyCode) { - mState = UNPRESSED; - mKeyCode = keyCode; + if (result >= KEYCODE_OFFSET) { + handleKeyCode(result - KEYCODE_OFFSET, appMode); + } else if (result >= 0) { + mTermSession.write(result); + } } - public boolean handleModifierKey(int incomingKeyCode, boolean down) { - if (incomingKeyCode == mKeyCode) { - if (down) { - this.onPress(); - } else { - this.onRelease(); - } + private boolean isEventFromToggleDevice(KeyEvent event) { + if (AndroidCompat.SDK < 11) { return true; - } else { - return false; } + KeyCharacterMapCompat kcm = KeyCharacterMapCompat.wrap( + KeyCharacterMap.load(event.getDeviceId())); + return kcm.getModifierBehaviour() == + KeyCharacterMapCompat.MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED; } - public void handleModifierKey(boolean down) { - this.handleModifierKey(mKeyCode, down); - } - - public void onPress() { - switch (mState) { - case PRESSED: - // This is a repeat before use - break; - case RELEASED: - mState = LOCKED; - break; - case USED: - // This is a repeat after use - break; - case LOCKED: - mState = UNPRESSED; - break; - default: - mState = PRESSED; - break; + public boolean handleKeyCode(int keyCode, boolean appMode) throws IOException { + if (keyCode >= 0 && keyCode < mKeyCodes.length) { + String code = null; + if (appMode) { + code = mAppKeyCodes[keyCode]; + } + if (code == null) { + code = mKeyCodes[keyCode]; + } + if (code != null) { + mTermSession.write(code); + return true; + } } + return false; } - public void onRelease() { - switch (mState) { - case USED: - mState = UNPRESSED; - break; - case PRESSED: - mState = RELEASED; + /** + * Handle a keyUp event. + * + * @param keyCode the keyCode of the keyUp event + */ + public void keyUp(int keyCode, KeyEvent event) { + boolean allowToggle = isEventFromToggleDevice(event); + switch (keyCode) { + case KeyEvent.KEYCODE_ALT_LEFT: + case KeyEvent.KEYCODE_ALT_RIGHT: + if (allowToggle) { + mAltKey.onRelease(); + } break; - default: - // Leave state alone + case KeyEvent.KEYCODE_SHIFT_LEFT: + case KeyEvent.KEYCODE_SHIFT_RIGHT: + if (allowToggle) { + mCapKey.onRelease(); + } break; - } - } - public void reset() { - mState = UNPRESSED; - } - - public void adjustAfterKeypress() { - switch (mState) { - case PRESSED: - mState = USED; - break; - case RELEASED: - mState = UNPRESSED; + case KEYCODE_CTRL_LEFT: + case KEYCODE_CTRL_RIGHT: + // ignore control keys. break; + default: - // Leave state alone + // Ignore other keyUps break; } } - - public boolean isActive() { - return mState != UNPRESSED; - } } diff --git a/res/values/defaults.xml b/res/values/defaults.xml index e58db54..76d4743 100644 --- a/res/values/defaults.xml +++ b/res/values/defaults.xml @@ -19,5 +19,4 @@ <bool name="pref_verify_path_default">true</bool> <bool name="pref_do_path_extensions_default">true</bool> <bool name="pref_allow_prepend_path_default">true</bool> - <bool name="pref_alt_is_escape_default">false</bool> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 8aa1599..b2e23f4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -144,7 +144,4 @@ <string name="email_transcript_subject">Transcript from Android Terminal Emulator</string> <string name="email_transcript_chooser_title">Mail transcript using:</string> <string name="email_transcript_no_email_activity_found">Could not choose an email activity to send transcript.</string> - - <string name="title_alt_is_escape">Alt sends Escape</string> - <string name="summary_alt_is_escape">Alt in combination with another key sends Escape to the terminal. Entering Unicode with the Alt key doesnt work in this case.</string> </resources> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index b977a64..81be6a0 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -128,7 +128,6 @@ android:entries="@array/entries_ime_preference" android:entryValues="@array/entryvalues_ime_preference" android:dialogTitle="@string/dialog_title_ime_preference" /> - <CheckBoxPreference android:key="altisescape" android:title="@string/title_alt_is_escape" android:summary="@string/summary_alt_is_escape" android:defaultValue="@bool/pref_alt_is_escape_default"/> </PreferenceCategory> diff --git a/src/jackpal/androidterm/TermView.java b/src/jackpal/androidterm/TermView.java index 3c8196b..5d83e3d 100644 --- a/src/jackpal/androidterm/TermView.java +++ b/src/jackpal/androidterm/TermView.java @@ -45,7 +45,6 @@ public class TermView extends EmulatorView { setBackKeyCharacter(settings.getBackKeyCharacter()); setControlKeyCode(settings.getControlKeyCode()); setFnKeyCode(settings.getFnKeyCode()); - setAltSendsEsc(settings.altSendsEscape()); } public void updatePrefs(TermSettings settings) { diff --git a/src/jackpal/androidterm/util/TermSettings.java b/src/jackpal/androidterm/util/TermSettings.java index 8287b81..6336eb0 100644 --- a/src/jackpal/androidterm/util/TermSettings.java +++ b/src/jackpal/androidterm/util/TermSettings.java @@ -47,7 +47,6 @@ public class TermSettings { private boolean mVerifyPath; private boolean mDoPathExtensions; private boolean mAllowPathPrepend; - private boolean mAltSendsEsc; private String mPrependPath = null; private String mAppendPath = null; @@ -70,7 +69,6 @@ public class TermSettings { private static final String VERIFYPATH_KEY = "verify_path"; private static final String PATHEXTENSIONS_KEY = "do_path_extensions"; private static final String PATHPREPEND_KEY = "allow_prepend_path"; - private static final String ALT_SENDS_ESC = "altisescape"; public static final int WHITE = 0xffffffff; public static final int BLACK = 0xff000000; @@ -155,7 +153,6 @@ public class TermSettings { mVerifyPath = res.getBoolean(R.bool.pref_verify_path_default); mDoPathExtensions = res.getBoolean(R.bool.pref_do_path_extensions_default); mAllowPathPrepend = res.getBoolean(R.bool.pref_allow_prepend_path_default); - mAltSendsEsc = res.getBoolean(R.bool.pref_alt_is_escape_default); } public void readPrefs(SharedPreferences prefs) { @@ -180,7 +177,6 @@ public class TermSettings { mVerifyPath = readBooleanPref(VERIFYPATH_KEY, mVerifyPath); mDoPathExtensions = readBooleanPref(PATHEXTENSIONS_KEY, mDoPathExtensions); mAllowPathPrepend = readBooleanPref(PATHPREPEND_KEY, mAllowPathPrepend); - mAltSendsEsc = readBooleanPref(ALT_SENDS_ESC, mAltSendsEsc); mPrefs = null; // we leak a Context if we hold on to this } @@ -315,8 +311,4 @@ public class TermSettings { public String getAppendPath() { return mAppendPath; } - - public boolean altSendsEscape() { - return mAltSendsEsc; - } } diff --git a/tests/emulatorview-test/AndroidManifest.xml b/tests/emulatorview-test/AndroidManifest.xml deleted file mode 100644 index e647f8d..0000000 --- a/tests/emulatorview-test/AndroidManifest.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="jackpal.androidterm.test" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="3" /> - - <instrumentation - android:name="android.test.InstrumentationTestRunner" - android:targetPackage="jackpal.androidterm" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <uses-library android:name="android.test.runner" /> - </application> - -</manifest>
\ No newline at end of file diff --git a/tests/emulatorview-test/ant.properties b/tests/emulatorview-test/ant.properties deleted file mode 100644 index 8f4a4fb..0000000 --- a/tests/emulatorview-test/ant.properties +++ /dev/null @@ -1,18 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - -tested.project.dir=../../libraries/emulatorview diff --git a/tests/emulatorview-test/proguard-project.txt b/tests/emulatorview-test/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/tests/emulatorview-test/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/tests/emulatorview-test/project.properties b/tests/emulatorview-test/project.properties deleted file mode 100644 index 4d07452..0000000 --- a/tests/emulatorview-test/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-11 diff --git a/tests/emulatorview-test/res/drawable-hdpi/ic_launcher.png b/tests/emulatorview-test/res/drawable-hdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 96a442e..0000000 --- a/tests/emulatorview-test/res/drawable-hdpi/ic_launcher.png +++ /dev/null diff --git a/tests/emulatorview-test/res/drawable-ldpi/ic_launcher.png b/tests/emulatorview-test/res/drawable-ldpi/ic_launcher.png Binary files differdeleted file mode 100644 index 9923872..0000000 --- a/tests/emulatorview-test/res/drawable-ldpi/ic_launcher.png +++ /dev/null diff --git a/tests/emulatorview-test/res/drawable-mdpi/ic_launcher.png b/tests/emulatorview-test/res/drawable-mdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 359047d..0000000 --- a/tests/emulatorview-test/res/drawable-mdpi/ic_launcher.png +++ /dev/null diff --git a/tests/emulatorview-test/res/drawable-xhdpi/ic_launcher.png b/tests/emulatorview-test/res/drawable-xhdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 71c6d76..0000000 --- a/tests/emulatorview-test/res/drawable-xhdpi/ic_launcher.png +++ /dev/null diff --git a/tests/emulatorview-test/res/values/strings.xml b/tests/emulatorview-test/res/values/strings.xml deleted file mode 100644 index 4d3121d..0000000 --- a/tests/emulatorview-test/res/values/strings.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="app_name">Emulatorview-testTest</string> - -</resources>
\ No newline at end of file diff --git a/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/InputConnectionTest.java b/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/InputConnectionTest.java deleted file mode 100644 index 8c91066..0000000 --- a/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/InputConnectionTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package jackpal.androidterm.emulatorview; - -import android.test.AndroidTestCase; -import android.test.mock.MockApplication; -import android.test.mock.MockContext; -import android.util.DisplayMetrics; -import android.view.inputmethod.InputConnection; - -public class InputConnectionTest extends AndroidTestCase { - - - - - public InputConnectionTest() { - super(); - } - - public void testBackSpace() { -// MockContext cn = new MockContext(); -// MockApplication a = new MockApplication(); -// TermSession ts = new TermSession(); -// DisplayMetrics m = new DisplayMetrics(); -// EmulatorView e = new EmulatorView(cn, ts, m); -// InputConnection c = e.onCreateInputConnection(null); - } -} diff --git a/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/ModifierKeyTest.java b/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/ModifierKeyTest.java deleted file mode 100644 index 0158901..0000000 --- a/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/ModifierKeyTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package jackpal.androidterm.emulatorview; - -import android.test.AndroidTestCase; -import android.view.KeyEvent; - -public class ModifierKeyTest extends AndroidTestCase { - - public void testCtrlKey() { - ModifierKey mk = new ModifierKey(KeyEvent.KEYCODE_CTRL_LEFT); - assertFalse(mk.isActive()); - mk.handleModifierKey(KeyEvent.KEYCODE_CTRL_LEFT, true); - assertTrue(mk.isActive()); - } -} diff --git a/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/TermKeyListenerTest.java b/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/TermKeyListenerTest.java deleted file mode 100644 index 877c4d1..0000000 --- a/tests/emulatorview-test/src/jackpal/androidterm/emulatorview/TermKeyListenerTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package jackpal.androidterm.emulatorview; - - -import java.io.UnsupportedEncodingException; - -import android.annotation.TargetApi; -import android.test.AndroidTestCase; -import android.view.KeyEvent; - -@TargetApi(3) -public class TermKeyListenerTest extends AndroidTestCase { - TermKeyListener tkl_AltIsEsc; - TermKeyListener tkl_AltNotEsc; - - public TermKeyListenerTest() { - super(); - } - - public void setUp() { - tkl_AltIsEsc = new TermKeyListener(KeyEvent.KEYCODE_CTRL_LEFT, KeyEvent.KEYCODE_ALT_LEFT, - KeyEvent.KEYCODE_ESCAPE, true, false); - tkl_AltNotEsc = new TermKeyListener(KeyEvent.KEYCODE_CTRL_LEFT, KeyEvent.KEYCODE_ALT_LEFT, - KeyEvent.KEYCODE_ESCAPE, false, false); - } - - public void testKey_a() { - KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_A); - tkl_AltIsEsc.keyDown(event); - byte[] res = tkl_AltIsEsc.extractCharSequence(); - assertNotNull(res); - assertEquals(0x61, res[0]); - } - - public void testKey_X() { - KeyEvent event = new KeyEvent(1,2,KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_X, 0, KeyEvent.META_SHIFT_ON); - tkl_AltIsEsc.keyDown(event); - byte[] res = tkl_AltIsEsc.extractCharSequence(); - assertNotNull(res); - assertEquals(0x58, res[0]); - } - - public void testKey_CTRL_c() { - KeyEvent event = new KeyEvent(1,2, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_C, 0, KeyEvent.META_CTRL_ON); - tkl_AltIsEsc.keyDown(event); - byte[] res = tkl_AltIsEsc.extractCharSequence(); - assertNotNull(res); - assertEquals(0x03, res[0]); - } - - public void testKey_CTRL_c_no_esc() { - KeyEvent event = new KeyEvent(1,2, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_C, 0, KeyEvent.META_CTRL_ON); - tkl_AltNotEsc.keyDown(event); - byte[] res = tkl_AltNotEsc.extractCharSequence(); - assertNotNull(res); - assertEquals(0x03, res[0]); - } - - public void testKey_Alt_x() { - KeyEvent event = new KeyEvent(1,2, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_X, 0, KeyEvent.META_ALT_ON); - tkl_AltIsEsc.keyDown(event); - byte[] res = tkl_AltIsEsc.extractCharSequence(); - assertNotNull(res); - assertEquals(0x1b, res[0]); - assertEquals(0x78, res[1]); - } - - public void testKey_Alt_x_no_esc() { - KeyEvent event = new KeyEvent(1,2, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_X, 0, KeyEvent.META_ALT_ON); - tkl_AltNotEsc.keyDown(event); - byte[] res = tkl_AltNotEsc.extractCharSequence(); - assertNull(res); - } - - - public void testKey_Alt_e() { - KeyEvent event = new KeyEvent(1,2, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_E, 0, KeyEvent.META_ALT_ON); - tkl_AltIsEsc.keyDown(event); - byte res[] = tkl_AltIsEsc.extractCharSequence(); - assertNotNull(res); - assertEquals(0x1b, res[0]); - assertEquals(0x65, res[1]); - } - - public void testKey_enter() { - KeyEvent event = new KeyEvent(1,2, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER, 0, 0); - tkl_AltIsEsc.keyDown(event); - byte[] res = tkl_AltIsEsc.extractCharSequence(); - assertNotNull(res); - assertEquals(0x0d, res[0]); - } - - public void testKey_del() throws UnsupportedEncodingException { - KeyEvent event = new KeyEvent(1,2, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL,0 ,0); - tkl_AltIsEsc.keyDown(event); - byte[] res = tkl_AltIsEsc.extractCharSequence(); - byte[] exp = "\177".getBytes("UTF-8"); - assertNotNull(res); - assertEquals(exp.length, res.length); - for (int i = 0; i<exp.length; i++) { - assertEquals(exp[i],res[i]); - } - } - - public void testPreconditions() { - - } - - public void tearDown() { - } - -} |