Loading res/drawable/ic_check_circle_green_24dp.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#0F9D58" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10 ,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"/> </vector> res/layout/preference_category_no_title.xml 0 → 100644 +27 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Based off frameworks/base/core/res/res/layout/preference_category_material.xml however set height to 0. This will be used in preference category without title in order to remove extra 32dp blank --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+android:id/title" android:layout_width="match_parent" android:layout_height="0dp" android:textAppearance="@android:style/TextAppearance.Material.Body2" android:textColor="?android:attr/colorAccent" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" /> res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -4746,6 +4746,11 @@ <!-- Summary for anomalies, meaning some apps behaving abnormally [CHAR LIMIT=80] --> <string name="battery_abnormal_apps_summary"><xliff:g id="number">%1$d</xliff:g> apps misbehaving</string> <!-- Title for the battery summary tip [CHAR LIMIT=NONE] --> <string name="battery_tip_summary_title">Battery is in good shape</string> <!-- Summary for the battery summary tip [CHAR LIMIT=NONE] --> <string name="battery_tip_summary_summary">Apps are behaving normally</string> <!-- Title for force stop dialog [CHAR LIMIT=30] --> <string name="dialog_stop_title">Stop app?</string> <!-- Message body for force stop dialog [CHAR LIMIT=NONE] --> Loading res/xml/power_usage_summary.xml +3 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,9 @@ android:selectable="true" android:layout="@layout/battery_header"/> <Preference android:key="high_usage" android:icon="@drawable/ic_battery_alert_24dp" android:title="@string/power_high_usage_title"/> <PreferenceCategory android:key="battery_tip" android:layout="@layout/preference_category_no_title"/> <PreferenceCategory android:key="device_usage_list"> Loading src/com/android/settings/fuelgauge/PowerUsageSummary.java +40 −53 Original line number Diff line number Diff line Loading @@ -55,10 +55,9 @@ import com.android.settings.display.BatteryPercentagePreferenceController; import com.android.settings.display.TimeoutPreferenceController; import com.android.settings.fuelgauge.anomaly.Anomaly; import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy; import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment.AnomalyDialogListener; import com.android.settings.fuelgauge.anomaly.AnomalyLoader; import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController; import com.android.settings.fuelgauge.anomaly.AnomalyUtils; import com.android.settings.fuelgauge.batterytip.BatteryTipLoader; import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController; import com.android.settings.fuelgauge.batterytip.tips.BatteryTip; import com.android.settings.overlay.FeatureFactory; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settingslib.core.AbstractPreferenceController; Loading @@ -72,14 +71,15 @@ import java.util.List; * Displays a list of apps and subsystems that consume power, ordered by how much power was * consumed since the last time it was unplugged. */ public class PowerUsageSummary extends PowerUsageBase implements AnomalyDialogListener, OnLongClickListener, OnClickListener { public class PowerUsageSummary extends PowerUsageBase implements OnLongClickListener, OnClickListener, BatteryTipPreferenceController.BatteryTipListener { static final String TAG = "PowerUsageSummary"; private static final boolean DEBUG = false; private static final String KEY_APP_LIST = "app_list"; private static final String KEY_BATTERY_HEADER = "battery_header"; private static final String KEY_BATTERY_TIP = "battery_tip"; private static final String KEY_SHOW_ALL_APPS = "show_all_apps"; private static final String KEY_SCREEN_USAGE = "screen_usage"; Loading @@ -89,12 +89,11 @@ public class PowerUsageSummary extends PowerUsageBase implements private static final String KEY_SCREEN_TIMEOUT = "screen_timeout_battery"; private static final String KEY_AMBIENT_DISPLAY = "ambient_display_battery"; private static final String KEY_BATTERY_SAVER_SUMMARY = "battery_saver_summary"; private static final String KEY_HIGH_USAGE = "high_usage"; @VisibleForTesting static final int ANOMALY_LOADER = 1; static final int BATTERY_INFO_LOADER = 1; @VisibleForTesting static final int BATTERY_INFO_LOADER = 2; static final int BATTERY_TIP_LOADER = 2; private static final int MENU_STATS_TYPE = Menu.FIRST; @VisibleForTesting static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3; Loading Loading @@ -126,36 +125,9 @@ public class PowerUsageSummary extends PowerUsageBase implements @VisibleForTesting BatteryHeaderPreferenceController mBatteryHeaderPreferenceController; private BatteryAppListPreferenceController mBatteryAppListPreferenceController; private AnomalySummaryPreferenceController mAnomalySummaryPreferenceController; private BatteryTipPreferenceController mBatteryTipPreferenceController; private int mStatsType = BatteryStats.STATS_SINCE_CHARGED; private LoaderManager.LoaderCallbacks<List<Anomaly>> mAnomalyLoaderCallbacks = new LoaderManager.LoaderCallbacks<List<Anomaly>>() { @Override public Loader<List<Anomaly>> onCreateLoader(int id, Bundle args) { return new AnomalyLoader(getContext(), mStatsHelper); } @Override public void onLoadFinished(Loader<List<Anomaly>> loader, List<Anomaly> data) { final AnomalyUtils anomalyUtils = AnomalyUtils.getInstance(getContext()); anomalyUtils.logAnomalies(mMetricsFeatureProvider, data, MetricsEvent.FUELGAUGE_POWER_USAGE_SUMMARY); // show high usage preference if possible mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(data); updateAnomalySparseArray(data); mBatteryAppListPreferenceController.refreshAnomalyIcon(mAnomalySparseArray); } @Override public void onLoaderReset(Loader<List<Anomaly>> loader) { } }; @VisibleForTesting LoaderManager.LoaderCallbacks<BatteryInfo> mBatteryInfoLoaderCallbacks = new LoaderManager.LoaderCallbacks<BatteryInfo>() { Loading Loading @@ -217,6 +189,26 @@ public class PowerUsageSummary extends PowerUsageBase implements } }; private LoaderManager.LoaderCallbacks<List<BatteryTip>> mBatteryTipsCallbacks = new LoaderManager.LoaderCallbacks<List<BatteryTip>>() { @Override public Loader<List<BatteryTip>> onCreateLoader(int id, Bundle args) { return new BatteryTipLoader(getContext(), mStatsHelper); } @Override public void onLoadFinished(Loader<List<BatteryTip>> loader, List<BatteryTip> data) { mBatteryTipPreferenceController.updateBatteryTips(data); } @Override public void onLoaderReset(Loader<List<BatteryTip>> loader) { } }; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Loading @@ -229,8 +221,6 @@ public class PowerUsageSummary extends PowerUsageBase implements mLastFullChargePref = (PowerGaugePreference) findPreference( KEY_TIME_SINCE_LAST_FULL_CHARGE); mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.battery_footer_summary); mAnomalySummaryPreferenceController = new AnomalySummaryPreferenceController( (SettingsActivity) getActivity(), this, MetricsEvent.FUELGAUGE_POWER_USAGE_SUMMARY); mBatteryUtils = BatteryUtils.getInstance(getContext()); mAnomalySparseArray = new SparseArray<>(); Loading @@ -251,9 +241,6 @@ public class PowerUsageSummary extends PowerUsageBase implements @Override public boolean onPreferenceTreeClick(Preference preference) { if (mAnomalySummaryPreferenceController.onPreferenceTreeClick(preference)) { return true; } if (KEY_BATTERY_HEADER.equals(preference.getKey())) { performBatteryHeaderClick(); return true; Loading Loading @@ -282,6 +269,9 @@ public class PowerUsageSummary extends PowerUsageBase implements mBatteryAppListPreferenceController = new BatteryAppListPreferenceController(context, KEY_APP_LIST, lifecycle, activity, this); controllers.add(mBatteryAppListPreferenceController); mBatteryTipPreferenceController = new BatteryTipPreferenceController(context, KEY_BATTERY_TIP, this); controllers.add(mBatteryTipPreferenceController); controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS)); controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT)); controllers.add(new BatterySaverController(context, getLifecycle())); Loading Loading @@ -382,7 +372,7 @@ public class PowerUsageSummary extends PowerUsageBase implements return; } restartAnomalyDetectionIfPossible(); restartBatteryTipLoader(); // reload BatteryInfo and updateUI restartBatteryInfoLoader(); Loading @@ -398,10 +388,8 @@ public class PowerUsageSummary extends PowerUsageBase implements } @VisibleForTesting void restartAnomalyDetectionIfPossible() { if (getAnomalyDetectionPolicy().isAnomalyDetectionEnabled()) { getLoaderManager().restartLoader(ANOMALY_LOADER, Bundle.EMPTY, mAnomalyLoaderCallbacks); } void restartBatteryTipLoader() { getLoaderManager().restartLoader(BATTERY_TIP_LOADER, Bundle.EMPTY, mBatteryTipsCallbacks); } @VisibleForTesting Loading Loading @@ -484,11 +472,6 @@ public class PowerUsageSummary extends PowerUsageBase implements } } @Override public void onAnomalyHandled(Anomaly anomaly) { mAnomalySummaryPreferenceController.hideHighUsagePreference(); } @Override public boolean onLongClick(View view) { showBothEstimates(); Loading @@ -513,6 +496,11 @@ public class PowerUsageSummary extends PowerUsageBase implements } } @Override public void onBatteryTipHandled(BatteryTip batteryTip) { restartBatteryTipLoader(); } private static class SummaryProvider implements SummaryLoader.SummaryProvider { private final Context mContext; private final SummaryLoader mLoader; Loading Loading @@ -555,7 +543,6 @@ public class PowerUsageSummary extends PowerUsageBase implements @Override public List<String> getNonIndexableKeys(Context context) { List<String> niks = super.getNonIndexableKeys(context); niks.add(KEY_HIGH_USAGE); niks.add(KEY_BATTERY_SAVER_SUMMARY); // Duplicates in display niks.add(KEY_AUTO_BRIGHTNESS); Loading Loading
res/drawable/ic_check_circle_green_24dp.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#0F9D58" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10 ,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"/> </vector>
res/layout/preference_category_no_title.xml 0 → 100644 +27 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Based off frameworks/base/core/res/res/layout/preference_category_material.xml however set height to 0. This will be used in preference category without title in order to remove extra 32dp blank --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+android:id/title" android:layout_width="match_parent" android:layout_height="0dp" android:textAppearance="@android:style/TextAppearance.Material.Body2" android:textColor="?android:attr/colorAccent" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" />
res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -4746,6 +4746,11 @@ <!-- Summary for anomalies, meaning some apps behaving abnormally [CHAR LIMIT=80] --> <string name="battery_abnormal_apps_summary"><xliff:g id="number">%1$d</xliff:g> apps misbehaving</string> <!-- Title for the battery summary tip [CHAR LIMIT=NONE] --> <string name="battery_tip_summary_title">Battery is in good shape</string> <!-- Summary for the battery summary tip [CHAR LIMIT=NONE] --> <string name="battery_tip_summary_summary">Apps are behaving normally</string> <!-- Title for force stop dialog [CHAR LIMIT=30] --> <string name="dialog_stop_title">Stop app?</string> <!-- Message body for force stop dialog [CHAR LIMIT=NONE] --> Loading
res/xml/power_usage_summary.xml +3 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,9 @@ android:selectable="true" android:layout="@layout/battery_header"/> <Preference android:key="high_usage" android:icon="@drawable/ic_battery_alert_24dp" android:title="@string/power_high_usage_title"/> <PreferenceCategory android:key="battery_tip" android:layout="@layout/preference_category_no_title"/> <PreferenceCategory android:key="device_usage_list"> Loading
src/com/android/settings/fuelgauge/PowerUsageSummary.java +40 −53 Original line number Diff line number Diff line Loading @@ -55,10 +55,9 @@ import com.android.settings.display.BatteryPercentagePreferenceController; import com.android.settings.display.TimeoutPreferenceController; import com.android.settings.fuelgauge.anomaly.Anomaly; import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy; import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment.AnomalyDialogListener; import com.android.settings.fuelgauge.anomaly.AnomalyLoader; import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController; import com.android.settings.fuelgauge.anomaly.AnomalyUtils; import com.android.settings.fuelgauge.batterytip.BatteryTipLoader; import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController; import com.android.settings.fuelgauge.batterytip.tips.BatteryTip; import com.android.settings.overlay.FeatureFactory; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settingslib.core.AbstractPreferenceController; Loading @@ -72,14 +71,15 @@ import java.util.List; * Displays a list of apps and subsystems that consume power, ordered by how much power was * consumed since the last time it was unplugged. */ public class PowerUsageSummary extends PowerUsageBase implements AnomalyDialogListener, OnLongClickListener, OnClickListener { public class PowerUsageSummary extends PowerUsageBase implements OnLongClickListener, OnClickListener, BatteryTipPreferenceController.BatteryTipListener { static final String TAG = "PowerUsageSummary"; private static final boolean DEBUG = false; private static final String KEY_APP_LIST = "app_list"; private static final String KEY_BATTERY_HEADER = "battery_header"; private static final String KEY_BATTERY_TIP = "battery_tip"; private static final String KEY_SHOW_ALL_APPS = "show_all_apps"; private static final String KEY_SCREEN_USAGE = "screen_usage"; Loading @@ -89,12 +89,11 @@ public class PowerUsageSummary extends PowerUsageBase implements private static final String KEY_SCREEN_TIMEOUT = "screen_timeout_battery"; private static final String KEY_AMBIENT_DISPLAY = "ambient_display_battery"; private static final String KEY_BATTERY_SAVER_SUMMARY = "battery_saver_summary"; private static final String KEY_HIGH_USAGE = "high_usage"; @VisibleForTesting static final int ANOMALY_LOADER = 1; static final int BATTERY_INFO_LOADER = 1; @VisibleForTesting static final int BATTERY_INFO_LOADER = 2; static final int BATTERY_TIP_LOADER = 2; private static final int MENU_STATS_TYPE = Menu.FIRST; @VisibleForTesting static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3; Loading Loading @@ -126,36 +125,9 @@ public class PowerUsageSummary extends PowerUsageBase implements @VisibleForTesting BatteryHeaderPreferenceController mBatteryHeaderPreferenceController; private BatteryAppListPreferenceController mBatteryAppListPreferenceController; private AnomalySummaryPreferenceController mAnomalySummaryPreferenceController; private BatteryTipPreferenceController mBatteryTipPreferenceController; private int mStatsType = BatteryStats.STATS_SINCE_CHARGED; private LoaderManager.LoaderCallbacks<List<Anomaly>> mAnomalyLoaderCallbacks = new LoaderManager.LoaderCallbacks<List<Anomaly>>() { @Override public Loader<List<Anomaly>> onCreateLoader(int id, Bundle args) { return new AnomalyLoader(getContext(), mStatsHelper); } @Override public void onLoadFinished(Loader<List<Anomaly>> loader, List<Anomaly> data) { final AnomalyUtils anomalyUtils = AnomalyUtils.getInstance(getContext()); anomalyUtils.logAnomalies(mMetricsFeatureProvider, data, MetricsEvent.FUELGAUGE_POWER_USAGE_SUMMARY); // show high usage preference if possible mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(data); updateAnomalySparseArray(data); mBatteryAppListPreferenceController.refreshAnomalyIcon(mAnomalySparseArray); } @Override public void onLoaderReset(Loader<List<Anomaly>> loader) { } }; @VisibleForTesting LoaderManager.LoaderCallbacks<BatteryInfo> mBatteryInfoLoaderCallbacks = new LoaderManager.LoaderCallbacks<BatteryInfo>() { Loading Loading @@ -217,6 +189,26 @@ public class PowerUsageSummary extends PowerUsageBase implements } }; private LoaderManager.LoaderCallbacks<List<BatteryTip>> mBatteryTipsCallbacks = new LoaderManager.LoaderCallbacks<List<BatteryTip>>() { @Override public Loader<List<BatteryTip>> onCreateLoader(int id, Bundle args) { return new BatteryTipLoader(getContext(), mStatsHelper); } @Override public void onLoadFinished(Loader<List<BatteryTip>> loader, List<BatteryTip> data) { mBatteryTipPreferenceController.updateBatteryTips(data); } @Override public void onLoaderReset(Loader<List<BatteryTip>> loader) { } }; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Loading @@ -229,8 +221,6 @@ public class PowerUsageSummary extends PowerUsageBase implements mLastFullChargePref = (PowerGaugePreference) findPreference( KEY_TIME_SINCE_LAST_FULL_CHARGE); mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.battery_footer_summary); mAnomalySummaryPreferenceController = new AnomalySummaryPreferenceController( (SettingsActivity) getActivity(), this, MetricsEvent.FUELGAUGE_POWER_USAGE_SUMMARY); mBatteryUtils = BatteryUtils.getInstance(getContext()); mAnomalySparseArray = new SparseArray<>(); Loading @@ -251,9 +241,6 @@ public class PowerUsageSummary extends PowerUsageBase implements @Override public boolean onPreferenceTreeClick(Preference preference) { if (mAnomalySummaryPreferenceController.onPreferenceTreeClick(preference)) { return true; } if (KEY_BATTERY_HEADER.equals(preference.getKey())) { performBatteryHeaderClick(); return true; Loading Loading @@ -282,6 +269,9 @@ public class PowerUsageSummary extends PowerUsageBase implements mBatteryAppListPreferenceController = new BatteryAppListPreferenceController(context, KEY_APP_LIST, lifecycle, activity, this); controllers.add(mBatteryAppListPreferenceController); mBatteryTipPreferenceController = new BatteryTipPreferenceController(context, KEY_BATTERY_TIP, this); controllers.add(mBatteryTipPreferenceController); controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS)); controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT)); controllers.add(new BatterySaverController(context, getLifecycle())); Loading Loading @@ -382,7 +372,7 @@ public class PowerUsageSummary extends PowerUsageBase implements return; } restartAnomalyDetectionIfPossible(); restartBatteryTipLoader(); // reload BatteryInfo and updateUI restartBatteryInfoLoader(); Loading @@ -398,10 +388,8 @@ public class PowerUsageSummary extends PowerUsageBase implements } @VisibleForTesting void restartAnomalyDetectionIfPossible() { if (getAnomalyDetectionPolicy().isAnomalyDetectionEnabled()) { getLoaderManager().restartLoader(ANOMALY_LOADER, Bundle.EMPTY, mAnomalyLoaderCallbacks); } void restartBatteryTipLoader() { getLoaderManager().restartLoader(BATTERY_TIP_LOADER, Bundle.EMPTY, mBatteryTipsCallbacks); } @VisibleForTesting Loading Loading @@ -484,11 +472,6 @@ public class PowerUsageSummary extends PowerUsageBase implements } } @Override public void onAnomalyHandled(Anomaly anomaly) { mAnomalySummaryPreferenceController.hideHighUsagePreference(); } @Override public boolean onLongClick(View view) { showBothEstimates(); Loading @@ -513,6 +496,11 @@ public class PowerUsageSummary extends PowerUsageBase implements } } @Override public void onBatteryTipHandled(BatteryTip batteryTip) { restartBatteryTipLoader(); } private static class SummaryProvider implements SummaryLoader.SummaryProvider { private final Context mContext; private final SummaryLoader mLoader; Loading Loading @@ -555,7 +543,6 @@ public class PowerUsageSummary extends PowerUsageBase implements @Override public List<String> getNonIndexableKeys(Context context) { List<String> niks = super.getNonIndexableKeys(context); niks.add(KEY_HIGH_USAGE); niks.add(KEY_BATTERY_SAVER_SUMMARY); // Duplicates in display niks.add(KEY_AUTO_BRIGHTNESS); Loading