Loading core/java/android/view/InsetsState.java +62 −17 Original line number Diff line number Diff line Loading @@ -17,7 +17,10 @@ package android.view; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; 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.indexOf; import android.annotation.IntDef; Loading Loading @@ -55,6 +58,12 @@ public class InsetsState implements Parcelable { TYPE_SIDE_BAR_1, TYPE_SIDE_BAR_2, TYPE_SIDE_BAR_3, TYPE_TOP_GESTURES, TYPE_BOTTOM_GESTURES, TYPE_LEFT_GESTURES, TYPE_RIGHT_GESTURES, TYPE_TOP_TAPPABLE_ELEMENT, TYPE_BOTTOM_TAPPABLE_ELEMENT, TYPE_IME }) public @interface InternalInsetType {} Loading @@ -73,8 +82,16 @@ public class InsetsState implements Parcelable { public static final int TYPE_SIDE_BAR_2 = 2; public static final int TYPE_SIDE_BAR_3 = 3; public static final int TYPE_TOP_GESTURES = 4; public static final int TYPE_BOTTOM_GESTURES = 5; public static final int TYPE_LEFT_GESTURES = 6; public static final int TYPE_RIGHT_GESTURES = 7; public static final int TYPE_TOP_TAPPABLE_ELEMENT = 8; public static final int TYPE_BOTTOM_TAPPABLE_ELEMENT = 9; /** Input method window. */ public static final int TYPE_IME = 4; public static final int TYPE_IME = 10; static final int LAST_TYPE = TYPE_IME; // Derived types Loading Loading @@ -137,17 +154,6 @@ public class InsetsState implements Parcelable { && legacyContentInsets != null && legacyStableInsets != null) { WindowInsets.assignCompatInsets(typeInsetsMap, legacyContentInsets); WindowInsets.assignCompatInsets(typeMaxInsetsMap, legacyStableInsets); // TODO: set system gesture insets based on actual system gesture area. typeInsetsMap[Type.indexOf(Type.systemGestures())] = Insets.of(legacyContentInsets); typeInsetsMap[Type.indexOf(Type.mandatorySystemGestures())] = Insets.of(legacyContentInsets); typeInsetsMap[Type.indexOf(Type.tappableElement())] = Insets.of(legacyContentInsets); typeMaxInsetsMap[Type.indexOf(Type.systemGestures())] = Insets.of(legacyStableInsets); typeMaxInsetsMap[Type.indexOf(Type.mandatorySystemGestures())] = Insets.of(legacyStableInsets); typeMaxInsetsMap[Type.indexOf(Type.tappableElement())] = Insets.of(legacyStableInsets); } for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) { InsetsSource source = mSources.get(type); Loading @@ -159,7 +165,9 @@ public class InsetsState implements Parcelable { && (type == TYPE_TOP_BAR || type == TYPE_NAVIGATION_BAR); boolean skipIme = source.getType() == TYPE_IME && (legacySoftInputMode & LayoutParams.SOFT_INPUT_ADJUST_RESIZE) == 0; if (skipSystemBars || skipIme) { boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE && (toPublicType(type) & Type.compatSystemInsets()) != 0; if (skipSystemBars || skipIme || skipLegacyTypes) { typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible(); continue; } Loading @@ -183,7 +191,25 @@ public class InsetsState implements Parcelable { @Nullable boolean[] typeVisibilityMap) { Insets insets = source.calculateInsets(relativeFrame, ignoreVisibility); int index = indexOf(toPublicType(source.getType())); int type = toPublicType(source.getType()); processSourceAsPublicType(source, typeInsetsMap, typeSideMap, typeVisibilityMap, insets, type); if (type == MANDATORY_SYSTEM_GESTURES) { // Mandatory system gestures are also system gestures. // TODO: find a way to express this more generally. One option would be to define // Type.systemGestureInsets() as NORMAL | MANDATORY, but then we lose the // ability to set systemGestureInsets() independently from // mandatorySystemGestureInsets() in the Builder. processSourceAsPublicType(source, typeInsetsMap, typeSideMap, typeVisibilityMap, insets, SYSTEM_GESTURES); } } private void processSourceAsPublicType(InsetsSource source, Insets[] typeInsetsMap, @InsetSide @Nullable SparseIntArray typeSideMap, @Nullable boolean[] typeVisibilityMap, Insets insets, int type) { int index = indexOf(type); Insets existing = typeInsetsMap[index]; if (existing == null) { typeInsetsMap[index] = insets; Loading Loading @@ -300,6 +326,15 @@ public class InsetsState implements Parcelable { return Type.SIDE_BARS; case TYPE_IME: return Type.IME; case TYPE_TOP_GESTURES: case TYPE_BOTTOM_GESTURES: return Type.MANDATORY_SYSTEM_GESTURES; case TYPE_LEFT_GESTURES: case TYPE_RIGHT_GESTURES: return Type.SYSTEM_GESTURES; case TYPE_TOP_TAPPABLE_ELEMENT: case TYPE_BOTTOM_TAPPABLE_ELEMENT: return Type.TAPPABLE_ELEMENT; default: throw new IllegalArgumentException("Unknown type: " + type); } Loading Loading @@ -336,10 +371,20 @@ public class InsetsState implements Parcelable { return "TYPE_SIDE_BAR_2"; case TYPE_SIDE_BAR_3: return "TYPE_SIDE_BAR_3"; case TYPE_IME: return "TYPE_IME"; case TYPE_TOP_GESTURES: return "TYPE_TOP_GESTURES"; case TYPE_BOTTOM_GESTURES: return "TYPE_BOTTOM_GESTURES"; case TYPE_LEFT_GESTURES: return "TYPE_LEFT_GESTURES"; case TYPE_RIGHT_GESTURES: return "TYPE_RIGHT_GESTURES"; case TYPE_TOP_TAPPABLE_ELEMENT: return "TYPE_TOP_TAPPABLE_ELEMENT"; case TYPE_BOTTOM_TAPPABLE_ELEMENT: return "TYPE_BOTTOM_TAPPABLE_ELEMENT"; default: return "TYPE_UNKNOWN"; return "TYPE_UNKNOWN_" + type; } } Loading core/java/android/view/ViewRootImpl.java +4 −10 Original line number Diff line number Diff line Loading @@ -1916,16 +1916,10 @@ public final class ViewRootImpl implements ViewParent, } contentInsets = ensureInsetsNonNegative(contentInsets, "content"); stableInsets = ensureInsetsNonNegative(stableInsets, "stable"); if (sNewInsetsMode != NEW_INSETS_MODE_NONE) { mLastWindowInsets = mInsetsController.calculateInsets( mContext.getResources().getConfiguration().isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars, displayCutout, contentInsets, stableInsets, mWindowAttributes.softInputMode); } else { mLastWindowInsets = new WindowInsets(contentInsets, stableInsets, mContext.getResources().getConfiguration().isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars, displayCutout); } } return mLastWindowInsets; } Loading core/java/android/view/WindowInsets.java +0 −7 Original line number Diff line number Diff line Loading @@ -29,9 +29,6 @@ import static android.view.WindowInsets.Type.TOP_BAR; 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.mandatorySystemGestures; import static android.view.WindowInsets.Type.systemGestures; import static android.view.WindowInsets.Type.tappableElement; import android.annotation.IntDef; import android.annotation.IntRange; Loading Loading @@ -225,10 +222,6 @@ public final class WindowInsets { } Insets[] typeInsetMap = new Insets[SIZE]; assignCompatInsets(typeInsetMap, insets); // TODO: set system gesture insets based on actual system gesture area. typeInsetMap[indexOf(systemGestures())] = Insets.of(insets); typeInsetMap[indexOf(mandatorySystemGestures())] = Insets.of(insets); typeInsetMap[indexOf(tappableElement())] = Insets.of(insets); return typeInsetMap; } Loading core/res/res/values/config.xml +6 −0 Original line number Diff line number Diff line Loading @@ -3241,6 +3241,12 @@ Only applies if the device display is not square. --> <bool name="config_navBarCanMove">true</bool> <!-- Controls whether the navigation bar lets through taps. --> <bool name="config_navBarTapThrough">false</bool> <!-- Controls the size of the back gesture inset. --> <dimen name="config_backGestureInset">0dp</dimen> <!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows. These values are in DPs and will be converted to pixel sizes internally. --> <string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">16x16</string> Loading core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2845,6 +2845,8 @@ <java-symbol type="integer" name="config_navBarOpacityMode" /> <java-symbol type="integer" name="config_navBarInteractionMode" /> <java-symbol type="bool" name="config_navBarCanMove" /> <java-symbol type="bool" name="config_navBarTapThrough" /> <java-symbol type="dimen" name="config_backGestureInset" /> <java-symbol type="color" name="system_bar_background_semi_transparent" /> <!-- EditText suggestion popup. --> Loading Loading
core/java/android/view/InsetsState.java +62 −17 Original line number Diff line number Diff line Loading @@ -17,7 +17,10 @@ package android.view; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; 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.indexOf; import android.annotation.IntDef; Loading Loading @@ -55,6 +58,12 @@ public class InsetsState implements Parcelable { TYPE_SIDE_BAR_1, TYPE_SIDE_BAR_2, TYPE_SIDE_BAR_3, TYPE_TOP_GESTURES, TYPE_BOTTOM_GESTURES, TYPE_LEFT_GESTURES, TYPE_RIGHT_GESTURES, TYPE_TOP_TAPPABLE_ELEMENT, TYPE_BOTTOM_TAPPABLE_ELEMENT, TYPE_IME }) public @interface InternalInsetType {} Loading @@ -73,8 +82,16 @@ public class InsetsState implements Parcelable { public static final int TYPE_SIDE_BAR_2 = 2; public static final int TYPE_SIDE_BAR_3 = 3; public static final int TYPE_TOP_GESTURES = 4; public static final int TYPE_BOTTOM_GESTURES = 5; public static final int TYPE_LEFT_GESTURES = 6; public static final int TYPE_RIGHT_GESTURES = 7; public static final int TYPE_TOP_TAPPABLE_ELEMENT = 8; public static final int TYPE_BOTTOM_TAPPABLE_ELEMENT = 9; /** Input method window. */ public static final int TYPE_IME = 4; public static final int TYPE_IME = 10; static final int LAST_TYPE = TYPE_IME; // Derived types Loading Loading @@ -137,17 +154,6 @@ public class InsetsState implements Parcelable { && legacyContentInsets != null && legacyStableInsets != null) { WindowInsets.assignCompatInsets(typeInsetsMap, legacyContentInsets); WindowInsets.assignCompatInsets(typeMaxInsetsMap, legacyStableInsets); // TODO: set system gesture insets based on actual system gesture area. typeInsetsMap[Type.indexOf(Type.systemGestures())] = Insets.of(legacyContentInsets); typeInsetsMap[Type.indexOf(Type.mandatorySystemGestures())] = Insets.of(legacyContentInsets); typeInsetsMap[Type.indexOf(Type.tappableElement())] = Insets.of(legacyContentInsets); typeMaxInsetsMap[Type.indexOf(Type.systemGestures())] = Insets.of(legacyStableInsets); typeMaxInsetsMap[Type.indexOf(Type.mandatorySystemGestures())] = Insets.of(legacyStableInsets); typeMaxInsetsMap[Type.indexOf(Type.tappableElement())] = Insets.of(legacyStableInsets); } for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) { InsetsSource source = mSources.get(type); Loading @@ -159,7 +165,9 @@ public class InsetsState implements Parcelable { && (type == TYPE_TOP_BAR || type == TYPE_NAVIGATION_BAR); boolean skipIme = source.getType() == TYPE_IME && (legacySoftInputMode & LayoutParams.SOFT_INPUT_ADJUST_RESIZE) == 0; if (skipSystemBars || skipIme) { boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE && (toPublicType(type) & Type.compatSystemInsets()) != 0; if (skipSystemBars || skipIme || skipLegacyTypes) { typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible(); continue; } Loading @@ -183,7 +191,25 @@ public class InsetsState implements Parcelable { @Nullable boolean[] typeVisibilityMap) { Insets insets = source.calculateInsets(relativeFrame, ignoreVisibility); int index = indexOf(toPublicType(source.getType())); int type = toPublicType(source.getType()); processSourceAsPublicType(source, typeInsetsMap, typeSideMap, typeVisibilityMap, insets, type); if (type == MANDATORY_SYSTEM_GESTURES) { // Mandatory system gestures are also system gestures. // TODO: find a way to express this more generally. One option would be to define // Type.systemGestureInsets() as NORMAL | MANDATORY, but then we lose the // ability to set systemGestureInsets() independently from // mandatorySystemGestureInsets() in the Builder. processSourceAsPublicType(source, typeInsetsMap, typeSideMap, typeVisibilityMap, insets, SYSTEM_GESTURES); } } private void processSourceAsPublicType(InsetsSource source, Insets[] typeInsetsMap, @InsetSide @Nullable SparseIntArray typeSideMap, @Nullable boolean[] typeVisibilityMap, Insets insets, int type) { int index = indexOf(type); Insets existing = typeInsetsMap[index]; if (existing == null) { typeInsetsMap[index] = insets; Loading Loading @@ -300,6 +326,15 @@ public class InsetsState implements Parcelable { return Type.SIDE_BARS; case TYPE_IME: return Type.IME; case TYPE_TOP_GESTURES: case TYPE_BOTTOM_GESTURES: return Type.MANDATORY_SYSTEM_GESTURES; case TYPE_LEFT_GESTURES: case TYPE_RIGHT_GESTURES: return Type.SYSTEM_GESTURES; case TYPE_TOP_TAPPABLE_ELEMENT: case TYPE_BOTTOM_TAPPABLE_ELEMENT: return Type.TAPPABLE_ELEMENT; default: throw new IllegalArgumentException("Unknown type: " + type); } Loading Loading @@ -336,10 +371,20 @@ public class InsetsState implements Parcelable { return "TYPE_SIDE_BAR_2"; case TYPE_SIDE_BAR_3: return "TYPE_SIDE_BAR_3"; case TYPE_IME: return "TYPE_IME"; case TYPE_TOP_GESTURES: return "TYPE_TOP_GESTURES"; case TYPE_BOTTOM_GESTURES: return "TYPE_BOTTOM_GESTURES"; case TYPE_LEFT_GESTURES: return "TYPE_LEFT_GESTURES"; case TYPE_RIGHT_GESTURES: return "TYPE_RIGHT_GESTURES"; case TYPE_TOP_TAPPABLE_ELEMENT: return "TYPE_TOP_TAPPABLE_ELEMENT"; case TYPE_BOTTOM_TAPPABLE_ELEMENT: return "TYPE_BOTTOM_TAPPABLE_ELEMENT"; default: return "TYPE_UNKNOWN"; return "TYPE_UNKNOWN_" + type; } } Loading
core/java/android/view/ViewRootImpl.java +4 −10 Original line number Diff line number Diff line Loading @@ -1916,16 +1916,10 @@ public final class ViewRootImpl implements ViewParent, } contentInsets = ensureInsetsNonNegative(contentInsets, "content"); stableInsets = ensureInsetsNonNegative(stableInsets, "stable"); if (sNewInsetsMode != NEW_INSETS_MODE_NONE) { mLastWindowInsets = mInsetsController.calculateInsets( mContext.getResources().getConfiguration().isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars, displayCutout, contentInsets, stableInsets, mWindowAttributes.softInputMode); } else { mLastWindowInsets = new WindowInsets(contentInsets, stableInsets, mContext.getResources().getConfiguration().isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars, displayCutout); } } return mLastWindowInsets; } Loading
core/java/android/view/WindowInsets.java +0 −7 Original line number Diff line number Diff line Loading @@ -29,9 +29,6 @@ import static android.view.WindowInsets.Type.TOP_BAR; 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.mandatorySystemGestures; import static android.view.WindowInsets.Type.systemGestures; import static android.view.WindowInsets.Type.tappableElement; import android.annotation.IntDef; import android.annotation.IntRange; Loading Loading @@ -225,10 +222,6 @@ public final class WindowInsets { } Insets[] typeInsetMap = new Insets[SIZE]; assignCompatInsets(typeInsetMap, insets); // TODO: set system gesture insets based on actual system gesture area. typeInsetMap[indexOf(systemGestures())] = Insets.of(insets); typeInsetMap[indexOf(mandatorySystemGestures())] = Insets.of(insets); typeInsetMap[indexOf(tappableElement())] = Insets.of(insets); return typeInsetMap; } Loading
core/res/res/values/config.xml +6 −0 Original line number Diff line number Diff line Loading @@ -3241,6 +3241,12 @@ Only applies if the device display is not square. --> <bool name="config_navBarCanMove">true</bool> <!-- Controls whether the navigation bar lets through taps. --> <bool name="config_navBarTapThrough">false</bool> <!-- Controls the size of the back gesture inset. --> <dimen name="config_backGestureInset">0dp</dimen> <!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows. These values are in DPs and will be converted to pixel sizes internally. --> <string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">16x16</string> Loading
core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2845,6 +2845,8 @@ <java-symbol type="integer" name="config_navBarOpacityMode" /> <java-symbol type="integer" name="config_navBarInteractionMode" /> <java-symbol type="bool" name="config_navBarCanMove" /> <java-symbol type="bool" name="config_navBarTapThrough" /> <java-symbol type="dimen" name="config_backGestureInset" /> <java-symbol type="color" name="system_bar_background_semi_transparent" /> <!-- EditText suggestion popup. --> Loading