Merge branch 'master' into pr/import-fix-timestamps
This commit is contained in:
commit
011dc3393e
4 changed files with 24 additions and 18 deletions
|
|
@ -104,11 +104,9 @@ class MainActivity : SimpleActivity() {
|
||||||
useTopSearchMenu = true
|
useTopSearchMenu = true
|
||||||
)
|
)
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
checkAndDeleteOldRecycleBinMessages()
|
||||||
checkAndDeleteOldRecycleBinMessages()
|
clearAllMessagesIfNeeded {
|
||||||
clearAllMessagesIfNeeded {
|
loadMessages()
|
||||||
loadMessages()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -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,16 +1103,16 @@ 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,
|
||||||
val draftUri = Uri.withAppendedPath(Sms.CONTENT_URI, "/${draftId}")
|
showErrors = true
|
||||||
contentResolver.delete(draftUri, null, null)
|
) { cursor ->
|
||||||
}
|
val draftId = cursor.getLongValue(Sms._ID)
|
||||||
}
|
val draftUri = Uri.withAppendedPath(Sms.CONTENT_URI, "/${draftId}")
|
||||||
} catch (e: Exception) {
|
contentResolver.delete(draftUri, null, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue