forked from upstream-mirrors/quik
Stricter check for phone number equality
This commit is contained in:
@@ -82,6 +82,7 @@ dependencies {
|
|||||||
implementation "com.jakewharton.timber:timber:$timber_version"
|
implementation "com.jakewharton.timber:timber:$timber_version"
|
||||||
implementation "com.squareup.moshi:moshi:$moshi_version"
|
implementation "com.squareup.moshi:moshi:$moshi_version"
|
||||||
implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
|
implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
|
||||||
|
implementation 'io.michaelrocks:libphonenumber-android:8.10.16'
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
|
||||||
implementation project(":android-smsmms")
|
implementation project(":android-smsmms")
|
||||||
|
|||||||
@@ -18,16 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.filter
|
package com.moez.QKSMS.filter
|
||||||
|
|
||||||
import android.telephony.PhoneNumberUtils
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class PhoneNumberFilter @Inject constructor() : Filter<String>() {
|
class PhoneNumberFilter @Inject constructor(
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
|
) : Filter<String>() {
|
||||||
|
|
||||||
override fun filter(item: String, query: CharSequence): Boolean {
|
override fun filter(item: String, query: CharSequence): Boolean {
|
||||||
val allCharactersDialable = query.all { PhoneNumberUtils.isReallyDialable(it) }
|
val allCharactersDialable = query.all { phoneNumberUtils.isReallyDialable(it) }
|
||||||
|
return allCharactersDialable && (phoneNumberUtils.compare(item, query.toString()) ||
|
||||||
return allCharactersDialable && (PhoneNumberUtils.compare(item, query.toString()) ||
|
phoneNumberUtils.normalizeNumber(item).contains(phoneNumberUtils.normalizeNumber(query.toString())))
|
||||||
PhoneNumberUtils.stripSeparators(item).contains(PhoneNumberUtils.stripSeparators(query.toString())))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,20 +18,22 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.repository
|
package com.moez.QKSMS.repository
|
||||||
|
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import com.moez.QKSMS.extensions.anyOf
|
import com.moez.QKSMS.extensions.anyOf
|
||||||
import com.moez.QKSMS.model.BlockedNumber
|
import com.moez.QKSMS.model.BlockedNumber
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmResults
|
import io.realm.RealmResults
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BlockingRepositoryImpl @Inject constructor() : BlockingRepository {
|
class BlockingRepositoryImpl @Inject constructor(
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
|
) : BlockingRepository {
|
||||||
|
|
||||||
override fun blockNumber(vararg addresses: String) {
|
override fun blockNumber(vararg addresses: String) {
|
||||||
Realm.getDefaultInstance().use { realm ->
|
Realm.getDefaultInstance().use { realm ->
|
||||||
val blockedNumbers = realm.where(BlockedNumber::class.java).findAll()
|
val blockedNumbers = realm.where(BlockedNumber::class.java).findAll()
|
||||||
val newAddresses = addresses.filter { address ->
|
val newAddresses = addresses.filter { address ->
|
||||||
blockedNumbers.none { number -> PhoneNumberUtils.compare(number.address, address) }
|
blockedNumbers.none { number -> phoneNumberUtils.compare(number.address, address) }
|
||||||
}
|
}
|
||||||
|
|
||||||
val maxId = realm.where(BlockedNumber::class.java)
|
val maxId = realm.where(BlockedNumber::class.java)
|
||||||
@@ -60,7 +62,7 @@ class BlockingRepositoryImpl @Inject constructor() : BlockingRepository {
|
|||||||
return Realm.getDefaultInstance().use { realm ->
|
return Realm.getDefaultInstance().use { realm ->
|
||||||
realm.where(BlockedNumber::class.java)
|
realm.where(BlockedNumber::class.java)
|
||||||
.findAll()
|
.findAll()
|
||||||
.any { number -> PhoneNumberUtils.compare(number.address, address) }
|
.any { number -> phoneNumberUtils.compare(number.address, address) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +82,7 @@ class BlockingRepositoryImpl @Inject constructor() : BlockingRepository {
|
|||||||
val ids = realm.where(BlockedNumber::class.java)
|
val ids = realm.where(BlockedNumber::class.java)
|
||||||
.findAll()
|
.findAll()
|
||||||
.filter { number ->
|
.filter { number ->
|
||||||
addresses.any { address -> PhoneNumberUtils.compare(number.address, address) }
|
addresses.any { address -> phoneNumberUtils.compare(number.address, address) }
|
||||||
}
|
}
|
||||||
.map { number -> number.id }
|
.map { number -> number.id }
|
||||||
.toLongArray()
|
.toLongArray()
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package com.moez.QKSMS.repository
|
|||||||
import android.content.ContentUris
|
import android.content.ContentUris
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import com.moez.QKSMS.compat.TelephonyCompat
|
import com.moez.QKSMS.compat.TelephonyCompat
|
||||||
import com.moez.QKSMS.extensions.anyOf
|
import com.moez.QKSMS.extensions.anyOf
|
||||||
import com.moez.QKSMS.extensions.map
|
import com.moez.QKSMS.extensions.map
|
||||||
@@ -34,6 +33,7 @@ import com.moez.QKSMS.model.Conversation
|
|||||||
import com.moez.QKSMS.model.Message
|
import com.moez.QKSMS.model.Message
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
import com.moez.QKSMS.model.SearchResult
|
import com.moez.QKSMS.model.SearchResult
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import com.moez.QKSMS.util.tryOrNull
|
import com.moez.QKSMS.util.tryOrNull
|
||||||
import io.realm.Case
|
import io.realm.Case
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
@@ -46,7 +46,8 @@ class ConversationRepositoryImpl @Inject constructor(
|
|||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val conversationFilter: ConversationFilter,
|
private val conversationFilter: ConversationFilter,
|
||||||
private val cursorToConversation: CursorToConversation,
|
private val cursorToConversation: CursorToConversation,
|
||||||
private val cursorToRecipient: CursorToRecipient
|
private val cursorToRecipient: CursorToRecipient,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
) : ConversationRepository {
|
) : ConversationRepository {
|
||||||
|
|
||||||
override fun getConversations(archived: Boolean): RealmResults<Conversation> {
|
override fun getConversations(archived: Boolean): RealmResults<Conversation> {
|
||||||
@@ -179,7 +180,7 @@ class ConversationRepositoryImpl @Inject constructor(
|
|||||||
.findAll()
|
.findAll()
|
||||||
.firstOrNull { conversation ->
|
.firstOrNull { conversation ->
|
||||||
conversation.recipients.size == recipients.size && conversation.recipients.map { it.address }.all { address ->
|
conversation.recipients.size == recipients.size && conversation.recipients.map { it.address }.all { address ->
|
||||||
recipients.any { recipient -> PhoneNumberUtils.compare(recipient, address) }
|
recipients.any { recipient -> phoneNumberUtils.compare(recipient, address) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?.id
|
?.id
|
||||||
@@ -363,7 +364,7 @@ class ConversationRepositoryImpl @Inject constructor(
|
|||||||
.map { recipient ->
|
.map { recipient ->
|
||||||
recipient.apply {
|
recipient.apply {
|
||||||
contact = contacts.firstOrNull {
|
contact = contacts.firstOrNull {
|
||||||
it.numbers.any { PhoneNumberUtils.compare(recipient.address, it.address) }
|
it.numbers.any { phoneNumberUtils.compare(recipient.address, it.address) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import android.content.Intent
|
|||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import android.telephony.SmsManager
|
import android.telephony.SmsManager
|
||||||
import androidx.core.content.contentValuesOf
|
import androidx.core.content.contentValuesOf
|
||||||
import com.google.android.mms.ContentType
|
import com.google.android.mms.ContentType
|
||||||
@@ -47,6 +46,7 @@ import com.moez.QKSMS.receiver.SendSmsReceiver
|
|||||||
import com.moez.QKSMS.receiver.SmsDeliveredReceiver
|
import com.moez.QKSMS.receiver.SmsDeliveredReceiver
|
||||||
import com.moez.QKSMS.receiver.SmsSentReceiver
|
import com.moez.QKSMS.receiver.SmsSentReceiver
|
||||||
import com.moez.QKSMS.util.ImageUtils
|
import com.moez.QKSMS.util.ImageUtils
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import com.moez.QKSMS.util.Preferences
|
import com.moez.QKSMS.util.Preferences
|
||||||
import com.moez.QKSMS.util.tryOrNull
|
import com.moez.QKSMS.util.tryOrNull
|
||||||
import io.realm.Case
|
import io.realm.Case
|
||||||
@@ -61,8 +61,9 @@ import javax.inject.Singleton
|
|||||||
class MessageRepositoryImpl @Inject constructor(
|
class MessageRepositoryImpl @Inject constructor(
|
||||||
private val activeConversationManager: ActiveConversationManager,
|
private val activeConversationManager: ActiveConversationManager,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val messageIds: KeyManager,
|
|
||||||
private val imageRepository: ImageRepository,
|
private val imageRepository: ImageRepository,
|
||||||
|
private val messageIds: KeyManager,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils,
|
||||||
private val prefs: Preferences,
|
private val prefs: Preferences,
|
||||||
private val syncRepository: SyncRepository
|
private val syncRepository: SyncRepository
|
||||||
) : MessageRepository {
|
) : MessageRepository {
|
||||||
@@ -290,7 +291,7 @@ class MessageRepositoryImpl @Inject constructor(
|
|||||||
.map { vCard -> MMSPart("contact", ContentType.TEXT_VCARD, vCard) }
|
.map { vCard -> MMSPart("contact", ContentType.TEXT_VCARD, vCard) }
|
||||||
|
|
||||||
val transaction = Transaction(context)
|
val transaction = Transaction(context)
|
||||||
transaction.sendNewMessage(subId, threadId, addresses.map(PhoneNumberUtils::stripSeparators), parts, null)
|
transaction.sendNewMessage(subId, threadId, addresses.map(phoneNumberUtils::normalizeNumber), parts, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.content.ContentResolver
|
|||||||
import android.content.ContentUris
|
import android.content.ContentUris
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import com.f2prateek.rx.preferences2.RxSharedPreferences
|
import com.f2prateek.rx.preferences2.RxSharedPreferences
|
||||||
import com.moez.QKSMS.extensions.insertOrUpdate
|
import com.moez.QKSMS.extensions.insertOrUpdate
|
||||||
import com.moez.QKSMS.extensions.map
|
import com.moez.QKSMS.extensions.map
|
||||||
@@ -37,6 +36,7 @@ import com.moez.QKSMS.model.Message
|
|||||||
import com.moez.QKSMS.model.MmsPart
|
import com.moez.QKSMS.model.MmsPart
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
import com.moez.QKSMS.model.SyncLog
|
import com.moez.QKSMS.model.SyncLog
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import com.moez.QKSMS.util.tryOrNull
|
import com.moez.QKSMS.util.tryOrNull
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
@@ -54,6 +54,7 @@ class SyncRepositoryImpl @Inject constructor(
|
|||||||
private val cursorToRecipient: CursorToRecipient,
|
private val cursorToRecipient: CursorToRecipient,
|
||||||
private val cursorToContact: CursorToContact,
|
private val cursorToContact: CursorToContact,
|
||||||
private val keys: KeyManager,
|
private val keys: KeyManager,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils,
|
||||||
private val rxPrefs: RxSharedPreferences
|
private val rxPrefs: RxSharedPreferences
|
||||||
) : SyncRepository {
|
) : SyncRepository {
|
||||||
|
|
||||||
@@ -170,7 +171,7 @@ class SyncRepositoryImpl @Inject constructor(
|
|||||||
syncProgress.onNext(SyncRepository.SyncProgress.Running(max, progress, false))
|
syncProgress.onNext(SyncRepository.SyncProgress.Running(max, progress, false))
|
||||||
cursorToRecipient.map(cursor).apply {
|
cursorToRecipient.map(cursor).apply {
|
||||||
contact = contacts.firstOrNull { contact ->
|
contact = contacts.firstOrNull { contact ->
|
||||||
contact.numbers.any { PhoneNumberUtils.compare(address, it.address) }
|
contact.numbers.any { phoneNumberUtils.compare(address, it.address) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,7 +251,7 @@ class SyncRepositoryImpl @Inject constructor(
|
|||||||
val updatedRecipients = recipients.map { recipient ->
|
val updatedRecipients = recipients.map { recipient ->
|
||||||
recipient.apply {
|
recipient.apply {
|
||||||
contact = contacts.firstOrNull {
|
contact = contacts.firstOrNull {
|
||||||
it.numbers.any { PhoneNumberUtils.compare(recipient.address, it.address) }
|
it.numbers.any { phoneNumberUtils.compare(recipient.address, it.address) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,7 +265,7 @@ class SyncRepositoryImpl @Inject constructor(
|
|||||||
override fun syncContact(address: String): Boolean {
|
override fun syncContact(address: String): Boolean {
|
||||||
// See if there's a contact that matches this phone number
|
// See if there's a contact that matches this phone number
|
||||||
var contact = getContacts().firstOrNull {
|
var contact = getContacts().firstOrNull {
|
||||||
it.numbers.any { number -> PhoneNumberUtils.compare(number.address, address) }
|
it.numbers.any { number -> phoneNumberUtils.compare(number.address, address) }
|
||||||
} ?: return false
|
} ?: return false
|
||||||
|
|
||||||
Realm.getDefaultInstance().use { realm ->
|
Realm.getDefaultInstance().use { realm ->
|
||||||
@@ -277,7 +278,7 @@ class SyncRepositoryImpl @Inject constructor(
|
|||||||
val updatedRecipients = recipients
|
val updatedRecipients = recipients
|
||||||
.filter { recipient ->
|
.filter { recipient ->
|
||||||
contact.numbers.any { number ->
|
contact.numbers.any { number ->
|
||||||
PhoneNumberUtils.compare(recipient.address, number.address)
|
phoneNumberUtils.compare(recipient.address, number.address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.map { recipient -> recipient.apply { this.contact = contact } }
|
.map { recipient -> recipient.apply { this.contact = contact } }
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package com.moez.QKSMS.util
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import com.bumptech.glide.Priority
|
import com.bumptech.glide.Priority
|
||||||
import com.bumptech.glide.load.DataSource
|
import com.bumptech.glide.load.DataSource
|
||||||
import com.bumptech.glide.load.Key
|
import com.bumptech.glide.load.Key
|
||||||
@@ -38,11 +37,12 @@ import java.security.MessageDigest
|
|||||||
|
|
||||||
class ContactImageLoader(
|
class ContactImageLoader(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val contactRepo: ContactRepository
|
private val contactRepo: ContactRepository,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
) : ModelLoader<String, InputStream> {
|
) : ModelLoader<String, InputStream> {
|
||||||
|
|
||||||
override fun handles(model: String): Boolean {
|
override fun handles(model: String): Boolean {
|
||||||
return PhoneNumberUtils.isGlobalPhoneNumber(model)
|
return phoneNumberUtils.isPossibleNumber(model)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun buildLoadData(
|
override fun buildLoadData(
|
||||||
@@ -51,12 +51,18 @@ class ContactImageLoader(
|
|||||||
height: Int,
|
height: Int,
|
||||||
options: Options
|
options: Options
|
||||||
): ModelLoader.LoadData<InputStream>? {
|
): ModelLoader.LoadData<InputStream>? {
|
||||||
return ModelLoader.LoadData(ContactImageKey(model), ContactImageFetcher(context, contactRepo, model))
|
return ModelLoader.LoadData(
|
||||||
|
ContactImageKey(phoneNumberUtils.normalizeNumber(model)),
|
||||||
|
ContactImageFetcher(context, contactRepo, model))
|
||||||
}
|
}
|
||||||
|
|
||||||
class Factory(val context: Context, val prefs: Preferences) : ModelLoaderFactory<String, InputStream> {
|
class Factory(
|
||||||
|
private val context: Context,
|
||||||
|
private val prefs: Preferences
|
||||||
|
) : ModelLoaderFactory<String, InputStream> {
|
||||||
|
|
||||||
override fun build(multiFactory: MultiModelLoaderFactory): ContactImageLoader {
|
override fun build(multiFactory: MultiModelLoaderFactory): ContactImageLoader {
|
||||||
return ContactImageLoader(context, ContactRepositoryImpl(context, prefs))
|
return ContactImageLoader(context, ContactRepositoryImpl(context, prefs), PhoneNumberUtils(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun teardown() {} // nothing to do here
|
override fun teardown() {} // nothing to do here
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Moez Bhatti <moez.bhatti@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is part of QKSMS.
|
||||||
|
*
|
||||||
|
* QKSMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* QKSMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.moez.QKSMS.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.telephony.PhoneNumberUtils
|
||||||
|
import io.michaelrocks.libphonenumber.android.PhoneNumberUtil
|
||||||
|
import io.michaelrocks.libphonenumber.android.Phonenumber
|
||||||
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class PhoneNumberUtils @Inject constructor(context: Context) {
|
||||||
|
|
||||||
|
private val countryCode = Locale.getDefault().country
|
||||||
|
private val phoneNumberUtil = PhoneNumberUtil.createInstance(context)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Android's implementation is too loose and causes false positives
|
||||||
|
* libphonenumber is stricter but too slow
|
||||||
|
*
|
||||||
|
* This method will run successfully stricter checks without compromising much speed
|
||||||
|
*/
|
||||||
|
fun compare(first: String, second: String): Boolean {
|
||||||
|
if (first.equals(second, true)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PhoneNumberUtils.compare(first, second)) {
|
||||||
|
if (phoneNumberUtil.isNumberMatch(first, second) >= PhoneNumberUtil.MatchType.NSN_MATCH) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isPossibleNumber(number: CharSequence): Boolean {
|
||||||
|
val phoneNumber = parse(number) ?: return false
|
||||||
|
return phoneNumberUtil.isPossibleNumber(phoneNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isReallyDialable(digit: Char): Boolean {
|
||||||
|
return PhoneNumberUtils.isReallyDialable(digit)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun formatNumber(number: CharSequence): String {
|
||||||
|
// PhoneNumberUtil doesn't maintain country code input
|
||||||
|
return PhoneNumberUtils.formatNumber(number.toString(), countryCode) ?: number.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun normalizeNumber(number: String): String {
|
||||||
|
return PhoneNumberUtils.stripSeparators(number)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parse(number: CharSequence): Phonenumber.PhoneNumber? {
|
||||||
|
return tryOrNull(false) { phoneNumberUtil.parse(number, countryCode) }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -34,7 +34,7 @@ open class Recipient(
|
|||||||
* Return a string that can be displayed to represent the name of this contact
|
* Return a string that can be displayed to represent the name of this contact
|
||||||
*/
|
*/
|
||||||
fun getDisplayName(): String = contact?.name?.takeIf { it.isNotBlank() }
|
fun getDisplayName(): String = contact?.name?.takeIf { it.isNotBlank() }
|
||||||
?: PhoneNumberUtils.formatNumber(address, Locale.getDefault().country)
|
?: PhoneNumberUtils.formatNumber(address, Locale.getDefault().country) // TODO: Use our own PhoneNumberUtils
|
||||||
?: address
|
?: address
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,14 +29,12 @@ import android.graphics.Color
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.core.app.Person
|
import androidx.core.app.Person
|
||||||
import androidx.core.app.RemoteInput
|
import androidx.core.app.RemoteInput
|
||||||
import androidx.core.app.TaskStackBuilder
|
import androidx.core.app.TaskStackBuilder
|
||||||
import androidx.core.graphics.drawable.IconCompat
|
import androidx.core.graphics.drawable.IconCompat
|
||||||
import androidx.core.graphics.get
|
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||||
import com.moez.QKSMS.extensions.isImage
|
import com.moez.QKSMS.extensions.isImage
|
||||||
@@ -48,10 +46,10 @@ import com.moez.QKSMS.receiver.DeleteMessagesReceiver
|
|||||||
import com.moez.QKSMS.receiver.MarkReadReceiver
|
import com.moez.QKSMS.receiver.MarkReadReceiver
|
||||||
import com.moez.QKSMS.receiver.MarkSeenReceiver
|
import com.moez.QKSMS.receiver.MarkSeenReceiver
|
||||||
import com.moez.QKSMS.receiver.RemoteMessagingReceiver
|
import com.moez.QKSMS.receiver.RemoteMessagingReceiver
|
||||||
import com.moez.QKSMS.repository.ContactRepository
|
|
||||||
import com.moez.QKSMS.repository.ConversationRepository
|
import com.moez.QKSMS.repository.ConversationRepository
|
||||||
import com.moez.QKSMS.repository.MessageRepository
|
import com.moez.QKSMS.repository.MessageRepository
|
||||||
import com.moez.QKSMS.util.GlideApp
|
import com.moez.QKSMS.util.GlideApp
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import com.moez.QKSMS.util.Preferences
|
import com.moez.QKSMS.util.Preferences
|
||||||
import com.moez.QKSMS.util.tryOrNull
|
import com.moez.QKSMS.util.tryOrNull
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -64,7 +62,8 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
private val conversationRepo: ConversationRepository,
|
private val conversationRepo: ConversationRepository,
|
||||||
private val prefs: Preferences,
|
private val prefs: Preferences,
|
||||||
private val messageRepo: MessageRepository,
|
private val messageRepo: MessageRepository,
|
||||||
private val permissions: PermissionManager
|
private val permissions: PermissionManager,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
) : com.moez.QKSMS.manager.NotificationManager {
|
) : com.moez.QKSMS.manager.NotificationManager {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -151,14 +150,14 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
|
|
||||||
if (!message.isMe()) {
|
if (!message.isMe()) {
|
||||||
val recipient = conversation.recipients
|
val recipient = conversation.recipients
|
||||||
.firstOrNull { PhoneNumberUtils.compare(it.address, message.address) }
|
.firstOrNull { phoneNumberUtils.compare(it.address, message.address) }
|
||||||
|
|
||||||
person.setName(recipient?.getDisplayName() ?: message.address)
|
person.setName(recipient?.getDisplayName() ?: message.address)
|
||||||
|
|
||||||
person.setIcon(GlideApp.with(context)
|
person.setIcon(GlideApp.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
.load(PhoneNumberUtils.stripSeparators(message.address))
|
.load(message.address)
|
||||||
.submit(64.dpToPx(context), 64.dpToPx(context))
|
.submit(64.dpToPx(context), 64.dpToPx(context))
|
||||||
.let { futureGet -> tryOrNull(false) { futureGet.get() } }
|
.let { futureGet -> tryOrNull(false) { futureGet.get() } }
|
||||||
?.let(IconCompat::createWithBitmap))
|
?.let(IconCompat::createWithBitmap))
|
||||||
@@ -183,7 +182,7 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
GlideApp.with(context)
|
GlideApp.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
.load(PhoneNumberUtils.stripSeparators(address))
|
.load(address)
|
||||||
.submit(64.dpToPx(context), 64.dpToPx(context))
|
.submit(64.dpToPx(context), 64.dpToPx(context))
|
||||||
}
|
}
|
||||||
?.let { futureGet -> tryOrNull(false) { futureGet.get() } }
|
?.let { futureGet -> tryOrNull(false) { futureGet.get() } }
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import android.graphics.drawable.Icon
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.service.chooser.ChooserTarget
|
import android.service.chooser.ChooserTarget
|
||||||
import android.service.chooser.ChooserTargetService
|
import android.service.chooser.ChooserTargetService
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
@@ -59,7 +58,7 @@ class QkChooserTargetService : ChooserTargetService() {
|
|||||||
val request = GlideApp.with(this)
|
val request = GlideApp.with(this)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
.load(PhoneNumberUtils.stripSeparators(address))
|
.load(address)
|
||||||
.submit()
|
.submit()
|
||||||
val bitmap = tryOrNull(false) { request.get() }
|
val bitmap = tryOrNull(false) { request.get() }
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import android.content.pm.ShortcutInfo
|
|||||||
import android.content.pm.ShortcutManager
|
import android.content.pm.ShortcutManager
|
||||||
import android.graphics.drawable.Icon
|
import android.graphics.drawable.Icon
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.feature.compose.ComposeActivity
|
import com.moez.QKSMS.feature.compose.ComposeActivity
|
||||||
import com.moez.QKSMS.model.Conversation
|
import com.moez.QKSMS.model.Conversation
|
||||||
@@ -66,7 +65,7 @@ class ShortcutManagerImpl @Inject constructor(
|
|||||||
val request = GlideApp.with(context)
|
val request = GlideApp.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
.load(PhoneNumberUtils.stripSeparators(address))
|
.load(address)
|
||||||
.submit(shortcutManager.iconMaxWidth, shortcutManager.iconMaxHeight)
|
.submit(shortcutManager.iconMaxWidth, shortcutManager.iconMaxHeight)
|
||||||
val bitmap = tryOrNull(false) { request.get() }
|
val bitmap = tryOrNull(false) { request.get() }
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package com.moez.QKSMS.common.widget
|
package com.moez.QKSMS.common.widget
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
@@ -127,7 +126,7 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
photo.setImageDrawable(null)
|
photo.setImageDrawable(null)
|
||||||
address?.let { address ->
|
address?.let { address ->
|
||||||
GlideApp.with(photo)
|
GlideApp.with(photo)
|
||||||
.load(PhoneNumberUtils.stripSeparators(address))
|
.load(address)
|
||||||
.signature(ObjectKey(lastUpdated ?: 0L))
|
.signature(ObjectKey(lastUpdated ?: 0L))
|
||||||
.into(photo)
|
.into(photo)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -18,14 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.blocking.numbers
|
package com.moez.QKSMS.feature.blocking.numbers
|
||||||
|
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import timber.log.Timber
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class BlockedNumberTextWatcher(private val editText: EditText) : TextWatcher {
|
class BlockedNumberTextWatcher(
|
||||||
|
private val editText: EditText,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
|
) : TextWatcher {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
editText.addTextChangedListener(this)
|
editText.addTextChangedListener(this)
|
||||||
@@ -36,8 +37,7 @@ class BlockedNumberTextWatcher(private val editText: EditText) : TextWatcher {
|
|||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
val formatted = PhoneNumberUtils.formatNumber(s?.toString(), Locale.getDefault().country)
|
val formatted = s?.let(phoneNumberUtils::formatNumber)
|
||||||
Timber.v("onTextChanged=$s, formatted=$formatted")
|
|
||||||
if (s?.toString() != formatted && formatted != null) {
|
if (s?.toString() != formatted && formatted != null) {
|
||||||
editText.setText(formatted)
|
editText.setText(formatted)
|
||||||
editText.setSelection(formatted.length)
|
editText.setSelection(formatted.length)
|
||||||
|
|||||||
+3
-1
@@ -28,6 +28,7 @@ import com.moez.QKSMS.common.util.Colors
|
|||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
@@ -40,6 +41,7 @@ class BlockedNumbersController : QkController<BlockedNumbersView, BlockedNumbers
|
|||||||
|
|
||||||
@Inject override lateinit var presenter: BlockedNumbersPresenter
|
@Inject override lateinit var presenter: BlockedNumbersPresenter
|
||||||
@Inject lateinit var colors: Colors
|
@Inject lateinit var colors: Colors
|
||||||
|
@Inject lateinit var phoneNumberUtils: PhoneNumberUtils
|
||||||
|
|
||||||
private val adapter = BlockedNumbersAdapter()
|
private val adapter = BlockedNumbersAdapter()
|
||||||
private val saveAddressSubject: Subject<String> = PublishSubject.create()
|
private val saveAddressSubject: Subject<String> = PublishSubject.create()
|
||||||
@@ -75,7 +77,7 @@ class BlockedNumbersController : QkController<BlockedNumbersView, BlockedNumbers
|
|||||||
|
|
||||||
override fun showAddDialog() {
|
override fun showAddDialog() {
|
||||||
val layout = LayoutInflater.from(activity).inflate(R.layout.blocked_numbers_add_dialog, null)
|
val layout = LayoutInflater.from(activity).inflate(R.layout.blocked_numbers_add_dialog, null)
|
||||||
val textWatcher = BlockedNumberTextWatcher(layout.input)
|
val textWatcher = BlockedNumberTextWatcher(layout.input, phoneNumberUtils)
|
||||||
val dialog = AlertDialog.Builder(activity!!)
|
val dialog = AlertDialog.Builder(activity!!)
|
||||||
.setView(layout)
|
.setView(layout)
|
||||||
.setPositiveButton(R.string.blocked_numbers_dialog_block) { _, _ ->
|
.setPositiveButton(R.string.blocked_numbers_dialog_block) { _, _ ->
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package com.moez.QKSMS.feature.compose
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import android.telephony.SmsMessage
|
import android.telephony.SmsMessage
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import com.moez.QKSMS.R
|
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.ConversationRepository
|
||||||
import com.moez.QKSMS.repository.MessageRepository
|
import com.moez.QKSMS.repository.MessageRepository
|
||||||
import com.moez.QKSMS.util.ActiveSubscriptionObservable
|
import com.moez.QKSMS.util.ActiveSubscriptionObservable
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import com.moez.QKSMS.util.Preferences
|
import com.moez.QKSMS.util.Preferences
|
||||||
import com.moez.QKSMS.util.tryOrNull
|
import com.moez.QKSMS.util.tryOrNull
|
||||||
import com.uber.autodispose.android.lifecycle.scope
|
import com.uber.autodispose.android.lifecycle.scope
|
||||||
@@ -96,6 +96,7 @@ class ComposeViewModel @Inject constructor(
|
|||||||
private val messageRepo: MessageRepository,
|
private val messageRepo: MessageRepository,
|
||||||
private val navigator: Navigator,
|
private val navigator: Navigator,
|
||||||
private val permissionManager: PermissionManager,
|
private val permissionManager: PermissionManager,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils,
|
||||||
private val prefs: Preferences,
|
private val prefs: Preferences,
|
||||||
private val retrySending: RetrySending,
|
private val retrySending: RetrySending,
|
||||||
private val sendMessage: SendMessage,
|
private val sendMessage: SendMessage,
|
||||||
@@ -260,10 +261,9 @@ class ComposeViewModel @Inject constructor(
|
|||||||
.filter { contact -> contactFilter.filter(contact, normalizedQuery) }
|
.filter { contact -> contactFilter.filter(contact, normalizedQuery) }
|
||||||
|
|
||||||
// If the entry is a valid destination, allow it as a recipient
|
// If the entry is a valid destination, allow it as a recipient
|
||||||
if (PhoneNumberUtils.isWellFormedSmsAddress(query.toString())) {
|
if (phoneNumberUtils.isPossibleNumber(query.toString())) {
|
||||||
val newAddress = PhoneNumberUtils.formatNumber(query.toString(), Locale.getDefault().country)
|
val newAddress = phoneNumberUtils.formatNumber(query)
|
||||||
val newContact = Contact(numbers = RealmList(PhoneNumber(address = newAddress
|
val newContact = Contact(numbers = RealmList(PhoneNumber(address = newAddress)))
|
||||||
?: query.toString())))
|
|
||||||
filteredContacts = listOf(newContact) + filteredContacts
|
filteredContacts = listOf(newContact) + filteredContacts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.animation.ObjectAnimator
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import android.text.Layout
|
import android.text.Layout
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
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.Conversation
|
||||||
import com.moez.QKSMS.model.Message
|
import com.moez.QKSMS.model.Message
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import com.moez.QKSMS.util.Preferences
|
import com.moez.QKSMS.util.Preferences
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
@@ -72,6 +72,7 @@ class MessagesAdapter @Inject constructor(
|
|||||||
private val colors: Colors,
|
private val colors: Colors,
|
||||||
private val dateFormatter: DateFormatter,
|
private val dateFormatter: DateFormatter,
|
||||||
private val navigator: Navigator,
|
private val navigator: Navigator,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils,
|
||||||
private val prefs: Preferences,
|
private val prefs: Preferences,
|
||||||
private val textViewStyler: TextViewStyler
|
private val textViewStyler: TextViewStyler
|
||||||
) : QkRealmAdapter<Message>() {
|
) : QkRealmAdapter<Message>() {
|
||||||
@@ -322,7 +323,7 @@ class MessagesAdapter @Inject constructor(
|
|||||||
|
|
||||||
override fun get(key: String): Recipient? {
|
override fun get(key: String): Recipient? {
|
||||||
if (super.get(key)?.isValid != true) {
|
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 }
|
return super.get(key)?.takeIf { it.isValid }
|
||||||
|
|||||||
+4
-3
@@ -19,7 +19,6 @@
|
|||||||
package com.moez.QKSMS.feature.scheduled
|
package com.moez.QKSMS.feature.scheduled
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
@@ -32,6 +31,7 @@ import com.moez.QKSMS.model.Contact
|
|||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
import com.moez.QKSMS.model.ScheduledMessage
|
import com.moez.QKSMS.model.ScheduledMessage
|
||||||
import com.moez.QKSMS.repository.ContactRepository
|
import com.moez.QKSMS.repository.ContactRepository
|
||||||
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
import kotlinx.android.synthetic.main.scheduled_message_list_item.view.*
|
import kotlinx.android.synthetic.main.scheduled_message_list_item.view.*
|
||||||
@@ -39,7 +39,8 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
class ScheduledMessageAdapter @Inject constructor(
|
class ScheduledMessageAdapter @Inject constructor(
|
||||||
private val contactRepo: ContactRepository,
|
private val contactRepo: ContactRepository,
|
||||||
private val dateFormatter: DateFormatter
|
private val dateFormatter: DateFormatter,
|
||||||
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
) : QkRealmAdapter<ScheduledMessage>() {
|
) : QkRealmAdapter<ScheduledMessage>() {
|
||||||
|
|
||||||
private val contacts by lazy { contactRepo.getContacts() }
|
private val contacts by lazy { contactRepo.getContacts() }
|
||||||
@@ -91,7 +92,7 @@ class ScheduledMessageAdapter @Inject constructor(
|
|||||||
if (super.get(key)?.isValid != true) {
|
if (super.get(key)?.isValid != true) {
|
||||||
set(key, contacts.firstOrNull { contact ->
|
set(key, contacts.firstOrNull { contact ->
|
||||||
contact.numbers.any {
|
contact.numbers.any {
|
||||||
PhoneNumberUtils.compare(it.address, key)
|
phoneNumberUtils.compare(it.address, key)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import android.appwidget.AppWidgetManager
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.telephony.PhoneNumberUtils
|
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.style.StyleSpan
|
import android.text.style.StyleSpan
|
||||||
@@ -133,7 +132,7 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
|||||||
contact?.numbers?.firstOrNull()?.address?.let { address ->
|
contact?.numbers?.firstOrNull()?.address?.let { address ->
|
||||||
val futureGet = GlideApp.with(context)
|
val futureGet = GlideApp.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(PhoneNumberUtils.stripSeparators(address))
|
.load(address)
|
||||||
.submit(48.dpToPx(context), 48.dpToPx(context))
|
.submit(48.dpToPx(context), 48.dpToPx(context))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user