Set the 'visibility' of 'FlutterView' to the previous one in 'FragmentActivityAndFragment.onStart' (flutter/engine#34601)

This commit is contained in:
ColdPaleLight
2022-07-12 15:05:05 +08:00
committed by GitHub
parent b11642aae1
commit 94376125a0
2 changed files with 22 additions and 2 deletions

View File

@@ -87,6 +87,7 @@ import java.util.List;
private boolean isFlutterUiDisplayed;
private boolean isFirstFrameRendered;
private boolean isAttached;
private Integer previousVisibility;
@NonNull
private final FlutterUiDisplayListener flutterUiDisplayListener =
@@ -399,7 +400,9 @@ import java.util.List;
// screen when unlocked. We can work around this by changing the visibility of FlutterView in
// onStart and onStop.
// See https://github.com/flutter/flutter/issues/93276
flutterView.setVisibility(View.VISIBLE);
if (previousVisibility != null) {
flutterView.setVisibility(previousVisibility);
}
}
/**
@@ -599,6 +602,7 @@ import java.util.List;
// screen when unlocked. We can work around this by changing the visibility of FlutterView in
// onStart and onStop.
// See https://github.com/flutter/flutter/issues/93276
previousVisibility = flutterView.getVisibility();
flutterView.setVisibility(View.GONE);
}

View File

@@ -1038,11 +1038,27 @@ public class FlutterActivityAndFragmentDelegateTest {
// Verify that the flutterView is visible.
assertEquals(View.VISIBLE, delegate.flutterView.getVisibility());
delegate.onStop();
// Verify that the flutterView is not visible.
// Verify that the flutterView is gone.
assertEquals(View.GONE, delegate.flutterView.getVisibility());
delegate.onStart();
// Verify that the flutterView is visible.
assertEquals(View.VISIBLE, delegate.flutterView.getVisibility());
delegate.flutterView.setVisibility(View.INVISIBLE);
delegate.onStop();
// Verify that the flutterView is gone.
assertEquals(View.GONE, delegate.flutterView.getVisibility());
delegate.onStart();
// Verify that the flutterView is invisible.
assertEquals(View.INVISIBLE, delegate.flutterView.getVisibility());
delegate.flutterView.setVisibility(View.GONE);
delegate.onStop();
// Verify that the flutterView is gone.
assertEquals(View.GONE, delegate.flutterView.getVisibility());
delegate.onStart();
// Verify that the flutterView is gone.
assertEquals(View.GONE, delegate.flutterView.getVisibility());
}
@Test