Create shell UI for smart battery saver

This CL creates the new screen WITHOUT any of the behaviors
(changing the global settings/calling power manager apis) and
hooks it up to the preference in BatterySaverSettings for
navigation. The logic for the preference in BatterySaver Settings
is also added so that it shows the correct summary when the
schedule settings are modified. Additionally, a small tweak is
made to the radio preference widget to make it possible to hide
the appendix view. It didn't seem to do anything except get in
the way and potentially ruin your day, much like its biological
counterpart.

Test: Overriding power mode via adb, robotests
Bug: 111450127
Change-Id: Ic681aaf565ce1caf7d00d314e14ae6c4779fe8f6
This commit is contained in:
Salvador Martinez
2018-11-08 11:08:52 -08:00
parent 42e9d26635
commit 108faaf1ce
8 changed files with 350 additions and 2 deletions

View File

@@ -44,6 +44,8 @@ public class RadioButtonPreference extends CheckBoxPreference {
}
private OnClickListener mListener = null;
private View appendix;
private int appendixVisibility = -1;
public RadioButtonPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
@@ -81,6 +83,10 @@ public class RadioButtonPreference extends CheckBoxPreference {
if (summaryContainer != null) {
summaryContainer.setVisibility(
TextUtils.isEmpty(getSummary()) ? View.GONE : View.VISIBLE);
appendix = view.findViewById(R.id.appendix);
if (appendix != null && appendixVisibility != -1) {
appendix.setVisibility(appendixVisibility);
}
}
TextView title = (TextView) view.findViewById(android.R.id.title);
@@ -89,4 +95,11 @@ public class RadioButtonPreference extends CheckBoxPreference {
title.setMaxLines(3);
}
}
public void setAppendixVisibility(int visibility) {
if (appendix != null) {
appendix.setVisibility(visibility);
}
appendixVisibility = visibility;
}
}