Java Code Examples for android.media.Ringtone#getTitle()
The following examples show how to use
android.media.Ringtone#getTitle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RingtoneUtils.java From android-ringtone-picker with Apache License 2.0 | 6 votes |
/** * Get the title of the ringtone from the uri of ringtone. * * @param context instance of the caller * @param uri uri of the tone to search * @return title of the tone or return null if no tone found. */ @Nullable public static String getRingtoneName(@NonNull final Context context, @NonNull final Uri uri) { final Ringtone ringtone = RingtoneManager.getRingtone(context, uri); if (ringtone != null) { return ringtone.getTitle(context); } else { Cursor cur = context .getContentResolver() .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Audio.Media.TITLE}, MediaStore.Audio.Media._ID + " =?", new String[]{uri.getLastPathSegment()}, null); String title = null; if (cur != null) { title = cur.getString(cur.getColumnIndex(MediaStore.Audio.Media.TITLE)); cur.close(); } return title; } }
Example 2
Source File: ItemDialog.java From sleep-cycle-alarm with GNU General Public License v3.0 | 6 votes |
private void setRingtoneSubtitle() { Context ctx = getContext(); String summary = ctx.getString(R.string.pref_ringtone_select_default_summary); try { Uri uri = Uri.parse(itemRingtone); Ringtone ringtone = RingtoneManager.getRingtone(getContext(), uri); String title = ringtone.getTitle(getContext()); String stringToParse = ctx.getString(R.string.pref_ringtone_select_selected_summary); summary = String.format(stringToParse, title); } catch (Exception e) { Log.e(getClass().getName(), "setRingtoneSubtitle(): " + e.getMessage()); } finally { ((TextView) vItemRingtone.findViewById(R.id.tv_item_alarm_subtitle)) .setText(summary); } }
Example 3
Source File: EditAlertActivity.java From xDrip with GNU General Public License v3.0 | 6 votes |
public String shortPath(String path) { if(isPathRingtone(mContext, path)) { Ringtone ringtone = RingtoneManager.getRingtone(mContext, Uri.parse(path)); // Just verified that the ringtone exists... not checking for null return ringtone.getTitle(mContext); } if(path == null) { return ""; } if(path.length() == 0) { return "xDrip Default"; } String[] segments = path.split("/"); if (segments.length > 1) { return segments[segments.length - 1]; } return path; }
Example 4
Source File: Preferences.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }
Example 5
Source File: RingtoneSetting.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
public static String getValueDisplayString(Context context, Uri uri) { if (uri == null) return context.getString(R.string.value_none); if (uri.equals(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))) return context.getString(R.string.value_default); Ringtone ret = RingtoneManager.getRingtone(context, uri); if (ret != null) return ret.getTitle(context); return null; }
Example 6
Source File: NotificationOptions.java From financisto with GNU General Public License v2.0 | 5 votes |
public String getSoundName(Context context) { if (sound == null) { return context.getString(R.string.notification_options_off); } Uri uri = Uri.parse(sound); if (Settings.System.DEFAULT_NOTIFICATION_URI.equals(uri)) { return context.getString(R.string.notification_options_default); } Ringtone ringtone = RingtoneManager.getRingtone(context, uri); return ringtone != null ? ringtone.getTitle(context) : context.getString(R.string.notification_options_off); }
Example 7
Source File: SettingsActivity.java From Android-Audio-Recorder with Apache License 2.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }
Example 8
Source File: Conversions.java From boilr with GNU General Public License v3.0 | 5 votes |
public static String ringtoneUriToName(String stringUri, Context context) { if(stringUri.equals("")) return context.getString(R.string.silent); Uri uri = Uri.parse(stringUri); // Context context = activity.getApplicationContext(); Ringtone ringtone = RingtoneManager.getRingtone(context, uri); return ringtone != null ? ringtone.getTitle(context) : context.getString(R.string.unknown_ringtone); }
Example 9
Source File: SettingsActivity.java From SwitchPreferenceCompat with MIT License | 4 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }
Example 10
Source File: ProfileNotificationsActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (data == null) { return; } 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 (requestCode == 13) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); 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"); } } else if (requestCode == 13) { if (name != null) { editor.putString("ringtone_" + dialog_id, name); editor.putString("ringtone_path_" + dialog_id, ringtone.toString()); } else { editor.putString("ringtone_" + dialog_id, "NoSound"); editor.putString("ringtone_path_" + dialog_id, "NoSound"); } } editor.commit(); if (adapter != null) { adapter.notifyItemChanged(requestCode == 13 ? ringtoneRow : soundRow); } } }
Example 11
Source File: SettingsActivity.java From AndroidDemo with MIT License | 4 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }
Example 12
Source File: NotificationsSettingsActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@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; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone); if (rng != null) { if (requestCode == callsRingtoneRow) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == callsRingtoneRow) { if (name != null && ringtone != null) { editor.putString("CallsRingtone", name); editor.putString("CallsRingtonePath", ringtone.toString()); } else { editor.putString("CallsRingtone", "NoSound"); editor.putString("CallsRingtonePath", "NoSound"); } } editor.commit(); adapter.notifyItemChanged(requestCode); } }
Example 13
Source File: UserSettingsActivity.java From sensorhub with Mozilla Public License 2.0 | 4 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof EditTextPreference) { if (stringValue == null || stringValue.length() == 0) { preference.getEditor().clear(); preference.getEditor().commit(); } } if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone(preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }
Example 14
Source File: ProfileNotificationsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (data == null) { return; } 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 (requestCode == 13) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); 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"); } } else if (requestCode == 13) { if (name != null) { editor.putString("ringtone_" + dialog_id, name); editor.putString("ringtone_path_" + dialog_id, ringtone.toString()); } else { editor.putString("ringtone_" + dialog_id, "NoSound"); editor.putString("ringtone_path_" + dialog_id, "NoSound"); } } editor.commit(); if (adapter != null) { adapter.notifyItemChanged(requestCode == 13 ? ringtoneRow : soundRow); } } }
Example 15
Source File: NotificationsSettingsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@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; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone); if (rng != null) { if (requestCode == callsRingtoneRow) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); 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"); } } else if (requestCode == callsRingtoneRow) { if (name != null && ringtone != null) { editor.putString("CallsRingtone", name); editor.putString("CallsRingtonePath", ringtone.toString()); } else { editor.putString("CallsRingtone", "NoSound"); editor.putString("CallsRingtonePath", "NoSound"); } } editor.commit(); if (requestCode == messageSoundRow || requestCode == groupSoundRow) { updateServerNotificationsSettings(requestCode == groupSoundRow); } adapter.notifyItemChanged(requestCode); } }
Example 16
Source File: SettingsActivity.java From shrinker with Apache License 2.0 | 4 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }
Example 17
Source File: SettingsActivity.java From GitJourney with Apache License 2.0 | 4 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }
Example 18
Source File: SettingsActivity.java From Cybernet-VPN with GNU General Public License v3.0 | 4 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }
Example 19
Source File: NotificationsSettingsActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@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; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone); if (rng != null) { if (requestCode == callsRingtoneRow) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == callsRingtoneRow) { if (name != null && ringtone != null) { editor.putString("CallsRingtone", name); editor.putString("CallsRingtonePath", ringtone.toString()); } else { editor.putString("CallsRingtone", "NoSound"); editor.putString("CallsRingtonePath", "NoSound"); } } editor.commit(); adapter.notifyItemChanged(requestCode); } }
Example 20
Source File: SettingsActivity.java From beaconloc with Apache License 2.0 | 4 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof RingtonePreference) { // For ringtone preferences, look up the correct display value // using RingtoneManager. if (TextUtils.isEmpty(stringValue)) { // Empty values correspond to 'silent' (no ringtone). preference.setSummary(R.string.pref_ringtone_silent); } else { Ringtone ringtone = RingtoneManager.getRingtone( preference.getContext(), Uri.parse(stringValue)); if (ringtone == null) { // Clear the summary if there was a lookup error. preference.setSummary(null); } else { // Set the summary to reflect the new ringtone display // name. String name = ringtone.getTitle(preference.getContext()); preference.setSummary(name); } } } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(stringValue); } return true; }