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:com.android.inputmethod.latin.suggestions.SuggestionStripView.java

@Override
public boolean onTouchEvent(final MotionEvent me) {
    if (!mMoreSuggestionsView.isShowingInParent()) {
        // Ignore any touch event while more suggestions panel hasn't been shown.
        // Detecting sliding up is done at {@link #onInterceptTouchEvent}.
        return true;
    }//from w  ww.  jav  a 2 s  .c o m
    // 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);
    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;
}

From source file:it.mb.whatshare.Utils.java

/**
 * Returns a string that represents the symbolic name of the specified
 * action such as "ACTION_DOWN", "ACTION_POINTER_DOWN(3)" or an equivalent
 * numeric constant such as "35" if unknown. By Google.
 * /*from  w  ww . j ava2s .  c o  m*/
 * @param action
 *            The action.
 * @return The symbolic name of the specified action.
 */
public static String actionToString(int action) {
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        return "ACTION_DOWN";
    case MotionEvent.ACTION_UP:
        return "ACTION_UP";
    case MotionEvent.ACTION_CANCEL:
        return "ACTION_CANCEL";
    case MotionEvent.ACTION_OUTSIDE:
        return "ACTION_OUTSIDE";
    case MotionEvent.ACTION_MOVE:
        return "ACTION_MOVE";
    case MotionEvent.ACTION_HOVER_MOVE:
        return "ACTION_HOVER_MOVE";
    case MotionEvent.ACTION_SCROLL:
        return "ACTION_SCROLL";
    case MotionEvent.ACTION_HOVER_ENTER:
        return "ACTION_HOVER_ENTER";
    case MotionEvent.ACTION_HOVER_EXIT:
        return "ACTION_HOVER_EXIT";
    }
    int index = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
    switch (action & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_POINTER_DOWN:
        return "ACTION_POINTER_DOWN(" + index + ")";
    case MotionEvent.ACTION_POINTER_UP:
        return "ACTION_POINTER_UP(" + index + ")";
    default:
        return Integer.toString(action);
    }
}

From source file:com.hippo.widget.lockpattern.LockPatternView.java

@Override
public boolean onHoverEvent(@NonNull MotionEvent event) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.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 ww  w .  j a v  a2s  . c  om
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}

From source file:com.android.screenspeak.contextmenu.RadialMenuView.java

@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_HOVER_ENTER:
        // Fall-through to movement events.
        onEnter(event.getX(), event.getY());
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_HOVER_MOVE:
        onMove(event.getX(), event.getY());
        break;//from  w w w  .j  a  v  a2 s  . co  m
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_HOVER_EXIT:
        onUp(event.getX(), event.getY());
        break;
    default:
        // Don't handle other types of events.
        return false;
    }

    mHandler.onTouch(this, event);

    return true;
}

From source file:com.googlecode.eyesfree.widget.RadialMenuView.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_HOVER_ENTER:
        // Fall-through to movement events.
        onEnter(event.getX(), event.getY());
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_HOVER_MOVE:
        onMove(event.getX(), event.getY());
        break;//from w w  w  .ja  v a2  s . c  o m
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_HOVER_EXIT:
        onUp(event.getX(), event.getY());
        break;
    default:
        // Don't handle other types of events.
        return false;
    }

    mHandler.onTouch(this, event);

    return true;
}

From source file:com.android.nobug.view.pattern.PatternView.java

@Override
public boolean onHoverEvent(MotionEvent event) {
    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;
        }/*  w w w  .j a  v  a  2 s.  co m*/
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}

From source file:io.authme.sdk.widget.LockPatternView.java

@Override
public boolean onHoverEvent(MotionEvent event) {
    if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE))
            .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;
        }//www .j  av a2 s .c  o m
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}

From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java

@Override
public boolean onHoverEvent(MotionEvent event) {
    final AccessibilityManager accessibilityManager = (AccessibilityManager) getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.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;
        }// w  w w  .  j  a v a  2  s .c  om
        onTouchEvent(event);
        event.setAction(action);
    }
    super.onHoverEvent(event);
    return true;
}

From source file:com.iiordanov.bVNC.RemoteCanvasActivity.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    // Ignore TOOL_TYPE_FINGER events that come from the touchscreen with HOVER type action
    // which cause pointer jumping trouble in simulated touchpad for some devices.
    int a = event.getAction();
    if (!((a == MotionEvent.ACTION_HOVER_ENTER || a == MotionEvent.ACTION_HOVER_EXIT
            || a == MotionEvent.ACTION_HOVER_MOVE) && event.getSource() == InputDevice.SOURCE_TOUCHSCREEN
            && event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER)) {
        try {//from  ww w .  j  a  v  a 2s.  co  m
            return inputHandler.onTouchEvent(event);
        } catch (NullPointerException e) {
        }
    }
    return super.onGenericMotionEvent(event);
}