Remove obsolete checks for API 23

This commit is contained in:
Moez Bhatti
2022-12-12 20:30:04 -05:00
parent ce9ba1b9f9
commit 4f2d4954ed
27 changed files with 88 additions and 282 deletions
@@ -42,28 +42,7 @@ object TelephonyCompat {
}
fun getOrCreateThreadId(context: Context, recipients: Collection<String>): Long {
return if (Build.VERSION.SDK_INT >= 23) {
Telephony.Threads.getOrCreateThreadId(context, recipients.toSet())
} else {
val uriBuilder = THREAD_ID_CONTENT_URI.buildUpon()
recipients
.map { recipient -> if (isEmailAddress(recipient)) extractAddrSpec(recipient) else recipient }
.forEach { recipient -> uriBuilder.appendQueryParameter("recipient", recipient) }
val uri = uriBuilder.build()
SqliteWrapper.query(context, context.contentResolver, uri, ID_PROJECTION, null, null, null)?.use { cursor ->
if (cursor.moveToFirst()) {
return cursor.getLong(0)
} else {
Timber.e("getOrCreateThreadId returned no rows!")
}
}
Timber.e("getOrCreateThreadId failed with " + recipients.size + " recipients")
throw IllegalArgumentException("Unable to find or allocate a thread ID.")
}
return Telephony.Threads.getOrCreateThreadId(context, recipients.toSet())
}
fun extractAddrSpec(address: String): String {