From d8133b0f06750599dda337495e0fbb3eb0fc6fe5 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Fri, 29 May 2020 21:35:10 +0200 Subject: [PATCH] Fixes #3426 Fixes fullscreen exit when opening a tab (#3434) * Fixes fullscreen exit when opening a tab * Fix fullscreen mode when a link is opened in a new session/window * Update the playback controls when session is changed --- .../ui/widgets/NavigationBarWidget.java | 12 ++++++++---- .../ui/widgets/NotificationManager.java | 2 +- .../vrbrowser/ui/widgets/WindowWidget.java | 19 ++++++++++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) 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 1e3d92079..272f2aa2b 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 @@ -486,7 +486,7 @@ public void detachFromWindow() { exitResizeMode(ResizeAction.RESTORE_SIZE); } if (mAttachedWindow != null && mAttachedWindow.isFullScreen()) { - exitFullScreenMode(); + mAttachedWindow.setIsFullScreen(false); } if (getSession() != null) { @@ -570,7 +570,7 @@ private void cleanSession(@NonNull Session aSession) { public void onSessionChanged(@NonNull Session aOldSession, @NonNull Session aSession) { cleanSession(aOldSession); setUpSession(aSession); - exitFullScreenMode(); + mAttachedWindow.setIsFullScreen(false); } @Override @@ -613,6 +613,8 @@ protected void onDraw(Canvas canvas) { } private void enterFullScreenMode() { + hideAllNotifications(); + mWidgetManager.pushBackHandler(mFullScreenBackHandler); AnimationHelper.fadeIn(mBinding.navigationBarFullscreen.fullScreenModeContainer, AnimationHelper.FADE_ANIMATION_DURATION, null); @@ -648,6 +650,8 @@ private void enterFullScreenMode() { } private void exitFullScreenMode() { + hideAllNotifications(); + if (mAttachedWindow == null || !mAttachedWindow.isFullScreen()) { return; } @@ -675,6 +679,8 @@ private void exitFullScreenMode() { } private void enterResizeMode() { + hideAllNotifications(); + if (mAttachedWindow.isResizing()) { return; } @@ -721,8 +727,6 @@ private void enterResizeMode() { } } - hideAllNotifications(); - // Update preset styles } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NotificationManager.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NotificationManager.java index e9cd73506..67d435a1d 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NotificationManager.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NotificationManager.java @@ -10,7 +10,6 @@ import androidx.annotation.StringRes; import org.mozilla.vrbrowser.R; -import org.mozilla.vrbrowser.VRBrowserApplication; import org.mozilla.vrbrowser.ui.views.UIButton; import org.mozilla.vrbrowser.ui.widgets.NotificationManager.Notification.NotificationPosition; @@ -88,6 +87,7 @@ public static class Builder { public Builder(@NonNull UIWidget parent) { this.parent = parent; + this.view = parent; this.density = R.dimen.tooltip_default_density; } 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 2b0cdf96a..e67aaacbb 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 @@ -1165,6 +1165,19 @@ public void onCurrentSessionChange(GeckoSession aOldSession, GeckoSession aSessi mViewModel.setIsPrivateSession(aSession.getSettings().getUsePrivateMode()); + // Update the title bar media controls state + boolean mediaAvailable = mSession.getActiveVideo() != null; + if (mediaAvailable) { + if (mSession.getActiveVideo().isPlayed()) { + mViewModel.setIsMediaPlaying(true); + } + mViewModel.setIsMediaAvailable(true); + + } else { + mViewModel.setIsMediaAvailable(false); + mViewModel.setIsMediaPlaying(false); + } + waitForFirstPaint(); } @@ -1179,7 +1192,11 @@ public void onStackSession(Session aSession) { Session current = mSession; setSession(aSession, WindowWidget.DEACTIVATE_CURRENT_SESSION); current.captureBackgroundBitmap(getWindowWidth(), getWindowHeight()).thenAccept(aVoid -> current.setActive(false)); - mWidgetManager.getWindows().showTabAddedNotification(); + + // Delay the notification so it it's displayed in the tray when a link in + // full screen ones in a new tab. Otherwise the navigation bar has not the correct size and + // the notification is misplaced. + postDelayed(() -> mWidgetManager.getWindows().showTabAddedNotification(), 500); GleanMetricsService.Tabs.openedCounter(GleanMetricsService.Tabs.TabSource.BROWSER); }