forked from upstream-mirrors/quik
Stricter check for phone number equality
This commit is contained in:
@@ -21,7 +21,6 @@ package com.moez.QKSMS.feature.compose
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.provider.ContactsContract
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import android.telephony.SmsMessage
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import com.moez.QKSMS.R
|
||||
@@ -57,6 +56,7 @@ import com.moez.QKSMS.repository.ContactRepository
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
import com.moez.QKSMS.repository.MessageRepository
|
||||
import com.moez.QKSMS.util.ActiveSubscriptionObservable
|
||||
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||
import com.moez.QKSMS.util.Preferences
|
||||
import com.moez.QKSMS.util.tryOrNull
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
@@ -96,6 +96,7 @@ class ComposeViewModel @Inject constructor(
|
||||
private val messageRepo: MessageRepository,
|
||||
private val navigator: Navigator,
|
||||
private val permissionManager: PermissionManager,
|
||||
private val phoneNumberUtils: PhoneNumberUtils,
|
||||
private val prefs: Preferences,
|
||||
private val retrySending: RetrySending,
|
||||
private val sendMessage: SendMessage,
|
||||
@@ -260,10 +261,9 @@ class ComposeViewModel @Inject constructor(
|
||||
.filter { contact -> contactFilter.filter(contact, normalizedQuery) }
|
||||
|
||||
// If the entry is a valid destination, allow it as a recipient
|
||||
if (PhoneNumberUtils.isWellFormedSmsAddress(query.toString())) {
|
||||
val newAddress = PhoneNumberUtils.formatNumber(query.toString(), Locale.getDefault().country)
|
||||
val newContact = Contact(numbers = RealmList(PhoneNumber(address = newAddress
|
||||
?: query.toString())))
|
||||
if (phoneNumberUtils.isPossibleNumber(query.toString())) {
|
||||
val newAddress = phoneNumberUtils.formatNumber(query)
|
||||
val newContact = Contact(numbers = RealmList(PhoneNumber(address = newAddress)))
|
||||
filteredContacts = listOf(newContact) + filteredContacts
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.animation.ObjectAnimator
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.os.Build
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import android.text.Layout
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
@@ -57,6 +56,7 @@ import com.moez.QKSMS.feature.compose.part.PartsAdapter
|
||||
import com.moez.QKSMS.model.Conversation
|
||||
import com.moez.QKSMS.model.Message
|
||||
import com.moez.QKSMS.model.Recipient
|
||||
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||
import com.moez.QKSMS.util.Preferences
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
@@ -72,6 +72,7 @@ class MessagesAdapter @Inject constructor(
|
||||
private val colors: Colors,
|
||||
private val dateFormatter: DateFormatter,
|
||||
private val navigator: Navigator,
|
||||
private val phoneNumberUtils: PhoneNumberUtils,
|
||||
private val prefs: Preferences,
|
||||
private val textViewStyler: TextViewStyler
|
||||
) : QkRealmAdapter<Message>() {
|
||||
@@ -322,7 +323,7 @@ class MessagesAdapter @Inject constructor(
|
||||
|
||||
override fun get(key: String): Recipient? {
|
||||
if (super.get(key)?.isValid != true) {
|
||||
set(key, conversation?.recipients?.firstOrNull { PhoneNumberUtils.compare(it.address, key) })
|
||||
set(key, conversation?.recipients?.firstOrNull { phoneNumberUtils.compare(it.address, key) })
|
||||
}
|
||||
|
||||
return super.get(key)?.takeIf { it.isValid }
|
||||
|
||||
Reference in New Issue
Block a user