sephiroth74 / android-target-tooltip

Create Toast like tooltips, but targets can be specified, plus custom properties and features
MIT License
1.49k stars 278 forks source link

Consume weird behaviour #125

Open Sulfkain opened 5 years ago

Sulfkain commented 5 years ago

Hello, great Lib! But the ClosePolicy is some strange. I set: inside(true) outside(false) consume(false)

So only the tooltip hides when clicked inside, I can touch on any other place of the window and the tooltip still there. When I click on the tooltip, it hides BUT it touch too on the element below. If i set the consume to TRUE, no touch are allowed outside.

Will be great to get that behaviour, which for me seems the default, not the actual. I'm wondering that ever you set to true on INSIDE will consume the touch. It usefull to no consume a touch when you click inside the tip?

Will be great if we discuss the right way to get it, and i can work on a PR.

sephiroth74 commented 5 years ago

I don't think there's a default behavior which will work for everyone, that's why you have the chance to define what the behavior should be.

Sulfkain commented 5 years ago

The problem is, i could not define that behaviour, because CONSUME is true/false in both cases, but not on one or another Consume true/false inside and outside always, not true on inside but no consume outside, etc.

That's the problem

Will be great if we can customize where will consume on both parts. But If this is too harsh to the numbers of options, I think when you select INSIDE or OUTSIDE or both, the consume true will be linked with that. INSIDE then consume on inside but not on outside OUTSIDE then consume on outside but not on outside EVERYWHERE then consume on boths

sephiroth74 commented 5 years ago

so basically there should be something like:

ClosePolicy.Builder()
    .inside(touch, consume)
    .outside(touch, consume)
    .build()
Sulfkain commented 5 years ago

Yes! :) That would be perfect.

If you need some help i could create a PR with that.

But i have not too much time so will be launched in some time, sorry

sephiroth74 commented 5 years ago

Understood. I can see what I can do

Sulfkain commented 5 years ago

To just be sure, on that code

ClosePolicy.Builder() .inside(touch, consume) .outside(touch, consume) .build()

consume should be 2 differents variables, one for inside, one for outside. I think that what you understand, it have not sense to pass a consume on each place then, because will be the same as now

Thank you Alessandro

sephiroth74 commented 5 years ago

Not sure this is the best solution: https://github.com/sephiroth74/android-target-tooltip/commit/e59315a8bf298dd1309829377945035b9964c01d

The problem is that the if the popup layoutparams has the flag WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE it's not possible to consume the touch at runtime (it will be always sent to the decor), on the other hand, without that flag, the touch event will be always consumed... that's why in first place I used a single flag for consume (instead of inside/outside)

Sulfkain commented 5 years ago

I miss the part where if not set the flag WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE the view will consume the touch.

I see you set a FrameLayout and there you have a touchListener. Could be maybe that method is the responsible to consume the touch that you talk?

Because it's weird the view consume the touch, surelly there is some method (no idea where) it consume it

If you create a nigth version of this modifications I can test on my devices and in my project

Thanks for this work :)

sephiroth74 commented 5 years ago

Let me try. in the meantime you can use: https://jitpack.io/#sephiroth74/android-target-tooltip/e59315a8bf

Sulfkain commented 5 years ago

Sorry for late response, but I was busy on other stuff.

I have tested that version I set val closePolicy = ClosePolicy.Builder().inside(true, true).outside(false, true).build()

But what happens is as you told, when touching outside, not consume but neither the touch is propagated to below views, so only when touching inside the tip, the view response.

Have you check something about the touch listener? or something related? Can I help you on that task?

Thanks :)