Fix volume talkback issues.

Fixes: 188226344
Test: use volume with talkback
Change-Id: Ifd451b8fa1c53a2de8604e87da61aa77714f6ac1
This commit is contained in:
Josh Tsuji
2021-06-10 15:59:11 -04:00
parent 20da155df4
commit 4028c6fa16
2 changed files with 30 additions and 18 deletions

View File

@@ -59,7 +59,7 @@
android:id="@+id/volume_drawer_vibrate"
android:layout_width="@dimen/volume_ringer_drawer_item_size"
android:layout_height="@dimen/volume_ringer_drawer_item_size"
android:description="@string/volume_ringer_hint_vibrate"
android:contentDescription="@string/volume_ringer_hint_vibrate"
android:gravity="center">
<ImageView
@@ -76,7 +76,7 @@
android:id="@+id/volume_drawer_mute"
android:layout_width="@dimen/volume_ringer_drawer_item_size"
android:layout_height="@dimen/volume_ringer_drawer_item_size"
android:description="@string/volume_ringer_hint_mute"
android:contentDescription="@string/volume_ringer_hint_mute"
android:gravity="center">
<ImageView
@@ -93,7 +93,7 @@
android:id="@+id/volume_drawer_normal"
android:layout_width="@dimen/volume_ringer_drawer_item_size"
android:layout_height="@dimen/volume_ringer_drawer_item_size"
android:description="@string/volume_ringer_hint_unmute"
android:contentDescription="@string/volume_ringer_hint_unmute"
android:gravity="center">
<ImageView
@@ -117,7 +117,7 @@
android:layout_width="@dimen/volume_ringer_drawer_item_size"
android:layout_height="@dimen/volume_ringer_drawer_item_size"
android:layout_gravity="bottom|right"
android:description="@string/volume_ringer_change"
android:contentDescription="@string/volume_ringer_change"
android:background="@drawable/volume_drawer_selection_bg">
<ImageView

View File

@@ -932,6 +932,13 @@ public class VolumeDialogImpl implements VolumeDialog,
.start();
}
// When the ringer drawer is open, tapping the currently selected ringer will set the ringer
// to the current ringer mode. Change the content description to that, instead of the 'tap
// to change ringer mode' default.
mSelectedRingerContainer.setContentDescription(
mContext.getString(getStringDescriptionResourceForRingerMode(
mState.ringerModeInternal)));
mIsRingerDrawerOpen = true;
}
@@ -976,6 +983,11 @@ public class VolumeDialogImpl implements VolumeDialog,
.translationY(0f)
.start();
// When the drawer is closed, tapping the selected ringer drawer will open it, allowing the
// user to change the ringer.
mSelectedRingerContainer.setContentDescription(
mContext.getString(R.string.volume_ringer_change));
mIsRingerDrawerOpen = false;
}
@@ -1464,20 +1476,8 @@ public class VolumeDialogImpl implements VolumeDialog,
}
private void addAccessibilityDescription(View view, int currState, String hintLabel) {
int currStateResId;
switch (currState) {
case RINGER_MODE_SILENT:
currStateResId = R.string.volume_ringer_status_silent;
break;
case RINGER_MODE_VIBRATE:
currStateResId = R.string.volume_ringer_status_vibrate;
break;
case RINGER_MODE_NORMAL:
default:
currStateResId = R.string.volume_ringer_status_normal;
}
view.setContentDescription(mContext.getString(currStateResId));
view.setContentDescription(
mContext.getString(getStringDescriptionResourceForRingerMode(currState)));
view.setAccessibilityDelegate(new AccessibilityDelegate() {
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
@@ -1487,6 +1487,18 @@ public class VolumeDialogImpl implements VolumeDialog,
});
}
private int getStringDescriptionResourceForRingerMode(int mode) {
switch (mode) {
case RINGER_MODE_SILENT:
return R.string.volume_ringer_status_silent;
case RINGER_MODE_VIBRATE:
return R.string.volume_ringer_status_vibrate;
case RINGER_MODE_NORMAL:
default:
return R.string.volume_ringer_status_normal;
}
}
/**
* Toggles enable state of views in a VolumeRow (not including seekbar or icon)
* Hides/shows zen icon