Account for padding in KeyguardStatusBarView

KeyguardStatusBarView was adding padding to account for potential
cutouts and rounded corner padding in addition to adding margin to the
system icons and carrier text view.  Instead, take into account the
padding when calculating the margins on the elements in
KeyguardStatusBarView.

Test: manually tested LTR and RTL languages
Fixes: 152020130
Change-Id: I4b724de78a54c7fe852710720a4f9511ae7f039c
This commit is contained in:
Beverly
2020-04-02 15:10:19 -04:00
committed by Beverly Tai
parent f0059d21c7
commit 00fc0c8bd1

View File

@@ -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);