Add content description for battery charging status icon
BUG: 372622360 Test: atest AdvancedBluetoothDetailsHeaderControllerTest Flag: EXEMPT minor fix Change-Id: I23a889e1576c0625cefb91386987df8826c1935f
This commit is contained in:
@@ -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>
|
<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] -->
|
<!-- Summary of Bluetooth LE Audio toggle in Device Details. [CHAR LIMIT=40] -->
|
||||||
<string name="device_details_leaudio_toggle_summary">Experimental. Improves audio quality.</string>
|
<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. -->
|
<!-- 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>
|
<string name="bluetooth_unpair_dialog_forget_confirm_button">Forget device</string>
|
||||||
|
@@ -626,6 +626,11 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
|||||||
imageView.setLayoutParams(layoutParams);
|
imageView.setLayoutParams(layoutParams);
|
||||||
} else {
|
} else {
|
||||||
imageView.setImageDrawable(createBtBatteryIcon(mContext, level, charging));
|
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(
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
imageView.setLayoutParams(layoutParams);
|
imageView.setLayoutParams(layoutParams);
|
||||||
|
@@ -329,11 +329,16 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
|||||||
|
|
||||||
mController.refresh();
|
mController.refresh();
|
||||||
|
|
||||||
assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_left),
|
assertBatteryIcon(
|
||||||
R.drawable.ic_battery_alert_24dp);
|
mLayoutPreference.findViewById(R.id.layout_left),
|
||||||
assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_right), /* resId= */-1);
|
R.drawable.ic_battery_alert_24dp,
|
||||||
assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle),
|
false);
|
||||||
R.drawable.ic_battery_alert_24dp);
|
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
|
@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);
|
final ImageView imageView = linearLayout.findViewById(R.id.bt_battery_icon);
|
||||||
assertThat(shadowOf(imageView.getDrawable()).getCreatedFromResId())
|
if (charging) {
|
||||||
.isEqualTo(resId);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user