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

Implement DisplayServer::screen_get_usable_rect() for Android #43104

Merged
merged 1 commit into from
Oct 27, 2020

Conversation

Klowner
Copy link
Contributor

@Klowner Klowner commented Oct 26, 2020

Fixes #20044 for me! Instead of showing letterboxes on the side, the full display is used, and OS.get_window_safe_area() should return a rectangle which excludes a device's cutout shapes.

It looks like lots of the methods for handling the cutout areas were updated in Android API 30, but hopefully this will work well enough for now.

@Calinou Calinou added cherrypick:3.x Considered for cherry-picking into a future 3.x release enhancement platform:android topic:porting labels Oct 26, 2020
@Calinou Calinou added this to the 4.0 milestone Oct 26, 2020
Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

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

I haven't tested, but the code looks fine apart from the little detail I've pointed out.

Another thing that needs to be addressed is DisplayCutout is min API level 28 and the current minimum is 21.
https://developer.android.com/reference/android/view/DisplayCutout

Is there any way we could disable this code if API < 28? I don't know if Java allows something like that.

Otherwise, we need to decide if it's ok to raise the minimum API level to 28 for 4.0.

platform/android/java_godot_io_wrapper.cpp Show resolved Hide resolved
@akien-mga
Copy link
Member

Otherwise, we need to decide if it's ok to raise the minimum API level to 28 for 4.0.

I'd say not OK, that excludes way too many users (40% of the market according to https://gs.statcounter.com/android-version-market-share/mobile/worldwide).

@Klowner
Copy link
Contributor Author

Klowner commented Oct 27, 2020

Eep! Thank you for bringing attention to the minimum API version, @pouleyKetchoupp.

I think there's a mechanism for checking the device's supported API version? (I haven't done much android development)

Since older devices probably don't have cutouts anyway, would returning the full screen rectangle on devices with API <28 be a sufficient work around?

Thanks for the feedback!

@pouleyKetchoupp
Copy link
Contributor

@Klowner Yes I think full screen rectangle would be fine as a fallback if you can figure out how to support both API versions.

@Klowner Klowner force-pushed the android-p-cutout-support branch 2 times, most recently from c448894 to d753a54 Compare October 27, 2020 14:55
@Klowner
Copy link
Contributor Author

Klowner commented Oct 27, 2020

There we go, all squashed down 👍

Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

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

Looks good to me. I've tested the fallback case and it works fine. I don't have a device with recent enough API to test the cutout itself.

@Klowner Klowner changed the title Implement OS.get_window_safe_area() for Android Implement DisplayServer::screen_get_usable_rect() or Android Oct 27, 2020
@Klowner Klowner changed the title Implement DisplayServer::screen_get_usable_rect() or Android Implement DisplayServer::screen_get_usable_rect() for Android Oct 27, 2020
@akien-mga akien-mga merged commit bc1eaab into godotengine:master Oct 27, 2020
@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Oct 27, 2020
@Xioor
Copy link

Xioor commented Apr 23, 2021

Could I cherry pick this in 3.x.x or would it be incompatible? Do I have to use 4.0 for this feature?

@akien-mga
Copy link
Member

This has already been merged in the 3.x branch and is included in 3.3-stable: #43140

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.

Android P notch support.
5 participants