update strings in battery settings(Round 1)
This cl updates the strings in several battery settings pages and dialogs, also add footers for battery manager page and restrict app page. Update the strings in battery settings except: 1. Summary for smart battery toggle 2. "Full charge lasts" 3. Restrict dialog 4. App info page Bug: 73018395 Test: RunSettingsRoboTests Change-Id: I4955cc7c19b5f1df18f21cfb47e8859c997e19d1
This commit is contained in:
@@ -4825,37 +4825,41 @@
|
|||||||
<!-- Title for the battery summary tip [CHAR LIMIT=NONE] -->
|
<!-- Title for the battery summary tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_summary_title">Battery is in good shape</string>
|
<string name="battery_tip_summary_title">Battery is in good shape</string>
|
||||||
<!-- Summary for the battery summary tip [CHAR LIMIT=NONE] -->
|
<!-- Summary for the battery summary tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_summary_summary">Apps are behaving normally</string>
|
<string name="battery_tip_summary_summary">Apps are running normally</string>
|
||||||
<!-- Title for the low battery tip [CHAR LIMIT=NONE] -->
|
<!-- Title for the low battery tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_low_battery_title">Low battery capacity</string>
|
<string name="battery_tip_low_battery_title">Low battery capacity</string>
|
||||||
<!-- Summary for the low battery tip [CHAR LIMIT=NONE] -->
|
<!-- Summary for the low battery tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_low_battery_summary">Battery can\'t provide good battery life</string>
|
<string name="battery_tip_low_battery_summary">Battery can\'t provide good battery life</string>
|
||||||
<!-- Title for the smart battery tip [CHAR LIMIT=NONE] -->
|
<!-- Title for the smart battery tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_smart_battery_title">Turn on smart battery manager</string>
|
<string name="battery_tip_smart_battery_title" product="default">Improve your phone\'s battery life</string>
|
||||||
|
<!-- Title for the smart battery tip [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="battery_tip_smart_battery_title" product="tablet">Improve your tablet\'s battery life</string>
|
||||||
|
<!-- Title for the smart battery tip [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="battery_tip_smart_battery_title" product="device">Improve your device\'s battery life</string>
|
||||||
<!-- Summary for the smart battery tip [CHAR LIMIT=NONE] -->
|
<!-- Summary for the smart battery tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_smart_battery_summary">Turn on to optimize battery usage</string>
|
<string name="battery_tip_smart_battery_summary">Turn on Battery Manager</string>
|
||||||
<!-- Title for the early heads up tip [CHAR LIMIT=NONE] -->
|
<!-- Title for the early heads up tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_early_heads_up_title">Turn on Low Battery Mode</string>
|
<string name="battery_tip_early_heads_up_title">Turn on Battery Saver</string>
|
||||||
<!-- Summary for the early hedas up tip [CHAR LIMIT=NONE] -->
|
<!-- Summary for the early hedas up tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_early_heads_up_summary">Extend your battery life</string>
|
<string name="battery_tip_early_heads_up_summary">Battery may run out earlier than usual</string>
|
||||||
<!-- Title when early heads up is solved [CHAR LIMIT=NONE] -->
|
<!-- Title when early heads up is solved [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_early_heads_up_done_title">Low Battery Mode is on</string>
|
<string name="battery_tip_early_heads_up_done_title">Battery Saver is on</string>
|
||||||
<!-- Summary when early heads up is solved [CHAR LIMIT=NONE] -->
|
<!-- Summary when early heads up is solved [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_early_heads_up_done_summary">Some features are limited</string>
|
<string name="battery_tip_early_heads_up_done_summary">Some features may be limited</string>
|
||||||
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
|
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_high_usage_title" product="default">Phone used heavily</string>
|
<string name="battery_tip_high_usage_title" product="default">Phone used more than usual</string>
|
||||||
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
|
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_high_usage_title" product="tablet">Tablet used heavily</string>
|
<string name="battery_tip_high_usage_title" product="tablet">Tablet used more than usual</string>
|
||||||
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
|
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_high_usage_title" product="device">Device used heavily</string>
|
<string name="battery_tip_high_usage_title" product="device">Device used more than usual</string>
|
||||||
<!-- Summary for the battery high usage tip, which presents how many hours the device been used since last full charge [CHAR LIMIT=NONE] -->
|
<!-- Summary for the battery high usage tip, which presents battery may run out soon [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_high_usage_summary">About <xliff:g id="hour">%1$s</xliff:g> used since last full charge</string>
|
<string name="battery_tip_high_usage_summary">Battery may run out soon</string>
|
||||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_dialog_message" product="default">Your phone was used heavily and this consumed a lot of battery. Your battery is behaving normally.\n\n Your phone was used for about <xliff:g id="hour">%1$s</xliff:g> since last full charge.\n\n Total usage:</string>
|
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
||||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_dialog_message" product="tablet">Your tablet was used heavily and this consumed a lot of battery. Your battery is behaving normally.\n\n Your tablet was used for about <xliff:g id="hour">%1$s</xliff:g> since last full charge.\n\n Total usage:</string>
|
<string name="battery_tip_dialog_message" product="tablet">Your tablet has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
||||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_dialog_message" product="device">Your device was used heavily and this consumed a lot of battery. Your battery is behaving normally.\n\n Your device was used for about <xliff:g id="hour">%1$s</xliff:g> since last full charge.\n\n Total usage:</string>
|
<string name="battery_tip_dialog_message" product="device">Your device has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
||||||
<!-- Title for restricted app preference, showing how many app need to be restricted [CHAR LIMIT=NONE] -->
|
<!-- Title for restricted app preference, showing how many app need to be restricted [CHAR LIMIT=NONE] -->
|
||||||
<plurals name="battery_tip_restrict_title">
|
<plurals name="battery_tip_restrict_title">
|
||||||
<item quantity="one">Restrict %1$d app</item>
|
<item quantity="one">Restrict %1$d app</item>
|
||||||
@@ -4863,16 +4867,19 @@
|
|||||||
</plurals>
|
</plurals>
|
||||||
<!-- Title for restricted app preference, showing how many app been restricted [CHAR LIMIT=NONE] -->
|
<!-- Title for restricted app preference, showing how many app been restricted [CHAR LIMIT=NONE] -->
|
||||||
<plurals name="battery_tip_restrict_handled_title">
|
<plurals name="battery_tip_restrict_handled_title">
|
||||||
<item quantity="one">%1$d recently restricted</item>
|
<item quantity="one">%1$s recently restricted</item>
|
||||||
<item quantity="other">%1$d apps recently restricted</item>
|
<item quantity="other">%2$d apps recently restricted</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<!-- Summary for restricted app preference, showing the impact of the apps [CHAR LIMIT=NONE] -->
|
<!-- Summary for restricted app preference, showing the impact of the apps [CHAR LIMIT=NONE] -->
|
||||||
<plurals name="battery_tip_restrict_summary">
|
<plurals name="battery_tip_restrict_summary">
|
||||||
<item quantity="one">%1$s has high battery usage</item>
|
<item quantity="one">%1$s has high background battery usage</item>
|
||||||
<item quantity="other">%2$d apps have high battery usage</item>
|
<item quantity="other">%2$d apps have high background battery usage</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<!-- Summary for restricted app preference, showing the impact of the apps [CHAR LIMIT=NONE] -->
|
<!-- Summary for restricted app preference, showing the impact of the apps [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_restrict_handled_summary">App changes are in progress</string>
|
<plurals name="battery_tip_restrict_handled_summary">
|
||||||
|
<item quantity="one">This app can\'t run in the background</item>
|
||||||
|
<item quantity="other">These apps can\'t run in the background</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
<!-- Title for dialog to restrict the app [CHAR LIMIT=NONE] -->
|
<!-- Title for dialog to restrict the app [CHAR LIMIT=NONE] -->
|
||||||
<plurals name="battery_tip_restrict_app_dialog_title">
|
<plurals name="battery_tip_restrict_app_dialog_title">
|
||||||
@@ -4888,13 +4895,13 @@
|
|||||||
<!-- OK button for battery tip dialog to show the restrict app list [CHAR LIMIT=NONE] -->
|
<!-- OK button for battery tip dialog to show the restrict app list [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_restrict_app_dialog_ok">Restrict</string>
|
<string name="battery_tip_restrict_app_dialog_ok">Restrict</string>
|
||||||
<!-- Title for dialog to remove restriction for the app [CHAR LIMIT=NONE] -->
|
<!-- Title for dialog to remove restriction for the app [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_unrestrict_app_dialog_title">Remove restriction for <xliff:g id="app">%1$s</xliff:g>?</string>
|
<string name="battery_tip_unrestrict_app_dialog_title">Remove restriction?</string>
|
||||||
<!-- Message for dialog to show the impact if remove restriction for app [CHAR LIMIT=NONE] -->
|
<!-- Message for dialog to show the impact if remove restriction for app [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_unrestrict_app_dialog_message">This app will be able to use battery in the background. This may cause your battery to be used up faster.</string>
|
<string name="battery_tip_unrestrict_app_dialog_message">This app will be able to use battery in the background. Your battery may run out sooner than expected.</string>
|
||||||
<!-- OK button for dialog to remove restriction for app [CHAR LIMIT=NONE] -->
|
<!-- OK button for dialog to remove restriction for app [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_unrestrict_app_dialog_ok">Remove</string>
|
<string name="battery_tip_unrestrict_app_dialog_ok">Remove</string>
|
||||||
<!-- CANCEL button for dialog to remove restriction for app [CHAR LIMIT=NONE] -->
|
<!-- CANCEL button for dialog to remove restriction for app [CHAR LIMIT=NONE] -->
|
||||||
<string name="battery_tip_unrestrict_app_dialog_cancel">Not now</string>
|
<string name="battery_tip_unrestrict_app_dialog_cancel">Cancel</string>
|
||||||
|
|
||||||
<!-- Message for battery tip dialog to show the battery summary -->
|
<!-- Message for battery tip dialog to show the battery summary -->
|
||||||
<string name="battery_tip_dialog_summary_message">Based on your usage, your battery usually lasts about <xliff:g id="time_duration">%1$s</xliff:g> when fully charged.\n\nIf you need to extend your battery life, turn on Battery Saver.</string>
|
<string name="battery_tip_dialog_summary_message">Based on your usage, your battery usually lasts about <xliff:g id="time_duration">%1$s</xliff:g> when fully charged.\n\nIf you need to extend your battery life, turn on Battery Saver.</string>
|
||||||
@@ -4902,11 +4909,13 @@
|
|||||||
<string name="battery_tip_dialog_summary_message_no_estimation">If you need to extend your battery life, turn on Battery Saver</string>
|
<string name="battery_tip_dialog_summary_message_no_estimation">If you need to extend your battery life, turn on Battery Saver</string>
|
||||||
|
|
||||||
<!-- Title for the smart battery manager preference [CHAR LIMIT=NONE] -->
|
<!-- Title for the smart battery manager preference [CHAR LIMIT=NONE] -->
|
||||||
<string name="smart_battery_manager_title">Smart battery manager</string>
|
<string name="smart_battery_manager_title">Battery Manager</string>
|
||||||
<!-- Title for the smart battery toggle [CHAR LIMIT=NONE] -->
|
<!-- Title for the smart battery toggle [CHAR LIMIT=NONE] -->
|
||||||
<string name="smart_battery_title">Auto-manage battery</string>
|
<string name="smart_battery_title">Manage apps automatically</string>
|
||||||
<!-- Summary for the smart battery toggle [CHAR LIMIT=NONE] -->
|
<!-- Summary for the smart battery toggle [CHAR LIMIT=NONE] -->
|
||||||
<string name="smart_battery_summary">Automatically adjust power usage by apps based on usage</string>
|
<string name="smart_battery_summary">Limit battery for infrequently used apps and apps that consume battery</string>
|
||||||
|
<!-- Footer for the aosp smart battery page -->
|
||||||
|
<string name="smart_battery_footer">Battery Manager prevents apps from consuming battery when you aren\’t using them</string>
|
||||||
<!-- Title for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
|
<!-- Title for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
|
||||||
<string name="restricted_app_title">Restricted apps</string>
|
<string name="restricted_app_title">Restricted apps</string>
|
||||||
<!-- Summary for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
|
<!-- Summary for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
|
||||||
@@ -4915,6 +4924,9 @@
|
|||||||
<item quantity="other">%1$d apps</item>
|
<item quantity="other">%1$d apps</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Footer message for restrict app details page -->
|
||||||
|
<string name="restricted_app_detail_footer">Apps shown here aren\'t behaving properly and have been using battery in the background.\n\nThese apps are now blocked from using battery in the background. As a result, some app notifications may be delayed.</string>
|
||||||
|
|
||||||
<!-- Title for auto restriction toggle -->
|
<!-- Title for auto restriction toggle -->
|
||||||
<string name="battery_auto_restriction_title">Restrict apps automatically</string>
|
<string name="battery_auto_restriction_title">Restrict apps automatically</string>
|
||||||
<!-- Summary for auto restriction toggle -->
|
<!-- Summary for auto restriction toggle -->
|
||||||
@@ -5168,13 +5180,10 @@
|
|||||||
<string name="process_dex2oat_label">App optimization</string>
|
<string name="process_dex2oat_label">App optimization</string>
|
||||||
|
|
||||||
<!-- Battery saver: Label for feature, title + menu item [CHAR_LIMIT=40] -->
|
<!-- Battery saver: Label for feature, title + menu item [CHAR_LIMIT=40] -->
|
||||||
<string name="battery_saver">Reduced power mode</string>
|
<string name="battery_saver">Battery Saver</string>
|
||||||
|
|
||||||
<!-- Battery saver: Label for preference to turn on battery saver automatically when battery is low [CHAR_LIMIT=40] -->
|
<!-- Battery saver: Label for preference to turn on battery saver automatically when battery is low [CHAR_LIMIT=40] -->
|
||||||
<string name="battery_saver_auto_title">Schedule</string>
|
<string name="battery_saver_auto_title">Turn on automatically</string>
|
||||||
|
|
||||||
<!-- Battery saver: Summary for preference to turn on battery saver automatically when battery is low [CHAR_LIMIT=40] -->
|
|
||||||
<string name="battery_saver_auto_summary">Turn on Reduced power mode automatically when battery is low</string>
|
|
||||||
|
|
||||||
<!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
|
<!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
|
||||||
<string name="battery_saver_seekbar_title">Turn on automatically at <xliff:g id="percent">%1$s</xliff:g></string>
|
<string name="battery_saver_seekbar_title">Turn on automatically at <xliff:g id="percent">%1$s</xliff:g></string>
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="auto_battery_saver"
|
android:key="auto_battery_saver"
|
||||||
android:title="@string/battery_saver_auto_title"
|
android:title="@string/battery_saver_auto_title"
|
||||||
android:summary="@string/battery_saver_auto_summary"
|
|
||||||
settings:controller="com.android.settings.fuelgauge.batterysaver.AutoBatterySaverPreferenceController"/>
|
settings:controller="com.android.settings.fuelgauge.batterysaver.AutoBatterySaverPreferenceController"/>
|
||||||
|
|
||||||
<com.android.settings.widget.SeekBarPreference
|
<com.android.settings.widget.SeekBarPreference
|
||||||
|
@@ -39,6 +39,7 @@ import com.android.settings.dashboard.DashboardFragment;
|
|||||||
import com.android.settings.fuelgauge.batterytip.AppInfo;
|
import com.android.settings.fuelgauge.batterytip.AppInfo;
|
||||||
import com.android.settings.widget.AppCheckBoxPreference;
|
import com.android.settings.widget.AppCheckBoxPreference;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
import com.android.settingslib.widget.FooterPreferenceMixin;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -63,6 +64,8 @@ public class RestrictedAppDetails extends DashboardFragment {
|
|||||||
BatteryUtils mBatteryUtils;
|
BatteryUtils mBatteryUtils;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
PackageManager mPackageManager;
|
PackageManager mPackageManager;
|
||||||
|
private final FooterPreferenceMixin mFooterPreferenceMixin =
|
||||||
|
new FooterPreferenceMixin(this, getLifecycle());
|
||||||
|
|
||||||
public static void startRestrictedAppDetails(SettingsActivity caller,
|
public static void startRestrictedAppDetails(SettingsActivity caller,
|
||||||
InstrumentedPreferenceFragment fragment, List<AppInfo> appInfos) {
|
InstrumentedPreferenceFragment fragment, List<AppInfo> appInfos) {
|
||||||
@@ -82,6 +85,8 @@ public class RestrictedAppDetails extends DashboardFragment {
|
|||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
|
|
||||||
|
mFooterPreferenceMixin.createFooterPreference().setTitle(
|
||||||
|
R.string.restricted_app_detail_footer);
|
||||||
mRestrictedAppListGroup = (PreferenceGroup) findPreference(KEY_PREF_RESTRICTED_APP_LIST);
|
mRestrictedAppListGroup = (PreferenceGroup) findPreference(KEY_PREF_RESTRICTED_APP_LIST);
|
||||||
mAppInfos = getArguments().getParcelableArrayList(EXTRA_APP_INFO_LIST);
|
mAppInfos = getArguments().getParcelableArrayList(EXTRA_APP_INFO_LIST);
|
||||||
mPackageManager = context.getPackageManager();
|
mPackageManager = context.getPackageManager();
|
||||||
|
@@ -45,7 +45,7 @@ public class SmartBatterySettings extends DashboardFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.battery_footer_summary);
|
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.smart_battery_footer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -97,9 +97,7 @@ public class BatteryTipDialogFragment extends InstrumentedDialogFragment impleme
|
|||||||
|
|
||||||
return new AlertDialog.Builder(context)
|
return new AlertDialog.Builder(context)
|
||||||
.setMessage(getString(R.string.battery_tip_dialog_message,
|
.setMessage(getString(R.string.battery_tip_dialog_message,
|
||||||
StringUtil.formatElapsedTime(
|
highUsageTip.getHighUsageAppList().size()))
|
||||||
context, highUsageTip.getScreenTimeMs(),
|
|
||||||
false /* withSeconds */)))
|
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
.create();
|
.create();
|
||||||
@@ -140,7 +138,7 @@ public class BatteryTipDialogFragment extends InstrumentedDialogFragment impleme
|
|||||||
unrestrictAppTip.getPackageName());
|
unrestrictAppTip.getPackageName());
|
||||||
|
|
||||||
return new AlertDialog.Builder(context)
|
return new AlertDialog.Builder(context)
|
||||||
.setTitle(getString(R.string.battery_tip_unrestrict_app_dialog_title, name))
|
.setTitle(getString(R.string.battery_tip_unrestrict_app_dialog_title))
|
||||||
.setMessage(R.string.battery_tip_unrestrict_app_dialog_message)
|
.setMessage(R.string.battery_tip_unrestrict_app_dialog_message)
|
||||||
.setPositiveButton(R.string.battery_tip_unrestrict_app_dialog_ok, this)
|
.setPositiveButton(R.string.battery_tip_unrestrict_app_dialog_ok, this)
|
||||||
.setNegativeButton(R.string.battery_tip_unrestrict_app_dialog_cancel, null)
|
.setNegativeButton(R.string.battery_tip_unrestrict_app_dialog_cancel, null)
|
||||||
|
@@ -66,8 +66,7 @@ public class HighUsageTip extends BatteryTip {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary(Context context) {
|
public CharSequence getSummary(Context context) {
|
||||||
return context.getString(R.string.battery_tip_high_usage_summary,
|
return context.getString(R.string.battery_tip_high_usage_summary);
|
||||||
StringUtil.formatElapsedTime(context, mScreenTimeMs, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.fuelgauge.batterytip.tips;
|
package com.android.settings.fuelgauge.batterytip.tips;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.icu.text.ListFormatter;
|
import android.icu.text.ListFormatter;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -58,11 +59,14 @@ public class RestrictAppTip extends BatteryTip {
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence getTitle(Context context) {
|
public CharSequence getTitle(Context context) {
|
||||||
final int num = mRestrictAppList.size();
|
final int num = mRestrictAppList.size();
|
||||||
return context.getResources().getQuantityString(
|
final CharSequence appLabel = num > 0 ? Utils.getApplicationLabel(context,
|
||||||
mState == StateType.HANDLED
|
mRestrictAppList.get(0).packageName) : "";
|
||||||
? R.plurals.battery_tip_restrict_handled_title
|
final Resources resources = context.getResources();
|
||||||
: R.plurals.battery_tip_restrict_title,
|
|
||||||
num, num);
|
return mState == StateType.HANDLED
|
||||||
|
? resources.getQuantityString(R.plurals.battery_tip_restrict_handled_title, num,
|
||||||
|
appLabel, num)
|
||||||
|
: resources.getQuantityString(R.plurals.battery_tip_restrict_title, num, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -70,10 +74,10 @@ public class RestrictAppTip extends BatteryTip {
|
|||||||
final int num = mRestrictAppList.size();
|
final int num = mRestrictAppList.size();
|
||||||
final CharSequence appLabel = num > 0 ? Utils.getApplicationLabel(context,
|
final CharSequence appLabel = num > 0 ? Utils.getApplicationLabel(context,
|
||||||
mRestrictAppList.get(0).packageName) : "";
|
mRestrictAppList.get(0).packageName) : "";
|
||||||
return mState == StateType.HANDLED
|
final int resId = mState == StateType.HANDLED
|
||||||
? context.getString(R.string.battery_tip_restrict_handled_summary)
|
? R.plurals.battery_tip_restrict_handled_summary
|
||||||
: context.getResources().getQuantityString(R.plurals.battery_tip_restrict_summary,
|
: R.plurals.battery_tip_restrict_summary;
|
||||||
num, appLabel, num);
|
return context.getResources().getQuantityString(resId, num, appLabel, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -112,7 +112,7 @@ public class BatteryTipDialogFragmentTest {
|
|||||||
ShadowAlertDialog shadowDialog = shadowOf(dialog);
|
ShadowAlertDialog shadowDialog = shadowOf(dialog);
|
||||||
|
|
||||||
assertThat(shadowDialog.getMessage())
|
assertThat(shadowDialog.getMessage())
|
||||||
.isEqualTo(mContext.getString(R.string.battery_tip_dialog_message, "1h"));
|
.isEqualTo(mContext.getString(R.string.battery_tip_dialog_message, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -185,7 +185,7 @@ public class BatteryTipDialogFragmentTest {
|
|||||||
final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
|
final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
|
||||||
ShadowAlertDialog shadowDialog = shadowOf(dialog);
|
ShadowAlertDialog shadowDialog = shadowOf(dialog);
|
||||||
|
|
||||||
assertThat(shadowDialog.getTitle()).isEqualTo("Remove restriction for app?");
|
assertThat(shadowDialog.getTitle()).isEqualTo("Remove restriction?");
|
||||||
assertThat(shadowDialog.getMessage())
|
assertThat(shadowDialog.getMessage())
|
||||||
.isEqualTo(mContext.getString(R.string.battery_tip_unrestrict_app_dialog_message));
|
.isEqualTo(mContext.getString(R.string.battery_tip_unrestrict_app_dialog_message));
|
||||||
}
|
}
|
||||||
|
@@ -150,6 +150,6 @@ public class BatteryTipPreferenceControllerTest {
|
|||||||
|
|
||||||
final Preference preference = preferenceGroup.getPreference(0);
|
final Preference preference = preferenceGroup.getPreference(0);
|
||||||
assertThat(preference.getTitle()).isEqualTo("Battery is in good shape");
|
assertThat(preference.getTitle()).isEqualTo("Battery is in good shape");
|
||||||
assertThat(preference.getSummary()).isEqualTo("Apps are behaving normally");
|
assertThat(preference.getSummary()).isEqualTo("Apps are running normally");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -67,8 +67,8 @@ public class EarlyWarningTipTest {
|
|||||||
final EarlyWarningTip tip =
|
final EarlyWarningTip tip =
|
||||||
new EarlyWarningTip(BatteryTip.StateType.NEW, false /* powerModeOn */);
|
new EarlyWarningTip(BatteryTip.StateType.NEW, false /* powerModeOn */);
|
||||||
|
|
||||||
assertThat(tip.getTitle(mContext)).isEqualTo("Turn on Low Battery Mode");
|
assertThat(tip.getTitle(mContext)).isEqualTo("Turn on Battery Saver");
|
||||||
assertThat(tip.getSummary(mContext)).isEqualTo("Extend your battery life");
|
assertThat(tip.getSummary(mContext)).isEqualTo("Battery may run out earlier than usual");
|
||||||
assertThat(tip.getIconId()).isEqualTo(R.drawable.ic_battery_alert_24dp);
|
assertThat(tip.getIconId()).isEqualTo(R.drawable.ic_battery_alert_24dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ public class EarlyWarningTipTest {
|
|||||||
final EarlyWarningTip tip =
|
final EarlyWarningTip tip =
|
||||||
new EarlyWarningTip(BatteryTip.StateType.HANDLED, false /* powerModeOn */);
|
new EarlyWarningTip(BatteryTip.StateType.HANDLED, false /* powerModeOn */);
|
||||||
|
|
||||||
assertThat(tip.getTitle(mContext)).isEqualTo("Low Battery Mode is on");
|
assertThat(tip.getTitle(mContext)).isEqualTo("Battery Saver is on");
|
||||||
assertThat(tip.getSummary(mContext)).isEqualTo("Some features are limited");
|
assertThat(tip.getSummary(mContext)).isEqualTo("Some features may be limited");
|
||||||
assertThat(tip.getIconId()).isEqualTo(R.drawable.ic_perm_device_information_green_24dp);
|
assertThat(tip.getIconId()).isEqualTo(R.drawable.ic_perm_device_information_green_24dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ public class HighUsageTipTest {
|
|||||||
|
|
||||||
final HighUsageTip parcelTip = new HighUsageTip(parcel);
|
final HighUsageTip parcelTip = new HighUsageTip(parcel);
|
||||||
|
|
||||||
assertThat(parcelTip.getTitle(mContext)).isEqualTo("Phone used heavily");
|
assertThat(parcelTip.getTitle(mContext)).isEqualTo("Phone used more than usual");
|
||||||
assertThat(parcelTip.getType()).isEqualTo(BatteryTip.TipType.HIGH_DEVICE_USAGE);
|
assertThat(parcelTip.getType()).isEqualTo(BatteryTip.TipType.HIGH_DEVICE_USAGE);
|
||||||
assertThat(parcelTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
assertThat(parcelTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
||||||
assertThat(parcelTip.getScreenTimeMs()).isEqualTo(SCREEN_TIME);
|
assertThat(parcelTip.getScreenTimeMs()).isEqualTo(SCREEN_TIME);
|
||||||
|
@@ -32,8 +32,10 @@ import android.os.Parcel;
|
|||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.fuelgauge.batterytip.AppInfo;
|
import com.android.settings.fuelgauge.batterytip.AppInfo;
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -106,20 +108,37 @@ public class RestrictAppTipTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getTitle_stateHandled_showHandledTitle() {
|
public void getTitle_oneAppHandled_showHandledTitle() {
|
||||||
assertThat(mHandledBatteryTip.getTitle(mContext)).isEqualTo("1 recently restricted");
|
assertThat(mHandledBatteryTip.getTitle(mContext)).isEqualTo("app recently restricted");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getTitle_moreAppsHandled_showHandledTitle() {
|
||||||
|
mUsageAppList.add(new AppInfo.Builder().build());
|
||||||
|
mHandledBatteryTip = new RestrictAppTip(BatteryTip.StateType.HANDLED, mUsageAppList);
|
||||||
|
assertThat(mHandledBatteryTip.getTitle(mContext)).isEqualTo("2 apps recently restricted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_stateNew_showRestrictSummary() {
|
public void getSummary_stateNew_showRestrictSummary() {
|
||||||
assertThat(mNewBatteryTip.getSummary(mContext))
|
assertThat(mNewBatteryTip.getSummary(mContext))
|
||||||
.isEqualTo("app has high battery usage");
|
.isEqualTo("app has high background battery usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_stateHandled_showHandledSummary() {
|
public void getSummary_oneAppHandled_showHandledSummary() {
|
||||||
|
assertThat(mHandledBatteryTip.getSummary(mContext).toString())
|
||||||
|
.isEqualTo(mContext.getResources().getQuantityString(
|
||||||
|
R.plurals.battery_tip_restrict_handled_summary, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_moreAppsHandled_showHandledSummary() {
|
||||||
|
mUsageAppList.add(new AppInfo.Builder().build());
|
||||||
|
mHandledBatteryTip = new RestrictAppTip(BatteryTip.StateType.HANDLED, mUsageAppList);
|
||||||
assertThat(mHandledBatteryTip.getSummary(mContext))
|
assertThat(mHandledBatteryTip.getSummary(mContext))
|
||||||
.isEqualTo("App changes are in progress");
|
.isEqualTo(mContext.getResources().getQuantityString(
|
||||||
|
R.plurals.battery_tip_restrict_handled_summary, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user