Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #671 Tray doesn't indicate private icon on when restoring #871

Merged
merged 1 commit into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -309,6 +308,8 @@ else if (SessionStore.get().canUnstackSession())
mPrefs = PreferenceManager.getDefaultSharedPreferences(mAppContext);
mPrefs.registerOnSharedPreferenceChangeListener(this);
updateServoButton();

handleSessionState();
}

@Override
Expand Down Expand Up @@ -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<GeckoSession> onNewSession(@NonNull GeckoSession aSession, @NonNull String aUri) {
return null;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,6 +51,8 @@ private void initialize(Context aContext) {

SessionStore.get().addSessionChangeListener(this);
mWidgetManager.addUpdateListener(this);

handleSessionState();
}

@Override
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -113,6 +112,8 @@ private void initialize(Context aContext) {
mIsLastSessionPrivate = false;

SessionStore.get().addSessionChangeListener(this);

handleSessionState();
}

private OnHoverListener mButtonScaleHoverListener = (view, motionEvent) -> {
Expand Down Expand Up @@ -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);
}
}
Expand Down