Check second down event of double tap is on shift key
This change also removes unnecessary touch point tweaks. Bug: 3385404 Change-Id: Ic398268ec4fcfaa9eafe8a70f2d10c2cd1fdfc62main
parent
6d0ff1d070
commit
e5ce433a9e
|
@ -403,7 +403,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
|
|
||||||
GestureDetector.SimpleOnGestureListener listener =
|
GestureDetector.SimpleOnGestureListener listener =
|
||||||
new GestureDetector.SimpleOnGestureListener() {
|
new GestureDetector.SimpleOnGestureListener() {
|
||||||
private boolean mProcessingDoubleTapEvent = false;
|
private boolean mProcessingShiftDoubleTapEvent = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFling(MotionEvent me1, MotionEvent me2, float velocityX,
|
public boolean onFling(MotionEvent me1, MotionEvent me2, float velocityX,
|
||||||
|
@ -424,25 +424,39 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onDoubleTap(MotionEvent e) {
|
public boolean onDoubleTap(MotionEvent firstDown) {
|
||||||
if (ENABLE_CAPSLOCK_BY_DOUBLETAP && mKeyboard instanceof LatinKeyboard
|
if (ENABLE_CAPSLOCK_BY_DOUBLETAP && mKeyboard instanceof LatinKeyboard
|
||||||
&& ((LatinKeyboard) mKeyboard).isAlphaKeyboard()) {
|
&& ((LatinKeyboard) mKeyboard).isAlphaKeyboard()) {
|
||||||
final int pointerIndex = e.getActionIndex();
|
final int pointerIndex = firstDown.getActionIndex();
|
||||||
final int id = e.getPointerId(pointerIndex);
|
final int id = firstDown.getPointerId(pointerIndex);
|
||||||
final PointerTracker tracker = getPointerTracker(id);
|
final PointerTracker tracker = getPointerTracker(id);
|
||||||
if (tracker.isOnShiftKey((int)e.getX(), (int)e.getY())) {
|
// If the first down event is on shift key.
|
||||||
onDoubleTapShiftKey(tracker);
|
if (tracker.isOnShiftKey((int)firstDown.getX(), (int)firstDown.getY())) {
|
||||||
mProcessingDoubleTapEvent = true;
|
mProcessingShiftDoubleTapEvent = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mProcessingDoubleTapEvent = false;
|
mProcessingShiftDoubleTapEvent = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onDoubleTapEvent(MotionEvent e) {
|
public boolean onDoubleTapEvent(MotionEvent secondTap) {
|
||||||
return mProcessingDoubleTapEvent;
|
if (mProcessingShiftDoubleTapEvent
|
||||||
|
&& secondTap.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
final MotionEvent secondDown = secondTap;
|
||||||
|
final int pointerIndex = secondDown.getActionIndex();
|
||||||
|
final int id = secondDown.getPointerId(pointerIndex);
|
||||||
|
final PointerTracker tracker = getPointerTracker(id);
|
||||||
|
// If the second down event is also on shift key.
|
||||||
|
if (tracker.isOnShiftKey((int)secondDown.getX(), (int)secondDown.getY())) {
|
||||||
|
onDoubleTapShiftKey(tracker);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Otherwise these events should not be handled as double tap.
|
||||||
|
mProcessingShiftDoubleTapEvent = false;
|
||||||
|
}
|
||||||
|
return mProcessingShiftDoubleTapEvent;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -315,11 +315,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
int x = pointX;
|
int x = pointX;
|
||||||
int y = pointY;
|
int y = pointY;
|
||||||
final int code = key.mCode;
|
final int code = key.mCode;
|
||||||
if (code == CODE_SHIFT || code == CODE_DELETE) {
|
if (code == CODE_SPACE) {
|
||||||
y -= key.mHeight / 10;
|
|
||||||
if (code == CODE_SHIFT) x += key.mWidth / 6;
|
|
||||||
if (code == CODE_DELETE) x -= key.mWidth / 6;
|
|
||||||
} else if (code == CODE_SPACE) {
|
|
||||||
y += LatinKeyboard.sSpacebarVerticalCorrection;
|
y += LatinKeyboard.sSpacebarVerticalCorrection;
|
||||||
if (SubtypeSwitcher.getInstance().useSpacebarLanguageSwitcher()
|
if (SubtypeSwitcher.getInstance().useSpacebarLanguageSwitcher()
|
||||||
&& SubtypeSwitcher.getInstance().getEnabledKeyboardLocaleCount() > 1) {
|
&& SubtypeSwitcher.getInstance().getEnabledKeyboardLocaleCount() > 1) {
|
||||||
|
|
Loading…
Reference in New Issue