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

Commit 6afe51bd authored by Angela Wang's avatar Angela Wang
Browse files

Update hearing device dialog UI to match figma

1. Change the background of the related tool from outlined shape to
   colored background
2. Limit the total number of related tools to 3 and ensure the layout
   will align left and right boundary as same as the above UI elements
   (device items, preset control)

Flag: EXEMPT bugfix
Test: manually check the UI, result attached in bug
Test: atest HearingDevicesDialogDelegateTest
Test: atest HearingDevicesToolItemParserTest
Bug: 372185688
Change-Id: Ic754581d7c0bca9af14192fd74f251e0805d1e22
parent b6c8c9d0
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -46,7 +46,9 @@ import android.platform.test.annotations.EnableFlags;
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;

import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -226,7 +228,7 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        mDialog.show();

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

    @Test
@@ -244,12 +246,13 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        when(mActivityInfo.loadLabel(mPackageManager)).thenReturn(TEST_LABEL);
        when(mActivityInfo.loadIcon(mPackageManager)).thenReturn(mDrawable);
        when(mActivityInfo.getComponentName()).thenReturn(TEST_COMPONENT);
        when(mDrawable.mutate()).thenReturn(mDrawable);

        setUpPairNewDeviceDialog();
        mDialog.show();

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

    @Test
@@ -364,6 +367,16 @@ public class HearingDevicesDialogDelegateTest extends SysuiTestCase {
        return dialog.requireViewById(R.id.preset_spinner);
    }

    private int countChildWithoutSpace(ViewGroup viewGroup) {
        int spaceCount = 0;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            if (viewGroup.getChildAt(i) instanceof Space) {
                spaceCount++;
            }
        }
        return viewGroup.getChildCount() - spaceCount;
    }

    @After
    public void reset() {
        if (mDialogDelegate != null) {
+8 −6
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public class HearingDevicesToolItemParserTest extends SysuiTestCase {
    }

    @Test
    public void parseStringArray_noString_emptyResult() {
    public void parseStringArray_noToolName_emptyResult() {
        assertThat(HearingDevicesToolItemParser.parseStringArray(mContext, new String[]{},
                new String[]{})).isEqualTo(emptyList());
    }
@@ -103,14 +103,14 @@ public class HearingDevicesToolItemParserTest extends SysuiTestCase {
    }

    @Test
    public void parseStringArray_fourToolName_maxThreeToolItem() {
    public void parseStringArray_threeToolNames_maxTwoToolItems() {
        String componentNameString = TEST_PKG + "/" + TEST_CLS;
        String[] fourToolName =
                new String[]{componentNameString, componentNameString, componentNameString,
                        componentNameString};
        String[] threeToolNames =
                new String[]{componentNameString, componentNameString, componentNameString};

        List<ToolItem> toolItemList = HearingDevicesToolItemParser.parseStringArray(mContext,
                fourToolName, new String[]{});
                threeToolNames, new String[]{});

        assertThat(toolItemList.size()).isEqualTo(HearingDevicesToolItemParser.MAX_NUM);
    }

@@ -120,6 +120,7 @@ public class HearingDevicesToolItemParserTest extends SysuiTestCase {

        List<ToolItem> toolItemList = HearingDevicesToolItemParser.parseStringArray(mContext,
                wrongFormatToolName, new String[]{});

        assertThat(toolItemList.size()).isEqualTo(0);
    }

@@ -129,6 +130,7 @@ public class HearingDevicesToolItemParserTest extends SysuiTestCase {

        List<ToolItem> toolItemList = HearingDevicesToolItemParser.parseStringArray(mContext,
                notExistToolName, new String[]{});

        assertThat(toolItemList.size()).isEqualTo(0);
    }
}
+1 −4
Original line number Diff line number Diff line
@@ -21,11 +21,8 @@
    android:color="?android:attr/colorControlHighlight">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@android:color/transparent"/>
            <solid android:color="?androidprv:attr/materialColorPrimaryContainer"/>
            <corners android:radius="@dimen/hearing_devices_preset_spinner_background_radius"/>
            <stroke
                android:width="1dp"
                android:color="?androidprv:attr/textColorTertiary" />
        </shape>
    </item>
</ripple>
+4 −13
Original line number Diff line number Diff line
@@ -72,7 +72,6 @@
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/device_function_barrier"
        app:layout_constraintBottom_toTopOf="@id/related_tools_scroll"
        android:drawableStart="@drawable/ic_add"
        android:drawablePadding="20dp"
        android:drawableTint="?android:attr/textColorPrimary"
@@ -92,24 +91,16 @@
        app:barrierDirection="bottom"
        app:constraint_referenced_ids="device_function_barrier, pair_new_device_button" />

    <HorizontalScrollView
        android:id="@+id/related_tools_scroll"
    <LinearLayout
        android:id="@+id/related_tools_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/bluetooth_dialog_layout_margin"
        android:layout_marginEnd="@dimen/bluetooth_dialog_layout_margin"
        android:layout_marginTop="@dimen/hearing_devices_layout_margin"
        android:scrollbars="none"
        android:fillViewport="true"
        android:orientation="horizontal"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/preset_spinner">
        <LinearLayout
            android:id="@+id/related_tools_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">
        </LinearLayout>
    </HorizontalScrollView>
        app:layout_constraintTop_toBottomOf="@id/device_barrier" />

</androidx.constraintlayout.widget.ConstraintLayout>
 No newline at end of file
+6 −4
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tool_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="top|center_horizontal"
    android:focusable="true"
@@ -26,8 +26,10 @@
    android:layout_weight="1">
    <FrameLayout
        android:id="@+id/icon_frame"
        android:layout_width="@dimen/hearing_devices_tool_icon_frame_width"
        android:layout_height="@dimen/hearing_devices_tool_icon_frame_height"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:background="@drawable/qs_hearing_devices_related_tools_background"
        android:focusable="false" >
        <ImageView
Loading