Update low battery tips string am: 6d836d2d51

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14048550

Change-Id: I20ef817e4cd7bea00cc4ea6b74a35c7ea82022c6
This commit is contained in:
Wesley.CW Wang
2021-04-01 06:52:53 +00:00
committed by Automerger Merge Worker
6 changed files with 22 additions and 17 deletions

View File

@@ -89,8 +89,7 @@ public class BatteryTipLoader extends AsyncLoaderCompat<List<BatteryTip>> {
final List<BatteryTip> tips = new ArrayList<>(); final List<BatteryTip> tips = new ArrayList<>();
tips.add(new SummaryTip(BatteryTip.StateType.NEW, tips.add(new SummaryTip(BatteryTip.StateType.NEW,
EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN)); EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
tips.add(new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */, tips.add(new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */));
"Fake data"));
return tips; return tips;
} }

View File

@@ -61,7 +61,6 @@ public class LowBatteryDetector implements BatteryTipDetector {
state = BatteryTip.StateType.NEW; state = BatteryTip.StateType.NEW;
} }
return new LowBatteryTip( return new LowBatteryTip(state, powerSaveModeOn);
state, powerSaveModeOn, mBatteryInfo.suggestionLabel);
} }
} }

View File

@@ -21,34 +21,36 @@ import android.content.Context;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import com.android.settings.R;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
/** /**
* Tip to show current battery level is low or remaining time is less than a certain period * Tip to show current battery level is low or remaining time is less than a certain period
*/ */
public class LowBatteryTip extends EarlyWarningTip { public class LowBatteryTip extends EarlyWarningTip {
private CharSequence mSummary;
public LowBatteryTip(@StateType int state, boolean powerSaveModeOn, CharSequence summary) { public LowBatteryTip(@StateType int state, boolean powerSaveModeOn) {
super(state, powerSaveModeOn); super(state, powerSaveModeOn);
mType = TipType.LOW_BATTERY; mType = TipType.LOW_BATTERY;
mSummary = summary;
} }
public LowBatteryTip(Parcel in) { public LowBatteryTip(Parcel in) {
super(in); super(in);
mSummary = in.readCharSequence(); }
@Override
public CharSequence getTitle(Context context) {
return context.getString(R.string.battery_tip_low_battery_title);
} }
@Override @Override
public CharSequence getSummary(Context context) { public CharSequence getSummary(Context context) {
return mSummary; return context.getString(R.string.battery_tip_low_battery_summary);
} }
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags); super.writeToParcel(dest, flags);
dest.writeCharSequence(mSummary);
} }
@Override @Override

View File

@@ -67,8 +67,7 @@ public class BatteryTipUtilsTest {
mEarlyWarningTip = spy( mEarlyWarningTip = spy(
new EarlyWarningTip(BatteryTip.StateType.NEW, true /* powerSaveModeOn */)); new EarlyWarningTip(BatteryTip.StateType.NEW, true /* powerSaveModeOn */));
mLowBatteryTip = spy( mLowBatteryTip = spy(
new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */, new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */));
"" /* summary */));
mBatteryDefenderTip = spy(new BatteryDefenderTip(BatteryTip.StateType.NEW)); mBatteryDefenderTip = spy(new BatteryDefenderTip(BatteryTip.StateType.NEW));
} }

View File

@@ -36,7 +36,7 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class LowBatteryTipTest { public class LowBatteryTipTest {
private static final CharSequence SUMMARY = "Only 15 minutes left"; private static final CharSequence SUMMARY = "Turn on Battery Saver to extend battery life";
@Mock @Mock
private MetricsFeatureProvider mMetricsFeatureProvider; private MetricsFeatureProvider mMetricsFeatureProvider;
@@ -48,8 +48,7 @@ public class LowBatteryTipTest {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application; mContext = RuntimeEnvironment.application;
mLowBatteryTip = new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */, mLowBatteryTip = new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */);
SUMMARY);
} }
@Test @Test
@@ -64,6 +63,13 @@ public class LowBatteryTipTest {
assertThat(parcelTip.getSummary(mContext)).isEqualTo(SUMMARY); assertThat(parcelTip.getSummary(mContext)).isEqualTo(SUMMARY);
} }
@Test
public void getSummary_tipNew_showTitle() {
mLowBatteryTip.mState = BatteryTip.StateType.NEW;
assertThat(mLowBatteryTip.getTitle(mContext)).isEqualTo("Battery level low");
}
@Test @Test
public void getSummary_tipNew_showSummary() { public void getSummary_tipNew_showSummary() {
mLowBatteryTip.mState = BatteryTip.StateType.NEW; mLowBatteryTip.mState = BatteryTip.StateType.NEW;

View File

@@ -85,7 +85,7 @@ public class BatteryFixSliceTest {
@Test @Test
public void refreshBatteryTips_hasImportantTip_shouldReturnTrue() { public void refreshBatteryTips_hasImportantTip_shouldReturnTrue() {
final List<BatteryTip> tips = new ArrayList<>(); final List<BatteryTip> tips = new ArrayList<>();
tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, "")); tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false));
tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false)); tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
ShadowBatteryTipLoader.setBatteryTips(tips); ShadowBatteryTipLoader.setBatteryTips(tips);
@@ -102,7 +102,7 @@ public class BatteryFixSliceTest {
.setPackageName("com.android.settings") .setPackageName("com.android.settings")
.setScreenOnTimeMs(10000L) .setScreenOnTimeMs(10000L)
.build()); .build());
tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, "")); tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false));
tips.add(new EarlyWarningTip(BatteryTip.StateType.HANDLED, false)); tips.add(new EarlyWarningTip(BatteryTip.StateType.HANDLED, false));
tips.add(new HighUsageTip(1000L, appList)); tips.add(new HighUsageTip(1000L, appList));
ShadowBatteryTipLoader.setBatteryTips(tips); ShadowBatteryTipLoader.setBatteryTips(tips);