aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index 26b3c0581..fd25d7521 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -881,8 +881,17 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
public void showPreview(int keyIndex, PointerTracker tracker) {
int oldKeyIndex = mOldPreviewKeyIndex;
mOldPreviewKeyIndex = keyIndex;
- // If key changed and preview is on ...
- if (oldKeyIndex != keyIndex && mShowPreview) {
+ final boolean isLanguageSwitchEnabled = (mKeyboard instanceof LatinKeyboard)
+ && ((LatinKeyboard)mKeyboard).isLanguageSwitchEnabled();
+ // We should re-draw popup preview when 1) we need to hide the preview, 2) we will show
+ // the space key preview and 3) pointer moves off the space key to other letter key, we
+ // should hide the preview of the previous key.
+ final boolean hidePreviewOrShowSpaceKeyPreview = (tracker == null)
+ || tracker.isSpaceKey(keyIndex) || tracker.isSpaceKey(oldKeyIndex);
+ // If key changed and preview is on or the key is space (language switch is enabled)
+ if (oldKeyIndex != keyIndex
+ && (mShowPreview
+ || (hidePreviewOrShowSpaceKeyPreview && isLanguageSwitchEnabled))) {
if (keyIndex == NOT_A_KEY) {
mHandler.cancelPopupPreview();
mHandler.dismissPreview(DELAY_AFTER_PREVIEW);