am 2505462d: am f4a3fd48: Merge "Disptach hover events when sliding suggestion mode" into lmp-dev
* commit '2505462da586cb708af5219e4c996644613f7677': Disptach hover events when sliding suggestion modemain
commit
17efa4fd5d
|
@ -38,6 +38,7 @@ import android.widget.ImageButton;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.MainKeyboardView;
|
import com.android.inputmethod.keyboard.MainKeyboardView;
|
||||||
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
||||||
|
@ -368,13 +369,15 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Working variables for {@link #onLongClick(View)} and
|
// Working variables for {@link onInterceptTouchEvent(MotionEvent)} and
|
||||||
// {@link onInterceptTouchEvent(MotionEvent)}.
|
// {@link onTouchEvent(MotionEvent)}.
|
||||||
private int mLastX;
|
private int mLastX;
|
||||||
private int mLastY;
|
private int mLastY;
|
||||||
private int mOriginX;
|
private int mOriginX;
|
||||||
private int mOriginY;
|
private int mOriginY;
|
||||||
private final int mMoreSuggestionsModalTolerance;
|
private final int mMoreSuggestionsModalTolerance;
|
||||||
|
private boolean mNeedsToTransformTouchEventToHoverEvent;
|
||||||
|
private boolean mIsDispatchingHoverEventToMoreSuggestions;
|
||||||
private final GestureDetector mMoreSuggestionsSlidingDetector;
|
private final GestureDetector mMoreSuggestionsSlidingDetector;
|
||||||
private final GestureDetector.OnGestureListener mMoreSuggestionsSlidingListener =
|
private final GestureDetector.OnGestureListener mMoreSuggestionsSlidingListener =
|
||||||
new GestureDetector.SimpleOnGestureListener() {
|
new GestureDetector.SimpleOnGestureListener() {
|
||||||
|
@ -402,9 +405,12 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
final int y = (int)me.getY(index);
|
final int y = (int)me.getY(index);
|
||||||
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 suggestion mode only when the touch point has been moved
|
||||||
// upward. Further {@link MotionEvent}s will be delivered to
|
// upward. Further {@link MotionEvent}s will be delivered to
|
||||||
// {@link #onTouchEvent(MotionEvent)}.
|
// {@link #onTouchEvent(MotionEvent)}.
|
||||||
|
mNeedsToTransformTouchEventToHoverEvent = AccessibilityUtils.getInstance()
|
||||||
|
.isTouchExplorationEnabled();
|
||||||
|
mIsDispatchingHoverEventToMoreSuggestions = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,10 +432,41 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
// In the sliding input mode. {@link MotionEvent} should be forwarded to
|
// In the sliding input mode. {@link MotionEvent} should be forwarded to
|
||||||
// {@link MoreSuggestionsView}.
|
// {@link MoreSuggestionsView}.
|
||||||
final int index = me.getActionIndex();
|
final int index = me.getActionIndex();
|
||||||
final int x = (int)me.getX(index);
|
final int x = mMoreSuggestionsView.translateX((int)me.getX(index));
|
||||||
final int y = (int)me.getY(index);
|
final int y = mMoreSuggestionsView.translateY((int)me.getY(index));
|
||||||
me.setLocation(mMoreSuggestionsView.translateX(x), mMoreSuggestionsView.translateY(y));
|
me.setLocation(x, y);
|
||||||
mMoreSuggestionsView.onTouchEvent(me);
|
if (!mNeedsToTransformTouchEventToHoverEvent) {
|
||||||
|
mMoreSuggestionsView.onTouchEvent(me);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// In sliding suggestion mode with accessibility mode on, a touch event should be
|
||||||
|
// transformed to a hover event.
|
||||||
|
final int width = mMoreSuggestionsView.getWidth();
|
||||||
|
final int height = mMoreSuggestionsView.getHeight();
|
||||||
|
final boolean onMoreSuggestions = (x >= 0 && x < width && y >= 0 && y < height);
|
||||||
|
if (!onMoreSuggestions && !mIsDispatchingHoverEventToMoreSuggestions) {
|
||||||
|
// Just drop this touch event because dispatching hover event isn't started yet and
|
||||||
|
// the touch event isn't on {@link MoreSuggestionsView}.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final int hoverAction;
|
||||||
|
if (onMoreSuggestions && !mIsDispatchingHoverEventToMoreSuggestions) {
|
||||||
|
// Transform this touch event to a hover enter event and start dispatching a hover
|
||||||
|
// event to {@link MoreSuggestionsView}.
|
||||||
|
mIsDispatchingHoverEventToMoreSuggestions = true;
|
||||||
|
hoverAction = MotionEvent.ACTION_HOVER_ENTER;
|
||||||
|
} else if (me.getActionMasked() == MotionEvent.ACTION_UP) {
|
||||||
|
// Transform this touch event to a hover exit event and stop dispatching a hover event
|
||||||
|
// after this.
|
||||||
|
mIsDispatchingHoverEventToMoreSuggestions = false;
|
||||||
|
mNeedsToTransformTouchEventToHoverEvent = false;
|
||||||
|
hoverAction = MotionEvent.ACTION_HOVER_EXIT;
|
||||||
|
} else {
|
||||||
|
// Transform this touch event to a hover move event.
|
||||||
|
hoverAction = MotionEvent.ACTION_HOVER_MOVE;
|
||||||
|
}
|
||||||
|
me.setAction(hoverAction);
|
||||||
|
mMoreSuggestionsView.onHoverEvent(me);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue