Fix #5940: Add edge-to-edge window insets for drawer-based activities#6214
Fix #5940: Add edge-to-edge window insets for drawer-based activities#6214Neer-rn wants to merge 3 commits intooppia:developfrom
Conversation
Current Testing ResultsBefore (No changes, with
|
|
Could you please check in landscape mode, specially drawers, In my case, I observed some unexpected shades. |
@subhajitxyz I have been working on the landscape drawer overlay issue you pointed out in the last meeting. Spent quite a bit of time investigating this but have not been able to resolve this issue. Thinking of opening a discussion and surely will bring this issue up in tomorrow's meeting so that we can further discuss this. |
|
I have tried many things, but they didn’t work for me.
Since NavigationView automatically handles insets, I suspect that this is causing the shading issue in the inner layout. |
…tionView insets listener
|
Hey @subhajitxyz, I was able to fix it! Let me explain what happened in detail. So after you mentioned this in the last meeting about this issue, I spent a lot of time trying to fix it. Like I was working on this particular issue from last week. What I tried (and what didn't work):
I searched a lot online but couldn't find anything about this exact issue. I tried the best and most powerful LLMs too and Gemini gave terrible answers, ChatGPT suggested things like The actual root cause: You were right, the issue is with the inner NavigationView (
Why I checked the AOSP source code for public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
if (mOnApplyWindowInsetsListener != null) {
return mOnApplyWindowInsetsListener.onApplyWindowInsets(this, insets);
} else {
return onApplyWindowInsets(insets);
}
}The (The above is the only explanation that I was convinced and at this point Claude and I both agree on this because this is the only way I was able to fix this issue) Why it only showed in landscape: In portrait, the status bar inset is at the top and the drawer header covers it, so the Why the outer NavigationView didn't have this problem: We were already setting The fix (3 lines): ViewCompat.setOnApplyWindowInsetsListener(binding.fragmentDrawerNavView) { _, insets ->
insets
}This replaces @BenHenning I would like to request you to specifically review the listener override in Thank you @subhajitxyz . Please have a look at my approach, What do you think about this?? |
|
Thanks @Neer-rn . It is actually a deep finding and a detailed explanation, and the solution is quite tricky. I really appreciate that 🙌 I think I also need to start using LLMs to get deeper insights like this. I would love to learn from you. I took a quick look at your PR, and it looks good overall 👍 |
| // system bar inset areas. Setting fitsSystemWindows=false alone is not sufficient because | ||
| // the OnApplyWindowInsetsListener set in ScrimInsetsFrameLayout's constructor is | ||
| // independent of the fitsSystemWindows flag. | ||
| ViewCompat.setOnApplyWindowInsetsListener(binding.fragmentDrawerNavView) { _, insets -> |
There was a problem hiding this comment.
For this and the other two: is it expected that we need to override the listeners in this way? It feels rather hacky and difficult to reason about:
- What if a different part of the lifecycle overrides this again?
- What are the implications of overriding this across different device and SDK level configurations?
- Does this introduce any RTL or accessibility problems?
- What if the implementation being altered changes its behaviors to use something else as a hook in the future?
I find it quite reasonable to have something like this as a medium-term solution (provided we don't find any issues with it while testing) so long as we know what the long-term replacement is. Otherwise, we may well want to consider what work may be needed to do a more "proper" fix (if three is one) that doesn't require overriding the insets listeners.
|
Thanks @Neer-rn and @subhajitxyz! I agree that your investigation was very well done @Neer-rn! I looked at the requested method and left one comment with more thoughts. |

















Explanation
Fixes part of #5940
This PR adds edge-to-edge window inset handling for all drawer-based screens in the app. When the
EnableEdgeToEdgefeature flag is ON, each screen properly handles the transparent status bar and navigation bar that Android 15+ enforces.What's done so far:
(Home, ClassroomList, Options, Help, DeveloperOptions, AdministratorControls)
EnableEdgeToEdgefeature flagStatusBarColor.statusBarColorUpdate()calls whenthe flag is ON
What's left:
(non-drawer screens like topic, exploration, story, etc.)
Depends on #6209 (feature flag PR must be merged first).
Essential Checklist
For UI-specific PRs only
Screenshots will be added during review once the full implementation is ready. Currently still working on remaining screens.