diff options
author | László Dávid <laszlo.david@gmail.com> | 2012-12-16 22:51:08 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.cyanogenmod.com> | 2012-12-16 14:42:59 -0800 |
commit | 28d7594b866e3cd13aea9b570b0a4f9976c9cf8c (patch) | |
tree | bb477cb89612dfd68a01a13c45a83a45ea23fba5 | |
parent | 4a302bea831a03247e55a326726d5d728150a6bf (diff) | |
download | packages_apps_settings-28d7594b866e3cd13aea9b570b0a4f9976c9cf8c.zip packages_apps_settings-28d7594b866e3cd13aea9b570b0a4f9976c9cf8c.tar.gz packages_apps_settings-28d7594b866e3cd13aea9b570b0a4f9976c9cf8c.tar.bz2 |
Status bar brightness control from CM10 (2/2)
Change-Id: I0b2765e0d66c9ac4f205d47677422bd86c7f49ba
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | res/xml/status_bar.xml | 6 | ||||
-rw-r--r-- | src/com/android/settings/cyanogenmod/StatusBar.java | 24 |
3 files changed, 33 insertions, 0 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 46b04c9..4848268 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4952,6 +4952,9 @@ <string name="status_bar_am_pm_title">AM/PM style</string> <string name="status_bar_am_pm_info">24-hour clock is enabled</string> <string name="status_bar_battery_title">Battery status style</string> + <string name="status_bar_toggle_brightness">Brightness control</string> + <string name="status_bar_toggle_brightness_summary">Adjust brightness by sliding across status bar</string> + <string name="status_bar_toggle_info">Automatic brightness is enabled</string> <string name="status_bar_signal_text_title">Signal status style</string> <string name="status_bar_style_icon">Icon</string> <string name="status_bar_style_hidden">Hidden</string> diff --git a/res/xml/status_bar.xml b/res/xml/status_bar.xml index 28d8a89..b996c6f 100644 --- a/res/xml/status_bar.xml +++ b/res/xml/status_bar.xml @@ -55,6 +55,12 @@ android:entryValues="@array/values_status_bar_signal" /> <CheckBoxPreference + android:key="status_bar_brightness_control" + android:title="@string/status_bar_toggle_brightness" + android:summary="@string/status_bar_toggle_brightness_summary" + android:defaultValue="false" /> + + <CheckBoxPreference android:key="status_bar_notif_count" android:title="@string/status_bar_notif_count_title" android:summary="@string/status_bar_notif_count_summary" diff --git a/src/com/android/settings/cyanogenmod/StatusBar.java b/src/com/android/settings/cyanogenmod/StatusBar.java index 6de2ccb..6c10d13 100644 --- a/src/com/android/settings/cyanogenmod/StatusBar.java +++ b/src/com/android/settings/cyanogenmod/StatusBar.java @@ -36,6 +36,7 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc private static final String STATUS_BAR_AM_PM = "status_bar_am_pm"; private static final String STATUS_BAR_BATTERY = "status_bar_battery"; private static final String STATUS_BAR_CLOCK = "status_bar_show_clock"; + private static final String STATUS_BAR_BRIGHTNESS_CONTROL = "status_bar_brightness_control"; private static final String STATUS_BAR_SIGNAL = "status_bar_signal"; private static final String STATUS_BAR_NOTIF_COUNT = "status_bar_notif_count"; private static final String STATUS_BAR_CATEGORY_GENERAL = "status_bar_general"; @@ -44,6 +45,7 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc private ListPreference mStatusBarBattery; private ListPreference mStatusBarCmSignal; private CheckBoxPreference mStatusBarClock; + private CheckBoxPreference mStatusBarBrightnessControl; private CheckBoxPreference mStatusBarNotifCount; private PreferenceCategory mPrefCategoryGeneral; @@ -56,12 +58,24 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc PreferenceScreen prefSet = getPreferenceScreen(); mStatusBarClock = (CheckBoxPreference) prefSet.findPreference(STATUS_BAR_CLOCK); + mStatusBarBrightnessControl = (CheckBoxPreference) prefSet.findPreference(STATUS_BAR_BRIGHTNESS_CONTROL); mStatusBarAmPm = (ListPreference) prefSet.findPreference(STATUS_BAR_AM_PM); mStatusBarBattery = (ListPreference) prefSet.findPreference(STATUS_BAR_BATTERY); mStatusBarCmSignal = (ListPreference) prefSet.findPreference(STATUS_BAR_SIGNAL); mStatusBarClock.setChecked((Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(), Settings.System.STATUS_BAR_CLOCK, 1) == 1)); + mStatusBarBrightnessControl.setChecked((Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(), + Settings.System.STATUS_BAR_BRIGHTNESS_CONTROL, 0) == 1)); + + try { + if (Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(), + Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) { + mStatusBarBrightnessControl.setEnabled(false); + mStatusBarBrightnessControl.setSummary(R.string.status_bar_toggle_info); + } + } catch (SettingNotFoundException e) { + } try { if (Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(), @@ -99,6 +113,11 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc if (Utils.isWifiOnly(getActivity())) { mPrefCategoryGeneral.removePreference(mStatusBarCmSignal); } + + if (Utils.isTablet(getActivity())) { + mPrefCategoryGeneral.removePreference(mStatusBarBrightnessControl); + } + } public boolean onPreferenceChange(Preference preference, Object newValue) { @@ -135,6 +154,11 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(), Settings.System.STATUS_BAR_CLOCK, value ? 1 : 0); return true; + } else if (preference == mStatusBarBrightnessControl) { + value = mStatusBarBrightnessControl.isChecked(); + Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(), + Settings.System.STATUS_BAR_BRIGHTNESS_CONTROL, value ? 1 : 0); + return true; } else if (preference == mStatusBarNotifCount) { value = mStatusBarNotifCount.isChecked(); Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(), |