Add dialog when restrict apps are more than 5
Bug: 73018395 Test: RunSettingsRoboTests Change-Id: Iec24fc1ce8e5840207610b3155dffa7059f9aa49
This commit is contained in:
@@ -107,21 +107,30 @@ public class BatteryTipDialogFragment extends InstrumentedDialogFragment impleme
|
||||
final RestrictAppTip restrictAppTip = (RestrictAppTip) mBatteryTip;
|
||||
final List<AppInfo> restrictedAppList = restrictAppTip.getRestrictAppList();
|
||||
final int num = restrictedAppList.size();
|
||||
final CharSequence appLabel = Utils.getApplicationLabel(context,
|
||||
restrictedAppList.get(0).packageName);
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context)
|
||||
.setTitle(context.getResources().getQuantityString(
|
||||
R.plurals.battery_tip_restrict_app_dialog_title, num, num))
|
||||
.setMessage(getString(R.string.battery_tip_restrict_app_dialog_message))
|
||||
.setPositiveButton(R.string.battery_tip_restrict_app_dialog_ok, this)
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
|
||||
// TODO(b/72385333): consider building dialog with 5+ apps when strings are done
|
||||
if (num > 1) {
|
||||
if (num == 1) {
|
||||
builder.setMessage(
|
||||
getString(R.string.battery_tip_restrict_app_dialog_message, appLabel));
|
||||
} else if (num <= 5) {
|
||||
builder.setMessage(
|
||||
getString(
|
||||
R.string.battery_tip_restrict_apps_less_than_5_dialog_message));
|
||||
final RecyclerView restrictionView = (RecyclerView) LayoutInflater.from(
|
||||
context).inflate(R.layout.recycler_view, null);
|
||||
restrictionView.setLayoutManager(new LinearLayoutManager(context));
|
||||
restrictionView.setAdapter(new HighUsageAdapter(context, restrictedAppList));
|
||||
builder.setView(restrictionView);
|
||||
} else {
|
||||
builder.setMessage(context.getString(
|
||||
R.string.battery_tip_restrict_apps_more_than_5_dialog_message,
|
||||
restrictAppTip.getRestrictAppsString(context)));
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
|
Reference in New Issue
Block a user