Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b1e7ad8

Browse files
authored
Revert "Set system bar appearance using WindowInsetsControllerCompat instead of the deprecated View#setSystemUiVisibility (#29060)" (#29206)
This reverts commit d8d9c4f.
1 parent bcdd9fe commit b1e7ad8

5 files changed

Lines changed: 9 additions & 113 deletions

File tree

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ deps = {
570570
'packages': [
571571
{
572572
'package': 'flutter/android/embedding_bundle',
573-
'version': 'last_updated:2021-10-08T14:22:08-0700'
573+
'version': 'last_updated:2021-08-10T22:12:57-0700'
574574
}
575575
],
576576
'condition': 'download_android_deps',

shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import androidx.annotation.NonNull;
2121
import androidx.annotation.Nullable;
2222
import androidx.annotation.VisibleForTesting;
23-
import androidx.core.view.WindowInsetsControllerCompat;
2423
import io.flutter.Log;
2524
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
2625
import java.io.FileNotFoundException;
@@ -365,8 +364,7 @@ private void setSystemChromeSystemUIOverlayStyle(
365364
PlatformChannel.SystemChromeStyle systemChromeStyle) {
366365
Window window = activity.getWindow();
367366
View view = window.getDecorView();
368-
WindowInsetsControllerCompat windowInsetsControllerCompat =
369-
new WindowInsetsControllerCompat(window, view);
367+
int flags = view.getSystemUiVisibility();
370368

371369
// SYSTEM STATUS BAR -------------------------------------------------------------------
372370
// You can't change the color of the system status bar until SDK 21, and you can't change the
@@ -379,14 +377,11 @@ private void setSystemChromeSystemUIOverlayStyle(
379377
if (systemChromeStyle.statusBarIconBrightness != null) {
380378
switch (systemChromeStyle.statusBarIconBrightness) {
381379
case DARK:
382-
// Dark status bar icon brightness.
383-
// Light status bar appearance.
384-
windowInsetsControllerCompat.setAppearanceLightStatusBars(true);
380+
// View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
381+
flags |= 0x2000;
385382
break;
386383
case LIGHT:
387-
// Light status bar icon brightness.
388-
// Dark status bar appearance.
389-
windowInsetsControllerCompat.setAppearanceLightStatusBars(false);
384+
flags &= ~0x2000;
390385
break;
391386
}
392387
}
@@ -413,14 +408,11 @@ private void setSystemChromeSystemUIOverlayStyle(
413408
if (systemChromeStyle.systemNavigationBarIconBrightness != null) {
414409
switch (systemChromeStyle.systemNavigationBarIconBrightness) {
415410
case DARK:
416-
// Dark navigation bar icon brightness.
417-
// Light navigation bar appearance.
418-
windowInsetsControllerCompat.setAppearanceLightNavigationBars(true);
411+
// View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
412+
flags |= 0x10;
419413
break;
420414
case LIGHT:
421-
// Light navigation bar icon brightness.
422-
// Dark navigation bar appearance.
423-
windowInsetsControllerCompat.setAppearanceLightNavigationBars(false);
415+
flags &= ~0x10;
424416
break;
425417
}
426418
}
@@ -446,6 +438,7 @@ private void setSystemChromeSystemUIOverlayStyle(
446438
systemChromeStyle.systemNavigationBarContrastEnforced);
447439
}
448440

441+
view.setSystemUiVisibility(flags);
449442
currentTheme = systemChromeStyle;
450443
}
451444

shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.flutter.plugin.platform;
22

3-
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
4-
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
53
import static org.junit.Assert.assertFalse;
64
import static org.junit.Assert.assertNotNull;
75
import static org.junit.Assert.assertNull;
@@ -22,7 +20,6 @@
2220
import android.os.Build;
2321
import android.view.View;
2422
import android.view.Window;
25-
import android.view.WindowInsetsController;
2623
import androidx.activity.OnBackPressedCallback;
2724
import androidx.fragment.app.FragmentActivity;
2825
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
@@ -219,98 +216,6 @@ public void setNavigationBarDividerColor() {
219216
}
220217
}
221218

222-
@Config(sdk = 30)
223-
@Test
224-
public void setNavigationBarIconBrightness() {
225-
if (Build.VERSION.SDK_INT >= 30) {
226-
View fakeDecorView = mock(View.class);
227-
WindowInsetsController fakeWindowInsetsController = mock(WindowInsetsController.class);
228-
Window fakeWindow = mock(Window.class);
229-
when(fakeWindow.getDecorView()).thenReturn(fakeDecorView);
230-
when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController);
231-
Activity fakeActivity = mock(Activity.class);
232-
when(fakeActivity.getWindow()).thenReturn(fakeWindow);
233-
PlatformChannel fakePlatformChannel = mock(PlatformChannel.class);
234-
PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel);
235-
236-
SystemChromeStyle style =
237-
new SystemChromeStyle(
238-
null, // statusBarColor
239-
null, // statusBarIconBrightness
240-
null, // systemStatusBarContrastEnforced
241-
null, // systemNavigationBarColor
242-
Brightness.LIGHT, // systemNavigationBarIconBrightness
243-
null, // systemNavigationBarDividerColor
244-
null); // systemNavigationBarContrastEnforced
245-
246-
platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(style);
247-
248-
verify(fakeWindowInsetsController)
249-
.setSystemBarsAppearance(0, APPEARANCE_LIGHT_NAVIGATION_BARS);
250-
251-
style =
252-
new SystemChromeStyle(
253-
null, // statusBarColor
254-
null, // statusBarIconBrightness
255-
null, // systemStatusBarContrastEnforced
256-
null, // systemNavigationBarColor
257-
Brightness.DARK, // systemNavigationBarIconBrightness
258-
null, // systemNavigationBarDividerColor
259-
null); // systemNavigationBarContrastEnforced
260-
261-
platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(style);
262-
263-
verify(fakeWindowInsetsController)
264-
.setSystemBarsAppearance(
265-
APPEARANCE_LIGHT_NAVIGATION_BARS, APPEARANCE_LIGHT_NAVIGATION_BARS);
266-
}
267-
}
268-
269-
@Config(sdk = 30)
270-
@Test
271-
public void setStatusBarIconBrightness() {
272-
if (Build.VERSION.SDK_INT >= 30) {
273-
View fakeDecorView = mock(View.class);
274-
WindowInsetsController fakeWindowInsetsController = mock(WindowInsetsController.class);
275-
Window fakeWindow = mock(Window.class);
276-
when(fakeWindow.getDecorView()).thenReturn(fakeDecorView);
277-
when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController);
278-
Activity fakeActivity = mock(Activity.class);
279-
when(fakeActivity.getWindow()).thenReturn(fakeWindow);
280-
PlatformChannel fakePlatformChannel = mock(PlatformChannel.class);
281-
PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel);
282-
283-
SystemChromeStyle style =
284-
new SystemChromeStyle(
285-
null, // statusBarColor
286-
Brightness.LIGHT, // statusBarIconBrightness
287-
null, // systemStatusBarContrastEnforced
288-
null, // systemNavigationBarColor
289-
null, // systemNavigationBarIconBrightness
290-
null, // systemNavigationBarDividerColor
291-
null); // systemNavigationBarContrastEnforced
292-
293-
platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(style);
294-
295-
verify(fakeWindowInsetsController).setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS);
296-
297-
style =
298-
new SystemChromeStyle(
299-
null, // statusBarColor
300-
Brightness.DARK, // statusBarIconBrightness
301-
null, // systemStatusBarContrastEnforced
302-
null, // systemNavigationBarColor
303-
null, // systemNavigationBarIconBrightness
304-
null, // systemNavigationBarDividerColor
305-
null); // systemNavigationBarContrastEnforced
306-
307-
platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(style);
308-
309-
verify(fakeWindowInsetsController)
310-
.setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS);
311-
}
312-
}
313-
314219
@Config(sdk = 29)
315220
@Test
316221
public void setSystemUiMode() {

shell/platform/android/test_runner/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ android {
3737
dependencies {
3838
testImplementation files(project.property("flutter_jar"))
3939
testImplementation "androidx.annotation:annotation:1.1.0"
40-
testImplementation "androidx.core:core:1.6.0"
4140
testImplementation "androidx.fragment:fragment:1.1.0"
4241
testImplementation "androidx.lifecycle:lifecycle-runtime:2.2.0"
4342
testImplementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"

tools/cipd/android_embedding_bundle/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ android {
4141

4242
dependencies {
4343
embedding "androidx.annotation:annotation:1.1.0"
44-
embedding "androidx.core:core:1.6.0"
4544
embedding "androidx.fragment:fragment:1.1.0"
4645

4746
def lifecycle_version = "2.2.0"

0 commit comments

Comments
 (0)