String change to highlight calculation stopped at last even hour

Bug: 278022447
Fix: 278022447
Test: manual
Change-Id: Ia04ae7c7cb4c7ebdd40f4aa3df05b34d2ce66628
Merged-In: Ia08dea791bb72113719fd1316e8e9587a96eaef1
This commit is contained in:
Zaiyue Xue
2023-04-14 14:22:57 +08:00
parent c7550f62e7
commit 205d8249a7
3 changed files with 60 additions and 9 deletions

View File

@@ -593,8 +593,19 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
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.
if (slotInformation == null) {
if (mDailyViewModel != null && mHourlyViewModels != null && isAllSelected()) {
int lastDailyChartIndex = mDailyViewModel.size() - 2;
int lastHourlyChartIndex = mHourlyViewModels.get(lastDailyChartIndex).size() - 1;
String lastSlotInformation = getSlotInformation(
lastDailyChartIndex, lastHourlyChartIndex, /*isDayTextOnly=*/ false);
return isApp
? mPrefContext.getString(
R.string.battery_app_usage_since_last_full_charge_to,
lastSlotInformation)
: mPrefContext.getString(
R.string.battery_system_usage_since_last_full_charge_to,
lastSlotInformation);
} else if (slotInformation == null) {
return isApp
? mPrefContext.getString(R.string.battery_app_usage)
: mPrefContext.getString(R.string.battery_system_usage);
@@ -614,14 +625,19 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
if (isAllSelected()) {
return null;
}
return getSlotInformation(mDailyChartIndex, mHourlyChartIndex,
/*isDayTextOnly=*/ mHourlyChartIndex == BatteryChartViewModel.SELECTED_INDEX_ALL);
}
final String selectedDayText = mDailyViewModel.getFullText(mDailyChartIndex);
if (mHourlyChartIndex == BatteryChartViewModel.SELECTED_INDEX_ALL) {
private String getSlotInformation(
int dailyChartIndex, int hourlyChartIndex, boolean isDayTextOnly) {
final String selectedDayText = mDailyViewModel.getFullText(dailyChartIndex);
if (isDayTextOnly) {
return selectedDayText;
}
final String selectedHourText = mHourlyViewModels.get(mDailyChartIndex).getFullText(
mHourlyChartIndex);
final String selectedHourText = mHourlyViewModels.get(dailyChartIndex).getFullText(
hourlyChartIndex);
if (isBatteryLevelDataInOneDay()) {
return selectedHourText;
}