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

Fix set status bar icons on API 30 #886

Merged
merged 1 commit into from
Nov 23, 2021
Merged

Conversation

alexvanyo
Copy link
Collaborator

This fixes #881

The issue occurs with the Activity's theme contains android:windowLightStatusBars="true". In other words, the status bars icons are dark by default.

There was a bug in androidx.core in this case that prevented showing the light icons on API 30: https://issuetracker.google.com/issues/180881870.

This was marked as fixed, and released with 1.7.0 (which accompanist is using), but there is a follow-up issue: Depending on how the WindowInsetsControllerCompat is acquired, the workaround fixing the issue on API 30 may or may not be used: https://issuetracker.google.com/issues/207401542

In our case, we were using a codepath that doesn't have the workaround, meaning that we are still encountering the "fixed" issue (#881). By switching from ViewCompat. getWindowInsetsController to the direct constructor of WindowInsetsControllerCompat, we will ensure we still get the workaround in the meantime while the upstream issue is fixed.

@google-cla google-cla bot added the cla: yes label Nov 22, 2021
Comment on lines +177 to +179
private val window = requireNotNull(view.context.findWindow()) {
"The Compose View must be hosted in an Activity with a Window!"
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made the requireNotNull explicit here on the window, since we were effectively requiring that anyway with the old code (at least on API 29 and below). This simplified a bit of the logic here as well.

Copy link
Contributor

@chrisbanes chrisbanes left a comment

Choose a reason for hiding this comment

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

:shipit:

@alexvanyo alexvanyo merged commit cbf04d0 into main Nov 23, 2021
@alexvanyo alexvanyo deleted the av/status-bar-icons-API-30 branch November 23, 2021 18:13
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.

SystemUiController.setStatusbarColor not changed icons color in status bar
4 participants