Shorten main settings battery string
This string will be too long in other languages so we're shortening it for the main settings screen. Test: robotests updated Bug: 64124535 Change-Id: I5ccad99b1023f84ee72a144e07b1ea60f3fc01d5
This commit is contained in:
@@ -219,10 +219,8 @@ public class BatteryInfo {
|
|||||||
CharSequence timeString = Utils.formatElapsedTime(context,
|
CharSequence timeString = Utils.formatElapsedTime(context,
|
||||||
BatteryUtils.convertUsToMs(drainTimeUs), false /* withSeconds */);
|
BatteryUtils.convertUsToMs(drainTimeUs), false /* withSeconds */);
|
||||||
info.remainingLabel = TextUtils.expandTemplate(context.getText(shortString ?
|
info.remainingLabel = TextUtils.expandTemplate(context.getText(shortString ?
|
||||||
(basedOnUsage ?
|
R.string.power_remaining_duration_only_short :
|
||||||
R.string.power_remaining_duration_only_short_enhanced :
|
(basedOnUsage ?
|
||||||
R.string.power_remaining_duration_only_short) :
|
|
||||||
(basedOnUsage ?
|
|
||||||
R.string.power_remaining_duration_only_enhanced :
|
R.string.power_remaining_duration_only_enhanced :
|
||||||
R.string.power_remaining_duration_only)), timeString);
|
R.string.power_remaining_duration_only)), timeString);
|
||||||
info.chargeLabel = TextUtils.expandTemplate(context.getText(
|
info.chargeLabel = TextUtils.expandTemplate(context.getText(
|
||||||
|
@@ -887,7 +887,7 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
|||||||
public void onBatteryInfoLoaded(BatteryInfo info) {
|
public void onBatteryInfoLoaded(BatteryInfo info) {
|
||||||
mLoader.setSummary(SummaryProvider.this, info.chargeLabel);
|
mLoader.setSummary(SummaryProvider.this, info.chargeLabel);
|
||||||
}
|
}
|
||||||
});
|
}, true /* shortString */);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -131,7 +131,7 @@ public class BatteryInfoTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBatteryInfo_basedOnUsageTrue_usesUsageString() {
|
public void testGetBatteryInfo_basedOnUsageTrue_usesCorrectString() {
|
||||||
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
|
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
|
||||||
mBatteryStats, SystemClock.elapsedRealtime() * 1000, false /* shortString */,
|
mBatteryStats, SystemClock.elapsedRealtime() * 1000, false /* shortString */,
|
||||||
1000, true /* basedOnUsage */);
|
1000, true /* basedOnUsage */);
|
||||||
@@ -139,8 +139,10 @@ public class BatteryInfoTest {
|
|||||||
mBatteryStats, SystemClock.elapsedRealtime() * 1000, true /* shortString */,
|
mBatteryStats, SystemClock.elapsedRealtime() * 1000, true /* shortString */,
|
||||||
1000, true /* basedOnUsage */);
|
1000, true /* basedOnUsage */);
|
||||||
|
|
||||||
|
// We only add special mention for the long string
|
||||||
assertThat(info.remainingLabel.toString()).contains(ENHANCED_STRING_SUFFIX);
|
assertThat(info.remainingLabel.toString()).contains(ENHANCED_STRING_SUFFIX);
|
||||||
assertThat(info2.remainingLabel.toString()).contains(ENHANCED_STRING_SUFFIX);
|
// shortened string should not have extra text
|
||||||
|
assertThat(info2.remainingLabel.toString()).doesNotContain(ENHANCED_STRING_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user