List of usage examples for android.media Ringtone getTitle
public String getTitle(Context context)
From source file:com.googlecode.mindbell.MindBellPreferences.java
/** * Sets the ringtone title into the summary of the ringtone preference. * * @param preferenceRingtone/*from w ww .j a va 2 s. c o m*/ * @param uriString */ private void setPreferenceRingtoneSummary(RingtonePreference preferenceRingtone, String uriString) { CharSequence summary; if (uriString == null || uriString.isEmpty()) { summary = getText(R.string.summaryRingtoneNotSet); } else { Uri ringtoneUri = Uri.parse(uriString); Ringtone ringtone = RingtoneManager.getRingtone(this, ringtoneUri); summary = ringtone.getTitle(this); } preferenceRingtone.setSummary(summary); }
From source file:org.telegram.ui.ChatProfileActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); avatarUpdater.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { if (requestCode == 15) { Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null;//w w w . ja v a 2 s .com if (ringtone != null && parentActivity != null) { Ringtone rng = RingtoneManager.getRingtone(parentActivity, ringtone); if (rng != null) { name = rng.getTitle(parentActivity); rng.stop(); } } SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (name != null && ringtone != null) { editor.putString("sound_chat_" + chat_id, name); editor.putString("sound_chat_path_" + chat_id, ringtone.toString()); } else { editor.putString("sound_chat_" + chat_id, "NoSound"); editor.putString("sound_chat_path_" + chat_id, "NoSound"); } editor.commit(); listView.invalidateViews(); } } }
From source file:com.stasbar.knowyourself.data.TimerModel.java
/** * @return the title of the ringtone that is played for all timers *//*from w ww. j ava 2 s . com*/ String getTimerRingtoneTitle() { if (mTimerRingtoneTitle == null) { if (isTimerRingtoneSilent()) { // Special case: no ringtone has a title of "Silent". mTimerRingtoneTitle = mContext.getString(R.string.silent_ringtone_title); } else { final Uri defaultUri = getDefaultTimerRingtoneUri(); final Uri uri = getTimerRingtoneUri(); if (defaultUri.equals(uri)) { // Special case: default ringtone has a title of "Timer Expired". mTimerRingtoneTitle = mContext.getString(R.string.default_timer_ringtone_title); } else { final Ringtone ringtone = RingtoneManager.getRingtone(mContext, uri); mTimerRingtoneTitle = ringtone.getTitle(mContext); } } } return mTimerRingtoneTitle; }
From source file:com.android.deskclock.data.TimerModel.java
/** * @return the title of the ringtone that is played for all timers *//*from w w w .java 2 s. com*/ String getTimerRingtoneTitle() { if (mTimerRingtoneTitle == null) { if (isTimerRingtoneSilent()) { // Special case: no ringtone has a title of "Silent". mTimerRingtoneTitle = mContext.getString(R.string.silent_timer_ringtone_title); } else { final Uri defaultUri = getDefaultTimerRingtoneUri(); final Uri uri = getTimerRingtoneUri(); if (defaultUri.equals(uri)) { // Special case: default ringtone has a title of "Timer Expired". mTimerRingtoneTitle = mContext.getString(R.string.default_timer_ringtone_title); } else { final Ringtone ringtone = RingtoneManager.getRingtone(mContext, uri); mTimerRingtoneTitle = ringtone.getTitle(mContext); } } } return mTimerRingtoneTitle; }
From source file:org.telegram.ui.ProfileNotificationsActivity.java
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (data == null) { return; }/*from ww w . j a v a2 s . co m*/ Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone); if (rng != null) { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } rng.stop(); } } SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == 12) { if (name != null) { editor.putString("sound_" + dialog_id, name); editor.putString("sound_path_" + dialog_id, ringtone.toString()); } else { editor.putString("sound_" + dialog_id, "NoSound"); editor.putString("sound_path_" + dialog_id, "NoSound"); } } editor.commit(); listView.invalidateViews(); } }
From source file:org.telegram.ui.NotificationsSettingsActivity.java
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null;// www .j a va 2s . co m if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone); if (rng != null) { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } rng.stop(); } } SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == messageSoundRow) { if (name != null && ringtone != null) { editor.putString("GlobalSound", name); editor.putString("GlobalSoundPath", ringtone.toString()); } else { editor.putString("GlobalSound", "NoSound"); editor.putString("GlobalSoundPath", "NoSound"); } } else if (requestCode == groupSoundRow) { if (name != null && ringtone != null) { editor.putString("GroupSound", name); editor.putString("GroupSoundPath", ringtone.toString()); } else { editor.putString("GroupSound", "NoSound"); editor.putString("GroupSoundPath", "NoSound"); } } editor.commit(); listView.invalidateViews(); } }
From source file:com.xorcode.andtweet.PreferencesActivity.java
protected void showRingtone(Object newValue) { String ringtone = (String) newValue; Uri uri;/*w w w. j a va 2s.com*/ Ringtone rt; if (ringtone == null) { uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); } else if ("".equals(ringtone)) { mNotificationRingtone.setSummary(R.string.summary_preference_no_ringtone); } else { uri = Uri.parse(ringtone); rt = RingtoneManager.getRingtone(this, uri); mNotificationRingtone.setSummary(rt.getTitle(this)); } }