forked from upstream-mirrors/quik
Remove obsolete checks for API 23
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user