From 50e273525314dc2b38103d821c48e6918b7e9b48 Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Fri, 26 Jun 2020 05:36:23 -0700 Subject: [PATCH] Only load home page if session uri is blank on new intent. (#3545) Fixes #3530 Fixes #3543 --- .../org/mozilla/vrbrowser/VRBrowserActivity.java | 2 +- .../org/mozilla/vrbrowser/ui/widgets/WindowWidget.java | 10 +++------- .../org/mozilla/vrbrowser/ui/widgets/Windows.java | 1 - 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index 2d601b836..de4612ad4 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -643,7 +643,7 @@ void loadFromIntent(final Intent intent) { } mWindows.openNewTabAfterRestore(uri.toString(), location); } else { - mWindows.getFocusedWindow().loadHomeIfNotRestored(); + mWindows.getFocusedWindow().loadHomeIfBlank(); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java index 18536a8e1..92ca24e52 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java @@ -126,7 +126,6 @@ public class WindowWidget extends UIWidget implements SessionChangeListener, private Windows.WindowPlacement mWindowPlacement = Windows.WindowPlacement.FRONT; private Windows.WindowPlacement mWindowPlacementBeforeFullscreen = Windows.WindowPlacement.FRONT; private float mMaxWindowScale = 3; - private boolean mIsRestored = false; private CopyOnWriteArrayList mListeners; boolean mActive = false; boolean mHovered = false; @@ -382,8 +381,9 @@ public void close() { mListeners.clear(); } - public void loadHomeIfNotRestored() { - if (!mIsRestored) { + public void loadHomeIfBlank() { + final String currentUri = mSession.getCurrentUri(); + if ((currentUri == null) || currentUri.isEmpty() || UrlUtils.isBlankUri(getContext(), mSession.getCurrentUri())) { loadHome(); } } @@ -397,10 +397,6 @@ public void loadHome() { } } - protected void setRestored(boolean restored) { - mIsRestored = restored; - } - private void setView(View view, boolean switchSurface) { Runnable setView = () -> { if (switchSurface) { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java index 9e44b3f6e..799077de3 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java @@ -333,7 +333,6 @@ private WindowWidget addRestoredWindow(@NonNull WindowState aState, @Nullable Se newWindow.getPlacement().width = aState.textureWidth; newWindow.getPlacement().height = aState.textureHeight; newWindow.getPlacement().worldWidth = aState.worldWidth; - newWindow.setRestored(true); placeWindow(newWindow, aState.placement); if (newWindow.getSession() != null) { if (aState.panelType != null) {