Merge "Make flag "showAllapps" persistent in PowerUsageSummary" into oc-dev
am: 4f02eebab8
Change-Id: Id02583309a3e547855b7ffc69e065c2293fb172e
This commit is contained in:
@@ -79,6 +79,7 @@ public class PowerUsageSummary extends PowerUsageBase {
|
||||
private static final boolean USE_FAKE_DATA = false;
|
||||
private static final String KEY_APP_LIST = "app_list";
|
||||
private static final String KEY_BATTERY_HEADER = "battery_header";
|
||||
private static final String KEY_SHOW_ALL_APPS = "show_all_apps";
|
||||
private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 10;
|
||||
private static final int MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP = 10;
|
||||
|
||||
@@ -131,6 +132,7 @@ public class PowerUsageSummary extends PowerUsageBase {
|
||||
|
||||
mBatteryUtils = BatteryUtils.getInstance(getContext());
|
||||
|
||||
restoreSavedInstance(icicle);
|
||||
initFeatureProvider();
|
||||
}
|
||||
|
||||
@@ -154,6 +156,12 @@ public class PowerUsageSummary extends PowerUsageBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(KEY_SHOW_ALL_APPS, mShowAllApps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
if (KEY_BATTERY_HEADER.equals(preference.getKey())) {
|
||||
@@ -262,6 +270,13 @@ public class PowerUsageSummary extends PowerUsageBase {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void restoreSavedInstance(Bundle savedInstance) {
|
||||
if (savedInstance != null) {
|
||||
mShowAllApps = savedInstance.getBoolean(KEY_SHOW_ALL_APPS, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNotAvailableMessage() {
|
||||
final String NOT_AVAILABLE = "not_available";
|
||||
Preference notAvailable = getCachedPreference(NOT_AVAILABLE);
|
||||
|
Reference in New Issue
Block a user