Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 063e4bc0 authored by fitsnugly's avatar fitsnugly Committed by Gerrit Code Review
Browse files

lockscreen battery status: add off option (2/2)

Change-Id: Ie10015865f161e783dc394d467e456d51dc9fbbc
parent 08aed043
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -3017,10 +3017,13 @@ public final class Settings {
        public static final String LOCKSCREEN_LONG_MENU_ACTION = "lockscreen_long_menu_action";

         /**
          * Always show the battery status on the lockscreen
          * Lockscreen battery status visibility mode
          * 0 = show if charging
          * 1 = always show
          * 2 = never show
          * @hide
          */
        public static final String LOCKSCREEN_ALWAYS_SHOW_BATTERY = "lockscreen_always_show_battery";
        public static final String LOCKSCREEN_BATTERY_VISIBILITY = "lockscreen_always_show_battery";

        /**
         * Show the pending notification counts as overlays on the status bar
@@ -3362,7 +3365,7 @@ public final class Settings {
            POWER_MENU_SOUND_ENABLED,
            POWER_MENU_USER_ENABLED,
            LOCKSCREEN_VIBRATE_ENABLED,
            LOCKSCREEN_ALWAYS_SHOW_BATTERY,
            LOCKSCREEN_BATTERY_VISIBILITY,
            PHONE_BLACKLIST_ENABLED,
            PHONE_BLACKLIST_NOTIFY_ENABLED,
            PHONE_BLACKLIST_PRIVATE_NUMBER_MODE,
+6 −1
Original line number Diff line number Diff line
@@ -167,7 +167,12 @@ class KeyguardMessageArea extends TextView {
            mBatteryCharged = status.isCharged();
            mBatteryIsLow = status.isBatteryLow();
            mAlwaysShowBattery = KeyguardUpdateMonitor.shouldAlwaysShowBatteryInfo(getContext());
            mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow() || mAlwaysShowBattery;
            if (KeyguardUpdateMonitor.shouldNeverShowBatteryInfo(getContext())) {
                mShowingBatteryInfo = false;
            } else {
                mShowingBatteryInfo = status.isPluggedIn()
                        || status.isBatteryLow() || mAlwaysShowBattery;
            }
            update();
        }
    };
+10 −3
Original line number Diff line number Diff line
@@ -767,7 +767,8 @@ public class KeyguardUpdateMonitor {
        return mSwitchingUser;
    }

    private static boolean isBatteryUpdateInteresting(BatteryStatus old, BatteryStatus current, Context context) {
    private static boolean isBatteryUpdateInteresting(BatteryStatus old,
            BatteryStatus current, Context context) {
        final boolean nowPluggedIn = current.isPluggedIn();
        final boolean wasPluggedIn = old.isPluggedIn();
        final boolean stateChangedWhilePluggedIn =
@@ -785,7 +786,8 @@ public class KeyguardUpdateMonitor {
        }

        // change in battery level while plugged in or always interested
        if ((nowPluggedIn || shouldAlwaysShowBatteryInfo(context) || current.isBatteryLow()) && old.level != current.level) {
        if ((nowPluggedIn || shouldAlwaysShowBatteryInfo(context) || current.isBatteryLow())
                && old.level != current.level) {
            return true;
        }

@@ -794,7 +796,12 @@ public class KeyguardUpdateMonitor {

    public static boolean shouldAlwaysShowBatteryInfo(Context context) {
        return Settings.System.getInt(context.getContentResolver(),
                       Settings.System.LOCKSCREEN_ALWAYS_SHOW_BATTERY, 0) == 1;
                Settings.System.LOCKSCREEN_BATTERY_VISIBILITY, 0) == 1;
    }

    public static boolean shouldNeverShowBatteryInfo(Context context) {
        return Settings.System.getInt(context.getContentResolver(),
                Settings.System.LOCKSCREEN_BATTERY_VISIBILITY, 0) == 2;
    }

    /**