From f79cd873f6013489f29c66e4d8ea08f9253a71aa Mon Sep 17 00:00:00 2001 From: Daniel Nishi Date: Mon, 27 Jun 2016 11:44:01 -0700 Subject: [PATCH] Add margins to the system icons when the user avatar is gone. This resolves a regression caused by situtionally removing the avatar on phones when there is only one user. Normally, the avatar's width acts as padding against the end. By removing the avatar, the buffer is also removed. This patch re-adds 6dp of margins to space the system icons properly on phones. Change-Id: I7b07b02fb74146e17109a7aaf23a41bb681683f3 FIXES: 29646859 --- packages/SystemUI/res/values/dimens.xml | 3 +++ .../statusbar/phone/KeyguardStatusBarView.java | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index cd861e14b18b7..e1cbbc5c9c543 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -141,6 +141,9 @@ 16dp + + 6dp + -1px 416dp diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 42f398d8d83f0..93ed1398c2a67 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone; import android.content.Context; import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.TypedValue; @@ -59,6 +60,7 @@ public class KeyguardStatusBarView extends RelativeLayout private UserSwitcherController mUserSwitcherController; private int mSystemIconsSwitcherHiddenExpandedMargin; + private int mSystemIconsBaseMargin; private View mSystemIconsContainer; public KeyguardStatusBarView(Context context, AttributeSet attrs) { @@ -137,8 +139,11 @@ public class KeyguardStatusBarView extends RelativeLayout } private void loadDimens() { - mSystemIconsSwitcherHiddenExpandedMargin = getResources().getDimensionPixelSize( + Resources res = getResources(); + mSystemIconsSwitcherHiddenExpandedMargin = res.getDimensionPixelSize( R.dimen.system_icons_switcher_hidden_expanded_margin); + mSystemIconsBaseMargin = res.getDimensionPixelSize( + R.dimen.system_icons_super_container_avatarless_margin_end); } private void updateVisibilities() { @@ -166,7 +171,13 @@ public class KeyguardStatusBarView extends RelativeLayout private void updateSystemIconsLayoutParams() { RelativeLayout.LayoutParams lp = (LayoutParams) mSystemIconsSuperContainer.getLayoutParams(); - int marginEnd = mKeyguardUserSwitcherShowing ? mSystemIconsSwitcherHiddenExpandedMargin : 0; + // If the avatar icon is gone, we need to have some end margin to display the system icons + // correctly. + int baseMarginEnd = mMultiUserSwitch.getVisibility() == View.GONE + ? mSystemIconsBaseMargin + : 0; + int marginEnd = mKeyguardUserSwitcherShowing ? mSystemIconsSwitcherHiddenExpandedMargin : + baseMarginEnd; if (marginEnd != lp.getMarginEnd()) { lp.setMarginEnd(marginEnd); mSystemIconsSuperContainer.setLayoutParams(lp); @@ -301,6 +312,7 @@ public class KeyguardStatusBarView extends RelativeLayout mMultiUserSwitch.setAlpha(1f); } else { updateVisibilities(); + updateSystemIconsLayoutParams(); } }