diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 8780f58743cdce5e2b026aae8f6a50a389bd54c3..9a3c6d5b322f28b91acc5178ebcaadc9d7d23515 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -3266,4 +3266,9 @@ <string name="privacy_dialog_active_app_usage_2">In use by <xliff:g id="app_name" example="Gmail">%1$s</xliff:g> (<xliff:g id="attribution_label" example="For Wallet">%2$s</xliff:g> \u2022 <xliff:g id="proxy_label" example="Speech services">%3$s</xliff:g>)</string> <!-- Label for recent app usage of a phone sensor with sub-attribution and proxy label in the privacy dialog [CHAR LIMIT=NONE] --> <string name="privacy_dialog_recent_app_usage_2">Recently used by <xliff:g id="app_name" example="Gmail">%1$s</xliff:g> (<xliff:g id="attribution_label" example="For Wallet">%2$s</xliff:g> \u2022 <xliff:g id="proxy_label" example="Speech services">%3$s</xliff:g>)</string> + + <!-- Content description for keyboard backlight brightness dialog [CHAR LIMIT=NONE] --> + <string name="keyboard_backlight_dialog_title">Keyboard backlight</string> + <!-- Content description for keyboard backlight brightness value [CHAR LIMIT=NONE] --> + <string name="keyboard_backlight_value">Level %1$d of %2$d</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt b/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt index e16bb0bb848214c0f4e4c4c60d2621232f07b30e..1e9be09bc3f3677785587f9eaaf53db1b96f29b2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt @@ -30,6 +30,7 @@ import android.view.View import android.view.ViewGroup.MarginLayoutParams import android.view.Window import android.view.WindowManager +import android.view.accessibility.AccessibilityEvent import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout @@ -78,23 +79,29 @@ class KeyboardBacklightDialog( private lateinit var stepProperties: StepViewProperties @ColorInt - var filledRectangleColor = getColorFromStyle(com.android.internal.R.attr.materialColorPrimary) + private val filledRectangleColor = + getColorFromStyle(com.android.internal.R.attr.materialColorPrimary) @ColorInt - var emptyRectangleColor = + private val emptyRectangleColor = getColorFromStyle(com.android.internal.R.attr.materialColorOutlineVariant) @ColorInt - var backgroundColor = getColorFromStyle(com.android.internal.R.attr.materialColorSurfaceBright) + private val backgroundColor = + getColorFromStyle(com.android.internal.R.attr.materialColorSurfaceBright) @ColorInt - var defaultIconColor = getColorFromStyle(com.android.internal.R.attr.materialColorOnPrimary) + private val defaultIconColor = + getColorFromStyle(com.android.internal.R.attr.materialColorOnPrimary) @ColorInt - var defaultIconBackgroundColor = + private val defaultIconBackgroundColor = getColorFromStyle(com.android.internal.R.attr.materialColorPrimary) @ColorInt - var dimmedIconColor = getColorFromStyle(com.android.internal.R.attr.materialColorOnSurface) + private val dimmedIconColor = + getColorFromStyle(com.android.internal.R.attr.materialColorOnSurface) @ColorInt - var dimmedIconBackgroundColor = + private val dimmedIconBackgroundColor = getColorFromStyle(com.android.internal.R.attr.materialColorSurfaceDim) + private val levelContentDescription = context.getString(R.string.keyboard_backlight_value) + init { currentLevel = initialCurrentLevel maxLevel = initialMaxLevel @@ -103,6 +110,8 @@ class KeyboardBacklightDialog( override fun onCreate(savedInstanceState: Bundle?) { setUpWindowProperties(this) setWindowPosition() + // title is used for a11y announcement + window?.setTitle(context.getString(R.string.keyboard_backlight_dialog_title)) updateResources() rootView = buildRootView() setContentView(rootView) @@ -159,6 +168,12 @@ class KeyboardBacklightDialog( currentLevel = current updateIconTile() updateStepColors() + updateAccessibilityInfo() + } + + private fun updateAccessibilityInfo() { + rootView.contentDescription = String.format(levelContentDescription, currentLevel, maxLevel) + rootView.sendAccessibilityEvent(AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION) } private fun updateIconTile() {