Fix b/265746746: Announce "Battery usage for [slot_timestamp]" instead of changing focus when Talk Back on.

https://drive.google.com/file/d/173RPKsnIE7ZhBAJLrivqkbiWg9Ay41bC/view?usp=sharing&resourcekey=0-jHJ7vZ9BEhzxdWncqCQVQg

Bug: 265746746
Fix: 265746746
Test: manual
Change-Id: Iad92eff50d73853793daa9d6d3551768678c2eb2
This commit is contained in:
Zaiyue Xue
2023-02-06 16:11:47 +08:00
parent 20326d6907
commit e04ffdea58
4 changed files with 17 additions and 74 deletions

View File

@@ -296,6 +296,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
mDailyChartIndex = trapezoidIndex;
mHourlyChartIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
refreshUi();
mHandler.post(() -> mDailyChartView.announceForAccessibility(
getAccessibilityAnnounceMessage()));
mMetricsFeatureProvider.action(
mPrefContext,
trapezoidIndex == BatteryChartViewModel.SELECTED_INDEX_ALL
@@ -311,6 +313,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
Log.d(TAG, "onHourlyChartSelect:" + trapezoidIndex);
mHourlyChartIndex = trapezoidIndex;
refreshUi();
mHandler.post(() -> mHourlyChartView.announceForAccessibility(
getAccessibilityAnnounceMessage()));
mMetricsFeatureProvider.action(
mPrefContext,
trapezoidIndex == BatteryChartViewModel.SELECTED_INDEX_ALL
@@ -439,6 +443,15 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
return String.format("%s %s", selectedDayText, selectedHourText);
}
private String getAccessibilityAnnounceMessage() {
final String slotInformation = getSlotInformation();
return slotInformation == null
? mPrefContext.getString(
R.string.battery_usage_breakdown_title_since_last_full_charge)
: mPrefContext.getString(
R.string.battery_usage_breakdown_title_for_slot, slotInformation);
}
private void animateBatteryChartViewGroup() {
if (mBatteryChartViewGroup != null && mBatteryChartViewGroup.getAlpha() == 0) {
mBatteryChartViewGroup.animate().alpha(1f).setDuration(FADE_IN_ANIMATION_DURATION)