From cac802fb77a96a188bb2f0f48b6e0549ca9a56a3 Mon Sep 17 00:00:00 2001 From: YangJH Date: Fri, 1 Dec 2023 05:16:24 +0900 Subject: [PATCH] chore(android): replacing deprecated SYSTEM_UI flag (#3386) --- .../exoplayer/ReactExoplayerView.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 698856dc..e0b7d452 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -25,6 +25,9 @@ import android.widget.ImageButton; import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.WorkerThread; +import androidx.core.view.WindowCompat; +import androidx.core.view.WindowInsetsCompat; +import androidx.core.view.WindowInsetsControllerCompat; import androidx.media3.common.AudioAttributes; import androidx.media3.common.C; import androidx.media3.common.Format; @@ -102,6 +105,7 @@ import com.facebook.react.bridge.Dynamic; import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.uimanager.ThemedReactContext; import com.google.ads.interactivemedia.v3.api.AdEvent; import com.google.common.collect.ImmutableList; @@ -1969,34 +1973,27 @@ public class ReactExoplayerView extends FrameLayout implements } Window window = activity.getWindow(); - View decorView = window.getDecorView(); - int uiOptions; + WindowInsetsControllerCompat controller = new WindowInsetsControllerCompat(window, window.getDecorView()); if (isFullscreen) { - if (Util.SDK_INT >= 19) { // 4.4+ - uiOptions = SYSTEM_UI_FLAG_HIDE_NAVIGATION - | SYSTEM_UI_FLAG_IMMERSIVE_STICKY - | SYSTEM_UI_FLAG_FULLSCREEN; - } else { - uiOptions = SYSTEM_UI_FLAG_HIDE_NAVIGATION - | SYSTEM_UI_FLAG_FULLSCREEN; - } eventEmitter.fullscreenWillPresent(); if (controls && fullScreenPlayerView != null) { fullScreenPlayerView.show(); } - post(() -> { - decorView.setSystemUiVisibility(uiOptions); + UiThreadUtil.runOnUiThread(() -> { + WindowCompat.setDecorFitsSystemWindows(window, false); + controller.hide(WindowInsetsCompat.Type.systemBars()); + controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); eventEmitter.fullscreenDidPresent(); }); } else { - uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; eventEmitter.fullscreenWillDismiss(); if (controls && fullScreenPlayerView != null) { fullScreenPlayerView.dismiss(); reLayout(exoPlayerView); } - post(() -> { - decorView.setSystemUiVisibility(uiOptions); + UiThreadUtil.runOnUiThread(() -> { + WindowCompat.setDecorFitsSystemWindows(window, true); + controller.show(WindowInsetsCompat.Type.systemBars()); eventEmitter.fullscreenDidDismiss(); }); }