chore(android): replacing deprecated SYSTEM_UI flag (#3386)

This commit is contained in:
YangJH 2023-12-01 05:16:24 +09:00 committed by GitHub
parent d05231d76b
commit cac802fb77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,9 @@ import android.widget.ImageButton;
import androidx.activity.OnBackPressedCallback; import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.WorkerThread; 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.AudioAttributes;
import androidx.media3.common.C; import androidx.media3.common.C;
import androidx.media3.common.Format; 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.LifecycleEventListener;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.google.ads.interactivemedia.v3.api.AdEvent; import com.google.ads.interactivemedia.v3.api.AdEvent;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -1969,34 +1973,27 @@ public class ReactExoplayerView extends FrameLayout implements
} }
Window window = activity.getWindow(); Window window = activity.getWindow();
View decorView = window.getDecorView(); WindowInsetsControllerCompat controller = new WindowInsetsControllerCompat(window, window.getDecorView());
int uiOptions;
if (isFullscreen) { 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(); eventEmitter.fullscreenWillPresent();
if (controls && fullScreenPlayerView != null) { if (controls && fullScreenPlayerView != null) {
fullScreenPlayerView.show(); fullScreenPlayerView.show();
} }
post(() -> { UiThreadUtil.runOnUiThread(() -> {
decorView.setSystemUiVisibility(uiOptions); WindowCompat.setDecorFitsSystemWindows(window, false);
controller.hide(WindowInsetsCompat.Type.systemBars());
controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
eventEmitter.fullscreenDidPresent(); eventEmitter.fullscreenDidPresent();
}); });
} else { } else {
uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
eventEmitter.fullscreenWillDismiss(); eventEmitter.fullscreenWillDismiss();
if (controls && fullScreenPlayerView != null) { if (controls && fullScreenPlayerView != null) {
fullScreenPlayerView.dismiss(); fullScreenPlayerView.dismiss();
reLayout(exoPlayerView); reLayout(exoPlayerView);
} }
post(() -> { UiThreadUtil.runOnUiThread(() -> {
decorView.setSystemUiVisibility(uiOptions); WindowCompat.setDecorFitsSystemWindows(window, true);
controller.show(WindowInsetsCompat.Type.systemBars());
eventEmitter.fullscreenDidDismiss(); eventEmitter.fullscreenDidDismiss();
}); });
} }