From 404d8f2b448716ab5f6fc2bfdd34a81633d37d23 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Wed, 21 Nov 2018 14:28:15 +0100 Subject: [PATCH] Fix stuck in fullscreen mode when exiting private browsing. Fixes #739 --- .../ui/widgets/NavigationBarWidget.java | 7 +++++++ .../vrbrowser/ui/widgets/TopBarWidget.java | 20 +++---------------- .../vrbrowser/ui/widgets/UIWidget.java | 2 +- 3 files changed, 11 insertions(+), 18 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 18afa6b65c..a32c82f58c 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 @@ -761,6 +761,13 @@ public void onCurrentSessionChange(GeckoSession aSession, int aId) { for (CustomUIButton button : mButtons) { button.setPrivateMode(isPrivateMode); } + boolean isFullScreen = SessionStore.get().isInFullScreen(aSession); + if (isFullScreen && !mIsInFullScreenMode) { + enterFullScreenMode(); + } else if (!isFullScreen && mIsInFullScreenMode) { + exitVRVideo(); + exitFullScreenMode(); + } } // NavigationURLBarDelegate diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TopBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TopBarWidget.java index 37f6fcf56c..009dee9e9e 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TopBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TopBarWidget.java @@ -47,10 +47,6 @@ private void initialize(Context aContext) { if (mAudio != null) { mAudio.playSound(AudioEngine.Sound.CLICK); } - - if (SessionStore.get().isInFullScreen()) { - SessionStore.get().exitFullScreen(); - } SessionStore.get().exitPrivateMode(); }); @@ -65,7 +61,6 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { Context context = getContext(); aPlacement.width = WidgetPlacement.dpDimension(context, R.dimen.top_bar_width); aPlacement.height = WidgetPlacement.dpDimension(context, R.dimen.top_bar_height); - // FIXME: Something wrong with the DPI ratio? Revert to top_bar_world_width when fixed aPlacement.worldWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.browser_world_width) * aPlacement.width/getWorldWidth(); aPlacement.translationY = WidgetPlacement.unitFromMeters(context, R.dimen.top_bar_world_y); aPlacement.anchorX = 0.5f; @@ -109,6 +104,7 @@ public void onCurrentSessionChange(GeckoSession aSession, int aId) { mCloseButton.setPrivateMode(isPrivateMode); } + @Override public void setVisible(boolean isVisible) { getPlacement().visible = isVisible; @@ -121,19 +117,9 @@ public void setVisible(boolean isVisible) { // WidgetManagerDelegate.UpdateListener @Override public void onWidgetUpdate(Widget aWidget) { - if (aWidget != mBrowserWidget) { - return; + if (aWidget == mBrowserWidget && isVisible()) { + mWidgetManager.updateWidget(this); } - // Browser window may have been resized, adjust the navigation bar - float targetWidth = aWidget.getPlacement().worldWidth; - // FIXME: Something wrong with the DPI ratio? Revert to top_bar_world_width when fixed - float defaultWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.browser_world_width) * 40/720; - targetWidth = Math.max(defaultWidth, targetWidth); - - float ratio = targetWidth / defaultWidth; - mWidgetPlacement.worldWidth = targetWidth; - mWidgetPlacement.width = (int) (WidgetPlacement.dpDimension(getContext(), R.dimen.top_bar_width) * ratio); - mWidgetManager.updateWidget(this); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UIWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UIWidget.java index d598f0e1fd..dacc759ffe 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UIWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UIWidget.java @@ -64,10 +64,10 @@ private void initialize() { mWidgetManager = (WidgetManagerDelegate) getContext(); mWidgetPlacement = new WidgetPlacement(getContext()); mHandle = mWidgetManager.newWidgetHandle(); + mWorldWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.world_width); initializeWidgetPlacement(mWidgetPlacement); mInitialWidth = mWidgetPlacement.width; mInitialHeight = mWidgetPlacement.height; - mWorldWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.world_width); // Transparent border useful for TimeWarp Layers and better aliasing. int padding_dp = 1; // 1 dps final float scale = getResources().getDisplayMetrics().density;