summaryrefslogtreecommitdiffstats
path: root/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java
diff options
context:
space:
mode:
Diffstat (limited to 'GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java')
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java69
1 files changed, 65 insertions, 4 deletions
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java b/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java
index bfbc62e..839a02b 100644
--- a/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java
@@ -23,14 +23,17 @@ import android.preference.DialogPreference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.view.View;
+import android.view.View.OnClickListener;
import android.widget.SeekBar;
import android.widget.TextView;
+import android.widget.Button;
+import android.util.Log;
/**
* Special preference type that allows configuration of both the ring volume and
* notification volume.
*/
-public class GammaTuningPreference extends DialogPreference {
+public class GammaTuningPreference extends DialogPreference implements OnClickListener {
private static final String TAG = "GAMMA...";
@@ -54,9 +57,9 @@ public class GammaTuningPreference extends DialogPreference {
private GammaSeekBar mSeekBars[] = new GammaSeekBar[3];
- private static final int MAX_VALUE = 80;
+ private static final int MAX_VALUE = 200;
- private static final int OFFSET_VALUE = 0;
+ private static final int OFFSET_VALUE = 100;
// Track instances to know when to restore original color
// (when the orientation changes, a new dialog is created before the old one
@@ -80,6 +83,16 @@ public class GammaTuningPreference extends DialogPreference {
TextView valueDisplay = (TextView) view.findViewById(VALUE_DISPLAY_ID[i]);
mSeekBars[i] = new GammaSeekBar(seekBar, valueDisplay, FILE_PATH[i]);
}
+ SetupButtonClickListeners(view);
+ }
+
+ private void SetupButtonClickListeners(View view) {
+ Button mDefaultButton = (Button)view.findViewById(R.id.btnGammaDefault);
+ Button mCMButton = (Button)view.findViewById(R.id.btnGammaCM);
+ Button mBrightButton = (Button)view.findViewById(R.id.btnGammaBright);
+ mDefaultButton.setOnClickListener(this);
+ mCMButton.setOnClickListener(this);
+ mBrightButton.setOnClickListener(this);
}
@Override
@@ -110,10 +123,21 @@ public class GammaTuningPreference extends DialogPreference {
}
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ Boolean bFirstTime = sharedPrefs.getBoolean("FirstTimeGamma", true);
for (String filePath : FILE_PATH) {
String sDefaultValue = Utils.readOneLine(filePath);
int iValue = sharedPrefs.getInt(filePath, Integer.valueOf(sDefaultValue));
- Utils.writeValue(filePath, String.valueOf((long) iValue));
+ if (bFirstTime)
+ Utils.writeValue(filePath, "0");
+ else
+ Utils.writeValue(filePath, String.valueOf((long) iValue));
+ }
+ if (bFirstTime)
+ {
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.putBoolean("FirstTimeGamma", false);
+ editor.commit();
}
}
@@ -206,6 +230,43 @@ public class GammaTuningPreference extends DialogPreference {
mValueDisplay.setText(String.format("%d", (int) progress));
}
+ public void SetNewValue(int iValue) {
+ mOriginal = iValue;
+ reset();
+ }
+
+ }
+
+ public void onClick(View v) {
+ switch(v.getId()){
+ case R.id.btnGammaDefault:
+ SetDefaultSettings();
+ break;
+ case R.id.btnGammaCM:
+ SetCMSettings();
+ break;
+ case R.id.btnGammaBright:
+ SetSBrightSettings();
+ break;
+ }
+ }
+
+ private void SetCMSettings() {
+ mSeekBars[0].SetNewValue(-15);
+ mSeekBars[1].SetNewValue(15);
+ mSeekBars[2].SetNewValue(-10);
+ }
+
+ private void SetSBrightSettings() {
+ mSeekBars[0].SetNewValue(6);
+ mSeekBars[1].SetNewValue(25);
+ mSeekBars[2].SetNewValue(7);
+ }
+
+ private void SetDefaultSettings() {
+ mSeekBars[0].SetNewValue(0);
+ mSeekBars[1].SetNewValue(0);
+ mSeekBars[2].SetNewValue(0);
}
}