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
This commit is contained in:
Daniel Nishi
2016-06-27 11:44:01 -07:00
parent 9459f93c97
commit f79cd873f6
2 changed files with 17 additions and 2 deletions

View File

@@ -141,6 +141,9 @@
<!-- Margin start of the system icons super container -->
<dimen name="system_icons_super_container_margin_start">16dp</dimen>
<!-- Margin end of the system icons super container when the avatar is missing. -->
<dimen name="system_icons_super_container_avatarless_margin_end">6dp</dimen>
<!-- Width for the notification panel and related windows -->
<dimen name="match_parent">-1px</dimen>
<dimen name="standard_notification_panel_width">416dp</dimen>

View File

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