From 2da3ccad82f18ea7b2f5c662d7e8b8282bb95776 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sat, 4 Jan 2025 15:52:01 +0530 Subject: [PATCH] Don't treat emails as short codes Closes https://github.com/FossifyOrg/Messages/issues/115 --- .../org/fossify/messages/messaging/Messaging.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/messages/messaging/Messaging.kt b/app/src/main/kotlin/org/fossify/messages/messaging/Messaging.kt index 7e7aa716..ab904498 100644 --- a/app/src/main/kotlin/org/fossify/messages/messaging/Messaging.kt +++ b/app/src/main/kotlin/org/fossify/messages/messaging/Messaging.kt @@ -2,6 +2,7 @@ package org.fossify.messages.messaging import android.content.Context import android.telephony.SmsMessage +import android.util.Patterns import android.widget.Toast.LENGTH_LONG import com.klinker.android.send_message.Settings import org.fossify.commons.extensions.showErrorToast @@ -99,9 +100,13 @@ fun Context.sendMessageCompat( * Check if a given "address" is a short code. * There's not much info available on these special numbers, even the wikipedia page (https://en.wikipedia.org/wiki/Short_code) * contains outdated information regarding max number of digits. The exact parameters for short codes can vary by country and by carrier. - * - * This function simply returns true if the [address] contains at least one letter. */ fun isShortCodeWithLetters(address: String): Boolean { - return address.any { it.isLetter() } + val hasLetters = address.any { it.isLetter() } + return if (hasLetters) { + // emails are not short codes: https://github.com/FossifyOrg/Messages/issues/115 + !Patterns.EMAIL_ADDRESS.matcher(address).matches() + } else { + true + } }