mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Refactor key preview code
This change removes mOldPreviewKeyIndex from KeyboardView. Bug: 4298393 Change-Id: I832eb6deab7e078609973bf0b8be09f73db204d7
This commit is contained in:
parent
bc91d89473
commit
d9786ce2e3
@ -153,7 +153,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||||||
|
|
||||||
makeSymbolsKeyboardIds(id.mMode, attribute);
|
makeSymbolsKeyboardIds(id.mMode, attribute);
|
||||||
mCurrentId = id;
|
mCurrentId = id;
|
||||||
mInputView.setPreviewEnabled(mInputMethodService.getPopupOn());
|
mInputView.setKeyPreviewEnabled(mInputMethodService.getPopupOn());
|
||||||
setKeyboard(getKeyboard(id));
|
setKeyboard(getKeyboard(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,27 +106,24 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
// Main keyboard
|
// Main keyboard
|
||||||
private Keyboard mKeyboard;
|
private Keyboard mKeyboard;
|
||||||
|
|
||||||
// Key preview popup
|
// Key preview
|
||||||
private boolean mInForeground;
|
private boolean mInForeground;
|
||||||
private TextView mPreviewText;
|
private TextView mPreviewText;
|
||||||
private int mPreviewTextSizeLarge;
|
private int mPreviewTextSizeLarge;
|
||||||
private final int[] mOffsetInWindow = new int[2];
|
private final int[] mOffsetInWindow = new int[2];
|
||||||
private int mOldPreviewKeyIndex = KeyDetector.NOT_A_KEY;
|
private boolean mShowKeyPreview = true;
|
||||||
private boolean mShowPreview = true;
|
private int mKeyPreviewDisplayedY;
|
||||||
private int mPopupPreviewOffsetX;
|
|
||||||
private int mPopupPreviewOffsetY;
|
|
||||||
private int mPopupPreviewDisplayedY;
|
|
||||||
private final int mDelayBeforePreview;
|
private final int mDelayBeforePreview;
|
||||||
private final int mDelayAfterPreview;
|
private final int mDelayAfterPreview;
|
||||||
private ViewGroup mPreviewPlacer;
|
private ViewGroup mPreviewPlacer;
|
||||||
|
|
||||||
// Popup mini keyboard
|
// Mini keyboard
|
||||||
private PopupWindow mMiniKeyboardPopup;
|
private PopupWindow mMiniKeyboardWindow;
|
||||||
private KeyboardView mMiniKeyboardView;
|
private KeyboardView mMiniKeyboardView;
|
||||||
private final WeakHashMap<Key, View> mMiniKeyboardCache = new WeakHashMap<Key, View>();
|
private final WeakHashMap<Key, View> mMiniKeyboardCache = new WeakHashMap<Key, View>();
|
||||||
private int mMiniKeyboardOriginX;
|
private int mMiniKeyboardOriginX;
|
||||||
private int mMiniKeyboardOriginY;
|
private int mMiniKeyboardOriginY;
|
||||||
private long mMiniKeyboardPopupTime;
|
private long mMiniKeyboardDisplayedTime;
|
||||||
private int[] mWindowOffset;
|
private int[] mWindowOffset;
|
||||||
private final float mMiniKeyboardSlideAllowance;
|
private final float mMiniKeyboardSlideAllowance;
|
||||||
private int mMiniKeyboardTrackerId;
|
private int mMiniKeyboardTrackerId;
|
||||||
@ -186,8 +183,8 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
private final UIHandler mHandler = new UIHandler();
|
private final UIHandler mHandler = new UIHandler();
|
||||||
|
|
||||||
class UIHandler extends Handler {
|
class UIHandler extends Handler {
|
||||||
private static final int MSG_POPUP_PREVIEW = 1;
|
private static final int MSG_SHOW_KEY_PREVIEW = 1;
|
||||||
private static final int MSG_DISMISS_PREVIEW = 2;
|
private static final int MSG_DISMISS_KEY_PREVIEW = 2;
|
||||||
private static final int MSG_REPEAT_KEY = 3;
|
private static final int MSG_REPEAT_KEY = 3;
|
||||||
private static final int MSG_LONGPRESS_KEY = 4;
|
private static final int MSG_LONGPRESS_KEY = 4;
|
||||||
private static final int MSG_LONGPRESS_SHIFT_KEY = 5;
|
private static final int MSG_LONGPRESS_SHIFT_KEY = 5;
|
||||||
@ -197,10 +194,10 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_POPUP_PREVIEW:
|
case MSG_SHOW_KEY_PREVIEW:
|
||||||
showKey(msg.arg1, (PointerTracker)msg.obj);
|
showKey(msg.arg1, (PointerTracker)msg.obj);
|
||||||
break;
|
break;
|
||||||
case MSG_DISMISS_PREVIEW:
|
case MSG_DISMISS_KEY_PREVIEW:
|
||||||
mPreviewText.setVisibility(View.INVISIBLE);
|
mPreviewText.setVisibility(View.INVISIBLE);
|
||||||
break;
|
break;
|
||||||
case MSG_REPEAT_KEY: {
|
case MSG_REPEAT_KEY: {
|
||||||
@ -211,7 +208,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
}
|
}
|
||||||
case MSG_LONGPRESS_KEY: {
|
case MSG_LONGPRESS_KEY: {
|
||||||
final PointerTracker tracker = (PointerTracker)msg.obj;
|
final PointerTracker tracker = (PointerTracker)msg.obj;
|
||||||
openPopupIfRequired(msg.arg1, tracker);
|
openMiniKeyboardIfRequired(msg.arg1, tracker);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_LONGPRESS_SHIFT_KEY: {
|
case MSG_LONGPRESS_SHIFT_KEY: {
|
||||||
@ -222,26 +219,35 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void popupPreview(long delay, int keyIndex, PointerTracker tracker) {
|
public void showKeyPreview(long delay, int keyIndex, PointerTracker tracker) {
|
||||||
removeMessages(MSG_POPUP_PREVIEW);
|
removeMessages(MSG_SHOW_KEY_PREVIEW);
|
||||||
if (mPreviewText.getVisibility() == VISIBLE || delay == 0) {
|
if (mPreviewText.getVisibility() == VISIBLE || delay == 0) {
|
||||||
// Show right away, if it's already visible and finger is moving around
|
// Show right away, if it's already visible and finger is moving around
|
||||||
showKey(keyIndex, tracker);
|
showKey(keyIndex, tracker);
|
||||||
} else {
|
} else {
|
||||||
sendMessageDelayed(obtainMessage(MSG_POPUP_PREVIEW, keyIndex, 0, tracker), delay);
|
sendMessageDelayed(
|
||||||
|
obtainMessage(MSG_SHOW_KEY_PREVIEW, keyIndex, 0, tracker), delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelPopupPreview() {
|
public void cancelShowKeyPreview(PointerTracker tracker) {
|
||||||
removeMessages(MSG_POPUP_PREVIEW);
|
removeMessages(MSG_SHOW_KEY_PREVIEW, tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dismissPreview(long delay) {
|
public void cancelAllShowKeyPreviews() {
|
||||||
sendMessageDelayed(obtainMessage(MSG_DISMISS_PREVIEW), delay);
|
removeMessages(MSG_SHOW_KEY_PREVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelDismissPreview() {
|
public void dismissKeyPreview(long delay, PointerTracker tracker) {
|
||||||
removeMessages(MSG_DISMISS_PREVIEW);
|
sendMessageDelayed(obtainMessage(MSG_DISMISS_KEY_PREVIEW, tracker), delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelDismissKeyPreview(PointerTracker tracker) {
|
||||||
|
removeMessages(MSG_DISMISS_KEY_PREVIEW, tracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelAllDismissKeyPreviews() {
|
||||||
|
removeMessages(MSG_DISMISS_KEY_PREVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker) {
|
public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker) {
|
||||||
@ -283,8 +289,8 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
|
|
||||||
public void cancelAllMessages() {
|
public void cancelAllMessages() {
|
||||||
cancelKeyTimers();
|
cancelKeyTimers();
|
||||||
cancelPopupPreview();
|
cancelAllShowKeyPreviews();
|
||||||
cancelDismissPreview();
|
cancelAllDismissKeyPreviews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,18 +370,18 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
mPreviewText = (TextView) LayoutInflater.from(context).inflate(previewLayout, null);
|
mPreviewText = (TextView) LayoutInflater.from(context).inflate(previewLayout, null);
|
||||||
mPreviewTextSizeLarge = (int) res.getDimension(R.dimen.key_preview_text_size_large);
|
mPreviewTextSizeLarge = (int) res.getDimension(R.dimen.key_preview_text_size_large);
|
||||||
} else {
|
} else {
|
||||||
mShowPreview = false;
|
mShowKeyPreview = false;
|
||||||
}
|
}
|
||||||
mDelayBeforePreview = res.getInteger(R.integer.config_delay_before_preview);
|
mDelayBeforePreview = res.getInteger(R.integer.config_delay_before_preview);
|
||||||
mDelayAfterPreview = res.getInteger(R.integer.config_delay_after_preview);
|
mDelayAfterPreview = res.getInteger(R.integer.config_delay_after_preview);
|
||||||
mKeyLabelHorizontalPadding = (int)res.getDimension(
|
mKeyLabelHorizontalPadding = (int)res.getDimension(
|
||||||
R.dimen.key_label_horizontal_alignment_padding);
|
R.dimen.key_label_horizontal_alignment_padding);
|
||||||
|
|
||||||
mMiniKeyboardPopup = new PopupWindow(context);
|
mMiniKeyboardWindow = new PopupWindow(context);
|
||||||
mMiniKeyboardPopup.setBackgroundDrawable(null);
|
mMiniKeyboardWindow.setBackgroundDrawable(null);
|
||||||
mMiniKeyboardPopup.setAnimationStyle(R.style.MiniKeyboardAnimation);
|
mMiniKeyboardWindow.setAnimationStyle(R.style.MiniKeyboardAnimation);
|
||||||
// Allow popup window to be drawn off the screen.
|
// Allow popup window to be drawn off the screen.
|
||||||
mMiniKeyboardPopup.setClippingEnabled(false);
|
mMiniKeyboardWindow.setClippingEnabled(false);
|
||||||
|
|
||||||
mPaint = new Paint();
|
mPaint = new Paint();
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
@ -485,11 +491,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
*/
|
*/
|
||||||
public void setKeyboard(Keyboard keyboard) {
|
public void setKeyboard(Keyboard keyboard) {
|
||||||
if (mKeyboard != null) {
|
if (mKeyboard != null) {
|
||||||
dismissKeyPreview();
|
dismissAllKeyPreviews();
|
||||||
}
|
}
|
||||||
// Remove any pending messages, except dismissing preview
|
// Remove any pending messages, except dismissing preview
|
||||||
mHandler.cancelKeyTimers();
|
mHandler.cancelKeyTimers();
|
||||||
mHandler.cancelPopupPreview();
|
mHandler.cancelAllShowKeyPreviews();
|
||||||
mKeyboard = keyboard;
|
mKeyboard = keyboard;
|
||||||
LatinImeLogger.onSetKeyboard(keyboard);
|
LatinImeLogger.onSetKeyboard(keyboard);
|
||||||
mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(),
|
mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(),
|
||||||
@ -545,33 +551,28 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables the key feedback popup. This is a popup that shows a magnified
|
* Enables or disables the key feedback preview. This is a preview that shows a magnified
|
||||||
* version of the depressed key. By default the preview is enabled.
|
* version of the depressed key. By default the preview is enabled.
|
||||||
* @param previewEnabled whether or not to enable the key feedback popup
|
* @param previewEnabled whether or not to enable the key feedback preview
|
||||||
* @see #isPreviewEnabled()
|
* @see #isKeyPreviewEnabled()
|
||||||
*/
|
*/
|
||||||
public void setPreviewEnabled(boolean previewEnabled) {
|
public void setKeyPreviewEnabled(boolean previewEnabled) {
|
||||||
mShowPreview = previewEnabled;
|
mShowKeyPreview = previewEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the enabled state of the key feedback popup.
|
* Returns the enabled state of the key feedback preview
|
||||||
* @return whether or not the key feedback popup is enabled
|
* @return whether or not the key feedback preview is enabled
|
||||||
* @see #setPreviewEnabled(boolean)
|
* @see #setKeyPreviewEnabled(boolean)
|
||||||
*/
|
*/
|
||||||
public boolean isPreviewEnabled() {
|
public boolean isKeyPreviewEnabled() {
|
||||||
return mShowPreview;
|
return mShowKeyPreview;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColorScheme() {
|
public int getColorScheme() {
|
||||||
return mColorScheme;
|
return mColorScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPopupOffset(int x, int y) {
|
|
||||||
mPopupPreviewOffsetX = x;
|
|
||||||
mPopupPreviewOffsetY = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key
|
* When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key
|
||||||
* codes for adjacent keys. When disabled, only the primary key code will be
|
* codes for adjacent keys. When disabled, only the primary key code will be
|
||||||
@ -879,23 +880,25 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: clean up this method.
|
// TODO: clean up this method.
|
||||||
private void dismissKeyPreview() {
|
private void dismissAllKeyPreviews() {
|
||||||
for (PointerTracker tracker : mPointerTrackers)
|
for (PointerTracker tracker : mPointerTrackers) {
|
||||||
tracker.setReleasedKeyGraphics();
|
tracker.setReleasedKeyGraphics();
|
||||||
showPreview(KeyDetector.NOT_A_KEY, null);
|
dismissKeyPreview(tracker);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showPreview(int keyIndex, PointerTracker tracker) {
|
public void showKeyPreview(int keyIndex, PointerTracker tracker) {
|
||||||
int oldKeyIndex = mOldPreviewKeyIndex;
|
if (mShowKeyPreview || mKeyboard.needSpacebarPreview(keyIndex)) {
|
||||||
mOldPreviewKeyIndex = keyIndex;
|
mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
|
||||||
if ((mShowPreview && oldKeyIndex != keyIndex) || mKeyboard.needSpacebarPreview(keyIndex)) {
|
}
|
||||||
if (keyIndex == KeyDetector.NOT_A_KEY) {
|
}
|
||||||
mHandler.cancelPopupPreview();
|
|
||||||
mHandler.dismissPreview(mDelayAfterPreview);
|
@Override
|
||||||
} else if (tracker != null) {
|
public void dismissKeyPreview(PointerTracker tracker) {
|
||||||
mHandler.popupPreview(mDelayBeforePreview, keyIndex, tracker);
|
if (mShowKeyPreview) {
|
||||||
}
|
mHandler.cancelShowKeyPreview(tracker);
|
||||||
|
mHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -924,7 +927,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
// TODO: Introduce minimum duration for displaying key previews
|
// TODO: Introduce minimum duration for displaying key previews
|
||||||
// TODO: Display up to two key previews when the user presses two keys at the same time
|
// TODO: Display up to two key previews when the user presses two keys at the same time
|
||||||
private void showKey(final int keyIndex, PointerTracker tracker) {
|
private void showKey(final int keyIndex, PointerTracker tracker) {
|
||||||
// If the preview popup has no parent view yet, add it to the ViewGroup which can place
|
// If the key preview has no parent view yet, add it to the ViewGroup which can place
|
||||||
// key preview absolutely in SoftInputWindow.
|
// key preview absolutely in SoftInputWindow.
|
||||||
if (mPreviewText.getParent() == null) {
|
if (mPreviewText.getParent() == null) {
|
||||||
addKeyPreview(mPreviewText);
|
addKeyPreview(mPreviewText);
|
||||||
@ -932,7 +935,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
|
|
||||||
final Key key = tracker.getKey(keyIndex);
|
final Key key = tracker.getKey(keyIndex);
|
||||||
// If keyIndex is invalid or IME is already closed, we must not show key preview.
|
// If keyIndex is invalid or IME is already closed, we must not show key preview.
|
||||||
// Trying to show preview PopupWindow while root window is closed causes
|
// Trying to show key preview while root window is closed causes
|
||||||
// WindowManager.BadTokenException.
|
// WindowManager.BadTokenException.
|
||||||
if (key == null || !mInForeground)
|
if (key == null || !mInForeground)
|
||||||
return;
|
return;
|
||||||
@ -956,37 +959,35 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
previewIcon != null ? previewIcon : key.getIcon());
|
previewIcon != null ? previewIcon : key.getIcon());
|
||||||
mPreviewText.setText(null);
|
mPreviewText.setText(null);
|
||||||
}
|
}
|
||||||
mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
|
|
||||||
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
|
||||||
int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), keyDrawWidth
|
|
||||||
+ mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
|
|
||||||
final int popupHeight = mPreviewHeight;
|
|
||||||
final ViewGroup.LayoutParams lp = mPreviewText.getLayoutParams();
|
|
||||||
lp.width = popupWidth;
|
|
||||||
lp.height = popupHeight;
|
|
||||||
|
|
||||||
int popupPreviewX = keyDrawX - (popupWidth - keyDrawWidth) / 2;
|
|
||||||
int popupPreviewY = key.mY - popupHeight + mPreviewOffset;
|
|
||||||
|
|
||||||
mHandler.cancelDismissPreview();
|
|
||||||
getLocationInWindow(mOffsetInWindow);
|
|
||||||
mOffsetInWindow[0] += mPopupPreviewOffsetX; // Offset may be zero
|
|
||||||
mOffsetInWindow[1] += mPopupPreviewOffsetY; // Offset may be zero
|
|
||||||
|
|
||||||
// Set the preview background state
|
// Set the preview background state
|
||||||
mPreviewText.getBackground().setState(
|
mPreviewText.getBackground().setState(
|
||||||
key.mPopupCharacters != null ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
|
key.mPopupCharacters != null ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
|
||||||
popupPreviewX += mOffsetInWindow[0];
|
|
||||||
popupPreviewY += mOffsetInWindow[1];
|
mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
|
||||||
|
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
||||||
|
int previewWidth = Math.max(mPreviewText.getMeasuredWidth(), keyDrawWidth
|
||||||
|
+ mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
|
||||||
|
final int previewHeight = mPreviewHeight;
|
||||||
|
final ViewGroup.LayoutParams lp = mPreviewText.getLayoutParams();
|
||||||
|
lp.width = previewWidth;
|
||||||
|
lp.height = previewHeight;
|
||||||
|
|
||||||
|
int previewX = keyDrawX - (previewWidth - keyDrawWidth) / 2;
|
||||||
|
int previewY = key.mY - previewHeight + mPreviewOffset;
|
||||||
|
|
||||||
|
mHandler.cancelAllDismissKeyPreviews();
|
||||||
|
getLocationInWindow(mOffsetInWindow);
|
||||||
|
previewX += mOffsetInWindow[0];
|
||||||
|
previewY += mOffsetInWindow[1];
|
||||||
|
|
||||||
// Place the key preview.
|
// Place the key preview.
|
||||||
// TODO: Adjust position of key previews which touch screen edges
|
// TODO: Adjust position of key previews which touch screen edges
|
||||||
if (lp instanceof ViewGroup.MarginLayoutParams) {
|
if (lp instanceof ViewGroup.MarginLayoutParams) {
|
||||||
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)lp;
|
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)lp;
|
||||||
mlp.setMargins(popupPreviewX, popupPreviewY, 0, 0);
|
mlp.setMargins(previewX, previewY, 0, 0);
|
||||||
}
|
}
|
||||||
// Record popup preview position to display mini-keyboard later at the same position
|
// Record key preview position to display mini-keyboard later at the same position
|
||||||
mPopupPreviewDisplayedY = popupPreviewY;
|
mKeyPreviewDisplayedY = previewY;
|
||||||
mPreviewText.setVisibility(VISIBLE);
|
mPreviewText.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,18 +1022,18 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
invalidate(mInvalidatedKeyRect);
|
invalidate(mInvalidatedKeyRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean openPopupIfRequired(int keyIndex, PointerTracker tracker) {
|
private boolean openMiniKeyboardIfRequired(int keyIndex, PointerTracker tracker) {
|
||||||
// Check if we have a popup layout specified first.
|
// Check if we have a popup layout specified first.
|
||||||
if (mPopupLayout == 0) {
|
if (mPopupLayout == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key popupKey = tracker.getKey(keyIndex);
|
Key parentKey = tracker.getKey(keyIndex);
|
||||||
if (popupKey == null)
|
if (parentKey == null)
|
||||||
return false;
|
return false;
|
||||||
boolean result = onLongPress(popupKey, tracker);
|
boolean result = onLongPress(parentKey, tracker);
|
||||||
if (result) {
|
if (result) {
|
||||||
dismissKeyPreview();
|
dismissAllKeyPreviews();
|
||||||
mMiniKeyboardTrackerId = tracker.mPointerId;
|
mMiniKeyboardTrackerId = tracker.mPointerId;
|
||||||
tracker.onLongPressed(mPointerQueue);
|
tracker.onLongPressed(mPointerQueue);
|
||||||
}
|
}
|
||||||
@ -1051,7 +1052,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
mKeyboardActionListener.onCodeInput(Keyboard.CODE_CAPSLOCK, null, 0, 0);
|
mKeyboardActionListener.onCodeInput(Keyboard.CODE_CAPSLOCK, null, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private View inflateMiniKeyboardContainer(Key popupKey) {
|
private View inflateMiniKeyboardContainer(Key parentKey) {
|
||||||
final View container = LayoutInflater.from(getContext()).inflate(mPopupLayout, null);
|
final View container = LayoutInflater.from(getContext()).inflate(mPopupLayout, null);
|
||||||
if (container == null)
|
if (container == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
@ -1062,19 +1063,19 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
@Override
|
@Override
|
||||||
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
|
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
|
||||||
mKeyboardActionListener.onCodeInput(primaryCode, keyCodes, x, y);
|
mKeyboardActionListener.onCodeInput(primaryCode, keyCodes, x, y);
|
||||||
dismissPopupKeyboard();
|
dismissMiniKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextInput(CharSequence text) {
|
public void onTextInput(CharSequence text) {
|
||||||
mKeyboardActionListener.onTextInput(text);
|
mKeyboardActionListener.onTextInput(text);
|
||||||
dismissPopupKeyboard();
|
dismissMiniKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancelInput() {
|
public void onCancelInput() {
|
||||||
mKeyboardActionListener.onCancelInput();
|
mKeyboardActionListener.onCancelInput();
|
||||||
dismissPopupKeyboard();
|
dismissMiniKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1096,7 +1097,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
miniKeyboardView.mGestureDetector = null;
|
miniKeyboardView.mGestureDetector = null;
|
||||||
|
|
||||||
final Keyboard keyboard = new MiniKeyboardBuilder(this, mKeyboard.getPopupKeyboardResId(),
|
final Keyboard keyboard = new MiniKeyboardBuilder(this, mKeyboard.getPopupKeyboardResId(),
|
||||||
popupKey).build();
|
parentKey).build();
|
||||||
miniKeyboardView.setKeyboard(keyboard);
|
miniKeyboardView.setKeyboard(keyboard);
|
||||||
|
|
||||||
container.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
|
container.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
|
||||||
@ -1119,20 +1120,20 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a key is long pressed. By default this will open any popup keyboard associated
|
* Called when a key is long pressed. By default this will open any mini keyboard associated
|
||||||
* with this key through the attributes popupLayout and popupCharacters.
|
* with this key through the attributes popupLayout and popupCharacters.
|
||||||
* @param popupKey the key that was long pressed
|
* @param parentKey the key that was long pressed
|
||||||
* @return true if the long press is handled, false otherwise. Subclasses should call the
|
* @return true if the long press is handled, false otherwise. Subclasses should call the
|
||||||
* method on the base class if the subclass doesn't wish to handle the call.
|
* method on the base class if the subclass doesn't wish to handle the call.
|
||||||
*/
|
*/
|
||||||
protected boolean onLongPress(Key popupKey, PointerTracker tracker) {
|
protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
|
||||||
if (popupKey.mPopupCharacters == null)
|
if (parentKey.mPopupCharacters == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
View container = mMiniKeyboardCache.get(popupKey);
|
View container = mMiniKeyboardCache.get(parentKey);
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
container = inflateMiniKeyboardContainer(popupKey);
|
container = inflateMiniKeyboardContainer(parentKey);
|
||||||
mMiniKeyboardCache.put(popupKey, container);
|
mMiniKeyboardCache.put(parentKey, container);
|
||||||
}
|
}
|
||||||
mMiniKeyboardView = (KeyboardView)container.findViewById(R.id.KeyboardView);
|
mMiniKeyboardView = (KeyboardView)container.findViewById(R.id.KeyboardView);
|
||||||
final MiniKeyboard miniKeyboard = (MiniKeyboard)mMiniKeyboardView.getKeyboard();
|
final MiniKeyboard miniKeyboard = (MiniKeyboard)mMiniKeyboardView.getKeyboard();
|
||||||
@ -1142,36 +1143,35 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
getLocationInWindow(mWindowOffset);
|
getLocationInWindow(mWindowOffset);
|
||||||
}
|
}
|
||||||
final int pointX = (mConfigShowMiniKeyboardAtTouchedPoint) ? tracker.getLastX()
|
final int pointX = (mConfigShowMiniKeyboardAtTouchedPoint) ? tracker.getLastX()
|
||||||
: popupKey.mX + popupKey.mWidth / 2;
|
: parentKey.mX + parentKey.mWidth / 2;
|
||||||
final int popupX = pointX - miniKeyboard.getDefaultCoordX()
|
final int miniKeyboardX = pointX - miniKeyboard.getDefaultCoordX()
|
||||||
- container.getPaddingLeft()
|
- container.getPaddingLeft()
|
||||||
+ getPaddingLeft() + mWindowOffset[0];
|
+ getPaddingLeft() + mWindowOffset[0];
|
||||||
final int popupY = popupKey.mY - mKeyboard.getVerticalGap()
|
final int miniKeyboardY = parentKey.mY - mKeyboard.getVerticalGap()
|
||||||
- (container.getMeasuredHeight() - container.getPaddingBottom())
|
- (container.getMeasuredHeight() - container.getPaddingBottom())
|
||||||
+ getPaddingTop() + mWindowOffset[1];
|
+ getPaddingTop() + mWindowOffset[1];
|
||||||
final int x = popupX;
|
final int x = miniKeyboardX;
|
||||||
final int y = mShowPreview && isOneRowKeys(miniKeyboard.getKeys())
|
final int y = mShowKeyPreview && isOneRowKeys(miniKeyboard.getKeys())
|
||||||
? mPopupPreviewDisplayedY : popupY;
|
? mKeyPreviewDisplayedY : miniKeyboardY;
|
||||||
|
|
||||||
mMiniKeyboardOriginX = x + container.getPaddingLeft() - mWindowOffset[0];
|
mMiniKeyboardOriginX = x + container.getPaddingLeft() - mWindowOffset[0];
|
||||||
mMiniKeyboardOriginY = y + container.getPaddingTop() - mWindowOffset[1];
|
mMiniKeyboardOriginY = y + container.getPaddingTop() - mWindowOffset[1];
|
||||||
mMiniKeyboardView.setPopupOffset(x, y);
|
|
||||||
if (miniKeyboard.setShifted(
|
if (miniKeyboard.setShifted(
|
||||||
mKeyboard == null ? false : mKeyboard.isShiftedOrShiftLocked())) {
|
mKeyboard == null ? false : mKeyboard.isShiftedOrShiftLocked())) {
|
||||||
mMiniKeyboardView.invalidateAllKeys();
|
mMiniKeyboardView.invalidateAllKeys();
|
||||||
}
|
}
|
||||||
// Mini keyboard needs no pop-up key preview displayed.
|
// Mini keyboard needs no pop-up key preview displayed.
|
||||||
mMiniKeyboardView.setPreviewEnabled(false);
|
mMiniKeyboardView.setKeyPreviewEnabled(false);
|
||||||
mMiniKeyboardPopup.setContentView(container);
|
mMiniKeyboardWindow.setContentView(container);
|
||||||
mMiniKeyboardPopup.setWidth(container.getMeasuredWidth());
|
mMiniKeyboardWindow.setWidth(container.getMeasuredWidth());
|
||||||
mMiniKeyboardPopup.setHeight(container.getMeasuredHeight());
|
mMiniKeyboardWindow.setHeight(container.getMeasuredHeight());
|
||||||
mMiniKeyboardPopup.showAtLocation(this, Gravity.NO_GRAVITY, x, y);
|
mMiniKeyboardWindow.showAtLocation(this, Gravity.NO_GRAVITY, x, y);
|
||||||
|
|
||||||
// Inject down event on the key to mini keyboard.
|
// Inject down event on the key to mini keyboard.
|
||||||
final long eventTime = SystemClock.uptimeMillis();
|
final long eventTime = SystemClock.uptimeMillis();
|
||||||
mMiniKeyboardPopupTime = eventTime;
|
mMiniKeyboardDisplayedTime = eventTime;
|
||||||
final MotionEvent downEvent = generateMiniKeyboardMotionEvent(MotionEvent.ACTION_DOWN,
|
final MotionEvent downEvent = generateMiniKeyboardMotionEvent(MotionEvent.ACTION_DOWN,
|
||||||
pointX, popupKey.mY + popupKey.mHeight / 2, eventTime);
|
pointX, parentKey.mY + parentKey.mHeight / 2, eventTime);
|
||||||
mMiniKeyboardView.onTouchEvent(downEvent);
|
mMiniKeyboardView.onTouchEvent(downEvent);
|
||||||
downEvent.recycle();
|
downEvent.recycle();
|
||||||
|
|
||||||
@ -1180,7 +1180,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MotionEvent generateMiniKeyboardMotionEvent(int action, int x, int y, long eventTime) {
|
private MotionEvent generateMiniKeyboardMotionEvent(int action, int x, int y, long eventTime) {
|
||||||
return MotionEvent.obtain(mMiniKeyboardPopupTime, eventTime, action,
|
return MotionEvent.obtain(mMiniKeyboardDisplayedTime, eventTime, action,
|
||||||
x - mMiniKeyboardOriginX, y - mMiniKeyboardOriginY, 0);
|
x - mMiniKeyboardOriginX, y - mMiniKeyboardOriginY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1191,7 +1191,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
|
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
|
||||||
for (int i = pointers.size(); i <= id; i++) {
|
for (int i = pointers.size(); i <= id; i++) {
|
||||||
final PointerTracker tracker =
|
final PointerTracker tracker =
|
||||||
new PointerTracker(i, mHandler, mKeyDetector, this, getResources());
|
new PointerTracker(i, this, mHandler, mKeyDetector, this);
|
||||||
if (mKeyboard != null)
|
if (mKeyboard != null)
|
||||||
tracker.setKeyboard(mKeyboard, mKeyHysteresisDistance);
|
tracker.setKeyboard(mKeyboard, mKeyHysteresisDistance);
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
@ -1237,7 +1237,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
// TODO: Reconcile gesture detection and accessibility features.
|
// TODO: Reconcile gesture detection and accessibility features.
|
||||||
if (mMiniKeyboardView == null && !mIsAccessibilityEnabled
|
if (mMiniKeyboardView == null && !mIsAccessibilityEnabled
|
||||||
&& mGestureDetector != null && mGestureDetector.onTouchEvent(me)) {
|
&& mGestureDetector != null && mGestureDetector.onTouchEvent(me)) {
|
||||||
dismissKeyPreview();
|
dismissAllKeyPreviews();
|
||||||
mHandler.cancelKeyTimers();
|
mHandler.cancelKeyTimers();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1334,7 +1334,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
mPreviewText.setVisibility(View.GONE);
|
mPreviewText.setVisibility(View.GONE);
|
||||||
mHandler.cancelAllMessages();
|
mHandler.cancelAllMessages();
|
||||||
|
|
||||||
dismissPopupKeyboard();
|
dismissMiniKeyboard();
|
||||||
mDirtyRect.union(0, 0, getWidth(), getHeight());
|
mDirtyRect.union(0, 0, getWidth(), getHeight());
|
||||||
mMiniKeyboardCache.clear();
|
mMiniKeyboardCache.clear();
|
||||||
requestLayout();
|
requestLayout();
|
||||||
@ -1351,9 +1351,9 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
closing();
|
closing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dismissPopupKeyboard() {
|
private void dismissMiniKeyboard() {
|
||||||
if (mMiniKeyboardPopup.isShowing()) {
|
if (mMiniKeyboardWindow.isShowing()) {
|
||||||
mMiniKeyboardPopup.dismiss();
|
mMiniKeyboardWindow.dismiss();
|
||||||
mMiniKeyboardView = null;
|
mMiniKeyboardView = null;
|
||||||
mMiniKeyboardOriginX = 0;
|
mMiniKeyboardOriginX = 0;
|
||||||
mMiniKeyboardOriginY = 0;
|
mMiniKeyboardOriginY = 0;
|
||||||
@ -1362,8 +1362,8 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleBack() {
|
public boolean handleBack() {
|
||||||
if (mMiniKeyboardPopup.isShowing()) {
|
if (mMiniKeyboardWindow.isShowing()) {
|
||||||
dismissPopupKeyboard();
|
dismissMiniKeyboard();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,14 +55,14 @@ public class LatinKeyboardView extends KeyboardView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPreviewEnabled(boolean previewEnabled) {
|
public void setKeyPreviewEnabled(boolean previewEnabled) {
|
||||||
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
||||||
if (latinKeyboard != null
|
if (latinKeyboard != null
|
||||||
&& (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard())) {
|
&& (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard())) {
|
||||||
// Phone and number keyboard never shows popup preview (except language switch).
|
// Phone and number keyboard never shows popup preview (except language switch).
|
||||||
super.setPreviewEnabled(false);
|
super.setKeyPreviewEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
super.setPreviewEnabled(previewEnabled);
|
super.setKeyPreviewEnabled(previewEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ public class PointerTracker {
|
|||||||
|
|
||||||
public interface UIProxy {
|
public interface UIProxy {
|
||||||
public void invalidateKey(Key key);
|
public void invalidateKey(Key key);
|
||||||
public void showPreview(int keyIndex, PointerTracker tracker);
|
public void showKeyPreview(int keyIndex, PointerTracker tracker);
|
||||||
|
public void dismissKeyPreview(PointerTracker tracker);
|
||||||
public boolean hasDistinctMultitouch();
|
public boolean hasDistinctMultitouch();
|
||||||
public boolean isAccessibilityEnabled();
|
public boolean isAccessibilityEnabled();
|
||||||
}
|
}
|
||||||
@ -49,9 +50,7 @@ public class PointerTracker {
|
|||||||
private final int mLongPressKeyTimeout;
|
private final int mLongPressKeyTimeout;
|
||||||
private final int mLongPressShiftKeyTimeout;
|
private final int mLongPressShiftKeyTimeout;
|
||||||
|
|
||||||
// Miscellaneous constants
|
private final KeyboardView mKeyboardView;
|
||||||
private static final int NOT_A_KEY = KeyDetector.NOT_A_KEY;
|
|
||||||
|
|
||||||
private final UIProxy mProxy;
|
private final UIProxy mProxy;
|
||||||
private final UIHandler mHandler;
|
private final UIHandler mHandler;
|
||||||
private final KeyDetector mKeyDetector;
|
private final KeyDetector mKeyDetector;
|
||||||
@ -107,11 +106,12 @@ public class PointerTracker {
|
|||||||
public void onSwipeDown() {}
|
public void onSwipeDown() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
public PointerTracker(int id, UIHandler handler, KeyDetector keyDetector,
|
public PointerTracker(int id, KeyboardView keyboardView, UIHandler handler,
|
||||||
UIProxy proxy, Resources res) {
|
KeyDetector keyDetector, UIProxy proxy) {
|
||||||
if (proxy == null || handler == null || keyDetector == null)
|
if (proxy == null || handler == null || keyDetector == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
mPointerId = id;
|
mPointerId = id;
|
||||||
|
mKeyboardView = keyboardView;
|
||||||
mProxy = proxy;
|
mProxy = proxy;
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mKeyDetector = keyDetector;
|
mKeyDetector = keyDetector;
|
||||||
@ -119,6 +119,7 @@ public class PointerTracker {
|
|||||||
mKeyState = new PointerTrackerKeyState(keyDetector);
|
mKeyState = new PointerTrackerKeyState(keyDetector);
|
||||||
mIsAccessibilityEnabled = proxy.isAccessibilityEnabled();
|
mIsAccessibilityEnabled = proxy.isAccessibilityEnabled();
|
||||||
mHasDistinctMultitouch = proxy.hasDistinctMultitouch();
|
mHasDistinctMultitouch = proxy.hasDistinctMultitouch();
|
||||||
|
final Resources res = mKeyboardView.getResources();
|
||||||
mConfigSlidingKeyInputEnabled = res.getBoolean(R.bool.config_sliding_key_input_enabled);
|
mConfigSlidingKeyInputEnabled = res.getBoolean(R.bool.config_sliding_key_input_enabled);
|
||||||
mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
|
mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
|
||||||
mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
|
mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
|
||||||
@ -420,11 +421,11 @@ public class PointerTracker {
|
|||||||
if (DEBUG_MODE)
|
if (DEBUG_MODE)
|
||||||
Log.w(TAG, String.format("onMoveEvent: sudden move is translated to "
|
Log.w(TAG, String.format("onMoveEvent: sudden move is translated to "
|
||||||
+ "up[%d,%d]/down[%d,%d] events", lastX, lastY, x, y));
|
+ "up[%d,%d]/down[%d,%d] events", lastX, lastY, x, y));
|
||||||
onUpEventInternal(lastX, lastY, eventTime);
|
onUpEventInternal(lastX, lastY, eventTime, true);
|
||||||
onDownEventInternal(x, y, eventTime);
|
onDownEventInternal(x, y, eventTime);
|
||||||
} else {
|
} else {
|
||||||
mKeyAlreadyProcessed = true;
|
mKeyAlreadyProcessed = true;
|
||||||
showKeyPreview(NOT_A_KEY);
|
dismissKeyPreview();
|
||||||
setReleasedKeyGraphics(oldKeyIndex);
|
setReleasedKeyGraphics(oldKeyIndex);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -442,7 +443,7 @@ public class PointerTracker {
|
|||||||
keyState.onMoveToNewKey(keyIndex, x, y);
|
keyState.onMoveToNewKey(keyIndex, x, y);
|
||||||
} else {
|
} else {
|
||||||
mKeyAlreadyProcessed = true;
|
mKeyAlreadyProcessed = true;
|
||||||
showKeyPreview(NOT_A_KEY);
|
dismissKeyPreview();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,17 +465,21 @@ public class PointerTracker {
|
|||||||
}
|
}
|
||||||
queue.remove(this);
|
queue.remove(this);
|
||||||
}
|
}
|
||||||
onUpEventInternal(x, y, eventTime);
|
onUpEventInternal(x, y, eventTime, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpEventForRelease(int x, int y, long eventTime) {
|
// Let this pointer tracker know that one of newer-than-this pointer trackers got an up event.
|
||||||
onUpEventInternal(x, y, eventTime);
|
// This pointer tracker needs to keep the key top graphics "pressed", but needs to get a
|
||||||
|
// "virtual" up event.
|
||||||
|
public void onPhantomUpEvent(int x, int y, long eventTime) {
|
||||||
|
onUpEventInternal(x, y, eventTime, false);
|
||||||
mKeyAlreadyProcessed = true;
|
mKeyAlreadyProcessed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpEventInternal(int x, int y, long eventTime) {
|
private void onUpEventInternal(int x, int y, long eventTime,
|
||||||
|
boolean updateReleasedKeyGraphics) {
|
||||||
mHandler.cancelKeyTimers();
|
mHandler.cancelKeyTimers();
|
||||||
mHandler.cancelPopupPreview();
|
mHandler.cancelShowKeyPreview(this);
|
||||||
mIsInSlidingKeyInput = false;
|
mIsInSlidingKeyInput = false;
|
||||||
final PointerTrackerKeyState keyState = mKeyState;
|
final PointerTrackerKeyState keyState = mKeyState;
|
||||||
final int keyX, keyY;
|
final int keyX, keyY;
|
||||||
@ -487,8 +492,9 @@ public class PointerTracker {
|
|||||||
keyY = keyState.getKeyY();
|
keyY = keyState.getKeyY();
|
||||||
}
|
}
|
||||||
final int keyIndex = keyState.onUpKey(keyX, keyY, eventTime);
|
final int keyIndex = keyState.onUpKey(keyX, keyY, eventTime);
|
||||||
showKeyPreview(NOT_A_KEY);
|
dismissKeyPreview();
|
||||||
setReleasedKeyGraphics(keyIndex);
|
if (updateReleasedKeyGraphics)
|
||||||
|
setReleasedKeyGraphics(keyIndex);
|
||||||
if (mKeyAlreadyProcessed)
|
if (mKeyAlreadyProcessed)
|
||||||
return;
|
return;
|
||||||
if (!mIsRepeatableKey) {
|
if (!mIsRepeatableKey) {
|
||||||
@ -513,8 +519,8 @@ public class PointerTracker {
|
|||||||
|
|
||||||
private void onCancelEventInternal() {
|
private void onCancelEventInternal() {
|
||||||
mHandler.cancelKeyTimers();
|
mHandler.cancelKeyTimers();
|
||||||
mHandler.cancelPopupPreview();
|
mHandler.cancelShowKeyPreview(this);
|
||||||
showKeyPreview(NOT_A_KEY);
|
dismissKeyPreview();
|
||||||
setReleasedKeyGraphics(mKeyState.getKeyIndex());
|
setReleasedKeyGraphics(mKeyState.getKeyIndex());
|
||||||
mIsInSlidingKeyInput = false;
|
mIsInSlidingKeyInput = false;
|
||||||
}
|
}
|
||||||
@ -559,11 +565,13 @@ public class PointerTracker {
|
|||||||
// supported. On the other hand, if multi-touch is not supported, the modifier key should
|
// supported. On the other hand, if multi-touch is not supported, the modifier key should
|
||||||
// be shown as preview. If accessibility is turned on, the modifier key should be shown as
|
// be shown as preview. If accessibility is turned on, the modifier key should be shown as
|
||||||
// preview.
|
// preview.
|
||||||
if (mHasDistinctMultitouch && isModifier() && !mIsAccessibilityEnabled) {
|
if (mHasDistinctMultitouch && isModifier() && !mIsAccessibilityEnabled)
|
||||||
mProxy.showPreview(NOT_A_KEY, this);
|
return;
|
||||||
} else {
|
mProxy.showKeyPreview(keyIndex, this);
|
||||||
mProxy.showPreview(keyIndex, this);
|
}
|
||||||
}
|
|
||||||
|
private void dismissKeyPreview() {
|
||||||
|
mProxy.dismissKeyPreview(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startLongPressTimer(int keyIndex) {
|
private void startLongPressTimer(int keyIndex) {
|
||||||
|
@ -35,7 +35,7 @@ public class PointerTrackerQueue {
|
|||||||
if (t.isModifier()) {
|
if (t.isModifier()) {
|
||||||
oldestPos++;
|
oldestPos++;
|
||||||
} else {
|
} else {
|
||||||
t.onUpEventForRelease(t.getLastX(), t.getLastY(), eventTime);
|
t.onPhantomUpEvent(t.getLastX(), t.getLastY(), eventTime);
|
||||||
queue.remove(oldestPos);
|
queue.remove(oldestPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ public class PointerTrackerQueue {
|
|||||||
for (PointerTracker t : mQueue) {
|
for (PointerTracker t : mQueue) {
|
||||||
if (t == tracker)
|
if (t == tracker)
|
||||||
continue;
|
continue;
|
||||||
t.onUpEventForRelease(t.getLastX(), t.getLastY(), eventTime);
|
t.onPhantomUpEvent(t.getLastX(), t.getLastY(), eventTime);
|
||||||
}
|
}
|
||||||
mQueue.clear();
|
mQueue.clear();
|
||||||
if (tracker != null)
|
if (tracker != null)
|
||||||
|
@ -592,7 +592,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
|
|
||||||
final boolean accessibilityEnabled = mAccessibilityUtils.isAccessibilityEnabled();
|
final boolean accessibilityEnabled = mAccessibilityUtils.isAccessibilityEnabled();
|
||||||
|
|
||||||
inputView.setPreviewEnabled(mPopupOn);
|
inputView.setKeyPreviewEnabled(mPopupOn);
|
||||||
inputView.setProximityCorrectionEnabled(true);
|
inputView.setProximityCorrectionEnabled(true);
|
||||||
inputView.setAccessibilityEnabled(accessibilityEnabled);
|
inputView.setAccessibilityEnabled(accessibilityEnabled);
|
||||||
// If we just entered a text field, maybe it has some old text that requires correction
|
// If we just entered a text field, maybe it has some old text that requires correction
|
||||||
|
Loading…
Reference in New Issue
Block a user