diff options
author | Amith Yamasani <yamasani@google.com> | 2011-01-31 21:15:54 -0800 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2011-01-31 21:20:22 -0800 |
commit | 424953d55b1cf790aa9ace5774469ead3d49181e (patch) | |
tree | 86da0207578178e5cd990b125faff472b45d0658 | |
parent | 13d62049f7c96c47356f23eaee7f0997612fdf9f (diff) | |
download | packages_apps_settings-424953d55b1cf790aa9ace5774469ead3d49181e.zip packages_apps_settings-424953d55b1cf790aa9ace5774469ead3d49181e.tar.gz packages_apps_settings-424953d55b1cf790aa9ace5774469ead3d49181e.tar.bz2 |
Use a custom media file for media volume sample.
Bug: 3409194
Intercept volume hard keys and ignore them if not voice capable.
Change-Id: Ieb620f1cfff675ab5a6a8ee69a7dd42355d2932e
-rw-r--r-- | res/raw/media_volume.ogg | bin | 0 -> 11969 bytes | |||
-rw-r--r-- | src/com/android/settings/RingerVolumePreference.java | 37 |
2 files changed, 35 insertions, 2 deletions
diff --git a/res/raw/media_volume.ogg b/res/raw/media_volume.ogg Binary files differnew file mode 100644 index 0000000..88db9d9 --- /dev/null +++ b/res/raw/media_volume.ogg diff --git a/src/com/android/settings/RingerVolumePreference.java b/src/com/android/settings/RingerVolumePreference.java index 7000e4e..daae1a7 100644 --- a/src/com/android/settings/RingerVolumePreference.java +++ b/src/com/android/settings/RingerVolumePreference.java @@ -17,13 +17,16 @@ package com.android.settings; import android.app.Dialog; +import android.content.ContentResolver; import android.content.Context; import android.media.AudioManager; +import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.preference.VolumePreference; import android.provider.Settings; import android.util.AttributeSet; +import android.view.KeyEvent; import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -40,6 +43,7 @@ public class RingerVolumePreference extends VolumePreference implements private CheckBox mNotificationsUseRingVolumeCheckbox; private SeekBarVolumizer [] mSeekBarVolumizer; + private boolean mIgnoreVolumeKeys; private static final int[] SEEKBAR_ID = new int[] { R.id.notification_volume_seekbar, R.id.media_volume_seekbar, @@ -70,6 +74,7 @@ public class RingerVolumePreference extends VolumePreference implements setDialogIcon(R.drawable.ic_settings_sound); mSeekBarVolumizer = new SeekBarVolumizer[SEEKBAR_ID.length]; + mIgnoreVolumeKeys = !Utils.isVoiceCapable(context); } @Override @@ -78,8 +83,13 @@ public class RingerVolumePreference extends VolumePreference implements for (int i = 0; i < SEEKBAR_ID.length; i++) { SeekBar seekBar = (SeekBar) view.findViewById(SEEKBAR_ID[i]); - mSeekBarVolumizer[i] = new SeekBarVolumizer(getContext(), seekBar, - SEEKBAR_TYPE[i]); + if (SEEKBAR_TYPE[i] == AudioManager.STREAM_MUSIC) { + mSeekBarVolumizer[i] = new SeekBarVolumizer(getContext(), seekBar, + SEEKBAR_TYPE[i], getMediaVolumeUri(getContext())); + } else { + mSeekBarVolumizer[i] = new SeekBarVolumizer(getContext(), seekBar, + SEEKBAR_TYPE[i]); + } } mNotificationVolumeTitle = (TextView) view.findViewById(R.id.notification_volume_title); @@ -95,6 +105,12 @@ public class RingerVolumePreference extends VolumePreference implements disableSettingsThatNeedVoice(view); } + private Uri getMediaVolumeUri(Context context) { + return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + + context.getPackageName() + + "/" + R.raw.media_volume); + } + private void disableSettingsThatNeedVoice(View parent) { final boolean voiceCapable = Utils.isVoiceCapable(getContext()); if (!voiceCapable) { @@ -139,6 +155,23 @@ public class RingerVolumePreference extends VolumePreference implements } @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + boolean isdown = (event.getAction() == KeyEvent.ACTION_DOWN); + switch (keyCode) { + case KeyEvent.KEYCODE_VOLUME_DOWN: + case KeyEvent.KEYCODE_VOLUME_UP: + case KeyEvent.KEYCODE_VOLUME_MUTE: + if (mIgnoreVolumeKeys) { + return true; + } else { + return super.onKey(v, keyCode, event); + } + default: + return false; + } + } + + @Override protected void onSampleStarting(SeekBarVolumizer volumizer) { super.onSampleStarting(volumizer); for (SeekBarVolumizer vol : mSeekBarVolumizer) { |