use the PhoneNumber model of Simple Commons, no real change

This commit is contained in:
tibbi 2022-02-06 10:59:08 +01:00
parent 6375607b7e
commit 02d744f753
10 changed files with 18 additions and 12 deletions

View file

@ -62,7 +62,7 @@ android {
} }
dependencies { 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.googlecode.ez-vcard:ez-vcard:0.11.3'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61' implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

View file

@ -25,6 +25,7 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.PhoneNumber
import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.dialogs.CustomLabelDialog import com.simplemobiletools.contacts.pro.dialogs.CustomLabelDialog

View file

@ -20,6 +20,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.PhoneNumber
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.dialogs.ChooseSocialDialog import com.simplemobiletools.contacts.pro.dialogs.ChooseSocialDialog
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
@ -323,8 +324,8 @@ class ViewContactActivity : ContactActivity() {
} }
phoneNumbers = phoneNumbers.distinctBy { phoneNumbers = phoneNumbers.distinctBy {
if (it.normalizedNumber != null && 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) it.normalizedNumber.substring(it.normalizedNumber.length - COMPARABLE_PHONE_NUMBER_LENGTH)
} else { } else {
it.normalizedNumber it.normalizedNumber
} }

View file

@ -14,6 +14,7 @@ import android.text.TextUtils
import android.util.SparseArray import android.util.SparseArray
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.PhoneNumber
import com.simplemobiletools.commons.overloads.times import com.simplemobiletools.commons.overloads.times
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.extensions.* import com.simplemobiletools.contacts.pro.extensions.*

View file

@ -3,7 +3,11 @@ package com.simplemobiletools.contacts.pro.helpers
import androidx.room.TypeConverter import androidx.room.TypeConverter
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken 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 { class Converters {
private val gson = Gson() private val gson = Gson()

View file

@ -163,10 +163,9 @@ class LocalContactsHelper(val context: Context) {
return if (contact == null || (withPhoneNumbersOnly && contact.phoneNumbers.isEmpty())) { return if (contact == null || (withPhoneNumbersOnly && contact.phoneNumbers.isEmpty())) {
null null
} else { } 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 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> 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)
} }
} }

View file

@ -9,6 +9,7 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredPostal
import android.widget.Toast import android.widget.Toast
import com.simplemobiletools.commons.extensions.normalizePhoneNumber import com.simplemobiletools.commons.extensions.normalizePhoneNumber
import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.commons.models.PhoneNumber
import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import com.simplemobiletools.contacts.pro.extensions.getCachePhoto import com.simplemobiletools.contacts.pro.extensions.getCachePhoto
import com.simplemobiletools.contacts.pro.extensions.getCachePhotoUri import com.simplemobiletools.contacts.pro.extensions.getCachePhotoUri

View file

@ -5,6 +5,7 @@ import android.telephony.PhoneNumberUtils
import com.simplemobiletools.commons.extensions.normalizePhoneNumber import com.simplemobiletools.commons.extensions.normalizePhoneNumber
import com.simplemobiletools.commons.extensions.normalizeString import com.simplemobiletools.commons.extensions.normalizeString
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.PhoneNumber
import com.simplemobiletools.contacts.pro.helpers.SMT_PRIVATE import com.simplemobiletools.contacts.pro.helpers.SMT_PRIVATE
data class Contact( data class Contact(
@ -175,7 +176,7 @@ data class Contact(
phoneNumbers.any { phoneNumbers.any {
PhoneNumberUtils.compare(it.normalizedNumber, normalizedText) || PhoneNumberUtils.compare(it.normalizedNumber, normalizedText) ||
it.value.contains(text) || it.value.contains(text) ||
it.normalizedNumber?.contains(normalizedText) == true || it.normalizedNumber.contains(normalizedText) ||
it.value.normalizePhoneNumber().contains(normalizedText) it.value.normalizePhoneNumber().contains(normalizedText)
} }
} else { } else {

View file

@ -4,6 +4,7 @@ import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.Index import androidx.room.Index
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import com.simplemobiletools.commons.models.PhoneNumber
@Entity(tableName = "contacts", indices = [(Index(value = ["id"], unique = true))]) @Entity(tableName = "contacts", indices = [(Index(value = ["id"], unique = true))])
data class LocalContact( data class LocalContact(
@ -27,8 +28,8 @@ data class LocalContact(
@ColumnInfo(name = "job_position") var jobPosition: String, @ColumnInfo(name = "job_position") var jobPosition: String,
@ColumnInfo(name = "websites") var websites: ArrayList<String>, @ColumnInfo(name = "websites") var websites: ArrayList<String>,
@ColumnInfo(name = "ims") var IMs: ArrayList<IM>, @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 equals(other: Any?) = id == (other as? LocalContact?)?.id
override fun hashCode() = id ?: 0 override fun hashCode() = id ?: 0

View file

@ -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?)