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:
parent
cfc16dd886
commit
cf839e99df
10 changed files with 59 additions and 2 deletions
|
|
@ -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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Added
|
||||||
|
- Option to keep conversations archived ([#334])
|
||||||
|
|
||||||
## [1.2.3] - 2025-08-21
|
## [1.2.3] - 2025-08-21
|
||||||
### Changed
|
### 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
|
[#288]: https://github.com/FossifyOrg/Messages/issues/288
|
||||||
[#294]: https://github.com/FossifyOrg/Messages/issues/294
|
[#294]: https://github.com/FossifyOrg/Messages/issues/294
|
||||||
[#309]: https://github.com/FossifyOrg/Messages/issues/309
|
[#309]: https://github.com/FossifyOrg/Messages/issues/309
|
||||||
|
[#334]: https://github.com/FossifyOrg/Messages/issues/334
|
||||||
[#349]: https://github.com/FossifyOrg/Messages/issues/349
|
[#349]: https://github.com/FossifyOrg/Messages/issues/349
|
||||||
[#359]: https://github.com/FossifyOrg/Messages/issues/359
|
[#359]: https://github.com/FossifyOrg/Messages/issues/359
|
||||||
[#461]: https://github.com/FossifyOrg/Messages/issues/461
|
[#461]: https://github.com/FossifyOrg/Messages/issues/461
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupEnableDeliveryReports()
|
setupEnableDeliveryReports()
|
||||||
setupSendLongMessageAsMMS()
|
setupSendLongMessageAsMMS()
|
||||||
setupGroupMessageAsMMS()
|
setupGroupMessageAsMMS()
|
||||||
|
setupKeepConversationsArchived()
|
||||||
setupLockScreenVisibility()
|
setupLockScreenVisibility()
|
||||||
setupMMSFileSizeLimit()
|
setupMMSFileSizeLimit()
|
||||||
setupUseRecycleBin()
|
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 {
|
private fun setupLockScreenVisibility() = binding.apply {
|
||||||
settingsLockScreenVisibility.text = getLockScreenVisibilityText()
|
settingsLockScreenVisibility.text = getLockScreenVisibilityText()
|
||||||
settingsLockScreenVisibilityHolder.setOnClickListener {
|
settingsLockScreenVisibilityHolder.setOnClickListener {
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ import org.fossify.messages.extensions.renameConversation
|
||||||
import org.fossify.messages.extensions.restoreAllMessagesFromRecycleBinForConversation
|
import org.fossify.messages.extensions.restoreAllMessagesFromRecycleBinForConversation
|
||||||
import org.fossify.messages.extensions.restoreMessageFromRecycleBin
|
import org.fossify.messages.extensions.restoreMessageFromRecycleBin
|
||||||
import org.fossify.messages.extensions.saveSmsDraft
|
import org.fossify.messages.extensions.saveSmsDraft
|
||||||
|
import org.fossify.messages.extensions.shouldUnarchive
|
||||||
import org.fossify.messages.extensions.showWithAnimation
|
import org.fossify.messages.extensions.showWithAnimation
|
||||||
import org.fossify.messages.extensions.subscriptionManagerCompat
|
import org.fossify.messages.extensions.subscriptionManagerCompat
|
||||||
import org.fossify.messages.extensions.toArrayList
|
import org.fossify.messages.extensions.toArrayList
|
||||||
|
|
@ -1640,8 +1641,10 @@ class ThreadActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
messagesDB.insertOrUpdate(message)
|
messagesDB.insertOrUpdate(message)
|
||||||
|
if (shouldUnarchive()) {
|
||||||
updateConversationArchivedStatus(message.threadId, false)
|
updateConversationArchivedStatus(message.threadId, false)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// show selected contacts, properly split to new lines when appropriate
|
// show selected contacts, properly split to new lines when appropriate
|
||||||
// based on https://stackoverflow.com/a/13505029/1967672
|
// based on https://stackoverflow.com/a/13505029/1967672
|
||||||
|
|
|
||||||
|
|
@ -1330,3 +1330,7 @@ fun Context.clearExpiredScheduledMessages(threadId: Long, messagesToDelete: List
|
||||||
fun Context.getDefaultKeyboardHeight(): Int {
|
fun Context.getDefaultKeyboardHeight(): Int {
|
||||||
return resources.getDimensionPixelSize(R.dimen.default_keyboard_height)
|
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, "")!!
|
get() = prefs.getString(LAST_BLOCKED_KEYWORD_EXPORT_PATH, "")!!
|
||||||
set(lastBlockedNumbersExportPath) = prefs.edit()
|
set(lastBlockedNumbersExportPath) = prefs.edit()
|
||||||
.putString(LAST_BLOCKED_KEYWORD_EXPORT_PATH, lastBlockedNumbersExportPath).apply()
|
.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 IS_ARCHIVE_AVAILABLE = "is_archive_available"
|
||||||
const val CUSTOM_NOTIFICATIONS = "custom_notifications"
|
const val CUSTOM_NOTIFICATIONS = "custom_notifications"
|
||||||
const val IS_LAUNCHED_FROM_SHORTCUT = "is_launched_from_shortcut"
|
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."
|
private const val PATH = "org.fossify.org.fossify.messages.action."
|
||||||
const val MARK_AS_READ = PATH + "mark_as_read"
|
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.getConversations
|
||||||
import org.fossify.messages.extensions.getLatestMMS
|
import org.fossify.messages.extensions.getLatestMMS
|
||||||
import org.fossify.messages.extensions.insertOrUpdateConversation
|
import org.fossify.messages.extensions.insertOrUpdateConversation
|
||||||
|
import org.fossify.messages.extensions.shouldUnarchive
|
||||||
import org.fossify.messages.extensions.showReceivedMessageNotification
|
import org.fossify.messages.extensions.showReceivedMessageNotification
|
||||||
|
import org.fossify.messages.extensions.updateConversationArchivedStatus
|
||||||
import org.fossify.messages.helpers.ReceiverUtils.isMessageFilteredOut
|
import org.fossify.messages.helpers.ReceiverUtils.isMessageFilteredOut
|
||||||
import org.fossify.messages.helpers.refreshMessages
|
import org.fossify.messages.helpers.refreshMessages
|
||||||
import org.fossify.messages.models.Message
|
import org.fossify.messages.models.Message
|
||||||
|
|
@ -88,6 +90,9 @@ class MmsReceiver : MmsReceivedReceiver() {
|
||||||
val conversation = context.getConversations(mms.threadId).firstOrNull()
|
val conversation = context.getConversations(mms.threadId).firstOrNull()
|
||||||
?: return@ensureBackgroundThread
|
?: return@ensureBackgroundThread
|
||||||
context.insertOrUpdateConversation(conversation)
|
context.insertOrUpdateConversation(conversation)
|
||||||
|
if (context.shouldUnarchive()) {
|
||||||
|
context.updateConversationArchivedStatus(mms.threadId, false)
|
||||||
|
}
|
||||||
refreshMessages()
|
refreshMessages()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
subscriptionId
|
subscriptionId
|
||||||
)
|
)
|
||||||
context.messagesDB.insertOrUpdate(message)
|
context.messagesDB.insertOrUpdate(message)
|
||||||
if (context.config.isArchiveAvailable) {
|
if (context.shouldUnarchive()) {
|
||||||
context.updateConversationArchivedStatus(threadId, false)
|
context.updateConversationArchivedStatus(threadId, false)
|
||||||
}
|
}
|
||||||
refreshMessages()
|
refreshMessages()
|
||||||
|
|
|
||||||
|
|
@ -351,6 +351,32 @@
|
||||||
android:id="@+id/settings_outgoing_messages_divider"
|
android:id="@+id/settings_outgoing_messages_divider"
|
||||||
layout="@layout/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
|
<TextView
|
||||||
android:id="@+id/settings_recycle_bin_label"
|
android:id="@+id/settings_recycle_bin_label"
|
||||||
style="@style/SettingsSectionLabelStyle"
|
style="@style/SettingsSectionLabelStyle"
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
<string name="no_archived_conversations">No archived conversations have been found</string>
|
<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="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="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 -->
|
<!-- Recycle bin -->
|
||||||
<string name="restore">Restore</string>
|
<string name="restore">Restore</string>
|
||||||
<string name="restore_all_messages">Restore all messages</string>
|
<string name="restore_all_messages">Restore all messages</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue