Help talkback to read the hyphen of time frame '{day}{time}-{time}' in PreferenceCategory Title.

Bug: 346707823
Test: atest + manual
Change-Id: I3098ccaffd6396fb1f00e3b57c326980250651f2
This commit is contained in:
mxyyiyi
2024-06-12 16:37:51 +08:00
parent 7f2090d395
commit d047b6da10
4 changed files with 75 additions and 24 deletions

View File

@@ -87,6 +87,7 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
@VisibleForTesting PreferenceGroup mAppListPreferenceGroup;
@VisibleForTesting FooterPreference mFooterPreference;
@VisibleForTesting BatteryDiffData mBatteryDiffData;
@VisibleForTesting String mBatteryUsageBreakdownTitleLastFullChargeText;
@VisibleForTesting String mPercentLessThanThresholdText;
@VisibleForTesting String mPercentLessThanThresholdContentDescription;
@VisibleForTesting boolean mIsHighlightSlot;
@@ -147,9 +148,10 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
private void logPreferenceClickedMetrics(BatteryDiffEntry entry) {
final int attribution = SettingsEnums.OPEN_BATTERY_USAGE;
final int action = entry.isSystemEntry()
? SettingsEnums.ACTION_BATTERY_USAGE_SYSTEM_ITEM
: SettingsEnums.ACTION_BATTERY_USAGE_APP_ITEM;
final int action =
entry.isSystemEntry()
? SettingsEnums.ACTION_BATTERY_USAGE_SYSTEM_ITEM
: SettingsEnums.ACTION_BATTERY_USAGE_APP_ITEM;
final int pageId = SettingsEnums.OPEN_BATTERY_USAGE;
final String packageName =
TextUtils.isEmpty(entry.getPackageName())
@@ -203,6 +205,9 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
mSpinnerPreference = screen.findPreference(SPINNER_PREFERENCE_KEY);
mAppListPreferenceGroup = screen.findPreference(APP_LIST_PREFERENCE_KEY);
mFooterPreference = screen.findPreference(FOOTER_PREFERENCE_KEY);
mBatteryUsageBreakdownTitleLastFullChargeText =
mPrefContext.getString(
R.string.battery_usage_breakdown_title_since_last_full_charge);
final String formatPercentage =
Utils.formatPercentage(BatteryDiffData.SMALL_PERCENTAGE_THRESHOLD, false);
mPercentLessThanThresholdText =
@@ -254,6 +259,7 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
void handleBatteryUsageUpdated(
BatteryDiffData slotUsageData,
String slotTimestamp,
String accessibilitySlotTimestamp,
boolean isAllUsageDataEmpty,
boolean isHighlightSlot,
Optional<AnomalyEventWrapper> optionalAnomalyEventWrapper) {
@@ -276,18 +282,24 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
: null;
}
showCategoryTitle(slotTimestamp);
showCategoryTitle(slotTimestamp, accessibilitySlotTimestamp);
showSpinnerAndAppList();
showFooterPreference(isAllUsageDataEmpty);
}
private void showCategoryTitle(String slotTimestamp) {
mRootPreference.setTitle(
private void showCategoryTitle(String slotTimestamp, String accessibilitySlotTimestamp) {
final String displayTitle =
slotTimestamp == null
? mPrefContext.getString(
R.string.battery_usage_breakdown_title_since_last_full_charge)
? mBatteryUsageBreakdownTitleLastFullChargeText
: mPrefContext.getString(
R.string.battery_usage_breakdown_title_for_slot, slotTimestamp));
R.string.battery_usage_breakdown_title_for_slot, slotTimestamp);
final String accessibilityTitle =
accessibilitySlotTimestamp == null
? mBatteryUsageBreakdownTitleLastFullChargeText
: mPrefContext.getString(
R.string.battery_usage_breakdown_title_for_slot,
accessibilitySlotTimestamp);
mRootPreference.setTitle(Utils.createAccessibleSequence(displayTitle, accessibilityTitle));
mRootPreference.setVisible(true);
}

