Merge "Fix a11y label for LE Audio Battery" into tm-dev
This commit is contained in:
@@ -61,75 +61,91 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="vertical">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/bt_battery_case"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/le_bluetooth_battery_start_margin"
|
android:layout_marginStart="@dimen/le_bluetooth_battery_start_margin"
|
||||||
android:orientation="vertical">
|
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:focusable="true">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bt_battery_case_title"
|
|
||||||
style="@style/TextAppearance.EntityHeaderTitle"
|
style="@style/TextAppearance.EntityHeaderTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
android:layout_weight="1"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:text="@string/bluetooth_middle_name"
|
android:text="@string/bluetooth_middle_name"
|
||||||
android:textSize="@dimen/advanced_bluetooth_header_title_text_size"
|
android:textSize="@dimen/advanced_bluetooth_header_title_text_size"/>
|
||||||
android:visibility="gone"/>
|
<TextView
|
||||||
|
android:id="@+id/bt_battery_case_summary"
|
||||||
|
style="@style/TextAppearance.EntityHeaderSummary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/le_bluetooth_summary_start_margin"
|
||||||
|
android:minWidth="@dimen/le_bluetooth_summary_min_width"
|
||||||
|
android:padding="@dimen/le_bluetooth_summary_padding"
|
||||||
|
android:drawablePadding="@dimen/le_bluetooth_summary_drawable_padding"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/bt_battery_left"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/le_bluetooth_battery_start_margin"
|
||||||
|
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:focusable="true">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bt_battery_left_title"
|
|
||||||
style="@style/TextAppearance.EntityHeaderTitle"
|
style="@style/TextAppearance.EntityHeaderTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
android:layout_weight="1"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:text="@string/bluetooth_left_name"
|
android:text="@string/bluetooth_left_name"
|
||||||
android:textSize="@dimen/advanced_bluetooth_header_title_text_size"/>
|
android:textSize="@dimen/advanced_bluetooth_header_title_text_size"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bt_battery_right_title"
|
android:id="@+id/bt_battery_left_summary"
|
||||||
|
style="@style/TextAppearance.EntityHeaderSummary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/le_bluetooth_summary_start_margin"
|
||||||
|
android:minWidth="@dimen/le_bluetooth_summary_min_width"
|
||||||
|
android:padding="@dimen/le_bluetooth_summary_padding"
|
||||||
|
android:drawablePadding="@dimen/le_bluetooth_summary_drawable_padding"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/bt_battery_right"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/le_bluetooth_battery_start_margin"
|
||||||
|
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:focusable="true">
|
||||||
|
<TextView
|
||||||
style="@style/TextAppearance.EntityHeaderTitle"
|
style="@style/TextAppearance.EntityHeaderTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
android:layout_weight="1"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:text="@string/bluetooth_right_name"
|
android:text="@string/bluetooth_right_name"
|
||||||
android:textSize="@dimen/advanced_bluetooth_header_title_text_size"/>
|
android:textSize="@dimen/advanced_bluetooth_header_title_text_size"/>
|
||||||
</LinearLayout>
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="@dimen/le_bluetooth_summary_start_margin"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/bt_battery_case_summary"
|
|
||||||
style="@style/TextAppearance.EntityHeaderSummary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
|
||||||
android:padding="@dimen/le_bluetooth_summary_padding"
|
|
||||||
android:drawablePadding="@dimen/le_bluetooth_summary_drawable_padding"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/bt_battery_left_summary"
|
|
||||||
style="@style/TextAppearance.EntityHeaderSummary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
|
||||||
android:padding="@dimen/le_bluetooth_summary_padding"
|
|
||||||
android:drawablePadding="@dimen/le_bluetooth_summary_drawable_padding"/>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bt_battery_right_summary"
|
android:id="@+id/bt_battery_right_summary"
|
||||||
style="@style/TextAppearance.EntityHeaderSummary"
|
style="@style/TextAppearance.EntityHeaderSummary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
|
android:layout_marginStart="@dimen/le_bluetooth_summary_start_margin"
|
||||||
|
android:minWidth="@dimen/le_bluetooth_summary_min_width"
|
||||||
android:padding="@dimen/le_bluetooth_summary_padding"
|
android:padding="@dimen/le_bluetooth_summary_padding"
|
||||||
android:drawablePadding="@dimen/le_bluetooth_summary_drawable_padding"/>
|
android:drawablePadding="@dimen/le_bluetooth_summary_drawable_padding"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -415,6 +415,7 @@
|
|||||||
<dimen name="le_bluetooth_summary_drawable_padding">6dp</dimen>
|
<dimen name="le_bluetooth_summary_drawable_padding">6dp</dimen>
|
||||||
<dimen name="le_bluetooth_summary_start_margin">20dp</dimen>
|
<dimen name="le_bluetooth_summary_start_margin">20dp</dimen>
|
||||||
<dimen name="le_bluetooth_summary_padding">1.5dp</dimen>
|
<dimen name="le_bluetooth_summary_padding">1.5dp</dimen>
|
||||||
|
<dimen name="le_bluetooth_summary_min_width">64dp</dimen>
|
||||||
|
|
||||||
<!-- Header layout of bluetooth find broadcast page -->
|
<!-- Header layout of bluetooth find broadcast page -->
|
||||||
<dimen name="bluetooth_find_broadcast_button_one_size">220dp</dimen>
|
<dimen name="bluetooth_find_broadcast_button_one_size">220dp</dimen>
|
||||||
|
@@ -198,38 +198,25 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
|
|||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getBatteryTitleResource(int deviceId) {
|
private int getBatterySummaryResource(int containerId) {
|
||||||
if (deviceId == LEFT_DEVICE_ID) {
|
if (containerId == R.id.bt_battery_case) {
|
||||||
return R.id.bt_battery_left_title;
|
return R.id.bt_battery_case_summary;
|
||||||
}
|
} else if (containerId == R.id.bt_battery_left) {
|
||||||
if (deviceId == RIGHT_DEVICE_ID) {
|
|
||||||
return R.id.bt_battery_right_title;
|
|
||||||
}
|
|
||||||
Log.d(TAG, "No resource id. The deviceId is " + deviceId);
|
|
||||||
return INVALID_RESOURCE_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getBatterySummaryResource(int deviceId) {
|
|
||||||
if (deviceId == LEFT_DEVICE_ID) {
|
|
||||||
return R.id.bt_battery_left_summary;
|
return R.id.bt_battery_left_summary;
|
||||||
}
|
} else if (containerId == R.id.bt_battery_right) {
|
||||||
if (deviceId == RIGHT_DEVICE_ID) {
|
|
||||||
return R.id.bt_battery_right_summary;
|
return R.id.bt_battery_right_summary;
|
||||||
}
|
}
|
||||||
Log.d(TAG, "No resource id. The deviceId is " + deviceId);
|
Log.d(TAG, "No summary resource id. The containerId is " + containerId);
|
||||||
return INVALID_RESOURCE_ID;
|
return INVALID_RESOURCE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideAllOfBatteryLayouts() {
|
private void hideAllOfBatteryLayouts() {
|
||||||
// hide the case
|
// hide the case
|
||||||
updateBatteryLayout(R.id.bt_battery_case_title, R.id.bt_battery_case_summary,
|
updateBatteryLayout(R.id.bt_battery_case, BluetoothUtils.META_INT_ERROR);
|
||||||
BluetoothUtils.META_INT_ERROR);
|
|
||||||
// hide the left
|
// hide the left
|
||||||
updateBatteryLayout(R.id.bt_battery_left_title, R.id.bt_battery_left_summary,
|
updateBatteryLayout(R.id.bt_battery_left, BluetoothUtils.META_INT_ERROR);
|
||||||
BluetoothUtils.META_INT_ERROR);
|
|
||||||
// hide the right
|
// hide the right
|
||||||
updateBatteryLayout(R.id.bt_battery_right_title, R.id.bt_battery_right_summary,
|
updateBatteryLayout(R.id.bt_battery_right, BluetoothUtils.META_INT_ERROR);
|
||||||
BluetoothUtils.META_INT_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CachedBluetoothDevice> getAllOfLeAudioDevices() {
|
private List<CachedBluetoothDevice> getAllOfLeAudioDevices() {
|
||||||
@@ -285,36 +272,36 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
|
|||||||
summary.setText(mCachedDevice.getConnectionSummary());
|
summary.setText(mCachedDevice.getConnectionSummary());
|
||||||
}
|
}
|
||||||
} else if (isLeft) {
|
} else if (isLeft) {
|
||||||
updateBatteryLayout(getBatteryTitleResource(LEFT_DEVICE_ID),
|
updateBatteryLayout(R.id.bt_battery_left, cachedDevice.getBatteryLevel());
|
||||||
getBatterySummaryResource(LEFT_DEVICE_ID), cachedDevice.getBatteryLevel());
|
|
||||||
} else if (isRight) {
|
} else if (isRight) {
|
||||||
updateBatteryLayout(getBatteryTitleResource(RIGHT_DEVICE_ID),
|
updateBatteryLayout(R.id.bt_battery_right, cachedDevice.getBatteryLevel());
|
||||||
getBatterySummaryResource(RIGHT_DEVICE_ID), cachedDevice.getBatteryLevel());
|
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "The device id is other Audio Location. Do nothing.");
|
Log.d(TAG, "The device id is other Audio Location. Do nothing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBatteryLayout(int titleResId, int summaryResId, int batteryLevel) {
|
private void updateBatteryLayout(int resId, int batteryLevel) {
|
||||||
final TextView batteryTitleView = mLayoutPreference.findViewById(titleResId);
|
final View batteryView = mLayoutPreference.findViewById(resId);
|
||||||
final TextView batterySummaryView = mLayoutPreference.findViewById(summaryResId);
|
if (batteryView == null) {
|
||||||
if (batteryTitleView == null || batterySummaryView == null) {
|
Log.e(TAG, "updateBatteryLayout: No View");
|
||||||
Log.e(TAG, "updateBatteryLayout: No TextView");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (batteryLevel != BluetoothUtils.META_INT_ERROR) {
|
if (batteryLevel != BluetoothUtils.META_INT_ERROR) {
|
||||||
batteryTitleView.setVisibility(View.VISIBLE);
|
batteryView.setVisibility(View.VISIBLE);
|
||||||
batterySummaryView.setVisibility(View.VISIBLE);
|
final TextView batterySummaryView =
|
||||||
batterySummaryView.setText(
|
batteryView.requireViewById(getBatterySummaryResource(resId));
|
||||||
com.android.settings.Utils.formatPercentage(batteryLevel));
|
final String batteryLevelPercentageString =
|
||||||
|
com.android.settings.Utils.formatPercentage(batteryLevel);
|
||||||
|
batterySummaryView.setText(batteryLevelPercentageString);
|
||||||
|
batterySummaryView.setContentDescription(mContext.getString(
|
||||||
|
R.string.bluetooth_battery_level, batteryLevelPercentageString));
|
||||||
batterySummaryView.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
batterySummaryView.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||||
createBtBatteryIcon(mContext, batteryLevel), /* top */ null,
|
createBtBatteryIcon(mContext, batteryLevel), /* top */ null,
|
||||||
/* end */ null, /* bottom */ null);
|
/* end */ null, /* bottom */ null);
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "updateBatteryLayout: Hide it if it doesn't have battery information.");
|
Log.d(TAG, "updateBatteryLayout: Hide it if it doesn't have battery information.");
|
||||||
batteryTitleView.setVisibility(View.GONE);
|
batteryView.setVisibility(View.GONE);
|
||||||
batterySummaryView.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user