mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
fix a glitch with Save/Discard dialog appearing, when it shouldnt
This commit is contained in:
@ -13,6 +13,7 @@ import android.os.Bundle
|
|||||||
import android.provider.ContactsContract.CommonDataKinds
|
import android.provider.ContactsContract.CommonDataKinds
|
||||||
import android.provider.ContactsContract.CommonDataKinds.*
|
import android.provider.ContactsContract.CommonDataKinds.*
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
|
import android.telephony.PhoneNumberUtils
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
@ -473,6 +474,7 @@ class EditContactActivity : ContactActivity() {
|
|||||||
|
|
||||||
numberHolder!!.apply {
|
numberHolder!!.apply {
|
||||||
contact_number.setText(number.value)
|
contact_number.setText(number.value)
|
||||||
|
contact_number.tag = number.normalizedNumber
|
||||||
setupPhoneNumberTypePicker(contact_number_type, number.type, number.label)
|
setupPhoneNumberTypePicker(contact_number_type, number.type, number.label)
|
||||||
if (highlightLastPhoneNumber && index == contact!!.phoneNumbers.size - 1) {
|
if (highlightLastPhoneNumber && index == contact!!.phoneNumbers.size - 1) {
|
||||||
numberViewToColor = contact_number
|
numberViewToColor = contact_number
|
||||||
@ -1022,7 +1024,15 @@ class EditContactActivity : ContactActivity() {
|
|||||||
val numberLabel = if (numberType == Phone.TYPE_CUSTOM) numberHolder.contact_number_type.value else ""
|
val numberLabel = if (numberType == Phone.TYPE_CUSTOM) numberHolder.contact_number_type.value else ""
|
||||||
|
|
||||||
if (number.isNotEmpty()) {
|
if (number.isNotEmpty()) {
|
||||||
phoneNumbers.add(PhoneNumber(number, numberType, numberLabel, number.normalizePhoneNumber()))
|
var normalizedNumber = number.normalizePhoneNumber()
|
||||||
|
|
||||||
|
// fix a glitch when onBackPressed the app thinks that a number changed because we fetched
|
||||||
|
// normalized number +421903123456, then at getting it from the input field we get 0903123456, can happen at WhatsApp contacts
|
||||||
|
val fetchedNormalizedNumber = numberHolder.contact_number.tag?.toString() ?: ""
|
||||||
|
if (PhoneNumberUtils.compare(number.normalizePhoneNumber(), fetchedNormalizedNumber)) {
|
||||||
|
normalizedNumber = fetchedNormalizedNumber
|
||||||
|
}
|
||||||
|
phoneNumbers.add(PhoneNumber(number, numberType, numberLabel, normalizedNumber))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return phoneNumbers
|
return phoneNumbers
|
||||||
|
@ -97,7 +97,6 @@ data class Contact(
|
|||||||
private fun compareUsingIds(other: Contact): Int {
|
private fun compareUsingIds(other: Contact): Int {
|
||||||
val firstId = id
|
val firstId = id
|
||||||
val secondId = other.id
|
val secondId = other.id
|
||||||
|
|
||||||
return firstId.compareTo(secondId)
|
return firstId.compareTo(secondId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user