Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also works on Android Gesture Navigation? #9

Open
Kelsonk opened this issue Aug 26, 2023 · 10 comments
Open

Also works on Android Gesture Navigation? #9

Kelsonk opened this issue Aug 26, 2023 · 10 comments

Comments

@Kelsonk
Copy link

Kelsonk commented Aug 26, 2023

Hi, in the change logs and elsewhere, I see only references to iOS for this ANE. Does this also work for Android? I'd just like a definitive answer since gesture navigation came more recently to Android than it did for iOS. Thanks!

@Kelsonk
Copy link
Author

Kelsonk commented Aug 26, 2023

I can confirm that SystemGestures.isSupported is false for Android. Do you think this can be implemented for Android as well? Maybe I can find another Ane that does this.

@marchbold
Copy link
Contributor

Correct, this is an iOS only extension currently.

Have you got a link to the native functionality you are looking for? Happy to look into adding it.

@Kelsonk
Copy link
Author

Kelsonk commented Aug 31, 2023

I believe it's related to this.

https://developer.android.com/reference/android/view/View#setSystemGestureExclusionRects(java.util.List%3Candroid.graphics.Rect%3E)

I opened on a topic on the Starling forum about my issue, and someone said to use the Application ANE and set the display mode to immersive, but I don't believe they're talking about the same issue as I'm having.

https://forum.starling-framework.org/d/23851-disable-system-gesture-swipes-on-android

@marchbold
Copy link
Contributor

Fullscreen immersive should allow you to get around the edge gestures I believe as Android disables them in this mode. I some updates to look into around this though as I believe some of those modes have been deprecated in the latest android sdk but I believe this should still work.

Decent overview here: https://medium.com/androiddevelopers/gesture-navigation-handling-gesture-conflicts-8ee9c2665c69

@Kelsonk
Copy link
Author

Kelsonk commented Sep 1, 2023

All I can say is that it's definitely not working for me on Android 10. I'd be surprised if I've implemented something incorrectly since it's pretty simple. I turned system gestures on on my phone, and any swipe from the side temporarily shows an arrow and will close the app on release. The status and nav bars are never visible on my phone at any time.

Either way, it would be nice to set the exclusion rects manually. People can swipe back to exit the app if they want, but only outside of the game board, which reaches the edges of the screen.

Here's a video of how it behaves.
https://youtube.com/shorts/pQUHQsPTRoM?feature=share

I'm actually wondering if this is something specific to the Xiaomi OS, which is what I have. I need more smart phones.

@marchbold
Copy link
Contributor

Yeah this behaviour is very likely tied to the android flavour you are testing on.

I've done some initial research into these exclusion rects and they are very limited. You can only specify about 200dp of vertical space that overrides the default action. So I'd have to redesign the api or something new for this.

@Kelsonk
Copy link
Author

Kelsonk commented Sep 7, 2023

Thanks for looking into it. I'd be more concerned about the horizontal space and preventing back swipes, 200 dp would be more than enough I'd think. Even immersive mode (if I could get it working) wouldn't be great, it still tries to pre open a menu on a first swipe.

Anyways, I shrank my game board to 90% of the width of the screen. It'd be nice to have the extra space since it can be a 16x16 grid but it works for now. Thanks again for checking it out.

@Kelsonk
Copy link
Author

Kelsonk commented Sep 7, 2023

Not to belabor this too much but is there a way to override the 'back' gesture? For most big apps (Twitter, Instagram), the back gesture doesn't close the app, but just goes to the previous screen or something.

@marchbold
Copy link
Contributor

Of course, just listen to the keyboard event and then call prevent default when it is the back operation.

NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownHandler);

function onKeyDownHandler( event:KeyboardEvent ):void 
{
    if (event.keyCode == Keyboard.BACK)
    {
        event.preventDefault(); 
    }
}

@Kelsonk
Copy link
Author

Kelsonk commented May 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants