Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
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 @@ -374,15 +374,17 @@ private void setSystemChromeSystemUIOverlayStyle(
// If transparent, SDK 29 and higher may apply a translucent scrim behind the bar to ensure
// proper contrast. This can be overridden with
// SystemChromeStyle.systemStatusBarContrastEnforced.
if (systemChromeStyle.statusBarIconBrightness != null && Build.VERSION.SDK_INT >= 23) {
switch (systemChromeStyle.statusBarIconBrightness) {
case DARK:
// View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
flags |= 0x2000;
break;
case LIGHT:
flags &= ~0x2000;
break;
if (Build.VERSION.SDK_INT >= 23) {
if (systemChromeStyle.statusBarIconBrightness != null) {
switch (systemChromeStyle.statusBarIconBrightness) {
case DARK:
// View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
Copy link

Choose a reason for hiding this comment

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

This value was deprecated in API 30.

Do we know if this still works in Build.VERSION.SDK_INT >= 30 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the migration should probably be in a separate change though so all of this file can be migrated.

flags |= 0x2000;
break;
case LIGHT:
flags &= ~0x2000;
break;
}
}

if (systemChromeStyle.statusBarColor != null) {
Expand All @@ -403,16 +405,17 @@ private void setSystemChromeSystemUIOverlayStyle(
// If transparent, SDK 29 and higher may apply a translucent scrim behind 2/3 button navigation
// bars to ensure proper contrast. This can be overridden with
// SystemChromeStyle.systemNavigationBarContrastEnforced.
if (systemChromeStyle.systemNavigationBarIconBrightness != null
&& Build.VERSION.SDK_INT >= 26) {
switch (systemChromeStyle.systemNavigationBarIconBrightness) {
case DARK:
// View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
flags |= 0x10;
break;
case LIGHT:
flags &= ~0x10;
break;
if (Build.VERSION.SDK_INT >= 26) {
if (systemChromeStyle.systemNavigationBarIconBrightness != null) {
switch (systemChromeStyle.systemNavigationBarIconBrightness) {
case DARK:
// View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
Copy link

Choose a reason for hiding this comment

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

This one is also deprecated.

flags |= 0x10;
break;
case LIGHT:
flags &= ~0x10;
break;
}
}

if (systemChromeStyle.systemNavigationBarColor != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,41 @@ public void setNavigationBarDividerColor() {
when(fakeActivity.getWindow()).thenReturn(fakeWindow);
PlatformChannel fakePlatformChannel = mock(PlatformChannel.class);
PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel);
// Default style test
SystemChromeStyle style =
new SystemChromeStyle(0XFF000000, null, true, 0XFFC70039, null, 0XFF006DB3, true);
new SystemChromeStyle(
0XFF000000, // statusBarColor
null, // statusBarIconBrightness
true, // systemStatusBarContrastEnforced
0XFFC70039, // systemNavigationBarColor
null, // systemNavigationBarIconBrightness
0XFF006DB3, // systemNavigationBarDividerColor
true); // systemNavigationBarContrastEnforced

if (Build.VERSION.SDK_INT >= 28) {
platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(style);

assertEquals(0XFF000000, fakeActivity.getWindow().getStatusBarColor());
assertEquals(0XFFC70039, fakeActivity.getWindow().getNavigationBarColor());
assertEquals(0XFF006DB3, fakeActivity.getWindow().getNavigationBarDividerColor());

// Regression test for https://github.com/flutter/flutter/issues/88431
// A null brightness should not affect changing color settings.
style =
new SystemChromeStyle(
0XFF006DB3, // statusBarColor
null, // statusBarIconBrightness
true, // systemStatusBarContrastEnforced
0XFF000000, // systemNavigationBarColor
null, // systemNavigationBarIconBrightness
0XFF006DB3, // systemNavigationBarDividerColor
true); // systemNavigationBarContrastEnforced

platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(style);

assertEquals(0XFFC70039, fakeActivity.getWindow().getStatusBarColor());
assertEquals(0XFF000000, fakeActivity.getWindow().getNavigationBarColor());
assertEquals(0XFF006DB3, fakeActivity.getWindow().getNavigationBarDividerColor());
}
}

Expand Down