List of usage examples for android.view MotionEvent ACTION_HOVER_ENTER
int ACTION_HOVER_ENTER
To view the source code for android.view MotionEvent ACTION_HOVER_ENTER.
Click Source Link
From source file:hide.com.googlecode.eyesfree.utils.TouchExplorationHelper.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public boolean onHover(View view, MotionEvent event) { if (!mManager.isTouchExplorationEnabled()) { return false; }//from w w w. j a va 2 s . co m switch (event.getAction()) { case MotionEvent.ACTION_HOVER_ENTER: case MotionEvent.ACTION_HOVER_MOVE: final T item = getItemAt(event.getX(), event.getY()); setCurrentItem(item); return true; case MotionEvent.ACTION_HOVER_EXIT: setCurrentItem(null); return true; } return false; }
From source file:com.android.hareime.accessibility.AccessibleKeyboardViewProxy.java
/** * Handles a hover event on a key. If {@link Key} extended View, this would * be analogous to calling View.onHoverEvent(MotionEvent). * * @param key The currently hovered key. * @param event The hover event.// ww w . jav a 2 s .com * @return {@code true} if the event was handled. */ private boolean onHoverKey(Key key, MotionEvent event) { // Null keys can't receive events. if (key == null) { return false; } final AccessibilityEntityProvider provider = getAccessibilityNodeProvider(); switch (event.getAction()) { case MotionEvent.ACTION_HOVER_ENTER: provider.sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER); provider.performActionForKey(key, AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS, null); break; case MotionEvent.ACTION_HOVER_EXIT: provider.sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_EXIT); break; } return true; }
From source file:com.deange.datetimepicker.TouchExplorationHelper.java
@Override public boolean onHover(View view, MotionEvent event) { if (!mManager.isTouchExplorationEnabled()) { return false; }/*w w w . ja va 2s. c o m*/ switch (event.getAction()) { case MotionEvent.ACTION_HOVER_ENTER: case MotionEvent.ACTION_HOVER_MOVE: final T item = getItemAt(event.getX(), event.getY()); setCurrentItem(item); return true; case MotionEvent.ACTION_HOVER_EXIT: setCurrentItem(null); return true; } return false; }
From source file:org.holoeverywhere.widget.datetimepicker.TouchExplorationHelper.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public View.OnHoverListener getOnHoverListener() { if (mOnHoverListener == null) { mOnHoverListener = new View.OnHoverListener() { @Override/*from w ww.ja v a2 s .c om*/ public boolean onHover(View view, MotionEvent event) { if (!mManager.isTouchExplorationEnabled()) { return false; } switch (event.getAction()) { case MotionEvent.ACTION_HOVER_ENTER: case MotionEvent.ACTION_HOVER_MOVE: final T item = getItemAt(event.getX(), event.getY()); setCurrentItem(item); return true; case MotionEvent.ACTION_HOVER_EXIT: setCurrentItem(null); return true; } return false; } }; } return (View.OnHoverListener) mOnHoverListener; }
From source file:com.commonsware.android.kbmouse.hotkeys.MainActivity.java
private void onHover(MotionEvent event, @StringRes final int message, final View anchor) { Runnable hover = hoverTimers.get(anchor.getId()); if (hover == null && (event.getAction() == MotionEvent.ACTION_HOVER_ENTER || event.getAction() == MotionEvent.ACTION_HOVER_MOVE)) { hover = new Runnable() { @Override/* w w w . j a v a 2 s .c o m*/ public void run() { showTooltip(message); } }; hoverTimers.put(anchor.getId(), hover); thumbnailLarge.postDelayed(hover, TOOLTIP_DELAY); } else if (hover != null && event.getAction() == MotionEvent.ACTION_HOVER_EXIT) { thumbnailLarge.removeCallbacks(hover); hoverTimers.remove(anchor.getId()); } }
From source file:com.onyx.latinime.accessibility.AccessibleKeyboardViewProxy.java
/** * Receives hover events when touch exploration is turned on in SDK versions ICS and higher. * * @param event The hover event./*from w ww . ja va2 s . co m*/ * @return {@code true} if the event is handled */ public boolean dispatchHoverEvent(final MotionEvent event, final PointerTracker tracker) { if (mView == null) { return false; } final int x = (int) event.getX(); final int y = (int) event.getY(); final Key previousKey = mLastHoverKey; final Key key; if (pointInView(x, y)) { key = tracker.getKeyOn(x, y); } else { key = null; } mLastHoverKey = key; switch (event.getAction()) { case MotionEvent.ACTION_HOVER_EXIT: // Make sure we're not getting an EXIT event because the user slid // off the keyboard area, then force a key press. if (key != null) { getAccessibilityNodeProvider().simulateKeyPress(key); } //$FALL-THROUGH$ case MotionEvent.ACTION_HOVER_ENTER: return onHoverKey(key, event); case MotionEvent.ACTION_HOVER_MOVE: if (key != previousKey) { return onTransitionKey(key, previousKey, event); } return onHoverKey(key, event); } return false; }
From source file:com.onyx.latinime.accessibility.AccessibleKeyboardViewProxy.java
/** * Simulates a transition between two {@link Key}s by sending a HOVER_EXIT on the previous key, * a HOVER_ENTER on the current key, and a HOVER_MOVE on the current key. * * @param currentKey The currently hovered key. * @param previousKey The previously hovered key. * @param event The event that triggered the transition. * @return {@code true} if the event was handled. *///from w ww . j av a2 s.co m private boolean onTransitionKey(final Key currentKey, final Key previousKey, final MotionEvent event) { final int savedAction = event.getAction(); event.setAction(MotionEvent.ACTION_HOVER_EXIT); onHoverKey(previousKey, event); event.setAction(MotionEvent.ACTION_HOVER_ENTER); onHoverKey(currentKey, event); event.setAction(MotionEvent.ACTION_HOVER_MOVE); final boolean handled = onHoverKey(currentKey, event); event.setAction(savedAction); return handled; }
From source file:com.rexmtorres.android.patternlock.PatternLockView.java
@Override public boolean onHoverEvent(MotionEvent event) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if (mAccessibilityManager.isTouchExplorationEnabled()) { final int action = event.getAction(); switch (action) { case MotionEvent.ACTION_HOVER_ENTER: event.setAction(MotionEvent.ACTION_DOWN); break; case MotionEvent.ACTION_HOVER_MOVE: event.setAction(MotionEvent.ACTION_MOVE); break; case MotionEvent.ACTION_HOVER_EXIT: event.setAction(MotionEvent.ACTION_UP); break; }/*from w w w . ja v a2 s .c om*/ onTouchEvent(event); event.setAction(action); } } return super.onHoverEvent(event); }
From source file:com.onyx.latinime.accessibility.AccessibleKeyboardViewProxy.java
/** * Handles a hover event on a key. If {@link Key} extended View, this would be analogous to * calling View.onHoverEvent(MotionEvent). * * @param key The currently hovered key. * @param event The hover event.//w ww . ja v a2 s . c o m * @return {@code true} if the event was handled. */ private boolean onHoverKey(final Key key, final MotionEvent event) { // Null keys can't receive events. if (key == null) { return false; } final AccessibilityEntityProvider provider = getAccessibilityNodeProvider(); switch (event.getAction()) { case MotionEvent.ACTION_HOVER_ENTER: provider.sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER); provider.performActionForKey(key, AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS, null); break; case MotionEvent.ACTION_HOVER_EXIT: provider.sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_EXIT); break; } return true; }
From source file:com.github.crvv.wubinput.wubi.dictionary.suggestions.SuggestionStripView.java
@Override public boolean onTouchEvent(final MotionEvent me) { // In the sliding input mode. {@link MotionEvent} should be forwarded to // {@link MoreSuggestionsView}. final int index = me.getActionIndex(); final int x = mMoreSuggestionsView.translateX((int) me.getX(index)); final int y = mMoreSuggestionsView.translateY((int) me.getY(index)); me.setLocation(x, y);//from w w w. jav a 2 s . c o m 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; }