Merge pull request #361 from Naveen3Singh/address_space_glitch

Fix address separator glitch
This commit is contained in:
Tibor Kaputa 2022-06-17 00:09:33 +02:00 committed by GitHub
commit 4a3520553f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 24 deletions

View File

@ -65,7 +65,7 @@ dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:faa6a972c2' implementation 'com.github.SimpleMobileTools:Simple-Commons:faa6a972c2'
implementation 'org.greenrobot:eventbus:3.3.1' implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61' implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
implementation 'com.github.tibbi:android-smsmms:9162ca7456' implementation 'com.github.tibbi:android-smsmms:a9ca153fbf'
implementation "me.leolin:ShortcutBadger:1.1.22" implementation "me.leolin:ShortcutBadger:1.1.22"
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

View File

@ -61,15 +61,14 @@ class NewConversationActivity : SimpleActivity() {
} }
fetchContacts() fetchContacts()
new_conversation_address.onTextChangeListener { new_conversation_address.onTextChangeListener { searchString ->
val searchString = it
val filteredContacts = ArrayList<SimpleContact>() val filteredContacts = ArrayList<SimpleContact>()
allContacts.forEach { allContacts.forEach { contact ->
if (it.phoneNumbers.any { it.normalizedNumber.contains(searchString, true) } || if (contact.phoneNumbers.any { it.normalizedNumber.contains(searchString, true) } ||
it.name.contains(searchString, true) || contact.name.contains(searchString, true) ||
it.name.contains(searchString.normalizeString(), true) || contact.name.contains(searchString.normalizeString(), true) ||
it.name.normalizeString().contains(searchString, true)) { contact.name.normalizeString().contains(searchString, true)) {
filteredContacts.add(it) filteredContacts.add(contact)
} }
} }

View File

@ -432,8 +432,8 @@ class ThreadActivity : SimpleActivity() {
thread_add_contacts.beGone() thread_add_contacts.beGone()
val numbers = HashSet<String>() val numbers = HashSet<String>()
participants.forEach { participants.forEach { contact ->
it.phoneNumbers.forEach { contact.phoneNumbers.forEach {
numbers.add(it.normalizedNumber) numbers.add(it.normalizedNumber)
} }
} }
@ -465,8 +465,8 @@ class ThreadActivity : SimpleActivity() {
} }
private fun setupAttachmentSizes() { private fun setupAttachmentSizes() {
messages.filter { it.attachment != null }.forEach { messages.filter { it.attachment != null }.forEach { message ->
it.attachment!!.attachments.forEach { message.attachment!!.attachments.forEach {
try { try {
if (it.mimetype.startsWith("image/")) { if (it.mimetype.startsWith("image/")) {
val fileOptions = BitmapFactory.Options() val fileOptions = BitmapFactory.Options()
@ -527,8 +527,8 @@ class ThreadActivity : SimpleActivity() {
} }
val numbers = ArrayList<String>() val numbers = ArrayList<String>()
participants.forEach { participants.forEach { contact ->
it.phoneNumbers.forEach { contact.phoneNumbers.forEach {
numbers.add(it.normalizedNumber) numbers.add(it.normalizedNumber)
} }
} }
@ -612,8 +612,7 @@ class ThreadActivity : SimpleActivity() {
val properPrimaryColor = getProperPrimaryColor() val properPrimaryColor = getProperPrimaryColor()
val views = ArrayList<View>() val views = ArrayList<View>()
participants.forEach { participants.forEach { contact ->
val contact = it
layoutInflater.inflate(R.layout.item_selected_contact, null).apply { layoutInflater.inflate(R.layout.item_selected_contact, null).apply {
val selectedContactBg = resources.getDrawable(R.drawable.item_selected_contact_background) val selectedContactBg = resources.getDrawable(R.drawable.item_selected_contact_background)
(selectedContactBg as LayerDrawable).findDrawableByLayerId(R.id.selected_contact_bg).applyColorFilter(properPrimaryColor) (selectedContactBg as LayerDrawable).findDrawableByLayerId(R.id.selected_contact_bg).applyColorFilter(properPrimaryColor)
@ -843,8 +842,8 @@ class ThreadActivity : SimpleActivity() {
msg = removeDiacriticsIfNeeded(msg) msg = removeDiacriticsIfNeeded(msg)
val numbers = ArrayList<String>() val numbers = ArrayList<String>()
participants.forEach { participants.forEach { contact ->
it.phoneNumbers.forEach { contact.phoneNumbers.forEach {
numbers.add(it.normalizedNumber) numbers.add(it.normalizedNumber)
} }
} }
@ -1047,7 +1046,7 @@ class ThreadActivity : SimpleActivity() {
messages.filter { !it.isReceivedMessage() && it.id > lastMaxId }.forEach { latestMessage -> messages.filter { !it.isReceivedMessage() && it.id > lastMaxId }.forEach { latestMessage ->
// subscriptionIds seem to be not filled out at sending with multiple SIM cards, so fill it manually // subscriptionIds seem to be not filled out at sending with multiple SIM cards, so fill it manually
if (SubscriptionManager.from(this).activeSubscriptionInfoList?.size ?: 0 > 1) { if ((SubscriptionManager.from(this).activeSubscriptionInfoList?.size ?: 0) > 1) {
val SIMId = availableSIMCards.getOrNull(currentSIMCardIndex)?.subscriptionId val SIMId = availableSIMCards.getOrNull(currentSIMCardIndex)?.subscriptionId
if (SIMId != null) { if (SIMId != null) {
updateMessageSubscriptionId(latestMessage.id, SIMId) updateMessageSubscriptionId(latestMessage.id, SIMId)

View File

@ -26,6 +26,7 @@ import android.text.TextUtils
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.RemoteInput import androidx.core.app.RemoteInput
import com.klinker.android.send_message.Settings import com.klinker.android.send_message.Settings
import com.klinker.android.send_message.Transaction.getAddressSeparator
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.PhoneNumber
@ -104,7 +105,7 @@ fun Context.getMessages(threadId: Long, getImageResolutions: Boolean, dateFrom:
val thread = cursor.getLongValue(Sms.THREAD_ID) val thread = cursor.getLongValue(Sms.THREAD_ID)
val subscriptionId = cursor.getIntValue(Sms.SUBSCRIPTION_ID) val subscriptionId = cursor.getIntValue(Sms.SUBSCRIPTION_ID)
val status = cursor.getIntValue(Sms.STATUS) val status = cursor.getIntValue(Sms.STATUS)
val participants = senderNumber.split(" ").map { number -> val participants = senderNumber.split(getAddressSeparator().toRegex()).map { number ->
val phoneNumber = PhoneNumber(number, 0, "", number) val phoneNumber = PhoneNumber(number, 0, "", number)
val participantPhoto = getNameAndPhotoFromPhoneNumber(number) val participantPhoto = getNameAndPhotoFromPhoneNumber(number)
SimpleContact(0, 0, participantPhoto.name, photoUri, arrayListOf(phoneNumber), ArrayList(), ArrayList()) SimpleContact(0, 0, participantPhoto.name, photoUri, arrayListOf(phoneNumber), ArrayList(), ArrayList())
@ -813,7 +814,12 @@ fun Context.showMessageNotification(address: String, body: String, threadId: Lon
notificationManager.notify(threadId.hashCode(), builder.build()) notificationManager.notify(threadId.hashCode(), builder.build())
} }
private fun Context.getMessagesStyle(notificationManager: NotificationManager, threadId: Long, sender: String, body: String): NotificationCompat.MessagingStyle { private fun Context.getMessagesStyle(
notificationManager: NotificationManager,
threadId: Long,
sender: String,
body: String
): NotificationCompat.MessagingStyle {
val oldMessages = getOldMessages(notificationManager, threadId) val oldMessages = getOldMessages(notificationManager, threadId)
val messages = NotificationCompat.MessagingStyle(getString(R.string.me)) val messages = NotificationCompat.MessagingStyle(getString(R.string.me))
oldMessages.forEach { oldMessages.forEach {

View File

@ -27,7 +27,7 @@ class DirectReplyReceiver : BroadcastReceiver() {
val settings = context.getSendMessageSettings() val settings = context.getSendMessageSettings()
if (address != null) { if (address != null) {
val availableSIMs = SubscriptionManager.from(context).activeSubscriptionInfoList val availableSIMs = SubscriptionManager.from(context).activeSubscriptionInfoList
if (availableSIMs?.size ?: 0 > 1) { if ((availableSIMs?.size ?: 0) > 1) {
val currentSIMCardIndex = context.config.getUseSIMIdAtNumber(address) val currentSIMCardIndex = context.config.getUseSIMIdAtNumber(address)
val wantedId = availableSIMs.getOrNull(currentSIMCardIndex) val wantedId = availableSIMs.getOrNull(currentSIMCardIndex)
if (wantedId != null) { if (wantedId != null) {

View File

@ -21,6 +21,7 @@ import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.extensions.* import com.simplemobiletools.smsmessenger.extensions.*
import com.simplemobiletools.smsmessenger.helpers.refreshMessages import com.simplemobiletools.smsmessenger.helpers.refreshMessages
import com.simplemobiletools.smsmessenger.models.Message import com.simplemobiletools.smsmessenger.models.Message
import kotlin.math.min
class SmsReceiver : BroadcastReceiver() { class SmsReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
@ -42,7 +43,7 @@ class SmsReceiver : BroadcastReceiver() {
subject = it.pseudoSubject subject = it.pseudoSubject
status = it.status status = it.status
body += it.messageBody body += it.messageBody
date = Math.min(it.timestampMillis, System.currentTimeMillis()) date = min(it.timestampMillis, System.currentTimeMillis())
threadId = context.getThreadId(address) threadId = context.getThreadId(address)
} }