diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt
index 7f00539ab..1ceb9e553 100644
--- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt
+++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt
@@ -741,7 +741,7 @@ class ConversationInfoActivity :
}
}
- if (!spreedCapabilities.features!!.contains(ARCHIVED_CONVERSATIONS)) {
+ if (!CapabilitiesUtil.isArchiveConversationsAvailable(spreedCapabilities)) {
binding.archiveConversationBtn.visibility = GONE
}
@@ -750,19 +750,23 @@ class ConversationInfoActivity :
viewModel.unarchiveConversation(conversationUser, conversationToken)
binding.archiveConversationIcon.setImageDrawable(resources.getDrawable(R.drawable.outline_archive_24))
binding.archiveConversationText.text = resources.getString(R.string.archive_conversation)
+ binding.archiveConversationTextHint.text = resources.getString(R.string.archive_hint)
} else {
viewModel.archiveConversation(conversationUser, conversationToken)
binding.archiveConversationIcon.setImageDrawable(resources.getDrawable(R.drawable.ic_eye))
binding.archiveConversationText.text = resources.getString(R.string.unarchive_conversation)
+ binding.archiveConversationTextHint.text = resources.getString(R.string.unarchive_hint)
}
}
if (conversation!!.hasArchived) {
binding.archiveConversationIcon.setImageDrawable(resources.getDrawable(R.drawable.ic_eye))
binding.archiveConversationText.text = resources.getString(R.string.unarchive_conversation)
+ binding.archiveConversationTextHint.text = resources.getString(R.string.unarchive_hint)
} else {
binding.archiveConversationIcon.setImageDrawable(resources.getDrawable(R.drawable.outline_archive_24))
binding.archiveConversationText.text = resources.getString(R.string.archive_conversation)
+ binding.archiveConversationTextHint.text = resources.getString(R.string.archive_hint)
}
if (!isDestroyed) {
@@ -1469,7 +1473,6 @@ class ConversationInfoActivity :
private const val DEMOTE_OR_PROMOTE = 1
private const val REMOVE_FROM_CONVERSATION = 2
private const val BAN_FROM_CONVERSATION = 3
- private const val ARCHIVED_CONVERSATIONS = "archived-conversations"
}
/**
diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt
index 562e91357..f20f02a91 100644
--- a/app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt
+++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt
@@ -214,7 +214,7 @@ class ConversationInfoViewModel @Inject constructor(
}
override fun onError(e: Throwable) {
- Log.d("Julius", "Error in archive $e")
+ Log.d(TAG, "Error in archive $e")
}
override fun onComplete() {
@@ -222,7 +222,7 @@ class ConversationInfoViewModel @Inject constructor(
}
override fun onNext(n: GenericOverall) {
- Log.d("Julius", "Archived successful")
+ Log.d(TAG, "Archived successful")
}
})
}
@@ -239,7 +239,7 @@ class ConversationInfoViewModel @Inject constructor(
}
override fun onError(e: Throwable) {
- Log.d("Julius", "Error in unarchive $e")
+ Log.d(TAG, "Error in unarchive $e")
}
override fun onComplete() {
@@ -247,7 +247,7 @@ class ConversationInfoViewModel @Inject constructor(
}
override fun onNext(n: GenericOverall) {
- Log.d("Julius", "unArchived successful")
+ Log.d(TAG, "unArchived successful")
}
})
}
diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
index fcb8ad497..3a13a7f3f 100644
--- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
+++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
@@ -382,7 +382,7 @@ class ConversationsListActivity :
sortConversations(conversationItemsWithHeader)
// Filter Conversations
- if (!containsTrue()) filterableConversationItems = conversationItems
+ if (!hasFilterEnabled()) filterableConversationItems = conversationItems
filterConversation()
adapter!!.updateDataSet(filterableConversationItems, false)
Handler().postDelayed({ checkToShowUnreadBubble() }, UNREAD_BUBBLE_DELAY.toLong())
@@ -397,7 +397,7 @@ class ConversationsListActivity :
}
}
- private fun containsTrue(): Boolean {
+ private fun hasFilterEnabled(): Boolean {
for ((k, v) in filterState) {
if (k != FilterConversationFragment.DEFAULT && v) return true
}
@@ -473,7 +473,7 @@ class ConversationsListActivity :
}
}
- Log.d("Julius", "Conversation: ${conversation.name} Result: $result")
+ Log.d(TAG, "Conversation: ${conversation.name} Result: $result")
return result
}
@@ -670,7 +670,7 @@ class ConversationsListActivity :
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
initSearchDisposable()
adapter!!.setHeadersShown(true)
- if (!containsTrue()) filterableConversationItems = searchableConversationItems
+ if (!hasFilterEnabled()) filterableConversationItems = searchableConversationItems
adapter!!.updateDataSet(filterableConversationItems, false)
adapter!!.showAllHeaders()
binding.swipeRefreshLayoutView?.isEnabled = false
@@ -680,7 +680,7 @@ class ConversationsListActivity :
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
adapter!!.setHeadersShown(false)
- if (!containsTrue()) filterableConversationItems = conversationItemsWithHeader
+ if (!hasFilterEnabled()) filterableConversationItems = conversationItemsWithHeader
adapter!!.updateDataSet(filterableConversationItems, false)
adapter!!.hideAllHeaders()
if (searchHelper != null) {
@@ -1847,7 +1847,7 @@ class ConversationsListActivity :
}
fun updateFilterConversationButtonColor() {
- if (containsTrue()) {
+ if (hasFilterEnabled()) {
binding.filterConversationsButton.let { viewThemeUtils.platform.colorImageView(it, ColorRole.PRIMARY) }
} else {
binding.filterConversationsButton.let {
diff --git a/app/src/main/java/com/nextcloud/talk/data/source/local/Migrations.kt b/app/src/main/java/com/nextcloud/talk/data/source/local/Migrations.kt
index 0d357b430..49011f1ca 100644
--- a/app/src/main/java/com/nextcloud/talk/data/source/local/Migrations.kt
+++ b/app/src/main/java/com/nextcloud/talk/data/source/local/Migrations.kt
@@ -40,6 +40,13 @@ object Migrations {
}
}
+ val MIGRATION_11_12 = object : Migration(11, 12) {
+ override fun migrate(db: SupportSQLiteDatabase) {
+ Log.i("Migrations", "Migrating 11 to 12")
+ addArchiveConversations(db)
+ }
+ }
+
fun migrateToRoom(db: SupportSQLiteDatabase) {
db.execSQL(
"CREATE TABLE User_new (" +
@@ -237,4 +244,16 @@ object Migrations {
"ON `ChatBlocks` (`internalConversationId`)"
)
}
+
+ fun addArchiveConversations(db: SupportSQLiteDatabase) {
+
+ try {
+ db.execSQL(
+ "ALTER TABLE Conversations " +
+ "ADD `hasArchived` INTEGER;"
+ )
+ } catch (e: Exception) {
+ Log.i("Migrations", "hasArchived already exists")
+ }
+ }
}
diff --git a/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt b/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt
index a0d053d90..053ad4766 100644
--- a/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt
+++ b/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt
@@ -49,9 +49,9 @@ import java.util.Locale
ChatMessageEntity::class,
ChatBlockEntity::class
],
- version = 11,
+ version = 12,
autoMigrations = [
- AutoMigration(from = 9, to = 10)
+ AutoMigration(from = 9, to = 11)
],
exportSchema = true
)
@@ -113,7 +113,8 @@ abstract class TalkDatabase : RoomDatabase() {
Migrations.MIGRATION_6_8,
Migrations.MIGRATION_7_8,
Migrations.MIGRATION_8_9,
- Migrations.MIGRATION_10_11
+ Migrations.MIGRATION_10_11,
+ Migrations.MIGRATION_11_12
)
.allowMainThreadQueries()
.addCallback(
diff --git a/app/src/main/java/com/nextcloud/talk/utils/CapabilitiesUtil.kt b/app/src/main/java/com/nextcloud/talk/utils/CapabilitiesUtil.kt
index 0a02bd914..996262296 100644
--- a/app/src/main/java/com/nextcloud/talk/utils/CapabilitiesUtil.kt
+++ b/app/src/main/java/com/nextcloud/talk/utils/CapabilitiesUtil.kt
@@ -55,7 +55,8 @@ enum class SpreedFeatures(val value: String) {
FEDERATION_V1("federation-v1"),
DELETE_MESSAGES_UNLIMITED("delete-messages-unlimited"),
BAN_V1("ban-v1"),
- EDIT_MESSAGES_NOTE_TO_SELF("edit-messages-note-to-self")
+ EDIT_MESSAGES_NOTE_TO_SELF("edit-messages-note-to-self"),
+ ARCHIVE_CONVERSATIONS("archived-conversations")
}
@Suppress("TooManyFunctions")
@@ -255,6 +256,10 @@ object CapabilitiesUtil {
user.capabilities!!.spreedCapability!!.config!!["federation"]!!.containsKey("enabled")
}
+ fun isArchiveConversationsAvailable(spreedCapabilities: SpreedCapability): Boolean {
+ return hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.ARCHIVE_CONVERSATIONS)
+ }
+
// endregion
//region ThemingCapabilities
diff --git a/app/src/main/res/layout/activity_conversation_info.xml b/app/src/main/res/layout/activity_conversation_info.xml
index 8168c8531..ded8afea1 100644
--- a/app/src/main/res/layout/activity_conversation_info.xml
+++ b/app/src/main/res/layout/activity_conversation_info.xml
@@ -414,6 +414,13 @@
+
+
Archive Conversation
Unarchive Conversation
Archived
+ Once a conversation is archived, it will be hidden by default. Select the filter \'Archived\' to view archived conversations. Direct mentions will still be received.
+ Once a conversation is unarchived, it will be shown by default again.