The back button key event is delivered correctly
Bug: 5275063 Change-Id: I439ce18665e40dc8b2e40e923e5cabfcae7c81cfmain
parent
a35ea4cba8
commit
d7b00f3490
|
@ -145,13 +145,6 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
|
||||||
// Nothing to do with.
|
// Nothing to do with.
|
||||||
}
|
}
|
||||||
|
|
||||||
private final View.OnTouchListener mMotionEventDelegate = new View.OnTouchListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onTouch(View view, MotionEvent me) {
|
|
||||||
return MoreSuggestionsView.this.dispatchTouchEvent(me);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showMoreKeysPanel(View parentView, Controller controller, int pointX, int pointY,
|
public void showMoreKeysPanel(View parentView, Controller controller, int pointX, int pointY,
|
||||||
PopupWindow window, KeyboardActionListener listener) {
|
PopupWindow window, KeyboardActionListener listener) {
|
||||||
|
@ -170,9 +163,7 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
|
||||||
- (container.getMeasuredHeight() - container.getPaddingBottom())
|
- (container.getMeasuredHeight() - container.getPaddingBottom())
|
||||||
+ parentView.getPaddingTop() + mCoordinates[1];
|
+ parentView.getPaddingTop() + mCoordinates[1];
|
||||||
|
|
||||||
container.setOnTouchListener(mMotionEventDelegate);
|
|
||||||
window.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
|
window.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||||
window.setFocusable(true);
|
|
||||||
window.setOutsideTouchable(true);
|
window.setOutsideTouchable(true);
|
||||||
window.setContentView(container);
|
window.setContentView(container);
|
||||||
window.setWidth(container.getMeasuredWidth());
|
window.setWidth(container.getMeasuredWidth());
|
||||||
|
@ -193,6 +184,7 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dismissMoreKeysPanel() {
|
public boolean dismissMoreKeysPanel() {
|
||||||
|
if (mController == null) return false;
|
||||||
return mController.dismissMoreKeysPanel();
|
return mController.dismissMoreKeysPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -549,6 +549,21 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
R.dimen.more_suggestions_modal_tolerance);
|
R.dimen.more_suggestions_modal_tolerance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final View.OnTouchListener mMoreSuggestionsCanceller = new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View view, MotionEvent me) {
|
||||||
|
if (!mMoreSuggestionsWindow.isShowing()) return false;
|
||||||
|
|
||||||
|
switch (me.getAction()) {
|
||||||
|
case MotionEvent.ACTION_UP:
|
||||||
|
case MotionEvent.ACTION_POINTER_UP:
|
||||||
|
return mMoreSuggestionsView.dismissMoreKeysPanel();
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A connection back to the input method.
|
* A connection back to the input method.
|
||||||
* @param listener
|
* @param listener
|
||||||
|
@ -764,6 +779,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
if (mMoreSuggestionsWindow.isShowing()) {
|
if (mMoreSuggestionsWindow.isShowing()) {
|
||||||
mMoreSuggestionsWindow.dismiss();
|
mMoreSuggestionsWindow.dismiss();
|
||||||
mKeyboardView.dimEntireKeyboard(false);
|
mKeyboardView.dimEntireKeyboard(false);
|
||||||
|
mKeyboardView.setOnTouchListener(null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -795,18 +811,22 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
moreKeysPanel.showMoreKeysPanel(
|
moreKeysPanel.showMoreKeysPanel(
|
||||||
this, mMoreSuggestionsController, pointX, pointY,
|
this, mMoreSuggestionsController, pointX, pointY,
|
||||||
mMoreSuggestionsWindow, mMoreSuggestionsListener);
|
mMoreSuggestionsWindow, mMoreSuggestionsListener);
|
||||||
mCheckingIfModalOrSlidingMode = true;
|
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
|
||||||
mOriginX = mLastX;
|
mOriginX = mLastX;
|
||||||
mOriginY = mLastY;
|
mOriginY = mLastY;
|
||||||
view.setPressed(false);
|
view.setPressed(false);
|
||||||
mKeyboardView.dimEntireKeyboard(true);
|
mKeyboardView.dimEntireKeyboard(true);
|
||||||
|
mKeyboardView.setOnTouchListener(mMoreSuggestionsCanceller);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Working variables for onLongClick and dispatchTouchEvent.
|
// Working variables for onLongClick and dispatchTouchEvent.
|
||||||
private boolean mCheckingIfModalOrSlidingMode;
|
private int mMoreSuggestionsMode = MORE_SUGGESTIONS_IN_MODAL_MODE;
|
||||||
|
private static final int MORE_SUGGESTIONS_IN_MODAL_MODE = 0;
|
||||||
|
private static final int MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING = 1;
|
||||||
|
private static final int MORE_SUGGESTIONS_IN_SLIDING_MODE = 2;
|
||||||
private int mLastX;
|
private int mLastX;
|
||||||
private int mLastY;
|
private int mLastY;
|
||||||
private int mOriginX;
|
private int mOriginX;
|
||||||
|
@ -815,7 +835,8 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchTouchEvent(MotionEvent me) {
|
public boolean dispatchTouchEvent(MotionEvent me) {
|
||||||
if (!mMoreSuggestionsWindow.isShowing()) {
|
if (!mMoreSuggestionsWindow.isShowing()
|
||||||
|
|| mMoreSuggestionsMode == MORE_SUGGESTIONS_IN_MODAL_MODE) {
|
||||||
mLastX = (int)me.getX();
|
mLastX = (int)me.getX();
|
||||||
mLastY = (int)me.getY();
|
mLastY = (int)me.getY();
|
||||||
return super.dispatchTouchEvent(me);
|
return super.dispatchTouchEvent(me);
|
||||||
|
@ -832,22 +853,22 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
final int translatedX = moreKeysPanel.translateX(x);
|
final int translatedX = moreKeysPanel.translateX(x);
|
||||||
final int translatedY = moreKeysPanel.translateY(y);
|
final int translatedY = moreKeysPanel.translateY(y);
|
||||||
|
|
||||||
if (mCheckingIfModalOrSlidingMode) {
|
if (mMoreSuggestionsMode == MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING) {
|
||||||
if (Math.abs(x - mOriginX) >= mMoreSuggestionsModalTolerance
|
if (Math.abs(x - mOriginX) >= mMoreSuggestionsModalTolerance
|
||||||
|| mOriginY - y >= mMoreSuggestionsModalTolerance) {
|
|| mOriginY - y >= mMoreSuggestionsModalTolerance) {
|
||||||
// Decided to be in the sliding input mode only when the touch point has been moved
|
// Decided to be in the sliding input mode only when the touch point has been moved
|
||||||
// upward.
|
// upward.
|
||||||
mCheckingIfModalOrSlidingMode = false;
|
mMoreSuggestionsMode = MORE_SUGGESTIONS_IN_SLIDING_MODE;
|
||||||
tracker.onShowMoreKeysPanel(
|
tracker.onShowMoreKeysPanel(
|
||||||
translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel);
|
translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel);
|
||||||
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
|
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
|
||||||
// Decided to be in the modal input mode
|
// Decided to be in the modal input mode
|
||||||
mCheckingIfModalOrSlidingMode = false;
|
mMoreSuggestionsMode = MORE_SUGGESTIONS_IN_MODAL_MODE;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process sliding motion events
|
// MORE_SUGGESTIONS_IN_SLIDING_MODE
|
||||||
tracker.processMotionEvent(action, translatedX, translatedY, eventTime, moreKeysPanel);
|
tracker.processMotionEvent(action, translatedX, translatedY, eventTime, moreKeysPanel);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue