summaryrefslogtreecommitdiffstats
path: root/AriesParts/src
diff options
context:
space:
mode:
authorjt1134 <jt1134@gmail.com>2012-11-11 03:07:34 -0600
committerPawit Pornkitprasan <p.pawit@gmail.com>2012-11-16 18:11:09 +0700
commit66786a5173bc24dc596733617b34726a5b0cf031 (patch)
treeb7c9b9f62bdd7d1d6a7f717fcc6e517d504296d2 /AriesParts/src
parent3e961fd8a5bb65414ba8013aedb4e8552da8fe5d (diff)
downloaddevice_samsung_aries-common-66786a5173bc24dc596733617b34726a5b0cf031.zip
device_samsung_aries-common-66786a5173bc24dc596733617b34726a5b0cf031.tar.gz
device_samsung_aries-common-66786a5173bc24dc596733617b34726a5b0cf031.tar.bz2
AriesParts: add a reset button for all seekbar preferences
Change-Id: Ie554b1a1b2e0a6e907843882c978bfeae075eaff
Diffstat (limited to 'AriesParts/src')
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java37
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java11
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/VolumeBoostPreference.java31
3 files changed, 77 insertions, 2 deletions
diff --git a/AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java b/AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java
index 390c5a2..6c72906 100644
--- a/AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java
+++ b/AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java
@@ -7,6 +7,8 @@ import android.preference.DialogPreference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
@@ -14,7 +16,7 @@ import android.widget.TextView;
* Special preference type that allows configuration of both the ring volume and
* notification volume.
*/
-public class ColorTuningPreference extends DialogPreference {
+public class ColorTuningPreference extends DialogPreference implements OnClickListener {
enum Colors {
RED,
@@ -92,6 +94,13 @@ public class ColorTuningPreference extends DialogPreference {
TextView valueDisplay = (TextView) view.findViewById(GAMMA_VALUE_DISPLAY_ID[i]);
mSeekBars[SEEKBAR_ID.length + i] = new GammaSeekBar(seekBar, valueDisplay, GAMMA_FILE_PATH[i]);
}
+
+ SetupButtonClickListener(view);
+ }
+
+ private void SetupButtonClickListener(View view) {
+ Button mResetButton = (Button)view.findViewById(R.id.color_reset);
+ mResetButton.setOnClickListener(this);
}
@Override
@@ -208,6 +217,12 @@ public class ColorTuningPreference extends DialogPreference {
mValueDisplay.setText(String.format("%.3f", (double) progress / MAX_VALUE));
}
+ public void resetDefault(String path, int value) {
+ mSeekBar.setProgress(value);
+ updateValue(value);
+ Utils.writeColor(path, value);
+ }
+
}
class GammaSeekBar extends ColorSeekBar {
@@ -238,5 +253,25 @@ public class ColorTuningPreference extends DialogPreference {
mValueDisplay.setText("-" + progress);
}
+ public void resetDefault(String path, int value) {
+ mSeekBar.setProgress(value);
+ updateValue(value);
+ Utils.writeGamma(path, value);
+ }
+
}
+
+ public void onClick(View v) {
+ switch(v.getId()) {
+ case R.id.color_reset:
+ for (int i = 0; i < SEEKBAR_ID.length; i++) {
+ mSeekBars[i].resetDefault(FILE_PATH[i], MAX_VALUE);
+ }
+ for (int i = 0; i < GAMMA_SEEKBAR_ID.length; i++) {
+ mSeekBars[SEEKBAR_ID.length + i].resetDefault(GAMMA_FILE_PATH[i], GAMMA_DEFAULT_VALUE);
+ }
+ break;
+ }
+ }
+
}
diff --git a/AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java b/AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java
index 1c5f204..1799ab4 100644
--- a/AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java
+++ b/AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java
@@ -51,6 +51,9 @@ public class VibrationPreference extends DialogPreference implements OnClickList
private void SetupButtonClickListener(View view) {
Button mTestButton = (Button)view.findViewById(R.id.vibration_test);
mTestButton.setOnClickListener(this);
+
+ Button mResetButton = (Button)view.findViewById(R.id.vibration_reset);
+ mResetButton.setOnClickListener(this);
}
@Override
@@ -142,6 +145,11 @@ public class VibrationPreference extends DialogPreference implements OnClickList
mValueDisplay.setText(String.valueOf(progress) + "%");
}
+ public void resetDefault() {
+ mSeekBar.setProgress(MAX_VALUE);
+ updateValue(MAX_VALUE);
+ Utils.writeValue(FILE_PATH, String.valueOf(MAX_VALUE));
+ }
}
public void onClick(View v) {
@@ -149,6 +157,9 @@ public class VibrationPreference extends DialogPreference implements OnClickList
case R.id.vibration_test:
testVibration();
break;
+ case R.id.vibration_reset:
+ mSeekBar.resetDefault();
+ break;
}
}
diff --git a/AriesParts/src/com/cyanogenmod/settings/device/VolumeBoostPreference.java b/AriesParts/src/com/cyanogenmod/settings/device/VolumeBoostPreference.java
index f168314..c048132 100644
--- a/AriesParts/src/com/cyanogenmod/settings/device/VolumeBoostPreference.java
+++ b/AriesParts/src/com/cyanogenmod/settings/device/VolumeBoostPreference.java
@@ -7,6 +7,8 @@ import android.preference.DialogPreference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
@@ -14,7 +16,7 @@ import android.widget.TextView;
* Special preference type that allows configuration of both the in call volume and
* in call mic gain.
*/
-public class VolumeBoostPreference extends DialogPreference {
+public class VolumeBoostPreference extends DialogPreference implements OnClickListener {
private static final int[] SEEKBAR_ID = new int[] {
R.id.boost_rcv_seekbar,
@@ -93,6 +95,13 @@ public class VolumeBoostPreference extends DialogPreference {
TextView valueDisplay = (TextView) view.findViewById(MIC_VALUE_DISPLAY_ID[i]);
mSeekBars[SEEKBAR_ID.length + i] = new MicSeekBar(seekBar, valueDisplay, MIC_FILE_PATH[i]);
}
+
+ SetupButtonClickListener(view);
+ }
+
+ private void SetupButtonClickListener(View view) {
+ Button mResetButton = (Button)view.findViewById(R.id.volume_reset);
+ mResetButton.setOnClickListener(this);
}
@Override
@@ -211,6 +220,12 @@ public class VolumeBoostPreference extends DialogPreference {
mValueDisplay.setText(String.valueOf(progress));
}
+ public void resetDefault(String path, int value) {
+ mSeekBar.setProgress(value);
+ updateValue(value);
+ Utils.writeValue(path, String.valueOf(value));
+ }
+
}
class MicSeekBar extends VolumeSeekBar {
@@ -242,4 +257,18 @@ public class VolumeBoostPreference extends DialogPreference {
}
}
+
+ public void onClick(View v) {
+ switch(v.getId()) {
+ case R.id.volume_reset:
+ for (int i = 0; i < BOOST_FILE_PATH.length; i++) {
+ mSeekBars[i].resetDefault(BOOST_FILE_PATH[i], BOOST_DEFAULT_VALUE);
+ }
+ for (int i = 0; i < MIC_FILE_PATH.length; i++) {
+ mSeekBars[BOOST_FILE_PATH.length + i].resetDefault(MIC_FILE_PATH[i], MIC_DEFAULT_VALUE);
+ }
+ break;
+ }
+ }
+
}