mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
Properly clear messages from database
This commit is contained in:
@@ -64,7 +64,9 @@ class MainActivity : SimpleActivity() {
|
|||||||
handleAppPasswordProtection {
|
handleAppPasswordProtection {
|
||||||
wasProtectionHandled = it
|
wasProtectionHandled = it
|
||||||
if (it) {
|
if (it) {
|
||||||
loadMessages()
|
clearAllMessagesIfNeeded {
|
||||||
|
loadMessages()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
@@ -74,8 +76,6 @@ class MainActivity : SimpleActivity() {
|
|||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAllMessagesIfNeeded()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@@ -136,7 +136,6 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAllMessagesIfNeeded()
|
|
||||||
threadId = intent.getLongExtra(THREAD_ID, 0L)
|
threadId = intent.getLongExtra(THREAD_ID, 0L)
|
||||||
intent.getStringExtra(THREAD_TITLE)?.let {
|
intent.getStringExtra(THREAD_TITLE)?.let {
|
||||||
binding.threadToolbar.title = it
|
binding.threadToolbar.title = it
|
||||||
@@ -152,7 +151,9 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
handleAppPasswordProtection {
|
handleAppPasswordProtection {
|
||||||
wasProtectionHandled = it
|
wasProtectionHandled = it
|
||||||
if (it) {
|
if (it) {
|
||||||
loadConversation()
|
clearAllMessagesIfNeeded {
|
||||||
|
loadConversation()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
@@ -989,12 +989,15 @@ fun Context.getFileSizeFromUri(uri: Uri): Long {
|
|||||||
// fix a glitch at enabling Release version minifying from 5.12.3
|
// fix a glitch at enabling Release version minifying from 5.12.3
|
||||||
// reset messages in 5.14.3 again, as PhoneNumber is no longer minified
|
// reset messages in 5.14.3 again, as PhoneNumber is no longer minified
|
||||||
// reset messages in 5.19.1 again, as SimpleContact is no longer minified
|
// reset messages in 5.19.1 again, as SimpleContact is no longer minified
|
||||||
fun Context.clearAllMessagesIfNeeded() {
|
fun Context.clearAllMessagesIfNeeded(callback: () -> Unit) {
|
||||||
if (!config.wasDbCleared) {
|
if (!config.wasDbCleared) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
messagesDB.deleteAll()
|
messagesDB.deleteAll()
|
||||||
|
config.wasDbCleared = true
|
||||||
|
callback()
|
||||||
}
|
}
|
||||||
config.wasDbCleared = true
|
} else {
|
||||||
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@ const val XML_MIME_TYPE = "text/xml"
|
|||||||
const val TXT_MIME_TYPE = "text/plain"
|
const val TXT_MIME_TYPE = "text/plain"
|
||||||
const val IMPORT_SMS = "import_sms"
|
const val IMPORT_SMS = "import_sms"
|
||||||
const val IMPORT_MMS = "import_mms"
|
const val IMPORT_MMS = "import_mms"
|
||||||
const val WAS_DB_CLEARED = "was_db_cleared_3"
|
const val WAS_DB_CLEARED = "was_db_cleared_4"
|
||||||
const val EXTRA_VCARD_URI = "vcard"
|
const val EXTRA_VCARD_URI = "vcard"
|
||||||
const val SCHEDULED_MESSAGE_ID = "scheduled_message_id"
|
const val SCHEDULED_MESSAGE_ID = "scheduled_message_id"
|
||||||
const val SOFT_KEYBOARD_HEIGHT = "soft_keyboard_height"
|
const val SOFT_KEYBOARD_HEIGHT = "soft_keyboard_height"
|
||||||
|
Reference in New Issue
Block a user