Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ChatHead is limiting the touch to itself only, BUT I need support second finger simultaenously second touching the area outside the chathead,

Tags:

android

http://www.piwai.info/chatheads-basics/ By following this good guide, I can make a chathead and also detect the touch event.
However, if I touch the chathead with first finger, and try to touch other area (outside) the chathead with second finger, the second touch is not possible.
(The area outside can be the home screen, or another app, activity)
Similarly, IF I first touch the outside, and try to use second finger to touch the chathead, it is not possible.
I tried the similar interaction with facebook messenger chathead and it is the same.

My question is: is it possible to support the second touch?
maybe using dispatch touch event? but afaik dispatch is only for activity.
the chathead uses service and window.

Any help would be deeply appreciated!

like image 810
tcboy88 Avatar asked Sep 05 '15 16:09

tcboy88


People also ask

How do I turn off floating in Messenger?

From Chats, tap your profile picture in the top left. Scroll down and tap Bubbles. Tap All conversations can bubble or Selected conversations can bubble. To turn off this feature, select Nothing can bubble.

What is a floating chat?

In Android, Floating bubbles or ChatHeads allow quick access to core features without fully opening the app.


2 Answers

Yes its possible using the following workaround.

  • Have a transparent layout surrounding your chathead.
  • This transparent layout will intercept the touch and you can do the necessary handling.
  • You can then pass this touch event up the hierarchy/other apps by returning false from OnTouchEvent().

To let the other apps handle touch event,the transparent view can only be activated when the user is already touching your chathead.This way you cna make sure that the user is planning to do some gesture with your chathead.

like image 107
rupesh jain Avatar answered Oct 18 '22 12:10

rupesh jain


This isn't possible using layouts manually added to the WindowManager as a system overlay when the underlying view is from a completely different hierarchy.

Once you start a touch event on the first view, all subsequent touch events will be sent to the same view heirarchy until ALL MotionEvents are finished (I.e ACTION_UP or ACTION_CANCEL has occurred).

Basically, once you are interacting with one view heirarchy, any outside touches are interpreted as touches outside the current heirarchy, and ignore any underlying view heirarchies which may or may not occupy the same screen position.

like image 35
Kane O'Riley Avatar answered Oct 18 '22 13:10

Kane O'Riley