OSDN Git Service

Fix "auto battery saver" confirmation dialog button layout
authorMakoto Onuki <omakoto@google.com>
Tue, 3 Apr 2018 18:46:02 +0000 (11:46 -0700)
committerMakoto Onuki <omakoto@google.com>
Tue, 3 Apr 2018 18:50:44 +0000 (11:50 -0700)
Bug: 77225862
Fixes: 77225862
Test: Manual test after resetting the BS states with the following commands:
adb shell settings delete global low_power
adb shell settings delete global low_power_sticky
adb shell settings delete global low_power_trigger_level
adb shell settings delete secure low_power_manual_activation_count
adb shell settings delete secure low_power_warning_acknowledged
adb shell settings delete secure suppress_auto_battery_saver

Change-Id: I2d826b1dadd3f2e2bf22746e874534d483f2cc39

packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java

index 49b00ce..3c9dae0 100644 (file)
@@ -483,16 +483,24 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
         d.setMessage(mContext.getString(R.string.auto_saver_enabled_text,
                 getLowBatteryAutoTriggerDefaultLevel()));
 
-        // Negative == "got it". Just close the dialog. Battery saver has already been enabled.
-        d.setNegativeButton(R.string.auto_saver_okay_action, null);
-        d.setPositiveButton(R.string.open_saver_setting_action, (dialog, which) ->
-                mContext.startActivity(actionBatterySaverSetting));
+        // "Got it". Just close the dialog. Automatic battery has been enabled already.
+        d.setPositiveButton(R.string.auto_saver_okay_action,
+                (dialog, which) -> onAutoSaverEnabledConfirmationClosed());
+
+        // "Settings" -> Opens the battery saver settings activity.
+        d.setNeutralButton(R.string.open_saver_setting_action, (dialog, which) -> {
+            mContext.startActivity(actionBatterySaverSetting);
+            onAutoSaverEnabledConfirmationClosed();
+        });
         d.setShowForAllUsers(true);
-        d.setOnDismissListener((dialog) -> mSaverEnabledConfirmation = null);
+        d.setOnDismissListener((dialog) -> onAutoSaverEnabledConfirmationClosed());
         d.show();
         mSaverEnabledConfirmation = d;
     }
 
+    private void onAutoSaverEnabledConfirmationClosed() {
+        mSaverEnabledConfirmation = null;
+    }
 
     private void setSaverMode(boolean mode, boolean needFirstTimeWarning) {
         BatterySaverUtils.setPowerSaveMode(mContext, mode, needFirstTimeWarning);
index 378dad7..6a8d3a5 100644 (file)
@@ -69,6 +69,10 @@ public class SystemUIDialog extends AlertDialog {
         setButton(BUTTON_NEGATIVE, mContext.getString(resId), onClick);
     }
 
+    public void setNeutralButton(int resId, OnClickListener onClick) {
+        setButton(BUTTON_NEUTRAL, mContext.getString(resId), onClick);
+    }
+
     public static void setShowForAllUsers(Dialog dialog, boolean show) {
         if (show) {
             dialog.getWindow().getAttributes().privateFlags |=