Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Don't remember fullscreen resize on restart (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and bluemarvin committed Nov 27, 2018
1 parent f88f5cf commit 9e66e70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -67,6 +68,7 @@ public BrowserWidget(Context aContext, int aSessionId) {

handleResizeEvent(SettingsStore.getInstance(getContext()).getBrowserWorldWidth(),
SettingsStore.getInstance(getContext()).getBrowserWorldHeight());
mSaveResizeChanges = true;
}

@Override
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,27 +355,22 @@ 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();
if (media != null && media.getWidth() > 0 && media.getHeight() > 0) {
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() {
if (mIsInFullScreenMode) {
return;
}

mBrowserWidget.setSaveResizeChanges(false);
setFullScreenSize();
mWidgetManager.pushBackHandler(mFullScreenBackHandler);
mIsInFullScreenMode = true;
Expand Down Expand Up @@ -426,6 +421,7 @@ private void exitFullScreenMode() {

mBrowserWidget.getPlacement().copyFrom(mSizeBeforeFullScreen);
mWidgetManager.updateWidget(mBrowserWidget);
mBrowserWidget.setSaveResizeChanges(true);

mIsInFullScreenMode = false;
mWidgetManager.popBackHandler(mFullScreenBackHandler);
Expand Down

0 comments on commit 9e66e70

Please sign in to comment.