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

Commit eb3a7c65 authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Account for padding in KeyguardStatusBarView" into rvc-dev am: da6e556c

Change-Id: I9feb26e870bd03baf632ae2728f89f8352f280c5
parents aa457d28 da6e556c
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -104,6 +104,8 @@ public class KeyguardStatusBarView extends RelativeLayout

    private DisplayCutout mDisplayCutout;
    private int mRoundedCornerPadding = 0;
    // right and left padding applied to this view to account for cutouts and rounded corners
    private Pair<Integer, Integer> mPadding = new Pair(0, 0);

    public KeyguardStatusBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -158,10 +160,13 @@ public class KeyguardStatusBarView extends RelativeLayout
                getResources().getDimensionPixelSize(
                        com.android.internal.R.dimen.text_size_small_material));
        lp = (MarginLayoutParams) mCarrierLabel.getLayoutParams();
        lp.setMarginStart(
                getResources().getDimensionPixelSize(R.dimen.keyguard_carrier_text_margin));
        mCarrierLabel.setLayoutParams(lp);

        int marginStart = calculateMargin(
                getResources().getDimensionPixelSize(R.dimen.keyguard_carrier_text_margin),
                mPadding.first);
        lp.setMarginStart(marginStart);

        mCarrierLabel.setLayoutParams(lp);
        updateKeyguardStatusBarHeight();
    }

@@ -220,6 +225,7 @@ public class KeyguardStatusBarView extends RelativeLayout
                : 0;
        int marginEnd = mKeyguardUserSwitcherShowing ? mSystemIconsSwitcherHiddenExpandedMargin :
                baseMarginEnd;
        marginEnd = calculateMargin(marginEnd, mPadding.second);
        if (marginEnd != lp.getMarginEnd()) {
            lp.setMarginEnd(marginEnd);
            mSystemIconsContainer.setLayoutParams(lp);
@@ -252,10 +258,10 @@ public class KeyguardStatusBarView extends RelativeLayout
    private void updatePadding(Pair<Integer, Integer> cornerCutoutMargins) {
        final int waterfallTop =
                mDisplayCutout == null ? 0 : mDisplayCutout.getWaterfallInsets().top;
        Pair<Integer, Integer> padding =
        mPadding =
                StatusBarWindowView.paddingNeededForCutoutAndRoundedCorner(
                        mDisplayCutout, cornerCutoutMargins, mRoundedCornerPadding);
        setPadding(padding.first, waterfallTop, padding.second, 0);
        setPadding(mPadding.first, waterfallTop, mPadding.second, 0);
    }

    private boolean updateLayoutParamsNoCutout() {
@@ -502,6 +508,17 @@ public class KeyguardStatusBarView extends RelativeLayout
        }
    }

    /**
     * Calculates the margin that isn't already accounted for in the view's padding.
     */
    private int calculateMargin(int margin, int padding) {
        if (padding >= margin) {
            return 0;
        } else {
            return margin - padding;
        }
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("KeyguardStatusBarView:");
        pw.println("  mBatteryCharging: " + mBatteryCharging);