Add Settings item to select sound effects control panel.

Change-Id: I7952aad3afbc9dea8ea54be9afcad7969a0f23bc
This commit is contained in:
Marco Nelissen
2011-07-15 15:02:03 -07:00
parent 1aa671cba7
commit 6eca4b3b92
3 changed files with 32 additions and 0 deletions

View File

@@ -1364,6 +1364,8 @@
<string name="ringtone_summary">""</string> <string name="ringtone_summary">""</string>
<!-- Sound settings screen, volume title --> <!-- Sound settings screen, volume title -->
<string name="all_volume_title">Volume</string> <string name="all_volume_title">Volume</string>
<!-- Sound settings screen, music effects title [CHAR LIMIT=30]-->
<string name="musicfx_title">Music Effects</string>
<!-- Sound settings screen, setting option name --> <!-- Sound settings screen, setting option name -->
<string name="ring_volume_title">Ringer volume</string> <string name="ring_volume_title">Ringer volume</string>
<!-- Sound settings screen, setting option summary text --> <!-- Sound settings screen, setting option summary text -->

View File

@@ -45,6 +45,13 @@
android:persistent="false" android:persistent="false"
android:streamType="ring" /> android:streamType="ring" />
<Preference
android:key="musicfx"
android:title="@string/musicfx_title">
<intent android:targetPackage="com.android.musicfx"
android:targetClass="com.android.musicfx.ControlPanelPicker" />
</Preference>
<PreferenceCategory <PreferenceCategory
android:key="category_calls" android:key="category_calls"
android:title="@string/sound_category_calls_title"/> android:title="@string/sound_category_calls_title"/>

View File

@@ -21,7 +21,10 @@ import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.audiofx.AudioEffect;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator; import android.os.Vibrator;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
@@ -34,6 +37,8 @@ import android.provider.Settings.SettingNotFoundException;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
import java.util.List;
public class SoundSettings extends SettingsPreferenceFragment implements public class SoundSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener { Preference.OnPreferenceChangeListener {
private static final String TAG = "SoundAndDisplaysSettings"; private static final String TAG = "SoundAndDisplaysSettings";
@@ -44,6 +49,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
private static final String KEY_SILENT = "silent"; private static final String KEY_SILENT = "silent";
private static final String KEY_VIBRATE = "vibrate"; private static final String KEY_VIBRATE = "vibrate";
private static final String KEY_RING_VOLUME = "ring_volume"; private static final String KEY_RING_VOLUME = "ring_volume";
private static final String KEY_MUSICFX = "musicfx";
private static final String KEY_DTMF_TONE = "dtmf_tone"; private static final String KEY_DTMF_TONE = "dtmf_tone";
private static final String KEY_SOUND_EFFECTS = "sound_effects"; private static final String KEY_SOUND_EFFECTS = "sound_effects";
private static final String KEY_HAPTIC_FEEDBACK = "haptic_feedback"; private static final String KEY_HAPTIC_FEEDBACK = "haptic_feedback";
@@ -80,6 +86,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
private CheckBoxPreference mSoundEffects; private CheckBoxPreference mSoundEffects;
private CheckBoxPreference mHapticFeedback; private CheckBoxPreference mHapticFeedback;
private CheckBoxPreference mNotificationPulse; private CheckBoxPreference mNotificationPulse;
private Preference mMusicFx;
private CheckBoxPreference mLockSounds; private CheckBoxPreference mLockSounds;
private AudioManager mAudioManager; private AudioManager mAudioManager;
@@ -165,6 +172,19 @@ public class SoundSettings extends SettingsPreferenceFragment implements
} }
} }
mMusicFx = mSoundSettings.findPreference(KEY_MUSICFX);
Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
PackageManager p = getPackageManager();
List<ResolveInfo> ris = p.queryIntentActivities(i, PackageManager.GET_DISABLED_COMPONENTS);
if (ris.size() <= 2) {
// no need to show the item if there is no choice for the user to make
// note: the built in musicfx panel has two activities (one being a
// compatibility shim that launches either the other activity, or a
// third party one), hence the check for <=2. If the implementation
// of the compatbility layer changes, this check may need to be updated.
mSoundSettings.removePreference(mMusicFx);
}
if (!Utils.isVoiceCapable(getActivity())) { if (!Utils.isVoiceCapable(getActivity())) {
for (String prefKey : NEED_VOICE_CAPABILITY) { for (String prefKey : NEED_VOICE_CAPABILITY) {
Preference pref = findPreference(prefKey); Preference pref = findPreference(prefKey);
@@ -335,6 +355,9 @@ public class SoundSettings extends SettingsPreferenceFragment implements
boolean value = mNotificationPulse.isChecked(); boolean value = mNotificationPulse.isChecked();
Settings.System.putInt(getContentResolver(), Settings.System.putInt(getContentResolver(),
Settings.System.NOTIFICATION_LIGHT_PULSE, value ? 1 : 0); Settings.System.NOTIFICATION_LIGHT_PULSE, value ? 1 : 0);
} else if (preference == mMusicFx) {
// let the framework fire off the intent
return false;
} }
return true; return true;