summaryrefslogtreecommitdiff
path: root/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java136
1 files changed, 3 insertions, 133 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 79b0cbf52..4d4046b98 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -21,16 +21,10 @@ import com.android.inputmethod.voice.VoiceIMEConnector;
import android.content.Context;
import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.os.Handler;
-import android.os.Message;
-import android.os.SystemClock;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
-import java.util.List;
-
// TODO: We should remove this class
public class LatinKeyboardView extends KeyboardView {
@@ -45,6 +39,8 @@ public class LatinKeyboardView extends KeyboardView {
private int mJumpThresholdSquare = Integer.MAX_VALUE;
/** The y coordinate of the last row */
private int mLastRowY;
+ private int mLastX;
+ private int mLastY;
public LatinKeyboardView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -73,7 +69,6 @@ public class LatinKeyboardView extends KeyboardView {
mJumpThresholdSquare *= mJumpThresholdSquare;
// Assuming there are 4 rows, this is the coordinate of the last row
mLastRowY = (k.getHeight() * 3) / 4;
- setKeyboardLocal(k);
}
public LatinKeyboard getLatinKeyboard() {
@@ -112,7 +107,7 @@ public class LatinKeyboardView extends KeyboardView {
&& keyboard.isShiftedOrShiftLocked()
&& !TextUtils.isEmpty(label) && label.length() < 3
&& Character.isLowerCase(label.charAt(0))) {
- label = label.toString().toUpperCase();
+ return label.toString().toUpperCase();
}
return label;
}
@@ -197,11 +192,6 @@ public class LatinKeyboardView extends KeyboardView {
@Override
public boolean onTouchEvent(MotionEvent me) {
LatinKeyboard keyboard = getLatinKeyboard();
- if (DEBUG_LINE) {
- mLastX = (int) me.getX();
- mLastY = (int) me.getY();
- invalidate();
- }
// If there was a sudden jump, return without processing the actual motion event.
if (handleSuddenJump(me))
@@ -228,106 +218,6 @@ public class LatinKeyboardView extends KeyboardView {
return super.onTouchEvent(me);
}
- /**************************** INSTRUMENTATION *******************************/
-
- public static final boolean DEBUG_AUTO_PLAY = false;
- public static final boolean DEBUG_LINE = false;
- private static final int MSG_TOUCH_DOWN = 1;
- private static final int MSG_TOUCH_UP = 2;
-
- Handler mHandler2;
-
- private String mStringToPlay;
- private int mStringIndex;
- private boolean mDownDelivered;
- private Key[] mAsciiKeys = new Key[256];
- private boolean mPlaying;
- private int mLastX;
- private int mLastY;
- private Paint mPaint;
-
- private void setKeyboardLocal(LatinKeyboard k) {
- if (DEBUG_AUTO_PLAY) {
- findKeys();
- if (mHandler2 == null) {
- mHandler2 = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- removeMessages(MSG_TOUCH_DOWN);
- removeMessages(MSG_TOUCH_UP);
- if (mPlaying == false) return;
-
- switch (msg.what) {
- case MSG_TOUCH_DOWN:
- if (mStringIndex >= mStringToPlay.length()) {
- mPlaying = false;
- return;
- }
- char c = mStringToPlay.charAt(mStringIndex);
- while (c > 255 || mAsciiKeys[c] == null) {
- mStringIndex++;
- if (mStringIndex >= mStringToPlay.length()) {
- mPlaying = false;
- return;
- }
- c = mStringToPlay.charAt(mStringIndex);
- }
- int x = mAsciiKeys[c].mX + 10;
- int y = mAsciiKeys[c].mY + 26;
- MotionEvent me = MotionEvent.obtain(SystemClock.uptimeMillis(),
- SystemClock.uptimeMillis(),
- MotionEvent.ACTION_DOWN, x, y, 0);
- LatinKeyboardView.this.dispatchTouchEvent(me);
- me.recycle();
- sendEmptyMessageDelayed(MSG_TOUCH_UP, 500); // Deliver up in 500ms if nothing else
- // happens
- mDownDelivered = true;
- break;
- case MSG_TOUCH_UP:
- char cUp = mStringToPlay.charAt(mStringIndex);
- int x2 = mAsciiKeys[cUp].mX + 10;
- int y2 = mAsciiKeys[cUp].mY + 26;
- mStringIndex++;
-
- MotionEvent me2 = MotionEvent.obtain(SystemClock.uptimeMillis(),
- SystemClock.uptimeMillis(),
- MotionEvent.ACTION_UP, x2, y2, 0);
- LatinKeyboardView.this.dispatchTouchEvent(me2);
- me2.recycle();
- sendEmptyMessageDelayed(MSG_TOUCH_DOWN, 500); // Deliver up in 500ms if nothing else
- // happens
- mDownDelivered = false;
- break;
- }
- }
- };
-
- }
- }
- }
-
- private void findKeys() {
- List<Key> keys = getLatinKeyboard().getKeys();
- // Get the keys on this keyboard
- for (int i = 0; i < keys.size(); i++) {
- int code = keys.get(i).mCodes[0];
- if (code >= 0 && code <= 255) {
- mAsciiKeys[code] = keys.get(i);
- }
- }
- }
-
- public void startPlaying(String s) {
- if (DEBUG_AUTO_PLAY) {
- if (s == null) return;
- mStringToPlay = s.toLowerCase();
- mPlaying = true;
- mDownDelivered = false;
- mStringIndex = 0;
- mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_DOWN, 10);
- }
- }
-
@Override
public void draw(Canvas c) {
Utils.GCUtils.getInstance().reset();
@@ -340,26 +230,6 @@ public class LatinKeyboardView extends KeyboardView {
tryGC = Utils.GCUtils.getInstance().tryGCOrWait("LatinKeyboardView", e);
}
}
- if (DEBUG_AUTO_PLAY) {
- if (mPlaying) {
- mHandler2.removeMessages(MSG_TOUCH_DOWN);
- mHandler2.removeMessages(MSG_TOUCH_UP);
- if (mDownDelivered) {
- mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_UP, 20);
- } else {
- mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_DOWN, 20);
- }
- }
- }
- if (DEBUG_LINE) {
- if (mPaint == null) {
- mPaint = new Paint();
- mPaint.setColor(0x80FFFFFF);
- mPaint.setAntiAlias(false);
- }
- c.drawLine(mLastX, 0, mLastX, getHeight(), mPaint);
- c.drawLine(0, mLastY, getWidth(), mLastY, mPaint);
- }
}
@Override