diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java index 31201d8337..1614af49ad 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java @@ -99,7 +99,7 @@ public class NavigationBarWidget extends UIWidget implements WSession.Navigation private static final int POPUP_NOTIFICATION_ID = 3; private static final int WEB_APP_ADDED_NOTIFICATION_ID = 4; - private static boolean disabledHeadlockForVRVideo; + private boolean shouldRestoreHeadLockOnVRVideoExit; public interface NavigationListener { void onBack(); @@ -683,12 +683,7 @@ public void onMediaFullScreen(@NonNull WMediaSession mediaSession, boolean aFull } if (mAutoSelectedProjection != VIDEO_PROJECTION_NONE && autoEnter.get()) { - SettingsStore settingsStore = SettingsStore.getInstance(getContext()); - if (settingsStore.isHeadLockEnabled()) { - settingsStore.setHeadLockEnabled(false); - disabledHeadlockForVRVideo = true; - } - + disableHeadlockForVRVideo(); mViewModel.setAutoEnteredVRVideo(true); postDelayed(() -> enterVRVideo(mAutoSelectedProjection), 300); } else { @@ -704,9 +699,6 @@ public void onMediaFullScreen(@NonNull WMediaSession mediaSession, boolean aFull if (isInVRVideo()) { exitVRVideo(); - if (disabledHeadlockForVRVideo) { - SettingsStore.getInstance(getContext()).setHeadLockEnabled(true); - } } } } @@ -766,22 +758,13 @@ private void enterFullScreenMode() { exitVRVideo(); mAttachedWindow.reCenterFrontWindow(); } else { - SettingsStore settingsStore = SettingsStore.getInstance(getContext()); - if (settingsStore.isHeadLockEnabled()) { - settingsStore.setHeadLockEnabled(false); - disabledHeadlockForVRVideo = true; - } - + disableHeadlockForVRVideo(); // Reproject while reproducing VRVideo mWidgetManager.showVRVideo(mAttachedWindow.getHandle(), projection); } closeFloatingMenus(); } else { - SettingsStore settingsStore = SettingsStore.getInstance(getContext()); - if (settingsStore.isHeadLockEnabled()) { - settingsStore.setHeadLockEnabled(false); - disabledHeadlockForVRVideo = true; - } + disableHeadlockForVRVideo(); enterVRVideo(projection); } }); @@ -795,6 +778,14 @@ private void enterFullScreenMode() { mWidgetManager.pushWorldBrightness(mBrightnessWidget, mBrightnessWidget.getSelectedBrightness()); } + private void disableHeadlockForVRVideo() { + SettingsStore settingsStore = SettingsStore.getInstance(getContext()); + if (settingsStore.isHeadLockEnabled()) { + settingsStore.setHeadLockEnabled(false); + shouldRestoreHeadLockOnVRVideoExit = true; + } + } + private void exitFullScreenMode() { mWidgetPlacement = mBeforeFullscreenPlacement; updateWidget(); @@ -1019,7 +1010,7 @@ private void exitVRVideo() { // Reposition UI in front of the user when exiting a VR video. mWidgetManager.recenterUIYaw(WidgetManagerDelegate.YAW_TARGET_ALL); - if (disabledHeadlockForVRVideo) { + if (shouldRestoreHeadLockOnVRVideoExit) { SettingsStore.getInstance(getContext()).setHeadLockEnabled(true); } }