aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java9
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyDetector.java8
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java19
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java6
4 files changed, 31 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index b2b68f0ad..ced763841 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -22,6 +22,7 @@ import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
+import android.util.Log;
import android.util.Xml;
import com.android.inputmethod.keyboard.internal.KeyStyles;
@@ -42,6 +43,8 @@ import java.util.Map;
* Class for describing the position and characteristics of a single key in the keyboard.
*/
public class Key {
+ private static final String TAG = Key.class.getSimpleName();
+
/**
* The key code (unicode or custom code) that this key generates.
*/
@@ -284,7 +287,11 @@ public class Key {
// specified.
final int code = style.getInt(keyAttr, R.styleable.Keyboard_Key_code,
Keyboard.CODE_UNSPECIFIED);
- if (code == Keyboard.CODE_UNSPECIFIED && !TextUtils.isEmpty(mLabel)) {
+ if (code == Keyboard.CODE_UNSPECIFIED && mOutputText == null
+ && !TextUtils.isEmpty(mLabel)) {
+ if (mLabel.length() != 1) {
+ Log.w(TAG, "Label is not a single letter: label=" + mLabel);
+ }
final int firstChar = mLabel.charAt(0);
mCode = getRtlParenthesisCode(firstChar, params.mIsRtlKeyboard);
} else if (code != Keyboard.CODE_UNSPECIFIED) {
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;
* </pre>
*/
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());
}