summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jason Hsu <jasonwshsu@google.com> 2024-05-27 10:46:39 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-05-27 10:46:39 +0000
commit4e1de135d6f7cea272bce473874fa24a666592dc (patch)
tree6213b6d4fb48c400081776389a15f26a92bec796
parent9ec62d0b50fb29b6c823cb9ccfbb96879939eec6 (diff)
parentad4b86901a45cd23c6ad72cb18eeccbe2c3cd68c (diff)
Merge "Update spinner style for preset info" into main
-rw-r--r--packages/SystemUI/res/drawable/hearing_devices_preset_spinner_background.xml4
-rw-r--r--packages/SystemUI/res/layout/hearing_devices_preset_dropdown_item.xml25
-rw-r--r--packages/SystemUI/res/layout/hearing_devices_preset_spinner_selected.xml46
-rw-r--r--packages/SystemUI/res/layout/hearing_devices_tile_dialog.xml13
-rw-r--r--packages/SystemUI/res/values/dimens.xml4
-rw-r--r--packages/SystemUI/res/values/strings.xml4
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/hearingaid/HearingDevicesDialogDelegate.java24
7 files changed, 108 insertions, 12 deletions
diff --git a/packages/SystemUI/res/drawable/hearing_devices_preset_spinner_background.xml b/packages/SystemUI/res/drawable/hearing_devices_preset_spinner_background.xml
index 6e6e032ef2c5..c83b6d38a0e1 100644
--- a/packages/SystemUI/res/drawable/hearing_devices_preset_spinner_background.xml
+++ b/packages/SystemUI/res/drawable/hearing_devices_preset_spinner_background.xml
@@ -30,8 +30,8 @@
android:end="20dp"
android:gravity="end|center_vertical">
<vector
- android:width="@dimen/screenrecord_spinner_arrow_size"
- android:height="@dimen/screenrecord_spinner_arrow_size"
+ android:width="@dimen/hearing_devices_preset_spinner_arrow_size"
+ android:height="@dimen/hearing_devices_preset_spinner_arrow_size"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?androidprv:attr/colorControlNormal">
diff --git a/packages/SystemUI/res/layout/hearing_devices_preset_dropdown_item.xml b/packages/SystemUI/res/layout/hearing_devices_preset_dropdown_item.xml
new file mode 100644
index 000000000000..1d9307ba20ed
--- /dev/null
+++ b/packages/SystemUI/res/layout/hearing_devices_preset_dropdown_item.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2024 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/hearing_devices_preset_option_text"
+ style="?android:attr/spinnerDropDownItemStyle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="@dimen/hearing_devices_preset_spinner_height"
+ android:paddingStart="@dimen/hearing_devices_preset_spinner_text_padding_start"
+ android:gravity="center_vertical"
+ android:ellipsize="end" /> \ No newline at end of file
diff --git a/packages/SystemUI/res/layout/hearing_devices_preset_spinner_selected.xml b/packages/SystemUI/res/layout/hearing_devices_preset_spinner_selected.xml
new file mode 100644
index 000000000000..77172ca8f90e
--- /dev/null
+++ b/packages/SystemUI/res/layout/hearing_devices_preset_spinner_selected.xml
@@ -0,0 +1,46 @@
+<!--
+ Copyright (C) 2024 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="@dimen/hearing_devices_preset_spinner_height"
+ android:paddingStart="@dimen/hearing_devices_preset_spinner_text_padding_start"
+ android:paddingTop="@dimen/hearing_devices_preset_spinner_text_padding_vertical"
+ android:paddingBottom="@dimen/hearing_devices_preset_spinner_text_padding_vertical"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:textAppearance="@style/TextAppearance.Dialog.Title"
+ android:lineSpacingExtra="6dp"
+ android:text="@string/hearing_devices_preset_label"
+ android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
+ android:textSize="14sp"
+ android:gravity="center_vertical"
+ android:layout_weight="1" />
+ <TextView
+ android:id="@+id/hearing_devices_preset_option_text"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:textAppearance="@style/TextAppearance.Dialog.Body"
+ android:lineSpacingExtra="6dp"
+ android:gravity="center_vertical"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:layout_weight="1" />
+</LinearLayout> \ No newline at end of file
diff --git a/packages/SystemUI/res/layout/hearing_devices_tile_dialog.xml b/packages/SystemUI/res/layout/hearing_devices_tile_dialog.xml
index 8e1d0a57100c..2bf6f80c32d0 100644
--- a/packages/SystemUI/res/layout/hearing_devices_tile_dialog.xml
+++ b/packages/SystemUI/res/layout/hearing_devices_tile_dialog.xml
@@ -17,7 +17,6 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:id="@+id/root"
style="@style/Widget.SliceView.Panel"
android:layout_width="wrap_content"
@@ -36,16 +35,22 @@
android:id="@+id/preset_spinner"
style="@style/BluetoothTileDialog.Device"
android:layout_width="match_parent"
- android:layout_height="@dimen/hearing_devices_preset_spinner_height"
- android:layout_marginTop="@dimen/hearing_devices_preset_spinner_margin"
- android:layout_marginBottom="@dimen/hearing_devices_preset_spinner_margin"
+ android:layout_height="wrap_content"
+ android:minHeight="@dimen/hearing_devices_preset_spinner_height"
+ android:layout_marginTop="@dimen/hearing_devices_layout_margin"
+ android:layout_marginBottom="@dimen/hearing_devices_layout_margin"
android:gravity="center_vertical"
android:background="@drawable/hearing_devices_preset_spinner_background"
android:popupBackground="@drawable/hearing_devices_preset_spinner_popup_background"
+ android:dropDownVerticalOffset="@dimen/hearing_devices_preset_spinner_height"
+ android:dropDownWidth="match_parent"
+ android:paddingStart="0dp"
+ android:paddingEnd="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/device_list"
app:layout_constraintBottom_toTopOf="@id/pair_new_device_button"
+ android:longClickable="false"
android:visibility="gone"/>
<androidx.constraintlayout.widget.Barrier
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 02b74ce14088..7d7a5d4dbf14 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1772,10 +1772,10 @@
<dimen name="bluetooth_dialog_scroll_view_min_height_with_auto_on">350dp</dimen>
<!-- Hearing devices dialog related dimensions -->
+ <dimen name="hearing_devices_layout_margin">12dp</dimen>
<dimen name="hearing_devices_preset_spinner_height">72dp</dimen>
- <dimen name="hearing_devices_preset_spinner_margin">24dp</dimen>
<dimen name="hearing_devices_preset_spinner_text_padding_start">20dp</dimen>
- <dimen name="hearing_devices_preset_spinner_text_padding_end">80dp</dimen>
+ <dimen name="hearing_devices_preset_spinner_text_padding_vertical">15dp</dimen>
<dimen name="hearing_devices_preset_spinner_arrow_size">24dp</dimen>
<dimen name="hearing_devices_preset_spinner_background_radius">28dp</dimen>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index abfdc2a79603..6f2806d80ef3 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -913,8 +913,10 @@
<string name="quick_settings_pair_hearing_devices">Pair new device</string>
<!-- QuickSettings: Content description of the hearing devices dialog pair new device [CHAR LIMIT=NONE] -->
<string name="accessibility_hearing_device_pair_new_device">Click to pair new device</string>
- <!-- Message when selecting hearing aids presets failed. [CHAR LIMIT=NONE] -->
+ <!-- QuickSettings: Message when selecting hearing aids presets failed. [CHAR LIMIT=NONE] -->
<string name="hearing_devices_presets_error">Couldn\'t update preset</string>
+ <!-- QuickSettings: Title for hearing aids presets. Preset is a set of hearing aid settings. User can apply different settings in different environments (e.g. Outdoor, Restaurant, Home) [CHAR LIMIT=40]-->
+ <string name="hearing_devices_preset_label">Preset</string>
<!--- Title of dialog triggered if the microphone is disabled but an app tried to access it. [CHAR LIMIT=150] -->
<string name="sensor_privacy_start_use_mic_dialog_title">Unblock device microphone?</string>
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/hearingaid/HearingDevicesDialogDelegate.java b/packages/SystemUI/src/com/android/systemui/accessibility/hearingaid/HearingDevicesDialogDelegate.java
index 7b5a09cb3848..28dd2338ff2b 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/hearingaid/HearingDevicesDialogDelegate.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/hearingaid/HearingDevicesDialogDelegate.java
@@ -32,6 +32,7 @@ import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.Visibility;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
@@ -208,6 +209,10 @@ public class HearingDevicesDialogDelegate implements SystemUIDialog.Delegate,
}
mMainHandler.post(() -> {
mDeviceListAdapter.refreshDeviceItemList(mHearingDeviceItemList);
+ final List<BluetoothHapPresetInfo> presetInfos =
+ mPresetsController.getAllPresetInfo();
+ final int activePresetIndex = mPresetsController.getActivePresetIndex();
+ refreshPresetInfoAdapter(presetInfos, activePresetIndex);
mPresetSpinner.setVisibility(
(activeHearingDevice != null && !mPresetInfoAdapter.isEmpty()) ? VISIBLE
: GONE);
@@ -295,10 +300,23 @@ public class HearingDevicesDialogDelegate implements SystemUIDialog.Delegate,
mHearingDeviceItemList);
mPresetsController.setActiveHearingDevice(activeHearingDevice);
- mPresetInfoAdapter = new ArrayAdapter<>(dialog.getContext(),
- android.R.layout.simple_spinner_dropdown_item);
- mPresetInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mPresetInfoAdapter = new ArrayAdapter<String>(dialog.getContext(),
+ R.layout.hearing_devices_preset_spinner_selected,
+ R.id.hearing_devices_preset_option_text);
+ mPresetInfoAdapter.setDropDownViewResource(
+ R.layout.hearing_devices_preset_dropdown_item);
mPresetSpinner.setAdapter(mPresetInfoAdapter);
+
+ // disable redundant Touch & Hold accessibility action for Switch Access
+ mPresetSpinner.setAccessibilityDelegate(new View.AccessibilityDelegate() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(@NonNull View host,
+ @NonNull AccessibilityNodeInfo info) {
+ info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK);
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ }
+ });
+
mPresetSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {