summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/preference_dialog_brightness.xml15
-rw-r--r--res/values/cm_arrays.xml17
-rw-r--r--res/values/cm_strings.xml7
-rw-r--r--src/com/android/settings/BrightnessPreference.java48
4 files changed, 87 insertions, 0 deletions
diff --git a/res/layout/preference_dialog_brightness.xml b/res/layout/preference_dialog_brightness.xml
index b3d62cb..4e93258 100644
--- a/res/layout/preference_dialog_brightness.xml
+++ b/res/layout/preference_dialog_brightness.xml
@@ -48,5 +48,20 @@
android:layout_height="wrap_content"
android:padding="20dip" />
+ <TextView android:id="@+id/automatic_sensitivity_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dip"
+ android:layout_marginLeft="12dip"
+ android:layout_marginRight="20dip"
+ android:text="@string/auto_brightness_sensitivity_title" />
+
+ <Spinner android:id="@+id/automatic_sensitivity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="4dip"
+ android:layout_marginLeft="20dip"
+ android:layout_marginRight="20dip" />
+
</LinearLayout>
</ScrollView>
diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml
index 2bd764c..13b8ff0 100644
--- a/res/values/cm_arrays.xml
+++ b/res/values/cm_arrays.xml
@@ -543,5 +543,22 @@
<item>1004</item>
<item>1005</item>
</string-array>
+
+ <!-- Auto-brightness sensitivity -->
+ <string-array name="auto_brightness_sensitivity_entries" translatable="false">
+ <item>@string/auto_brightness_sensitivity_verylow</item>
+ <item>@string/auto_brightness_sensitivity_low</item>
+ <item>@string/auto_brightness_sensitivity_medium</item>
+ <item>@string/auto_brightness_sensitivity_high</item>
+ <item>@string/auto_brightness_sensitivity_veryhigh</item>
+ </string-array>
+
+ <integer-array name="auto_brightness_sensitivity_values">
+ <item>150</item>
+ <item>125</item>
+ <item>100</item>
+ <item>50</item>
+ <item>25</item>
+ </integer-array>
</resources>
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 3b18fb0..7c6949e 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -843,6 +843,13 @@ desired screen brightness. Selecting \'Split\' allows you to to duplicate one li
two in order to insert additional control points. \'Remove\' deletes the selected line.
</string>
+ <string name="auto_brightness_sensitivity_title">Adjustment sensitivity</string>
+ <string name="auto_brightness_sensitivity_verylow">Very low</string>
+ <string name="auto_brightness_sensitivity_low">Low</string>
+ <string name="auto_brightness_sensitivity_medium">Medium</string>
+ <string name="auto_brightness_sensitivity_high">High</string>
+ <string name="auto_brightness_sensitivity_veryhigh">Very high</string>
+
<!-- Advanced reboot options -->
<string name="advanced_reboot_title">Advanced reboot</string>
<string name="advanced_reboot_summary">When unlocked, include options in the power menu for rebooting into recovery or bootloader</string>
diff --git a/src/com/android/settings/BrightnessPreference.java b/src/com/android/settings/BrightnessPreference.java
index 42e307f..a7c4024 100644
--- a/src/com/android/settings/BrightnessPreference.java
+++ b/src/com/android/settings/BrightnessPreference.java
@@ -35,10 +35,13 @@ import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.util.AttributeSet;
import android.view.View;
+import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.SeekBar;
+import android.widget.Spinner;
+import android.widget.TextView;
import com.android.settings.cyanogenmod.AutoBrightnessCustomizeDialog;
@@ -53,6 +56,8 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
private SeekBar mSeekBar;
private CheckBox mCheckBox;
+ private TextView mAutoSensitivityTitle;
+ private Spinner mAutoSensitivity;
private int mOldBrightness;
private int mOldAutomatic;
@@ -148,15 +153,41 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
mSeekBar.setProgress(mOldBrightness);
mCheckBox = (CheckBox)view.findViewById(R.id.automatic_mode);
+ mAutoSensitivityTitle = (TextView) view.findViewById(R.id.automatic_sensitivity_title);
+ mAutoSensitivity = (Spinner) view.findViewById(R.id.automatic_sensitivity);
+
if (mAutomaticAvailable) {
mCheckBox.setOnCheckedChangeListener(this);
mOldAutomatic = getBrightnessMode(0);
mAutomaticMode = mOldAutomatic == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
mCheckBox.setChecked(mAutomaticMode);
mSeekBar.setEnabled(!mAutomaticMode || USE_SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT);
+ mAutoSensitivityTitle.setEnabled(mAutomaticMode);
+ mAutoSensitivity.setEnabled(mAutomaticMode);
+
+ ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(),
+ R.array.auto_brightness_sensitivity_entries,
+ android.R.layout.simple_spinner_item);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mAutoSensitivity.setAdapter(adapter);
+
+ float currentSensitivity = Settings.System.getFloat(getContext().getContentResolver(),
+ Settings.System.AUTO_BRIGHTNESS_RESPONSIVENESS, 1.0f);
+ int currentSensitivityInt = (int) (currentSensitivity * 100);
+ int[] sensitivityValues = getContext().getResources().getIntArray(
+ R.array.auto_brightness_sensitivity_values);
+
+ for (int i = 0; i < sensitivityValues.length; i++) {
+ if (sensitivityValues[i] == currentSensitivityInt) {
+ mAutoSensitivity.setSelection(i);
+ break;
+ }
+ }
} else {
mCheckBox.setEnabled(false);
mSeekBar.setEnabled(true);
+ mAutoSensitivityTitle.setVisibility(View.GONE);
+ mAutoSensitivity.setVisibility(View.GONE);
}
mSeekBar.setOnSeekBarChangeListener(this);
}
@@ -179,6 +210,8 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
: Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
mSeekBar.setProgress(getBrightness());
mSeekBar.setEnabled(!mAutomaticMode || USE_SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT);
+ mAutoSensitivityTitle.setEnabled(mAutomaticMode);
+ mAutoSensitivity.setEnabled(mAutomaticMode);
setBrightness(mSeekBar.getProgress(), false);
updateAutoBrightnessCustomizeButton();
}
@@ -242,6 +275,16 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
if (positiveResult) {
setBrightness(mSeekBar.getProgress(), true);
+
+ int selection = mAutoSensitivity.getSelectedItemPosition();
+ if (selection >= 0) {
+ int[] sensitivityValues = getContext().getResources().getIntArray(
+ R.array.auto_brightness_sensitivity_values);
+ float sensitivity = 0.01f * sensitivityValues[selection];
+
+ Settings.System.putFloat(resolver,
+ Settings.System.AUTO_BRIGHTNESS_RESPONSIVENESS, sensitivity);
+ }
} else {
restoreOldState();
}
@@ -339,6 +382,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
myState.oldAutomatic = mOldAutomatic == 1;
myState.oldProgress = mOldBrightness;
myState.curBrightness = mCurBrightness;
+ myState.autoSensitivitySelection = mAutoSensitivity.getSelectedItemPosition();
myState.customizeDialogShown = mCustomizeDialog != null && mCustomizeDialog.isShowing();
if (myState.customizeDialogShown) {
myState.customizeDialogState = mCustomizeDialog.onSaveInstanceState();
@@ -364,6 +408,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
setMode(myState.automatic ? 1 : 0);
setBrightness(myState.progress, false);
mCurBrightness = myState.curBrightness;
+ mAutoSensitivity.setSelection(myState.autoSensitivitySelection);
if (myState.customizeDialogShown) {
showCustomizeDialog(myState.customizeDialogState);
@@ -377,6 +422,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
int progress;
int oldProgress;
int curBrightness;
+ int autoSensitivitySelection;
boolean customizeDialogShown;
Bundle customizeDialogState;
@@ -387,6 +433,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
oldAutomatic = source.readInt() == 1;
oldProgress = source.readInt();
curBrightness = source.readInt();
+ autoSensitivitySelection = source.readInt();
customizeDialogShown = source.readInt() == 1;
customizeDialogState = source.readBundle();
}
@@ -399,6 +446,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
dest.writeInt(oldAutomatic ? 1 : 0);
dest.writeInt(oldProgress);
dest.writeInt(curBrightness);
+ dest.writeInt(autoSensitivitySelection);
dest.writeInt(customizeDialogShown ? 1 : 0);
dest.writeBundle(customizeDialogState);
}