Rename `useThreadsArchive` to `isArchiveAvailable` for clarity
This commit is contained in:
parent
0e68da2710
commit
e41630e543
|
@ -187,7 +187,7 @@ class MainActivity : SimpleActivity() {
|
|||
binding.mainMenu.getToolbar().menu.apply {
|
||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)
|
||||
findItem(R.id.show_recycle_bin).isVisible = config.useRecycleBin
|
||||
findItem(R.id.show_archived).isVisible = config.useThreadsArchive
|
||||
findItem(R.id.show_archived).isVisible = config.isArchiveAvailable
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -249,12 +249,12 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
private fun refreshMenuItems() {
|
||||
val firstPhoneNumber = participants.firstOrNull()?.phoneNumbers?.firstOrNull()?.value
|
||||
val useArchive = config.useThreadsArchive
|
||||
val archiveAvailable = config.isArchiveAvailable
|
||||
binding.threadToolbar.menu.apply {
|
||||
findItem(R.id.delete).isVisible = threadItems.isNotEmpty()
|
||||
findItem(R.id.restore).isVisible = threadItems.isNotEmpty() && isRecycleBin
|
||||
findItem(R.id.archive).isVisible = threadItems.isNotEmpty() && conversation?.isArchived == false && !isRecycleBin && useArchive
|
||||
findItem(R.id.unarchive).isVisible = threadItems.isNotEmpty() && conversation?.isArchived == true && !isRecycleBin && useArchive
|
||||
findItem(R.id.archive).isVisible = threadItems.isNotEmpty() && conversation?.isArchived == false && !isRecycleBin && archiveAvailable
|
||||
findItem(R.id.unarchive).isVisible = threadItems.isNotEmpty() && conversation?.isArchived == true && !isRecycleBin && archiveAvailable
|
||||
findItem(R.id.rename_conversation).isVisible = participants.size > 1 && conversation != null && !isRecycleBin
|
||||
findItem(R.id.conversation_details).isVisible = conversation != null && !isRecycleBin
|
||||
findItem(R.id.block_number).title = addLockedLabelIfNeeded(com.simplemobiletools.commons.R.string.block_number)
|
||||
|
|
|
@ -28,7 +28,7 @@ class ConversationsAdapter(
|
|||
val isSingleSelection = isOneItemSelected()
|
||||
val selectedConversation = selectedItems.firstOrNull() ?: return
|
||||
val isGroupConversation = selectedConversation.isGroupConversation
|
||||
val useArchive = activity.config.useThreadsArchive
|
||||
val archiveAvailable = activity.config.isArchiveAvailable
|
||||
|
||||
menu.apply {
|
||||
findItem(R.id.cab_block_number).title = activity.addLockedLabelIfNeeded(com.simplemobiletools.commons.R.string.block_number)
|
||||
|
@ -39,7 +39,7 @@ class ConversationsAdapter(
|
|||
findItem(R.id.cab_rename_conversation).isVisible = isSingleSelection && isGroupConversation
|
||||
findItem(R.id.cab_mark_as_read).isVisible = selectedItems.any { !it.read }
|
||||
findItem(R.id.cab_mark_as_unread).isVisible = selectedItems.any { it.read }
|
||||
findItem(R.id.cab_archive).isVisible = useArchive
|
||||
findItem(R.id.cab_archive).isVisible = archiveAvailable
|
||||
checkPinBtnVisibility(this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ fun Context.getMMSSender(msgId: Long): String {
|
|||
}
|
||||
|
||||
fun Context.getConversations(threadId: Long? = null, privateContacts: ArrayList<SimpleContact> = ArrayList()): ArrayList<Conversation> {
|
||||
val useArchive = config.useThreadsArchive
|
||||
val archiveAvailable = config.isArchiveAvailable
|
||||
|
||||
val uri = Uri.parse("${Threads.CONTENT_URI}?simple=true")
|
||||
val projection = mutableListOf(
|
||||
|
@ -274,7 +274,7 @@ fun Context.getConversations(threadId: Long? = null, privateContacts: ArrayList<
|
|||
Threads.RECIPIENT_IDS,
|
||||
)
|
||||
|
||||
if (useArchive) {
|
||||
if (archiveAvailable) {
|
||||
projection += Threads.ARCHIVED
|
||||
}
|
||||
|
||||
|
@ -315,13 +315,13 @@ fun Context.getConversations(threadId: Long? = null, privateContacts: ArrayList<
|
|||
val photoUri = if (phoneNumbers.size == 1) simpleContactHelper.getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
||||
val isGroupConversation = phoneNumbers.size > 1
|
||||
val read = cursor.getIntValue(Threads.READ) == 1
|
||||
val archived = if (useArchive) cursor.getIntValue(Threads.ARCHIVED) == 1 else false
|
||||
val archived = if (archiveAvailable) cursor.getIntValue(Threads.ARCHIVED) == 1 else false
|
||||
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation, phoneNumbers.first(), isArchived = archived)
|
||||
conversations.add(conversation)
|
||||
}
|
||||
} catch (sqliteException: SQLiteException) {
|
||||
if (sqliteException.message?.contains("no such column: archived") == true && useArchive) {
|
||||
config.useThreadsArchive = false
|
||||
if (sqliteException.message?.contains("no such column: archived") == true && archiveAvailable) {
|
||||
config.isArchiveAvailable = false
|
||||
return getConversations(threadId, privateContacts)
|
||||
} else {
|
||||
showErrorToast(sqliteException)
|
||||
|
@ -751,8 +751,8 @@ fun Context.updateConversationArchivedStatus(threadId: Long, archived: Boolean)
|
|||
try {
|
||||
contentResolver.update(uri, values, selection, selectionArgs)
|
||||
} catch (sqliteException: SQLiteException) {
|
||||
if (sqliteException.message?.contains("no such column: archived") == true && config.useThreadsArchive) {
|
||||
config.useThreadsArchive = false
|
||||
if (sqliteException.message?.contains("no such column: archived") == true && config.isArchiveAvailable) {
|
||||
config.isArchiveAvailable = false
|
||||
return
|
||||
} else {
|
||||
throw sqliteException
|
||||
|
|
|
@ -112,7 +112,7 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getLong(LAST_RECYCLE_BIN_CHECK, 0L)
|
||||
set(lastRecycleBinCheck) = prefs.edit().putLong(LAST_RECYCLE_BIN_CHECK, lastRecycleBinCheck).apply()
|
||||
|
||||
var useThreadsArchive: Boolean
|
||||
var isArchiveAvailable: Boolean
|
||||
get() = prefs.getBoolean(USE_THREADS_ARCHIVE, true)
|
||||
set(useThreadsArchive) = prefs.edit().putBoolean(USE_THREADS_ARCHIVE, useThreadsArchive).apply()
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
subscriptionId
|
||||
)
|
||||
context.messagesDB.insertOrUpdate(message)
|
||||
if (context.config.useThreadsArchive) {
|
||||
if (context.config.isArchiveAvailable) {
|
||||
context.updateConversationArchivedStatus(threadId, false)
|
||||
}
|
||||
refreshMessages()
|
||||
|
|
Loading…
Reference in New Issue