Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

GaryQian
Copy link
Contributor

@GaryQian GaryQian commented May 7, 2020

These workarounds are necessary to maintain the correct behavior for padding when fullscreen.

The v1 embedding had it, but the workarounds were not moved to the v2 embedding. This PR restores the workarounds to the v2 embedding to fix the regression.

Fixes flutter/flutter#56449

@auto-assign auto-assign bot requested a review from chinmaygarde May 7, 2020 08:45
// Decide if we want to zero the padding of the sides. When in Landscape orientation,
// android may decide to place the software navigation bars on the side. When the nav
// bar is hidden, the reported insets should be removed to prevent extra useless space
// on the sides.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mirror an Android API? If so, consider adding a See: link or identifier names to help readers link the Flutter/Android concepts/APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information seems to be intentionally hidden from us to prevent people from locking users out of their phone by preventing touches to the navbar

@@ -381,6 +383,68 @@ protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight)
sendViewportMetricsToFlutter();
}

// TODO(garyq): Add support for notch cutout API
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BOTH
}

ZeroSides calculateShouldZeroSides() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What visibility should this and ZeroSides have? I'd probably shoot for private rather than expose this utility method until we have people asking us to do so.

Since this class is non-final, and this is used from onApplyWindowInsets below, we should probably require that any overrides call super.onApplyWindowSets() (if that's reasonable -- I admit I didn't read through all the code) or expect that one day someone will want us to expose this publicly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes, these should definitely be private. Not sure why I didn't make them private in the original code.

// can be used.
@TargetApi(20)
@RequiresApi(20)
int calculateBottomKeyboardInset(WindowInsets insets) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment to calculateShouldZeroSides with respect to visibility.

return ZeroSides.NONE;
}

// TODO(garyq): Use clean ways to detect keyboard instead of heuristics if possible
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, you can update this todo too for the new getInsets IME API

// can be used.
@TargetApi(20)
@RequiresApi(20)
private int calculateBottomKeyboardInset(WindowInsets insets) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we call this guessBottomKeyboardInset to reflect the certainty? :)

@xster
Copy link
Member

xster commented May 7, 2020

This PR needs tests. Fortunately everything is mockable in robolectric and should have some examples in FlutterViewTest.java

Activity activity = (Activity) getContext();
int orientation = activity.getResources().getConfiguration().orientation;
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
Context context = getContext();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This avoids casting to Activity which can be unsafe

@GaryQian GaryQian requested a review from xster May 8, 2020 13:55
@GaryQian GaryQian requested a review from cbracken May 8, 2020 20:38
@xster
Copy link
Member

xster commented May 8, 2020

Excellent tests.

LGTM

Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops some of my draft comments didn't go through

.getDefaultDisplay());
display.setRotation(1);
assertEquals(0, flutterView.getSystemUiVisibility());
when(flutterView.getWindowSystemUiVisibility())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this works? You're altering the response of the spy instance but I'm assuming FlutterView is calling getWindowSystemUiVisibility() against itself internally and not the spy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it does. It is getting the correct values internally, and executing the right branches of code. Removing this breaks it.

when(flutterEngine.getRenderer()).thenReturn(flutterRenderer);

// When we attach a new FlutterView to the engine without any system insets, the viewport
// metrics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: line break

@GaryQian GaryQian added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label May 9, 2020
@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • Please get at least one approved review before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.
  • The status or check suite Mac iOS Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label May 9, 2020
@GaryQian
Copy link
Contributor Author

GaryQian commented May 9, 2020

Manually landing, Mac iOS engine passed on rerun: https://ci.chromium.org/p/flutter/builders/try/Mac%20iOS%20Engine/2214

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Padding not working properly for full screen on android v2 embedding.
5 participants