Merge "Fix InsetsState#calculateUncontrollableInsetsFromFrame" into tm-qpr-dev am: 12b430a7a0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18670487 Change-Id: Ic5097a6c21609d76221c0e326d627c3977bfc769 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -404,27 +404,20 @@ public class InsetsState implements Parcelable {
|
|||||||
if (source == null) {
|
if (source == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!canControlSide(frame, getInsetSide(
|
if (!canControlSource(frame, source)) {
|
||||||
source.calculateInsets(frame, true /* ignoreVisibility */)))) {
|
|
||||||
blocked |= toPublicType(type);
|
blocked |= toPublicType(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return blocked;
|
return blocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canControlSide(Rect frame, int side) {
|
private static boolean canControlSource(Rect frame, InsetsSource source) {
|
||||||
switch (side) {
|
final Insets insets = source.calculateInsets(frame, true /* ignoreVisibility */);
|
||||||
case ISIDE_LEFT:
|
final Rect sourceFrame = source.getFrame();
|
||||||
case ISIDE_RIGHT:
|
final int sourceWidth = sourceFrame.width();
|
||||||
return frame.left == mDisplayFrame.left && frame.right == mDisplayFrame.right;
|
final int sourceHeight = sourceFrame.height();
|
||||||
case ISIDE_TOP:
|
return insets.left == sourceWidth || insets.right == sourceWidth
|
||||||
case ISIDE_BOTTOM:
|
|| insets.top == sourceHeight || insets.bottom == sourceHeight;
|
||||||
return frame.top == mDisplayFrame.top && frame.bottom == mDisplayFrame.bottom;
|
|
||||||
case ISIDE_FLOATING:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processSource(InsetsSource source, Rect relativeFrame, boolean ignoreVisibility,
|
private void processSource(InsetsSource source, Rect relativeFrame, boolean ignoreVisibility,
|
||||||
|
|||||||
@@ -214,19 +214,23 @@ public class InsetsControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFrameDoesntMatchDisplay() {
|
public void testFrameDoesntOverlapWithInsets() {
|
||||||
mController.onFrameChanged(new Rect(0, 0, 100, 100));
|
|
||||||
mController.getState().setDisplayFrame(new Rect(0, 0, 200, 200));
|
|
||||||
InsetsSourceControl control =
|
|
||||||
new InsetsSourceControl(
|
|
||||||
ITYPE_STATUS_BAR, mLeash, new Point(), Insets.of(0, 10, 0, 0));
|
|
||||||
mController.onControlsChanged(new InsetsSourceControl[] { control });
|
|
||||||
WindowInsetsAnimationControlListener controlListener =
|
WindowInsetsAnimationControlListener controlListener =
|
||||||
mock(WindowInsetsAnimationControlListener.class);
|
mock(WindowInsetsAnimationControlListener.class);
|
||||||
mController.controlWindowInsetsAnimation(0, 0 /* durationMs */, new LinearInterpolator(),
|
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||||
new CancellationSignal(), controlListener);
|
// The frame doesn't overlap with status bar.
|
||||||
mController.addOnControllableInsetsChangedListener(
|
mController.onFrameChanged(new Rect(0, 10, 100, 100));
|
||||||
(controller, typeMask) -> assertEquals(0, typeMask));
|
|
||||||
|
InsetsSourceControl control =
|
||||||
|
new InsetsSourceControl(
|
||||||
|
ITYPE_STATUS_BAR, mLeash, new Point(), Insets.of(0, 10, 0, 0));
|
||||||
|
mController.onControlsChanged(new InsetsSourceControl[]{control});
|
||||||
|
mController.controlWindowInsetsAnimation(0, 0 /* durationMs */,
|
||||||
|
new LinearInterpolator(),
|
||||||
|
new CancellationSignal(), controlListener);
|
||||||
|
mController.addOnControllableInsetsChangedListener(
|
||||||
|
(controller, typeMask) -> assertEquals(0, typeMask));
|
||||||
|
});
|
||||||
verify(controlListener).onCancelled(null);
|
verify(controlListener).onCancelled(null);
|
||||||
verify(controlListener, never()).onReady(any(), anyInt());
|
verify(controlListener, never()).onReady(any(), anyInt());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textViewControllableInsets"
|
android:id="@+id/textViewControllableInsets"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="5dp" />
|
android:layout_margin="5dp" />
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<!-- The item positions should match the flag values respectively. -->
|
<!-- The item positions should match the flag values respectively. -->
|
||||||
<string-array name="behaviors">
|
<string-array name="behaviors">
|
||||||
<item>BEHAVIOR_SHOW_BARS_BY_TOUCH</item>
|
<item>BEHAVIOR_SHOW_BARS_BY_TOUCH (deprecated)</item>
|
||||||
<item>BEHAVIOR_DEFAULT</item>
|
<item>BEHAVIOR_DEFAULT</item>
|
||||||
<item>BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE</item>
|
<item>BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|||||||
@@ -83,7 +83,51 @@ public class ControllerActivity extends Activity implements View.OnApplyWindowIn
|
|||||||
final View contentView = findViewById(R.id.content);
|
final View contentView = findViewById(R.id.content);
|
||||||
contentView.setOnApplyWindowInsetsListener(this);
|
contentView.setOnApplyWindowInsetsListener(this);
|
||||||
contentView.getWindowInsetsController().addOnControllableInsetsChangedListener(
|
contentView.getWindowInsetsController().addOnControllableInsetsChangedListener(
|
||||||
(c, types) -> mTextControllableInsets.setText("ControllableInsetsTypes=" + types));
|
(c, types) -> mTextControllableInsets.setText(
|
||||||
|
"ControllableInsetsTypes:\n" + insetsTypesToString(types)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String insetsTypesToString(int types) {
|
||||||
|
if (types == 0) {
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
if ((types & Type.statusBars()) != 0) {
|
||||||
|
types &= ~Type.statusBars();
|
||||||
|
sb.append("statusBars ");
|
||||||
|
}
|
||||||
|
if ((types & Type.navigationBars()) != 0) {
|
||||||
|
types &= ~Type.navigationBars();
|
||||||
|
sb.append("navigationBars ");
|
||||||
|
}
|
||||||
|
if ((types & Type.captionBar()) != 0) {
|
||||||
|
types &= ~Type.captionBar();
|
||||||
|
sb.append("captionBar ");
|
||||||
|
}
|
||||||
|
if ((types & Type.ime()) != 0) {
|
||||||
|
types &= ~Type.ime();
|
||||||
|
sb.append("ime ");
|
||||||
|
}
|
||||||
|
if ((types & Type.systemGestures()) != 0) {
|
||||||
|
types &= ~Type.systemGestures();
|
||||||
|
sb.append("systemGestures ");
|
||||||
|
}
|
||||||
|
if ((types & Type.mandatorySystemGestures()) != 0) {
|
||||||
|
types &= ~Type.mandatorySystemGestures();
|
||||||
|
sb.append("mandatorySystemGestures ");
|
||||||
|
}
|
||||||
|
if ((types & Type.tappableElement()) != 0) {
|
||||||
|
types &= ~Type.tappableElement();
|
||||||
|
sb.append("tappableElement ");
|
||||||
|
}
|
||||||
|
if ((types & Type.displayCutout()) != 0) {
|
||||||
|
types &= ~Type.displayCutout();
|
||||||
|
sb.append("displayCutout ");
|
||||||
|
}
|
||||||
|
if (types != 0) {
|
||||||
|
sb.append("unknownTypes:").append(types);
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user