Browse files

Auto-dim backlight setting

  • Loading branch information...
1 parent 44f4279 commit 856b4997b3f6f33090943030e6cbee9e8dda8d52 @peteralfonso committed Feb 3, 2012
Showing with 17 additions and 0 deletions.
  1. +2 −0 res/values/strings.xml
  2. +4 −0 res/xml/display_settings.xml
  3. +11 −0 src/com/android/settings/DisplaySettings.java
View
2 res/values/strings.xml
@@ -1610,6 +1610,8 @@
<string name="brightness">Brightness</string>
<!-- Sound & display settings screen, setting option summary to change brightness -->
<string name="brightness_summary">Adjust the brightness of the screen</string>
+ <!-- Sound & display settings screen, auto-dim backlight check box label -->
+ <string name="brightness_auto_dim_title">Auto-dim backlight</string>
<!-- Sound & display settings screen, setting option name to change screen timeout -->
<string name="screen_timeout">Sleep</string>
<!-- Sound & display settings screen, setting option summary to change screen timeout -->
View
4 res/xml/display_settings.xml
@@ -23,6 +23,10 @@
android:title="@string/brightness"
android:dialogTitle="@string/brightness" />
+ <CheckBoxPreference
+ android:key="brightness_auto_dim"
+ android:title="@string/brightness_auto_dim_title"/>
+
<PreferenceScreen
android:key="wallpaper"
android:title="@string/wallpaper_settings_title"
View
11 src/com/android/settings/DisplaySettings.java
@@ -53,6 +53,7 @@
private static final String KEY_FONT_SIZE = "font_size";
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
+ private CheckBoxPreference mBrightnessAutoDim;
private CheckBoxPreference mAccelerometer;
private ListPreference mFontSizePref;
private CheckBoxPreference mNotificationPulse;
@@ -75,6 +76,11 @@ public void onCreate(Bundle savedInstanceState) {
addPreferencesFromResource(R.xml.display_settings);
+ mBrightnessAutoDim = (CheckBoxPreference) findPreference("brightness_auto_dim");
+ mBrightnessAutoDim.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS_AUTO_DIM, 0) == 1);
+ mBrightnessAutoDim.setOnPreferenceChangeListener(this);
+
mAccelerometer = (CheckBoxPreference) findPreference(KEY_ACCELEROMETER);
mAccelerometer.setPersistent(false);
@@ -249,6 +255,11 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
Settings.System.putInt(getContentResolver(), Settings.System.NOTIFICATION_LIGHT_PULSE,
value ? 1 : 0);
return true;
+ } else if (preference == mBrightnessAutoDim) {
+ boolean value = mBrightnessAutoDim.isChecked();
+ Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_AUTO_DIM,
+ value ? 1 : 0);
+ return true;
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}

0 comments on commit 856b499

Please sign in to comment.