Merge "Straighten out logic for revert word paths"
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index b2b68f0..ced7638 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.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 @@
* 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 @@
// 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 2a6e0a2..8e325b6 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -222,13 +222,7 @@
}
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 f234507..e267aa6 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -18,6 +18,7 @@
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 @@
* </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 @@
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 9e0c5ce..3a07cdf 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -239,7 +239,7 @@
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 @@
// 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 @@
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());
}