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 useTopSearchMenu = true
) )
if (savedInstanceState == null) {
checkAndDeleteOldRecycleBinMessages() checkAndDeleteOldRecycleBinMessages()
clearAllMessagesIfNeeded { clearAllMessagesIfNeeded {
loadMessages() loadMessages()
} }
}
if (checkAppSideloading()) { if (checkAppSideloading()) {
return return

View file

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

View file

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

View file

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