Skip to content

Commit

Permalink
AriesParts: add a reset button for all seekbar preferences
Browse files Browse the repository at this point in the history
Change-Id: Ie554b1a1b2e0a6e907843882c978bfeae075eaff
  • Loading branch information
jt1134 authored and pawitp committed Nov 16, 2012
1 parent 3e961fd commit 66786a5
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 9 deletions.
20 changes: 18 additions & 2 deletions AriesParts/res/layout/preference_dialog_color_tuning.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@
android:paddingTop="2dip"
android:paddingLeft="20dip"
android:paddingRight="20dip" />


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_below="@+id/color_blue_gamma_seekbar"
android:paddingTop="5dip" >

<Button android:id="@+id/color_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:text="@string/button_reset_title" />

</LinearLayout>

</RelativeLayout>
</ScrollView>
</ScrollView>
15 changes: 10 additions & 5 deletions AriesParts/res/layout/preference_dialog_vibration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:paddingLeft="20dip"
android:paddingRight="20dip" />

<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
Expand All @@ -42,11 +42,16 @@
<Button android:id="@+id/vibration_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:text="@string/vibration_test_title" />
android:text="@string/vibration_test_title"
android:width="100dp" />

</RelativeLayout>
<Button android:id="@+id/vibration_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_reset_title"
android:width="100dp" />

</LinearLayout>

</RelativeLayout>
</ScrollView>
16 changes: 16 additions & 0 deletions AriesParts/res/layout/preference_dialog_volume_boost.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,21 @@
android:paddingLeft="20dip"
android:paddingRight="20dip" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_below="@+id/mic_hp_no_mic_seekbar"
android:paddingTop="5dip" >

<Button android:id="@+id/volume_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:text="@string/button_reset_title" />

</LinearLayout>

</RelativeLayout>
</ScrollView>
2 changes: 2 additions & 0 deletions AriesParts/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<string name="vibration_title">Vibration intensity</string>
<string name="vibration_test_title">Test</string>

<string name="button_reset_title">Reset</string>

<!-- Used for activity title. Usually not visible, except on the
multi-task screen -->
<string name="generic_warning_title">Warning</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
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;

/**
* 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,
Expand Down Expand Up @@ -92,6 +94,13 @@ protected void onBindDialogView(View view) {
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
Expand Down Expand Up @@ -208,6 +217,12 @@ protected void updateValue(int progress) {
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 {
Expand Down Expand Up @@ -238,5 +253,25 @@ protected void updateValue(int progress) {
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;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ protected void onBindDialogView(View view) {
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
Expand Down Expand Up @@ -142,13 +145,21 @@ protected void updateValue(int progress) {
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) {
switch(v.getId()) {
case R.id.vibration_test:
testVibration();
break;
case R.id.vibration_reset:
mSeekBar.resetDefault();
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
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;

/**
* 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,
Expand Down Expand Up @@ -93,6 +95,13 @@ protected void onBindDialogView(View view) {
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
Expand Down Expand Up @@ -211,6 +220,12 @@ protected void updateValue(int progress) {
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 {
Expand Down Expand Up @@ -242,4 +257,18 @@ protected void updateValue(int progress) {
}

}

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;
}
}

}

0 comments on commit 66786a5

Please sign in to comment.