Detecting when the system ui is visible with sticky immersive mode
Asked Answered
E

0

7

When using sticky immersive mode (https://developer.android.com/training/system-ui/immersive.html) neither the View.OnSystemUiVisibilityChangeListener is called nor will any visibility flags be cleared (like View.SYSTEM_UI_FLAG_HIDE_NAVIGATION):

Sticky flag—This is the UI you see if you use the IMMERSIVE_STICKY flag, and the user swipes to display the system bars. Semi-transparent bars temporarily appear and then hide again. The act of swiping doesn't clear any flags, nor does it trigger your system UI visibility change listeners, because the transient appearance of the system bars isn't considered a UI visibility change.

I have a view with complex gesture detection code. The down swipe to show the system navigation ui does interfere with these gestures. If I use the regular immersive mode I can check for the system navigation ui to be visible in which case I ignore the gestures but with the sticky mode that check is not possible (as explained above).

Does anyone know how to determine if the system navigation ui is visible in sticky immersive mode or does anyone have another idea how to deal with the down swipe that interferes with my own gesture detection code?

I'm aware of this question Detecting when system buttons are visible while using 'immersive mode' but I've seen apps that use sticky immersive mode with gesture detection that don't get messed up by the down swipe.

Evade answered 25/9, 2014 at 18:20 Comment(4)
I'm using a simple onTouchListener on my rootView and that gives me all the correct motionEvents. Can you describe what you try to achieve or how it interferes with your code?Tion
I use a combination of my own motion detector code in a simple onTouchEvent() method and a GestureDetector to detect single taps, double taps and long presses. When I swipe down to show the system ui elements I receive an MotionEvent.ACTION_DOWN, some ACTION_MOVE and finally an ACTION_UP event which of course will be interpreted as gestures by the view but are really just a down swipe due to the immersive mode.Evade
I would expect Android to intercept all touch events once it has determined it's a down swipe to show the system ui (e.g. by using onInterceptTouchEvent) but that doesn't seem to be the case. In non-sticky mode I can just ignore the touch events since I know when the system ui is visible but in sticky mode there's no such way.Evade
I just came around this issue as well and I find it a pity that there is no way to detect it. I really had hoped that there was some way.Hysterectomy

© 2022 - 2024 — McMap. All rights reserved.