forked from upstream-mirrors/quik
Format phone number when displaying conversation title
This commit is contained in:
@@ -18,10 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package data.model
|
package data.model
|
||||||
|
|
||||||
|
import android.telephony.PhoneNumberUtils
|
||||||
import io.realm.RealmList
|
import io.realm.RealmList
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.annotations.Index
|
import io.realm.annotations.Index
|
||||||
import io.realm.annotations.PrimaryKey
|
import io.realm.annotations.PrimaryKey
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
open class Conversation : RealmObject() {
|
open class Conversation : RealmObject() {
|
||||||
|
|
||||||
@@ -34,8 +36,8 @@ open class Conversation : RealmObject() {
|
|||||||
fun getTitle(): String {
|
fun getTitle(): String {
|
||||||
var title = ""
|
var title = ""
|
||||||
recipients.forEachIndexed { index, recipient ->
|
recipients.forEachIndexed { index, recipient ->
|
||||||
val name = recipient.contact?.name
|
val name = recipient.contact?.name?.takeIf { it.isNotBlank() }
|
||||||
title += if (name.isNullOrBlank()) recipient.address else name
|
title += name ?: PhoneNumberUtils.formatNumber(recipient.address, Locale.getDefault().country)
|
||||||
if (index < recipients.size - 1) {
|
if (index < recipients.size - 1) {
|
||||||
title += ", "
|
title += ", "
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user