diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt index 4002775c..8b99d1e4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt @@ -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 } } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index a26b7aa1..40b7d207 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ConversationsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ConversationsAdapter.kt index c7897ff0..8a4995c1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ConversationsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ConversationsAdapter.kt @@ -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) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt index 0bd22f23..b213314e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt @@ -263,7 +263,7 @@ fun Context.getMMSSender(msgId: Long): String { } fun Context.getConversations(threadId: Long? = null, privateContacts: ArrayList = ArrayList()): ArrayList { - 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 diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt index 8522b33b..99230836 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt @@ -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() } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/SmsReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/SmsReceiver.kt index d748b1e3..3544adeb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/SmsReceiver.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/SmsReceiver.kt @@ -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()