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

Don't remember fullscreen resize on restart #856

Merged
merged 1 commit into from
Nov 27, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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