OSDN Git Service

AI 143256: Make the Term emulator work with the most recent keyboard IME.
authorJack Palevich <>
Fri, 27 Mar 2009 22:49:45 +0000 (15:49 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Fri, 27 Mar 2009 22:49:45 +0000 (15:49 -0700)
  + Makes the "Enter" key work again.
  + Makes the "Delete" key delete just one character each time you press it
  instead of two.
  BUG=1615131

Automated import of CL 143256

apps/Term/src/com/android/term/Term.java

index d74159b..1f43843 100644 (file)
@@ -548,16 +548,6 @@ public class Term extends Activity {
                     + controlKey + " 6 ==> Control-^").
             show();
      }
-
-    private void print(String msg) {
-        char[] chars = msg.toCharArray();
-        int len = chars.length;
-        byte[] bytes = new byte[len];
-        for (int i = 0; i < len; i++) {
-            bytes[i] = (byte) chars[i];
-        }
-        mEmulatorView.append(bytes, 0, len);
-    }
 }
 
 
@@ -2707,8 +2697,13 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
                 return null;
             }
 
-            public boolean hideStatusIcon() {
-                return true;
+            public boolean performEditorAction(int actionCode) {
+                if(actionCode == EditorInfo.IME_ACTION_UNSPECIFIED) {
+                    // The "return" key has been pressed on the IME.
+                    sendText("\n");
+                    return true;
+                }
+                return false;
             }
 
             public boolean performContextMenuAction(int id) {
@@ -2720,13 +2715,12 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
             }
 
             public boolean sendKeyEvent(KeyEvent event) {
-                switch(event.getKeyCode()) {
-                case KeyEvent.KEYCODE_ENTER:
-                    sendChar('\r');
-                    break;
-                case KeyEvent.KEYCODE_DEL:
-                    sendChar(127);
-                    break;
+                if (event.getAction() == KeyEvent.ACTION_DOWN) {
+                    switch(event.getKeyCode()) {
+                    case KeyEvent.KEYCODE_DEL:
+                        sendChar(127);
+                        break;
+                    }
                 }
                 return true;
             }
@@ -2739,10 +2733,6 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
                 return true;
             }
 
-            public boolean showStatusIcon(String packageName, int resId) {
-                return true;
-            }
-
             private void sendChar(int c) {
                 try {
                     mTermOut.write(c);