Fix setting state description of toggle button and switch
We should set the state description whenever textOn and textOff are updated. Setting it multiple times doesn't hurt because the setStateDescription method won't do anything if the state description is the same. Test: tested with talkback test app. Without the change, a toggle button with textOn and textOff set won't have them announced as the state before a click happens. After the change, a toggle button with textOn and textOff set has them announced as state. Change-Id: Ia1cc6218c8cd0125c123c9b650bb4963825db23a
This commit is contained in:
@@ -309,6 +309,9 @@ public class Switch extends CompoundButton {
|
||||
|
||||
// Refresh display with current params
|
||||
refreshDrawableState();
|
||||
// Default state is derived from on/off-text, so state has to be updated when on/off-text
|
||||
// are updated.
|
||||
setDefaultStateDescritption();
|
||||
setChecked(isChecked());
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ public class ToggleButton extends CompoundButton {
|
||||
mTextOff = a.getText(com.android.internal.R.styleable.ToggleButton_textOff);
|
||||
mDisabledAlpha = a.getFloat(com.android.internal.R.styleable.ToggleButton_disabledAlpha, 0.5f);
|
||||
syncTextState();
|
||||
// Default state is derived from on/off-text, so state has to be updated when on/off-text
|
||||
// are updated.
|
||||
setDefaultStateDescritption();
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user