Merge "Make dimens in StatusBarIconView resources" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8281f9c42e
@@ -73,6 +73,11 @@
|
||||
<dimen name="navigation_bar_width_car_mode">96dp</dimen>
|
||||
<!-- Height of notification icons in the status bar -->
|
||||
<dimen name="status_bar_icon_size">22dip</dimen>
|
||||
<!-- Desired size of system icons in status bar. -->
|
||||
<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">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. -->
|
||||
|
||||
@@ -2279,6 +2279,8 @@
|
||||
|
||||
<java-symbol type="bool" name="config_alwaysUseCdmaRssi" />
|
||||
<java-symbol type="dimen" name="status_bar_icon_size" />
|
||||
<java-symbol type="dimen" name="status_bar_system_icon_size" />
|
||||
<java-symbol type="dimen" name="status_bar_system_icon_intrinsic_size" />
|
||||
<java-symbol type="drawable" name="list_selector_pressed_holo_dark" />
|
||||
<java-symbol type="drawable" name="scrubber_control_disabled_holo" />
|
||||
<java-symbol type="drawable" name="scrubber_control_selector_holo" />
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
<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">15dp</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">4dp</dimen>
|
||||
|
||||
@@ -40,7 +40,6 @@ import android.os.UserHandle;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.Log;
|
||||
import android.util.Property;
|
||||
@@ -72,12 +71,12 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
/**
|
||||
* 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.
|
||||
* 17dp * (15 / 17) = 15dp, the new height. After the first call to {@link #reloadDimens} all
|
||||
* values will be in px.
|
||||
*/
|
||||
private static final float SYSTEM_ICON_DESIRED_HEIGHT = 15f;
|
||||
private static final float SYSTEM_ICON_INTRINSIC_HEIGHT = 17f;
|
||||
private static final float SYSTEM_ICON_SCALE =
|
||||
SYSTEM_ICON_DESIRED_HEIGHT / SYSTEM_ICON_INTRINSIC_HEIGHT;
|
||||
private float mSystemIconDesiredHeight = 15f;
|
||||
private float mSystemIconIntrinsicHeight = 17f;
|
||||
private float mSystemIconDefaultScale = mSystemIconDesiredHeight / mSystemIconIntrinsicHeight;
|
||||
private final int ANIMATION_DURATION_FAST = 100;
|
||||
|
||||
public static final int STATE_ICON = 0;
|
||||
@@ -209,21 +208,20 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
// 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 = getIconHeightInDps();
|
||||
float iconHeight = getIconHeight();
|
||||
if (iconHeight != 0) {
|
||||
mIconScale = SYSTEM_ICON_DESIRED_HEIGHT / iconHeight;
|
||||
mIconScale = mSystemIconDesiredHeight / iconHeight;
|
||||
} else {
|
||||
mIconScale = SYSTEM_ICON_SCALE;
|
||||
mIconScale = mSystemIconDefaultScale;
|
||||
}
|
||||
}
|
||||
|
||||
private float getIconHeightInDps() {
|
||||
private float getIconHeight() {
|
||||
Drawable d = getDrawable();
|
||||
if (d != null) {
|
||||
return ((float) getDrawable().getIntrinsicHeight() * DisplayMetrics.DENSITY_DEFAULT)
|
||||
/ mDensity;
|
||||
return (float) getDrawable().getIntrinsicHeight();
|
||||
} else {
|
||||
return SYSTEM_ICON_INTRINSIC_HEIGHT;
|
||||
return mSystemIconIntrinsicHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +263,11 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
if (applyRadius) {
|
||||
mDotRadius = mStaticDotRadius;
|
||||
}
|
||||
mSystemIconDesiredHeight = res.getDimension(
|
||||
com.android.internal.R.dimen.status_bar_system_icon_size);
|
||||
mSystemIconIntrinsicHeight = res.getDimension(
|
||||
com.android.internal.R.dimen.status_bar_system_icon_intrinsic_size);
|
||||
mSystemIconDefaultScale = mSystemIconDesiredHeight / mSystemIconIntrinsicHeight;
|
||||
}
|
||||
|
||||
public void setNotification(StatusBarNotification notification) {
|
||||
@@ -272,6 +275,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
if (notification != null) {
|
||||
setContentDescription(notification.getNotification());
|
||||
}
|
||||
maybeUpdateIconScaleDimens();
|
||||
}
|
||||
|
||||
public StatusBarIconView(Context context, AttributeSet attrs) {
|
||||
@@ -280,7 +284,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
mBlocked = false;
|
||||
mAlwaysScaleIcon = true;
|
||||
reloadDimens();
|
||||
updateIconScaleForNotifications();
|
||||
maybeUpdateIconScaleDimens();
|
||||
mDensity = context.getResources().getDisplayMetrics().densityDpi;
|
||||
}
|
||||
|
||||
@@ -854,7 +858,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
public void setDark(boolean dark, boolean fade, long delay) {
|
||||
mDozer.setIntensityDark(f -> {
|
||||
mDarkAmount = f;
|
||||
updateIconScaleForNotifications();
|
||||
maybeUpdateIconScaleDimens();
|
||||
updateDecorColor();
|
||||
updateIconColor();
|
||||
updateAllowAnimation();
|
||||
|
||||
Reference in New Issue
Block a user