development
修订版 | f33ef54e21e102c757a15cab7bd91f67702670ac (tree) |
---|---|
时间 | 2011-08-05 16:28:27 |
作者 | Yi Sun <beyounn@gmai...> |
Commiter | Chih-Wei Huang |
Changed Ctrl to the real Ctrl keys. I did not add CAP key support for the Term yet.
Change-Id: Iccf659020aaffe655196169cdb051e0ac2e339d2
@@ -41,20 +41,6 @@ | ||
41 | 41 | </PreferenceCategory> |
42 | 42 | |
43 | 43 | <PreferenceCategory |
44 | - android:title="@string/keyboard_preferences"> | |
45 | - | |
46 | - <ListPreference | |
47 | - android:key="controlkey" | |
48 | - android:defaultValue="@string/default_value_controlkey_preference" | |
49 | - android:title="@string/title_controlkey_preference" | |
50 | - android:summary="@string/summary_controlkey_preference" | |
51 | - android:entries="@array/entries_controlkey_preference" | |
52 | - android:entryValues="@array/entryvalues_controlkey_preference" | |
53 | - android:dialogTitle="@string/dialog_title_controlkey_preference" /> | |
54 | - | |
55 | - </PreferenceCategory> | |
56 | - | |
57 | - <PreferenceCategory | |
58 | 44 | android:title="@string/shell_preferences"> |
59 | 45 | |
60 | 46 | <EditTextPreference |
@@ -118,11 +118,9 @@ public class Term extends Activity { | ||
118 | 118 | |
119 | 119 | private int mFontSize = 9; |
120 | 120 | private int mColorId = 2; |
121 | - private int mControlKeyId = 0; | |
122 | 121 | |
123 | 122 | private static final String FONTSIZE_KEY = "fontsize"; |
124 | 123 | private static final String COLOR_KEY = "color"; |
125 | - private static final String CONTROLKEY_KEY = "controlkey"; | |
126 | 124 | private static final String SHELL_KEY = "shell"; |
127 | 125 | private static final String INITIALCOMMAND_KEY = "initialcommand"; |
128 | 126 |
@@ -133,18 +131,6 @@ public class Term extends Activity { | ||
133 | 131 | private static final int[][] COLOR_SCHEMES = { |
134 | 132 | {BLACK, WHITE}, {WHITE, BLACK}, {WHITE, BLUE}}; |
135 | 133 | |
136 | - private static final int[] CONTROL_KEY_SCHEMES = { | |
137 | - KeyEvent.KEYCODE_DPAD_CENTER, | |
138 | - KeyEvent.KEYCODE_AT, | |
139 | - KeyEvent.KEYCODE_ALT_LEFT, | |
140 | - KeyEvent.KEYCODE_ALT_RIGHT | |
141 | - }; | |
142 | - private static final String[] CONTROL_KEY_NAME = { | |
143 | - "Ball", "@", "Left-Alt", "Right-Alt" | |
144 | - }; | |
145 | - | |
146 | - private int mControlKeyCode; | |
147 | - | |
148 | 134 | private final static String DEFAULT_SHELL = "/system/bin/sh -"; |
149 | 135 | private String mShell; |
150 | 136 |
@@ -313,8 +299,6 @@ public class Term extends Activity { | ||
313 | 299 | private void readPrefs() { |
314 | 300 | mFontSize = readIntPref(FONTSIZE_KEY, mFontSize, 20); |
315 | 301 | mColorId = readIntPref(COLOR_KEY, mColorId, COLOR_SCHEMES.length - 1); |
316 | - mControlKeyId = readIntPref(CONTROLKEY_KEY, mControlKeyId, | |
317 | - CONTROL_KEY_SCHEMES.length - 1); | |
318 | 302 | { |
319 | 303 | String newShell = readStringPref(SHELL_KEY, mShell); |
320 | 304 | if ((newShell == null) || ! newShell.equals(mShell)) { |
@@ -344,7 +328,6 @@ public class Term extends Activity { | ||
344 | 328 | getWindowManager().getDefaultDisplay().getMetrics(metrics); |
345 | 329 | mEmulatorView.setTextSize((int) (mFontSize * metrics.density)); |
346 | 330 | setColors(); |
347 | - mControlKeyCode = CONTROL_KEY_SCHEMES[mControlKeyId]; | |
348 | 331 | } |
349 | 332 | |
350 | 333 | private int readIntPref(String key, int defaultValue, int maxValue) { |
@@ -417,7 +400,8 @@ public class Term extends Activity { | ||
417 | 400 | } |
418 | 401 | |
419 | 402 | private boolean handleControlKey(int keyCode, boolean down) { |
420 | - if (keyCode == mControlKeyCode) { | |
403 | + if (keyCode == KeyEvent.KEYCODE_CTRL_RIGHT || | |
404 | + keyCode == KeyEvent.KEYCODE_CTRL_LEFT) { | |
421 | 405 | mKeyListener.handleControlKey(down); |
422 | 406 | return true; |
423 | 407 | } |
@@ -524,7 +508,7 @@ public class Term extends Activity { | ||
524 | 508 | } |
525 | 509 | |
526 | 510 | private void doDocumentKeys() { |
527 | - String controlKey = CONTROL_KEY_NAME[mControlKeyId]; | |
511 | + String controlKey = "ctrl"; | |
528 | 512 | new AlertDialog.Builder(this). |
529 | 513 | setTitle("Press " + controlKey + " and Key"). |
530 | 514 | setMessage(controlKey + " Space ==> Control-@ (NUL)\n" |
@@ -3174,6 +3158,7 @@ class TermKeyListener { | ||
3174 | 3158 | mControlKey.onPress(); |
3175 | 3159 | } else { |
3176 | 3160 | mControlKey.onRelease(); |
3161 | + mControlKey.adjustAfterKeypress(); | |
3177 | 3162 | } |
3178 | 3163 | } |
3179 | 3164 |
@@ -3200,8 +3185,6 @@ class TermKeyListener { | ||
3200 | 3185 | |
3201 | 3186 | if (result > -1) { |
3202 | 3187 | mAltKey.adjustAfterKeypress(); |
3203 | - mCapKey.adjustAfterKeypress(); | |
3204 | - mControlKey.adjustAfterKeypress(); | |
3205 | 3188 | } |
3206 | 3189 | return result; |
3207 | 3190 | } |
@@ -3225,7 +3208,6 @@ class TermKeyListener { | ||
3225 | 3208 | case KeyEvent.KEYCODE_SHIFT_RIGHT: |
3226 | 3209 | mCapKey.onPress(); |
3227 | 3210 | break; |
3228 | - | |
3229 | 3211 | case KeyEvent.KEYCODE_ENTER: |
3230 | 3212 | // Convert newlines into returns. The vt100 sends a |
3231 | 3213 | // '\r' when the 'Return' key is pressed, but our |
@@ -3265,6 +3247,7 @@ class TermKeyListener { | ||
3265 | 3247 | case KeyEvent.KEYCODE_SHIFT_LEFT: |
3266 | 3248 | case KeyEvent.KEYCODE_SHIFT_RIGHT: |
3267 | 3249 | mCapKey.onRelease(); |
3250 | + mCapKey.adjustAfterKeypress(); | |
3268 | 3251 | break; |
3269 | 3252 | default: |
3270 | 3253 | // Ignore other keyUps |