MrStahlfelge / lightblocks

Falling Lightblocks. Falling block game for Android (Mobile and TV), iOS, Web browsers. Works on desktops, too.
https://www.golfgl.de/lightblocks/
Other
140 stars 15 forks source link

Android version gesture navigation landscape issue #30

Closed JohnLunzer closed 3 years ago

JohnLunzer commented 3 years ago

I just switched my phone to a Pixel 5 which uses Android 11's "navigation gestures" instead of a home and back buttons. This option is represented as a long "pill" (it's just a long visible line) right at the bottom of the screen. When you swipe up from the bottom of the screen it goes home.

When I'm playing, in particular in landscape mode, this behavior constantly interferes with my input to the game. I'm honestly not sure if there is a solution. Because I'd like the home gesture disabled but the back gesture is needed to pause the game and go back through there menus. The issue is bad it enough that the game isn't really playable competitively anymore for me, I've been playing and supporting for a few years now on Android.

JohnLunzer commented 3 years ago

https://developer.android.com/training/gestures/gesturenav

Apparently Google leaves this behavior up to app developers and the above site indicates the different behaviors you can set.

JohnLunzer commented 3 years ago

I also found this API reference page which I believe is related, https://developer.android.com/reference/android/view/WindowInsetsController

Anyway, I hope this is enough leg work to make a fix not too much work.

MrStahlfelge commented 3 years ago

I don't have a Pixel to test with, please help me understand what exactly is the problem. I can see a problem with doing pause, but what is the problem when playing the game?

Lightblocks does not set immersive mode because it is intended to show the navigation buttons (for normal system buttons). Additionally, there were problems with rotation when I tested using immersive mode. It also already respects window insets, this is needed for display cutouts. The only thing not done so far is View.setSystemGestureExclusionRects(). As far as I understand, this will deactivate navigation gestures. Would that help?

JohnLunzer commented 3 years ago

Luckily my screenshots shows something of my dilemma on the pixel 5.

Below I show landscape mode with both rotations.

On the pixel 5 there is a cutout for the selfie camera and Android 11 chops the left or right side of the screen in some applications, indicated by the blue arrow. This isn't a huge issue.

The main issue is indicated by the red arrow. You'll see there is a narrow black strip at the bottom of the screen, in the middle of that strip you'll see a small grey line. The black strip and grey line are a visual indication of the gesture navigation functionally. Behaviorally because some of my controls are near the bottom of the screen the navigation gestures will trigger while playing.

An option to fully deactivate navigation gestures would likely fix the issue, though if you did this you would need to add a "back" button to the on screen controls otherwise I think there would be no way to get out of a game except turning the screen off and back on which pauses the game. To me this seems like a reasonable compromise, but you may feel differently.

I'm willing to test out anything keeping in mind I get my falling light blocks through the play store.

If you need any other additional information please let me know.

Screenshot_20210425-104306 Screenshot_20210425-104426

MrStahlfelge commented 3 years ago

I was able to get my hands on a pixel. Bad news though, system limits the back swipe exclusion area a lot. Probably immersive mode is the only way to go. I will check if immersive mode got more reliable since the last time I tried it.

JohnLunzer commented 3 years ago

Okay, keep in my suggestion of disabling all navigation gestures and adding a back button to the on screen controls.

MrStahlfelge commented 3 years ago

It works well in immersive sticky mode. Unfortunately, the immersive sticky mode is not cool for normal navigation in some cases, and Android has no way to detect if gesture or button navigation is set. So a game setting is probably needed for this.

JohnLunzer commented 3 years ago

Agreed on the game setting.

MrStahlfelge commented 3 years ago

Published 2108 with immersive mode and no setting. I experienced no problems like I did four years ago that made me skip the immersive mode. You can switch to the beta channel in Play Store to receive the update in a view hours.

JohnLunzer commented 3 years ago

I can confirm an improved playing experience. The navigation gesture bar is gone and there is no false trigger of gestures. The on screen pause works as expected, though the graphic looks a little blurry and mishaped. In fact the "back" navigation gesture still works but about 10% of the time it doesn't seem to trigger. This is really only a very minor annoyance. I'm convinced that the fixes as is will satisfy all but the most picky. Thank you for your attention to this issue, much appreciated.