Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable vibration when visibility is toggled #4

Open
hardysim opened this issue Apr 1, 2016 · 3 comments
Open

Option to disable vibration when visibility is toggled #4

hardysim opened this issue Apr 1, 2016 · 3 comments

Comments

@hardysim
Copy link

hardysim commented Apr 1, 2016

It appears that the device does a short vibration when the visibility is changed (and the cursor jumps to the end).

Can we get an option to disable this "feature"?
It seems handy to indicate that a password-field got visible but it would be good to decide ourselves.

PS: Why is it vibrating in the first place? I cannot identify the piece of code doing it.
PPS: Using Android N Preview 2

@hardysim
Copy link
Author

hardysim commented Apr 1, 2016

I just saw #3 - seems related :-)

@marcouberti
Copy link

The piece of code that generates the vibration is this one:

@Override 
public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_UP
                && event.getX() >= (getRight() - getCompoundDrawables()[2].getBounds().width())) {
            visible = !visible;
            setup();
            invalidate();
            return true; // <---- REMOVE THIS TO REMOVE VIBRATION
        }

        return super.onTouchEvent(event);
}

I removed the return true; line and now there is no more vibration.
Hope this help.

@lisawray
Copy link
Owner

It's caused by a click on the TextView. By handling only MotionEvent.UP, I was allowing the TextView to handle MotionEvent.DOWN, etc as usual and its default behavior is to vibrate. I'm going to investigate more to be sure it's gone, but I'm no longer seeing it:

#17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants