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 dark status bar icons when player is in fullscreen #3445

Merged
merged 5 commits into from
Mar 30, 2023

Conversation

anilbeesetti
Copy link
Contributor

Before:
Screenshot_20230328-201725_LibreTube_Debug
After:
Screenshot_20230328-203936_LibreTube_Debug

Comment on lines 16 to 22
fun Activity.setLightStatusBarIcons() {
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = false
}

fun Activity.setDarkStatusBarIcons() {
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = true
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like the method names should be swapped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are correct. Here we have to change the statusbar icon color but there's no direct method to change icon color directly. So if we set the statusbar as light then icons will be dark

Copy link
Collaborator

@Isira-Seneviratne Isira-Seneviratne Mar 29, 2023

Choose a reason for hiding this comment

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

Right, missed that.

Edit: Instead of adding these extensions, you could just create a WindowInsetsControllerCompat in the fragment itself and reuse it as needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we can do that. It's just a preference. By doing what you suggested the code is not reusable and using functions make code more readable in my opinion

Copy link
Collaborator

Choose a reason for hiding this comment

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

True, but it's not like the code is being used anywhere else in your changeset. If it needs to be used in other places as well, it can be easily refactored.

Comment on lines 501 to 502
// set status bar icon color to white
mainActivity.setLightStatusBarIcons()
Copy link
Collaborator

@Isira-Seneviratne Isira-Seneviratne Mar 29, 2023

Choose a reason for hiding this comment

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

Suggested change
// set status bar icon color to white
mainActivity.setLightStatusBarIcons()
// set status bar icon color to white
windowInsetsControllerCompat.isAppearanceLightStatusBars = false

The WindowInsetsControllerCompat object used here could be created/destroyed in the relevant fragment lifecycle callbacks (onCreate, onDestroy), like with the fragment's view binding.

Comment on lines 530 to 534
if (mainActivity.isLightTheme) {
mainActivity.setDarkStatusBarIcons()
} else {
mainActivity.setLightStatusBarIcons()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (mainActivity.isLightTheme) {
mainActivity.setDarkStatusBarIcons()
} else {
mainActivity.setLightStatusBarIcons()
}
windowInsetsControllerCompat.isAppearanceLightStatusBars = when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> false
Configuration.UI_MODE_NIGHT_NO -> true
else -> true
}

Copy link
Collaborator

@Isira-Seneviratne Isira-Seneviratne left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@Bnyro Bnyro merged commit fe9a48e into libre-tube:master Mar 30, 2023
@Bnyro
Copy link
Member

Bnyro commented Mar 30, 2023

Thank you!

@anilbeesetti anilbeesetti deleted the fix-statusbar-icons branch March 30, 2023 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants