Merge "Revert "Revert "Ringer mode button state a11y""" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
66e2d492f1
@@ -929,6 +929,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
|
|||||||
showRingerDrawer();
|
showRingerDrawer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
updateSelectedRingerContainerDescription(mIsRingerDrawerOpen);
|
||||||
|
|
||||||
mRingerDrawerVibrate.setOnClickListener(
|
mRingerDrawerVibrate.setOnClickListener(
|
||||||
new RingerDrawerItemClickListener(RINGER_MODE_VIBRATE));
|
new RingerDrawerItemClickListener(RINGER_MODE_VIBRATE));
|
||||||
@@ -991,6 +992,19 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
|
|||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting String getSelectedRingerContainerDescription() {
|
||||||
|
return mSelectedRingerContainer == null ? null :
|
||||||
|
mSelectedRingerContainer.getContentDescription().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting void toggleRingerDrawer(boolean show) {
|
||||||
|
if (show) {
|
||||||
|
showRingerDrawer();
|
||||||
|
} else {
|
||||||
|
hideRingerDrawer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Animates in the ringer drawer. */
|
/** Animates in the ringer drawer. */
|
||||||
private void showRingerDrawer() {
|
private void showRingerDrawer() {
|
||||||
if (mIsRingerDrawerOpen) {
|
if (mIsRingerDrawerOpen) {
|
||||||
@@ -1068,12 +1082,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
|
|||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the ringer drawer is open, tapping the currently selected ringer will set the ringer
|
updateSelectedRingerContainerDescription(true);
|
||||||
// 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;
|
mIsRingerDrawerOpen = true;
|
||||||
}
|
}
|
||||||
@@ -1119,14 +1128,38 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
|
|||||||
.translationY(0f)
|
.translationY(0f)
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
// When the drawer is closed, tapping the selected ringer drawer will open it, allowing the
|
updateSelectedRingerContainerDescription(false);
|
||||||
// user to change the ringer.
|
|
||||||
mSelectedRingerContainer.setContentDescription(
|
|
||||||
mContext.getString(R.string.volume_ringer_change));
|
|
||||||
|
|
||||||
mIsRingerDrawerOpen = false;
|
mIsRingerDrawerOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param open false to set the description when drawer is closed
|
||||||
|
*/
|
||||||
|
private void updateSelectedRingerContainerDescription(boolean open) {
|
||||||
|
if (mState == null || mSelectedRingerContainer == null) return;
|
||||||
|
|
||||||
|
String currentMode = mContext.getString(getStringDescriptionResourceForRingerMode(
|
||||||
|
mState.ringerModeInternal));
|
||||||
|
String tapToSelect;
|
||||||
|
|
||||||
|
if (open) {
|
||||||
|
// 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.
|
||||||
|
tapToSelect = "";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// When the drawer is closed, tapping the selected ringer drawer will open it, allowing
|
||||||
|
// the user to change the ringer. The user needs to know that, and also the current mode
|
||||||
|
currentMode += ", ";
|
||||||
|
tapToSelect = mContext.getString(R.string.volume_ringer_change);
|
||||||
|
}
|
||||||
|
|
||||||
|
mSelectedRingerContainer.setContentDescription(currentMode + tapToSelect);
|
||||||
|
}
|
||||||
|
|
||||||
private void initSettingsH(int lockTaskModeState) {
|
private void initSettingsH(int lockTaskModeState) {
|
||||||
if (mSettingsView != null) {
|
if (mSettingsView != null) {
|
||||||
mSettingsView.setVisibility(
|
mSettingsView.setVisibility(
|
||||||
@@ -1702,7 +1735,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getStringDescriptionResourceForRingerMode(int mode) {
|
@VisibleForTesting int getStringDescriptionResourceForRingerMode(int mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case RINGER_MODE_SILENT:
|
case RINGER_MODE_SILENT:
|
||||||
return R.string.volume_ringer_status_silent;
|
return R.string.volume_ringer_status_silent;
|
||||||
@@ -1784,6 +1817,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
|
|||||||
updateVolumeRowH(row);
|
updateVolumeRowH(row);
|
||||||
}
|
}
|
||||||
updateRingerH();
|
updateRingerH();
|
||||||
|
updateSelectedRingerContainerDescription(mIsRingerDrawerOpen);
|
||||||
mWindow.setTitle(composeWindowTitle());
|
mWindow.setTitle(composeWindowTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,19 @@
|
|||||||
|
|
||||||
package com.android.systemui.volume;
|
package com.android.systemui.volume;
|
||||||
|
|
||||||
|
import static android.media.AudioManager.RINGER_MODE_NORMAL;
|
||||||
|
import static android.media.AudioManager.RINGER_MODE_SILENT;
|
||||||
|
import static android.media.AudioManager.RINGER_MODE_VIBRATE;
|
||||||
|
|
||||||
import static com.android.systemui.volume.Events.DISMISS_REASON_UNKNOWN;
|
import static com.android.systemui.volume.Events.DISMISS_REASON_UNKNOWN;
|
||||||
import static com.android.systemui.volume.Events.SHOW_REASON_UNKNOWN;
|
import static com.android.systemui.volume.Events.SHOW_REASON_UNKNOWN;
|
||||||
import static com.android.systemui.volume.VolumeDialogControllerImpl.STREAMS;
|
import static com.android.systemui.volume.VolumeDialogControllerImpl.STREAMS;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
import static junit.framework.Assert.assertNotSame;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
|
import static org.junit.Assume.assumeNotNull;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@@ -293,7 +299,7 @@ public class VolumeDialogImplTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testSelectVibrateFromDrawer() {
|
public void testSelectVibrateFromDrawer() {
|
||||||
final State initialUnsetState = new State();
|
final State initialUnsetState = new State();
|
||||||
initialUnsetState.ringerModeInternal = AudioManager.RINGER_MODE_NORMAL;
|
initialUnsetState.ringerModeInternal = RINGER_MODE_NORMAL;
|
||||||
mDialog.onStateChangedH(initialUnsetState);
|
mDialog.onStateChangedH(initialUnsetState);
|
||||||
|
|
||||||
mActiveRinger.performClick();
|
mActiveRinger.performClick();
|
||||||
@@ -307,7 +313,7 @@ public class VolumeDialogImplTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testSelectMuteFromDrawer() {
|
public void testSelectMuteFromDrawer() {
|
||||||
final State initialUnsetState = new State();
|
final State initialUnsetState = new State();
|
||||||
initialUnsetState.ringerModeInternal = AudioManager.RINGER_MODE_NORMAL;
|
initialUnsetState.ringerModeInternal = RINGER_MODE_NORMAL;
|
||||||
mDialog.onStateChangedH(initialUnsetState);
|
mDialog.onStateChangedH(initialUnsetState);
|
||||||
|
|
||||||
mActiveRinger.performClick();
|
mActiveRinger.performClick();
|
||||||
@@ -329,7 +335,7 @@ public class VolumeDialogImplTest extends SysuiTestCase {
|
|||||||
|
|
||||||
// Make sure we've actually changed the ringer mode.
|
// Make sure we've actually changed the ringer mode.
|
||||||
verify(mVolumeDialogController, times(1)).setRingerMode(
|
verify(mVolumeDialogController, times(1)).setRingerMode(
|
||||||
AudioManager.RINGER_MODE_NORMAL, false);
|
RINGER_MODE_NORMAL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -511,6 +517,87 @@ public class VolumeDialogImplTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum RingerDrawerState {INIT, OPEN, CLOSE}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeNormal_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_NORMAL, RingerDrawerState.INIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeSilent_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_SILENT, RingerDrawerState.INIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeVibrate_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_VIBRATE, RingerDrawerState.INIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeNormal_openDrawer_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_NORMAL, RingerDrawerState.OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeSilent_openDrawer_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_SILENT, RingerDrawerState.OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeVibrate_openDrawer_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_VIBRATE, RingerDrawerState.OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeNormal_closeDrawer_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_NORMAL, RingerDrawerState.CLOSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeSilent_closeDrawer_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_SILENT, RingerDrawerState.CLOSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeVibrate_closeDrawer_ringerContainerDescribesItsState() {
|
||||||
|
assertRingerContainerDescribesItsState(RINGER_MODE_VIBRATE, RingerDrawerState.CLOSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The content description should include ringer state, and the correct one.
|
||||||
|
*/
|
||||||
|
private void assertRingerContainerDescribesItsState(int ringerMode,
|
||||||
|
RingerDrawerState drawerState) {
|
||||||
|
State state = createShellState();
|
||||||
|
state.ringerModeInternal = ringerMode;
|
||||||
|
mDialog.onStateChangedH(state);
|
||||||
|
|
||||||
|
mDialog.show(SHOW_REASON_UNKNOWN);
|
||||||
|
|
||||||
|
if (drawerState != RingerDrawerState.INIT) {
|
||||||
|
// in both cases we first open the drawer
|
||||||
|
mDialog.toggleRingerDrawer(true);
|
||||||
|
|
||||||
|
if (drawerState == RingerDrawerState.CLOSE) {
|
||||||
|
mDialog.toggleRingerDrawer(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String ringerContainerDescription = mDialog.getSelectedRingerContainerDescription();
|
||||||
|
assumeNotNull(ringerContainerDescription);
|
||||||
|
|
||||||
|
String ringerDescription = mContext.getString(
|
||||||
|
mDialog.getStringDescriptionResourceForRingerMode(ringerMode));
|
||||||
|
|
||||||
|
if (drawerState == RingerDrawerState.OPEN) {
|
||||||
|
assertEquals(ringerDescription, ringerContainerDescription);
|
||||||
|
} else {
|
||||||
|
assertNotSame(ringerDescription, ringerContainerDescription);
|
||||||
|
assertTrue(ringerContainerDescription.startsWith(ringerDescription));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void teardown() {
|
public void teardown() {
|
||||||
if (mDialog != null) {
|
if (mDialog != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user