-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathRecentCall.kt
37 lines (35 loc) · 1.12 KB
/
RecentCall.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.fossify.phone.models
import android.telephony.PhoneNumberUtils
import org.fossify.commons.extensions.normalizePhoneNumber
/**
* Used at displaying recent calls.
* For contacts with multiple numbers specify the number and type
*/
@kotlinx.serialization.Serializable
data class RecentCall(
val id: Int,
val phoneNumber: String,
val name: String,
val photoUri: String,
val startTS: Int,
val duration: Int,
val type: Int,
val neighbourIDs: MutableList<Int>,
val simID: Int,
val simColor: Int,
val specificNumber: String,
val specificType: String,
val isUnknownNumber: Boolean,
) {
fun doesContainPhoneNumber(text: String): Boolean {
if (text.toIntOrNull() != null) {
val normalizedText = text.normalizePhoneNumber()
return PhoneNumberUtils.compare(phoneNumber.normalizePhoneNumber(), normalizedText) ||
phoneNumber.contains(text) ||
phoneNumber.normalizePhoneNumber().contains(normalizedText) ||
phoneNumber.contains(normalizedText)
} else {
return false
}
}
}