diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java index 2a6e0a2de..8e325b65c 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java @@ -222,13 +222,7 @@ public class KeyDetector { } public static String printableCode(Key key) { - return key != null ? printableCode(key.mCode) : "none"; - } - - public static String printableCode(int primaryCode) { - if (primaryCode < 0) return String.format("%4d", primaryCode); - if (primaryCode < 0x100) return String.format("\\u%02x", primaryCode); - return String.format("\\u04x", primaryCode); + return key != null ? Keyboard.printableCode(key.mCode) : "none"; } public static String printableCodes(int[] codes) { diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index f234507d5..e267aa65c 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard; import android.graphics.drawable.Drawable; import android.text.TextUtils; +import android.util.Log; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardParams; @@ -48,6 +49,8 @@ import java.util.Set; * */ public class Keyboard { + private static final String TAG = Keyboard.class.getSimpleName(); + /** Some common keys code. These should be aligned with values/keycodes.xml */ public static final int CODE_ENTER = '\n'; public static final int CODE_TAB = '\t'; @@ -241,4 +244,20 @@ public class Keyboard { default: return null; } } + + public static String printableCode(int code) { + switch (code) { + case CODE_SHIFT: return "shift"; + case CODE_SWITCH_ALPHA_SYMBOL: return "symbol"; + case CODE_CAPSLOCK: return "capslock"; + case CODE_DELETE: return "delete"; + case CODE_SHORTCUT: return "shortcut"; + case CODE_DUMMY: return "dummy"; + case CODE_UNSPECIFIED: return "unspec"; + default: + if (code < 0) Log.w(TAG, "Unknow negative key code=" + code); + if (code < 0x100) return String.format("\\u%02x", code); + return String.format("\\u04x", code); + } + } } diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 9e0c5ce02..3a07cdf4d 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -239,7 +239,7 @@ public class PointerTracker { private boolean callListenerOnPressAndCheckKeyboardLayoutChange(Key key, boolean withSliding) { final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier(); if (DEBUG_LISTENER) { - Log.d(TAG, "onPress : " + KeyDetector.printableCode(key.mCode) + Log.d(TAG, "onPress : " + KeyDetector.printableCode(key) + " sliding=" + withSliding + " ignoreModifier=" + ignoreModifierKey + " enabled=" + key.isEnabled()); } @@ -264,7 +264,7 @@ public class PointerTracker { // If code is CODE_DUMMY here, this key will be ignored or generate text. final CharSequence text = (code != Keyboard.CODE_DUMMY) ? null : key.mOutputText; if (DEBUG_LISTENER) { - Log.d(TAG, "onCodeInput: " + KeyDetector.printableCode(code) + " text=" + text + Log.d(TAG, "onCodeInput: " + Keyboard.printableCode(code) + " text=" + text + " codes="+ KeyDetector.printableCodes(keyCodes) + " x=" + x + " y=" + y + " ignoreModifier=" + ignoreModifierKey + " alterCode=" + alterCode + " enabled=" + key.isEnabled()); @@ -289,7 +289,7 @@ public class PointerTracker { private void callListenerOnRelease(Key key, int primaryCode, boolean withSliding) { final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier(); if (DEBUG_LISTENER) { - Log.d(TAG, "onRelease : " + KeyDetector.printableCode(primaryCode) + Log.d(TAG, "onRelease : " + Keyboard.printableCode(primaryCode) + " sliding=" + withSliding + " ignoreModifier=" + ignoreModifierKey + " enabled="+ key.isEnabled()); }