I am creating my first Android app using this guide as a reference. Currently, I have a red button on my canvas and when the user clicks the button a boolean (green) will be set to true in order for the button's bitmap to a green button.
That part of the application works, however it works regardless where the user clicks on the canvas. I only want the boolean to be changed when the user clicks on the button's bitmap. Here is what I currently have in my code:
The onTouchEvent() method
    @Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        button.handleActionDown((int)event.getX(), (int)event.getY());
        if (button.isTouched()) {
            green = true;
        }
    } if (event.getAction() == MotionEvent.ACTION_MOVE) {
    } if (event.getAction() == MotionEvent.ACTION_UP) {
        if (button.isTouched()) {
            green = false;
            button.setTouched(false);
        }
    }
    return true;
}
The handleActionDown() Method
    public void handleActionDown(int eventX, int eventY) {
    if (eventX >= (x - bitmap.getWidth() / 2) && (eventX <= (x + bitmap.getWidth()/2))) {
        if (eventY >= (y - bitmap.getHeight() / 2) && (eventY <= (y + bitmap.getHeight()/2))) {
            setTouched(true);
        } else {
            setTouched(false);
        }
    } else {
        setTouched(false);
    }
}
Can anybody see what I am missing in order for the ACTION_DOWN event to make it so it only triggers when the bitmap's bitmap is touched?
Regards