Skip to content
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

Closed
wants to merge 8 commits into from

Conversation

manabu-nakamura
Copy link
Contributor

#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).
Screenshot_20240215_105930
(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).
Screenshot_20240215_110222

@@ -33,6 +34,7 @@ class MainActivity : ComponentActivity() {
)
)
super.onCreate(savedInstanceState)
ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, insets -> insets }
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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)?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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)

Copy link

stale bot commented Apr 21, 2024

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.

@stale stale bot added the stale label Apr 21, 2024
@stale stale bot closed this Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants