private String getNotiToneURI() { return getPreferenceScreen() .getSharedPreferences() .getString( MyApplication.CHOOSE_NOTIFICATION_KEY, Settings.System.DEFAULT_NOTIFICATION_URI.toString()); }
@Override protected Object onGetDefaultValue(TypedArray a, int index) { final String defValue = (String) super.onGetDefaultValue(a, index); if ("default".equals(defValue)) return Settings.System.DEFAULT_NOTIFICATION_URI.toString(); else if ("silent".equals(defValue)) return ""; return defValue; }
public int addAlarm() { return addAlarm( true, "fully_charged", "", android.provider.Settings.System.DEFAULT_NOTIFICATION_URI.toString(), false, true); }
public static String getRingtone() { return prefs.getString( "notifications_new_message_ringtone", android.provider.Settings.System.DEFAULT_NOTIFICATION_URI.toString()); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ContentResolver resolver = getContentResolver(); int activePhoneType = TelephonyManager.getDefault().getCurrentPhoneType(); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); addPreferencesFromResource(R.xml.sound_settings); if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) { // device is not CDMA, do not display CDMA emergency_tone getPreferenceScreen().removePreference(findPreference(KEY_EMERGENCY_TONE)); } mVolumeOverlay = (ListPreference) findPreference(KEY_VOLUME_OVERLAY); mVolumeOverlay.setOnPreferenceChangeListener(this); int volumeOverlay = Settings.System.getInt( getContentResolver(), Settings.System.MODE_VOLUME_OVERLAY, VolumePanel.VOLUME_OVERLAY_EXPANDABLE); mVolumeOverlay.setValue(Integer.toString(volumeOverlay)); mVolumeOverlay.setSummary(mVolumeOverlay.getEntry()); mRingMode = (ListPreference) findPreference(KEY_RING_MODE); if (!getResources().getBoolean(R.bool.has_silent_mode)) { getPreferenceScreen().removePreference(mRingMode); findPreference(KEY_RING_VOLUME).setDependency(null); } else { mRingMode.setOnPreferenceChangeListener(this); } if (getResources().getBoolean(com.android.internal.R.bool.config_useFixedVolume)) { // device with fixed volume policy, do not display volumes submenu getPreferenceScreen().removePreference(findPreference(KEY_RING_VOLUME)); } mQuietHours = (PreferenceScreen) findPreference(KEY_QUIET_HOURS); updateQuietHoursSummary(); mSoundEffects = (CheckBoxPreference) findPreference(KEY_SOUND_EFFECTS); if (!Utils.hasVolumeRocker(getActivity())) { getPreferenceScreen().removePreference(findPreference(KEY_VOLUME_ADJUST_SOUNDS)); } mRingtonePreference = findPreference(KEY_RINGTONE); mNotificationPreference = findPreference(KEY_NOTIFICATION_SOUND); Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); if (vibrator == null || !vibrator.hasVibrator()) { removePreference(KEY_VIBRATE); removePreference(KEY_HAPTIC_FEEDBACK); removePreference(KEY_VIBRATION_INTENSITY); removePreference(KEY_CONVERT_SOUND_TO_VIBRATE); removePreference(KEY_VIBRATE_DURING_CALLS); } else if (!VibratorIntensity.isSupported()) { removePreference(KEY_VIBRATION_INTENSITY); } if (TelephonyManager.PHONE_TYPE_CDMA == activePhoneType) { ListPreference emergencyTonePreference = (ListPreference) findPreference(KEY_EMERGENCY_TONE); emergencyTonePreference.setValue( String.valueOf( Settings.Global.getInt( resolver, Settings.Global.EMERGENCY_TONE, FALLBACK_EMERGENCY_TONE_VALUE))); emergencyTonePreference.setOnPreferenceChangeListener(this); } mSoundSettings = (PreferenceGroup) findPreference(KEY_SOUND_SETTINGS); mMusicFx = mSoundSettings.findPreference(KEY_MUSICFX); Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL); mMusicFx.setIntent(i); PackageManager p = getPackageManager(); List<ResolveInfo> ris = p.queryIntentActivities(i, 0); if (ris.size() == 0) { mSoundSettings.removePreference(mMusicFx); } else if (ris.size() == 1) { mMusicFx.setSummary(ris.get(0).loadLabel(p)); } if (!Utils.isVoiceCapable(getActivity())) { for (String prefKey : NEED_VOICE_CAPABILITY) { Preference pref = findPreference(prefKey); if (pref != null) { getPreferenceScreen().removePreference(pref); } } mRingtonePreference = null; } mRingtoneLookupRunnable = new Runnable() { public void run() { if (mRingtonePreference != null) { updateRingtoneName( RingtoneManager.TYPE_RINGTONE, mRingtonePreference, MSG_UPDATE_RINGTONE_SUMMARY); } if (mNotificationPreference != null) { updateRingtoneName( RingtoneManager.TYPE_NOTIFICATION, mNotificationPreference, MSG_UPDATE_NOTIFICATION_SUMMARY); } } }; // power state change notification sounds mPowerSounds = (CheckBoxPreference) findPreference(KEY_POWER_NOTIFICATIONS); mPowerSounds.setChecked( Settings.Global.getInt(resolver, Settings.Global.POWER_NOTIFICATIONS_ENABLED, 0) != 0); mPowerSoundsVibrate = (CheckBoxPreference) findPreference(KEY_POWER_NOTIFICATIONS_VIBRATE); mPowerSoundsVibrate.setChecked( Settings.Global.getInt(resolver, Settings.Global.POWER_NOTIFICATIONS_VIBRATE, 0) != 0); if (vibrator == null || !vibrator.hasVibrator()) { removePreference(KEY_POWER_NOTIFICATIONS_VIBRATE); } mPowerSoundsRingtone = findPreference(KEY_POWER_NOTIFICATIONS_RINGTONE); String currentPowerRingtonePath = Settings.Global.getString(resolver, Settings.Global.POWER_NOTIFICATIONS_RINGTONE); // set to default notification if we don't yet have one if (currentPowerRingtonePath == null) { currentPowerRingtonePath = Settings.System.DEFAULT_NOTIFICATION_URI.toString(); Settings.Global.putString( getContentResolver(), Settings.Global.POWER_NOTIFICATIONS_RINGTONE, currentPowerRingtonePath); } // is it silent ? if (currentPowerRingtonePath.equals(POWER_NOTIFICATIONS_SILENT_URI)) { mPowerSoundsRingtone.setSummary(getString(R.string.power_notifications_ringtone_silent)); } else { final Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), Uri.parse(currentPowerRingtonePath)); if (ringtone != null) { mPowerSoundsRingtone.setSummary(ringtone.getTitle(getActivity())); } } initDockSettings(); }