package com.simplemobiletools.commons.models

import android.os.Parcelable
import android.telephony.PhoneNumberUtils
import androidx.annotation.Keep
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
import kotlinx.parcelize.Parcelize

/**
 * Used at displaying recent calls.
 * For contacts with multiple numbers specify the number and type
 */
@Keep
@kotlinx.serialization.Serializable
@Parcelize
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 specificNumber: String,
    val specificType: String,
    val isUnknownNumber: Boolean,
    var isShunFeng: Boolean,
    var sfNumber: String,
    var isExport: Boolean = false,//是否已经导出过该条记录
) : Parcelable {
    fun doesContainPhoneNumber(text: String): Boolean {
        val normalizedText = text.normalizePhoneNumber()
        return PhoneNumberUtils.compare(phoneNumber.normalizePhoneNumber(), normalizedText) ||
            phoneNumber.contains(text) ||
            phoneNumber.normalizePhoneNumber().contains(normalizedText) ||
            phoneNumber.contains(normalizedText)
    }
}
