From 25355f7b14acbee65e7835bde78b304742c19bd3 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Thu, 20 Dec 2018 11:54:52 +0100 Subject: [PATCH] Exit fullscreen on VR video exit when autoenter is used --- .../ui/widgets/NavigationBarWidget.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java index 9f9ee358d..d66b4034f 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java @@ -64,6 +64,7 @@ public class NavigationBarWidget extends UIWidget implements GeckoSession.Naviga private boolean mIsInFullScreenMode; private boolean mIsResizing; private boolean mIsInVRVideo; + private boolean mAutoEnteredVRVideo; private WidgetPlacement mSizeBeforeFullScreen; private Runnable mResizeBackHandler; private Runnable mFullScreenBackHandler; @@ -130,7 +131,15 @@ private void initialize(Context aContext) { mResizeBackHandler = () -> exitResizeMode(true); mFullScreenBackHandler = this::exitFullScreenMode; - mVRVideoBackHandler = this::exitVRVideo; + mVRVideoBackHandler = new Runnable() { + @Override + public void run() { + exitVRVideo(); + if (mAutoEnteredVRVideo) { + exitFullScreenMode(); + } + } + }; mBackButton.setOnClickListener(v -> { v.requestFocusFromTouch(); @@ -705,7 +714,10 @@ public void onFullScreen(GeckoSession session, boolean aFullScreen) { AtomicBoolean autoEnter = new AtomicBoolean(false); mAutoSelectedProjection = VideoProjectionMenuWidget.getAutomaticProjection(SessionStore.get().getUriFromSession(session), autoEnter); if (mAutoSelectedProjection != null && autoEnter.get()) { - getHandler().postDelayed(() -> enterVRVideo(mAutoSelectedProjection), 300); + mAutoEnteredVRVideo = true; + postDelayed(() -> enterVRVideo(mAutoSelectedProjection), 300); + } else { + mAutoEnteredVRVideo = false; } } else { if (mIsInVRVideo) {