diff options
| author | Jorim Jaggi <jjaggi@google.com> | 2020-01-08 20:44:38 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-01-08 20:44:38 +0000 |
| commit | 7894518e04e1af196bc50136b828636e52b5dd1c (patch) | |
| tree | cef42fa10bd4ecdc60f2ac86f4a9cc3f071b2c14 /core/java/android | |
| parent | d9c399ef6d02e9e09882b5cb0e58e214730575fa (diff) | |
| parent | 761a5ab018b404272414ea7731500dbad6382fbc (diff) | |
Merge "Treat IME adjust flags correctly"
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/InsetsState.java | 17 | ||||
| -rw-r--r-- | core/java/android/view/WindowInsets.java | 43 |
2 files changed, 34 insertions, 26 deletions
diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java index e3fed3a5dce3..ae1e579da8f6 100644 --- a/core/java/android/view/InsetsState.java +++ b/core/java/android/view/InsetsState.java @@ -19,10 +19,15 @@ package android.view; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; +import static android.view.WindowInsets.Type.IME; import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES; import static android.view.WindowInsets.Type.SIZE; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; +import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.indexOf; +import static android.view.WindowInsets.Type.systemBars; +import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; +import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; import android.annotation.IntDef; import android.annotation.Nullable; @@ -156,11 +161,10 @@ public class InsetsState implements Parcelable { && source.getType() != ITYPE_IME; boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR); - boolean skipIme = source.getType() == ITYPE_IME - && (legacySoftInputMode & LayoutParams.SOFT_INPUT_ADJUST_RESIZE) == 0; boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE - && (toPublicType(type) & Type.compatSystemInsets()) != 0; - if (skipSystemBars || skipIme || skipLegacyTypes || skipNonImeInImeMode) { + && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR + || type == ITYPE_IME); + if (skipSystemBars || skipLegacyTypes || skipNonImeInImeMode) { typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible(); continue; } @@ -175,8 +179,11 @@ public class InsetsState implements Parcelable { typeMaxInsetsMap, null /* typeSideMap */, null /* typeVisibilityMap */); } } + final int softInputAdjustMode = legacySoftInputMode & SOFT_INPUT_MASK_ADJUST; return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound, - alwaysConsumeSystemBars, cutout); + alwaysConsumeSystemBars, cutout, softInputAdjustMode == SOFT_INPUT_ADJUST_RESIZE + ? systemBars() | ime() + : systemBars()); } private void processSource(InsetsSource source, Rect relativeFrame, boolean ignoreVisibility, diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java index a9cc50f9e65e..9df131de6754 100644 --- a/core/java/android/view/WindowInsets.java +++ b/core/java/android/view/WindowInsets.java @@ -27,8 +27,8 @@ import static android.view.WindowInsets.Type.STATUS_BARS; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; import static android.view.WindowInsets.Type.all; -import static android.view.WindowInsets.Type.compatSystemInsets; import static android.view.WindowInsets.Type.indexOf; +import static android.view.WindowInsets.Type.systemBars; import android.annotation.IntDef; import android.annotation.IntRange; @@ -87,6 +87,8 @@ public final class WindowInsets { private final boolean mStableInsetsConsumed; private final boolean mDisplayCutoutConsumed; + private final int mCompatInsetTypes; + /** * Since new insets may be added in the future that existing apps couldn't * know about, this fully empty constant shouldn't be made available to apps @@ -112,7 +114,7 @@ public final class WindowInsets { boolean isRound, boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) { this(createCompatTypeMap(systemWindowInsetsRect), createCompatTypeMap(stableInsetsRect), createCompatVisibilityMap(createCompatTypeMap(systemWindowInsetsRect)), - isRound, alwaysConsumeSystemBars, displayCutout); + isRound, alwaysConsumeSystemBars, displayCutout, systemBars()); } /** @@ -131,7 +133,7 @@ public final class WindowInsets { @Nullable Insets[] typeMaxInsetsMap, boolean[] typeVisibilityMap, boolean isRound, - boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) { + boolean alwaysConsumeSystemBars, DisplayCutout displayCutout, int compatInsetTypes) { mSystemWindowInsetsConsumed = typeInsetsMap == null; mTypeInsetsMap = mSystemWindowInsetsConsumed ? new Insets[SIZE] @@ -145,6 +147,7 @@ public final class WindowInsets { mTypeVisibilityMap = typeVisibilityMap; mIsRound = isRound; mAlwaysConsumeSystemBars = alwaysConsumeSystemBars; + mCompatInsetTypes = compatInsetTypes; mDisplayCutoutConsumed = displayCutout == null; mDisplayCutout = (mDisplayCutoutConsumed || displayCutout.isEmpty()) @@ -160,7 +163,8 @@ public final class WindowInsets { this(src.mSystemWindowInsetsConsumed ? null : src.mTypeInsetsMap, src.mStableInsetsConsumed ? null : src.mTypeMaxInsetsMap, src.mTypeVisibilityMap, src.mIsRound, - src.mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(src)); + src.mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(src), + src.mCompatInsetTypes); } private static DisplayCutout displayCutoutCopyConstructorArgument(WindowInsets w) { @@ -211,7 +215,8 @@ public final class WindowInsets { /** @hide */ @UnsupportedAppUsage public WindowInsets(Rect systemWindowInsets) { - this(createCompatTypeMap(systemWindowInsets), null, new boolean[SIZE], false, false, null); + this(createCompatTypeMap(systemWindowInsets), null, new boolean[SIZE], false, false, null, + systemBars()); } /** @@ -280,7 +285,7 @@ public final class WindowInsets { */ @NonNull public Insets getSystemWindowInsets() { - return getInsets(mTypeInsetsMap, compatSystemInsets()); + return getInsets(mTypeInsetsMap, mCompatInsetTypes); } /** @@ -439,7 +444,8 @@ public final class WindowInsets { mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, - null /* displayCutout */); + null /* displayCutout */, + mCompatInsetTypes); } @@ -485,7 +491,8 @@ public final class WindowInsets { return new WindowInsets(null, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, - displayCutoutCopyConstructorArgument(this)); + displayCutoutCopyConstructorArgument(this), + mCompatInsetTypes); } // TODO(b/119190588): replace @code with @link below @@ -555,7 +562,7 @@ public final class WindowInsets { */ @NonNull public Insets getStableInsets() { - return getInsets(mTypeMaxInsetsMap, compatSystemInsets()); + return getInsets(mTypeMaxInsetsMap, mCompatInsetTypes); } /** @@ -733,7 +740,8 @@ public final class WindowInsets { public WindowInsets consumeStableInsets() { return new WindowInsets(mSystemWindowInsetsConsumed ? null : mTypeInsetsMap, null, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, - displayCutoutCopyConstructorArgument(this)); + displayCutoutCopyConstructorArgument(this), + mCompatInsetTypes); } /** @@ -817,7 +825,8 @@ public final class WindowInsets { ? null : mDisplayCutout == null ? DisplayCutout.NO_CUTOUT - : mDisplayCutout.inset(left, top, right, bottom)); + : mDisplayCutout.inset(left, top, right, bottom), + mCompatInsetTypes); } @Override @@ -1134,7 +1143,8 @@ public final class WindowInsets { public WindowInsets build() { return new WindowInsets(mSystemInsetsConsumed ? null : mTypeInsetsMap, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, - mIsRound, mAlwaysConsumeSystemBars, mDisplayCutout); + mIsRound, mAlwaysConsumeSystemBars, mDisplayCutout, + systemBars()); } } @@ -1271,15 +1281,6 @@ public final class WindowInsets { } /** - * @return Inset types representing the list of bars that traditionally were denoted as - * system insets. - * @hide - */ - static @InsetsType int compatSystemInsets() { - return STATUS_BARS | NAVIGATION_BARS | IME; - } - - /** * @return All inset types combined. * * TODO: Figure out if this makes sense at all, mixing e.g {@link #systemGestures()} and |
