moving some contact related things into Commons
This commit is contained in:
parent
c17d78b871
commit
605f9e845a
9 changed files with 44 additions and 166 deletions
|
|
@ -1,24 +0,0 @@
|
|||
package com.simplemobiletools.smsmessenger.models
|
||||
|
||||
import com.simplemobiletools.commons.extensions.normalizeString
|
||||
|
||||
data class Contact(val id: Int, var name: String, var photoUri: String, var phoneNumber: String) : Comparable<Contact> {
|
||||
override fun compareTo(other: Contact): Int {
|
||||
val firstString = name.normalizeString()
|
||||
val secondString = other.name.normalizeString()
|
||||
|
||||
return if (firstString.firstOrNull()?.isLetter() == true && secondString.firstOrNull()?.isLetter() == false) {
|
||||
-1
|
||||
} else if (firstString.firstOrNull()?.isLetter() == false && secondString.firstOrNull()?.isLetter() == true) {
|
||||
1
|
||||
} else {
|
||||
if (firstString.isEmpty() && secondString.isNotEmpty()) {
|
||||
1
|
||||
} else if (firstString.isNotEmpty() && secondString.isEmpty()) {
|
||||
-1
|
||||
} else {
|
||||
firstString.compareTo(secondString, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
package com.simplemobiletools.smsmessenger.models
|
||||
|
||||
import android.provider.Telephony
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
|
||||
data class Message(
|
||||
val id: Int, val body: String, val type: Int, val participants: ArrayList<Contact>, val date: Int, val read: Boolean, val thread: Int,
|
||||
val id: Int, val body: String, val type: Int, val participants: ArrayList<SimpleContact>, val date: Int, val read: Boolean, val thread: Int,
|
||||
val isMMS: Boolean, val attachment: MessageAttachment?, val senderName: String, val senderPhotoUri: String
|
||||
) : ThreadItem() {
|
||||
fun isReceivedMessage() = type == Telephony.Sms.MESSAGE_TYPE_INBOX
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue