Skip to content

Address the still unfixed issues related to setStatusBarColor and setNavigationBarColor warning targeting API level 35 and above #4883

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ private void setUpModalSheet(
context, androidx.appcompat.R.attr.isLightTheme, true);
Window window = sheetDialog.getWindow();
sheetDialog.setFitsSystemWindows(!edgeToEdgeEnabled);
window.setNavigationBarColor(Color.TRANSPARENT);
if (VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// In API 35 the call to setNavigationBarColor is deprecated, doesn't affect gesture navigation and nav bar is set to match window background.
window.setNavigationBarColor(Color.TRANSPARENT);
}
WindowCompat.getInsetsController(window, window.getDecorView())
.setAppearanceLightStatusBars(edgeToEdgeEnabled && isLightTheme);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
if (window != null) {
// The status bar should always be transparent because of the window animation.
window.setStatusBarColor(0);

if (VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// The status bar should always be transparent because of the window animation.
// Starting with API 35, the call to setStatusBarColor() is deprecated and no longer works, since the status bar is always transparent.
window.setStatusBarColor(0);
}
window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (VERSION.SDK_INT < VERSION_CODES.M) {
// It can be transparent for API 23 and above because we will handle switching the status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ public static void applyEdgeToEdge(

int statusBarColor = getStatusBarColor(window.getContext(), edgeToEdgeEnabled);
int navigationBarColor = getNavigationBarColor(window.getContext(), edgeToEdgeEnabled);

window.setStatusBarColor(statusBarColor);
window.setNavigationBarColor(navigationBarColor);
if (VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// Starting with API 35, the call to setStatusBarColor() is deprecated and no longer works, since the status bar is always transparent.
window.setStatusBarColor(statusBarColor);
// In API 35 the call to setNavigationBarColor is deprecated, doesn't affect gesture navigation and nav bar is set to match window background.
window.setNavigationBarColor(navigationBarColor);
}

setLightStatusBar(
window,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
if (window != null) {
// The status bar should always be transparent because of the window animation.
window.setStatusBarColor(0);
if (VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// The status bar should always be transparent because of the window animation.
// Starting with API 35, the call to setStatusBarColor() is deprecated and no longer works, since the status bar is always transparent.
window.setStatusBarColor(0);
}

window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (VERSION.SDK_INT < VERSION_CODES.M) {
Expand Down