Clear empty drafts caused by version 1.1.1
See https://github.com/FossifyOrg/Messages/issues/274
This commit is contained in:
parent
2853be9e2c
commit
b1d5452459
2 changed files with 19 additions and 1 deletions
|
|
@ -60,6 +60,7 @@ import org.fossify.messages.databinding.ActivityMainBinding
|
|||
import org.fossify.messages.extensions.checkAndDeleteOldRecycleBinMessages
|
||||
import org.fossify.messages.extensions.clearAllMessagesIfNeeded
|
||||
import org.fossify.messages.extensions.clearExpiredScheduledMessages
|
||||
import org.fossify.messages.extensions.clearSystemDrafts
|
||||
import org.fossify.messages.extensions.config
|
||||
import org.fossify.messages.extensions.conversationsDB
|
||||
import org.fossify.messages.extensions.getConversations
|
||||
|
|
@ -287,7 +288,7 @@ class MainActivity : SimpleActivity() {
|
|||
checkWhatsNewDialog()
|
||||
storeStateVariables()
|
||||
getCachedConversations()
|
||||
|
||||
clearSystemDrafts()
|
||||
binding.noConversationsPlaceholder2.setOnClickListener {
|
||||
launchNewConversation()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1102,6 +1102,23 @@ fun Context.deleteSmsDraft(threadId: Long) {
|
|||
}
|
||||
}
|
||||
|
||||
// Revert changes done by version 1.1.1 (https://github.com/FossifyOrg/Messages/issues/274)
|
||||
fun Context.clearSystemDrafts() {
|
||||
ensureBackgroundThread {
|
||||
val uri = Sms.Draft.CONTENT_URI
|
||||
val projection = arrayOf(Sms._ID, Sms.BODY)
|
||||
queryCursor(uri = uri, projection = projection) { cursor ->
|
||||
val draftId = cursor.getLongValue(Sms._ID)
|
||||
val body = cursor.getStringValue(Sms.BODY) ?: return@queryCursor
|
||||
if (body.isEmpty() || body.isBlank()) {
|
||||
val draftUri = Uri.withAppendedPath(Sms.CONTENT_URI, "/${draftId}")
|
||||
contentResolver.delete(draftUri, null, null)
|
||||
return@queryCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.updateLastConversationMessage(threadId: Long) {
|
||||
updateLastConversationMessage(setOf(threadId))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue