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 8fbbc254d..c053bce0b 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 @@ -18,7 +18,6 @@ import org.mozilla.geckoview.AllowOrDeny; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoSession; -import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.geckoview.WebRequestError; import org.mozilla.vrbrowser.*; import org.mozilla.vrbrowser.audio.AudioEngine; @@ -309,6 +308,8 @@ else if (SessionStore.get().canUnstackSession()) mPrefs = PreferenceManager.getDefaultSharedPreferences(mAppContext); mPrefs.registerOnSharedPreferenceChangeListener(this); updateServoButton(); + + handleSessionState(); } @Override @@ -557,6 +558,15 @@ private void closeFloatingMenus() { } } + private void handleSessionState() { + boolean isPrivateMode = SessionStore.get().isCurrentSessionPrivate(); + + mURLBar.setPrivateMode(isPrivateMode); + for (CustomUIButton button : mButtons) { + button.setPrivateMode(isPrivateMode); + } + } + @Override public GeckoResult onNewSession(@NonNull GeckoSession aSession, @NonNull String aUri) { return null; @@ -759,12 +769,8 @@ public void onRemoveSession(GeckoSession aSession, int aId) { @Override public void onCurrentSessionChange(GeckoSession aSession, int aId) { - boolean isPrivateMode = aSession.getSettings().getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE); - mURLBar.setPrivateMode(isPrivateMode); + handleSessionState(); - for (CustomUIButton button : mButtons) { - button.setPrivateMode(isPrivateMode); - } boolean isFullScreen = SessionStore.get().isInFullScreen(aSession); if (isFullScreen && !mIsInFullScreenMode) { enterFullScreenMode(); 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 c28720aa1..1bda459ce 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 @@ -9,7 +9,6 @@ import android.util.AttributeSet; import org.mozilla.geckoview.GeckoSession; -import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.audio.AudioEngine; import org.mozilla.vrbrowser.browser.SessionStore; @@ -52,6 +51,8 @@ private void initialize(Context aContext) { SessionStore.get().addSessionChangeListener(this); mWidgetManager.addUpdateListener(this); + + handleSessionState(); } @Override @@ -97,9 +98,7 @@ public void onRemoveSession(GeckoSession aSession, int aId) { @Override public void onCurrentSessionChange(GeckoSession aSession, int aId) { - boolean isPrivateMode = aSession.getSettings().getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE); - setVisible(isPrivateMode); - mCloseButton.setPrivateMode(isPrivateMode); + handleSessionState(); } @Override @@ -112,6 +111,12 @@ public void setVisible(boolean isVisible) { mWidgetManager.removeWidget(this); } + private void handleSessionState() { + boolean isPrivateMode = SessionStore.get().isCurrentSessionPrivate(); + setVisible(isPrivateMode); + mCloseButton.setPrivateMode(isPrivateMode); + } + // WidgetManagerDelegate.UpdateListener @Override public void onWidgetUpdate(Widget aWidget) { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java index 56b8783f6..29513ea0a 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/TrayWidget.java @@ -14,7 +14,6 @@ import android.view.animation.AccelerateDecelerateInterpolator; import org.mozilla.geckoview.GeckoSession; -import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.vrbrowser.R; import org.mozilla.vrbrowser.audio.AudioEngine; import org.mozilla.vrbrowser.browser.SessionStore; @@ -113,6 +112,8 @@ private void initialize(Context aContext) { mIsLastSessionPrivate = false; SessionStore.get().addSessionChangeListener(this); + + handleSessionState(); } private OnHoverListener mButtonScaleHoverListener = (view, motionEvent) -> { @@ -218,16 +219,20 @@ public void onRemoveSession(GeckoSession aSession, int aId) { @Override public void onCurrentSessionChange(GeckoSession aSession, int aId) { - boolean isPrivateMode = aSession.getSettings().getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE); + handleSessionState(); + } + + private void handleSessionState() { + boolean isPrivateMode = SessionStore.get().isCurrentSessionPrivate(); if (isPrivateMode != mIsLastSessionPrivate) { mPrivateButton.setPrivateMode(isPrivateMode); if (isPrivateMode) { - mWidgetManager.setWorldBrightness(null, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS); + mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS); mPrivateButton.setImageResource(R.drawable.ic_tray_private_on); } else { - mWidgetManager.setWorldBrightness(null,1.0f); + mWidgetManager.popWorldBrightness(this); mPrivateButton.setImageResource(R.drawable.ic_tray_private); } }