Support accessibility for battery usage in U (1)
Fix b/265746746: TalkBack doesn't have any feedback after the actual double-tap of day bar and bi-hourly bar. 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/1ZuKQDBiTA2F8hHZDFvNx5nJEP-rMA0eZ/view?usp=sharing&resourcekey=0-2Q552VNxN4QwI2b5sdnvqg Bug: 265746746 Fix: 265746746 Test: manual Change-Id: I5485e714149014a96318fd88e8f8c854dde6cb67
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<com.android.settings.fuelgauge.batteryusage.AccessibilityFocusablePreferenceCategory
|
||||||
android:key="battery_usage_breakdown"
|
android:key="battery_usage_breakdown"
|
||||||
settings:controller=
|
settings:controller=
|
||||||
"com.android.settings.fuelgauge.batteryusage.BatteryUsageBreakdownController"
|
"com.android.settings.fuelgauge.batteryusage.BatteryUsageBreakdownController"
|
||||||
@@ -58,5 +58,5 @@
|
|||||||
settings:isPreferenceVisible="false"
|
settings:isPreferenceVisible="false"
|
||||||
settings:searchable="false" />
|
settings:searchable="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</com.android.settings.fuelgauge.batteryusage.AccessibilityFocusablePreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.fuelgauge.batteryusage;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference category that supports requesting accessibility focus.
|
||||||
|
*/
|
||||||
|
public class AccessibilityFocusablePreferenceCategory extends PreferenceCategory {
|
||||||
|
private PreferenceViewHolder mView;
|
||||||
|
|
||||||
|
public AccessibilityFocusablePreferenceCategory(Context context, AttributeSet attrs,
|
||||||
|
int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccessibilityFocusablePreferenceCategory(Context context, AttributeSet attrs,
|
||||||
|
int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccessibilityFocusablePreferenceCategory(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccessibilityFocusablePreferenceCategory(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||||
|
super.onBindViewHolder(view);
|
||||||
|
mView = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this to try to give accessibility focus to the category title.
|
||||||
|
*/
|
||||||
|
public void requestAccessibilityFocus() {
|
||||||
|
if (mView == null || mView.itemView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!AccessibilityManager.getInstance(getContext()).isEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mView.itemView.requestAccessibilityFocus();
|
||||||
|
}
|
||||||
|
}
|
@@ -27,7 +27,6 @@ import android.view.View;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceCategory;
|
|
||||||
import androidx.preference.PreferenceGroup;
|
import androidx.preference.PreferenceGroup;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
@@ -75,7 +74,7 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Context mPrefContext;
|
Context mPrefContext;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
PreferenceCategory mRootPreference;
|
AccessibilityFocusablePreferenceCategory mRootPreference;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SpinnerPreference mSpinnerPreference;
|
SpinnerPreference mSpinnerPreference;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -193,7 +192,6 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
|
|||||||
showFooterPreference(isAllUsageDataEmpty, slotTimestamp);
|
showFooterPreference(isAllUsageDataEmpty, slotTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: request accessibility focus on category title when slot selection updated.
|
|
||||||
private void showCategoryTitle(String slotTimestamp) {
|
private void showCategoryTitle(String slotTimestamp) {
|
||||||
mRootPreference.setTitle(slotTimestamp == null
|
mRootPreference.setTitle(slotTimestamp == null
|
||||||
? mPrefContext.getString(
|
? mPrefContext.getString(
|
||||||
@@ -201,6 +199,7 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
|
|||||||
: mPrefContext.getString(
|
: mPrefContext.getString(
|
||||||
R.string.battery_usage_breakdown_title_for_slot, slotTimestamp));
|
R.string.battery_usage_breakdown_title_for_slot, slotTimestamp));
|
||||||
mRootPreference.setVisible(true);
|
mRootPreference.setVisible(true);
|
||||||
|
mRootPreference.requestAccessibilityFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showFooterPreference(boolean isAllBatteryUsageEmpty, String slotTimestamp) {
|
private void showFooterPreference(boolean isAllBatteryUsageEmpty, String slotTimestamp) {
|
||||||
|
Reference in New Issue
Block a user