mirror of
https://github.com/FossifyOrg/Messages.git
synced 2025-12-24 00:00:16 -05:00
feat: add option to keep conversations archived (#501)
* feat: add option to keep conversations archived Refs: https://github.com/FossifyOrg/Messages/issues/334 * fix: archive/unarchive when mms is received Previously, conversations weren't unarchived for new MMS messages. * docs: update changelog
This commit is contained in:
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Option to keep conversations archived ([#334])
|
||||
|
||||
## [1.2.3] - 2025-08-21
|
||||
### Changed
|
||||
@@ -134,6 +136,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
[#288]: https://github.com/FossifyOrg/Messages/issues/288
|
||||
[#294]: https://github.com/FossifyOrg/Messages/issues/294
|
||||
[#309]: https://github.com/FossifyOrg/Messages/issues/309
|
||||
[#334]: https://github.com/FossifyOrg/Messages/issues/334
|
||||
[#349]: https://github.com/FossifyOrg/Messages/issues/349
|
||||
[#359]: https://github.com/FossifyOrg/Messages/issues/359
|
||||
[#461]: https://github.com/FossifyOrg/Messages/issues/461
|
||||
|
||||
@@ -120,6 +120,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupEnableDeliveryReports()
|
||||
setupSendLongMessageAsMMS()
|
||||
setupGroupMessageAsMMS()
|
||||
setupKeepConversationsArchived()
|
||||
setupLockScreenVisibility()
|
||||
setupMMSFileSizeLimit()
|
||||
setupUseRecycleBin()
|
||||
@@ -310,6 +311,14 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupKeepConversationsArchived() = binding.apply {
|
||||
settingsKeepConversationsArchived.isChecked = config.keepConversationsArchived
|
||||
settingsKeepConversationsArchivedHolder.setOnClickListener {
|
||||
settingsKeepConversationsArchived.toggle()
|
||||
config.keepConversationsArchived = settingsKeepConversationsArchived.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupLockScreenVisibility() = binding.apply {
|
||||
settingsLockScreenVisibility.text = getLockScreenVisibilityText()
|
||||
settingsLockScreenVisibilityHolder.setOnClickListener {
|
||||
|
||||
@@ -141,6 +141,7 @@ import org.fossify.messages.extensions.renameConversation
|
||||
import org.fossify.messages.extensions.restoreAllMessagesFromRecycleBinForConversation
|
||||
import org.fossify.messages.extensions.restoreMessageFromRecycleBin
|
||||
import org.fossify.messages.extensions.saveSmsDraft
|
||||
import org.fossify.messages.extensions.shouldUnarchive
|
||||
import org.fossify.messages.extensions.showWithAnimation
|
||||
import org.fossify.messages.extensions.subscriptionManagerCompat
|
||||
import org.fossify.messages.extensions.toArrayList
|
||||
@@ -1640,7 +1641,9 @@ class ThreadActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
messagesDB.insertOrUpdate(message)
|
||||
updateConversationArchivedStatus(message.threadId, false)
|
||||
if (shouldUnarchive()) {
|
||||
updateConversationArchivedStatus(message.threadId, false)
|
||||
}
|
||||
}
|
||||
|
||||
// show selected contacts, properly split to new lines when appropriate
|
||||
|
||||
@@ -1330,3 +1330,7 @@ fun Context.clearExpiredScheduledMessages(threadId: Long, messagesToDelete: List
|
||||
fun Context.getDefaultKeyboardHeight(): Int {
|
||||
return resources.getDimensionPixelSize(R.dimen.default_keyboard_height)
|
||||
}
|
||||
|
||||
fun Context.shouldUnarchive(): Boolean {
|
||||
return config.isArchiveAvailable && !config.keepConversationsArchived
|
||||
}
|
||||
|
||||
@@ -143,4 +143,9 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
get() = prefs.getString(LAST_BLOCKED_KEYWORD_EXPORT_PATH, "")!!
|
||||
set(lastBlockedNumbersExportPath) = prefs.edit()
|
||||
.putString(LAST_BLOCKED_KEYWORD_EXPORT_PATH, lastBlockedNumbersExportPath).apply()
|
||||
|
||||
var keepConversationsArchived: Boolean
|
||||
get() = prefs.getBoolean(KEEP_CONVERSATIONS_ARCHIVED, false)
|
||||
set(keepConversationsArchived) = prefs.edit()
|
||||
.putBoolean(KEEP_CONVERSATIONS_ARCHIVED, keepConversationsArchived).apply()
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ const val IS_RECYCLE_BIN = "is_recycle_bin"
|
||||
const val IS_ARCHIVE_AVAILABLE = "is_archive_available"
|
||||
const val CUSTOM_NOTIFICATIONS = "custom_notifications"
|
||||
const val IS_LAUNCHED_FROM_SHORTCUT = "is_launched_from_shortcut"
|
||||
const val KEEP_CONVERSATIONS_ARCHIVED = "keep_conversations_archived"
|
||||
|
||||
private const val PATH = "org.fossify.org.fossify.messages.action."
|
||||
const val MARK_AS_READ = PATH + "mark_as_read"
|
||||
|
||||
@@ -17,7 +17,9 @@ import org.fossify.messages.R
|
||||
import org.fossify.messages.extensions.getConversations
|
||||
import org.fossify.messages.extensions.getLatestMMS
|
||||
import org.fossify.messages.extensions.insertOrUpdateConversation
|
||||
import org.fossify.messages.extensions.shouldUnarchive
|
||||
import org.fossify.messages.extensions.showReceivedMessageNotification
|
||||
import org.fossify.messages.extensions.updateConversationArchivedStatus
|
||||
import org.fossify.messages.helpers.ReceiverUtils.isMessageFilteredOut
|
||||
import org.fossify.messages.helpers.refreshMessages
|
||||
import org.fossify.messages.models.Message
|
||||
@@ -88,6 +90,9 @@ class MmsReceiver : MmsReceivedReceiver() {
|
||||
val conversation = context.getConversations(mms.threadId).firstOrNull()
|
||||
?: return@ensureBackgroundThread
|
||||
context.insertOrUpdateConversation(conversation)
|
||||
if (context.shouldUnarchive()) {
|
||||
context.updateConversationArchivedStatus(mms.threadId, false)
|
||||
}
|
||||
refreshMessages()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class SmsReceiver : BroadcastReceiver() {
|
||||
subscriptionId
|
||||
)
|
||||
context.messagesDB.insertOrUpdate(message)
|
||||
if (context.config.isArchiveAvailable) {
|
||||
if (context.shouldUnarchive()) {
|
||||
context.updateConversationArchivedStatus(threadId, false)
|
||||
}
|
||||
refreshMessages()
|
||||
|
||||
@@ -351,6 +351,32 @@
|
||||
android:id="@+id/settings_outgoing_messages_divider"
|
||||
layout="@layout/divider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_archived_messages_label"
|
||||
style="@style/SettingsSectionLabelStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/archive" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_keep_conversations_archived_holder"
|
||||
style="@style/SettingsHolderSwitchStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<org.fossify.commons.views.MyMaterialSwitch
|
||||
android:id="@+id/settings_keep_conversations_archived"
|
||||
style="@style/SettingsSwitchStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/keep_conversations_archived" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/settings_archive_divider"
|
||||
layout="@layout/divider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_recycle_bin_label"
|
||||
style="@style/SettingsSectionLabelStyle"
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
<string name="no_archived_conversations">No archived conversations have been found</string>
|
||||
<string name="archive_emptied_successfully">The archive has been emptied successfully</string>
|
||||
<string name="empty_archive_confirmation">Are you sure you want to empty the archive? All archived conversations will be permanently lost.</string>
|
||||
<string name="keep_conversations_archived">Keep conversations archived</string>
|
||||
<!-- Recycle bin -->
|
||||
<string name="restore">Restore</string>
|
||||
<string name="restore_all_messages">Restore all messages</string>
|
||||
|
||||
Reference in New Issue
Block a user