Example usage for android.view MotionEvent ACTION_HOVER_EXIT

List of usage examples for android.view MotionEvent ACTION_HOVER_EXIT

Introduction

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

Prototype

int ACTION_HOVER_EXIT

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

Click Source Link

Document

Constant for #getActionMasked : The pointer is not down but has exited the boundaries of a window or view.

Usage

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 a 2 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;
        }/*from w  w w .ja va 2s  .  c o  m*/
        onTouchEvent(event);
        event.setAction(action);
    }
    super.onHoverEvent(event);
    return true;
}

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

@Override
public boolean onHoverEvent(MotionEvent ev) {
    // Same deal as onTouchEvent() above. Eat all hover events, but still
    // respect the touch event dispatch contract.

    final int action = MotionEventCompat.getActionMasked(ev);
    if (action == MotionEvent.ACTION_HOVER_ENTER) {
        mEatingHover = false;/*from   w w w  . j ava 2s .  c  o m*/
    }

    if (!mEatingHover) {
        final boolean handled = super.onHoverEvent(ev);
        if (action == MotionEvent.ACTION_HOVER_ENTER && !handled) {
            mEatingHover = true;
        }
    }

    if (action == MotionEvent.ACTION_HOVER_EXIT || action == MotionEvent.ACTION_CANCEL) {
        mEatingHover = false;
    }

    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  .  jav a2s  . com
            return inputHandler.onTouchEvent(event);
        } catch (NullPointerException e) {
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.farmerbb.taskbar.service.TaskbarService.java

private View getView(List<AppEntry> list, int position) {
    View convertView = View.inflate(this, R.layout.icon, null);

    final AppEntry entry = list.get(position);
    final SharedPreferences pref = U.getSharedPreferences(this);

    ImageView imageView = (ImageView) convertView.findViewById(R.id.icon);
    ImageView imageView2 = (ImageView) convertView.findViewById(R.id.shortcut_icon);
    imageView.setImageDrawable(entry.getIcon(this));
    imageView2.setBackgroundColor(//from   w  ww. ja  va2  s  . co m
            pref.getInt("accent_color", getResources().getInteger(R.integer.translucent_white)));

    String taskbarPosition = U.getTaskbarPosition(this);
    if (pref.getBoolean("shortcut_icon", true)) {
        boolean shouldShowShortcutIcon;
        if (taskbarPosition.contains("vertical"))
            shouldShowShortcutIcon = position >= list.size() - numOfPinnedApps;
        else
            shouldShowShortcutIcon = position < numOfPinnedApps;

        if (shouldShowShortcutIcon)
            imageView2.setVisibility(View.VISIBLE);
    }

    if (taskbarPosition.equals("bottom_right") || taskbarPosition.equals("top_right")) {
        imageView.setRotationY(180);
        imageView2.setRotationY(180);
    }

    FrameLayout layout = (FrameLayout) convertView.findViewById(R.id.entry);
    layout.setOnClickListener(view -> U.launchApp(TaskbarService.this, entry.getPackageName(),
            entry.getComponentName(), entry.getUserId(TaskbarService.this), null, true, false));

    layout.setOnLongClickListener(view -> {
        int[] location = new int[2];
        view.getLocationOnScreen(location);
        openContextMenu(entry, location);
        return true;
    });

    layout.setOnGenericMotionListener((view, motionEvent) -> {
        int action = motionEvent.getAction();

        if (action == MotionEvent.ACTION_BUTTON_PRESS
                && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
            int[] location = new int[2];
            view.getLocationOnScreen(location);
            openContextMenu(entry, location);
        }

        if (action == MotionEvent.ACTION_SCROLL && pref.getBoolean("visual_feedback", true))
            view.setBackgroundColor(0);

        return false;
    });

    if (pref.getBoolean("visual_feedback", true)) {
        layout.setOnHoverListener((v, event) -> {
            if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
                int accentColor = U.getAccentColor(TaskbarService.this);
                accentColor = ColorUtils.setAlphaComponent(accentColor, Color.alpha(accentColor) / 2);
                v.setBackgroundColor(accentColor);
            }

            if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT)
                v.setBackgroundColor(0);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
                v.setPointerIcon(PointerIcon.getSystemIcon(TaskbarService.this, PointerIcon.TYPE_DEFAULT));

            return false;
        });

        layout.setOnTouchListener((v, event) -> {
            v.setAlpha(
                    event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE
                            ? 0.5f
                            : 1);
            return false;
        });
    }

    return convertView;
}