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

Commit 967a05a3 authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Add content description for battery charging status icon" into main

parents e380b4e9 cc28aba2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2040,6 +2040,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);
    }

}