Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
rapterjet2004 2024-10-23 07:26:20 -05:00
parent 39305d7e96
commit 46efdf4b0c
No known key found for this signature in database
GPG key ID: 3AA5FDFED7944099
8 changed files with 53 additions and 16 deletions

View file

@ -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"
}
/**

View file

@ -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")
}
})
}

View file

@ -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 {

View file

@ -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")
}
}
}

View file

@ -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(

View file

@ -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

View file

@ -414,6 +414,13 @@
</LinearLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/archive_conversation_text_hint"
android:layout_marginHorizontal="@dimen/standard_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/archive_hint" />
<LinearLayout
android:id="@+id/danger_zone_options"
android:layout_width="match_parent"

View file

@ -818,4 +818,6 @@ How to translate with transifex:
<string name="archive_conversation">Archive Conversation</string>
<string name="unarchive_conversation">Unarchive Conversation</string>
<string name="archived">Archived</string>
<string name="archive_hint">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.</string>
<string name="unarchive_hint">Once a conversation is unarchived, it will be shown by default again.</string>
</resources>