Android Insets not updated on 180º rotations
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 25.4k
- Forks
- 6.5k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 5
Description
User gerdsOn on Discord has reported that safe insets are not updated when rotating the device 180º on a landscapeSensor app. The reason is that onSurfaceChanged() is not triggered on that case because width and height don't change. This makes sense as, until recently, screens where symmetric. This issue probably occurs on portraitSensor as well.
The solution may be to move the insets update to a DisplayListener.onDisplayChanged() listener that is triggered on any orientation change including 180º (It is API > 17 but that's ok). A resize() should also be triggered on this case for the app to react to the change but we need to make sure it's not triggered twice for 90º rotations.
Relevant SO post https://stackoverflow.com/questions/9909037/how-to-detect-screen-rotation-through-180-degrees-from-landscape-to-landscape-or
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Android handling around onSurfaceChanged(), DisplayListener.onDisplayChanged(), and resize(). Verify how 180º landscape rotations update safe insets and trigger resize(), then check that 90º rotations do not trigger resize() twice; the fix is done when both rotation paths update correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100