Revert "Make keyboard backlight indicator more accessible"
This reverts commit 8109c21051217397b8038c7c48c5af8a521bc809.
Reason for revert: This appears to be causing all of our unit tests to flake
Change-Id: I0f903c03444f2d2ac99f12f25a7d1f1727beabd7
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 0359fc4..a2637d5 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -3255,9 +3255,4 @@
<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 1e9be09..e16bb0b 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,7 +30,6 @@
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
@@ -79,29 +78,23 @@
private lateinit var stepProperties: StepViewProperties
@ColorInt
- private val filledRectangleColor =
- getColorFromStyle(com.android.internal.R.attr.materialColorPrimary)
+ var filledRectangleColor = getColorFromStyle(com.android.internal.R.attr.materialColorPrimary)
@ColorInt
- private val emptyRectangleColor =
+ var emptyRectangleColor =
getColorFromStyle(com.android.internal.R.attr.materialColorOutlineVariant)
@ColorInt
- private val backgroundColor =
- getColorFromStyle(com.android.internal.R.attr.materialColorSurfaceBright)
+ var backgroundColor = getColorFromStyle(com.android.internal.R.attr.materialColorSurfaceBright)
@ColorInt
- private val defaultIconColor =
- getColorFromStyle(com.android.internal.R.attr.materialColorOnPrimary)
+ var defaultIconColor = getColorFromStyle(com.android.internal.R.attr.materialColorOnPrimary)
@ColorInt
- private val defaultIconBackgroundColor =
+ var defaultIconBackgroundColor =
getColorFromStyle(com.android.internal.R.attr.materialColorPrimary)
@ColorInt
- private val dimmedIconColor =
- getColorFromStyle(com.android.internal.R.attr.materialColorOnSurface)
+ var dimmedIconColor = getColorFromStyle(com.android.internal.R.attr.materialColorOnSurface)
@ColorInt
- private val dimmedIconBackgroundColor =
+ var dimmedIconBackgroundColor =
getColorFromStyle(com.android.internal.R.attr.materialColorSurfaceDim)
- private val levelContentDescription = context.getString(R.string.keyboard_backlight_value)
-
init {
currentLevel = initialCurrentLevel
maxLevel = initialMaxLevel
@@ -110,8 +103,6 @@
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)
@@ -168,12 +159,6 @@
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() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialogTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialogTest.kt
deleted file mode 100644
index 8b572eb..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialogTest.kt
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.systemui.keyboard.backlight.ui.view
-
-import android.testing.TestableLooper.RunWithLooper
-import android.view.View
-import android.view.accessibility.AccessibilityEvent
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.res.R
-import com.google.common.truth.Truth.assertThat
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-
-@RunWithLooper
-@SmallTest
-@RunWith(JUnit4::class)
-class KeyboardBacklightDialogTest : SysuiTestCase() {
-
- private lateinit var dialog: KeyboardBacklightDialog
- private lateinit var rootView: View
- private val descriptionString = context.getString(R.string.keyboard_backlight_value)
-
- @Before
- fun setUp() {
- dialog =
- KeyboardBacklightDialog(context, initialCurrentLevel = 0, initialMaxLevel = MAX_LEVEL)
- dialog.show()
- rootView = dialog.requireViewById(R.id.keyboard_backlight_dialog_container)
- }
-
- @Test
- fun rootViewContentDescription_containsInitialLevel() {
- assertThat(rootView.contentDescription).isEqualTo(contentDescriptionForLevel(INITIAL_LEVEL))
- }
-
- @Test
- fun contentDescriptionUpdated_afterEveryLevelUpdate() {
- val events = startCollectingAccessibilityEvents(rootView)
-
- dialog.updateState(current = 1, max = MAX_LEVEL)
-
- assertThat(rootView.contentDescription).isEqualTo(contentDescriptionForLevel(1))
- assertThat(events).contains(AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION)
- }
-
- private fun contentDescriptionForLevel(level: Int): String {
- return String.format(descriptionString, level, MAX_LEVEL)
- }
-
- private fun startCollectingAccessibilityEvents(rootView: View): MutableList<Int> {
- val events = mutableListOf<Int>()
- rootView.accessibilityDelegate =
- object : View.AccessibilityDelegate() {
- override fun sendAccessibilityEvent(host: View, eventType: Int) {
- super.sendAccessibilityEvent(host, eventType)
- events.add(eventType)
- }
- }
- return events
- }
-
- companion object {
- private const val MAX_LEVEL = 5
- private const val INITIAL_LEVEL = 0
- }
-}