diff options
author | jt1134 <jt1134@gmail.com> | 2012-10-17 20:56:53 -0500 |
---|---|---|
committer | jt1134 <jt1134@gmail.com> | 2012-10-17 21:10:13 -0500 |
commit | b0c3fa03fed579f59ed79bc0f0c82ac41827e7c7 (patch) | |
tree | 72124adcbf1402f44ac40ea442b60a6660881af2 /AriesParts | |
parent | 4740deddfa4cb5717058c8eba48077e0a1da83e9 (diff) | |
download | device_samsung_aries-common-b0c3fa03fed579f59ed79bc0f0c82ac41827e7c7.zip device_samsung_aries-common-b0c3fa03fed579f59ed79bc0f0c82ac41827e7c7.tar.gz device_samsung_aries-common-b0c3fa03fed579f59ed79bc0f0c82ac41827e7c7.tar.bz2 |
AriesParts: add "test" button to vibration controls
based on patch from tuna
Change-Id: I95dbe816a0050f2dec925b080bab5bf511e22a16
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); + } + } |