Add climate bar insets

This can be used to support a 3rd kind of system bar to inset the
applicaiton space.

Bug: 152763889
Test: manual
Change-Id: I3ba75886e94a9fe80a0d1a920749d152dda64031
This commit is contained in:
Heemin Seog
2020-05-06 15:32:50 -07:00
parent 1961a740b4
commit d79e4f49d2
2 changed files with 48 additions and 2 deletions

View File

@@ -78,7 +78,9 @@ public class InsetsState implements Parcelable {
ITYPE_TOP_DISPLAY_CUTOUT,
ITYPE_RIGHT_DISPLAY_CUTOUT,
ITYPE_BOTTOM_DISPLAY_CUTOUT,
ITYPE_IME
ITYPE_IME,
ITYPE_CLIMATE_BAR,
ITYPE_EXTRA_NAVIGATION_BAR
})
public @interface InternalInsetsType {}
@@ -109,7 +111,11 @@ public class InsetsState implements Parcelable {
/** Input method window. */
public static final int ITYPE_IME = 13;
static final int LAST_TYPE = ITYPE_IME;
/** Additional system decorations inset type. */
public static final int ITYPE_CLIMATE_BAR = 14;
public static final int ITYPE_EXTRA_NAVIGATION_BAR = 15;
static final int LAST_TYPE = ITYPE_EXTRA_NAVIGATION_BAR;
// Derived types
@@ -417,8 +423,10 @@ public class InsetsState implements Parcelable {
public static @Type.InsetsType int toPublicType(@InternalInsetsType int type) {
switch (type) {
case ITYPE_STATUS_BAR:
case ITYPE_CLIMATE_BAR:
return Type.STATUS_BARS;
case ITYPE_NAVIGATION_BAR:
case ITYPE_EXTRA_NAVIGATION_BAR:
return Type.NAVIGATION_BARS;
case ITYPE_CAPTION_BAR:
return Type.CAPTION_BAR;
@@ -497,6 +505,10 @@ public class InsetsState implements Parcelable {
return "ITYPE_BOTTOM_DISPLAY_CUTOUT";
case ITYPE_IME:
return "ITYPE_IME";
case ITYPE_CLIMATE_BAR:
return "ITYPE_CLIMATE_BAR";
case ITYPE_EXTRA_NAVIGATION_BAR:
return "ITYPE_EXTRA_NAVIGATION_BAR";
default:
return "ITYPE_UNKNOWN_" + type;
}

View File

@@ -20,6 +20,8 @@ import static android.view.InsetsState.ISIDE_BOTTOM;
import static android.view.InsetsState.ISIDE_TOP;
import static android.view.InsetsState.ITYPE_BOTTOM_GESTURES;
import static android.view.InsetsState.ITYPE_CAPTION_BAR;
import static android.view.InsetsState.ITYPE_CLIMATE_BAR;
import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_IME;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
@@ -182,6 +184,38 @@ public class InsetsStateTest {
}
}
@Test
public void testCalculateInsets_extraNavRightStatusTop() throws Exception {
try (InsetsModeSession session =
new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
mState.getSource(ITYPE_EXTRA_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
mState.getSource(ITYPE_EXTRA_NAVIGATION_BAR).setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
false, DisplayCutout.NO_CUTOUT, 0, 0, null);
assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.navigationBars()));
}
}
@Test
public void testCalculateInsets_navigationRightClimateTop() throws Exception {
try (InsetsModeSession session =
new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
mState.getSource(ITYPE_CLIMATE_BAR).setFrame(new Rect(0, 0, 100, 100));
mState.getSource(ITYPE_CLIMATE_BAR).setVisible(true);
mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
false, DisplayCutout.NO_CUTOUT, 0, 0, null);
assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.navigationBars()));
}
}
@Test
public void testStripForDispatch() {
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));