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
Include rounded corner radius in android safe area implementation #6143
Conversation
Android apparently has a separate API for "window cutouts", i.e. for cameras and the like, and a separate API for "rounded corners", i.e. devices where the rounded corners of the display will cause some areas of the theoretically-rectangular display to be obscured. Because there is no engineering like overengineering, right? Bonus points for them being usable at different API levels, too. Disclaimer that this does absolutely nothing on my one test device that has a rounded display and a high enough API level, but honestly it may be a device issue since it's not even returning `true` for `WindowInsets.IsRound`. Maybe it'll help someone, no idea.
Reading the code, I'm guessing that the resulting safe area is less than optimal. It would make way more sense if the code only cut away from the longest screen side (resulting in what I colored orange), or if optimizing for most play area only 1-sqrt(2)/2 of the radius should be cut away (resulting in what I colored green). Hopefully someone can test what the resulting screen actually looks like. Also there's a TODO still left in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've yet to test this on a real device, but the native android stuff looks correct.
You should remove this todo about rounded corners:
var radiusInsetArea = screenArea.Shrink(cornerInsetLeft, cornerInsetRight, cornerInsetTop, cornerInsetBottom); | ||
usableScreenArea = usableScreenArea.Intersect(radiusInsetArea); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more for the orange solution as it matched what other games do & doesn't complicate things with 4-side padding. The green solution is too simple and not a true optimal area, as it doesn't consider the width and height of the screen (if the screen is really tall, it would be optimal to push the corner point towards the orange solution). |
can anyone with an iOS device say what iOS does with rounded corners? @frenzibyte @peppy? |
I think this is accurate, except the bottom safe area edge is overriden locally. |
that looks weird because it cuts out mostly at the long edge but also appears to cut out a bit on the short edge? i dunno. think i'm just gonna make it cut at the long edge and hope everyone here can be satisfied with that. |
60ea37d
to
471d5e9
Compare
int cornerInsetTop = Math.Max(topLeftCorner?.Radius ?? 0, topRightCorner?.Radius ?? 0); | ||
int cornerInsetBottom = Math.Max(bottomLeftCorner?.Radius ?? 0, bottomRightCorner?.Radius ?? 0); | ||
|
||
var radiusInsetArea = screenArea.Width >= screenArea.Height |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i hope i can be forgiven for probably imperfectly handling square screens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semi serious, safe area is a setting, right? This isn't going to break someone using osu-framework on a smart watch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not a setting, and i have absolutely no idea, can we skip that question?
that's just the bezel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested to work as expected when hard-coding corner radii.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on Pixel 6a.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sane
Android apparently has a separate API for "window cutouts", i.e. for cameras and the like, and a separate API for "rounded corners", i.e. devices where the rounded corners of the display will cause some areas of the theoretically-rectangular display to be obscured. Because there is no engineering like overengineering, right? Bonus points for them being usable at different API levels, too.
Disclaimer that this does absolutely nothing on my one test device that has a rounded display and a high enough API level, but honestly it may be a device issue since it's not even returning
true
forWindowInsets.IsRound
. Maybe it'll help someone, no idea.