Get rid of Key.needsSpecialPopupHint and related
Change-Id: I28e87ea3af9581f12094770b42f113e9018886c4main
parent
bc781e963f
commit
22b48de11c
|
@ -125,8 +125,6 @@ public class Key {
|
|||
private boolean mHighlightOn;
|
||||
/** Key is enabled and responds on press */
|
||||
private boolean mEnabled = true;
|
||||
/** Whether this key needs to show the "..." popup hint for special purposes */
|
||||
private boolean mNeedsSpecialPopupHint;
|
||||
|
||||
// RTL parenthesis character swapping map.
|
||||
private static final Map<Integer, Integer> sRtlParenthesisMap = new HashMap<Integer, Integer>();
|
||||
|
@ -449,14 +447,6 @@ public class Key {
|
|||
return (mLabelFlags & LABEL_FLAGS_HAS_POPUP_HINT) != 0;
|
||||
}
|
||||
|
||||
public void setNeedsSpecialPopupHint(boolean needsSpecialPopupHint) {
|
||||
mNeedsSpecialPopupHint = needsSpecialPopupHint;
|
||||
}
|
||||
|
||||
public boolean needsSpecialPopupHint() {
|
||||
return mNeedsSpecialPopupHint;
|
||||
}
|
||||
|
||||
public boolean hasUppercaseLetter() {
|
||||
return (mLabelFlags & LABEL_FLAGS_HAS_UPPERCASE_LETTER) != 0;
|
||||
}
|
||||
|
|
|
@ -165,8 +165,8 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
|||
// If the cached keyboard had been switched to another keyboard while the language was
|
||||
// displayed on its spacebar, it might have had arbitrary text fade factor. In such
|
||||
// case, we should reset the text fade factor. It is also applicable to shortcut key.
|
||||
mKeyboardView.updateSpacebar();
|
||||
latinKeyboard.updateSpacebarLanguage(0.0f,
|
||||
Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */),
|
||||
mSubtypeSwitcher.needsToDisplayLanguage(latinKeyboard.mId.mLocale));
|
||||
latinKeyboard.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
|
||||
}
|
||||
|
|
|
@ -712,8 +712,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
|||
}
|
||||
}
|
||||
|
||||
if ((key.hasPopupHint() && key.mMoreKeys != null && key.mMoreKeys.length > 0)
|
||||
|| key.needsSpecialPopupHint()) {
|
||||
if (key.hasPopupHint() && key.mMoreKeys != null && key.mMoreKeys.length > 0) {
|
||||
drawKeyPopupHint(key, canvas, paint, params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,10 +55,8 @@ public class LatinKeyboard extends Keyboard {
|
|||
private final int mSpacebarTextShadowColor;
|
||||
private final HashMap<Integer, BitmapDrawable> mSpaceDrawableCache =
|
||||
new HashMap<Integer, BitmapDrawable>();
|
||||
private final boolean mIsSpacebarTriggeringPopupByLongPress;
|
||||
|
||||
private boolean mAutoCorrectionSpacebarLedOn;
|
||||
private boolean mMultipleEnabledIMEsOrSubtypes;
|
||||
private boolean mNeedsToDisplayLanguage;
|
||||
private float mSpacebarTextFadeFactor = 0.0f;
|
||||
|
||||
|
@ -83,9 +81,6 @@ public class LatinKeyboard extends Keyboard {
|
|||
|
||||
mShortcutKey = getKey(CODE_SHORTCUT);
|
||||
mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
|
||||
final int longPressSpaceKeyTimeout =
|
||||
mRes.getInteger(R.integer.config_long_press_space_key_timeout);
|
||||
mIsSpacebarTriggeringPopupByLongPress = (longPressSpaceKeyTimeout > 0);
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
|
||||
|
@ -123,10 +118,8 @@ public class LatinKeyboard extends Keyboard {
|
|||
|
||||
// TODO: Move this drawing method to LatinKeyboardView.
|
||||
// TODO: Use Key.keyLabel to draw language name of spacebar.
|
||||
public Key updateSpacebarLanguage(float fadeFactor, boolean multipleEnabledIMEsOrSubtypes,
|
||||
boolean needsToDisplayLanguage) {
|
||||
public Key updateSpacebarLanguage(float fadeFactor, boolean needsToDisplayLanguage) {
|
||||
mSpacebarTextFadeFactor = fadeFactor;
|
||||
mMultipleEnabledIMEsOrSubtypes = multipleEnabledIMEsOrSubtypes;
|
||||
mNeedsToDisplayLanguage = needsToDisplayLanguage;
|
||||
updateSpacebarIcon();
|
||||
return mSpaceKey;
|
||||
|
@ -173,9 +166,6 @@ public class LatinKeyboard extends Keyboard {
|
|||
|
||||
private void updateSpacebarIcon() {
|
||||
if (mSpaceKey == null) return;
|
||||
final boolean shouldShowInputMethodPicker = mIsSpacebarTriggeringPopupByLongPress
|
||||
&& mMultipleEnabledIMEsOrSubtypes;
|
||||
mSpaceKey.setNeedsSpecialPopupHint(shouldShowInputMethodPicker);
|
||||
if (mNeedsToDisplayLanguage) {
|
||||
mSpaceKey.setIcon(getSpaceDrawable(mId.mLocale));
|
||||
} else if (mAutoCorrectionSpacebarLedOn) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Context;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
|
@ -60,6 +61,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
|||
|
||||
private static final boolean ENABLE_CAPSLOCK_BY_DOUBLETAP = true;
|
||||
|
||||
// For drawing spacebar.
|
||||
private final boolean mIsSpacebarTriggeringPopupByLongPress;
|
||||
private boolean mMultipleEnabledIMEsOrSubtypes;
|
||||
|
||||
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
|
||||
|
||||
// Timing constants
|
||||
|
@ -247,6 +252,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
|||
mKeyRepeatInterval = res.getInteger(R.integer.config_key_repeat_interval);
|
||||
|
||||
PointerTracker.init(mHasDistinctMultitouch, getContext());
|
||||
|
||||
final int longPressSpaceKeyTimeout =
|
||||
res.getInteger(R.integer.config_long_press_space_key_timeout);
|
||||
mIsSpacebarTriggeringPopupByLongPress = (longPressSpaceKeyTimeout > 0);
|
||||
}
|
||||
|
||||
public void startIgnoringDoubleTap() {
|
||||
|
@ -685,4 +694,21 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
|||
// Reflection doesn't support calling superclass methods.
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateSpacebar() {
|
||||
mMultipleEnabledIMEsOrSubtypes = Utils.hasMultipleEnabledIMEsOrSubtypes(
|
||||
true /* include aux subtypes */);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint,
|
||||
KeyDrawParams params) {
|
||||
super.onDrawKeyTopVisuals(key, canvas, paint, params);
|
||||
|
||||
// Whether space key needs to show the "..." popup hint for special purposes
|
||||
if (key.mCode == Keyboard.CODE_SPACE && mIsSpacebarTriggeringPopupByLongPress
|
||||
&& mMultipleEnabledIMEsOrSubtypes) {
|
||||
super.drawKeyPopupHint(key, canvas, paint, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -344,9 +344,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
if (inputView == null) return;
|
||||
final Keyboard keyboard = inputView.getKeyboard();
|
||||
if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
|
||||
inputView.updateSpacebar();
|
||||
final Key updatedKey = ((LatinKeyboard)keyboard).updateSpacebarLanguage(
|
||||
fadeFactor,
|
||||
Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */),
|
||||
SubtypeSwitcher.getInstance().needsToDisplayLanguage(keyboard.mId.mLocale));
|
||||
inputView.invalidateKey(updatedKey);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue