[GAR] fix spoke a percentage number is not the same as displayed content

in the Battery Saver and Battery Share, we have customized rule to map
the seekbar progresss to another displayed percentagge value, which
cause the a11y will speak the incorrect state, since the state is
referenced the original progress value. we add a method to override it
into our cusromized value.

Bug: 187780942
Bug: 190958777
Test: make SettingsGoogleRoboTests
Change-Id: Ie630ac03e66c2f8da1df00d6d2616b2e6979aa3e
This commit is contained in:
ykhung
2021-06-13 10:21:10 +08:00
committed by YUKAI HUNG
parent efd1c870f2
commit 64112f65fd
4 changed files with 40 additions and 6 deletions

View File

@@ -57,6 +57,7 @@ public class SeekBarPreference extends RestrictedPreference
private SeekBar mSeekBar;
private boolean mShouldBlink;
private int mAccessibilityRangeInfoType = AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_INT;
private CharSequence mOverrideSeekBarStateDescription;
private CharSequence mSeekBarContentDescription;
private CharSequence mSeekBarStateDescription;
@@ -162,6 +163,9 @@ public class SeekBarPreference extends RestrictedPreference
mAccessibilityRangeInfoType, rangeInfo.getMin(),
rangeInfo.getMax(), rangeInfo.getCurrent()));
}
if (mOverrideSeekBarStateDescription != null) {
info.setStateDescription(mOverrideSeekBarStateDescription);
}
}
});
}
@@ -348,6 +352,13 @@ public class SeekBarPreference extends RestrictedPreference
}
}
/**
* Overrides the state description of {@link SeekBar} with given content.
*/
public void overrideSeekBarStateDescription(CharSequence stateDescription) {
mOverrideSeekBarStateDescription = stateDescription;
}
@Override
protected Parcelable onSaveInstanceState() {
/*