Skip to content

Commit

Permalink
refactor: replacing deprecated SYSTEM_UI flag
Browse files Browse the repository at this point in the history
  • Loading branch information
YangJonghun committed Nov 28, 2023
1 parent d05231d commit a6ad4d3
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
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;
Expand Down Expand Up @@ -102,6 +105,7 @@
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;
Expand Down Expand Up @@ -1969,34 +1973,27 @@ public void setFullscreen(boolean fullscreen) {
}

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();
});
}
Expand Down

0 comments on commit a6ad4d3

Please sign in to comment.