Merge "Rounded corners can be different on top/bottom" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-25 19:37:37 +00:00
committed by Android (Google) Code Review
2 changed files with 34 additions and 9 deletions

View File

@@ -917,6 +917,8 @@
<dimen name="edge_margin">8dp</dimen> <dimen name="edge_margin">8dp</dimen>
<dimen name="rounded_corner_radius">0dp</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="rounded_corner_content_padding">0dp</dimen>
<dimen name="nav_content_padding">0dp</dimen> <dimen name="nav_content_padding">0dp</dimen>
<dimen name="nav_quick_scrub_track_edge_padding">42dp</dimen> <dimen name="nav_quick_scrub_track_edge_padding">42dp</dimen>

View File

@@ -78,6 +78,8 @@ public class ScreenDecorations extends SystemUI implements Tunable {
SystemProperties.getBoolean("debug.screenshot_rounded_corners", false); SystemProperties.getBoolean("debug.screenshot_rounded_corners", false);
private int mRoundedDefault; private int mRoundedDefault;
private int mRoundedDefaultTop;
private int mRoundedDefaultBottom;
private View mOverlay; private View mOverlay;
private View mBottomOverlay; private View mBottomOverlay;
private float mDensity; private float mDensity;
@@ -89,9 +91,14 @@ public class ScreenDecorations extends SystemUI implements Tunable {
mWindowManager = mContext.getSystemService(WindowManager.class); mWindowManager = mContext.getSystemService(WindowManager.class);
mRoundedDefault = mContext.getResources().getDimensionPixelSize( mRoundedDefault = mContext.getResources().getDimensionPixelSize(
R.dimen.rounded_corner_radius); 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(); setupDecorations();
} }
int padding = mContext.getResources().getDimensionPixelSize( int padding = mContext.getResources().getDimensionPixelSize(
R.dimen.rounded_corner_content_padding); R.dimen.rounded_corner_content_padding);
if (padding != 0) { if (padding != 0) {
@@ -208,11 +215,15 @@ public class ScreenDecorations extends SystemUI implements Tunable {
private void updateWindowVisibility(View overlay) { private void updateWindowVisibility(View overlay) {
boolean visibleForCutout = shouldDrawCutout() boolean visibleForCutout = shouldDrawCutout()
&& overlay.findViewById(R.id.display_cutout).getVisibility() == View.VISIBLE; && overlay.findViewById(R.id.display_cutout).getVisibility() == View.VISIBLE;
boolean visibleForRoundedCorners = mRoundedDefault > 0; boolean visibleForRoundedCorners = hasRoundedCorners();
overlay.setVisibility(visibleForCutout || visibleForRoundedCorners overlay.setVisibility(visibleForCutout || visibleForRoundedCorners
? View.VISIBLE : View.GONE); ? View.VISIBLE : View.GONE);
} }
private boolean hasRoundedCorners() {
return mRoundedDefault > 0 || mRoundedDefaultBottom > 0 || mRoundedDefaultTop > 0;
}
private boolean shouldDrawCutout() { private boolean shouldDrawCutout() {
return shouldDrawCutout(mContext); return shouldDrawCutout(mContext);
} }
@@ -284,14 +295,26 @@ public class ScreenDecorations extends SystemUI implements Tunable {
if (mOverlay == null) return; if (mOverlay == null) return;
if (SIZE.equals(key)) { if (SIZE.equals(key)) {
int size = mRoundedDefault; int size = mRoundedDefault;
try { int sizeTop = mRoundedDefaultTop;
size = (int) (Integer.parseInt(newValue) * mDensity); int sizeBottom = mRoundedDefaultBottom;
} catch (Exception e) { 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); if (sizeTop == 0) {
setSize(mBottomOverlay.findViewById(R.id.left), size); sizeTop = size;
setSize(mBottomOverlay.findViewById(R.id.right), 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);
} }
} }