Disable replying to non-numeric short codes

Also, break down large thread layout file
This commit is contained in:
Naveen 2023-01-06 18:30:19 +05:30
parent 7665415b87
commit f0c3333a72
7 changed files with 340 additions and 212 deletions

View file

@ -59,3 +59,16 @@ fun Context.sendMessageCompat(text: String, addresses: List<String>, subId: Int?
}
}
/**
* 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 returns true if the [address] length is less than or equal to [maxLength] and contains at least one letter.
*/
fun isShortCodeWithLetters(address: String, maxLength: Int = 10): Boolean {
if (address.length > maxLength) {
return false
}
return address.any { it.isLetter() }
}