Support accessibility for battery chart (4)
According to accessibility suggestion, when users double clicked a time slot in battery usage chart with TalkBack on, jump the accessibility focus to the app list category title to let users know what happened after click. screen record: https://drive.google.com/file/d/13vvA2Il5lz9kvHegH9Tmbq9hJYFGVwJJ/view?usp=sharing&resourcekey=0-g3A29rVsd4NU37SwBD1uzQ Bug: 242989585 Fix: 242989585 Test: manual Change-Id: I8ab3b5f1364247121e43b0b8d51e8aa3743b5c2b
This commit is contained in:
@@ -28,6 +28,7 @@ import android.text.format.DateFormat;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -106,6 +107,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
private boolean mIs24HourFormat;
|
||||
private boolean mIsFooterPrefAdded = false;
|
||||
private View mBatteryChartViewGroup;
|
||||
private View mCategoryTitleView;
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
private FooterPreference mFooterPreference;
|
||||
private BatteryChartViewModel mDailyViewModel;
|
||||
@@ -327,6 +329,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
mDailyChartIndex = trapezoidIndex;
|
||||
mHourlyChartIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
|
||||
refreshUi();
|
||||
requestAccessibilityFocusForCategoryTitle(mDailyChartView);
|
||||
mMetricsFeatureProvider.action(
|
||||
mPrefContext,
|
||||
trapezoidIndex == BatteryChartViewModel.SELECTED_INDEX_ALL
|
||||
@@ -342,6 +345,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
Log.d(TAG, "onHourlyChartSelect:" + trapezoidIndex);
|
||||
mHourlyChartIndex = trapezoidIndex;
|
||||
refreshUi();
|
||||
requestAccessibilityFocusForCategoryTitle(mHourlyChartView);
|
||||
mMetricsFeatureProvider.action(
|
||||
mPrefContext,
|
||||
trapezoidIndex == BatteryChartViewModel.SELECTED_INDEX_ALL
|
||||
@@ -525,6 +529,18 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
}
|
||||
}
|
||||
|
||||
private void requestAccessibilityFocusForCategoryTitle(View view) {
|
||||
if (!AccessibilityManager.getInstance(mContext).isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (mCategoryTitleView == null) {
|
||||
mCategoryTitleView = view.getRootView().findViewById(com.android.internal.R.id.title);
|
||||
}
|
||||
if (mCategoryTitleView != null) {
|
||||
mCategoryTitleView.requestAccessibilityFocus();
|
||||
}
|
||||
}
|
||||
|
||||
private String getSlotInformation(boolean isApp, String slotInformation) {
|
||||
// TODO: Updates the right slot information from daily and hourly chart selection.
|
||||
// Null means we show all information without a specific time slot.
|
||||
|
Reference in New Issue
Block a user