properly handle fetching the current ringtone uri

This commit is contained in:
tibbi 2021-03-04 21:02:03 +01:00
parent 49ec8965af
commit 68082ab9ed
1 changed files with 9 additions and 2 deletions

View File

@ -231,12 +231,19 @@ abstract class ContactActivity : SimpleActivity() {
protected fun getDefaultRingtoneUri() = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE)
protected fun getRingtonePickerIntent(): Intent {
val defaultRingtoneUri = getDefaultRingtoneUri()
val currentRingtoneUri = if (contact!!.ringtone != null) {
Uri.parse(contact!!.ringtone)
} else {
defaultRingtoneUri
}
return Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply {
putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true)
putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true)
putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE)
putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, getDefaultRingtoneUri())
putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(contact!!.ringtone))
putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, defaultRingtoneUri)
putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentRingtoneUri)
}
}
}