Skip to content

Commit

Permalink
[PCCT] Fix a visual glitch after exiting fullscreen mode
Browse files Browse the repository at this point in the history
Restoring the window/view dimension after exiting fullscreen mode had
a bug resulting in a wrong navigation bar height. This CL correctly
restores the dimensions that were altered in fullscreen mode.

Bug: 1385148
Change-Id: I2cf8f20401bfd5043b1bb3e00dd47b4158909350
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4034586
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1073587}
  • Loading branch information
JinsukKim authored and Chromium LUCI CQ committed Nov 18, 2022
1 parent 1ad427b commit ca3e0be
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable;
Expand Down Expand Up @@ -119,6 +120,7 @@ public class PartialCustomTabHeightStrategy extends CustomTabHeightStrategy
private final @Px int mUnclampedInitialHeight;
private final FullscreenManager mFullscreenManager;
private final boolean mAlwaysShowNavbarButtons;
private final Rect mFullscreenRestoreRect = new Rect();

private static boolean sHasLoggedImmersiveModeConfirmationSetting;

Expand Down Expand Up @@ -921,12 +923,12 @@ public boolean onDragEnd(int flingDistance) {
@Override
public void onEnterFullscreen(Tab tab, FullscreenOptions options) {
if (isFullscreen()) return;
WindowManager.LayoutParams attrs = new WindowManager.LayoutParams();
attrs.copyFrom(mActivity.getWindow().getAttributes());
WindowManager.LayoutParams attrs = mActivity.getWindow().getAttributes();
mFullscreenRestoreRect.set(attrs.x, attrs.y, attrs.width, attrs.height);
attrs.x = 0;
attrs.y = 0;
attrs.height = MATCH_PARENT;
attrs.width = MATCH_PARENT;
attrs.height = MATCH_PARENT;
mActivity.getWindow().setAttributes(attrs);
setTopMargins(0, 0);
maybeInvokeResizeCallback();
Expand All @@ -935,8 +937,13 @@ public void onEnterFullscreen(Tab tab, FullscreenOptions options) {
@Override
public void onExitFullscreen(Tab tab) {
if (!isFullscreen()) return;
setTopMargins(mShadowOffset, getHandleHeight() + mShadowOffset);
initializeHeight();
WindowManager.LayoutParams attrs = mActivity.getWindow().getAttributes();
attrs.x = mFullscreenRestoreRect.left;
attrs.y = mFullscreenRestoreRect.top;
attrs.width = mFullscreenRestoreRect.right;
attrs.height = mFullscreenRestoreRect.bottom;
mActivity.getWindow().setAttributes(attrs);
updateShadowOffset();
maybeInvokeResizeCallback();
}

Expand Down

0 comments on commit ca3e0be

Please sign in to comment.