Merge branch 'master' into pr/import-fix-timestamps

This commit is contained in:
Naveen Singh 2024-12-27 17:46:11 +05:30 committed by GitHub
commit 011dc3393e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 18 deletions

View file

@ -104,12 +104,10 @@ class MainActivity : SimpleActivity() {
useTopSearchMenu = true
)
if (savedInstanceState == null) {
checkAndDeleteOldRecycleBinMessages()
clearAllMessagesIfNeeded {
loadMessages()
}
}
if (checkAppSideloading()) {
return

View file

@ -307,9 +307,9 @@ class ThreadActivity : SimpleActivity() {
override fun onPause() {
super.onPause()
if (binding.messageHolder.threadTypeMessage.value != "" && getAttachmentSelections().isEmpty()) {
saveSmsDraft(binding.messageHolder.threadTypeMessage.value, threadId)
val draftMessage = binding.messageHolder.threadTypeMessage.value
if (draftMessage.isNotEmpty() && getAttachmentSelections().isEmpty()) {
saveSmsDraft(draftMessage, threadId)
} else {
deleteSmsDraft(threadId)
}
@ -969,6 +969,7 @@ class ThreadActivity : SimpleActivity() {
private fun maybeDisableShortCodeReply() {
if (isSpecialNumber() && !isRecycleBin) {
binding.messageHolder.threadTypeMessage.text?.clear()
binding.messageHolder.root.beGone()
binding.shortCodeHolder.root.beVisible()
val textColor = getProperTextColor()

View file

@ -1081,6 +1081,8 @@ fun Context.getAllDrafts(): HashMap<Long, String?> {
}
fun Context.saveSmsDraft(body: String, threadId: Long) {
deleteSmsDraft(threadId)
val uri = Sms.Draft.CONTENT_URI
val contentValues = ContentValues().apply {
put(Sms.BODY, body)
@ -1092,6 +1094,7 @@ fun Context.saveSmsDraft(body: String, threadId: Long) {
try {
contentResolver.insert(uri, contentValues)
} catch (e: Exception) {
showErrorToast(e)
}
}
@ -1100,18 +1103,18 @@ fun Context.deleteSmsDraft(threadId: Long) {
val projection = arrayOf(Sms._ID)
val selection = "${Sms.THREAD_ID} = ?"
val selectionArgs = arrayOf(threadId.toString())
try {
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
cursor.use {
if (cursor?.moveToFirst() == true) {
val draftId = cursor.getLong(0)
queryCursor(
uri = uri,
projection = projection,
selection = selection,
selectionArgs = selectionArgs,
showErrors = true
) { cursor ->
val draftId = cursor.getLongValue(Sms._ID)
val draftUri = Uri.withAppendedPath(Sms.CONTENT_URI, "/${draftId}")
contentResolver.delete(draftUri, null, null)
}
}
} catch (e: Exception) {
}
}
fun Context.updateLastConversationMessage(threadId: Long) {
updateLastConversationMessage(setOf(threadId))

View file

@ -22,6 +22,10 @@
android:fillViewport="true"
android:scrollbars="none">
<include
layout="@layout/divider"
app:layout_constraintTop_toTopOf="parent" />
<RelativeLayout
android:id="@+id/thread_add_contacts"
android:layout_width="match_parent"