use the PhoneNumber model of Simple Commons, no real change
This commit is contained in:
parent
6375607b7e
commit
02d744f753
|
@ -62,7 +62,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:4d36cc84e9'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:b70e7039e5'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
||||
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
|||
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.PhoneNumber
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.dialogs.CustomLabelDialog
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
|||
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.PhoneNumber
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.dialogs.ChooseSocialDialog
|
||||
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
|
||||
|
@ -323,8 +324,8 @@ class ViewContactActivity : ContactActivity() {
|
|||
}
|
||||
|
||||
phoneNumbers = phoneNumbers.distinctBy {
|
||||
if (it.normalizedNumber != null && it.normalizedNumber!!.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
|
||||
it.normalizedNumber?.substring(it.normalizedNumber!!.length - COMPARABLE_PHONE_NUMBER_LENGTH)
|
||||
if (it.normalizedNumber.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
|
||||
it.normalizedNumber.substring(it.normalizedNumber.length - COMPARABLE_PHONE_NUMBER_LENGTH)
|
||||
} else {
|
||||
it.normalizedNumber
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.text.TextUtils
|
|||
import android.util.SparseArray
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.PhoneNumber
|
||||
import com.simplemobiletools.commons.overloads.times
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.extensions.*
|
||||
|
|
|
@ -3,7 +3,11 @@ package com.simplemobiletools.contacts.pro.helpers
|
|||
import androidx.room.TypeConverter
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.simplemobiletools.contacts.pro.models.*
|
||||
import com.simplemobiletools.commons.models.PhoneNumber
|
||||
import com.simplemobiletools.contacts.pro.models.Address
|
||||
import com.simplemobiletools.contacts.pro.models.Email
|
||||
import com.simplemobiletools.contacts.pro.models.Event
|
||||
import com.simplemobiletools.contacts.pro.models.IM
|
||||
|
||||
class Converters {
|
||||
private val gson = Gson()
|
||||
|
|
|
@ -163,10 +163,9 @@ class LocalContactsHelper(val context: Context) {
|
|||
return if (contact == null || (withPhoneNumbersOnly && contact.phoneNumbers.isEmpty())) {
|
||||
null
|
||||
} else {
|
||||
val phoneNumbers = contact.phoneNumbers.map { it.value }.toMutableList() as ArrayList<String>
|
||||
val birthdays = contact.events.filter { it.type == Event.TYPE_BIRTHDAY }.map { it.value }.toMutableList() as ArrayList<String>
|
||||
val anniversaries = contact.events.filter { it.type == Event.TYPE_ANNIVERSARY }.map { it.value }.toMutableList() as ArrayList<String>
|
||||
SimpleContact(contact.id, contact.id, contact.getNameToDisplay(), contact.photoUri, phoneNumbers, birthdays, anniversaries)
|
||||
SimpleContact(contact.id, contact.id, contact.getNameToDisplay(), contact.photoUri, contact.phoneNumbers, birthdays, anniversaries)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredPostal
|
|||
import android.widget.Toast
|
||||
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||
import com.simplemobiletools.commons.models.PhoneNumber
|
||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.contacts.pro.extensions.getCachePhoto
|
||||
import com.simplemobiletools.contacts.pro.extensions.getCachePhotoUri
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.telephony.PhoneNumberUtils
|
|||
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
||||
import com.simplemobiletools.commons.extensions.normalizeString
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.PhoneNumber
|
||||
import com.simplemobiletools.contacts.pro.helpers.SMT_PRIVATE
|
||||
|
||||
data class Contact(
|
||||
|
@ -175,7 +176,7 @@ data class Contact(
|
|||
phoneNumbers.any {
|
||||
PhoneNumberUtils.compare(it.normalizedNumber, normalizedText) ||
|
||||
it.value.contains(text) ||
|
||||
it.normalizedNumber?.contains(normalizedText) == true ||
|
||||
it.normalizedNumber.contains(normalizedText) ||
|
||||
it.value.normalizePhoneNumber().contains(normalizedText)
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.room.ColumnInfo
|
|||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import com.simplemobiletools.commons.models.PhoneNumber
|
||||
|
||||
@Entity(tableName = "contacts", indices = [(Index(value = ["id"], unique = true))])
|
||||
data class LocalContact(
|
||||
|
@ -27,8 +28,8 @@ data class LocalContact(
|
|||
@ColumnInfo(name = "job_position") var jobPosition: String,
|
||||
@ColumnInfo(name = "websites") var websites: ArrayList<String>,
|
||||
@ColumnInfo(name = "ims") var IMs: ArrayList<IM>,
|
||||
@ColumnInfo(name = "ringtone") var ringtone: String?) {
|
||||
|
||||
@ColumnInfo(name = "ringtone") var ringtone: String?
|
||||
) {
|
||||
override fun equals(other: Any?) = id == (other as? LocalContact?)?.id
|
||||
|
||||
override fun hashCode() = id ?: 0
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
package com.simplemobiletools.contacts.pro.models
|
||||
|
||||
data class PhoneNumber(var value: String, var type: Int, var label: String, var normalizedNumber: String?)
|
Loading…
Reference in New Issue