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

Commit 1db8a06b authored by blunden's avatar blunden Committed by Michael Bestas
Browse files

Framework: Add option to always show battery status on lockscreen (1/2)

Based on the feature by burnsra in CM7
Authored by Blunden
Tweaked by DvTonder
Change-Id: I642da4dcd82a776a74d77031d37acc76f97b25af

lockscreen battery status: add off option (2/2)
Change-Id: Ie10015865f161e783dc394d467e456d51dc9fbbc
parent 97e968c8
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2629,6 +2629,15 @@ public final class Settings {
         */
        public static final String LOCKSCREEN_TARGETS = "lockscreen_targets";

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

        /**
         * @deprecated Use {@link android.provider.Settings.Global#LOW_BATTERY_SOUND}
         * instead
@@ -3497,6 +3506,7 @@ public final class Settings {
            POWER_MENU_SOUND_ENABLED,
            POWER_MENU_USER_ENABLED,
            LOCKSCREEN_VIBRATE_ENABLED,
            LOCKSCREEN_BATTERY_VISIBILITY,
            PHONE_BLACKLIST_ENABLED,
            PHONE_BLACKLIST_NOTIFY_ENABLED,
            PHONE_BLACKLIST_PRIVATE_NUMBER_MODE,
+3 −0
Original line number Diff line number Diff line
@@ -1947,4 +1947,7 @@
  <java-symbol type="string" name="symbol_picker_z" />
  <java-symbol type="string" name="symbol_picker_Z" />

  <!-- Lock screen always show battery -->
  <java-symbol type="string" name="lockscreen_discharging" />

</resources>
+19 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2014 The CyanogenMod 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.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="keyguard_discharging">Discharging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>
</resources>
+2 −2
Original line number Diff line number Diff line
@@ -61,8 +61,8 @@
    <string name="keyguard_plugged_in">Charging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>

    <!-- When the lock screen is showing and the battery is low, warn user to plug
         in the phone soon. -->
    <string name="keyguard_low_battery">Connect your charger.</string>
         in the phone soon and show current percentage. -->
    <string name="keyguard_low_battery">Connect your charger, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>

    <!-- On the keyguard screen, when pattern lock is disabled, only tell them to press menu to unlock.  This is shown in small font at the bottom. -->
    <string name="keyguard_instructions_when_pattern_disabled">Press Menu to unlock.</string>
+16 −2
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ class KeyguardMessageArea extends TextView {

    static final int CHARGING_ICON = 0; //R.drawable.ic_lock_idle_charging;
    static final int BATTERY_LOW_ICON = 0; //R.drawable.ic_lock_idle_low_battery;
    static final int DISCHARGING_ICON = 0; // no icon used in ics+ currently

    static final int SECURITY_MESSAGE_DURATION = 5000;
    protected static final int FADE_DURATION = 750;
@@ -66,6 +67,9 @@ class KeyguardMessageArea extends TextView {
    // are we showing battery information?
    boolean mShowingBatteryInfo = false;

    // always show battery status?
    boolean mAlwaysShowBattery = false;

    // is the bouncer up?
    boolean mShowingBouncer = false;

@@ -155,12 +159,18 @@ class KeyguardMessageArea extends TextView {
    private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
        @Override
        public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
            mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow();
            mCharging = status.status == BatteryManager.BATTERY_STATUS_CHARGING
                     || status.status == BatteryManager.BATTERY_STATUS_FULL;
            mBatteryLevel = status.level;
            mBatteryCharged = status.isCharged();
            mBatteryIsLow = status.isBatteryLow();
            mAlwaysShowBattery = KeyguardUpdateMonitor.shouldAlwaysShowBatteryInfo(getContext());
            if (KeyguardUpdateMonitor.shouldNeverShowBatteryInfo(getContext())) {
                mShowingBatteryInfo = false;
            } else {
                mShowingBatteryInfo = status.isPluggedIn()
                        || status.isBatteryLow() || mAlwaysShowBattery;
            }
            update();
        }
        public void onScreenTurnedOff(int why) {
@@ -267,8 +277,12 @@ class KeyguardMessageArea extends TextView {
                icon.value = CHARGING_ICON;
            } else if (mBatteryIsLow) {
                // Battery is low
                string = getContext().getString(R.string.keyguard_low_battery);
                string = getContext().getString(R.string.keyguard_low_battery, mBatteryLevel);
                icon.value = BATTERY_LOW_ICON;
            } else if (mAlwaysShowBattery) {
                // Discharging
                string = getContext().getString(R.string.keyguard_discharging, mBatteryLevel);
                icon.value = DISCHARGING_ICON;
            }
        }
        return string;
Loading