android-target-tooltip icon indicating copy to clipboard operation
android-target-tooltip copied to clipboard

Close Policy Documentation

Open stripathi669 opened this issue 9 years ago • 6 comments

A documentation on how close policy works is required. Where may I find it? Especially, I want to know what does the consume boolean means and does?

stripathi669 avatar May 29 '16 19:05 stripathi669

@stripathi669 I now this is reaaaally old, but well.. for future readers.

I was diving on the code and the fast documentation is on this code:

        override fun onTouchEvent(event: MotionEvent): Boolean {
            if (!isShowing || !isVisible || !mActivated) return false

            Timber.i("onTouchEvent: $event")
            Timber.d("event position: ${event.x}, ${event.y}")

            val r1 = Rect()
            mTextView.getGlobalVisibleRect(r1)
            val containsTouch = r1.contains(event.x.toInt(), event.y.toInt())

            if (mClosePolicy.anywhere()) {
                hide()
            } else if (mClosePolicy.inside() && containsTouch) {
                hide()
            } else if (mClosePolicy.outside() && !containsTouch) {
                hide()
            }

            return mClosePolicy.consume()
}

INSIDE => hides when clicked INSIDE the tooltip
OUTSIDE => hides when clicked OUTSIDE the tooltip
CONSUME=> Consume the click on the view, so no click is propagated to the rest of the view.
This has some weird behaviour, because if you set to
False -> when clicking will pass the touches too on the below views
True -> when you try to touch or do a gesture this will not act to your touches

So ANYWARE_CONSUME => hide on any touch and no elements below will be touched
INSIDE_NO_CONSUME => hide on click inside BUT the elements below will be clicked too (TOO WEIRD!)
and so on.

Hope this helps

Sulfkain avatar Feb 28 '19 15:02 Sulfkain

@sephiroth74 If it's ok, I could add this to the wiki section

Sulfkain avatar Feb 28 '19 16:02 Sulfkain

Added to wiki

whoyawn avatar Jul 01 '19 23:07 whoyawn

@whoyawn Could you please paste the link to the doc, because I cannot find it on the wiki space https://github.com/sephiroth74/android-target-tooltip/wiki

Thanks!

Sulfkain avatar Jul 02 '19 07:07 Sulfkain

https://github.com/sephiroth74/android-target-tooltip/wiki/Close-Policy-Documentation

whoyawn avatar Jul 17 '19 07:07 whoyawn

Hello @whoyawn. Ok, Thanks! But don't you think we should update too the main wiki page?, but the users will not found this wiki documentation you created.

I have add the link on main wiki https://github.com/sephiroth74/android-target-tooltip/wiki

I have edited the policy documentation too to explianed better, this could be even better if the explanation will be on a JavaDoc on code. Sorry but I don't have the time right now to make a PR about it.

Sulfkain avatar Jul 17 '19 07:07 Sulfkain