Fixed contact order when accents are present + other fixes & improvements over contacts
This commit is contained in:
parent
cfd11a40ec
commit
a106da7cc5
8 changed files with 39 additions and 13 deletions
|
@ -23,7 +23,7 @@ import androidx.lifecycle.ViewModel
|
|||
import org.linphone.core.Address
|
||||
|
||||
class ContactNumberOrAddressViewModel(
|
||||
val address: Address,
|
||||
val address: Address?,
|
||||
val hasPresence: Boolean,
|
||||
val displayedValue: String,
|
||||
val isSip: Boolean = true,
|
||||
|
@ -33,10 +33,12 @@ class ContactNumberOrAddressViewModel(
|
|||
val showInvite = !hasPresence && !isSip
|
||||
|
||||
fun startCall() {
|
||||
address ?: return
|
||||
listener.onCall(address)
|
||||
}
|
||||
|
||||
fun startChat(secured: Boolean) {
|
||||
address ?: return
|
||||
listener.onChat(address, secured)
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ class ContactViewModel(private val c: Contact) : ErrorReportingViewModel(), Cont
|
|||
val presenceModel = c.friend?.getPresenceModelForUriOrTel(number)
|
||||
val hasPresence = presenceModel != null && presenceModel.basicStatus == PresenceBasicStatus.Open
|
||||
val contactAddress = presenceModel?.contact ?: number
|
||||
val address = coreContext.core.interpretUrl(contactAddress) ?: continue
|
||||
val address = coreContext.core.interpretUrl(contactAddress)
|
||||
val isMe = coreContext.core.defaultProxyConfig?.identityAddress?.weakEqual(address) ?: false
|
||||
val secureChatAllowed = !isMe && c.friend?.getPresenceModelForUriOrTel(number)?.hasCapability(FriendCapability.LimeX3Dh) ?: false
|
||||
val noa = ContactNumberOrAddressViewModel(address, hasPresence, number, isSip = false, showSecureChat = secureChatAllowed, listener = listener)
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.graphics.Bitmap
|
|||
import android.net.Uri
|
||||
import androidx.core.app.Person
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import java.text.Collator
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Address
|
||||
|
@ -76,7 +77,9 @@ open class Contact : Comparable<Contact> {
|
|||
val otherOrg = other.organization ?: ""
|
||||
return org.compareTo(otherOrg)
|
||||
}
|
||||
return fn.compareTo(otherFn)
|
||||
val collator = Collator.getInstance()
|
||||
collator.strength = Collator.NO_DECOMPOSITION
|
||||
return collator.compare(fn, otherFn)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
|
|
@ -110,7 +110,7 @@ class NativeContact(val nativeId: String, private val lookupKey: String? = null)
|
|||
|
||||
Log.d("[Native Contact] Found phone number $data1 ($data4)")
|
||||
val number = data4 ?: data1
|
||||
if (number != null && !phoneNumbers.contains(number)) phoneNumbers.add(number)
|
||||
if (number != null && number.isNotEmpty() && !phoneNumbers.contains(number)) phoneNumbers.add(number)
|
||||
}
|
||||
linphoneMime, ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE -> {
|
||||
if (data1 == null) {
|
||||
|
|
|
@ -130,7 +130,7 @@ class NativeContactEditor(
|
|||
fun setOrganization(value: String): NativeContactEditor {
|
||||
val previousValue = contact.organization
|
||||
if (value == previousValue) {
|
||||
Log.w("[Native Contact Editor] Organization hasn't changed")
|
||||
Log.d("[Native Contact Editor] Organization hasn't changed")
|
||||
return this
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,11 @@ class NativeContactEditor(
|
|||
when {
|
||||
phoneNumber.currentValue.isEmpty() -> {
|
||||
// New phone number to add
|
||||
addCount++
|
||||
addPhoneNumber(phoneNumber.newValue.value.orEmpty())
|
||||
val number = phoneNumber.newValue.value.orEmpty()
|
||||
if (number.isNotEmpty()) {
|
||||
addCount++
|
||||
addPhoneNumber(number)
|
||||
}
|
||||
}
|
||||
phoneNumber.toRemove.value == true -> {
|
||||
// Existing number to remove
|
||||
|
@ -180,8 +183,11 @@ class NativeContactEditor(
|
|||
}
|
||||
phoneNumber.currentValue != phoneNumber.newValue.value -> {
|
||||
// Existing number to update
|
||||
editCount++
|
||||
updatePhoneNumber(phoneNumber.currentValue, phoneNumber.newValue.value.orEmpty())
|
||||
val number = phoneNumber.newValue.value.orEmpty()
|
||||
if (number.isNotEmpty()) {
|
||||
editCount++
|
||||
updatePhoneNumber(phoneNumber.currentValue, number)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,9 +205,11 @@ class NativeContactEditor(
|
|||
when {
|
||||
sipAddress.currentValue.isEmpty() -> {
|
||||
// New address to add
|
||||
addCount++
|
||||
val address = sipAddress.newValue.value.orEmpty()
|
||||
addSipAddress(address)
|
||||
if (address.isNotEmpty()) {
|
||||
addCount++
|
||||
addSipAddress(address)
|
||||
}
|
||||
}
|
||||
sipAddress.toRemove.value == true -> {
|
||||
// Existing address to remove
|
||||
|
@ -210,8 +218,11 @@ class NativeContactEditor(
|
|||
}
|
||||
sipAddress.currentValue != sipAddress.newValue.value -> {
|
||||
// Existing address to update
|
||||
editCount++
|
||||
updateLinphoneOrSipAddress(sipAddress.currentValue, sipAddress.newValue.value.orEmpty())
|
||||
val address = sipAddress.newValue.value.orEmpty()
|
||||
if (address.isNotEmpty()) {
|
||||
editCount++
|
||||
updateLinphoneOrSipAddress(sipAddress.currentValue, address)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/round_orange_button_background_over" />
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/round_orange_button_background_disabled" />
|
||||
<item
|
||||
android:drawable="@drawable/round_orange_button_background_default" />
|
||||
</selector>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
|
||||
<solid android:color="@color/grey_color"/>
|
||||
<size android:width="30dp" android:height="30dp"/>
|
||||
</shape>
|
|
@ -80,6 +80,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{() -> data.startCall()}"
|
||||
android:enabled="@{data.address != null}"
|
||||
android:contentDescription="@string/content_description_start_call"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
|
@ -89,6 +90,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{() -> data.startChat(false)}"
|
||||
android:enabled="@{data.address != null}"
|
||||
android:contentDescription="@string/content_description_start_chat"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
|
@ -98,6 +100,7 @@
|
|||
|
||||
<RelativeLayout
|
||||
android:visibility="@{data.showSecureChat ? View.VISIBLE : View.GONE}"
|
||||
android:enabled="@{data.address != null}"
|
||||
android:onClick="@{() -> data.startChat(true)}"
|
||||
android:layout_width="65dp"
|
||||
android:layout_height="60dp"
|
||||
|
|
Loading…
Reference in a new issue