Merge "Add climate bar insets" into rvc-dev
This commit is contained in:
@@ -79,7 +79,9 @@ public class InsetsState implements Parcelable {
|
|||||||
ITYPE_TOP_DISPLAY_CUTOUT,
|
ITYPE_TOP_DISPLAY_CUTOUT,
|
||||||
ITYPE_RIGHT_DISPLAY_CUTOUT,
|
ITYPE_RIGHT_DISPLAY_CUTOUT,
|
||||||
ITYPE_BOTTOM_DISPLAY_CUTOUT,
|
ITYPE_BOTTOM_DISPLAY_CUTOUT,
|
||||||
ITYPE_IME
|
ITYPE_IME,
|
||||||
|
ITYPE_CLIMATE_BAR,
|
||||||
|
ITYPE_EXTRA_NAVIGATION_BAR
|
||||||
})
|
})
|
||||||
public @interface InternalInsetsType {}
|
public @interface InternalInsetsType {}
|
||||||
|
|
||||||
@@ -110,7 +112,11 @@ public class InsetsState implements Parcelable {
|
|||||||
/** Input method window. */
|
/** Input method window. */
|
||||||
public static final int ITYPE_IME = 13;
|
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
|
// Derived types
|
||||||
|
|
||||||
@@ -418,8 +424,10 @@ public class InsetsState implements Parcelable {
|
|||||||
public static @Type.InsetsType int toPublicType(@InternalInsetsType int type) {
|
public static @Type.InsetsType int toPublicType(@InternalInsetsType int type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ITYPE_STATUS_BAR:
|
case ITYPE_STATUS_BAR:
|
||||||
|
case ITYPE_CLIMATE_BAR:
|
||||||
return Type.STATUS_BARS;
|
return Type.STATUS_BARS;
|
||||||
case ITYPE_NAVIGATION_BAR:
|
case ITYPE_NAVIGATION_BAR:
|
||||||
|
case ITYPE_EXTRA_NAVIGATION_BAR:
|
||||||
return Type.NAVIGATION_BARS;
|
return Type.NAVIGATION_BARS;
|
||||||
case ITYPE_CAPTION_BAR:
|
case ITYPE_CAPTION_BAR:
|
||||||
return Type.CAPTION_BAR;
|
return Type.CAPTION_BAR;
|
||||||
@@ -498,6 +506,10 @@ public class InsetsState implements Parcelable {
|
|||||||
return "ITYPE_BOTTOM_DISPLAY_CUTOUT";
|
return "ITYPE_BOTTOM_DISPLAY_CUTOUT";
|
||||||
case ITYPE_IME:
|
case ITYPE_IME:
|
||||||
return "ITYPE_IME";
|
return "ITYPE_IME";
|
||||||
|
case ITYPE_CLIMATE_BAR:
|
||||||
|
return "ITYPE_CLIMATE_BAR";
|
||||||
|
case ITYPE_EXTRA_NAVIGATION_BAR:
|
||||||
|
return "ITYPE_EXTRA_NAVIGATION_BAR";
|
||||||
default:
|
default:
|
||||||
return "ITYPE_UNKNOWN_" + type;
|
return "ITYPE_UNKNOWN_" + type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import static android.view.InsetsState.ISIDE_BOTTOM;
|
|||||||
import static android.view.InsetsState.ISIDE_TOP;
|
import static android.view.InsetsState.ISIDE_TOP;
|
||||||
import static android.view.InsetsState.ITYPE_BOTTOM_GESTURES;
|
import static android.view.InsetsState.ITYPE_BOTTOM_GESTURES;
|
||||||
import static android.view.InsetsState.ITYPE_CAPTION_BAR;
|
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_IME;
|
||||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||||
import static android.view.InsetsState.ITYPE_STATUS_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
|
@Test
|
||||||
public void testStripForDispatch() {
|
public void testStripForDispatch() {
|
||||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||||
|
|||||||
Reference in New Issue
Block a user