Simplify inset logic, fix landscape mode, fix cutout overlapping
I've tested this on:
* API 36 (Android 16 QPR1) - Pixel Tablet
* API 36 (Android 16) - Pixel 10 Pro XL
* API 33 - Emulator
* API 29 - Emulator
* API 27 - Emulator
* API 26 - Emulator
* API 23 - Emulator
* API 21 - Emulator
* API 19 - Emulator
I unfortunately don't have any way to test on more finicky devices, like Xiaomi. I don't think this PR would break anything there, but if anyone is able to test, it would be much appreciated!
---
The commit primarily fixes a few overlapping issues caused by the window inset handling. Previously, there were two main issues:
* Because `setTransparentNavigationBar()` checked for portrait mode, the inset logic never executed in landscape mode. This caused the app to overlap the status bar and navigation bar.
* The inset logic did not have handling for `displayCutout` insets. In landscape mode, this would cause the app to overlap the notch or camera hole punch area on phones.
In addition to fixing those issues, this commit simplifies the inset logic a bit:
* `applyWindowInsets()` now accepts an `EnumSet` of `WindowInsetPosition` to avoid needing to duplicate logic for the various position combinations.
* Insets are now applied to the main container in the layout instead of individual elements where possible. This eliminates the need for the previous manual IME height handling logic in `BOTTOM_IME` vs `TOP_BOTTOM_IME` (for avoiding the insets being applied twice).
* Since insets are now applied to the main layout container, `applyWindowInsets()` now takes `systemBars`, `displayCutout`, and `ime` all into consideration. This should avoid all possible overlapping.
* Add support for using padding instead of margins for insets. This is used for `GroupActivity`'s navigation drawer, where Material design intends for the drawer background to be drawn behind system bars.
---
Screenshots of issues being fixed:
* [`GroupActivity`] In landscape mode, the status bar, navigation bar, and camera hole are all overlapped.
* Before: [screenshot](https://github.com/user-attachments/assets/4d60f686-39ec-4541-b083-7cf1c2a4ed38)
* After: [screenshot](https://github.com/user-attachments/assets/2e7d60cc-9706-498c-82d1-36bc61cafb33)
* [`GroupActivity`] In landscape mode, the navigation drawer overlaps the camera hole and has a shadow drawn on top.
* Before: [screenshot](https://github.com/user-attachments/assets/5a85b727-436b-44ba-a6c7-ddd89dc98ed1)
* After: [screenshot](https://github.com/user-attachments/assets/a4fe893a-6356-4753-8afa-d255d1dcf2bb)
* [`EntryEditActivity`] In landscape mode on phones, the status bar, navigation bar, and camera hole are all overlapped. However, when the IME is visible, this is more apparent as the contents of the app "leak" through.
* Before: [screenshot](https://github.com/user-attachments/assets/21049fb4-217f-47cc-9408-a473e932f5f7)
* After: [screenshot](https://github.com/user-attachments/assets/469dc26e-0f2b-4188-b44a-9c982f5ca4f2)
* [`EntryEditActivity`] In landscape mode on tablets, everything is once again overlapped. However, since the IME is not fullscreen, this makes it impossible to access the bottom half of the app (fields, footer, etc.).
* Before: [screenshot](https://github.com/user-attachments/assets/2d42cab7-923e-4628-b8ab-2e75ce79029f)
* After: [screenshot](https://github.com/user-attachments/assets/80c253bb-4fbb-4a58-a339-470eefaea34c)
---
Fixes: #2198
合并状态:未合并 2 条评论