Adjusting bounds of system_icons and statusIcons so they align with cursor hover state
Changing bounds of them both to be wrapped_content instead of match_parent - then when we introduce hover state for system_icons, it can simply align with view bounds instead of doing custom measurements. StatusIconContainer required changes in onMeasure, otherwise it was always taking all available space vertically. Both views are still centered vertically, no changes in that regard.. Bug: 249859409 Test: Checking how status bar looks in different orientations on launcher/keyguard Change-Id: Icb4e3cb832a82097444a92f7a398d3e7cdf06666
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/battery_percentage_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
|
||||
@@ -47,7 +47,10 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="@dimen/status_bar_padding_end"
|
||||
android:gravity="center_vertical|end">
|
||||
<include layout="@layout/system_icons" />
|
||||
<include layout="@layout/system_icons"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView android:id="@+id/multi_user_avatar"
|
||||
|
||||
@@ -18,20 +18,23 @@
|
||||
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/system_icons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/status_bar_icons_padding_bottom"
|
||||
android:paddingTop="@dimen/status_bar_icons_padding_top"
|
||||
android:paddingStart="@dimen/status_bar_icons_padding_start"
|
||||
android:paddingEnd="@dimen/status_bar_icons_padding_end"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<com.android.systemui.statusbar.phone.StatusIconContainer android:id="@+id/statusIcons"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingEnd="@dimen/signal_cluster_battery_padding"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"/>
|
||||
|
||||
<com.android.systemui.battery.BatteryMeterView android:id="@+id/battery"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:clipChildren="false"
|
||||
|
||||
@@ -16,8 +16,15 @@
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<!-- padding for container with status icons and battery -->
|
||||
<dimen name="status_bar_icons_padding_end">12dp</dimen>
|
||||
<!-- it's a bit smaller on large screen to account for status_bar_icon_horizontal_margin -->
|
||||
<dimen name="status_bar_icons_padding_start">10dp</dimen>
|
||||
|
||||
<dimen name="status_bar_padding_end">0dp</dimen>
|
||||
|
||||
<!-- gap on either side of status bar notification icons -->
|
||||
<dimen name="status_bar_icon_padding">1dp</dimen>
|
||||
<dimen name="status_bar_icon_horizontal_margin">1dp</dimen>
|
||||
|
||||
<dimen name="controls_header_horizontal_padding">28dp</dimen>
|
||||
<dimen name="controls_content_margin_horizontal">40dp</dimen>
|
||||
|
||||
@@ -326,8 +326,16 @@
|
||||
<!-- opacity at which Notification icons will be drawn in the status bar -->
|
||||
<item type="dimen" name="status_bar_icon_drawing_alpha">90%</item>
|
||||
|
||||
<!-- paddings for container with status icons and battery -->
|
||||
<!-- padding start is a bit smaller than end to account for status icon margin-->
|
||||
<dimen name="status_bar_icons_padding_start">11dp</dimen>
|
||||
|
||||
<dimen name="status_bar_icons_padding_end">0dp</dimen>
|
||||
<dimen name="status_bar_icons_padding_bottom">8dp</dimen>
|
||||
<dimen name="status_bar_icons_padding_top">8dp</dimen>
|
||||
|
||||
<!-- gap on either side of status bar notification icons -->
|
||||
<dimen name="status_bar_icon_padding">0dp</dimen>
|
||||
<dimen name="status_bar_icon_horizontal_margin">0dp</dimen>
|
||||
|
||||
<!-- the padding on the start of the statusbar -->
|
||||
<dimen name="status_bar_padding_start">8dp</dimen>
|
||||
@@ -1560,7 +1568,8 @@
|
||||
|
||||
<!-- Status bar user chip -->
|
||||
<dimen name="status_bar_user_chip_avatar_size">16dp</dimen>
|
||||
<dimen name="status_bar_user_chip_end_margin">12dp</dimen>
|
||||
<!-- below also works as break between user chip and hover state of status icons -->
|
||||
<dimen name="status_bar_user_chip_end_margin">4dp</dimen>
|
||||
<dimen name="status_bar_user_chip_text_size">12sp</dimen>
|
||||
|
||||
<!-- System UI Dialog -->
|
||||
|
||||
@@ -348,7 +348,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {
|
||||
updatePercentText();
|
||||
addView(mBatteryPercentView, new LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.MATCH_PARENT));
|
||||
LayoutParams.WRAP_CONTENT));
|
||||
}
|
||||
} else {
|
||||
if (showing) {
|
||||
|
||||
@@ -240,7 +240,7 @@ public class NotificationIconAreaController implements
|
||||
private void reloadDimens(Context context) {
|
||||
Resources res = context.getResources();
|
||||
mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
|
||||
mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_padding);
|
||||
mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_horizontal_margin);
|
||||
mAodIconAppearTranslation = res.getDimensionPixelSize(
|
||||
R.dimen.shelf_appear_translation);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public interface StatusBarIconController {
|
||||
*/
|
||||
class DarkIconManager extends IconManager {
|
||||
private final DarkIconDispatcher mDarkIconDispatcher;
|
||||
private int mIconHPadding;
|
||||
private final int mIconHorizontalMargin;
|
||||
|
||||
public DarkIconManager(
|
||||
LinearLayout linearLayout,
|
||||
@@ -189,8 +189,8 @@ public interface StatusBarIconController {
|
||||
wifiUiAdapter,
|
||||
mobileUiAdapter,
|
||||
mobileContextProvider);
|
||||
mIconHPadding = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.status_bar_icon_padding);
|
||||
mIconHorizontalMargin = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.status_bar_icon_horizontal_margin);
|
||||
mDarkIconDispatcher = darkIconDispatcher;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public interface StatusBarIconController {
|
||||
protected LayoutParams onCreateLayoutParams() {
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, mIconSize);
|
||||
lp.setMargins(mIconHPadding, 0, mIconHPadding, 0);
|
||||
lp.setMargins(mIconHorizontalMargin, 0, mIconHorizontalMargin, 0);
|
||||
return lp;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,8 +145,8 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
mMeasureViews.clear();
|
||||
int mode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
final int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
final int specWidth = MeasureSpec.getSize(widthMeasureSpec);
|
||||
final int count = getChildCount();
|
||||
// Collect all of the views which want to be laid out
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -163,7 +163,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
||||
boolean trackWidth = true;
|
||||
|
||||
// Measure all children so that they report the correct width
|
||||
int childWidthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.UNSPECIFIED);
|
||||
int childWidthSpec = MeasureSpec.makeMeasureSpec(specWidth, MeasureSpec.UNSPECIFIED);
|
||||
mNeedsUnderflow = mShouldRestrictIcons && visibleCount > MAX_ICONS;
|
||||
for (int i = 0; i < visibleCount; i++) {
|
||||
// Walking backwards
|
||||
@@ -182,18 +182,35 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
||||
totalWidth += getViewTotalMeasuredWidth(child) + spacing;
|
||||
}
|
||||
}
|
||||
setMeasuredDimension(
|
||||
getMeasuredWidth(widthMode, specWidth, totalWidth),
|
||||
getMeasuredHeight(heightMeasureSpec, mMeasureViews));
|
||||
}
|
||||
|
||||
if (mode == MeasureSpec.EXACTLY) {
|
||||
if (!mNeedsUnderflow && totalWidth > width) {
|
||||
mNeedsUnderflow = true;
|
||||
}
|
||||
setMeasuredDimension(width, MeasureSpec.getSize(heightMeasureSpec));
|
||||
private int getMeasuredHeight(int heightMeasureSpec, List<View> measuredChildren) {
|
||||
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY) {
|
||||
return MeasureSpec.getSize(heightMeasureSpec);
|
||||
} else {
|
||||
if (mode == MeasureSpec.AT_MOST && totalWidth > width) {
|
||||
mNeedsUnderflow = true;
|
||||
totalWidth = width;
|
||||
int highest = 0;
|
||||
for (View child : measuredChildren) {
|
||||
highest = Math.max(child.getMeasuredHeight(), highest);
|
||||
}
|
||||
setMeasuredDimension(totalWidth, MeasureSpec.getSize(heightMeasureSpec));
|
||||
return highest + getPaddingTop() + getPaddingBottom();
|
||||
}
|
||||
}
|
||||
|
||||
private int getMeasuredWidth(int widthMode, int specWidth, int totalWidth) {
|
||||
if (widthMode == MeasureSpec.EXACTLY) {
|
||||
if (!mNeedsUnderflow && totalWidth > specWidth) {
|
||||
mNeedsUnderflow = true;
|
||||
}
|
||||
return specWidth;
|
||||
} else {
|
||||
if (widthMode == MeasureSpec.AT_MOST && totalWidth > specWidth) {
|
||||
mNeedsUnderflow = true;
|
||||
totalWidth = specWidth;
|
||||
}
|
||||
return totalWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,34 +296,6 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of ignored icon slots clearing the current list.
|
||||
* @param slots names of the icons to ignore
|
||||
*/
|
||||
public void setIgnoredSlots(List<String> slots) {
|
||||
mIgnoredSlots.clear();
|
||||
addIgnoredSlots(slots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view corresponding to a particular slot.
|
||||
*
|
||||
* Use it solely to manipulate how it is presented.
|
||||
* @param slot name of the slot to find. Names are defined in
|
||||
* {@link com.android.internal.R.config_statusBarIcons}
|
||||
* @return a view for the slot if this container has it, else {@code null}
|
||||
*/
|
||||
public View getViewForSlot(String slot) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child instanceof StatusIconDisplayable
|
||||
&& ((StatusIconDisplayable) child).getSlot().equals(slot)) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Layout is happening from end -> start
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user