Merge "String change to highlight calculation stopped at last even hour" into tm-qpr-dev
This commit is contained in:
@@ -7004,6 +7004,10 @@
|
||||
<string name="battery_system_usage_for">System usage for <xliff:g id="slot">%s</xliff:g></string>
|
||||
<!-- [CHAR_LIMIT=NONE] Battery app usage section header -->
|
||||
<string name="battery_app_usage_for">App usage for <xliff:g id="slot">%s</xliff:g></string>
|
||||
<!-- [CHAR_LIMIT=NONE] Battery system usage section header since last full charge to slot_timestamp. Please use similar text with tc/3248552137819897140 -->
|
||||
<string name="battery_system_usage_since_last_full_charge_to">System usage since last full charge to <xliff:g id="slot_timestamp" example="Friday 10 am">%s</xliff:g></string>
|
||||
<!-- [CHAR_LIMIT=NONE] Battery app usage section header since last full charge to slot_timestamp. Please use similar text with tc/7309909074935858949 -->
|
||||
<string name="battery_app_usage_since_last_full_charge_to">App usage since last full charge to <xliff:g id="slot_timestamp" example="Friday 10 am">%s</xliff:g></string>
|
||||
<!-- [CHAR_LIMIT=NONE] Battery usage item for total usage time less than a minute -->
|
||||
<string name="battery_usage_total_less_than_one_minute">Total: less than a min</string>
|
||||
<!-- [CHAR_LIMIT=NONE] Battery usage item for total background time less than a minute -->
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -571,12 +571,13 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshCategoryTitle_setLastFullChargeIntoBothTitleTextView() {
|
||||
public void refreshCategoryTitle_singleDayData_setLastFullChargeIntoBothTitleTextView() {
|
||||
mBatteryChartPreferenceController = createController();
|
||||
mBatteryChartPreferenceController.mAppListPrefGroup =
|
||||
spy(new PreferenceCategory(mContext));
|
||||
mBatteryChartPreferenceController.mExpandDividerPreference =
|
||||
spy(new ExpandDividerPreference(mContext));
|
||||
mBatteryChartPreferenceController.setBatteryHistoryMap(createBatteryHistoryMap(6));
|
||||
// Simulates select all condition.
|
||||
mBatteryChartPreferenceController.mDailyChartIndex =
|
||||
BatteryChartViewModel.SELECTED_INDEX_ALL;
|
||||
@@ -590,13 +591,43 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
verify(mBatteryChartPreferenceController.mAppListPrefGroup)
|
||||
.setTitle(captor.capture());
|
||||
assertThat(captor.getValue())
|
||||
.isEqualTo("App usage since last full charge");
|
||||
.isEqualTo("App usage since last full charge to 12 PM");
|
||||
// Verifies the title in the expandable divider.
|
||||
captor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mBatteryChartPreferenceController.mExpandDividerPreference)
|
||||
.setTitle(captor.capture());
|
||||
assertThat(captor.getValue())
|
||||
.isEqualTo("System usage since last full charge");
|
||||
.isEqualTo("System usage since last full charge to 12 PM");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshCategoryTitle_multiDaysData_setLastFullChargeIntoBothTitleTextView() {
|
||||
mBatteryChartPreferenceController = createController();
|
||||
mBatteryChartPreferenceController.mAppListPrefGroup =
|
||||
spy(new PreferenceCategory(mContext));
|
||||
mBatteryChartPreferenceController.mExpandDividerPreference =
|
||||
spy(new ExpandDividerPreference(mContext));
|
||||
mBatteryChartPreferenceController.setBatteryHistoryMap(createBatteryHistoryMap(60));
|
||||
// Simulates select all condition.
|
||||
mBatteryChartPreferenceController.mDailyChartIndex =
|
||||
BatteryChartViewModel.SELECTED_INDEX_ALL;
|
||||
mBatteryChartPreferenceController.mHourlyChartIndex =
|
||||
BatteryChartViewModel.SELECTED_INDEX_ALL;
|
||||
|
||||
mBatteryChartPreferenceController.refreshCategoryTitle();
|
||||
|
||||
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
|
||||
// Verifies the title in the preference group.
|
||||
verify(mBatteryChartPreferenceController.mAppListPrefGroup)
|
||||
.setTitle(captor.capture());
|
||||
assertThat(captor.getValue())
|
||||
.isEqualTo("App usage since last full charge to Monday 6 PM");
|
||||
// Verifies the title in the expandable divider.
|
||||
captor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mBatteryChartPreferenceController.mExpandDividerPreference)
|
||||
.setTitle(captor.capture());
|
||||
assertThat(captor.getValue())
|
||||
.isEqualTo("System usage since last full charge to Monday 6 PM");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user