summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2020-06-09 09:25:03 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-09 09:25:03 +0000
commit8a931d7f085a1534ddc1bcf74907aee27632ff54 (patch)
tree189db15f306324dd87370ba53b8be8bb55022a96 /core/java
parent99b6143fb29609fd917c191d457b166d49601d93 (diff)
parentd49ab516fe8722f436e2ff095aa630c1328984c0 (diff)
Merge "Insets: allow controlling insets as long as the window is covering in the relevant direction" into rvc-dev am: 5b12e07b9c am: 37afe34234 am: cbfdd45165 am: d49ab516fe
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11632046 Change-Id: I5e7e7a5c229e2e6fd2e786545da392b18d7aff80
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/InsetsController.java14
-rw-r--r--core/java/android/view/InsetsState.java38
2 files changed, 40 insertions, 12 deletions
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index ef9edc6c0741..e4d53c64a063 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -791,7 +791,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
WindowInsetsAnimationControlListener listener,
boolean fromIme, long durationMs, @Nullable Interpolator interpolator,
@AnimationType int animationType) {
- if (!checkDisplayFramesForControlling()) {
+ if ((mState.calculateUncontrollableInsetsFromFrame(mFrame) & types) != 0) {
listener.onCancelled(null);
return;
}
@@ -801,13 +801,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
false /* useInsetsAnimationThread */);
}
- private boolean checkDisplayFramesForControlling() {
-
- // If the frame of our window doesn't span the entire display, the control API makes very
- // little sense, as we don't deal with negative insets. So just cancel immediately.
- return mState.getDisplayFrame().equals(mFrame);
- }
-
private void controlAnimationUnchecked(@InsetsType int types,
@Nullable CancellationSignal cancellationSignal,
WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme,
@@ -1285,9 +1278,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
}
private @InsetsType int calculateControllableTypes() {
- if (!checkDisplayFramesForControlling()) {
- return 0;
- }
@InsetsType int result = 0;
for (int i = mSourceConsumers.size() - 1; i >= 0; i--) {
InsetsSourceConsumer consumer = mSourceConsumers.valueAt(i);
@@ -1295,7 +1285,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
result |= toPublicType(consumer.mType);
}
}
- return result;
+ return result & ~mState.calculateUncontrollableInsetsFromFrame(mFrame);
}
/**
diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java
index 3822ee59b4aa..f0bca260be38 100644
--- a/core/java/android/view/InsetsState.java
+++ b/core/java/android/view/InsetsState.java
@@ -245,6 +245,44 @@ public class InsetsState implements Parcelable {
return insets.toRect();
}
+ /**
+ * Calculate which insets *cannot* be controlled, because the frame does not cover the
+ * respective side of the inset.
+ *
+ * If the frame of our window doesn't cover the entire inset, the control API makes very
+ * little sense, as we don't deal with negative insets.
+ */
+ @InsetsType
+ public int calculateUncontrollableInsetsFromFrame(Rect frame) {
+ int blocked = 0;
+ for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
+ InsetsSource source = mSources.get(type);
+ if (source == null) {
+ continue;
+ }
+ if (!canControlSide(frame, getInsetSide(
+ source.calculateInsets(frame, true /* ignoreVisibility */)))) {
+ blocked |= toPublicType(type);
+ }
+ }
+ return blocked;
+ }
+
+ private boolean canControlSide(Rect frame, int side) {
+ switch (side) {
+ case ISIDE_LEFT:
+ case ISIDE_RIGHT:
+ return frame.left == mDisplayFrame.left && frame.right == mDisplayFrame.right;
+ case ISIDE_TOP:
+ case ISIDE_BOTTOM:
+ 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,
Insets[] typeInsetsMap, @Nullable @InternalInsetsSide SparseIntArray typeSideMap,
@Nullable boolean[] typeVisibilityMap) {