diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ContactActivity.kt index 936fb415..05de1d4c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ContactActivity.kt @@ -241,12 +241,14 @@ abstract class ContactActivity : SimpleActivity() { return bitmap } - protected fun getDefaultRingtoneUri() = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE) + protected fun getDefaultRingtoneUri() = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE) protected fun getRingtonePickerIntent(): Intent { val defaultRingtoneUri = getDefaultRingtoneUri() - val currentRingtoneUri = if (contact!!.ringtone != null) { + val currentRingtoneUri = if (contact!!.ringtone != null && contact!!.ringtone!!.isNotEmpty()) { Uri.parse(contact!!.ringtone) + } else if (contact!!.ringtone?.isNotEmpty() == false) { + null } else { defaultRingtoneUri } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt index fe717b39..648feaf3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt @@ -1321,7 +1321,7 @@ class EditContactActivity : ContactActivity() { } override fun systemRingtoneSelected(uri: Uri?) { - contact!!.ringtone = uri?.toString() + contact!!.ringtone = uri?.toString() ?: "" val contactRingtone = RingtoneManager.getRingtone(this, uri) contact_ringtone.text = contactRingtone.getTitle(this) } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt index 74fd0ea7..7627e303 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt @@ -615,7 +615,7 @@ class ViewContactActivity : ContactActivity() { val ringtone = contact!!.ringtone if (ringtone?.isEmpty() == true) { contact_ringtone.text = getString(R.string.no_sound) - } else if (ringtone?.isNotEmpty() == true) { + } else if (ringtone?.isNotEmpty() == true && ringtone != getDefaultRingtoneUri().toString()) { if (ringtone == SILENT) { contact_ringtone.text = getString(R.string.no_sound) } else { @@ -708,7 +708,7 @@ class ViewContactActivity : ContactActivity() { override fun systemRingtoneSelected(uri: Uri?) { val contactRingtone = RingtoneManager.getRingtone(this, uri) contact_ringtone.text = contactRingtone.getTitle(this) - ringtoneUpdated(uri.toString()) + ringtoneUpdated(uri?.toString() ?: "") } private fun ringtoneUpdated(path: String?) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt index 96db9435..59795654 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt @@ -1097,7 +1097,7 @@ class ContactsHelper(val context: Context) { val uri = Uri.withAppendedPath(Contacts.CONTENT_URI, contact.contactId.toString()) val contentValues = ContentValues(2) contentValues.put(Contacts.STARRED, contact.starred) - contentValues.put(Contacts.CUSTOM_RINGTONE, contact.ringtone ?: "") + contentValues.put(Contacts.CUSTOM_RINGTONE, contact.ringtone) context.contentResolver.update(uri, contentValues, null, null) } catch (e: Exception) { context.showErrorToast(e)