From 9e66e709476ef2055b19021af6e4908ba2ea68f8 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Tue, 27 Nov 2018 19:54:23 +0100 Subject: [PATCH] Don't remember fullscreen resize on restart (#856) --- .../mozilla/vrbrowser/ui/widgets/BrowserWidget.java | 12 ++++++++++-- .../vrbrowser/ui/widgets/NavigationBarWidget.java | 8 ++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/BrowserWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/BrowserWidget.java index e12de7bc6..a15cd3255 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/BrowserWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/BrowserWidget.java @@ -47,6 +47,7 @@ public class BrowserWidget extends UIWidget implements SessionStore.SessionChang private int mBorderWidth; Runnable mFirstDrawCallback; private boolean mIsInVRVideoMode; + private boolean mSaveResizeChanges; public BrowserWidget(Context aContext, int aSessionId) { super(aContext); @@ -67,6 +68,7 @@ public BrowserWidget(Context aContext, int aSessionId) { handleResizeEvent(SettingsStore.getInstance(getContext()).getBrowserWorldWidth(), SettingsStore.getInstance(getContext()).getBrowserWorldHeight()); + mSaveResizeChanges = true; } @Override @@ -184,6 +186,10 @@ public int getTextureHeight() { return mHeight; } + public void setSaveResizeChanges(boolean aSave) { + mSaveResizeChanges = aSave; + } + @Override public void setSurfaceTexture(SurfaceTexture aTexture, final int aWidth, final int aHeight) { GeckoSession session = SessionStore.get().getSession(mSessionId); @@ -288,8 +294,10 @@ public void handleResizeEvent(float aWorldWidth, float aWorldHeight) { mWidgetPlacement.worldWidth = aWorldWidth; mWidgetManager.updateWidget(this); - SettingsStore.getInstance(getContext()).setBrowserWorldWidth(aWorldWidth); - SettingsStore.getInstance(getContext()).setBrowserWorldHeight(aWorldHeight); + if (mSaveResizeChanges) { + SettingsStore.getInstance(getContext()).setBrowserWorldWidth(aWorldWidth); + SettingsStore.getInstance(getContext()).setBrowserWorldHeight(aWorldHeight); + } } @Override 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 bb0ca28b6..8fbbc254d 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 @@ -355,10 +355,7 @@ public void setBookmarksWidget(BookmarksWidget aWidget) { } private void setFullScreenSize() { - SettingsStore settings = SettingsStore.getInstance(getContext()); mSizeBeforeFullScreen.copyFrom(mBrowserWidget.getPlacement()); - final float oldWidth = settings.getBrowserWorldWidth(); - final float oldHeight = settings.getBrowserWorldHeight(); // Set browser fullscreen size float aspect = SettingsStore.getInstance(getContext()).getWindowAspect(); Media media = SessionStore.get().getFullScreenVideo(); @@ -366,9 +363,6 @@ private void setFullScreenSize() { aspect = (float)media.getWidth() / (float)media.getHeight(); } mBrowserWidget.resizeByMultiplier(aspect,1.75f); - // Save the old values on settings to prevent the fullscreen size being used on a app restart - SettingsStore.getInstance(getContext()).setBrowserWorldWidth(oldWidth); - SettingsStore.getInstance(getContext()).setBrowserWorldHeight(oldHeight); } private void enterFullScreenMode() { @@ -376,6 +370,7 @@ private void enterFullScreenMode() { return; } + mBrowserWidget.setSaveResizeChanges(false); setFullScreenSize(); mWidgetManager.pushBackHandler(mFullScreenBackHandler); mIsInFullScreenMode = true; @@ -426,6 +421,7 @@ private void exitFullScreenMode() { mBrowserWidget.getPlacement().copyFrom(mSizeBeforeFullScreen); mWidgetManager.updateWidget(mBrowserWidget); + mBrowserWidget.setSaveResizeChanges(true); mIsInFullScreenMode = false; mWidgetManager.popBackHandler(mFullScreenBackHandler);