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

IOnApplyWindowInsetsListener problem with Android 15. #9505

Open
gmck opened this issue Nov 12, 2024 · 3 comments
Open

IOnApplyWindowInsetsListener problem with Android 15. #9505

gmck opened this issue Nov 12, 2024 · 3 comments
Labels
Area: Bindings Issues in Java Library Binding projects. need-attention A xamarin-android contributor needs to review

Comments

@gmck
Copy link

gmck commented Nov 12, 2024

Android framework version

net9.0-android

Affected platform version

VS2022 17.12.0 Prev 4.0

Description

Since I worked around the problem I reported in #9244, rather than continuing to develop my app with net8-android, I thought I would look at the issues I might hit when moving to net9.0-android35 with a test project. Going edge-to-edge will mean reworking Material3 themes, especially since Android has not only deprecated but removed both SetStatusBarColor() and SetNavigationBarColor() from Android 15.

I encountered bizarre behaviour when closing the fragment when trying to get edge-to-edge to work correctly with a fragment containing a RecylerView on all devices Api 29 - 35. To get around the problem, I had to create a method to determine what mode of Navigation was being used, i.e. Gesture or 3-button.

I’m not sure if this should be classified as a bug, but as I’ve never had that requirement previously with any other IOnApplyWindowInsetsListener or read about any such requirement in the Android 15 docs, I thought I should raise it as an issue here.

The test project is at https://github.com/gmck/NavigationGraph9Net9. The readme explains the bizarre closing behaviour and the new method for circumventing it.

Steps to Reproduce

See the test project above.

Did you find any workaround?

Yes

Relevant log output

n/a
@gmck gmck added Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned. labels Nov 12, 2024
@jonpryor
Copy link
Member

I don't understand what you consider to be the bug, and skimming gmck/NavigationGraph9Net9 is not enlightening.

I have to imagine (hope) that the issue isn't due to .NET for Android bindings, but instead due to the underlying Android APIs.

Have you tried searching stackoverflow.com /etc. for Java/Kotlin variants of this question/scenario?

@jonpryor jonpryor added the need-info Issues that need more information from the author. label Nov 14, 2024
@gmck
Copy link
Author

gmck commented Nov 14, 2024

@jonpryor

I don't understand what you consider to be the bug, and skimming gmck/NavigationGraph9Net9 is not enlightening.

I thought I spelled it out in README. You can see it readily enough if you build and run it.
Just comment out the lines ViewCompat.SetOnApplyWindowInsetsListener(recyclerView, this); in the OnCreateView of BooksFragment

I have to imagine (hope) that the issue isn't due to .NET for Android bindings, but instead due to the underlying Android APIs.

The more I work with it, the less I think it is a bug in your .NET for Android bindings. I’m also unaware of anyone having the same issue on any Android (Kotlin/Java) forums, but I can’t say I’ve looked at any particular Kotlin/Java forum.

Have you tried searching stackoverflow.com /etc. for Java/Kotlin variants of this question/scenario?

Yes, I found an answer to a specific question: How to detect full screen gesture mode in android 10
https://stackoverflow.com/questions/56689210/how-to-detect-full-screen-gesture-mode-in-android-10/60733427#60733427. But as you can see, it is from 5 years ago, and the OP didn’t state why he needed such a function.

I’ve since converted the recommended answer from the above and tested it in my example, and that function works equally as well as mine and also eliminates the problem.

Therefore, assuming that most net8.0-android apps will have a fragment with RecyclerView, these guys will hit this issue when they upgrade to net9.0-android35 as soon as they enable edge-to-edge.

I’ve never had that requirement with any other IOnApplyWindowInsetsListener with a RecyclerView before, and I've never read about any such requirement in the Android 15 docs.

In searching for an answer, I also came across Redth’s [Android] Apps compiled for 15.0 / 35 default displaying as Edge to Edge #24742 issue. If that is how they want to do it in Maui, that’s fine, but it’s still just a cop-out. Why even bother moving from Android 14 if you aren’t going to enable edge-to-edge?

I raised the issue here first to bring it to your attention, and second, there doesn’t seem to be a particular forum devoted to .Net for Android where developers can discuss problems.

The Shanghai Police moderators have turned https://learn.microsoft.com/en-us/answers/tags/18/xamarin into a useless forum, and StackOverflow is still Xamarin.Android.

You can no longer get an answer about Xamarin.Android and Android 14, even though, thanks to you guys, you gave us a perfectly viable solution for Android 14 for at least another 12 months. If you attempt to answer an X.A. API 34 question, the Shanghai Police now delete your answer. Consequently, people have left – not a single question so far in November.

Why can’t MS create another forum for .Net for Android (without the Shanghai Police) so the existing Xamarin forum can quietly fade away?

Then, make a separate new Maui forum for those guys.

@dotnet-policy-service dotnet-policy-service bot added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Nov 14, 2024
@gmck
Copy link
Author

gmck commented Nov 16, 2024

@jonpryor
As a further test, I went back to the NavigationGraph8Net8 project, which was the base project I first converted to NavigationGraph9Net9 before modifying it to support Android 15.

As it didn’t have the BooksFragment, I added the BooksFragment-related code from NavigationGraph9Net9 to NavigationGraph8Net8 to check the behaviour of the recyclerview using net8.0-android.

The difference using the net8.0-android project is that there is no need for the IsGestureNavigation() function. However, what I came up with for going edge-to-edge differs from how Android 15 does, as I relied on WindowCompat.SetDecorFitsSystemWindows(Window, false), which is now deprecated in Android 15. Note it needs to be activated via the preference setting.

I have no objection to using IsGestureNavigation(); I’m just concerned that I’ve only tested it on the limited number of phones I listed in the readme.

@grendello grendello added Area: Bindings Issues in Java Library Binding projects. and removed Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned. labels Nov 18, 2024
@grendello grendello removed their assignment Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Bindings Issues in Java Library Binding projects. need-attention A xamarin-android contributor needs to review
Projects
None yet
Development

No branches or pull requests

3 participants