Merge "Rounded corners can be different on top/bottom" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
336076b2a2
@@ -917,6 +917,8 @@
|
||||
<dimen name="edge_margin">8dp</dimen>
|
||||
|
||||
<dimen name="rounded_corner_radius">0dp</dimen>
|
||||
<dimen name="rounded_corner_radius_top">0dp</dimen>
|
||||
<dimen name="rounded_corner_radius_bottom">0dp</dimen>
|
||||
<dimen name="rounded_corner_content_padding">0dp</dimen>
|
||||
<dimen name="nav_content_padding">0dp</dimen>
|
||||
<dimen name="nav_quick_scrub_track_edge_padding">42dp</dimen>
|
||||
|
||||
@@ -78,6 +78,8 @@ public class ScreenDecorations extends SystemUI implements Tunable {
|
||||
SystemProperties.getBoolean("debug.screenshot_rounded_corners", false);
|
||||
|
||||
private int mRoundedDefault;
|
||||
private int mRoundedDefaultTop;
|
||||
private int mRoundedDefaultBottom;
|
||||
private View mOverlay;
|
||||
private View mBottomOverlay;
|
||||
private float mDensity;
|
||||
@@ -89,9 +91,14 @@ public class ScreenDecorations extends SystemUI implements Tunable {
|
||||
mWindowManager = mContext.getSystemService(WindowManager.class);
|
||||
mRoundedDefault = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius);
|
||||
if (mRoundedDefault != 0 || shouldDrawCutout()) {
|
||||
mRoundedDefaultTop = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius_top);
|
||||
mRoundedDefaultBottom = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius_bottom);
|
||||
if (hasRoundedCorners() || shouldDrawCutout()) {
|
||||
setupDecorations();
|
||||
}
|
||||
|
||||
int padding = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_content_padding);
|
||||
if (padding != 0) {
|
||||
@@ -208,11 +215,15 @@ public class ScreenDecorations extends SystemUI implements Tunable {
|
||||
private void updateWindowVisibility(View overlay) {
|
||||
boolean visibleForCutout = shouldDrawCutout()
|
||||
&& overlay.findViewById(R.id.display_cutout).getVisibility() == View.VISIBLE;
|
||||
boolean visibleForRoundedCorners = mRoundedDefault > 0;
|
||||
boolean visibleForRoundedCorners = hasRoundedCorners();
|
||||
overlay.setVisibility(visibleForCutout || visibleForRoundedCorners
|
||||
? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private boolean hasRoundedCorners() {
|
||||
return mRoundedDefault > 0 || mRoundedDefaultBottom > 0 || mRoundedDefaultTop > 0;
|
||||
}
|
||||
|
||||
private boolean shouldDrawCutout() {
|
||||
return shouldDrawCutout(mContext);
|
||||
}
|
||||
@@ -284,14 +295,26 @@ public class ScreenDecorations extends SystemUI implements Tunable {
|
||||
if (mOverlay == null) return;
|
||||
if (SIZE.equals(key)) {
|
||||
int size = mRoundedDefault;
|
||||
try {
|
||||
size = (int) (Integer.parseInt(newValue) * mDensity);
|
||||
} catch (Exception e) {
|
||||
int sizeTop = mRoundedDefaultTop;
|
||||
int sizeBottom = mRoundedDefaultBottom;
|
||||
if (newValue != null) {
|
||||
try {
|
||||
size = (int) (Integer.parseInt(newValue) * mDensity);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
setSize(mOverlay.findViewById(R.id.left), size);
|
||||
setSize(mOverlay.findViewById(R.id.right), size);
|
||||
setSize(mBottomOverlay.findViewById(R.id.left), size);
|
||||
setSize(mBottomOverlay.findViewById(R.id.right), size);
|
||||
|
||||
if (sizeTop == 0) {
|
||||
sizeTop = size;
|
||||
}
|
||||
if (sizeBottom == 0) {
|
||||
sizeBottom = size;
|
||||
}
|
||||
|
||||
setSize(mOverlay.findViewById(R.id.left), sizeTop);
|
||||
setSize(mOverlay.findViewById(R.id.right), sizeTop);
|
||||
setSize(mBottomOverlay.findViewById(R.id.left), sizeBottom);
|
||||
setSize(mBottomOverlay.findViewById(R.id.right), sizeBottom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user