From b19f56ba1f9ea2b3311b5a723e22914a421a8a40 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Mon, 22 Jul 2019 21:36:17 +0200 Subject: [PATCH] Do not resize fullscreen window size if the window size is actually bigger than the fullscreen min size threshold (#1379) --- .../vrbrowser/ui/widgets/NavigationBarWidget.java | 8 +++++++- .../mozilla/vrbrowser/ui/widgets/WindowWidget.java | 14 ++++++++++++++ app/src/main/res/values/dimen.xml | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) 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 ffd66924d..de92f4226 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 @@ -379,13 +379,19 @@ public void setBrowserWidget(WindowWidget aWidget) { private void setFullScreenSize() { mPlacementBeforeResize.copyFrom(mWindowWidget.getPlacement()); + final float minScale = WidgetPlacement.floatDimension(getContext(), R.dimen.window_fullscreen_min_scale); // 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(); } - mWindowWidget.resizeByMultiplier(aspect,1.75f); + float scale = mWindowWidget.getCurrentScale(); + // Enforce min fullscreen size. + // If current window area is larger only resize if the aspect changes (e.g. media). + if (scale < minScale || aspect != mWindowWidget.getCurrentAspect()) { + mWindowWidget.resizeByMultiplier(aspect, Math.max(scale, minScale)); + } } private void enterFullScreenMode() { 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 97dea4bd3..0c6d82940 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 @@ -254,6 +254,20 @@ public void resizeByMultiplier(float aspect, float multiplier) { handleResizeEvent(targetWidth, targetHeight); } + public float getCurrentScale() { + float currentAspect = getCurrentAspect(); + float currentWorldHeight = mWidgetPlacement.worldWidth / currentAspect; + float currentArea = mWidgetPlacement.worldWidth * currentWorldHeight; + float defaultWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.window_world_width); + float defaultHeight = defaultWidth / SettingsStore.getInstance(getContext()).getWindowAspect(); + float defaultArea = defaultWidth * defaultHeight; + return currentArea / defaultArea; + } + + public float getCurrentAspect() { + return (float) mWidgetPlacement.width / (float) mWidgetPlacement.height; + } + public int getBorderWidth() { return mBorderWidth; } diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml index a0cd6170b..6102f8341 100644 --- a/app/src/main/res/values/dimen.xml +++ b/app/src/main/res/values/dimen.xml @@ -8,6 +8,7 @@ 0.2 -4.2 1.5 + 1.75 720dp