From f61d6ecbbffefab0b380e19cf103addc404bffe5 Mon Sep 17 00:00:00 2001 From: chelseahao Date: Thu, 9 Nov 2023 18:39:04 +0800 Subject: Make talkback to announce "double-tap to disconnect" for active devices. Also enlarged some click areas. Test: atest -c com.android.systemui.qs.tiles.dialog.bluetooth Bug: b/308878793 Change-Id: I02d05ee12624020d3bc9785fca1542cb8df82105 --- .../SystemUI/res/layout/bluetooth_device_item.xml | 3 +- .../SystemUI/res/layout/bluetooth_tile_dialog.xml | 24 ++++++++++++++++ packages/SystemUI/res/values/strings.xml | 8 ++++++ .../tiles/dialog/bluetooth/BluetoothTileDialog.kt | 33 +++++++++++++++++----- .../qs/tiles/dialog/bluetooth/DeviceItem.kt | 3 +- .../qs/tiles/dialog/bluetooth/DeviceItemFactory.kt | 8 ++++++ 6 files changed, 70 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/res/layout/bluetooth_device_item.xml b/packages/SystemUI/res/layout/bluetooth_device_item.xml index 08eccbbe9669..4336ccc70c33 100644 --- a/packages/SystemUI/res/layout/bluetooth_device_item.xml +++ b/packages/SystemUI/res/layout/bluetooth_device_item.xml @@ -21,7 +21,7 @@ style="@style/BluetoothTileDialog.Device" android:layout_width="match_parent" android:layout_height="@dimen/bluetooth_dialog_device_height" - android:paddingEnd="24dp" + android:paddingEnd="0dp" android:paddingStart="20dp" android:layout_marginBottom="4dp"> @@ -86,6 +86,7 @@ android:id="@+id/gear_icon_image" android:layout_width="0dp" android:layout_height="24dp" + android:paddingEnd="24dp" android:src="@drawable/ic_settings_24dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/packages/SystemUI/res/layout/bluetooth_tile_dialog.xml b/packages/SystemUI/res/layout/bluetooth_tile_dialog.xml index c11a18b795a1..af29cada2657 100644 --- a/packages/SystemUI/res/layout/bluetooth_tile_dialog.xml +++ b/packages/SystemUI/res/layout/bluetooth_tile_dialog.xml @@ -120,6 +120,16 @@ android:visibility="gone" app:constraint_referenced_ids="ic_arrow,see_all_text" /> + + + + Click to configure device detail + + Click to see all devices + + Click to pair new device Battery percentage unknown. @@ -640,6 +644,10 @@ Connected Saved + + disconnect + + activate %s battery diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialog.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialog.kt index aa7954e3cd0b..5bdb592a3558 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/BluetoothTileDialog.kt @@ -20,9 +20,12 @@ import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View +import android.view.View.AccessibilityDelegate import android.view.View.GONE import android.view.View.VISIBLE import android.view.ViewGroup +import android.view.accessibility.AccessibilityNodeInfo +import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction import android.widget.ImageView import android.widget.Switch import android.widget.TextView @@ -80,8 +83,8 @@ constructor( private lateinit var doneButton: View private lateinit var seeAllViewGroup: View private lateinit var pairNewDeviceViewGroup: View - private lateinit var seeAllText: View - private lateinit var pairNewDeviceText: View + private lateinit var seeAllRow: View + private lateinit var pairNewDeviceRow: View private lateinit var deviceListView: RecyclerView override fun onCreate(savedInstanceState: Bundle?) { @@ -98,8 +101,8 @@ constructor( doneButton = requireViewById(R.id.done_button) seeAllViewGroup = requireViewById(R.id.see_all_layout_group) pairNewDeviceViewGroup = requireViewById(R.id.pair_new_device_layout_group) - seeAllText = requireViewById(R.id.see_all_text) - pairNewDeviceText = requireViewById(R.id.pair_new_device_text) + seeAllRow = requireViewById(R.id.see_all_clickable_row) + pairNewDeviceRow = requireViewById(R.id.pair_new_device_clickable_row) deviceListView = requireViewById(R.id.device_list) setupToggle() @@ -107,8 +110,8 @@ constructor( subtitleTextView.text = context.getString(subtitleResIdInitialValue) doneButton.setOnClickListener { dismiss() } - seeAllText.setOnClickListener { bluetoothTileDialogCallback.onSeeAllClicked(it) } - pairNewDeviceText.setOnClickListener { + seeAllRow.setOnClickListener { bluetoothTileDialogCallback.onSeeAllClicked(it) } + pairNewDeviceRow.setOnClickListener { bluetoothTileDialogCallback.onPairNewDeviceClicked(it) } } @@ -194,7 +197,8 @@ constructor( deviceItem1.iconWithDescription?.second == deviceItem2.iconWithDescription?.second && deviceItem1.background == deviceItem2.background && - deviceItem1.isEnabled == deviceItem2.isEnabled + deviceItem1.isEnabled == deviceItem2.isEnabled && + deviceItem1.actionAccessibilityLabel == deviceItem2.actionAccessibilityLabel } } @@ -238,6 +242,21 @@ constructor( mutableDeviceItemClick.tryEmit(item) uiEventLogger.log(BluetoothTileDialogUiEvent.DEVICE_CLICKED) } + accessibilityDelegate = + object : AccessibilityDelegate() { + override fun onInitializeAccessibilityNodeInfo( + host: View, + info: AccessibilityNodeInfo + ) { + super.onInitializeAccessibilityNodeInfo(host, info) + info.addAction( + AccessibilityAction( + AccessibilityAction.ACTION_CLICK.id, + item.actionAccessibilityLabel + ) + ) + } + } } nameView.text = item.deviceName summaryView.text = item.connectionSummary diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/DeviceItem.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/DeviceItem.kt index 2c8d2a0806d2..1c621b87533d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/DeviceItem.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/DeviceItem.kt @@ -49,5 +49,6 @@ data class DeviceItem( val connectionSummary: String = "", val iconWithDescription: Pair? = null, val background: Int? = null, - var isEnabled: Boolean = true + var isEnabled: Boolean = true, + var actionAccessibilityLabel: String = "", ) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/DeviceItemFactory.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/DeviceItemFactory.kt index 7bb1619c5001..1c9be0f105b2 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/DeviceItemFactory.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/bluetooth/DeviceItemFactory.kt @@ -28,6 +28,10 @@ private val backgroundOff = R.drawable.bluetooth_tile_dialog_bg_off private val backgroundOffBusy = R.drawable.bluetooth_tile_dialog_bg_off_busy private val connected = R.string.quick_settings_bluetooth_device_connected private val saved = R.string.quick_settings_bluetooth_device_saved +private val actionAccessibilityLabelActivate = + R.string.accessibility_quick_settings_bluetooth_device_tap_to_activate +private val actionAccessibilityLabelDisconnect = + R.string.accessibility_quick_settings_bluetooth_device_tap_to_disconnect /** Factories to create different types of Bluetooth device items from CachedBluetoothDevice. */ internal abstract class DeviceItemFactory { @@ -60,6 +64,7 @@ internal class ActiveMediaDeviceItemFactory : DeviceItemFactory() { }, background = backgroundOn, isEnabled = !cachedDevice.isBusy, + actionAccessibilityLabel = context.getString(actionAccessibilityLabelDisconnect), ) } } @@ -87,6 +92,7 @@ internal class AvailableMediaDeviceItemFactory : DeviceItemFactory() { }, background = if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff, isEnabled = !cachedDevice.isBusy, + actionAccessibilityLabel = context.getString(actionAccessibilityLabelActivate), ) } } @@ -112,6 +118,7 @@ internal class ConnectedDeviceItemFactory : DeviceItemFactory() { }, background = if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff, isEnabled = !cachedDevice.isBusy, + actionAccessibilityLabel = context.getString(actionAccessibilityLabelDisconnect), ) } } @@ -137,6 +144,7 @@ internal class SavedDeviceItemFactory : DeviceItemFactory() { }, background = if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff, isEnabled = !cachedDevice.isBusy, + actionAccessibilityLabel = context.getString(actionAccessibilityLabelActivate), ) } } -- cgit v1.2.3-59-g8ed1b