diff options
| author | 2019-11-21 15:15:36 -0800 | |
|---|---|---|
| committer | 2019-12-20 20:21:25 +0000 | |
| commit | 21cc2e5f7dda348750a818a04edae11fc4d31a5a (patch) | |
| tree | 6dd5c4b3e5f34201e061285f14f1f2f88f688306 | |
| parent | 23e867d5dea428d111a3799fe0d50df40cd0a5d1 (diff) | |
Support @left marker
By default cutouts are centered and support a @right marker to allow
them to be right aligned. Let's also support left alignment by
introducing a @left marker.
Test: atest DisplayCutoutTest
Test: manual
Bug: 143222961
Bug: 145707162
Change-Id: Ic5a645bd9f0513f3665f31c8b0f1861585bf30e6
Merged-In: Ic5a645bd9f0513f3665f31c8b0f1861585bf30e6
(cherry picked from commit 6e9636c5e0bde377e43fafaef80d13e8cb57fb92)
| -rw-r--r-- | core/java/android/view/DisplayCutout.java | 4 | ||||
| -rw-r--r-- | core/res/res/values/config.xml | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/view/DisplayCutout.java b/core/java/android/view/DisplayCutout.java index 715181f28076..e77d7191d5b8 100644 --- a/core/java/android/view/DisplayCutout.java +++ b/core/java/android/view/DisplayCutout.java @@ -66,6 +66,7 @@ public final class DisplayCutout { private static final String BOTTOM_MARKER = "@bottom"; private static final String DP_MARKER = "@dp"; private static final String RIGHT_MARKER = "@right"; + private static final String LEFT_MARKER = "@left"; /** * Category for overlays that allow emulating a display cutout on devices that don't have @@ -642,6 +643,9 @@ public final class DisplayCutout { if (spec.endsWith(RIGHT_MARKER)) { offsetX = displayWidth; spec = spec.substring(0, spec.length() - RIGHT_MARKER.length()).trim(); + } else if (spec.endsWith(LEFT_MARKER)) { + offsetX = 0; + spec = spec.substring(0, spec.length() - LEFT_MARKER.length()).trim(); } else { offsetX = displayWidth / 2f; } diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 4a464656a63a..8331a57a3417 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3194,7 +3194,9 @@ The path is assumed to be specified in display coordinates with pixel units and in the display's native orientation, with the origin of the coordinate system at the - center top of the display. + center top of the display. Optionally, you can append either `@left` or `@right` to the + end of the path string, in order to change the path origin to either the top left, + or top right of the display. To facilitate writing device-independent emulation overlays, the marker `@dp` can be appended after the path string to interpret coordinates in dp instead of px units. |