-
Notifications
You must be signed in to change notification settings - Fork 706
Add full support for edge-to-edge #2002
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
base: master
Are you sure you want to change the base?
Conversation
I think this is now ready for review. I've done extremely extensive testing on practically every single supported API level and it seems to work fine. But there is always a good chance I missed something. |
Could you perhaps split this into two pull requests, one for targetSdk and one for edge-to-edge. That way we can first merge edge-to-edge and then merge targetSdk later. By doing this we can test out edge-to-edge on the pre-release group first, without all the small changes of changing the targetSdk. |
Sure, good point. I did it like this only because bumping to 36 (original intent of this PR) required edge-to-edge support. I'll switch it back to 35 for now. |
@fire-light42 now switched back to 35. I'll do another PR later to bump to targetSdk 36. I kept manifestPlaceholders here even though its now unrelated because its useful to just have anyway. |
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.
Code looks good, will test later 👍
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.
Everything looks good. Unfortunately it does not handle the notch correctly on phones with a notch. Please check the behavior with a notch in both versions (eg on landscape mode). If you do not have a notch on your device there is a software notch in developer settings.
Whoops, yes I did forget to handle |
Ive added display cutout support. I had to end up drawing an overlay for it so that it doesn't look horrible by making the cutout background the same as the default fragment background which was a bit tricky. Hopefully I did it okay, if not I apologize. |
I also found and fixed another bug where using RTL layout totally messed it up. But thats also now fixed. |
This is required for targetSdk 36, so it is also in preparation for that.
A side effect of doing this fixes many layout bugs such as:
This also fixes immersive mode to use the modern method, the commented out was just wrong and unreliable but this uses a more reliable (and modern) method that is more compatible with edge-to-edge.
This also adds compat methods,
setNavigationBarColorCompat
, andenableEdgeToEdgeCompat
to reduce code duplication and properly maintain compatability on very low APIs that edge-to-edge doesnt support, or is very buggy (technically Android 10 supports it but it is very buggy so we only enable on Android 11+).navigationBarColor
no longer does anything at all when using edge-to-edge, so just to future proof it and to maintain consistency and reduce the likelihood of random odd bugs, we don't use it when using edge-to-edge. Technically the same goes forandroid:navigationBarColor
andandroid:statusBarColor
instyles.xml
but it should be okay and can leave those for now.For the cutout, it honors the camera cutout setting in Android settings in some devices, if thats set to auto or hidden it pads it and then draws a black overlay to make design look consistent and appear as if the screen ends at that point. When that setting is set to show, if doesn't draw the black bar nor pad because in that case it makes the system think there is no cutout and thus
WindowInsetsCompat.Type.displayCutout
returns nothing, which is what all that logic bases on for compatability accross all devices and API levels.This also properly handles RTL support so the layout doesn't get very odd on RTL languages.