Example usage for android.view MotionEvent ACTION_HOVER_MOVE

List of usage examples for android.view MotionEvent ACTION_HOVER_MOVE

Introduction

In this page you can find the example usage for android.view MotionEvent ACTION_HOVER_MOVE.

Prototype

int ACTION_HOVER_MOVE

To view the source code for android.view MotionEvent ACTION_HOVER_MOVE.

Click Source Link

Document

Constant for #getActionMasked : A change happened but the pointer is not down (unlike #ACTION_MOVE ).

Usage

From source file:Main.java

/**
 * Returns {@true} if the provided event is a touch exploration (e.g. hover)
 * event. This is used to determine whether the event should be processed by
 * the touch exploration code within the keyboard.
 *
 * @param event The event to check./*w  w w . j  a  v a  2  s.  c o m*/
 * @return {@true} is the event is a touch exploration event
 */
public static boolean isTouchExplorationEvent(final MotionEvent event) {
    final int action = event.getAction();
    return action == MotionEvent.ACTION_HOVER_ENTER || action == MotionEvent.ACTION_HOVER_EXIT
            || action == MotionEvent.ACTION_HOVER_MOVE;
}

From source file:Main.java

public static String getMotionEventString(int action) {
    switch (action) {
    case (MotionEvent.ACTION_DOWN):
        return "action_down";
    case (MotionEvent.ACTION_UP):
        return "action_down";
    case (MotionEvent.ACTION_CANCEL):
        return "action_down";
    case (MotionEvent.ACTION_MOVE):
        return "action_move";
    case (MotionEvent.ACTION_OUTSIDE):
        return "action_outside";
    case (MotionEvent.ACTION_HOVER_ENTER):
        return "action_hover_enter";
    case (MotionEvent.ACTION_HOVER_EXIT):
        return "action_hover_exit";
    case (MotionEvent.ACTION_HOVER_MOVE):
        return "action_hover_move";
    case (MotionEvent.ACTION_MASK):
        return "action_mask";
    }/*from  w  w  w . ja v a2s .  com*/
    return "unknown action event";
}

From source file:Main.java

/**
 * Gets the name of an action.//w  w  w .java  2  s.com
 * 
 * @param action        The action being performed.
 * @param isMotionEvent Whether or not the action is a motion event.
 * 
 * @return The name of the action being performed.
 */
public static String getActionName(int action, boolean isMotionEvent) {
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        return "DOWN";
    case MotionEvent.ACTION_UP:
        return "UP";
    case MotionEvent.ACTION_MOVE:
        return isMotionEvent ? "MOVE" : "MULTIPLE";
    case MotionEvent.ACTION_CANCEL:
        return "CANCEL";
    case MotionEvent.ACTION_OUTSIDE:
        return "OUTSIDE";
    case MotionEvent.ACTION_POINTER_DOWN:
        return "POINTER_DOWN";
    case MotionEvent.ACTION_POINTER_UP:
        return "POINTER_UP";
    case MotionEvent.ACTION_HOVER_MOVE:
        return "HOVER_MOVE";
    case MotionEvent.ACTION_SCROLL:
        return "SCROLL";
    case MotionEvent.ACTION_HOVER_ENTER:
        return "HOVER_ENTER";
    case MotionEvent.ACTION_HOVER_EXIT:
        return "HOVER_EXIT";
    default:
        return "ACTION_" + Integer.toString(action);
    }
}

From source file:android.support.v7.widget.TooltipCompatHandler.java

@Override
public boolean onHover(View v, MotionEvent event) {
    if (mPopup != null && mFromTouch) {
        return false;
    }// ww  w  .  ja v a2 s  . c  om
    AccessibilityManager manager = (AccessibilityManager) mAnchor.getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (manager.isEnabled() && manager.isTouchExplorationEnabled()) {
        return false;
    }
    switch (event.getAction()) {
    case MotionEvent.ACTION_HOVER_MOVE:
        if (mAnchor.isEnabled() && mPopup == null) {
            mAnchorX = (int) event.getX();
            mAnchorY = (int) event.getY();
            setPendingHandler(this);
        }
        break;
    case MotionEvent.ACTION_HOVER_EXIT:
        hide();
        break;
    }

    return false;
}

From source file:com.android.hareime.accessibility.AccessibleKeyboardViewProxy.java

