Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5f7a30b authored by Beverly's avatar Beverly
Browse files

Rounded corners can be different on top/bottom

Test: manual, visual inspection
Bug: 75949920
Change-Id: I1e9a9df0767aa5235e67b752a19c8e4b32701ed1
parent c907be6f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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>
+32 −9
Original line number Diff line number Diff line
@@ -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;
            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);
        }
    }