|
|
|
@@ -16,17 +16,14 @@
|
|
|
|
|
|
|
|
|
|
package com.android.settings;
|
|
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
|
import android.content.ContentResolver;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.content.pm.ResolveInfo;
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
import android.database.sqlite.SQLiteException;
|
|
|
|
|
import android.media.AudioManager;
|
|
|
|
|
import android.media.Ringtone;
|
|
|
|
|
import android.media.RingtoneManager;
|
|
|
|
|
import android.media.audiofx.AudioEffect;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
@@ -41,8 +38,6 @@ import android.preference.PreferenceGroup;
|
|
|
|
|
import android.preference.PreferenceScreen;
|
|
|
|
|
import android.provider.MediaStore;
|
|
|
|
|
import android.provider.Settings;
|
|
|
|
|
import android.provider.MediaStore.Images.Media;
|
|
|
|
|
import android.provider.Settings.SettingNotFoundException;
|
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
@@ -55,7 +50,6 @@ public class SoundSettings extends SettingsPreferenceFragment implements
|
|
|
|
|
/** If there is no setting in the provider, use this. */
|
|
|
|
|
private static final int FALLBACK_EMERGENCY_TONE_VALUE = 0;
|
|
|
|
|
|
|
|
|
|
private static final String KEY_SILENT_MODE = "silent_mode";
|
|
|
|
|
private static final String KEY_VIBRATE = "vibrate_when_ringing";
|
|
|
|
|
private static final String KEY_RING_VOLUME = "ring_volume";
|
|
|
|
|
private static final String KEY_MUSICFX = "musicfx";
|
|
|
|
@@ -69,10 +63,6 @@ public class SoundSettings extends SettingsPreferenceFragment implements
|
|
|
|
|
private static final String KEY_NOTIFICATION_SOUND = "notification_sound";
|
|
|
|
|
private static final String KEY_CATEGORY_CALLS = "category_calls_and_notification";
|
|
|
|
|
|
|
|
|
|
private static final String SILENT_MODE_OFF = "off";
|
|
|
|
|
private static final String SILENT_MODE_VIBRATE = "vibrate";
|
|
|
|
|
private static final String SILENT_MODE_MUTE = "mute";
|
|
|
|
|
|
|
|
|
|
private static final String[] NEED_VOICE_CAPABILITY = {
|
|
|
|
|
KEY_RINGTONE, KEY_DTMF_TONE, KEY_CATEGORY_CALLS,
|
|
|
|
|
KEY_EMERGENCY_TONE
|
|
|
|
@@ -82,7 +72,6 @@ public class SoundSettings extends SettingsPreferenceFragment implements
|
|
|
|
|
private static final int MSG_UPDATE_NOTIFICATION_SUMMARY = 2;
|
|
|
|
|
|
|
|
|
|
private CheckBoxPreference mVibrateWhenRinging;
|
|
|
|
|
private ListPreference mSilentMode;
|
|
|
|
|
private CheckBoxPreference mDtmfTone;
|
|
|
|
|
private CheckBoxPreference mSoundEffects;
|
|
|
|
|
private CheckBoxPreference mHapticFeedback;
|
|
|
|
@@ -95,15 +84,6 @@ public class SoundSettings extends SettingsPreferenceFragment implements
|
|
|
|
|
|
|
|
|
|
private AudioManager mAudioManager;
|
|
|
|
|
|
|
|
|
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
|
if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
|
|
|
|
|
updateState(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private Handler mHandler = new Handler() {
|
|
|
|
|
public void handleMessage(Message msg) {
|
|
|
|
|
switch (msg.what) {
|
|
|
|
@@ -134,12 +114,8 @@ public class SoundSettings extends SettingsPreferenceFragment implements
|
|
|
|
|
getPreferenceScreen().removePreference(findPreference(KEY_EMERGENCY_TONE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mSilentMode = (ListPreference) findPreference(KEY_SILENT_MODE);
|
|
|
|
|
if (!getResources().getBoolean(R.bool.has_silent_mode)) {
|
|
|
|
|
getPreferenceScreen().removePreference(mSilentMode);
|
|
|
|
|
findPreference(KEY_RING_VOLUME).setDependency(null);
|
|
|
|
|
} else {
|
|
|
|
|
mSilentMode.setOnPreferenceChangeListener(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mVibrateWhenRinging = (CheckBoxPreference) findPreference(KEY_VIBRATE);
|
|
|
|
@@ -223,50 +199,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
|
|
|
|
|
public void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
|
|
|
|
|
updateState(true);
|
|
|
|
|
lookupRingtoneNames();
|
|
|
|
|
|
|
|
|
|
IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
|
|
|
|
getActivity().registerReceiver(mReceiver, filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPause() {
|
|
|
|
|
super.onPause();
|
|
|
|
|
|
|
|
|
|
getActivity().unregisterReceiver(mReceiver);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setPhoneSilentSettingValue(String value) {
|
|
|
|
|
int ringerMode = AudioManager.RINGER_MODE_NORMAL;
|
|
|
|
|
if (value.equals(SILENT_MODE_MUTE)) {
|
|
|
|
|
ringerMode = AudioManager.RINGER_MODE_SILENT;
|
|
|
|
|
} else if (value.equals(SILENT_MODE_VIBRATE)) {
|
|
|
|
|
ringerMode = AudioManager.RINGER_MODE_VIBRATE;
|
|
|
|
|
}
|
|
|
|
|
mAudioManager.setRingerMode(ringerMode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getPhoneSilentModeSettingValue() {
|
|
|
|
|
switch (mAudioManager.getRingerMode()) {
|
|
|
|
|
case AudioManager.RINGER_MODE_NORMAL:
|
|
|
|
|
return SILENT_MODE_OFF;
|
|
|
|
|
case AudioManager.RINGER_MODE_VIBRATE:
|
|
|
|
|
return SILENT_MODE_VIBRATE;
|
|
|
|
|
case AudioManager.RINGER_MODE_SILENT:
|
|
|
|
|
return SILENT_MODE_MUTE;
|
|
|
|
|
}
|
|
|
|
|
// Shouldn't happen
|
|
|
|
|
return SILENT_MODE_OFF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// updateState in fact updates the UI to reflect the system state
|
|
|
|
|
private void updateState(boolean force) {
|
|
|
|
|
if (getActivity() == null) return;
|
|
|
|
|
|
|
|
|
|
mSilentMode.setValue(getPhoneSilentModeSettingValue());
|
|
|
|
|
|
|
|
|
|
mSilentMode.setSummary(mSilentMode.getEntry());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateRingtoneName(int type, Preference preference, int msg) {
|
|
|
|
@@ -344,8 +277,6 @@ public class SoundSettings extends SettingsPreferenceFragment implements
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
Log.e(TAG, "could not persist emergency tone setting", e);
|
|
|
|
|
}
|
|
|
|
|
} else if (preference == mSilentMode) {
|
|
|
|
|
setPhoneSilentSettingValue(objValue.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|