summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2020-04-01 21:59:18 +0200
committerJorim Jaggi <jjaggi@google.com>2020-04-01 22:00:39 +0200
commit6f2ccea9f95c1e0d5b333cfa3695ba38627f5b9e (patch)
treef514df1b0e31f1de743b778b2bd5fb76e0dba045 /core/java/android
parent884aa6afe156ec88cfc89e9d5dac4480223c9495 (diff)
Initialize sourceless insets with Insets.NONE
...in order to make WindowInsets.equals consider source missing and source not providing insets the same. Fixes: 152822955 Test: InsetsAnimationTest Change-Id: I31cb0278f45c38fb788d4f2bdefb1a13b6870216
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/InsetsState.java4
-rw-r--r--core/java/android/view/WindowInsets.java50
2 files changed, 48 insertions, 6 deletions
diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java
index c5154662928e..9896aa4fe214 100644
--- a/core/java/android/view/InsetsState.java
+++ b/core/java/android/view/InsetsState.java
@@ -172,6 +172,10 @@ public class InsetsState implements Parcelable {
for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
InsetsSource source = mSources.get(type);
if (source == null) {
+ int index = indexOf(toPublicType(type));
+ if (typeInsetsMap[index] == null) {
+ typeInsetsMap[index] = Insets.NONE;
+ }
continue;
}
diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java
index 9b2a6cbce48f..33a45f170164 100644
--- a/core/java/android/view/WindowInsets.java
+++ b/core/java/android/view/WindowInsets.java
@@ -835,12 +835,24 @@ public final class WindowInsets {
@Override
public String toString() {
- return "WindowInsets{systemWindowInsets=" + getSystemWindowInsets()
- + " stableInsets=" + getStableInsets()
- + " sysGestureInsets=" + getSystemGestureInsets()
- + (mDisplayCutout != null ? " cutout=" + mDisplayCutout : "")
- + (isRound() ? " round" : "")
- + "}";
+ StringBuilder result = new StringBuilder("WindowInsets{\n ");
+ for (int i = 0; i < SIZE; i++) {
+ Insets insets = mTypeInsetsMap[i];
+ Insets maxInsets = mTypeMaxInsetsMap[i];
+ boolean visible = mTypeVisibilityMap[i];
+ if (!Insets.NONE.equals(insets) || !Insets.NONE.equals(maxInsets) || visible) {
+ result.append(Type.toString(1 << i)).append("=").append(insets)
+ .append(" max=").append(maxInsets)
+ .append(" vis=").append(visible)
+ .append("\n ");
+ }
+ }
+
+ result.append(mDisplayCutout != null ? "cutout=" + mDisplayCutout : "");
+ result.append("\n ");
+ result.append(isRound() ? "round" : "");
+ result.append("}");
+ return result.toString();
}
/**
@@ -1309,6 +1321,32 @@ public final class WindowInsets {
}
}
+ static String toString(@InsetsType int type) {
+ switch (type) {
+ case STATUS_BARS:
+ return "statusBars";
+ case NAVIGATION_BARS:
+ return "navigationBars";
+ case CAPTION_BAR:
+ return "captionBar";
+ case IME:
+ return "ime";
+ case SYSTEM_GESTURES:
+ return "systemGestures";
+ case MANDATORY_SYSTEM_GESTURES:
+ return "mandatorySystemGestures";
+ case TAPPABLE_ELEMENT:
+ return "tappableElement";
+ case DISPLAY_CUTOUT:
+ return "displayCutout";
+ case WINDOW_DECOR:
+ return "windowDecor";
+ default:
+ throw new IllegalArgumentException("type needs to be >= FIRST and <= LAST,"
+ + " type=" + type);
+ }
+ }
+
private Type() {
}