Merge "Add the systemOverlays() method"

This commit is contained in:
Gaurav Bhola
2022-11-12 22:50:29 +00:00
committed by Android (Google) Code Review
3 changed files with 27 additions and 10 deletions

View File

@@ -51925,6 +51925,7 @@ package android.view {
method public static int statusBars();
method public static int systemBars();
method public static int systemGestures();
method public static int systemOverlays();
method public static int tappableElement();
}

View File

@@ -702,7 +702,7 @@ public class InsetsState implements Parcelable {
result.add(ITYPE_NAVIGATION_BAR);
result.add(ITYPE_EXTRA_NAVIGATION_BAR);
}
if ((types & Type.GENERIC_OVERLAYS) != 0) {
if ((types & Type.SYSTEM_OVERLAYS) != 0) {
result.add(ITYPE_LEFT_GENERIC_OVERLAY);
result.add(ITYPE_TOP_GENERIC_OVERLAY);
result.add(ITYPE_RIGHT_GENERIC_OVERLAY);
@@ -752,7 +752,7 @@ public class InsetsState implements Parcelable {
case ITYPE_TOP_GENERIC_OVERLAY:
case ITYPE_RIGHT_GENERIC_OVERLAY:
case ITYPE_BOTTOM_GENERIC_OVERLAY:
return Type.GENERIC_OVERLAYS;
return Type.SYSTEM_OVERLAYS;
case ITYPE_CAPTION_BAR:
return Type.CAPTION_BAR;
case ITYPE_IME:

View File

@@ -1425,8 +1425,8 @@ public final class WindowInsets {
static final int WINDOW_DECOR = 1 << 8;
static final int GENERIC_OVERLAYS = 1 << 9;
static final int LAST = GENERIC_OVERLAYS;
static final int SYSTEM_OVERLAYS = 1 << 9;
static final int LAST = SYSTEM_OVERLAYS;
static final int SIZE = 10;
static final int DEFAULT_VISIBLE = ~IME;
@@ -1451,7 +1451,7 @@ public final class WindowInsets {
return 7;
case WINDOW_DECOR:
return 8;
case GENERIC_OVERLAYS:
case SYSTEM_OVERLAYS:
return 9;
default:
throw new IllegalArgumentException("type needs to be >= FIRST and <= LAST,"
@@ -1489,8 +1489,8 @@ public final class WindowInsets {
if ((types & WINDOW_DECOR) != 0) {
result.append("windowDecor |");
}
if ((types & GENERIC_OVERLAYS) != 0) {
result.append("genericOverlays |");
if ((types & SYSTEM_OVERLAYS) != 0) {
result.append("systemOverlays |");
}
if (result.length() > 0) {
result.delete(result.length() - 2, result.length());
@@ -1505,7 +1505,7 @@ public final class WindowInsets {
@Retention(RetentionPolicy.SOURCE)
@IntDef(flag = true, value = {STATUS_BARS, NAVIGATION_BARS, CAPTION_BAR, IME, WINDOW_DECOR,
SYSTEM_GESTURES, MANDATORY_SYSTEM_GESTURES, TAPPABLE_ELEMENT, DISPLAY_CUTOUT,
GENERIC_OVERLAYS})
SYSTEM_OVERLAYS})
public @interface InsetsType {
}
@@ -1592,12 +1592,28 @@ public final class WindowInsets {
return DISPLAY_CUTOUT;
}
/**
* System overlays represent the insets caused by the system visible elements. Unlike
* {@link #navigationBars()} or {@link #statusBars()}, system overlays might not be
* hidden by the client.
*
* For compatibility reasons, this type is included in {@link #systemBars()}. In this
* way, views which fit {@link #systemBars()} fit {@link #systemOverlays()}.
*
* Examples include climate controls, multi-tasking affordances, etc.
*
* @return An insets type representing the system overlays.
*/
public static @InsetsType int systemOverlays() {
return SYSTEM_OVERLAYS;
}
/**
* @return All system bars. Includes {@link #statusBars()}, {@link #captionBar()} as well as
* {@link #navigationBars()}, but not {@link #ime()}.
* {@link #navigationBars()}, {@link #systemOverlays()}, but not {@link #ime()}.
*/
public static @InsetsType int systemBars() {
return STATUS_BARS | NAVIGATION_BARS | CAPTION_BAR | GENERIC_OVERLAYS;
return STATUS_BARS | NAVIGATION_BARS | CAPTION_BAR | SYSTEM_OVERLAYS;
}
/**