Merge "Revert "fix(non linear font scaling): fix status bar ui broken when 200% font scaling"" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b26d3a557e
@@ -96,12 +96,12 @@
|
||||
<!-- Width of the navigation bar when it is placed vertically on the screen in car mode -->
|
||||
<dimen name="navigation_bar_width_car_mode">96dp</dimen>
|
||||
<!-- Height of notification icons in the status bar -->
|
||||
<dimen name="status_bar_icon_size">18sp</dimen>
|
||||
<dimen name="status_bar_icon_size">22dip</dimen>
|
||||
<!-- Desired size of system icons in status bar. -->
|
||||
<dimen name="status_bar_system_icon_size">15sp</dimen>
|
||||
<dimen name="status_bar_system_icon_size">15dp</dimen>
|
||||
<!-- Intrinsic size of most system icons in status bar. This is the default value that
|
||||
is used if a Drawable reports an intrinsic size of 0. -->
|
||||
<dimen name="status_bar_system_icon_intrinsic_size">17sp</dimen>
|
||||
<dimen name="status_bar_system_icon_intrinsic_size">17dp</dimen>
|
||||
<!-- Size of the giant number (unread count) in the notifications -->
|
||||
<dimen name="status_bar_content_number_size">48sp</dimen>
|
||||
<!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
|
||||
@@ -330,7 +330,7 @@
|
||||
<dimen name="notification_icon_circle_start">16dp</dimen>
|
||||
|
||||
<!-- size (width and height) of the icon in the notification header -->
|
||||
<dimen name="notification_header_icon_size_ambient">18sp</dimen>
|
||||
<dimen name="notification_header_icon_size_ambient">18dp</dimen>
|
||||
|
||||
<!-- The margin before the start of the app name in the header. -->
|
||||
<dimen name="notification_header_app_name_margin_start">3dp</dimen>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/inout_container"
|
||||
android:layout_height="@*android:dimen/status_bar_system_icon_intrinsic_size"
|
||||
android:layout_height="17dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical">
|
||||
<ImageView
|
||||
@@ -39,25 +39,24 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:src="@drawable/ic_activity_down"
|
||||
android:visibility="gone"
|
||||
android:paddingEnd="2sp"
|
||||
android:paddingEnd="2dp"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/mobile_out"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:src="@drawable/ic_activity_up"
|
||||
android:paddingEnd="2sp"
|
||||
android:paddingEnd="2dp"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
</FrameLayout>
|
||||
<ImageView
|
||||
android:id="@+id/mobile_type"
|
||||
android:layout_height="@dimen/status_bar_mobile_signal_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:adjustViewBounds="true"
|
||||
android:paddingStart="2.5sp"
|
||||
android:paddingEnd="1sp"
|
||||
android:paddingStart="2.5dp"
|
||||
android:paddingEnd="1dp"
|
||||
android:visibility="gone" />
|
||||
<Space
|
||||
android:id="@+id/mobile_roaming_space"
|
||||
@@ -71,14 +70,14 @@
|
||||
android:layout_gravity="center_vertical">
|
||||
<com.android.systemui.statusbar.AnimatedImageView
|
||||
android:id="@+id/mobile_signal"
|
||||
android:layout_height="@dimen/status_bar_mobile_signal_size"
|
||||
android:layout_width="@dimen/status_bar_mobile_signal_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
systemui:hasOverlappingRendering="false"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/mobile_roaming"
|
||||
android:layout_width="@dimen/status_bar_mobile_signal_size"
|
||||
android:layout_height="@dimen/status_bar_mobile_signal_size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/stat_sys_roaming"
|
||||
android:contentDescription="@string/data_connection_roaming"
|
||||
android:visibility="gone" />
|
||||
|
||||
@@ -126,7 +126,8 @@
|
||||
<com.android.systemui.battery.BatteryMeterView
|
||||
android:id="@+id/batteryRemainingIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="@dimen/large_screen_shade_header_min_height"
|
||||
app:layout_constraintHeight_min="@dimen/large_screen_shade_header_min_height"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:textAppearance="@style/TextAppearance.QS.Status"
|
||||
app:layout_constraintStart_toEndOf="@id/statusIcons"
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginStart="2.5sp"
|
||||
android:layout_marginStart="2.5dp"
|
||||
>
|
||||
<FrameLayout
|
||||
android:id="@+id/inout_container"
|
||||
android:layout_height="@*android:dimen/status_bar_system_icon_intrinsic_size"
|
||||
android:layout_height="17dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center_vertical" >
|
||||
<ImageView
|
||||
@@ -37,14 +37,14 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:src="@drawable/ic_activity_down"
|
||||
android:visibility="gone"
|
||||
android:paddingEnd="2sp"
|
||||
android:paddingEnd="2dp"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/wifi_out"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:src="@drawable/ic_activity_up"
|
||||
android:paddingEnd="2sp"
|
||||
android:paddingEnd="2dp"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
</FrameLayout>
|
||||
@@ -62,7 +62,7 @@
|
||||
<View
|
||||
android:id="@+id/wifi_signal_spacer"
|
||||
android:layout_width="@dimen/status_bar_wifi_signal_spacer_width"
|
||||
android:layout_height="4sp"
|
||||
android:layout_height="4dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Looks like CarStatusBar uses this... -->
|
||||
@@ -75,7 +75,7 @@
|
||||
<View
|
||||
android:id="@+id/wifi_airplane_spacer"
|
||||
android:layout_width="@dimen/status_bar_airplane_spacer_width"
|
||||
android:layout_height="4sp"
|
||||
android:layout_height="4dp"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
</com.android.keyguard.AlphaOptimizedLinearLayout>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
-->
|
||||
<resources>
|
||||
<!-- gap on either side of status bar notification icons -->
|
||||
<dimen name="status_bar_icon_padding">1sp</dimen>
|
||||
<dimen name="status_bar_icon_padding">1dp</dimen>
|
||||
|
||||
<dimen name="controls_header_horizontal_padding">28dp</dimen>
|
||||
<dimen name="controls_content_margin_horizontal">40dp</dimen>
|
||||
|
||||
@@ -122,26 +122,26 @@
|
||||
<dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen>
|
||||
|
||||
<!-- Default horizontal drawable padding for status bar icons. -->
|
||||
<dimen name="status_bar_horizontal_padding">2.5sp</dimen>
|
||||
<dimen name="status_bar_horizontal_padding">2.5dp</dimen>
|
||||
|
||||
<!-- Height of the battery icon in the status bar. -->
|
||||
<dimen name="status_bar_battery_icon_height">13.0sp</dimen>
|
||||
<dimen name="status_bar_battery_icon_height">13.0dp</dimen>
|
||||
|
||||
<!-- Width of the battery icon in the status bar. The battery drawable assumes a 12x20 canvas,
|
||||
so the width of the icon should be 13.0sp * (12.0 / 20.0) -->
|
||||
<dimen name="status_bar_battery_icon_width">7.8sp</dimen>
|
||||
so the width of the icon should be 13.0dp * (12.0 / 20.0) -->
|
||||
<dimen name="status_bar_battery_icon_width">7.8dp</dimen>
|
||||
|
||||
<!-- The battery icon is 13sp tall, but the other system icons are 15sp tall (see
|
||||
<!-- The battery icon is 13dp tall, but the other system icons are 15dp tall (see
|
||||
@*android:dimen/status_bar_system_icon_size) with some top and bottom padding embedded in
|
||||
the drawables themselves. So, the battery icon may need an extra 1sp of spacing so that its
|
||||
the drawables themselves. So, the battery icon may need an extra 1dp of spacing so that its
|
||||
bottom still aligns with the bottom of all the other system icons. See b/258672854. -->
|
||||
<dimen name="status_bar_battery_extra_vertical_spacing">1sp</dimen>
|
||||
<dimen name="status_bar_battery_extra_vertical_spacing">1dp</dimen>
|
||||
|
||||
<!-- The font size for the clock in the status bar. -->
|
||||
<dimen name="status_bar_clock_size">14sp</dimen>
|
||||
|
||||
<!-- The starting padding for the clock in the status bar. -->
|
||||
<dimen name="status_bar_clock_starting_padding">7sp</dimen>
|
||||
<dimen name="status_bar_clock_starting_padding">7dp</dimen>
|
||||
|
||||
<!-- The end padding for the clock in the status bar. -->
|
||||
<dimen name="status_bar_clock_end_padding">0dp</dimen>
|
||||
@@ -153,19 +153,16 @@
|
||||
<dimen name="status_bar_left_clock_end_padding">2dp</dimen>
|
||||
|
||||
<!-- Spacing after the wifi signals that is present if there are any icons following it. -->
|
||||
<dimen name="status_bar_wifi_signal_spacer_width">2.5sp</dimen>
|
||||
<dimen name="status_bar_wifi_signal_spacer_width">2.5dp</dimen>
|
||||
|
||||
<!-- Size of the view displaying the wifi signal icon in the status bar. -->
|
||||
<dimen name="status_bar_wifi_signal_size">13sp</dimen>
|
||||
|
||||
<!-- Size of the view displaying the mobile signal icon in the status bar. -->
|
||||
<dimen name="status_bar_mobile_signal_size">13sp</dimen>
|
||||
<dimen name="status_bar_wifi_signal_size">@*android:dimen/status_bar_system_icon_size</dimen>
|
||||
|
||||
<!-- Spacing before the airplane mode icon if there are any icons preceding it. -->
|
||||
<dimen name="status_bar_airplane_spacer_width">4sp</dimen>
|
||||
<dimen name="status_bar_airplane_spacer_width">4dp</dimen>
|
||||
|
||||
<!-- Spacing between system icons. -->
|
||||
<dimen name="status_bar_system_icon_spacing">2sp</dimen>
|
||||
<dimen name="status_bar_system_icon_spacing">0dp</dimen>
|
||||
|
||||
<!-- The amount to scale each of the status bar icons by. A value of 1 means no scaling. -->
|
||||
<item name="status_bar_icon_scale_factor" format="float" type="dimen">1.0</item>
|
||||
@@ -313,7 +310,7 @@
|
||||
<dimen name="snooze_snackbar_min_height">56dp</dimen>
|
||||
|
||||
<!-- size at which Notification icons will be drawn in the status bar -->
|
||||
<dimen name="status_bar_icon_drawing_size">15sp</dimen>
|
||||
<dimen name="status_bar_icon_drawing_size">15dp</dimen>
|
||||
|
||||
<!-- size at which Notification icons will be drawn on Ambient Display -->
|
||||
<dimen name="status_bar_icon_drawing_size_dark">
|
||||
@@ -324,22 +321,22 @@
|
||||
<item type="dimen" name="status_bar_icon_drawing_alpha">90%</item>
|
||||
|
||||
<!-- gap on either side of status bar notification icons -->
|
||||
<dimen name="status_bar_icon_padding">0sp</dimen>
|
||||
<dimen name="status_bar_icon_padding">0dp</dimen>
|
||||
|
||||
<!-- the padding on the start of the statusbar -->
|
||||
<dimen name="status_bar_padding_start">8sp</dimen>
|
||||
<dimen name="status_bar_padding_start">8dp</dimen>
|
||||
|
||||
<!-- the padding on the end of the statusbar -->
|
||||
<dimen name="status_bar_padding_end">8sp</dimen>
|
||||
<dimen name="status_bar_padding_end">8dp</dimen>
|
||||
|
||||
<!-- the padding on the top of the statusbar (usually 0) -->
|
||||
<dimen name="status_bar_padding_top">0sp</dimen>
|
||||
<dimen name="status_bar_padding_top">0dp</dimen>
|
||||
|
||||
<!-- the radius of the overflow dot in the status bar -->
|
||||
<dimen name="overflow_dot_radius">2sp</dimen>
|
||||
<dimen name="overflow_dot_radius">2dp</dimen>
|
||||
|
||||
<!-- the padding between dots in the icon overflow -->
|
||||
<dimen name="overflow_icon_dot_padding">3sp</dimen>
|
||||
<dimen name="overflow_icon_dot_padding">3dp</dimen>
|
||||
|
||||
<!-- Dimensions related to screenshots -->
|
||||
|
||||
@@ -620,8 +617,8 @@
|
||||
<dimen name="qs_footer_icon_size">20dp</dimen>
|
||||
<dimen name="qs_header_row_min_height">48dp</dimen>
|
||||
|
||||
<dimen name="qs_header_non_clickable_element_height">24sp</dimen>
|
||||
<dimen name="new_qs_header_non_clickable_element_height">24sp</dimen>
|
||||
<dimen name="qs_header_non_clickable_element_height">24dp</dimen>
|
||||
<dimen name="new_qs_header_non_clickable_element_height">24dp</dimen>
|
||||
|
||||
<dimen name="qs_footer_padding">20dp</dimen>
|
||||
<dimen name="qs_security_footer_height">88dp</dimen>
|
||||
@@ -825,7 +822,7 @@
|
||||
|
||||
<!-- Padding between the mobile signal indicator and the start icon when the roaming icon
|
||||
is displayed in the upper left corner. -->
|
||||
<dimen name="roaming_icon_start_padding">2sp</dimen>
|
||||
<dimen name="roaming_icon_start_padding">2dp</dimen>
|
||||
|
||||
<!-- Extra padding between the mobile data type icon and the strength indicator when the data
|
||||
type icon is wide for the tile in quick settings. -->
|
||||
@@ -1045,13 +1042,13 @@
|
||||
<dimen name="display_cutout_margin_consumption">0px</dimen>
|
||||
|
||||
<!-- Height of the Ongoing App Ops chip -->
|
||||
<dimen name="ongoing_appops_chip_height">24sp</dimen>
|
||||
<dimen name="ongoing_appops_chip_height">24dp</dimen>
|
||||
<!-- Side padding between background of Ongoing App Ops chip and content -->
|
||||
<dimen name="ongoing_appops_chip_side_padding">8dp</dimen>
|
||||
<!-- Margin between icons of Ongoing App Ops chip -->
|
||||
<dimen name="ongoing_appops_chip_icon_margin">4dp</dimen>
|
||||
<!-- Icon size of Ongoing App Ops chip -->
|
||||
<dimen name="ongoing_appops_chip_icon_size">16sp</dimen>
|
||||
<dimen name="ongoing_appops_chip_icon_size">16dp</dimen>
|
||||
<!-- Radius of Ongoing App Ops chip corners -->
|
||||
<dimen name="ongoing_appops_chip_bg_corner_radius">28dp</dimen>
|
||||
<!-- One or two privacy items -->
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
package com.android.systemui.privacy
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity.CENTER_VERTICAL
|
||||
import android.view.Gravity.END
|
||||
@@ -103,11 +102,6 @@ class OngoingPrivacyChip @JvmOverloads constructor(
|
||||
R.string.ongoing_privacy_chip_content_multiple_apps, typesText)
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
updateResources()
|
||||
}
|
||||
|
||||
private fun updateResources() {
|
||||
iconMargin = context.resources
|
||||
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_icon_margin)
|
||||
@@ -116,11 +110,8 @@ class OngoingPrivacyChip @JvmOverloads constructor(
|
||||
iconColor =
|
||||
Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorPrimary)
|
||||
|
||||
val height = context.resources
|
||||
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_height)
|
||||
val padding = context.resources
|
||||
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_side_padding)
|
||||
iconsContainer.layoutParams.height = height
|
||||
iconsContainer.setPaddingRelative(padding, 0, padding, 0)
|
||||
iconsContainer.background = context.getDrawable(R.drawable.statusbar_privacy_chip_bg)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.annotation.IntDef;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Notification;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
@@ -76,9 +75,9 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
*/
|
||||
private static final float DARK_ALPHA_BOOST = 0.67f;
|
||||
/**
|
||||
* Status icons are currently drawn with the intention of being 17sp tall, but we
|
||||
* want to scale them (in a way that doesn't require an asset dump) down 2sp. So
|
||||
* 17sp * (15 / 17) = 15sp, the new height. After the first call to {@link #reloadDimens} all
|
||||
* Status icons are currently drawn with the intention of being 17dp tall, but we
|
||||
* want to scale them (in a way that doesn't require an asset dump) down 2dp. So
|
||||
* 17dp * (15 / 17) = 15dp, the new height. After the first call to {@link #reloadDimens} all
|
||||
* values will be in px.
|
||||
*/
|
||||
private float mSystemIconDesiredHeight = 15f;
|
||||
@@ -145,7 +144,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
private String mNumberText;
|
||||
private StatusBarNotification mNotification;
|
||||
private final boolean mBlocked;
|
||||
private Configuration mConfiguration;
|
||||
private int mDensity;
|
||||
private boolean mNightMode;
|
||||
private float mIconScale = 1.0f;
|
||||
private final Paint mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
@@ -199,8 +198,9 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
mNumberPain.setAntiAlias(true);
|
||||
setNotification(sbn);
|
||||
setScaleType(ScaleType.CENTER);
|
||||
mConfiguration = new Configuration(context.getResources().getConfiguration());
|
||||
mNightMode = (mConfiguration.uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
||||
mDensity = context.getResources().getDisplayMetrics().densityDpi;
|
||||
Configuration configuration = context.getResources().getConfiguration();
|
||||
mNightMode = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
||||
== Configuration.UI_MODE_NIGHT_YES;
|
||||
initializeDecorColor();
|
||||
reloadDimens();
|
||||
@@ -214,7 +214,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
mAlwaysScaleIcon = true;
|
||||
reloadDimens();
|
||||
maybeUpdateIconScaleDimens();
|
||||
mConfiguration = new Configuration(context.getResources().getConfiguration());
|
||||
mDensity = context.getResources().getDisplayMetrics().densityDpi;
|
||||
}
|
||||
|
||||
/** Should always be preceded by {@link #reloadDimens()} */
|
||||
@@ -231,17 +231,12 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
private void updateIconScaleForNotifications() {
|
||||
final float imageBounds = mIncreasedSize ?
|
||||
mStatusBarIconDrawingSizeIncreased : mStatusBarIconDrawingSize;
|
||||
float iconHeight = getIconHeight();
|
||||
if (iconHeight != 0) {
|
||||
mIconScale = imageBounds / iconHeight;
|
||||
} else {
|
||||
final int outerBounds = mStatusBarIconSize;
|
||||
mIconScale = imageBounds / (float) outerBounds;
|
||||
}
|
||||
final int outerBounds = mStatusBarIconSize;
|
||||
mIconScale = imageBounds / (float)outerBounds;
|
||||
updatePivot();
|
||||
}
|
||||
|
||||
// Makes sure that all icons are scaled to the same height (15sp). If we cannot get a height
|
||||
// Makes sure that all icons are scaled to the same height (15dp). If we cannot get a height
|
||||
// for the icon, it uses the default SCALE (15f / 17f) which is the old behavior
|
||||
private void updateIconScaleForSystemIcons() {
|
||||
float iconHeight = getIconHeight();
|
||||
@@ -272,10 +267,12 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
final int configDiff = newConfig.diff(mConfiguration);
|
||||
mConfiguration.setTo(newConfig);
|
||||
if ((configDiff & (ActivityInfo.CONFIG_DENSITY | ActivityInfo.CONFIG_FONT_SCALE)) != 0) {
|
||||
updateIconDimens();
|
||||
int density = newConfig.densityDpi;
|
||||
if (density != mDensity) {
|
||||
mDensity = density;
|
||||
reloadDimens();
|
||||
updateDrawable();
|
||||
maybeUpdateIconScaleDimens();
|
||||
}
|
||||
boolean nightMode = (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
||||
== Configuration.UI_MODE_NIGHT_YES;
|
||||
@@ -285,15 +282,6 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the icon dimens and drawable with current resources
|
||||
*/
|
||||
public void updateIconDimens() {
|
||||
reloadDimens();
|
||||
updateDrawable();
|
||||
maybeUpdateIconScaleDimens();
|
||||
}
|
||||
|
||||
private void reloadDimens() {
|
||||
boolean applyRadius = mDotRadius == mStaticDotRadius;
|
||||
Resources res = getResources();
|
||||
|
||||
@@ -306,7 +306,7 @@ public class NotificationIconContainer extends ViewGroup {
|
||||
public void applyIconStates() {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
IconState childState = mIconStates.get(child);
|
||||
ViewState childState = mIconStates.get(child);
|
||||
if (childState != null) {
|
||||
childState.applyToView(child);
|
||||
}
|
||||
@@ -339,7 +339,6 @@ public class NotificationIconContainer extends ViewGroup {
|
||||
}
|
||||
}
|
||||
if (child instanceof StatusBarIconView) {
|
||||
((StatusBarIconView) child).updateIconDimens();
|
||||
((StatusBarIconView) child).setDozing(mDozing, false, 0);
|
||||
}
|
||||
}
|
||||
@@ -448,14 +447,9 @@ public class NotificationIconContainer extends ViewGroup {
|
||||
@VisibleForTesting
|
||||
boolean isOverflowing(boolean isLastChild, float translationX, float layoutEnd,
|
||||
float iconSize) {
|
||||
if (isLastChild) {
|
||||
return translationX + iconSize > layoutEnd;
|
||||
} else {
|
||||
// If the child is not the last child, we need to ensure that we have room for the next
|
||||
// icon and the dot. The dot could be as large as an icon, so verify that we have room
|
||||
// for 2 icons.
|
||||
return translationX + iconSize * 2f > layoutEnd;
|
||||
}
|
||||
// Layout end, as used here, does not include padding end.
|
||||
final float overflowX = isLastChild ? layoutEnd : layoutEnd - iconSize;
|
||||
return translationX >= overflowX;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,7 +489,10 @@ public class NotificationIconContainer extends ViewGroup {
|
||||
// First icon to overflow.
|
||||
if (firstOverflowIndex == -1 && isOverflowing) {
|
||||
firstOverflowIndex = i;
|
||||
mVisualOverflowStart = translationX;
|
||||
mVisualOverflowStart = layoutEnd - mIconSize;
|
||||
if (forceOverflow || mIsStaticLayout) {
|
||||
mVisualOverflowStart = Math.min(translationX, mVisualOverflowStart);
|
||||
}
|
||||
}
|
||||
final float drawingScale = mOnLockScreen && view instanceof StatusBarIconView
|
||||
? ((StatusBarIconView) view).getIconScaleIncreased()
|
||||
|
||||
@@ -203,7 +203,8 @@ public interface StatusBarIconController {
|
||||
|
||||
@Override
|
||||
protected LayoutParams onCreateLayoutParams() {
|
||||
LinearLayout.LayoutParams lp = super.onCreateLayoutParams();
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, mIconSize);
|
||||
lp.setMargins(mIconHPadding, 0, mIconHPadding, 0);
|
||||
return lp;
|
||||
}
|
||||
@@ -369,7 +370,7 @@ public interface StatusBarIconController {
|
||||
private final MobileIconsViewModel mMobileIconsViewModel;
|
||||
|
||||
protected final Context mContext;
|
||||
protected int mIconSize;
|
||||
protected final int mIconSize;
|
||||
// Whether or not these icons show up in dumpsys
|
||||
protected boolean mShouldLog = false;
|
||||
private StatusBarIconController mController;
|
||||
@@ -394,10 +395,10 @@ public interface StatusBarIconController {
|
||||
mStatusBarPipelineFlags = statusBarPipelineFlags;
|
||||
mMobileContextProvider = mobileContextProvider;
|
||||
mContext = group.getContext();
|
||||
mIconSize = mContext.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.status_bar_icon_size);
|
||||
mLocation = location;
|
||||
|
||||
reloadDimens();
|
||||
|
||||
if (statusBarPipelineFlags.runNewMobileIconsBackend()) {
|
||||
// This starts the flow for the new pipeline, and will notify us of changes if
|
||||
// {@link StatusBarPipelineFlags#useNewMobileIcons} is also true.
|
||||
@@ -608,9 +609,13 @@ public interface StatusBarIconController {
|
||||
mGroup.removeAllViews();
|
||||
}
|
||||
|
||||
protected void reloadDimens() {
|
||||
mIconSize = mContext.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.status_bar_icon_size);
|
||||
protected void onDensityOrFontScaleChanged() {
|
||||
for (int i = 0; i < mGroup.getChildCount(); i++) {
|
||||
View child = mGroup.getChildAt(i);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, mIconSize);
|
||||
child.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
|
||||
private void setHeightAndCenter(ImageView imageView, int height) {
|
||||
|
||||
@@ -109,7 +109,6 @@ public class StatusBarIconControllerImpl implements Tunable,
|
||||
}
|
||||
|
||||
group.setController(this);
|
||||
group.reloadDimens();
|
||||
mIconGroups.add(group);
|
||||
List<Slot> allSlots = mStatusBarIconList.getSlots();
|
||||
for (int i = 0; i < allSlots.size(); i++) {
|
||||
|
||||
@@ -22,8 +22,6 @@ import static com.android.systemui.statusbar.StatusBarIconView.STATE_ICON;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
@@ -74,16 +72,13 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
||||
// Any ignored icon will never be added as a child
|
||||
private ArrayList<String> mIgnoredSlots = new ArrayList<>();
|
||||
|
||||
private Configuration mConfiguration;
|
||||
|
||||
public StatusIconContainer(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public StatusIconContainer(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mConfiguration = new Configuration(context.getResources().getConfiguration());
|
||||
reloadDimens();
|
||||
initDimens();
|
||||
setWillNotDraw(!DEBUG_OVERFLOW);
|
||||
}
|
||||
|
||||
@@ -100,7 +95,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
||||
return mShouldRestrictIcons;
|
||||
}
|
||||
|
||||
private void reloadDimens() {
|
||||
private void initDimens() {
|
||||
// This is the same value that StatusBarIconView uses
|
||||
mIconDotFrameWidth = getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.status_bar_icon_size);
|
||||
@@ -216,16 +211,6 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
||||
child.setTag(R.id.status_bar_view_state_tag, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
final int configDiff = newConfig.diff(mConfiguration);
|
||||
mConfiguration.setTo(newConfig);
|
||||
if ((configDiff & (ActivityInfo.CONFIG_DENSITY | ActivityInfo.CONFIG_FONT_SCALE)) != 0) {
|
||||
reloadDimens();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a name of an icon slot to be ignored. It will not show up nor be measured
|
||||
* @param slotName name of the icon as it exists in
|
||||
@@ -363,17 +348,13 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
||||
int totalVisible = mLayoutStates.size();
|
||||
int maxVisible = totalVisible <= MAX_ICONS ? MAX_ICONS : MAX_ICONS - 1;
|
||||
|
||||
// Init mUnderflowStart value with the offset to let the dot be placed next to battery icon.
|
||||
// It to prevent if the underflow happens at rightest(totalVisible - 1) child then break the
|
||||
// for loop with mUnderflowStart staying 0(initial value), causing the dot be placed at the
|
||||
// leftest side.
|
||||
mUnderflowStart = (int) Math.max(contentStart, width - getPaddingEnd() - mUnderflowWidth);
|
||||
mUnderflowStart = 0;
|
||||
int visible = 0;
|
||||
int firstUnderflowIndex = -1;
|
||||
for (int i = totalVisible - 1; i >= 0; i--) {
|
||||
StatusIconState state = mLayoutStates.get(i);
|
||||
// Allow room for underflow if we found we need it in onMeasure
|
||||
if ((mNeedsUnderflow && (state.getXTranslation() < (contentStart + mUnderflowWidth)))
|
||||
if (mNeedsUnderflow && (state.getXTranslation() < (contentStart + mUnderflowWidth))
|
||||
|| (mShouldRestrictIcons && (visible >= maxVisible))) {
|
||||
firstUnderflowIndex = i;
|
||||
break;
|
||||
|
||||
@@ -21,8 +21,6 @@ import android.testing.TestableLooper.RunWithLooper
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.statusbar.StatusBarIconView
|
||||
import com.android.systemui.statusbar.StatusBarIconView.STATE_DOT
|
||||
import com.android.systemui.statusbar.StatusBarIconView.STATE_HIDDEN
|
||||
import junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertFalse
|
||||
import junit.framework.Assert.assertTrue
|
||||
@@ -51,7 +49,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
fun calculateWidthFor_oneIcon_widthForOneIcon() {
|
||||
iconContainer.setActualPaddingStart(10f)
|
||||
iconContainer.setActualPaddingEnd(10f)
|
||||
iconContainer.setIconSize(10)
|
||||
iconContainer.setIconSize(10);
|
||||
|
||||
assertEquals(/* expected= */ iconContainer.calculateWidthFor(/* numIcons= */ 1f),
|
||||
/* actual= */ 30f)
|
||||
@@ -61,7 +59,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
fun calculateWidthFor_fourIcons_widthForFourIcons() {
|
||||
iconContainer.setActualPaddingStart(10f)
|
||||
iconContainer.setActualPaddingEnd(10f)
|
||||
iconContainer.setIconSize(10)
|
||||
iconContainer.setIconSize(10);
|
||||
|
||||
assertEquals(/* expected= */ iconContainer.calculateWidthFor(/* numIcons= */ 4f),
|
||||
/* actual= */ 60f)
|
||||
@@ -71,7 +69,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
fun calculateWidthFor_fiveIcons_widthForFourIcons() {
|
||||
iconContainer.setActualPaddingStart(10f)
|
||||
iconContainer.setActualPaddingEnd(10f)
|
||||
iconContainer.setIconSize(10)
|
||||
iconContainer.setIconSize(10);
|
||||
assertEquals(/* expected= */ iconContainer.calculateWidthFor(/* numIcons= */ 5f),
|
||||
/* actual= */ 60f)
|
||||
}
|
||||
@@ -80,7 +78,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
fun calculateIconXTranslations_shortShelfOneIcon_atCorrectXWithoutOverflowDot() {
|
||||
iconContainer.setActualPaddingStart(10f)
|
||||
iconContainer.setActualPaddingEnd(10f)
|
||||
iconContainer.setIconSize(10)
|
||||
iconContainer.setIconSize(10);
|
||||
|
||||
val icon = mockStatusBarIcon()
|
||||
iconContainer.addView(icon)
|
||||
@@ -101,7 +99,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
fun calculateIconXTranslations_shortShelfFourIcons_atCorrectXWithoutOverflowDot() {
|
||||
iconContainer.setActualPaddingStart(10f)
|
||||
iconContainer.setActualPaddingEnd(10f)
|
||||
iconContainer.setIconSize(10)
|
||||
iconContainer.setIconSize(10);
|
||||
|
||||
val iconOne = mockStatusBarIcon()
|
||||
val iconTwo = mockStatusBarIcon()
|
||||
@@ -130,7 +128,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
fun calculateIconXTranslations_shortShelfFiveIcons_atCorrectXWithOverflowDot() {
|
||||
iconContainer.setActualPaddingStart(10f)
|
||||
iconContainer.setActualPaddingEnd(10f)
|
||||
iconContainer.setIconSize(10)
|
||||
iconContainer.setIconSize(10);
|
||||
|
||||
val iconOne = mockStatusBarIcon()
|
||||
val iconTwo = mockStatusBarIcon()
|
||||
@@ -155,55 +153,6 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
assertTrue(iconContainer.areIconsOverflowing())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun calculateIconXTranslations_givenWidthEnoughForThreeIcons_atCorrectXWithoutOverflowDot() {
|
||||
iconContainer.setActualPaddingStart(0f)
|
||||
iconContainer.setActualPaddingEnd(0f)
|
||||
iconContainer.setActualLayoutWidth(30)
|
||||
iconContainer.setIconSize(10)
|
||||
|
||||
val iconOne = mockStatusBarIcon()
|
||||
val iconTwo = mockStatusBarIcon()
|
||||
val iconThree = mockStatusBarIcon()
|
||||
|
||||
iconContainer.addView(iconOne)
|
||||
iconContainer.addView(iconTwo)
|
||||
iconContainer.addView(iconThree)
|
||||
assertEquals(3, iconContainer.childCount)
|
||||
|
||||
iconContainer.calculateIconXTranslations()
|
||||
assertEquals(0f, iconContainer.getIconState(iconOne).xTranslation)
|
||||
assertEquals(10f, iconContainer.getIconState(iconTwo).xTranslation)
|
||||
assertEquals(20f, iconContainer.getIconState(iconThree).xTranslation)
|
||||
assertFalse(iconContainer.areIconsOverflowing())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun calculateIconXTranslations_givenWidthNotEnoughForFourIcons_atCorrectXWithOverflowDot() {
|
||||
iconContainer.setActualPaddingStart(0f)
|
||||
iconContainer.setActualPaddingEnd(0f)
|
||||
iconContainer.setActualLayoutWidth(35)
|
||||
iconContainer.setIconSize(10)
|
||||
|
||||
val iconOne = mockStatusBarIcon()
|
||||
val iconTwo = mockStatusBarIcon()
|
||||
val iconThree = mockStatusBarIcon()
|
||||
val iconFour = mockStatusBarIcon()
|
||||
|
||||
iconContainer.addView(iconOne)
|
||||
iconContainer.addView(iconTwo)
|
||||
iconContainer.addView(iconThree)
|
||||
iconContainer.addView(iconFour)
|
||||
assertEquals(4, iconContainer.childCount)
|
||||
|
||||
iconContainer.calculateIconXTranslations()
|
||||
assertEquals(0f, iconContainer.getIconState(iconOne).xTranslation)
|
||||
assertEquals(10f, iconContainer.getIconState(iconTwo).xTranslation)
|
||||
assertEquals(STATE_DOT, iconContainer.getIconState(iconThree).visibleState)
|
||||
assertEquals(STATE_HIDDEN, iconContainer.getIconState(iconFour).visibleState)
|
||||
assertTrue(iconContainer.areIconsOverflowing())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldForceOverflow_appearingAboveSpeedBump_true() {
|
||||
val forceOverflow = iconContainer.shouldForceOverflow(
|
||||
@@ -212,7 +161,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
/* iconAppearAmount= */ 1f,
|
||||
/* maxVisibleIcons= */ 5
|
||||
)
|
||||
assertTrue(forceOverflow)
|
||||
assertTrue(forceOverflow);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,7 +172,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
/* iconAppearAmount= */ 0f,
|
||||
/* maxVisibleIcons= */ 5
|
||||
)
|
||||
assertTrue(forceOverflow)
|
||||
assertTrue(forceOverflow);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,7 +183,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
/* iconAppearAmount= */ 0f,
|
||||
/* maxVisibleIcons= */ 5
|
||||
)
|
||||
assertFalse(forceOverflow)
|
||||
assertFalse(forceOverflow);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -260,17 +209,6 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
assertTrue(isOverflowing)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isOverflowing_lastChildXGreaterThanDotX_true() {
|
||||
val isOverflowing = iconContainer.isOverflowing(
|
||||
/* isLastChild= */ true,
|
||||
/* translationX= */ 9f,
|
||||
/* layoutEnd= */ 10f,
|
||||
/* iconSize= */ 2f,
|
||||
)
|
||||
assertTrue(isOverflowing)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isOverflowing_lastChildXGreaterThanLayoutEnd_true() {
|
||||
val isOverflowing = iconContainer.isOverflowing(
|
||||
@@ -315,7 +253,7 @@ class NotificationIconContainerTest : SysuiTestCase() {
|
||||
assertTrue(isOverflowing)
|
||||
}
|
||||
|
||||
private fun mockStatusBarIcon(): StatusBarIconView {
|
||||
private fun mockStatusBarIcon() : StatusBarIconView {
|
||||
val iconView = mock(StatusBarIconView::class.java)
|
||||
whenever(iconView.width).thenReturn(10)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user