Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85cfd4a1 authored by Angela Wang's avatar Angela Wang
Browse files

Update hearing device dialog UI

1. Move title out of spinner
2. Spinner dropdown style
3. Add title of related tools

Flag: EXEMPT bugfix
Bug: 376779544
Test: manually check the UI, results attached in bug
Test: atest HearingDevicesDialogDelegateTest
Change-Id: Iffa77fc5283635dc73b18508eb07e6b257511057
parent bda78423
Loading
Loading
Loading
Loading
+43 −14
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import android.provider.Settings;
import android.testing.TestableLooper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Space;
import android.widget.Spinner;

@@ -215,6 +214,18 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
                TEST_LAUNCH_SOURCE_ID);
    }

    @Test
    @EnableFlags(Flags.FLAG_HEARING_DEVICES_DIALOG_RELATED_TOOLS)
    public void showDialog_noLiveCaption_noRelatedToolsInConfig_relatedToolLayoutGone() {
        mContext.getOrCreateTestableResources().addOverride(
                R.array.config_quickSettingsHearingDevicesRelatedToolName, new String[]{});

        setUpPairNewDeviceDialog();
        mDialog.show();

        assertToolsUi(0);
    }

    @Test
    @EnableFlags(Flags.FLAG_HEARING_DEVICES_DIALOG_RELATED_TOOLS)
    public void showDialog_hasLiveCaption_noRelatedToolsInConfig_showOneRelatedTool() {
@@ -227,8 +238,7 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        setUpPairNewDeviceDialog();
        mDialog.show();

        LinearLayout relatedToolsView = (LinearLayout) getRelatedToolsView(mDialog);
        assertThat(countChildWithoutSpace(relatedToolsView)).isEqualTo(1);
        assertToolsUi(1);
    }

    @Test
@@ -251,8 +261,7 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        setUpPairNewDeviceDialog();
        mDialog.show();

        LinearLayout relatedToolsView = (LinearLayout) getRelatedToolsView(mDialog);
        assertThat(countChildWithoutSpace(relatedToolsView)).isEqualTo(2);
        assertToolsUi(2);
    }

    @Test
@@ -263,8 +272,8 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        setUpDeviceListDialog();
        mDialog.show();

        Spinner spinner = (Spinner) getPresetSpinner(mDialog);
        assertThat(spinner.getVisibility()).isEqualTo(View.GONE);
        ViewGroup presetLayout = getPresetLayout(mDialog);
        assertThat(presetLayout.getVisibility()).isEqualTo(View.GONE);
    }

    @Test
@@ -276,8 +285,9 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        setUpDeviceListDialog();
        mDialog.show();

        Spinner spinner = (Spinner) getPresetSpinner(mDialog);
        assertThat(spinner.getVisibility()).isEqualTo(View.VISIBLE);
        ViewGroup presetLayout = getPresetLayout(mDialog);
        assertThat(presetLayout.getVisibility()).isEqualTo(View.VISIBLE);
        Spinner spinner = getPresetSpinner(mDialog);
        assertThat(spinner.getSelectedItemPosition()).isEqualTo(0);
    }

@@ -292,8 +302,9 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        mDialogDelegate.onActiveDeviceChanged(mCachedDevice, BluetoothProfile.LE_AUDIO);
        mTestableLooper.processAllMessages();

        Spinner spinner = (Spinner) getPresetSpinner(mDialog);
        assertThat(spinner.getVisibility()).isEqualTo(View.VISIBLE);
        ViewGroup presetLayout = getPresetLayout(mDialog);
        assertThat(presetLayout.getVisibility()).isEqualTo(View.VISIBLE);
        Spinner spinner = getPresetSpinner(mDialog);
        assertThat(spinner.getSelectedItemPosition()).isEqualTo(0);
    }

@@ -359,14 +370,23 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        return dialog.requireViewById(R.id.pair_new_device_button);
    }

    private View getRelatedToolsView(SystemUIDialog dialog) {
        return dialog.requireViewById(R.id.related_tools_container);
    private ViewGroup getToolsContainer(SystemUIDialog dialog) {
        return dialog.requireViewById(R.id.tools_container);
    }

    private ViewGroup getToolsLayout(SystemUIDialog dialog) {
        return dialog.requireViewById(R.id.tools_layout);
    }

    private View getPresetSpinner(SystemUIDialog dialog) {
    private Spinner getPresetSpinner(SystemUIDialog dialog) {
        return dialog.requireViewById(R.id.preset_spinner);
    }

    private ViewGroup getPresetLayout(SystemUIDialog dialog) {
        return dialog.requireViewById(R.id.preset_layout);
    }


    private int countChildWithoutSpace(ViewGroup viewGroup) {
        int spaceCount = 0;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
@@ -377,6 +397,15 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        return viewGroup.getChildCount() - spaceCount;
    }

    private void assertToolsUi(int childCount) {
        ViewGroup toolsContainer = getToolsContainer(mDialog);
        assertThat(countChildWithoutSpace(toolsContainer)).isEqualTo(childCount);

        int targetVisibility = childCount == 0 ? View.GONE : View.VISIBLE;
        ViewGroup toolsLayout = getToolsLayout(mDialog);
        assertThat(toolsLayout.getVisibility()).isEqualTo(targetVisibility);
    }

    @After
    public void reset() {
        if (mDialogDelegate != null) {
+4 −3
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@
    limitations under the License.
-->

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:paddingMode="stack">
    <item>
@@ -30,8 +31,8 @@
        android:end="20dp"
        android:gravity="end|center_vertical">
        <vector
            android:width="@dimen/hearing_devices_preset_spinner_arrow_size"
            android:height="@dimen/hearing_devices_preset_spinner_arrow_size"
            android:width="@dimen/hearing_devices_preset_spinner_icon_size"
            android:height="@dimen/hearing_devices_preset_spinner_icon_size"
            android:viewportWidth="24"
            android:viewportHeight="24"
            android:tint="?androidprv:attr/colorControlNormal">
+7 −11
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (C) 2024 The Android Open Source Project

@@ -13,14 +14,9 @@
    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:textDirection="locale"
    android:ellipsize="end" />
 No newline at end of file
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/settingslib_switch_bar_bg_on"
    android:insetTop="8dp"
    android:insetBottom="8dp"
    android:insetLeft="11dp"
    android:insetRight="11dp" />
 No newline at end of file
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright 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.
-->
<vector
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportHeight="24"
    android:viewportWidth="24">
    <path
        android:pathData="M0 0h24v24H0z"/>
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>
</vector>
 No newline at end of file
Loading