Merge pull request #761 from Aga-C/fix-select-ringtone-issues
Fixed problems with ringtone selection (#756)
This commit is contained in:
commit
5d20e6b664
4 changed files with 8 additions and 6 deletions
|
@ -241,12 +241,14 @@ abstract class ContactActivity : SimpleActivity() {
|
||||||
return bitmap
|
return bitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun getDefaultRingtoneUri() = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE)
|
protected fun getDefaultRingtoneUri() = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)
|
||||||
|
|
||||||
protected fun getRingtonePickerIntent(): Intent {
|
protected fun getRingtonePickerIntent(): Intent {
|
||||||
val defaultRingtoneUri = getDefaultRingtoneUri()
|
val defaultRingtoneUri = getDefaultRingtoneUri()
|
||||||
val currentRingtoneUri = if (contact!!.ringtone != null) {
|
val currentRingtoneUri = if (contact!!.ringtone != null && contact!!.ringtone!!.isNotEmpty()) {
|
||||||
Uri.parse(contact!!.ringtone)
|
Uri.parse(contact!!.ringtone)
|
||||||
|
} else if (contact!!.ringtone?.isNotEmpty() == false) {
|
||||||
|
null
|
||||||
} else {
|
} else {
|
||||||
defaultRingtoneUri
|
defaultRingtoneUri
|
||||||
}
|
}
|
||||||
|
|
|
@ -1321,7 +1321,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun systemRingtoneSelected(uri: Uri?) {
|
override fun systemRingtoneSelected(uri: Uri?) {
|
||||||
contact!!.ringtone = uri?.toString()
|
contact!!.ringtone = uri?.toString() ?: ""
|
||||||
val contactRingtone = RingtoneManager.getRingtone(this, uri)
|
val contactRingtone = RingtoneManager.getRingtone(this, uri)
|
||||||
contact_ringtone.text = contactRingtone.getTitle(this)
|
contact_ringtone.text = contactRingtone.getTitle(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -615,7 +615,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
val ringtone = contact!!.ringtone
|
val ringtone = contact!!.ringtone
|
||||||
if (ringtone?.isEmpty() == true) {
|
if (ringtone?.isEmpty() == true) {
|
||||||
contact_ringtone.text = getString(R.string.no_sound)
|
contact_ringtone.text = getString(R.string.no_sound)
|
||||||
} else if (ringtone?.isNotEmpty() == true) {
|
} else if (ringtone?.isNotEmpty() == true && ringtone != getDefaultRingtoneUri().toString()) {
|
||||||
if (ringtone == SILENT) {
|
if (ringtone == SILENT) {
|
||||||
contact_ringtone.text = getString(R.string.no_sound)
|
contact_ringtone.text = getString(R.string.no_sound)
|
||||||
} else {
|
} else {
|
||||||
|
@ -708,7 +708,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
override fun systemRingtoneSelected(uri: Uri?) {
|
override fun systemRingtoneSelected(uri: Uri?) {
|
||||||
val contactRingtone = RingtoneManager.getRingtone(this, uri)
|
val contactRingtone = RingtoneManager.getRingtone(this, uri)
|
||||||
contact_ringtone.text = contactRingtone.getTitle(this)
|
contact_ringtone.text = contactRingtone.getTitle(this)
|
||||||
ringtoneUpdated(uri.toString())
|
ringtoneUpdated(uri?.toString() ?: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ringtoneUpdated(path: String?) {
|
private fun ringtoneUpdated(path: String?) {
|
||||||
|
|
|
@ -1097,7 +1097,7 @@ class ContactsHelper(val context: Context) {
|
||||||
val uri = Uri.withAppendedPath(Contacts.CONTENT_URI, contact.contactId.toString())
|
val uri = Uri.withAppendedPath(Contacts.CONTENT_URI, contact.contactId.toString())
|
||||||
val contentValues = ContentValues(2)
|
val contentValues = ContentValues(2)
|
||||||
contentValues.put(Contacts.STARRED, contact.starred)
|
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)
|
context.contentResolver.update(uri, contentValues, null, null)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
context.showErrorToast(e)
|
context.showErrorToast(e)
|
||||||
|
|
Loading…
Reference in a new issue