Display spacebar language switcher even when key preview is off
Bug: 4313884 Change-Id: I9d4a474302dadbfc610324799f8768b803705e52main
parent
5454ff5a66
commit
e6cb8fc234
|
@ -889,8 +889,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showKeyPreview(int keyIndex, PointerTracker tracker) {
|
public void showKeyPreview(int keyIndex, PointerTracker tracker) {
|
||||||
if (mShowKeyPreview || mKeyboard.needSpacebarPreview(keyIndex)) {
|
if (mShowKeyPreview) {
|
||||||
mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
|
mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
|
||||||
|
} else if (mKeyboard.needSpacebarPreview(keyIndex)) {
|
||||||
|
// Show key preview (in this case, slide language switcher) without any delay.
|
||||||
|
showKey(keyIndex, tracker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,6 +902,9 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
if (mShowKeyPreview) {
|
if (mShowKeyPreview) {
|
||||||
mHandler.cancelShowKeyPreview(tracker);
|
mHandler.cancelShowKeyPreview(tracker);
|
||||||
mHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
|
mHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
|
||||||
|
} else if (mKeyboard.needSpacebarPreview(KeyDetector.NOT_A_KEY)) {
|
||||||
|
// Dismiss key preview (in this case, slide language switcher) without any delay.
|
||||||
|
mPreviewText.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ public class PointerTracker {
|
||||||
startLongPressTimer(keyIndex);
|
startLongPressTimer(keyIndex);
|
||||||
showKeyPreview(keyIndex);
|
showKeyPreview(keyIndex);
|
||||||
setPressedKeyGraphics(keyIndex);
|
setPressedKeyGraphics(keyIndex);
|
||||||
} else if (!isMinorMoveBounce(x, y, keyIndex)) {
|
} else if (isMajorEnoughMoveToBeOnNewKey(x, y, keyIndex)) {
|
||||||
// The pointer has been slid in to the new key from the previous key, we must call
|
// The pointer has been slid in to the new key from the previous key, we must call
|
||||||
// onRelease() first to notify that the previous key has been released, then call
|
// onRelease() first to notify that the previous key has been released, then call
|
||||||
// onPress() to notify that the new key is being pressed.
|
// onPress() to notify that the new key is being pressed.
|
||||||
|
@ -430,9 +430,12 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (mKeyboard.needSpacebarPreview(keyIndex)) {
|
||||||
|
// Display spacebar slide language switcher.
|
||||||
|
showKeyPreview(keyIndex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (oldKey != null && !isMinorMoveBounce(x, y, keyIndex)) {
|
if (oldKey != null && isMajorEnoughMoveToBeOnNewKey(x, y, keyIndex)) {
|
||||||
// The pointer has been slid out from the previous key, we must call onRelease() to
|
// The pointer has been slid out from the previous key, we must call onRelease() to
|
||||||
// notify that the previous key has been released.
|
// notify that the previous key has been released.
|
||||||
setReleasedKeyGraphics(oldKeyIndex);
|
setReleasedKeyGraphics(oldKeyIndex);
|
||||||
|
@ -483,7 +486,7 @@ public class PointerTracker {
|
||||||
mIsInSlidingKeyInput = false;
|
mIsInSlidingKeyInput = false;
|
||||||
final PointerTrackerKeyState keyState = mKeyState;
|
final PointerTrackerKeyState keyState = mKeyState;
|
||||||
final int keyX, keyY;
|
final int keyX, keyY;
|
||||||
if (!isMinorMoveBounce(x, y, keyState.onMoveKey(x, y))) {
|
if (isMajorEnoughMoveToBeOnNewKey(x, y, keyState.onMoveKey(x, y))) {
|
||||||
keyX = x;
|
keyX = x;
|
||||||
keyY = y;
|
keyY = y;
|
||||||
} else {
|
} else {
|
||||||
|
@ -544,16 +547,16 @@ public class PointerTracker {
|
||||||
return mKeyState.getDownTime();
|
return mKeyState.getDownTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMinorMoveBounce(int x, int y, int newKey) {
|
private boolean isMajorEnoughMoveToBeOnNewKey(int x, int y, int newKey) {
|
||||||
if (mKeys == null || mKeyHysteresisDistanceSquared < 0)
|
if (mKeys == null || mKeyHysteresisDistanceSquared < 0)
|
||||||
throw new IllegalStateException("keyboard and/or hysteresis not set");
|
throw new IllegalStateException("keyboard and/or hysteresis not set");
|
||||||
int curKey = mKeyState.getKeyIndex();
|
int curKey = mKeyState.getKeyIndex();
|
||||||
if (newKey == curKey) {
|
if (newKey == curKey) {
|
||||||
return true;
|
|
||||||
} else if (isValidKeyIndex(curKey)) {
|
|
||||||
return mKeys.get(curKey).squaredDistanceToEdge(x, y) < mKeyHysteresisDistanceSquared;
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
|
} else if (isValidKeyIndex(curKey)) {
|
||||||
|
return mKeys.get(curKey).squaredDistanceToEdge(x, y) >= mKeyHysteresisDistanceSquared;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue