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

Commit b6f3f983 authored by LuK1337's avatar LuK1337 Committed by Łukasz Patron
Browse files

SystemUI: Update carrier label margin right after setting the padding

This change addresses the two following issues:

* When restarting SystemUI using `pkill -9 systemui`, carrier label's
  margin start would not get initialized since onConfigurationChanged()
  didn't get called.

* onConfigurationChanged() was being called before onApplyWindowInsets()
  resulting in invalid mPadding.first being used.

Change-Id: I076d1e9cd7a2a011512f5dbd5de4a9a991f28042
parent 8f854f40
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -154,14 +154,7 @@ public class KeyguardStatusBarView extends RelativeLayout
        mCarrierLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimensionPixelSize(
                        com.android.internal.R.dimen.text_size_small_material));
        lp = (MarginLayoutParams) mCarrierLabel.getLayoutParams();

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

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

@@ -241,6 +234,7 @@ public class KeyguardStatusBarView extends RelativeLayout
        Pair<Integer, Integer> cornerCutoutMargins =
                StatusBarWindowView.cornerCutoutMargins(mDisplayCutout, getDisplay());
        updatePadding(cornerCutoutMargins);
        updateCarrierLabelParams();
        if (mDisplayCutout == null || cornerCutoutMargins != null) {
            return updateLayoutParamsNoCutout();
        } else {
@@ -257,6 +251,16 @@ public class KeyguardStatusBarView extends RelativeLayout
        setPadding(mPadding.first, waterfallTop, mPadding.second, 0);
    }

    private void updateCarrierLabelParams() {
        int marginStart = calculateMargin(
                getResources().getDimensionPixelSize(R.dimen.keyguard_carrier_text_margin),
                mPadding.first);
        MarginLayoutParams lp = (MarginLayoutParams) mCarrierLabel.getLayoutParams();
        lp.setMarginStart(marginStart);

        mCarrierLabel.setLayoutParams(lp);
    }

    private boolean updateLayoutParamsNoCutout() {
        if (mLayoutState == LAYOUT_NO_CUTOUT) {
            return false;