/**
 * Receives hover events when accessibility is turned on in SDK versions ICS
 * and higher./*  w  w  w.  j a va  2  s .c  om*/
 *
 * @param event The hover event.
 * @return {@code true} if the event is handled
 */
public boolean dispatchHoverEvent(MotionEvent event, PointerTracker tracker) {
    final int x = (int) event.getX();
    final int y = (int) event.getY();
    final Key key = tracker.getKeyOn(x, y);
    final Key previousKey = mLastHoverKey;

    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 (pointInView(x, y) && (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);
        } else {
            return onHoverKey(key, event);
        }
    }

    return false;
}

From source file:com.onyx.latinime.accessibility.AccessibilityUtils.java

/**
 * Returns {@true} if the provided event is a touch exploration (e.g. hover)
 * event. This is used to determine whether the event should be processed by
 * the touch exploration code within the keyboard.
 *
 * @param event The event to check./*from www.  j  av a  2  s .  c  o  m*/
 * @return {@true} is the event is a touch exploration event
 */
public boolean isTouchExplorationEvent(final MotionEvent event) {
    final int action = event.getAction();
    return action == MotionEvent.ACTION_HOVER_ENTER || action == MotionEvent.ACTION_HOVER_EXIT
            || action == MotionEvent.ACTION_HOVER_MOVE;
}

From source file:com.android.utils.ExploreByTouchHelper.java

/**
 * Dispatches hover {@link MotionEvent}s to the virtual view hierarchy when
 * the Explore by Touch feature is enabled.
 * <p>//from w w  w.  jav  a 2  s .  co  m
 * This method should be called by overriding
 * {@link View#dispatchHoverEvent}:
 *
 * <pre>
 * &#64;Override
 * public boolean dispatchHoverEvent(MotionEvent event) {
 *   if (mHelper.dispatchHoverEvent(this, event) {
 *     return true;
 *   }
 *   return super.dispatchHoverEvent(event);
 * }
 * </pre>
 *
 * @param event The hover event to dispatch to the virtual view hierarchy.
 * @return Whether the hover event was handled.
 */
public boolean dispatchHoverEvent(MotionEvent event) {
    if (!mManager.isTouchExplorationEnabled()) {
        return false;
    }

    int virtualViewId = getVirtualViewIdAt(event.getX(), event.getY());
    if (virtualViewId == INVALID_ID) {
        virtualViewId = ROOT_ID;
    }

    switch (event.getAction()) {
    case MotionEvent.ACTION_HOVER_ENTER:
    case MotionEvent.ACTION_HOVER_MOVE:
        setHoveredVirtualViewId(virtualViewId);
        break;
    case MotionEvent.ACTION_HOVER_EXIT:
        setHoveredVirtualViewId(virtualViewId);
        break;
    }

    return true;
}

From source file:com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy.java

/**
 * Receives hover events when touch exploration is turned on in SDK versions
 * ICS and higher./*from w  w w . j a v a2  s .co m*/
 *
 * @param event The hover event.
 * @return {@code true} if the event is handled
 */
public boolean dispatchHoverEvent(MotionEvent event, PointerTracker tracker) {
    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);
        } else {
            return onHoverKey(key, event);
        }
    }

    return false;
}

From source file:com.android.inputmethod.accessibility.KeyboardAccessibilityDelegate.java

/**
 * Receives hover events when touch exploration is turned on in SDK versions ICS and higher.
 *
 * @param event The hover event./*from  w w w. j  a v a2  s .  c o  m*/
 * @return {@code true} if the event is handled.
 */
public boolean onHoverEvent(final MotionEvent event) {
    switch (event.getActionMasked()) {
    case MotionEvent.ACTION_HOVER_ENTER:
        onHoverEnter(event);
        break;
    case MotionEvent.ACTION_HOVER_MOVE:
        onHoverMove(event);
        break;
    case MotionEvent.ACTION_HOVER_EXIT:
        onHoverExit(event);
        break;
    default:
        Log.w(getClass().getSimpleName(), "Unknown hover event: " + event);
        break;
    }
    return true;
}

From source file:com.android.hareime.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.//from  w w w  .j  a va  2 s . c  o m
 *
 * @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.
 */
private boolean onTransitionKey(Key currentKey, Key previousKey, 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;
}