View File

@@ -242,9 +242,14 @@ public class PowerUsageAdvanced extends PowerUsageBase {
final String slotInformation =
mBatteryChartPreferenceController.getSlotInformation(
/* isAccessibilityText= */ false);
final String accessibilitySlotInformation =
mBatteryChartPreferenceController.getSlotInformation(
/* isAccessibilityText= */ true);
final BatteryDiffData slotUsageData = mBatteryUsageMap.get(dailyIndex).get(hourlyIndex);
mScreenOnTimeController.handleSceenOnTimeUpdated(
slotUsageData != null ? slotUsageData.getScreenOnTime() : 0L, slotInformation);
mScreenOnTimeController.handleScreenOnTimeUpdated(
slotUsageData != null ? slotUsageData.getScreenOnTime() : 0L,
slotInformation,
accessibilitySlotInformation);
// Hide card tips if the related highlight slot was clicked.
if (isAppsAnomalyEventFocused()) {
mBatteryTipsController.acceptTipsCard();
@@ -252,6 +257,7 @@ public class PowerUsageAdvanced extends PowerUsageBase {
mBatteryUsageBreakdownController.handleBatteryUsageUpdated(
slotUsageData,
slotInformation,
accessibilitySlotInformation,
isBatteryUsageMapNullOrEmpty(),
isAppsAnomalyEventFocused(),
mHighlightEventWrapper);

View File

@@ -27,6 +27,7 @@ import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.fuelgauge.BatteryUtils;
@@ -45,6 +46,7 @@ public class ScreenOnTimeController extends BasePreferenceController {
@VisibleForTesting Context mPrefContext;
@VisibleForTesting PreferenceCategory mRootPreference;
@VisibleForTesting TextViewPreference mScreenOnTimeTextPreference;
@VisibleForTesting String mScreenTimeCategoryLastFullChargeText;
public ScreenOnTimeController(Context context) {
super(context, ROOT_PREFERENCE_KEY);
@@ -61,25 +63,34 @@ public class ScreenOnTimeController extends BasePreferenceController {
mPrefContext = screen.getContext();
mRootPreference = screen.findPreference(ROOT_PREFERENCE_KEY);
mScreenOnTimeTextPreference = screen.findPreference(SCREEN_ON_TIME_TEXT_PREFERENCE_KEY);
mScreenTimeCategoryLastFullChargeText =
mPrefContext.getString(R.string.screen_time_category_last_full_charge);
}
void handleSceenOnTimeUpdated(Long screenOnTime, String slotTimestamp) {
void handleScreenOnTimeUpdated(
Long screenOnTime, String slotTimestamp, String accessibilitySlotTimestamp) {
if (screenOnTime == null) {
mRootPreference.setVisible(false);
mScreenOnTimeTextPreference.setVisible(false);
return;
}
showCategoryTitle(slotTimestamp);
showCategoryTitle(slotTimestamp, accessibilitySlotTimestamp);
showScreenOnTimeText(screenOnTime);
}
@VisibleForTesting
void showCategoryTitle(String slotTimestamp) {
mRootPreference.setTitle(
void showCategoryTitle(String slotTimestamp, String accessibilitySlotTimestamp) {
final String displayTitle =
slotTimestamp == null
? mPrefContext.getString(R.string.screen_time_category_last_full_charge)
? mScreenTimeCategoryLastFullChargeText
: mPrefContext.getString(
R.string.screen_time_category_for_slot, slotTimestamp));
R.string.screen_time_category_for_slot, slotTimestamp);
final String accessibilityTitle =
accessibilitySlotTimestamp == null
? mScreenTimeCategoryLastFullChargeText
: mPrefContext.getString(
R.string.screen_time_category_for_slot, accessibilitySlotTimestamp);
mRootPreference.setTitle(Utils.createAccessibleSequence(displayTitle, accessibilityTitle));
mRootPreference.setVisible(true);
}