Merge changes from topic "icon_sp" into udc-qpr-dev am: 2befc23192
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23388857 Change-Id: I67812c97e823a8413b52632600f37729e6173fd7 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -95,8 +95,10 @@
|
|||||||
<dimen name="navigation_bar_height_landscape_car_mode">96dp</dimen>
|
<dimen name="navigation_bar_height_landscape_car_mode">96dp</dimen>
|
||||||
<!-- Width of the navigation bar when it is placed vertically on the screen in car mode -->
|
<!-- 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>
|
<dimen name="navigation_bar_width_car_mode">96dp</dimen>
|
||||||
<!-- Height of notification icons in the status bar -->
|
<!-- Original dp height of notification icons in the status bar -->
|
||||||
<dimen name="status_bar_icon_size">22dip</dimen>
|
<dimen name="status_bar_icon_size">22dip</dimen>
|
||||||
|
<!-- New sp height of notification icons in the status bar -->
|
||||||
|
<dimen name="status_bar_icon_size_sp">22sp</dimen>
|
||||||
<!-- Desired size of system icons in status bar. -->
|
<!-- Desired size of system icons in status bar. -->
|
||||||
<dimen name="status_bar_system_icon_size">15dp</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
|
<!-- Intrinsic size of most system icons in status bar. This is the default value that
|
||||||
|
|||||||
@@ -2298,6 +2298,7 @@
|
|||||||
|
|
||||||
<java-symbol type="bool" name="config_alwaysUseCdmaRssi" />
|
<java-symbol type="bool" name="config_alwaysUseCdmaRssi" />
|
||||||
<java-symbol type="dimen" name="status_bar_icon_size" />
|
<java-symbol type="dimen" name="status_bar_icon_size" />
|
||||||
|
<java-symbol type="dimen" name="status_bar_icon_size_sp" />
|
||||||
<java-symbol type="dimen" name="status_bar_system_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="dimen" name="status_bar_system_icon_intrinsic_size" />
|
||||||
<java-symbol type="drawable" name="list_selector_pressed_holo_dark" />
|
<java-symbol type="drawable" name="list_selector_pressed_holo_dark" />
|
||||||
|
|||||||
@@ -30,12 +30,13 @@
|
|||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/inout_container"
|
android:id="@+id/inout_container"
|
||||||
android:layout_height="17dp"
|
android:layout_height="@dimen/status_bar_mobile_inout_container_size"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center_vertical">
|
android:layout_gravity="center_vertical">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/mobile_in"
|
android:id="@+id/mobile_in"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/status_bar_mobile_signal_size"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:src="@drawable/ic_activity_down"
|
android:src="@drawable/ic_activity_down"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
@@ -43,7 +44,8 @@
|
|||||||
/>
|
/>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/mobile_out"
|
android:id="@+id/mobile_out"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/status_bar_mobile_signal_size"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:src="@drawable/ic_activity_up"
|
android:src="@drawable/ic_activity_up"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
@@ -52,11 +54,12 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/mobile_type"
|
android:id="@+id/mobile_type"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/status_bar_mobile_signal_size"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingStart="2.5dp"
|
android:adjustViewBounds="true"
|
||||||
android:paddingEnd="1dp"
|
android:paddingStart="2.5sp"
|
||||||
|
android:paddingEnd="1sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
<Space
|
<Space
|
||||||
android:id="@+id/mobile_roaming_space"
|
android:id="@+id/mobile_roaming_space"
|
||||||
@@ -70,14 +73,14 @@
|
|||||||
android:layout_gravity="center_vertical">
|
android:layout_gravity="center_vertical">
|
||||||
<com.android.systemui.statusbar.AnimatedImageView
|
<com.android.systemui.statusbar.AnimatedImageView
|
||||||
android:id="@+id/mobile_signal"
|
android:id="@+id/mobile_signal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/status_bar_mobile_signal_size"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="@dimen/status_bar_mobile_signal_size"
|
||||||
systemui:hasOverlappingRendering="false"
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/mobile_roaming"
|
android:id="@+id/mobile_roaming"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="@dimen/status_bar_mobile_signal_size"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/status_bar_mobile_signal_size"
|
||||||
android:layout_gravity="top|start"
|
android:layout_gravity="top|start"
|
||||||
android:src="@drawable/stat_sys_roaming"
|
android:src="@drawable/stat_sys_roaming"
|
||||||
android:contentDescription="@string/data_connection_roaming"
|
android:contentDescription="@string/data_connection_roaming"
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
view. -->
|
view. -->
|
||||||
<Space
|
<Space
|
||||||
android:id="@+id/icon_placeholder"
|
android:id="@+id/icon_placeholder"
|
||||||
android:layout_width="@dimen/status_bar_icon_drawing_size"
|
android:layout_width="@dimen/status_bar_icon_size_sp"
|
||||||
android:layout_height="@dimen/status_bar_icon_drawing_size"
|
android:layout_height="@dimen/status_bar_icon_size_sp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
/>
|
/>
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/notification_lights_out"
|
android:id="@+id/notification_lights_out"
|
||||||
android:layout_width="@dimen/status_bar_icon_size"
|
android:layout_width="@dimen/status_bar_icon_size_sp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingStart="@dimen/status_bar_padding_start"
|
android:paddingStart="@dimen/status_bar_padding_start"
|
||||||
android:paddingBottom="2dip"
|
android:paddingBottom="2dip"
|
||||||
|
|||||||
@@ -24,16 +24,17 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginStart="2.5dp"
|
android:layout_marginStart="2.5sp"
|
||||||
>
|
>
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/inout_container"
|
android:id="@+id/inout_container"
|
||||||
android:layout_height="17dp"
|
android:layout_height="@dimen/status_bar_wifi_inout_container_size"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:gravity="center_vertical" >
|
android:gravity="center_vertical" >
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/wifi_in"
|
android:id="@+id/wifi_in"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/status_bar_wifi_signal_size"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:src="@drawable/ic_activity_down"
|
android:src="@drawable/ic_activity_down"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
@@ -41,7 +42,8 @@
|
|||||||
/>
|
/>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/wifi_out"
|
android:id="@+id/wifi_out"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/status_bar_wifi_signal_size"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:src="@drawable/ic_activity_up"
|
android:src="@drawable/ic_activity_up"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
@@ -75,7 +77,7 @@
|
|||||||
<View
|
<View
|
||||||
android:id="@+id/wifi_airplane_spacer"
|
android:id="@+id/wifi_airplane_spacer"
|
||||||
android:layout_width="@dimen/status_bar_airplane_spacer_width"
|
android:layout_width="@dimen/status_bar_airplane_spacer_width"
|
||||||
android:layout_height="4dp"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
/>
|
/>
|
||||||
</com.android.keyguard.AlphaOptimizedLinearLayout>
|
</com.android.keyguard.AlphaOptimizedLinearLayout>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<dimen name="status_bar_icons_padding_start">10dp</dimen>
|
<dimen name="status_bar_icons_padding_start">10dp</dimen>
|
||||||
|
|
||||||
<!-- gap on either side of status bar notification icons -->
|
<!-- gap on either side of status bar notification icons -->
|
||||||
<dimen name="status_bar_icon_horizontal_margin">1dp</dimen>
|
<dimen name="status_bar_icon_horizontal_margin">1sp</dimen>
|
||||||
|
|
||||||
<dimen name="controls_header_horizontal_padding">28dp</dimen>
|
<dimen name="controls_header_horizontal_padding">28dp</dimen>
|
||||||
<dimen name="controls_content_margin_horizontal">40dp</dimen>
|
<dimen name="controls_content_margin_horizontal">40dp</dimen>
|
||||||
|
|||||||
@@ -121,24 +121,26 @@
|
|||||||
<dimen name="navigation_edge_cancelled_arrow_height">0dp</dimen>
|
<dimen name="navigation_edge_cancelled_arrow_height">0dp</dimen>
|
||||||
<dimen name="navigation_edge_cancelled_edge_corners">6dp</dimen>
|
<dimen name="navigation_edge_cancelled_edge_corners">6dp</dimen>
|
||||||
|
|
||||||
<!-- Height of notification icons in the status bar -->
|
<!-- New sp height of notification icons in the status bar -->
|
||||||
|
<dimen name="status_bar_icon_size_sp">@*android:dimen/status_bar_icon_size_sp</dimen>
|
||||||
|
<!-- Original dp height of notification icons in the status bar -->
|
||||||
<dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen>
|
<dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen>
|
||||||
|
|
||||||
<!-- Default horizontal drawable padding for status bar icons. -->
|
<!-- Default horizontal drawable padding for status bar icons. -->
|
||||||
<dimen name="status_bar_horizontal_padding">2.5dp</dimen>
|
<dimen name="status_bar_horizontal_padding">2.5sp</dimen>
|
||||||
|
|
||||||
<!-- Height of the battery icon in the status bar. -->
|
<!-- Height of the battery icon in the status bar. -->
|
||||||
<dimen name="status_bar_battery_icon_height">13.0dp</dimen>
|
<dimen name="status_bar_battery_icon_height">13.0sp</dimen>
|
||||||
|
|
||||||
<!-- Width of the battery icon in the status bar. The battery drawable assumes a 12x20 canvas,
|
<!-- 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.0dp * (12.0 / 20.0) -->
|
so the width of the icon should be 13.0sp * (12.0 / 20.0) -->
|
||||||
<dimen name="status_bar_battery_icon_width">7.8dp</dimen>
|
<dimen name="status_bar_battery_icon_width">7.8sp</dimen>
|
||||||
|
|
||||||
<!-- The battery icon is 13dp tall, but the other system icons are 15dp tall (see
|
<!-- The battery icon is 13sp tall, but the other system icons are 15sp tall (see
|
||||||
@*android:dimen/status_bar_system_icon_size) with some top and bottom padding embedded in
|
@*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 1dp 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. -->
|
bottom still aligns with the bottom of all the other system icons. See b/258672854. -->
|
||||||
<dimen name="status_bar_battery_extra_vertical_spacing">1dp</dimen>
|
<dimen name="status_bar_battery_extra_vertical_spacing">1sp</dimen>
|
||||||
|
|
||||||
<!-- The font size for the clock in the status bar. -->
|
<!-- The font size for the clock in the status bar. -->
|
||||||
<dimen name="status_bar_clock_size">14sp</dimen>
|
<dimen name="status_bar_clock_size">14sp</dimen>
|
||||||
@@ -153,19 +155,26 @@
|
|||||||
<dimen name="status_bar_left_clock_starting_padding">0dp</dimen>
|
<dimen name="status_bar_left_clock_starting_padding">0dp</dimen>
|
||||||
|
|
||||||
<!-- End padding for left-aligned status bar clock -->
|
<!-- End padding for left-aligned status bar clock -->
|
||||||
<dimen name="status_bar_left_clock_end_padding">2dp</dimen>
|
<dimen name="status_bar_left_clock_end_padding">2sp</dimen>
|
||||||
|
|
||||||
<!-- Spacing after the wifi signals that is present if there are any icons following it. -->
|
<!-- Spacing after the wifi signals that is present if there are any icons following it. -->
|
||||||
<dimen name="status_bar_wifi_signal_spacer_width">2.5dp</dimen>
|
<dimen name="status_bar_wifi_signal_spacer_width">2.5sp</dimen>
|
||||||
|
|
||||||
|
<!-- Size of the view displaying the wifi inout icon in the status bar. -->
|
||||||
|
<dimen name="status_bar_wifi_inout_container_size">17sp</dimen>
|
||||||
<!-- Size of the view displaying the wifi signal icon in the status bar. -->
|
<!-- Size of the view displaying the wifi signal icon in the status bar. -->
|
||||||
<dimen name="status_bar_wifi_signal_size">@*android:dimen/status_bar_system_icon_size</dimen>
|
<dimen name="status_bar_wifi_signal_size">13sp</dimen>
|
||||||
|
|
||||||
|
<!-- Size of the view displaying the mobile inout icon in the status bar. -->
|
||||||
|
<dimen name="status_bar_mobile_inout_container_size">17sp</dimen>
|
||||||
|
<!-- Size of the view displaying the mobile signal icon in the status bar. -->
|
||||||
|
<dimen name="status_bar_mobile_signal_size">13sp</dimen>
|
||||||
|
|
||||||
<!-- Spacing before the airplane mode icon if there are any icons preceding it. -->
|
<!-- Spacing before the airplane mode icon if there are any icons preceding it. -->
|
||||||
<dimen name="status_bar_airplane_spacer_width">4dp</dimen>
|
<dimen name="status_bar_airplane_spacer_width">4sp</dimen>
|
||||||
|
|
||||||
<!-- Spacing between system icons. -->
|
<!-- Spacing between system icons. -->
|
||||||
<dimen name="status_bar_system_icon_spacing">0dp</dimen>
|
<dimen name="status_bar_system_icon_spacing">0sp</dimen>
|
||||||
|
|
||||||
<!-- The amount to scale each of the status bar icons by. A value of 1 means no scaling. -->
|
<!-- 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>
|
<item name="status_bar_icon_scale_factor" format="float" type="dimen">1.0</item>
|
||||||
@@ -338,7 +347,7 @@
|
|||||||
<dimen name="status_bar_icons_padding_top">8dp</dimen>
|
<dimen name="status_bar_icons_padding_top">8dp</dimen>
|
||||||
|
|
||||||
<!-- gap on either side of status bar notification icons -->
|
<!-- gap on either side of status bar notification icons -->
|
||||||
<dimen name="status_bar_icon_horizontal_margin">0dp</dimen>
|
<dimen name="status_bar_icon_horizontal_margin">0sp</dimen>
|
||||||
|
|
||||||
<!-- the padding on the start of the statusbar -->
|
<!-- the padding on the start of the statusbar -->
|
||||||
<dimen name="status_bar_padding_start">8dp</dimen>
|
<dimen name="status_bar_padding_start">8dp</dimen>
|
||||||
@@ -350,10 +359,10 @@
|
|||||||
<dimen name="status_bar_padding_top">0dp</dimen>
|
<dimen name="status_bar_padding_top">0dp</dimen>
|
||||||
|
|
||||||
<!-- the radius of the overflow dot in the status bar -->
|
<!-- the radius of the overflow dot in the status bar -->
|
||||||
<dimen name="overflow_dot_radius">2dp</dimen>
|
<dimen name="overflow_dot_radius">2sp</dimen>
|
||||||
|
|
||||||
<!-- the padding between dots in the icon overflow -->
|
<!-- the padding between dots in the icon overflow -->
|
||||||
<dimen name="overflow_icon_dot_padding">3dp</dimen>
|
<dimen name="overflow_icon_dot_padding">3sp</dimen>
|
||||||
|
|
||||||
<!-- Dimensions related to screenshots -->
|
<!-- Dimensions related to screenshots -->
|
||||||
|
|
||||||
@@ -841,7 +850,7 @@
|
|||||||
|
|
||||||
<!-- Padding between the mobile signal indicator and the start icon when the roaming icon
|
<!-- Padding between the mobile signal indicator and the start icon when the roaming icon
|
||||||
is displayed in the upper left corner. -->
|
is displayed in the upper left corner. -->
|
||||||
<dimen name="roaming_icon_start_padding">2dp</dimen>
|
<dimen name="roaming_icon_start_padding">2sp</dimen>
|
||||||
|
|
||||||
<!-- Extra padding between the mobile data type icon and the strength indicator when the data
|
<!-- 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. -->
|
type icon is wide for the tile in quick settings. -->
|
||||||
@@ -1067,7 +1076,7 @@
|
|||||||
<!-- Margin between icons of Ongoing App Ops chip -->
|
<!-- Margin between icons of Ongoing App Ops chip -->
|
||||||
<dimen name="ongoing_appops_chip_icon_margin">4dp</dimen>
|
<dimen name="ongoing_appops_chip_icon_margin">4dp</dimen>
|
||||||
<!-- Icon size of Ongoing App Ops chip -->
|
<!-- Icon size of Ongoing App Ops chip -->
|
||||||
<dimen name="ongoing_appops_chip_icon_size">16dp</dimen>
|
<dimen name="ongoing_appops_chip_icon_size">16sp</dimen>
|
||||||
<!-- Radius of Ongoing App Ops chip corners -->
|
<!-- Radius of Ongoing App Ops chip corners -->
|
||||||
<dimen name="ongoing_appops_chip_bg_corner_radius">28dp</dimen>
|
<dimen name="ongoing_appops_chip_bg_corner_radius">28dp</dimen>
|
||||||
<!-- One or two privacy items -->
|
<!-- One or two privacy items -->
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
package com.android.systemui.privacy
|
package com.android.systemui.privacy
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.Gravity.CENTER_VERTICAL
|
import android.view.Gravity.CENTER_VERTICAL
|
||||||
import android.view.Gravity.END
|
import android.view.Gravity.END
|
||||||
@@ -35,6 +37,7 @@ class OngoingPrivacyChip @JvmOverloads constructor(
|
|||||||
defStyleRes: Int = 0
|
defStyleRes: Int = 0
|
||||||
) : LaunchableFrameLayout(context, attrs, defStyleAttrs, defStyleRes), BackgroundAnimatableView {
|
) : LaunchableFrameLayout(context, attrs, defStyleAttrs, defStyleRes), BackgroundAnimatableView {
|
||||||
|
|
||||||
|
private var configuration: Configuration
|
||||||
private var iconMargin = 0
|
private var iconMargin = 0
|
||||||
private var iconSize = 0
|
private var iconSize = 0
|
||||||
private var iconColor = 0
|
private var iconColor = 0
|
||||||
@@ -54,6 +57,7 @@ class OngoingPrivacyChip @JvmOverloads constructor(
|
|||||||
clipChildren = true
|
clipChildren = true
|
||||||
clipToPadding = true
|
clipToPadding = true
|
||||||
iconsContainer = requireViewById(R.id.icons_container)
|
iconsContainer = requireViewById(R.id.icons_container)
|
||||||
|
configuration = Configuration(context.resources.configuration)
|
||||||
updateResources()
|
updateResources()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +106,17 @@ class OngoingPrivacyChip @JvmOverloads constructor(
|
|||||||
R.string.ongoing_privacy_chip_content_multiple_apps, typesText)
|
R.string.ongoing_privacy_chip_content_multiple_apps, typesText)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||||
|
super.onConfigurationChanged(newConfig)
|
||||||
|
if (newConfig != null) {
|
||||||
|
val diff = newConfig.diff(configuration)
|
||||||
|
configuration.setTo(newConfig)
|
||||||
|
if (diff.and(ActivityInfo.CONFIG_DENSITY.or(ActivityInfo.CONFIG_FONT_SCALE)) != 0) {
|
||||||
|
updateResources()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateResources() {
|
private fun updateResources() {
|
||||||
iconMargin = context.resources
|
iconMargin = context.resources
|
||||||
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_icon_margin)
|
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_icon_margin)
|
||||||
@@ -110,8 +125,11 @@ class OngoingPrivacyChip @JvmOverloads constructor(
|
|||||||
iconColor =
|
iconColor =
|
||||||
Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorPrimary)
|
Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorPrimary)
|
||||||
|
|
||||||
|
val height = context.resources
|
||||||
|
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_height)
|
||||||
val padding = context.resources
|
val padding = context.resources
|
||||||
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_side_padding)
|
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_side_padding)
|
||||||
|
iconsContainer.layoutParams.height = height
|
||||||
iconsContainer.setPaddingRelative(padding, 0, padding, 0)
|
iconsContainer.setPaddingRelative(padding, 0, padding, 0)
|
||||||
iconsContainer.background = context.getDrawable(R.drawable.statusbar_privacy_chip_bg)
|
iconsContainer.background = context.getDrawable(R.drawable.statusbar_privacy_chip_bg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.annotation.IntDef;
|
|||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -46,12 +47,14 @@ import android.util.Log;
|
|||||||
import android.util.Property;
|
import android.util.Property;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.ViewDebug;
|
import android.view.ViewDebug;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.animation.Interpolator;
|
import android.view.animation.Interpolator;
|
||||||
|
|
||||||
import androidx.core.graphics.ColorUtils;
|
import androidx.core.graphics.ColorUtils;
|
||||||
|
|
||||||
import com.android.app.animation.Interpolators;
|
import com.android.app.animation.Interpolators;
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.statusbar.StatusBarIcon;
|
import com.android.internal.statusbar.StatusBarIcon;
|
||||||
import com.android.internal.util.ContrastColorUtil;
|
import com.android.internal.util.ContrastColorUtil;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -131,8 +134,11 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
|||||||
};
|
};
|
||||||
|
|
||||||
private int mStatusBarIconDrawingSizeIncreased = 1;
|
private int mStatusBarIconDrawingSizeIncreased = 1;
|
||||||
private int mStatusBarIconDrawingSize = 1;
|
@VisibleForTesting int mStatusBarIconDrawingSize = 1;
|
||||||
private int mStatusBarIconSize = 1;
|
|
||||||
|
@VisibleForTesting int mOriginalStatusBarIconSize = 1;
|
||||||
|
@VisibleForTesting int mNewStatusBarIconSize = 1;
|
||||||
|
@VisibleForTesting float mScaleToFitNewIconSize = 1;
|
||||||
private StatusBarIcon mIcon;
|
private StatusBarIcon mIcon;
|
||||||
@ViewDebug.ExportedProperty private String mSlot;
|
@ViewDebug.ExportedProperty private String mSlot;
|
||||||
private Drawable mNumberBackground;
|
private Drawable mNumberBackground;
|
||||||
@@ -142,7 +148,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
|||||||
private String mNumberText;
|
private String mNumberText;
|
||||||
private StatusBarNotification mNotification;
|
private StatusBarNotification mNotification;
|
||||||
private final boolean mBlocked;
|
private final boolean mBlocked;
|
||||||
private int mDensity;
|
private Configuration mConfiguration;
|
||||||
private boolean mNightMode;
|
private boolean mNightMode;
|
||||||
private float mIconScale = 1.0f;
|
private float mIconScale = 1.0f;
|
||||||
private final Paint mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
private final Paint mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
@@ -196,9 +202,8 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
|||||||
mNumberPain.setAntiAlias(true);
|
mNumberPain.setAntiAlias(true);
|
||||||
setNotification(sbn);
|
setNotification(sbn);
|
||||||
setScaleType(ScaleType.CENTER);
|
setScaleType(ScaleType.CENTER);
|
||||||
mDensity = context.getResources().getDisplayMetrics().densityDpi;
|
mConfiguration = new Configuration(context.getResources().getConfiguration());
|
||||||
Configuration configuration = context.getResources().getConfiguration();
|
mNightMode = (mConfiguration.uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
||||||
mNightMode = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
|
||||||
== Configuration.UI_MODE_NIGHT_YES;
|
== Configuration.UI_MODE_NIGHT_YES;
|
||||||
initializeDecorColor();
|
initializeDecorColor();
|
||||||
reloadDimens();
|
reloadDimens();
|
||||||
@@ -206,7 +211,8 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Should always be preceded by {@link #reloadDimens()} */
|
/** Should always be preceded by {@link #reloadDimens()} */
|
||||||
private void maybeUpdateIconScaleDimens() {
|
@VisibleForTesting
|
||||||
|
public void maybeUpdateIconScaleDimens() {
|
||||||
// We do not resize and scale system icons (on the right), only notification icons (on the
|
// We do not resize and scale system icons (on the right), only notification icons (on the
|
||||||
// left).
|
// left).
|
||||||
if (isNotification()) {
|
if (isNotification()) {
|
||||||
@@ -217,22 +223,63 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateIconScaleForNotifications() {
|
private void updateIconScaleForNotifications() {
|
||||||
|
float iconScale;
|
||||||
|
// we need to scale the image size to be same as the original size
|
||||||
|
// (fit mOriginalStatusBarIconSize), then we can scale it with mScaleToFitNewIconSize
|
||||||
|
// to fit mNewStatusBarIconSize
|
||||||
|
float scaleToOriginalDrawingSize = 1.0f;
|
||||||
|
ViewGroup.LayoutParams lp = getLayoutParams();
|
||||||
|
if (getDrawable() != null && (lp != null && lp.width > 0 && lp.height > 0)) {
|
||||||
|
final int iconViewWidth = lp.width;
|
||||||
|
final int iconViewHeight = lp.height;
|
||||||
|
// first we estimate the image exact size when put the drawable in scaled iconView size,
|
||||||
|
// then we can compute the scaleToOriginalDrawingSize to make the image size fit in
|
||||||
|
// mOriginalStatusBarIconSize
|
||||||
|
final int drawableWidth = getDrawable().getIntrinsicWidth();
|
||||||
|
final int drawableHeight = getDrawable().getIntrinsicHeight();
|
||||||
|
float scaleToFitIconView = Math.min(
|
||||||
|
(float) iconViewWidth / drawableWidth,
|
||||||
|
(float) iconViewHeight / drawableHeight);
|
||||||
|
// if the drawable size <= the icon view size, the drawable won't be scaled
|
||||||
|
if (scaleToFitIconView > 1.0f) {
|
||||||
|
scaleToFitIconView = 1.0f;
|
||||||
|
}
|
||||||
|
final float scaledImageWidth = drawableWidth * scaleToFitIconView;
|
||||||
|
final float scaledImageHeight = drawableHeight * scaleToFitIconView;
|
||||||
|
// if the scaled image size <= mOriginalStatusBarIconSize, we don't need to enlarge it
|
||||||
|
scaleToOriginalDrawingSize = Math.min(
|
||||||
|
(float) mOriginalStatusBarIconSize / scaledImageWidth,
|
||||||
|
(float) mOriginalStatusBarIconSize / scaledImageHeight);
|
||||||
|
if (scaleToOriginalDrawingSize > 1.0f) {
|
||||||
|
scaleToOriginalDrawingSize = 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iconScale = scaleToOriginalDrawingSize;
|
||||||
|
|
||||||
final float imageBounds = mIncreasedSize ?
|
final float imageBounds = mIncreasedSize ?
|
||||||
mStatusBarIconDrawingSizeIncreased : mStatusBarIconDrawingSize;
|
mStatusBarIconDrawingSizeIncreased : mStatusBarIconDrawingSize;
|
||||||
final int outerBounds = mStatusBarIconSize;
|
final int originalOuterBounds = mOriginalStatusBarIconSize;
|
||||||
mIconScale = imageBounds / (float)outerBounds;
|
iconScale = iconScale * (imageBounds / (float) originalOuterBounds);
|
||||||
|
|
||||||
|
// scale image to fit new icon size
|
||||||
|
mIconScale = iconScale * mScaleToFitNewIconSize;
|
||||||
|
|
||||||
updatePivot();
|
updatePivot();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Makes sure that all icons are scaled to the same height (15dp). 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
|
// for the icon, it uses the default SCALE (15f / 17f) which is the old behavior
|
||||||
private void updateIconScaleForSystemIcons() {
|
private void updateIconScaleForSystemIcons() {
|
||||||
|
float iconScale;
|
||||||
float iconHeight = getIconHeight();
|
float iconHeight = getIconHeight();
|
||||||
if (iconHeight != 0) {
|
if (iconHeight != 0) {
|
||||||
mIconScale = mSystemIconDesiredHeight / iconHeight;
|
iconScale = mSystemIconDesiredHeight / iconHeight;
|
||||||
} else {
|
} else {
|
||||||
mIconScale = mSystemIconDefaultScale;
|
iconScale = mSystemIconDefaultScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scale image to fit new icon size
|
||||||
|
mIconScale = iconScale * mScaleToFitNewIconSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getIconHeight() {
|
private float getIconHeight() {
|
||||||
@@ -255,12 +302,10 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
|||||||
@Override
|
@Override
|
||||||
protected void onConfigurationChanged(Configuration newConfig) {
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
int density = newConfig.densityDpi;
|
final int configDiff = newConfig.diff(mConfiguration);
|
||||||
if (density != mDensity) {
|
mConfiguration.setTo(newConfig);
|
||||||
mDensity = density;
|
if ((configDiff & (ActivityInfo.CONFIG_DENSITY | ActivityInfo.CONFIG_FONT_SCALE)) != 0) {
|
||||||
reloadDimens();
|
updateIconDimens();
|
||||||
updateDrawable();
|
|
||||||
maybeUpdateIconScaleDimens();
|
|
||||||
}
|
}
|
||||||
boolean nightMode = (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
boolean nightMode = (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
||||||
== Configuration.UI_MODE_NIGHT_YES;
|
== Configuration.UI_MODE_NIGHT_YES;
|
||||||
@@ -270,11 +315,22 @@ 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() {
|
private void reloadDimens() {
|
||||||
boolean applyRadius = mDotRadius == mStaticDotRadius;
|
boolean applyRadius = mDotRadius == mStaticDotRadius;
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
mStaticDotRadius = res.getDimensionPixelSize(R.dimen.overflow_dot_radius);
|
mStaticDotRadius = res.getDimensionPixelSize(R.dimen.overflow_dot_radius);
|
||||||
mStatusBarIconSize = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
|
mOriginalStatusBarIconSize = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
|
||||||
|
mNewStatusBarIconSize = res.getDimensionPixelSize(R.dimen.status_bar_icon_size_sp);
|
||||||
|
mScaleToFitNewIconSize = (float) mNewStatusBarIconSize / mOriginalStatusBarIconSize;
|
||||||
mStatusBarIconDrawingSizeIncreased =
|
mStatusBarIconDrawingSizeIncreased =
|
||||||
res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size_dark);
|
res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size_dark);
|
||||||
mStatusBarIconDrawingSize =
|
mStatusBarIconDrawingSize =
|
||||||
@@ -482,12 +538,30 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
|||||||
updateDrawable();
|
updateDrawable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
|
||||||
|
if (!isNotification()) {
|
||||||
|
// for system icons, calculated measured width from super is for image drawable real
|
||||||
|
// width (17dp). We may scale the image with font scale, so we also need to scale the
|
||||||
|
// measured width so that scaled measured width and image width would be fit.
|
||||||
|
int measuredWidth = getMeasuredWidth();
|
||||||
|
int measuredHeight = getMeasuredHeight();
|
||||||
|
setMeasuredDimension((int) (measuredWidth * mScaleToFitNewIconSize), measuredHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
|
// In this method, for width/height division computation we intend to discard the
|
||||||
|
// fractional part as the original behavior.
|
||||||
if (mIconAppearAmount > 0.0f) {
|
if (mIconAppearAmount > 0.0f) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
|
int px = getWidth() / 2;
|
||||||
|
int py = getHeight() / 2;
|
||||||
canvas.scale(mIconScale * mIconAppearAmount, mIconScale * mIconAppearAmount,
|
canvas.scale(mIconScale * mIconAppearAmount, mIconScale * mIconAppearAmount,
|
||||||
getWidth() / 2, getHeight() / 2);
|
(float) px, (float) py);
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
@@ -504,10 +578,15 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
|||||||
} else {
|
} else {
|
||||||
float fadeOutAmount = mDotAppearAmount - 1.0f;
|
float fadeOutAmount = mDotAppearAmount - 1.0f;
|
||||||
alpha = alpha * (1.0f - fadeOutAmount);
|
alpha = alpha * (1.0f - fadeOutAmount);
|
||||||
radius = NotificationUtils.interpolate(mDotRadius, getWidth() / 4, fadeOutAmount);
|
int end = getWidth() / 4;
|
||||||
|
radius = NotificationUtils.interpolate(mDotRadius, (float) end, fadeOutAmount);
|
||||||
}
|
}
|
||||||
mDotPaint.setAlpha((int) (alpha * 255));
|
mDotPaint.setAlpha((int) (alpha * 255));
|
||||||
canvas.drawCircle(mStatusBarIconSize / 2, getHeight() / 2, radius, mDotPaint);
|
int cx = mNewStatusBarIconSize / 2;
|
||||||
|
int cy = getHeight() / 2;
|
||||||
|
canvas.drawCircle(
|
||||||
|
(float) cx, (float) cy,
|
||||||
|
radius, mDotPaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class StatusBarMobileView extends BaseStatusBarFrameLayout implements Dar
|
|||||||
mDotView = new StatusBarIconView(mContext, mSlot, null);
|
mDotView = new StatusBarIconView(mContext, mSlot, null);
|
||||||
mDotView.setVisibleState(STATE_DOT);
|
mDotView.setVisibleState(STATE_DOT);
|
||||||
|
|
||||||
int width = mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size);
|
int width = mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size_sp);
|
||||||
LayoutParams lp = new LayoutParams(width, width);
|
LayoutParams lp = new LayoutParams(width, width);
|
||||||
lp.gravity = Gravity.CENTER_VERTICAL | Gravity.START;
|
lp.gravity = Gravity.CENTER_VERTICAL | Gravity.START;
|
||||||
addView(mDotView, lp);
|
addView(mDotView, lp);
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public class StatusBarWifiView extends BaseStatusBarFrameLayout implements DarkR
|
|||||||
mDotView = new StatusBarIconView(mContext, mSlot, null);
|
mDotView = new StatusBarIconView(mContext, mSlot, null);
|
||||||
mDotView.setVisibleState(STATE_DOT);
|
mDotView.setVisibleState(STATE_DOT);
|
||||||
|
|
||||||
int width = mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size);
|
int width = mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size_sp);
|
||||||
LayoutParams lp = new LayoutParams(width, width);
|
LayoutParams lp = new LayoutParams(width, width);
|
||||||
lp.gravity = Gravity.CENTER_VERTICAL | Gravity.START;
|
lp.gravity = Gravity.CENTER_VERTICAL | Gravity.START;
|
||||||
addView(mDotView, lp);
|
addView(mDotView, lp);
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public class NotificationIconAreaController implements
|
|||||||
|
|
||||||
private void reloadDimens(Context context) {
|
private void reloadDimens(Context context) {
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
|
mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size_sp);
|
||||||
mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_horizontal_margin);
|
mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_horizontal_margin);
|
||||||
mAodIconAppearTranslation = res.getDimensionPixelSize(
|
mAodIconAppearTranslation = res.getDimensionPixelSize(
|
||||||
R.dimen.shelf_appear_translation);
|
R.dimen.shelf_appear_translation);
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ public class NotificationIconContainer extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (child instanceof StatusBarIconView) {
|
if (child instanceof StatusBarIconView) {
|
||||||
|
((StatusBarIconView) child).updateIconDimens();
|
||||||
((StatusBarIconView) child).setDozing(mDozing, false, 0);
|
((StatusBarIconView) child).setDozing(mDozing, false, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,9 +538,10 @@ public class NotificationIconContainer extends ViewGroup {
|
|||||||
IconState iconState = mIconStates.get(mIsolatedIcon);
|
IconState iconState = mIconStates.get(mIsolatedIcon);
|
||||||
if (iconState != null) {
|
if (iconState != null) {
|
||||||
// Most of the time the icon isn't yet added when this is called but only happening
|
// Most of the time the icon isn't yet added when this is called but only happening
|
||||||
// later
|
// later. The isolated icon position left should equal to the mIsolatedIconLocation
|
||||||
iconState.setXTranslation(mIsolatedIconLocation.left - mAbsolutePosition[0]
|
// to ensure the icon be put at the center of the HUN icon placeholder,
|
||||||
- (1 - mIsolatedIcon.getIconScale()) * mIsolatedIcon.getWidth() / 2.0f);
|
// {@See HeadsUpAppearanceController#updateIsolatedIconLocation}.
|
||||||
|
iconState.setXTranslation(mIsolatedIconLocation.left - mAbsolutePosition[0]);
|
||||||
iconState.visibleState = StatusBarIconView.STATE_ICON;
|
iconState.visibleState = StatusBarIconView.STATE_ICON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ public interface StatusBarIconController {
|
|||||||
private final MobileIconsViewModel mMobileIconsViewModel;
|
private final MobileIconsViewModel mMobileIconsViewModel;
|
||||||
|
|
||||||
protected final Context mContext;
|
protected final Context mContext;
|
||||||
protected final int mIconSize;
|
protected int mIconSize;
|
||||||
// Whether or not these icons show up in dumpsys
|
// Whether or not these icons show up in dumpsys
|
||||||
protected boolean mShouldLog = false;
|
protected boolean mShouldLog = false;
|
||||||
private StatusBarIconController mController;
|
private StatusBarIconController mController;
|
||||||
@@ -395,10 +395,10 @@ public interface StatusBarIconController {
|
|||||||
mStatusBarPipelineFlags = statusBarPipelineFlags;
|
mStatusBarPipelineFlags = statusBarPipelineFlags;
|
||||||
mMobileContextProvider = mobileContextProvider;
|
mMobileContextProvider = mobileContextProvider;
|
||||||
mContext = group.getContext();
|
mContext = group.getContext();
|
||||||
mIconSize = mContext.getResources().getDimensionPixelSize(
|
|
||||||
com.android.internal.R.dimen.status_bar_icon_size);
|
|
||||||
mLocation = location;
|
mLocation = location;
|
||||||
|
|
||||||
|
reloadDimens();
|
||||||
|
|
||||||
if (statusBarPipelineFlags.runNewMobileIconsBackend()) {
|
if (statusBarPipelineFlags.runNewMobileIconsBackend()) {
|
||||||
// This starts the flow for the new pipeline, and will notify us of changes if
|
// This starts the flow for the new pipeline, and will notify us of changes if
|
||||||
// {@link StatusBarPipelineFlags#useNewMobileIcons} is also true.
|
// {@link StatusBarPipelineFlags#useNewMobileIcons} is also true.
|
||||||
@@ -609,13 +609,9 @@ public interface StatusBarIconController {
|
|||||||
mGroup.removeAllViews();
|
mGroup.removeAllViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onDensityOrFontScaleChanged() {
|
protected void reloadDimens() {
|
||||||
for (int i = 0; i < mGroup.getChildCount(); i++) {
|
mIconSize = mContext.getResources().getDimensionPixelSize(
|
||||||
View child = mGroup.getChildAt(i);
|
com.android.internal.R.dimen.status_bar_icon_size_sp);
|
||||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT, mIconSize);
|
|
||||||
child.setLayoutParams(lp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHeightAndCenter(ImageView imageView, int height) {
|
private void setHeightAndCenter(ImageView imageView, int height) {
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ public class StatusBarIconControllerImpl implements Tunable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
group.setController(this);
|
group.setController(this);
|
||||||
|
group.reloadDimens();
|
||||||
mIconGroups.add(group);
|
mIconGroups.add(group);
|
||||||
List<Slot> allSlots = mStatusBarIconList.getSlots();
|
List<Slot> allSlots = mStatusBarIconList.getSlots();
|
||||||
for (int i = 0; i < allSlots.size(); i++) {
|
for (int i = 0; i < allSlots.size(); i++) {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
|||||||
private void initDimens() {
|
private void initDimens() {
|
||||||
// This is the same value that StatusBarIconView uses
|
// This is the same value that StatusBarIconView uses
|
||||||
mIconDotFrameWidth = getResources().getDimensionPixelSize(
|
mIconDotFrameWidth = getResources().getDimensionPixelSize(
|
||||||
com.android.internal.R.dimen.status_bar_icon_size);
|
com.android.internal.R.dimen.status_bar_icon_size_sp);
|
||||||
mDotPadding = getResources().getDimensionPixelSize(R.dimen.overflow_icon_dot_padding);
|
mDotPadding = getResources().getDimensionPixelSize(R.dimen.overflow_icon_dot_padding);
|
||||||
mIconSpacing = getResources().getDimensionPixelSize(R.dimen.status_bar_system_icon_spacing);
|
mIconSpacing = getResources().getDimensionPixelSize(R.dimen.status_bar_system_icon_spacing);
|
||||||
int radius = getResources().getDimensionPixelSize(R.dimen.overflow_dot_radius);
|
int radius = getResources().getDimensionPixelSize(R.dimen.overflow_dot_radius);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ open class ModernStatusBarView(context: Context, attrs: AttributeSet?) :
|
|||||||
it.visibleState = STATE_DOT
|
it.visibleState = STATE_DOT
|
||||||
}
|
}
|
||||||
|
|
||||||
val width = mContext.resources.getDimensionPixelSize(R.dimen.status_bar_icon_size)
|
val width = mContext.resources.getDimensionPixelSize(R.dimen.status_bar_icon_size_sp)
|
||||||
val lp = LayoutParams(width, width)
|
val lp = LayoutParams(width, width)
|
||||||
lp.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
lp.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
||||||
addView(dotView, lp)
|
addView(dotView, lp)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import android.graphics.drawable.Icon;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
@@ -65,6 +66,8 @@ import org.mockito.ArgumentMatcher;
|
|||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class StatusBarIconViewTest extends SysuiTestCase {
|
public class StatusBarIconViewTest extends SysuiTestCase {
|
||||||
|
|
||||||
|
private static final int TEST_STATUS_BAR_HEIGHT = 150;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException mThrown = ExpectedException.none();
|
public ExpectedException mThrown = ExpectedException.none();
|
||||||
|
|
||||||
@@ -184,4 +187,218 @@ public class StatusBarIconViewTest extends SysuiTestCase {
|
|||||||
|
|
||||||
// no crash, good
|
// no crash, good
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateIconScale_constrainedDrawableSizeLessThanDpIconSize() {
|
||||||
|
int dpIconSize = 60;
|
||||||
|
int dpDrawingSize = 30;
|
||||||
|
// the icon view layout size would be 60x150
|
||||||
|
// (the height is always 150 due to TEST_STATUS_BAR_HEIGHT)
|
||||||
|
setUpIconView(dpIconSize, dpDrawingSize, dpIconSize);
|
||||||
|
mIconView.setNotification(mock(StatusBarNotification.class));
|
||||||
|
// the raw drawable size is 50x50. When put the drawable into iconView whose
|
||||||
|
// layout size is 60x150, the drawable size would not be constrained and thus keep 50x50
|
||||||
|
setIconDrawableWithSize(/* width= */ 50, /* height= */ 50);
|
||||||
|
mIconView.maybeUpdateIconScaleDimens();
|
||||||
|
|
||||||
|
// WHEN both the constrained drawable width/height are less than dpIconSize,
|
||||||
|
// THEN the icon is scaled down from dpIconSize to fit the dpDrawingSize
|
||||||
|
float scaleToFitDrawingSize = (float) dpDrawingSize / dpIconSize;
|
||||||
|
assertEquals(scaleToFitDrawingSize, mIconView.getIconScale(), 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateIconScale_constrainedDrawableHeightLargerThanDpIconSize() {
|
||||||
|
int dpIconSize = 60;
|
||||||
|
int dpDrawingSize = 30;
|
||||||
|
// the icon view layout size would be 60x150
|
||||||
|
// (the height is always 150 due to TEST_STATUS_BAR_HEIGHT)
|
||||||
|
setUpIconView(dpIconSize, dpDrawingSize, dpIconSize);
|
||||||
|
mIconView.setNotification(mock(StatusBarNotification.class));
|
||||||
|
// the raw drawable size is 50x100. When put the drawable into iconView whose
|
||||||
|
// layout size is 60x150, the drawable size would not be constrained and thus keep 50x100
|
||||||
|
setIconDrawableWithSize(/* width= */ 50, /* height= */ 100);
|
||||||
|
mIconView.maybeUpdateIconScaleDimens();
|
||||||
|
|
||||||
|
// WHEN constrained drawable larger side length 100 >= dpIconSize
|
||||||
|
// THEN the icon is scaled down from larger side length 100 to ensure both side
|
||||||
|
// length fit in dpDrawingSize.
|
||||||
|
float scaleToFitDrawingSize = (float) dpDrawingSize / 100;
|
||||||
|
assertEquals(scaleToFitDrawingSize, mIconView.getIconScale(), 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateIconScale_constrainedDrawableWidthLargerThanDpIconSize() {
|
||||||
|
int dpIconSize = 60;
|
||||||
|
int dpDrawingSize = 30;
|
||||||
|
// the icon view layout size would be 60x150
|
||||||
|
// (the height is always 150 due to TEST_STATUS_BAR_HEIGHT)
|
||||||
|
setUpIconView(dpIconSize, dpDrawingSize, dpIconSize);
|
||||||
|
mIconView.setNotification(mock(StatusBarNotification.class));
|
||||||
|
// the raw drawable size is 100x50. When put the drawable into iconView whose
|
||||||
|
// layout size is 60x150, the drawable size would be constrained to 60x30
|
||||||
|
setIconDrawableWithSize(/* width= */ 100, /* height= */ 50);
|
||||||
|
mIconView.maybeUpdateIconScaleDimens();
|
||||||
|
|
||||||
|
// WHEN constrained drawable larger side length 60 >= dpIconSize
|
||||||
|
// THEN the icon is scaled down from larger side length 60 to ensure both side
|
||||||
|
// length fit in dpDrawingSize.
|
||||||
|
float scaleToFitDrawingSize = (float) dpDrawingSize / 60;
|
||||||
|
assertEquals(scaleToFitDrawingSize, mIconView.getIconScale(), 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateIconScale_smallerFontAndConstrainedDrawableSizeLessThanDpIconSize() {
|
||||||
|
int dpIconSize = 60;
|
||||||
|
int dpDrawingSize = 30;
|
||||||
|
// smaller font scaling causes the spIconSize < dpIconSize
|
||||||
|
int spIconSize = 40;
|
||||||
|
// the icon view layout size would be 40x150
|
||||||
|
// (the height is always 150 due to TEST_STATUS_BAR_HEIGHT)
|
||||||
|
setUpIconView(dpIconSize, dpDrawingSize, spIconSize);
|
||||||
|
mIconView.setNotification(mock(StatusBarNotification.class));
|
||||||
|
// the raw drawable size is 50x50. When put the drawable into iconView whose
|
||||||
|
// layout size is 40x150, the drawable size would be constrained to 40x40
|
||||||
|
setIconDrawableWithSize(/* width= */ 50, /* height= */ 50);
|
||||||
|
mIconView.maybeUpdateIconScaleDimens();
|
||||||
|
|
||||||
|
// WHEN both the constrained drawable width/height are less than dpIconSize,
|
||||||
|
// THEN the icon is scaled down from dpIconSize to fit the dpDrawingSize
|
||||||
|
float scaleToFitDrawingSize = (float) dpDrawingSize / dpIconSize;
|
||||||
|
// THEN the scaled icon should be scaled down further to fit spIconSize
|
||||||
|
float scaleToFitSpIconSize = (float) spIconSize / dpIconSize;
|
||||||
|
assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, mIconView.getIconScale(), 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateIconScale_smallerFontAndConstrainedDrawableHeightLargerThanDpIconSize() {
|
||||||
|
int dpIconSize = 60;
|
||||||
|
int dpDrawingSize = 30;
|
||||||
|
// smaller font scaling causes the spIconSize < dpIconSize
|
||||||
|
int spIconSize = 40;
|
||||||
|
// the icon view layout size would be 40x150
|
||||||
|
// (the height is always 150 due to TEST_STATUS_BAR_HEIGHT)
|
||||||
|
setUpIconView(dpIconSize, dpDrawingSize, spIconSize);
|
||||||
|
mIconView.setNotification(mock(StatusBarNotification.class));
|
||||||
|
// the raw drawable size is 50x100. When put the drawable into iconView whose
|
||||||
|
// layout size is 40x150, the drawable size would be constrained to 40x80
|
||||||
|
setIconDrawableWithSize(/* width= */ 50, /* height= */ 100);
|
||||||
|
mIconView.maybeUpdateIconScaleDimens();
|
||||||
|
|
||||||
|
// WHEN constrained drawable larger side length 80 >= dpIconSize
|
||||||
|
// THEN the icon is scaled down from larger side length 80 to ensure both side
|
||||||
|
// length fit in dpDrawingSize.
|
||||||
|
float scaleToFitDrawingSize = (float) dpDrawingSize / 80;
|
||||||
|
// THEN the scaled icon should be scaled down further to fit spIconSize
|
||||||
|
float scaleToFitSpIconSize = (float) spIconSize / dpIconSize;
|
||||||
|
assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, mIconView.getIconScale(), 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateIconScale_largerFontAndConstrainedDrawableSizeLessThanDpIconSize() {
|
||||||
|
int dpIconSize = 60;
|
||||||
|
int dpDrawingSize = 30;
|
||||||
|
// larger font scaling causes the spIconSize > dpIconSize
|
||||||
|
int spIconSize = 80;
|
||||||
|
// the icon view layout size would be 80x150
|
||||||
|
// (the height is always 150 due to TEST_STATUS_BAR_HEIGHT)
|
||||||
|
setUpIconView(dpIconSize, dpDrawingSize, spIconSize);
|
||||||
|
mIconView.setNotification(mock(StatusBarNotification.class));
|
||||||
|
// the raw drawable size is 50x50. When put the drawable into iconView whose
|
||||||
|
// layout size is 80x150, the drawable size would not be constrained and thus keep 50x50
|
||||||
|
setIconDrawableWithSize(/* width= */ 50, /* height= */ 50);
|
||||||
|
mIconView.maybeUpdateIconScaleDimens();
|
||||||
|
|
||||||
|
// WHEN both the constrained drawable width/height are less than dpIconSize,
|
||||||
|
// THEN the icon is scaled down from dpIconSize to fit the dpDrawingSize
|
||||||
|
float scaleToFitDrawingSize = (float) dpDrawingSize / dpIconSize;
|
||||||
|
// THEN the scaled icon should be scaled up to fit spIconSize
|
||||||
|
float scaleToFitSpIconSize = (float) spIconSize / dpIconSize;
|
||||||
|
assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, mIconView.getIconScale(), 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateIconScale_largerFontAndConstrainedDrawableHeightLargerThanDpIconSize() {
|
||||||
|
int dpIconSize = 60;
|
||||||
|
int dpDrawingSize = 30;
|
||||||
|
// larger font scaling causes the spIconSize > dpIconSize
|
||||||
|
int spIconSize = 80;
|
||||||
|
// the icon view layout size would be 80x150
|
||||||
|
// (the height is always 150 due to TEST_STATUS_BAR_HEIGHT)
|
||||||
|
setUpIconView(dpIconSize, dpDrawingSize, spIconSize);
|
||||||
|
mIconView.setNotification(mock(StatusBarNotification.class));
|
||||||
|
// the raw drawable size is 50x100. When put the drawable into iconView whose
|
||||||
|
// layout size is 80x150, the drawable size would not be constrained and thus keep 50x100
|
||||||
|
setIconDrawableWithSize(/* width= */ 50, /* height= */ 100);
|
||||||
|
mIconView.maybeUpdateIconScaleDimens();
|
||||||
|
|
||||||
|
// WHEN constrained drawable larger side length 100 >= dpIconSize
|
||||||
|
// THEN the icon is scaled down from larger side length 100 to ensure both side
|
||||||
|
// length fit in dpDrawingSize.
|
||||||
|
float scaleToFitDrawingSize = (float) dpDrawingSize / 100;
|
||||||
|
// THEN the scaled icon should be scaled up to fit spIconSize
|
||||||
|
float scaleToFitSpIconSize = (float) spIconSize / dpIconSize;
|
||||||
|
assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, mIconView.getIconScale(), 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateIconScale_largerFontAndConstrainedDrawableWidthLargerThanDpIconSize() {
|
||||||
|
int dpIconSize = 60;
|
||||||
|
int dpDrawingSize = 30;
|
||||||
|
// larger font scaling causes the spIconSize > dpIconSize
|
||||||
|
int spIconSize = 80;
|
||||||
|
// the icon view layout size would be 80x150
|
||||||
|
// (the height is always 150 due to TEST_STATUS_BAR_HEIGHT)
|
||||||
|
setUpIconView(dpIconSize, dpDrawingSize, spIconSize);
|
||||||
|
mIconView.setNotification(mock(StatusBarNotification.class));
|
||||||
|
// the raw drawable size is 100x50. When put the drawable into iconView whose
|
||||||
|
// layout size is 80x150, the drawable size would not be constrained and thus keep 80x40
|
||||||
|
setIconDrawableWithSize(/* width= */ 100, /* height= */ 50);
|
||||||
|
mIconView.maybeUpdateIconScaleDimens();
|
||||||
|
|
||||||
|
// WHEN constrained drawable larger side length 80 >= dpIconSize
|
||||||
|
// THEN the icon is scaled down from larger side length 80 to ensure both side
|
||||||
|
// length fit in dpDrawingSize.
|
||||||
|
float scaleToFitDrawingSize = (float) dpDrawingSize / 80;
|
||||||
|
// THEN the scaled icon should be scaled up to fit spIconSize
|
||||||
|
float scaleToFitSpIconSize = (float) spIconSize / dpIconSize;
|
||||||
|
assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize,
|
||||||
|
mIconView.getIconScale(), 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup iconView dimens for testing. The result icon view layout width would
|
||||||
|
* be spIconSize and height would be 150.
|
||||||
|
*
|
||||||
|
* @param dpIconSize corresponding to status_bar_icon_size
|
||||||
|
* @param dpDrawingSize corresponding to status_bar_icon_drawing_size
|
||||||
|
* @param spIconSize corresponding to status_bar_icon_size_sp under different font scaling
|
||||||
|
*/
|
||||||
|
private void setUpIconView(int dpIconSize, int dpDrawingSize, int spIconSize) {
|
||||||
|
mIconView.setIncreasedSize(false);
|
||||||
|
mIconView.mOriginalStatusBarIconSize = dpIconSize;
|
||||||
|
mIconView.mStatusBarIconDrawingSize = dpDrawingSize;
|
||||||
|
|
||||||
|
mIconView.mNewStatusBarIconSize = spIconSize;
|
||||||
|
mIconView.mScaleToFitNewIconSize = (float) spIconSize / dpIconSize;
|
||||||
|
|
||||||
|
// the layout width would be spIconSize + 2 * iconPadding, and we assume iconPadding
|
||||||
|
// is 0 here.
|
||||||
|
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(spIconSize, TEST_STATUS_BAR_HEIGHT);
|
||||||
|
mIconView.setLayoutParams(lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setIconDrawableWithSize(int width, int height) {
|
||||||
|
Bitmap bitmap = Bitmap.createBitmap(
|
||||||
|
width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
Icon icon = Icon.createWithBitmap(bitmap);
|
||||||
|
mStatusBarIcon = new StatusBarIcon(UserHandle.ALL, "mockPackage",
|
||||||
|
icon, 0, 0, "");
|
||||||
|
// Since we only want to verify icon scale logic here, we directly use
|
||||||
|
// {@link StatusBarIconView#setImageDrawable(Drawable)} to set the image drawable
|
||||||
|
// to iconView instead of call {@link StatusBarIconView#set(StatusBarIcon)}. It's to prevent
|
||||||
|
// the icon drawable size being scaled down when internally calling
|
||||||
|
// {@link StatusBarIconView#getIcon(Context,Context,StatusBarIcon)}.
|
||||||
|
mIconView.setImageDrawable(icon.loadDrawable(mContext));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user