diff options
author | David van Tonder <david.vantonder@gmail.com> | 2012-12-15 13:47:50 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.cyanogenmod.com> | 2012-12-15 13:47:50 -0800 |
commit | c05857807625a1f4d5a1c16a3c4fdaaac8ad07c7 (patch) | |
tree | d18084233bca04e3688aecfbf8d8ee457028ae71 /src | |
parent | 0744a09beed7a39d03f42670c8973229161437cc (diff) | |
parent | 0611cbeba4c9a27685e06536b645ffaf12182f2c (diff) | |
download | packages_apps_settings-c05857807625a1f4d5a1c16a3c4fdaaac8ad07c7.zip packages_apps_settings-c05857807625a1f4d5a1c16a3c4fdaaac8ad07c7.tar.gz packages_apps_settings-c05857807625a1f4d5a1c16a3c4fdaaac8ad07c7.tar.bz2 |
Merge "Settings: Add option to always show battery status on lockscreen (2/2)" into cm-10.1
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/cyanogenmod/LockscreenInterface.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/com/android/settings/cyanogenmod/LockscreenInterface.java b/src/com/android/settings/cyanogenmod/LockscreenInterface.java index 7df8699..63787c5 100644 --- a/src/com/android/settings/cyanogenmod/LockscreenInterface.java +++ b/src/com/android/settings/cyanogenmod/LockscreenInterface.java @@ -16,18 +16,22 @@ package com.android.settings.cyanogenmod; import android.os.Bundle; +import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceScreen; +import android.provider.Settings; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; -public class LockscreenInterface extends SettingsPreferenceFragment { +public class LockscreenInterface extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener { private static final String TAG = "LockscreenInterface"; + private static final String KEY_ALWAYS_BATTERY_PREF = "lockscreen_battery_status"; private static final String KEY_LOCKSCREEN_BUTTONS = "lockscreen_buttons"; private PreferenceScreen mLockscreenButtons; + private ListPreference mBatteryStatus; public boolean hasButtons() { return !getResources().getBoolean(com.android.internal.R.bool.config_showNavigationBar); @@ -39,6 +43,9 @@ public class LockscreenInterface extends SettingsPreferenceFragment { addPreferencesFromResource(R.xml.lockscreen_interface_settings); + mBatteryStatus = (ListPreference) findPreference(KEY_ALWAYS_BATTERY_PREF); + mBatteryStatus.setOnPreferenceChangeListener(this); + mLockscreenButtons = (PreferenceScreen) findPreference(KEY_LOCKSCREEN_BUTTONS); if (!hasButtons()) { getPreferenceScreen().removePreference(mLockscreenButtons); @@ -53,10 +60,31 @@ public class LockscreenInterface extends SettingsPreferenceFragment { @Override public void onPause() { super.onPause(); + + // Set the battery status description text + if (mBatteryStatus != null) { + int batteryStatus = Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(), + Settings.System.LOCKSCREEN_ALWAYS_SHOW_BATTERY, 0); + mBatteryStatus.setValueIndex(batteryStatus); + mBatteryStatus.setSummary(mBatteryStatus.getEntries()[batteryStatus]); + } } @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { return super.onPreferenceTreeClick(preferenceScreen, preference); } + + @Override + public boolean onPreferenceChange(Preference preference, Object objValue) { + if (preference == mBatteryStatus) { + int value = Integer.valueOf((String) objValue); + int index = mBatteryStatus.findIndexOfValue((String) objValue); + Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(), + Settings.System.LOCKSCREEN_ALWAYS_SHOW_BATTERY, value); + mBatteryStatus.setSummary(mBatteryStatus.getEntries()[index]); + return true; + } + return false; + } } |