Skip to content

Commit

Permalink
Add a temporary feature that fixes all conversation timestamps, trigg…
Browse files Browse the repository at this point in the history
…ered by importing then pressing back
  • Loading branch information
tom93 committed Apr 9, 2024
1 parent 0d4ce78 commit 9007331
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import org.fossify.messages.helpers.*
import java.util.Locale
import kotlin.system.exitProcess

import android.provider.Telephony.Threads
import org.fossify.messages.extensions.*

class SettingsActivity : SimpleActivity() {
private var blockedNumbersAtPause = -1
private var recycleBinMessages = 0
Expand Down Expand Up @@ -90,9 +93,36 @@ class SettingsActivity : SimpleActivity() {
}
}

private fun debug(message: String) {
System.err.println("XXX $message")
toast(message)
}

private fun debug(e: Exception) {
e.printStackTrace()
toast(e.toString())
}

private val getContent = registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
if (uri != null) {
MessagesImporter(this).importMessages(uri)
} else {
ensureBackgroundThread {
debug("Fixing conversation timestamps...")
try {
// based on updateLastConversationMessage(), with the fix from #149, and modified to update *all* conversations
val uri = Threads.CONTENT_URI
val selection = "1 = 0" // always-false condition, because we don't actually want to delete any messages
contentResolver.delete(uri, selection, null)
val conversations = getConversations()
for (conversation in conversations) {
insertOrUpdateConversation(conversation)
}
debug("Finished processing ${conversations.size} conversations")
} catch (e: Exception) {
debug(e)
}
}
}
}

Expand Down

0 comments on commit 9007331

Please sign in to comment.