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
Owl is laid out edge-to-edge in 2 & 3-button navigation mode #1265
Conversation
@@ -33,6 +34,7 @@ class MainActivity : ComponentActivity() { | |||
) | |||
) | |||
super.onCreate(savedInstanceState) | |||
ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, insets -> insets } |
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.
This gets the inset and return it without doing anything. It seems to me that it doesn't do what the before/after screenshots do.
Is the PR missing some commits?
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.
No, it isn't.
The MDC Catalog app does the same thing for edge-to-edge layout.
https://github.com/material-components/material-components-android/blob/master/catalog/java/io/material/catalog/windowpreferences/WindowPreferencesManager.java#L80-L81
https://github.com/material-components/material-components-android/blob/master/catalog/java/io/material/catalog/windowpreferences/WindowPreferencesManager.java#L41-L46
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.
The listener in that code is doing a lot.
https://github.com/material-components/material-components-android/blob/dd8f6bebdd45c2875fab6574376a604a7d40061a/catalog/java/io/material/catalog/windowpreferences/WindowPreferencesManager.java#L42
This code only returns the passed parameter.
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.
In portrait orientation, the listener in MDC Catalog app only returns the passed parameter, too. This causes that it is drawn behind the system navigation bar in 2 & 3-button navigation mode.
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.
I see, so this is for disabling the contrast enforcement for the 3-button navbar. That is a side effect of preventing the original onApplyWindowInsets
of the decorView
.
https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/com/android/internal/policy/DecorView.java;l=1030
The problem is that it also prevents other things done in that method. For example, R.color.immersive_sys_ui
set above won't be used.
If you want the 3-button nav to be transparent, you should use the navigationBarStyle
parameter in enableEdgeToEdge
.
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.
Thank you. But, I don't understand that window.isNavigationBarContrastEnforced = false when navigationBarStyle = SystemBarStyle.dark() or SystemBarStyle.light().
Does this PR still need fixing?
P.S.
Should we use the navigationBarStyle parameter in enableEdgeToEdge instead of ViewCompat.setOnApplyWindowInsetsListener() inside other apps (Jetchat, Jetsnack, and Reply)?
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.
SystemBarStyle.auto
sets up with the recommended style (transparent gesture nav and translucent 3-button nav). The color parameters are for backward compatibility, and not suitable for color customization.
If you really want the bar to be transparent on 3-button nav, then you can use either SystemBarStyle.light
or SystemBarStyle.dark
. This app seems to change the background between the light/dark modes, so you need to call the right one based on the mode. I would leave this enableEdgeToEdge
as is, and add a second call in Themes.kt
because the mode isDarkMode
is available there.
I don't recommend using ViewCompat.setOnApplyWindowInsetsListener
for suppressing the DecorView's default behavior.
And the same goes for all the other PRs.
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.
Thank you. I tried writing it.
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.
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.
Is this implementation redundant?
P.S.
It would be nice to have a function to select SystemBarStyle.dark() or SystemBarStyle.light().
This can be executed in Java:
SystemBarStyle systemBarStyle = SystemBarStyle.auto(0, 0).getDetectDarkMode$activity_release().invoke(getResources()) ? SystemBarStyle.dark(0) : SystemBarStyle.light(0, 0);
EdgeToEdge.enable(this, systemBarStyle, systemBarStyle);
This can't be executed in Kotlin:
val systemBarStyle = if (SystemBarStyle.auto(0, 0).detectDarkMode(resources)) SystemBarStyle.dark(0) else SystemBarStyle.light(0, 0)
enableEdgeToEdge(systemBarStyle, systemBarStyle)
This issue has been automatically marked as stale because it has not had any recent activity. Please comment here if it is still valid so that we can reprioritize it. Thank you for your contributions. |
#1264
(before) Owl is not laid out edge-to-edge in 2 & 3-button navigation mode (it is not drawn behind the system navigation bar in 2 & 3-button navigation mode).
(after) Owl is laid out edge-to-edge in 2 & 3-button navigation mode (it is drawn behind the system navigation bar in 2 & 3-button navigation mode).