aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/ModifierKeyState.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2010-11-13 00:16:34 -0800
committerTadashi G. Takaoka <takaoka@google.com>2010-11-18 19:32:59 -0800
commitf27364600c742509b48857e6b8f17312033e0dc7 (patch)
treea07e3d98753fac073d34a643957204beaadcd4c4 /java/src/com/android/inputmethod/latin/ModifierKeyState.java
parent1d2d3228a393b3c562226936e3523eed4894def4 (diff)
downloadlatinime-f27364600c742509b48857e6b8f17312033e0dc7.tar.gz
latinime-f27364600c742509b48857e6b8f17312033e0dc7.tar.xz
latinime-f27364600c742509b48857e6b8f17312033e0dc7.zip
Implement both automatic and manual temporary upper cases
With this change, - Shift and Shift lock state of keyboard is maintained by LatinKeyboard.ShiftState. - Shift key state is maintained by ShiftKeyState object in KeyboardSwitcher. - LatinIME informs KeyboardSwitcher that shift key press, release and long press and KeyboardSwitcher determines which state LatinKeyboard and ShiftLeyState should be. Bug: 3193390 Change-Id: I948ef26fda512eb1cb0ebddc89d322c4f4f4d670
Diffstat (limited to '')
-rw-r--r--java/src/com/android/inputmethod/latin/ModifierKeyState.java36
1 files changed, 35 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/ModifierKeyState.java b/java/src/com/android/inputmethod/latin/ModifierKeyState.java
index 8139ec531..07a5c4f7f 100644
--- a/java/src/com/android/inputmethod/latin/ModifierKeyState.java
+++ b/java/src/com/android/inputmethod/latin/ModifierKeyState.java
@@ -16,26 +16,60 @@
package com.android.inputmethod.latin;
+import android.util.Log;
+
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() {
- mState = MOMENTARY;
+ final int oldState = mState;
+ if (mState == PRESSING)
+ mState = MOMENTARY;
+ if (DEBUG)
+ Log.d(TAG, mName + ".onOtherKeyPressed: " + toString(oldState) + " > " + this);
}
public boolean isMomentary() {
return mState == MOMENTARY;
}
+
+ @Override
+ public String toString() {
+ return toString(mState);
+ }
+
+ protected static String toString(int state) {
+ switch (state) {
+ case RELEASING: return "RELEASING";
+ case PRESSING: return "PRESSING";
+ case MOMENTARY: return "MOMENTARY";
+ default: return "UNKNOWN";
+ }
+ }
}