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

Commit 72e44850 authored by blunden's avatar blunden Committed by nebkat
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

Screenshot: https://dl.dropbox.com/u/50993944/Screenshot_2012-08-03-08-47-10.png

Patchset 1-8: Initial code
Patchset 9  : Minor tweaks

Change-Id: I642da4dcd82a776a74d77031d37acc76f97b25af

Conflicts:
	core/java/android/provider/Settings.java
	policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
	policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
parent 03189712
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2888,6 +2888,12 @@ public final class Settings {
         */
        public static final String LOCKSCREEN_LONG_MENU_ACTION = "lockscreen_long_menu_action";

         /**
          * Always show the battery status on the lockscreen
          * @hide
          */
        public static final String LOCKSCREEN_ALWAYS_SHOW_BATTERY = "lockscreen_always_show_battery";

        /**
         * Show the pending notification counts as overlays on the status bar
         * @hide
@@ -2955,6 +2961,7 @@ public final class Settings {
        public static final String LOCKSCREEN_VIBRATE_ENABLED = "lockscreen.vibrate_enabled";

        /**
         * Show the pending notification counts as overlays on the status bar
         * Whether to enable custom rebindings of the actions performed on
         * certain key press events.
         * @hide
@@ -3118,6 +3125,7 @@ public final class Settings {
            POWER_MENU_SILENT_ENABLED,
            POWER_MENU_USER_ENABLED,
            LOCKSCREEN_VIBRATE_ENABLED,
            LOCKSCREEN_ALWAYS_SHOW_BATTERY,
        };

        // Settings moved to Settings.Secure
+3 −2
Original line number Diff line number Diff line
@@ -2154,6 +2154,7 @@
    <!-- When the lock screen is showing and the phone plugged in, and the battery
         is not fully charged, show the current charge %.  -->
    <string name="lockscreen_plugged_in">Charging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>
    <string name="lockscreen_discharging">Discharging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>
    <!-- When the lock screen is showing, the phone is plugged in and the battery is fully
         charged, say that it is charged. -->
    <string name="lockscreen_charged">Charged</string>
@@ -2161,8 +2162,8 @@
    <string name="lockscreen_battery_short"><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="lockscreen_low_battery">Connect your charger.</string>
         in the phone soon and show current percentage. -->
    <string name="lockscreen_low_battery">Connect your charger, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>

    <!-- Shown in the lock screen when there is no SIM card. -->
    <string name="lockscreen_missing_sim_message_short">No SIM card</string>
+2 −0
Original line number Diff line number Diff line
@@ -1880,5 +1880,7 @@

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

</resources>
+12 −3
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.internal.R;
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;
@@ -47,6 +48,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;

@@ -133,11 +137,12 @@ class KeyguardMessageArea extends TextView {
    private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
        @Override
        public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
            mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow();
            mPluggedIn = status.isPluggedIn();
            mBatteryLevel = status.level;
            mBatteryCharged = status.isCharged();
            mBatteryIsLow = status.isBatteryLow();
            mAlwaysShowBattery = KeyguardUpdateMonitor.shouldAlwaysShowBatteryInfo(getContext());
            mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow() || mAlwaysShowBattery;
            update();
        }
    };
@@ -232,8 +237,12 @@ class KeyguardMessageArea extends TextView {
            } else if (mBatteryIsLow) {
                // Battery is low
                string = getContext().getString(
                        com.android.internal.R.string.lockscreen_low_battery);
                        com.android.internal.R.string.lockscreen_low_battery, mBatteryLevel);
                icon.value = BATTERY_LOW_ICON;
            } else if (mAlwaysShowBattery) {
                // Discharging
                string = getContext().getString(R.string.lockscreen_discharging, mBatteryLevel);
                icon.value = DISCHARGING_ICON;
             }
        }
        return string;
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public class KeyguardStatusView extends GridLayout {
    public static final int LOCK_ICON = 0; // R.drawable.ic_lock_idle_lock;
    public static final int ALARM_ICON = com.android.internal.R.drawable.ic_lock_idle_alarm;
    public static final int CHARGING_ICON = 0; //R.drawable.ic_lock_idle_charging;
    public static final int DISCHARGING_ICON = 0; // no icon used in ics+ currently
    public static final int BATTERY_LOW_ICON = 0; //R.drawable.ic_lock_idle_low_battery;

    private CharSequence mDateFormatString;
Loading