diff options
Diffstat (limited to 'AriesParts')
-rw-r--r-- | AriesParts/res/layout/preference_dialog_vibration.xml | 16 | ||||
-rw-r--r-- | AriesParts/res/values/strings.xml | 1 | ||||
-rw-r--r-- | AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java | 25 |
3 files changed, 41 insertions, 1 deletions
diff --git a/AriesParts/res/layout/preference_dialog_vibration.xml b/AriesParts/res/layout/preference_dialog_vibration.xml index 9e11233..02cca16 100644 --- a/AriesParts/res/layout/preference_dialog_vibration.xml +++ b/AriesParts/res/layout/preference_dialog_vibration.xml @@ -32,5 +32,21 @@ android:paddingLeft="20dip" android:paddingRight="20dip" /> + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:layout_below="@+id/vibration_seekbar" + android:paddingTop="5dip" > + + <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" /> + + </RelativeLayout> + </RelativeLayout> </ScrollView> diff --git a/AriesParts/res/values/strings.xml b/AriesParts/res/values/strings.xml index 6e4ecd4..fe2d7d6 100644 --- a/AriesParts/res/values/strings.xml +++ b/AriesParts/res/values/strings.xml @@ -54,6 +54,7 @@ <string name="vibration_title_head">Vibration</string> <string name="vibration_summary_head">Control vibration intensity</string> <string name="vibration_title">Vibration intensity</string> + <string name="vibration_test_title">Test</string> <!-- Used for activity title. Usually not visible, except on the multi-task screen --> diff --git a/AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java b/AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java index 9bf6726..1c5f204 100644 --- a/AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java +++ b/AriesParts/src/com/cyanogenmod/settings/device/VibrationPreference.java @@ -3,14 +3,17 @@ package com.cyanogenmod.settings.device; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; +import android.os.Vibrator; 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; -public class VibrationPreference extends DialogPreference { +public class VibrationPreference extends DialogPreference implements OnClickListener { private static final int SEEKBAR_ID = R.id.vibration_seekbar; @@ -41,6 +44,13 @@ public class VibrationPreference extends DialogPreference { SeekBar seekBar = (SeekBar) view.findViewById(SEEKBAR_ID); TextView valueDisplay = (TextView) view.findViewById(VALUE_DISPLAY_ID); mSeekBar = new VibrationSeekBar(seekBar, valueDisplay, FILE_PATH); + + SetupButtonClickListener(view); + } + + private void SetupButtonClickListener(View view) { + Button mTestButton = (Button)view.findViewById(R.id.vibration_test); + mTestButton.setOnClickListener(this); } @Override @@ -134,4 +144,17 @@ public class VibrationPreference extends DialogPreference { } + public void onClick(View v) { + switch(v.getId()) { + case R.id.vibration_test: + testVibration(); + break; + } + } + + public void testVibration() { + Vibrator vib = (Vibrator) this.getContext().getSystemService(Context.VIBRATOR_SERVICE); + vib.vibrate(1000); + } + } |