natario1 / ZoomLayout

2D zoom and pan behavior for View hierarchies, images, video streams, and much more, written in Kotlin for Android.
https://natario1.github.io/ZoomLayout
Apache License 2.0
1.03k stars 148 forks source link

Zoom resets when in fullscreen landscape mode #191

Closed blonsky95 closed 3 years ago

blonsky95 commented 3 years ago

First of all, I am not entirely sure if the problem lies in this great repo or if within the Android framework, but I'm sure that no one is going to know it better than you guys.

I use ZoomSurfaceView to analyse video, the reason I went with this library is the ease with which I can enable zooming and panning, which was all I needed. The bug/problem I'm experimenting is that when I have my device in landscape, and with fullscreen mode enabled, notifications and status bar drag downs cause the zooming/panning to reset. This does not happen in Portrait mode, nor in the ZoomLayout or imageview in the sample app. Its only on the ZoomSurfaceView, when in landscape, and in fullscreen.

To Reproduce

You can reproduce the bug in the demo app:

To enable the fullscreen all I did is add these 3 lines of code to the ZoomSurfaceView button like so:

             buttonZoomSurface.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN);
        }
    });

Expected behavior

XML layout

Same as demo app

Screenshots

Can record my screen and put it up here if needed

Other

What annoys me is not user dragging down the status bar, its the notifications which can come at any time and cause the same reset, I only mentioned the status bar drag as it is more replicable. Imagine carefully analysing a video in slow motion with zoom but then you get a notification which triggers the zoom to reset so you need to start again, but you might keep interrupted constantly.

markusressel commented 3 years ago

Thx for the report. My first guess would be that it might be related to orientation changes (or config changes) in general, not sure what android does with the app's configuration when the notification window opens. Would definitely need some more investigation to be able to track down the cause.

blonsky95 commented 3 years ago

Ok, actually you can close this, even though I tried multiple combinations in the past few days, today I tried a new combination and it worked. Nothing to do with this library.

Just added a few "LAYOUT flags" to the visibility call. Without them some gestures cause a redraw of the layout or something, but it works like a charm now.

                 (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                // Set the content to appear under the system bars so that the
                // content doesn't resize when the system bars hide and show.
                or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                //These hide nav and status bar
                or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_FULLSCREEN)

Sorry for the inconvenience!

markusressel commented 3 years ago

No worries, glad it is working for you now 😄