Merge pull request #538 from Aga-C/show_all_drafts

Fixed showing all drafts (#537)
This commit is contained in:
Tibor Kaputa 2023-01-01 21:08:25 +01:00 committed by GitHub
commit db37ac1b19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -789,11 +789,14 @@ fun Context.getAllDrafts(): HashMap<Long, String?> {
val projection = arrayOf(Sms.BODY, Sms.THREAD_ID) val projection = arrayOf(Sms.BODY, Sms.THREAD_ID)
try { try {
queryCursor(uri, projection) { cursor -> val cursor = contentResolver.query(uri, projection, null, null, null)
cursor.use { cursor?.use {
val threadId = cursor.getLongValue(Sms.THREAD_ID) while (it.moveToNext()) {
val draft = cursor.getStringValue(Sms.BODY) ?: return@queryCursor val threadId = it.getLongValue(Sms.THREAD_ID)
drafts[threadId] = draft val draft = it.getStringValue(Sms.BODY)
if (draft != null) {
drafts[threadId] = draft
}
} }
} }
} catch (e: Exception) { } catch (e: Exception) {