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

Fix obsolete code in Android safe area handling by using AndroidX #6175

Merged
merged 5 commits into from Feb 7, 2024

Conversation

Susko3
Copy link
Member

@Susko3 Susko3 commented Feb 5, 2024

This replaces obsolete calls with AndroidX compat classes that allow using new-style APIs on older android platforms.

Eg. Display.getRealSize() is deprecated on API 31+ and the suggested alternative is WindowManager.getCurrentWindowMetrics() (API 30+), so instead of having to call the old API on old platforms and the new API on new platforms, we use AndroidX WindowMetricsCalculator which does that for us.

Microsoft.Maui.Essentials is using Xamarin.AndroidX libraries (see nuget), so it's safe and supported to use them.

@Susko3 Susko3 changed the title Fix obsolete code in Android safe area handling Fix obsolete code in Android safe area handling by using AndroidX Feb 5, 2024
Comment on lines -199 to -205
Activity.IsActive.BindValueChanged(active =>
{
// When rotating device 180 degrees in the background,
// LayoutChange doesn't trigger after returning to game.
// So update safe area once active again.
if (active.NewValue)
updateSafeArea();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this scenario on two of my devices, and there are no issues when using OnApplyWindowInsets().

@smoogipoo smoogipoo requested a review from bdach February 6, 2024 06:58
@bdach bdach merged commit 25bfac1 into ppy:master Feb 7, 2024
21 checks passed
@Susko3 Susko3 deleted the fix-obsolete-in-safe-area branch February 7, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants