aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/ModifierKeyState.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ModifierKeyState.java')
-rw-r--r--java/src/com/android/inputmethod/latin/ModifierKeyState.java49
1 files changed, 43 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/ModifierKeyState.java b/java/src/com/android/inputmethod/latin/ModifierKeyState.java
index 097e87abe..eb1204f70 100644
--- a/java/src/com/android/inputmethod/latin/ModifierKeyState.java
+++ b/java/src/com/android/inputmethod/latin/ModifierKeyState.java
@@ -16,27 +16,64 @@
package com.android.inputmethod.latin;
-class ModifierKeyState {
- private static final int RELEASING = 0;
- private static final int PRESSING = 1;
- private static final int MOMENTARY = 2;
+import android.util.Log;
- private int mState = RELEASING;
+public class ModifierKeyState {
+ protected static final String TAG = "ModifierKeyState";
+ protected static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
+
+ protected static final int RELEASING = 0;
+ protected static final int PRESSING = 1;
+ protected static final int MOMENTARY = 2;
+
+ protected final String mName;
+ protected int mState = RELEASING;
+
+ public ModifierKeyState(String name) {
+ mName = name;
+ }
public void onPress() {
+ final int oldState = mState;
mState = PRESSING;
+ if (DEBUG)
+ Log.d(TAG, mName + ".onPress: " + toString(oldState) + " > " + this);
}
public void onRelease() {
+ final int oldState = mState;
mState = RELEASING;
+ if (DEBUG)
+ Log.d(TAG, mName + ".onRelease: " + toString(oldState) + " > " + this);
}
public void onOtherKeyPressed() {
- if (mState == PRESSING)
+ final int oldState = mState;
+ if (oldState == PRESSING)
mState = MOMENTARY;
+ if (DEBUG)
+ Log.d(TAG, mName + ".onOtherKeyPressed: " + toString(oldState) + " > " + this);
+ }
+
+ public boolean isReleasing() {
+ return mState == RELEASING;
}
public boolean isMomentary() {
return mState == MOMENTARY;
}
+
+ @Override
+ public String toString() {
+ return toString(mState);
+ }
+
+ protected String toString(int state) {
+ switch (state) {
+ case RELEASING: return "RELEASING";
+ case PRESSING: return "PRESSING";
+ case MOMENTARY: return "MOMENTARY";
+ default: return "UNKNOWN";
+ }
+ }
}