summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid van Tonder <david.vantonder@gmail.com>2013-05-28 05:11:31 -0700
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-05-28 05:11:31 -0700
commit7368651cb07ac32f44113e12a501cf81eae080a7 (patch)
tree8fa5f9b397113f3c63065fc304d4486415c6be92 /src
parent0385685271b227ca750a7160162b279ea2887969 (diff)
parentd9607fcf0ffc8747647bc04c2cbe43ea6b7e3f6b (diff)
downloadpackages_apps_settings-7368651cb07ac32f44113e12a501cf81eae080a7.zip
packages_apps_settings-7368651cb07ac32f44113e12a501cf81eae080a7.tar.gz
packages_apps_settings-7368651cb07ac32f44113e12a501cf81eae080a7.tar.bz2
Merge "Allow changing auto-brightness responsitivity." into cm-10.1
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/BrightnessPreference.java48
1 files changed, 48 insertions, 0 deletions
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);
}