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

Commit cc28aba2 authored by Haijie Hong's avatar Haijie Hong
Browse files

Add content description for battery charging status icon

BUG: 372622360
Test: atest AdvancedBluetoothDetailsHeaderControllerTest
Flag: EXEMPT minor fix
Change-Id: I23a889e1576c0625cefb91386987df8826c1935f
parent 75cae486
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2002,6 +2002,11 @@
    <string name="bluetooth_companion_app_body"><xliff:g id="app_name" example="App Name">%1$s</xliff:g> app will no longer connect to your <xliff:g id="device_name" example="Device Name">%2$s</xliff:g></string>
    <!-- Summary of Bluetooth LE Audio toggle in Device Details. [CHAR LIMIT=40] -->
    <string name="device_details_leaudio_toggle_summary">Experimental. Improves audio quality.</string>
    <!-- Content Description for battery icon in device details screen [CHAR LIMIT=NONE]-->
    <string name="device_details_battery">Battery</string>
    <!-- Content Description for battery charging icon in device details screen [CHAR LIMIT=NONE]-->
    <string name="device_details_battery_charging">Battery, charging</string>
    <!--  Bluetooth device details. In the confirmation dialog for unpairing a paired device, this is the label on the button that will complete the unpairing action. -->
    <string name="bluetooth_unpair_dialog_forget_confirm_button">Forget device</string>
+5 −0
Original line number Diff line number Diff line
@@ -626,6 +626,11 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
            imageView.setLayoutParams(layoutParams);
        } else {
            imageView.setImageDrawable(createBtBatteryIcon(mContext, level, charging));
            imageView.setContentDescription(
                    mContext.getString(
                            charging
                                    ? R.string.device_details_battery_charging
                                    : R.string.device_details_battery));
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            imageView.setLayoutParams(layoutParams);
+19 −9
Original line number Diff line number Diff line
@@ -329,11 +329,16 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {

        mController.refresh();

        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_left),
                R.drawable.ic_battery_alert_24dp);
        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_right), /* resId= */-1);
        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle),
                R.drawable.ic_battery_alert_24dp);
        assertBatteryIcon(
                mLayoutPreference.findViewById(R.id.layout_left),
                R.drawable.ic_battery_alert_24dp,
                false);
        assertBatteryIcon(
                mLayoutPreference.findViewById(R.id.layout_right), /* resId= */ -1, true);
        assertBatteryIcon(
                mLayoutPreference.findViewById(R.id.layout_middle),
                R.drawable.ic_battery_alert_24dp,
                false);
    }

    @Test
@@ -546,10 +551,15 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
        }
    }

    private void assertBatteryIcon(LinearLayout linearLayout, int resId) {
    private void assertBatteryIcon(LinearLayout linearLayout, int resId, boolean charging) {
        final ImageView imageView = linearLayout.findViewById(R.id.bt_battery_icon);
        assertThat(shadowOf(imageView.getDrawable()).getCreatedFromResId())
                .isEqualTo(resId);
        if (charging) {
            assertThat(imageView.getContentDescription().toString())
                    .isEqualTo(mContext.getString(R.string.device_details_battery_charging));
        } else {
            assertThat(imageView.getContentDescription().toString())
                    .isEqualTo(mContext.getString(R.string.device_details_battery));
        }
        assertThat(shadowOf(imageView.getDrawable()).getCreatedFromResId()).isEqualTo(resId);
    }

}