From 4803712ca31052d0a4a8227bab88c33f52800b20 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Tue, 20 May 2025 16:54:59 +0200 Subject: [PATCH 01/10] add endpoints and hasImportant variable Signed-off-by: sowjanyakch --- .../java/com/nextcloud/talk/api/NcApiCoroutines.kt | 13 +++++++++++++ .../data/database/mappers/ConversationMapUtils.kt | 9 ++++++--- .../talk/data/database/model/ConversationEntity.kt | 3 ++- .../talk/models/domain/ConversationModel.kt | 5 +++-- .../talk/models/json/conversations/Conversation.kt | 5 ++++- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt b/app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt index 168932dff..aa356b95f 100644 --- a/app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt +++ b/app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt @@ -179,6 +179,19 @@ interface NcApiCoroutines { @Url url: String ): GenericOverall + + @POST + suspend fun markConversationAsImportant( + @Header("Authorization") authorization: String, + @Url url: String + ): GenericOverall + + @DELETE + suspend fun markConversationAsUnimportant( + @Header("Authorization") authorization: String, + @Url url: String + ): GenericOverall + @DELETE suspend fun removeConversationFromFavorites( @Header("Authorization") authorization: String, diff --git a/app/src/main/java/com/nextcloud/talk/data/database/mappers/ConversationMapUtils.kt b/app/src/main/java/com/nextcloud/talk/data/database/mappers/ConversationMapUtils.kt index 5353bbf7c..dd28633e3 100644 --- a/app/src/main/java/com/nextcloud/talk/data/database/mappers/ConversationMapUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/data/database/mappers/ConversationMapUtils.kt @@ -62,7 +62,8 @@ fun ConversationModel.asEntity() = remoteServer = remoteServer, remoteToken = remoteToken, hasArchived = hasArchived, - hasSensitive = hasSensitive + hasSensitive = hasSensitive, + hasImportant = hasImportant ) fun ConversationEntity.asModel() = @@ -115,7 +116,8 @@ fun ConversationEntity.asModel() = remoteServer = remoteServer, remoteToken = remoteToken, hasArchived = hasArchived, - hasSensitive = hasSensitive + hasSensitive = hasSensitive, + hasImportant = hasImportant ) fun Conversation.asEntity(accountId: Long) = @@ -167,5 +169,6 @@ fun Conversation.asEntity(accountId: Long) = remoteServer = remoteServer, remoteToken = remoteToken, hasArchived = hasArchived, - hasSensitive = hasSensitive + hasSensitive = hasSensitive, + hasImportant = hasImportant ) diff --git a/app/src/main/java/com/nextcloud/talk/data/database/model/ConversationEntity.kt b/app/src/main/java/com/nextcloud/talk/data/database/model/ConversationEntity.kt index dd71050bb..8cdd4db58 100644 --- a/app/src/main/java/com/nextcloud/talk/data/database/model/ConversationEntity.kt +++ b/app/src/main/java/com/nextcloud/talk/data/database/model/ConversationEntity.kt @@ -95,7 +95,8 @@ data class ConversationEntity( @ColumnInfo(name = "unreadMentionDirect") var unreadMentionDirect: Boolean, @ColumnInfo(name = "unreadMessages") var unreadMessages: Int = 0, @ColumnInfo(name = "hasArchived") var hasArchived: Boolean = false, - @ColumnInfo(name = "hasSensitive") var hasSensitive: Boolean = false + @ColumnInfo(name = "hasSensitive") var hasSensitive: Boolean = false, + @ColumnInfo(name = "hasImportant") var hasImportant: Boolean = false // missing/not needed: attendeeId // missing/not needed: attendeePin // missing/not needed: attendeePermissions diff --git a/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt b/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt index 6f87e672c..fbbfc6c46 100644 --- a/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt +++ b/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt @@ -62,10 +62,10 @@ class ConversationModel( var remoteToken: String? = null, var hasArchived: Boolean = false, var hasSensitive: Boolean = false, + var hasImportant:Boolean = false, // attributes that don't come from API. This should be changed?! var password: String? = null - ) { companion object { @@ -128,7 +128,8 @@ class ConversationModel( remoteServer = conversation.remoteServer, remoteToken = conversation.remoteToken, hasArchived = conversation.hasArchived, - hasSensitive = conversation.hasSensitive + hasSensitive = conversation.hasSensitive, + hasImportant = conversation.hasImportant ) } } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt index 3bb542a75..c6750a2ec 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt @@ -168,5 +168,8 @@ data class Conversation( var hasArchived: Boolean = false, @JsonField(name = ["isSensitive"]) - var hasSensitive: Boolean = false + var hasSensitive: Boolean = false, + + @JsonField(name = ["isImportant"]) + var hasImportant: Boolean = false ) : Parcelable From 799d10870807365b95ff44bab3ab7d6e3fa43fc7 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Tue, 20 May 2025 17:09:10 +0200 Subject: [PATCH 02/10] add repo and repo implementation Signed-off-by: sowjanyakch --- .../conversations/ConversationsRepository.kt | 5 +++++ .../ConversationsRepositoryImpl.kt | 18 ++++++++++++++++++ .../java/com/nextcloud/talk/utils/ApiUtils.kt | 4 ++++ .../nextcloud/talk/utils/CapabilitiesUtil.kt | 3 ++- app/src/main/res/values/strings.xml | 3 +++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt index 74366ed6e..bda3839d5 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt @@ -53,4 +53,9 @@ interface ConversationsRepository { suspend fun markConversationAsSensitive(credentials: String, baseUrl: String, roomToken: String): GenericOverall suspend fun markConversationAsInsensitive(credentials: String, baseUrl: String, roomToken: String): GenericOverall + + suspend fun markConversationAsImportant(credentials: String, baseUrl: String, roomToken: String): GenericOverall + + suspend fun markConversationAsUnImportant(credentials: String, baseUrl: String, roomToken: String): GenericOverall } + diff --git a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepositoryImpl.kt index 8b06228a9..f46469f70 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepositoryImpl.kt @@ -139,6 +139,24 @@ class ConversationsRepositoryImpl( return coroutineApi.markConversationAsInsensitive(credentials, url) } + override suspend fun markConversationAsImportant( + credentials: String, + baseUrl: String, + roomToken: String + ): GenericOverall { + val url = ApiUtils.getUrlForImportantConversation(baseUrl, roomToken) + return coroutineApi.markConversationAsImportant(credentials, url) + } + + override suspend fun markConversationAsUnImportant( + credentials: String, + baseUrl: String, + roomToken: String + ): GenericOverall { + val url = ApiUtils.getUrlForImportantConversation(baseUrl, roomToken) + return coroutineApi.markConversationAsUnimportant(credentials, url) + } + override suspend fun banActor( credentials: String, url: String, diff --git a/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.kt index bc5903acc..fe258be3c 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.kt @@ -205,6 +205,10 @@ object ApiUtils { return getUrlForParticipants(version, baseUrl, token) + "/active" } + fun getUrlForImportantConversation(baseUrl: String, roomToken: String): String { + return "$baseUrl$OCS_API_VERSION/apps/spreed/api/v4/room/$roomToken/important" + } + @JvmStatic fun getUrlForParticipantsSelf(version: Int, baseUrl: String?, token: String?): String { return getUrlForParticipants(version, baseUrl, token) + "/self" 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 e27bd75bf..329787ac1 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/CapabilitiesUtil.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/CapabilitiesUtil.kt @@ -59,7 +59,8 @@ enum class SpreedFeatures(val value: String) { ARCHIVE_CONVERSATIONS("archived-conversations-v2"), CONVERSATION_CREATION_ALL("conversation-creation-all"), UNBIND_CONVERSATION("unbind-conversation"), - SENSITIVE_CONVERSATIONS("sensitive-conversations") + SENSITIVE_CONVERSATIONS("sensitive-conversations"), + IMPORTANT_CONVERSATIONS("important-conversations") } @Suppress("TooManyFunctions") diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2be132c4f..b292ac92f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -242,6 +242,8 @@ How to translate with transifex: All messages were deleted Conversation marked as sensitive Conversation unmarked as sensitive + Conversation marked as important + Conversation unmarked as important Rename conversation Rename Delete conversation @@ -350,6 +352,7 @@ How to translate with transifex: Sensitive conversation Message preview will be disabled in conversation list and notifications Important conversation + Ignore Do not disturb Notifications in this conversation will override Do Not Disturb settings OK, all done! From 7548ce58b544151fd5aa078e423473f79cb4ff90 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Tue, 20 May 2025 18:10:17 +0200 Subject: [PATCH 03/10] mark conversation as important / unimportant Signed-off-by: sowjanyakch --- .../14.json | 12 ++- .../ConversationInfoActivity.kt | 84 ++++++++++++++++--- .../viewmodel/ConversationInfoViewModel.kt | 51 +++++++++++ .../DatabaseStorageModule.kt | 28 +++---- .../res/layout/item_notification_settings.xml | 3 +- app/src/main/res/values/strings.xml | 3 +- 6 files changed, 150 insertions(+), 31 deletions(-) diff --git a/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/14.json b/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/14.json index cc73f1e94..dfabb1af3 100644 --- a/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/14.json +++ b/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/14.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 14, - "identityHash": "506abc931eb3b657cafe6ad1b25f635d", + "identityHash": "d977dea7f7b5cc6d466a4aeb68c538fb", "entities": [ { "tableName": "User", @@ -122,7 +122,7 @@ }, { "tableName": "Conversations", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`internalId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `token` TEXT NOT NULL, `displayName` TEXT NOT NULL, `actorId` TEXT NOT NULL, `actorType` TEXT NOT NULL, `avatarVersion` TEXT NOT NULL, `callFlag` INTEGER NOT NULL, `callRecording` INTEGER NOT NULL, `callStartTime` INTEGER NOT NULL, `canDeleteConversation` INTEGER NOT NULL, `canLeaveConversation` INTEGER NOT NULL, `canStartCall` INTEGER NOT NULL, `description` TEXT NOT NULL, `hasCall` INTEGER NOT NULL, `hasPassword` INTEGER NOT NULL, `isCustomAvatar` INTEGER NOT NULL, `isFavorite` INTEGER NOT NULL, `lastActivity` INTEGER NOT NULL, `lastCommonReadMessage` INTEGER NOT NULL, `lastMessage` TEXT, `lastPing` INTEGER NOT NULL, `lastReadMessage` INTEGER NOT NULL, `lobbyState` TEXT NOT NULL, `lobbyTimer` INTEGER NOT NULL, `messageExpiration` INTEGER NOT NULL, `name` TEXT NOT NULL, `notificationCalls` INTEGER NOT NULL, `notificationLevel` TEXT NOT NULL, `objectType` TEXT NOT NULL, `objectId` TEXT NOT NULL, `participantType` TEXT NOT NULL, `permissions` INTEGER NOT NULL, `readOnly` TEXT NOT NULL, `recordingConsent` INTEGER NOT NULL, `remoteServer` TEXT, `remoteToken` TEXT, `sessionId` TEXT NOT NULL, `status` TEXT, `statusClearAt` INTEGER, `statusIcon` TEXT, `statusMessage` TEXT, `type` TEXT NOT NULL, `unreadMention` INTEGER NOT NULL, `unreadMentionDirect` INTEGER NOT NULL, `unreadMessages` INTEGER NOT NULL, `hasArchived` INTEGER NOT NULL, PRIMARY KEY(`internalId`), FOREIGN KEY(`accountId`) REFERENCES `User`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`internalId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `token` TEXT NOT NULL, `displayName` TEXT NOT NULL, `actorId` TEXT NOT NULL, `actorType` TEXT NOT NULL, `avatarVersion` TEXT NOT NULL, `callFlag` INTEGER NOT NULL, `callRecording` INTEGER NOT NULL, `callStartTime` INTEGER NOT NULL, `canDeleteConversation` INTEGER NOT NULL, `canLeaveConversation` INTEGER NOT NULL, `canStartCall` INTEGER NOT NULL, `description` TEXT NOT NULL, `hasCall` INTEGER NOT NULL, `hasPassword` INTEGER NOT NULL, `isCustomAvatar` INTEGER NOT NULL, `isFavorite` INTEGER NOT NULL, `lastActivity` INTEGER NOT NULL, `lastCommonReadMessage` INTEGER NOT NULL, `lastMessage` TEXT, `lastPing` INTEGER NOT NULL, `lastReadMessage` INTEGER NOT NULL, `lobbyState` TEXT NOT NULL, `lobbyTimer` INTEGER NOT NULL, `messageExpiration` INTEGER NOT NULL, `name` TEXT NOT NULL, `notificationCalls` INTEGER NOT NULL, `notificationLevel` TEXT NOT NULL, `objectType` TEXT NOT NULL, `objectId` TEXT NOT NULL, `participantType` TEXT NOT NULL, `permissions` INTEGER NOT NULL, `readOnly` TEXT NOT NULL, `recordingConsent` INTEGER NOT NULL, `remoteServer` TEXT, `remoteToken` TEXT, `sessionId` TEXT NOT NULL, `status` TEXT, `statusClearAt` INTEGER, `statusIcon` TEXT, `statusMessage` TEXT, `type` TEXT NOT NULL, `unreadMention` INTEGER NOT NULL, `unreadMentionDirect` INTEGER NOT NULL, `unreadMessages` INTEGER NOT NULL, `hasArchived` INTEGER NOT NULL, `hasImportant` INTEGER NOT NULL, PRIMARY KEY(`internalId`), FOREIGN KEY(`accountId`) REFERENCES `User`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", "fields": [ { "fieldPath": "internalId", @@ -398,6 +398,12 @@ "columnName": "hasArchived", "affinity": "INTEGER", "notNull": true + }, + { + "fieldPath": "hasImportant", + "columnName": "hasImportant", + "affinity": "INTEGER", + "notNull": true } ], "primaryKey": { @@ -713,7 +719,7 @@ ], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '506abc931eb3b657cafe6ad1b25f635d')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd977dea7f7b5cc6d466a4aeb68c538fb')" ] } } \ No newline at end of file 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 ff5acdbe4..8db02892e 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt @@ -252,6 +252,8 @@ class ConversationInfoActivity : initClearChatHistoryObserver() initMarkConversationAsSensitiveObserver() initMarkConversationAsInsensitiveObserver() + initMarkConversationAsImportantObserver() + initMarkConversationAsUnimportantObserver() } private fun initMarkConversationAsSensitiveObserver() { @@ -381,7 +383,46 @@ class ConversationInfoActivity : } } - @SuppressLint("SetTextI18n") + private fun initMarkConversationAsImportantObserver() { + viewModel.markAsImportantResult.observe(this) { uiState -> + when (uiState) { + is ConversationInfoViewModel.MarkConversationAsImportantViewState.Success -> { + binding.root, + context.getString(R.string.nc_mark_conversation_as_important), + Snackbar.LENGTH_LONG + ).show() + } + is ConversationInfoViewModel.MarkConversationAsImportantViewState.Error -> { + Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show() + Log.e(TAG, "failed to mark conversation as important", uiState.exception) + } + else -> { + } + } + } + } + + + private fun initMarkConversationAsUnimportantObserver() { + viewModel.markAsUnimportantResult.observe(this) { uiState -> + when (uiState) { + is ConversationInfoViewModel.MarkConversationAsUnimportantViewState.Success -> { + Snackbar.make( + binding.root, + context.getString(R.string.nc_mark_conversation_as_unimportant), + Snackbar.LENGTH_LONG + ).show() + } + is ConversationInfoViewModel.MarkConversationAsUnimportantViewState.Error -> { + Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show() + Log.e(TAG, "failed to mark conversation as unimportant", uiState.exception) + } + else -> { + } + } + } + } + private fun initViewStateObserver() { viewModel.viewState.observe(this) { state -> when (state) { @@ -1025,6 +1066,29 @@ class ConversationInfoActivity : } } + binding.notificationSettingsView.importantConversationSwitch.isChecked = conversation!!.hasImportant + + binding.notificationSettingsView.importantConversationSwitch.setOnCheckedChangeListener { _, isChecked -> + if (isChecked) { + viewModel.markConversationAsImportant( + credentials, + conversationUser.baseUrl!!, + conversation?.token!! + ) + } else { + viewModel.markConversationAsUnimportant( + credentials, + conversationUser.baseUrl!!, + conversation?.token!! + ) + } + } + if (hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.IMPORTANT_CONVERSATIONS)) { + binding.notificationSettingsView.notificationSettingsImportantConversation.visibility = VISIBLE + } else { + binding.notificationSettingsView.notificationSettingsImportantConversation.visibility = GONE + } + if (!hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.ARCHIVE_CONVERSATIONS)) { binding.archiveConversationBtn.visibility = GONE binding.archiveConversationTextHint.visibility = GONE @@ -1756,13 +1820,13 @@ class ConversationInfoActivity : } private fun setUpNotificationSettings(module: DatabaseStorageModule) { - binding.notificationSettingsView.notificationSettingsImportantConversation.setOnClickListener { - val isChecked = binding.notificationSettingsView.importantConversationSwitch.isChecked - binding.notificationSettingsView.importantConversationSwitch.isChecked = !isChecked - lifecycleScope.launch { - module.saveBoolean("important_conversation_switch", !isChecked) - } - } + // binding.notificationSettingsView.notificationSettingsImportantConversation.setOnClickListener { + // val isChecked = binding.notificationSettingsView.importantConversationSwitch.isChecked + // binding.notificationSettingsView.importantConversationSwitch.isChecked = !isChecked + // lifecycleScope.launch { + // module.saveBoolean("important_conversation_switch", !isChecked) + // } + // } binding.notificationSettingsView.notificationSettingsCallNotifications.setOnClickListener { val isChecked = binding.notificationSettingsView.callNotificationsSwitch.isChecked binding.notificationSettingsView.callNotificationsSwitch.isChecked = !isChecked @@ -1780,8 +1844,8 @@ class ConversationInfoActivity : } } - binding.notificationSettingsView.importantConversationSwitch.isChecked = module - .getBoolean("important_conversation_switch", false) + // binding.notificationSettingsView.importantConversationSwitch.isChecked = module + // .getBoolean("important_conversation_switch", false) if (conversation!!.remoteServer.isNullOrEmpty()) { binding.notificationSettingsView.notificationSettingsCallNotifications.visibility = VISIBLE 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 b9008c91a..ea67f57d4 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 @@ -124,6 +124,16 @@ class ConversationInfoViewModel @Inject constructor( val getConversationReadOnlyState: LiveData get() = _getConversationReadOnlyState + private val _markConversationAsImportantResult = + MutableLiveData(MarkConversationAsImportantViewState.None) + val markAsImportantResult: LiveData + get() = _markConversationAsImportantResult + + private val _markConversationAsUnimportantResult = + MutableLiveData(MarkConversationAsUnimportantViewState.None) + val markAsUnimportantResult: LiveData + get() = _markConversationAsUnimportantResult + private val _createRoomViewState = MutableLiveData(CreateRoomUIState.None) val createRoomViewState: LiveData get() = _createRoomViewState @@ -356,6 +366,35 @@ class ConversationInfoViewModel @Inject constructor( conversationsRepository.unarchiveConversation(user.getCredentials(), url) } + + @Suppress("Detekt.TooGenericExceptionCaught") + fun markConversationAsImportant(credentials: String, baseUrl: String, roomToken: String) { + viewModelScope.launch { + try { + val response = conversationsRepository.markConversationAsImportant(credentials, baseUrl, roomToken) + _markConversationAsImportantResult.value = + MarkConversationAsImportantViewState.Success(response.ocs?.meta?.statusCode!!) + } catch (exception: Exception) { + _markConversationAsImportantResult.value = + MarkConversationAsImportantViewState.Error(exception) + } + } + } + + @Suppress("Detekt.TooGenericExceptionCaught") + fun markConversationAsUnimportant(credentials: String, baseUrl: String, roomToken: String) { + viewModelScope.launch { + try { + val response = conversationsRepository.markConversationAsImportant(credentials, baseUrl, roomToken) + _markConversationAsUnimportantResult.value = + MarkConversationAsUnimportantViewState.Success(response.ocs?.meta?.statusCode!!) + } catch (exception: Exception) { + _markConversationAsUnimportantResult.value = + MarkConversationAsUnimportantViewState.Error(exception) + } + } + } + @Suppress("Detekt.TooGenericExceptionCaught") fun clearChatHistory(apiVersion: Int, roomToken: String) { viewModelScope.launch { @@ -480,4 +519,16 @@ class ConversationInfoViewModel @Inject constructor( data object Success : PasswordUiState() data class Error(val exception: Exception) : PasswordUiState() } + + sealed class MarkConversationAsImportantViewState { + data object None : MarkConversationAsImportantViewState() + data class Success(val statusCode: Int) : MarkConversationAsImportantViewState() + data class Error(val exception: Exception) : MarkConversationAsImportantViewState() + } + + sealed class MarkConversationAsUnimportantViewState { + data object None : MarkConversationAsUnimportantViewState() + data class Success(val statusCode: Int) : MarkConversationAsUnimportantViewState() + data class Error(val exception: Exception) : MarkConversationAsUnimportantViewState() + } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt index 1bfe577f7..080c909b3 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt @@ -65,20 +65,20 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) { @Suppress("Detekt.TooGenericExceptionCaught") suspend fun saveBoolean(key: String, value: Boolean) { - if ("call_notifications_switch" == key) { - val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4)) - val url = getUrlForRoomNotificationCalls(apiVersion, conversationUser.baseUrl, conversationToken) - val credentials = getCredentials(conversationUser.username, conversationUser.token) - val notificationLevel = if (value) 1 else 0 - withContext(Dispatchers.IO) { - try { - ncApiCoroutines!!.notificationCalls(credentials!!, url, notificationLevel) - Log.d(TAG, "Toggled notification calls") - } catch (e: Exception) { - Log.e(TAG, "Error when trying to toggle notification calls", e) - } - } - } + // if ("call_notifications_switch" == key) { + // val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4)) + // val url = getUrlForRoomNotificationCalls(apiVersion, conversationUser.baseUrl, conversationToken) + // val credentials = getCredentials(conversationUser.username, conversationUser.token) + // val notificationLevel = if (value) 1 else 0 + // withContext(Dispatchers.IO) { + // try { + // ncApiCoroutines!!.notificationCalls(credentials!!, url, notificationLevel) + // Log.d(TAG, "Toggled notification calls") + // } catch (e: Exception) { + // Log.e(TAG, "Error when trying to toggle notification calls", e) + // } + // } + // } if ("lobby_switch" != key) { arbitraryStorageManager!!.storeStorageSetting( accountIdentifier, diff --git a/app/src/main/res/layout/item_notification_settings.xml b/app/src/main/res/layout/item_notification_settings.xml index c5a958b7e..b22268a22 100644 --- a/app/src/main/res/layout/item_notification_settings.xml +++ b/app/src/main/res/layout/item_notification_settings.xml @@ -61,8 +61,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_marginStart="@dimen/standard_margin" - android:clickable="false" /> + android:layout_marginStart="@dimen/standard_margin" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b292ac92f..230d168bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -352,8 +352,7 @@ How to translate with transifex: Sensitive conversation Message preview will be disabled in conversation list and notifications Important conversation - Ignore Do not disturb - Notifications in this conversation will override Do Not Disturb settings + \"Do not disturb\" user status is ignored for important conversations OK, all done! OK From 62041d2581c2a841caace6a2b624a694ce8c7ca9 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Tue, 20 May 2025 18:31:50 +0200 Subject: [PATCH 04/10] refactor Signed-off-by: sowjanyakch --- app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt | 1 - .../nextcloud/talk/conversationinfo/ConversationInfoActivity.kt | 2 +- .../conversationinfo/viewmodel/ConversationInfoViewModel.kt | 1 - .../talk/repositories/conversations/ConversationsRepository.kt | 1 - .../preferences/preferencestorage/DatabaseStorageModule.kt | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt b/app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt index aa356b95f..a2e58dcd1 100644 --- a/app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt +++ b/app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt @@ -179,7 +179,6 @@ interface NcApiCoroutines { @Url url: String ): GenericOverall - @POST suspend fun markConversationAsImportant( @Header("Authorization") authorization: String, 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 8db02892e..48a48c6fe 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt @@ -387,6 +387,7 @@ class ConversationInfoActivity : viewModel.markAsImportantResult.observe(this) { uiState -> when (uiState) { is ConversationInfoViewModel.MarkConversationAsImportantViewState.Success -> { + Snackbar.make( binding.root, context.getString(R.string.nc_mark_conversation_as_important), Snackbar.LENGTH_LONG @@ -402,7 +403,6 @@ class ConversationInfoActivity : } } - private fun initMarkConversationAsUnimportantObserver() { viewModel.markAsUnimportantResult.observe(this) { uiState -> when (uiState) { 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 ea67f57d4..d530f1c13 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 @@ -366,7 +366,6 @@ class ConversationInfoViewModel @Inject constructor( conversationsRepository.unarchiveConversation(user.getCredentials(), url) } - @Suppress("Detekt.TooGenericExceptionCaught") fun markConversationAsImportant(credentials: String, baseUrl: String, roomToken: String) { viewModelScope.launch { diff --git a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt index bda3839d5..2a6e8dd69 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt @@ -58,4 +58,3 @@ interface ConversationsRepository { suspend fun markConversationAsUnImportant(credentials: String, baseUrl: String, roomToken: String): GenericOverall } - diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt index 080c909b3..7a34e7d4e 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt @@ -22,7 +22,6 @@ import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ApiUtils.getConversationApiVersion import com.nextcloud.talk.utils.ApiUtils.getCredentials import com.nextcloud.talk.utils.ApiUtils.getUrlForMessageExpiration -import com.nextcloud.talk.utils.ApiUtils.getUrlForRoomNotificationCalls import com.nextcloud.talk.utils.ApiUtils.getUrlForRoomNotificationLevel import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability import com.nextcloud.talk.utils.SpreedFeatures From 38482b8bb55157fa0be0dbab24884b72fe0e734c Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Wed, 21 May 2025 17:02:46 +0200 Subject: [PATCH 05/10] mark conversation as important Signed-off-by: sowjanyakch --- .../ConversationInfoActivity.kt | 16 +++------- .../viewmodel/ConversationInfoViewModel.kt | 2 +- .../DatabaseStorageModule.kt | 29 ++++++++++--------- .../res/layout/item_notification_settings.xml | 5 ++-- 4 files changed, 23 insertions(+), 29 deletions(-) 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 48a48c6fe..7fe172344 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt @@ -1068,8 +1068,10 @@ class ConversationInfoActivity : binding.notificationSettingsView.importantConversationSwitch.isChecked = conversation!!.hasImportant - binding.notificationSettingsView.importantConversationSwitch.setOnCheckedChangeListener { _, isChecked -> - if (isChecked) { + binding.notificationSettingsView.notificationSettingsImportantConversation.setOnClickListener { + val isChecked = binding.notificationSettingsView.importantConversationSwitch.isChecked + binding.notificationSettingsView.importantConversationSwitch.isChecked = !isChecked + if (!isChecked) { viewModel.markConversationAsImportant( credentials, conversationUser.baseUrl!!, @@ -1820,13 +1822,6 @@ class ConversationInfoActivity : } private fun setUpNotificationSettings(module: DatabaseStorageModule) { - // binding.notificationSettingsView.notificationSettingsImportantConversation.setOnClickListener { - // val isChecked = binding.notificationSettingsView.importantConversationSwitch.isChecked - // binding.notificationSettingsView.importantConversationSwitch.isChecked = !isChecked - // lifecycleScope.launch { - // module.saveBoolean("important_conversation_switch", !isChecked) - // } - // } binding.notificationSettingsView.notificationSettingsCallNotifications.setOnClickListener { val isChecked = binding.notificationSettingsView.callNotificationsSwitch.isChecked binding.notificationSettingsView.callNotificationsSwitch.isChecked = !isChecked @@ -1844,9 +1839,6 @@ class ConversationInfoActivity : } } - // binding.notificationSettingsView.importantConversationSwitch.isChecked = module - // .getBoolean("important_conversation_switch", false) - if (conversation!!.remoteServer.isNullOrEmpty()) { binding.notificationSettingsView.notificationSettingsCallNotifications.visibility = VISIBLE binding.notificationSettingsView.callNotificationsSwitch.isChecked = module 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 d530f1c13..428c4b4af 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 @@ -384,7 +384,7 @@ class ConversationInfoViewModel @Inject constructor( fun markConversationAsUnimportant(credentials: String, baseUrl: String, roomToken: String) { viewModelScope.launch { try { - val response = conversationsRepository.markConversationAsImportant(credentials, baseUrl, roomToken) + val response = conversationsRepository.markConversationAsUnImportant(credentials, baseUrl, roomToken) _markConversationAsUnimportantResult.value = MarkConversationAsUnimportantViewState.Success(response.ocs?.meta?.statusCode!!) } catch (exception: Exception) { diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt index 7a34e7d4e..1bfe577f7 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt @@ -22,6 +22,7 @@ import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ApiUtils.getConversationApiVersion import com.nextcloud.talk.utils.ApiUtils.getCredentials import com.nextcloud.talk.utils.ApiUtils.getUrlForMessageExpiration +import com.nextcloud.talk.utils.ApiUtils.getUrlForRoomNotificationCalls import com.nextcloud.talk.utils.ApiUtils.getUrlForRoomNotificationLevel import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability import com.nextcloud.talk.utils.SpreedFeatures @@ -64,20 +65,20 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) { @Suppress("Detekt.TooGenericExceptionCaught") suspend fun saveBoolean(key: String, value: Boolean) { - // if ("call_notifications_switch" == key) { - // val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4)) - // val url = getUrlForRoomNotificationCalls(apiVersion, conversationUser.baseUrl, conversationToken) - // val credentials = getCredentials(conversationUser.username, conversationUser.token) - // val notificationLevel = if (value) 1 else 0 - // withContext(Dispatchers.IO) { - // try { - // ncApiCoroutines!!.notificationCalls(credentials!!, url, notificationLevel) - // Log.d(TAG, "Toggled notification calls") - // } catch (e: Exception) { - // Log.e(TAG, "Error when trying to toggle notification calls", e) - // } - // } - // } + if ("call_notifications_switch" == key) { + val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4)) + val url = getUrlForRoomNotificationCalls(apiVersion, conversationUser.baseUrl, conversationToken) + val credentials = getCredentials(conversationUser.username, conversationUser.token) + val notificationLevel = if (value) 1 else 0 + withContext(Dispatchers.IO) { + try { + ncApiCoroutines!!.notificationCalls(credentials!!, url, notificationLevel) + Log.d(TAG, "Toggled notification calls") + } catch (e: Exception) { + Log.e(TAG, "Error when trying to toggle notification calls", e) + } + } + } if ("lobby_switch" != key) { arbitraryStorageManager!!.storeStorageSetting( accountIdentifier, diff --git a/app/src/main/res/layout/item_notification_settings.xml b/app/src/main/res/layout/item_notification_settings.xml index b22268a22..9caf96d78 100644 --- a/app/src/main/res/layout/item_notification_settings.xml +++ b/app/src/main/res/layout/item_notification_settings.xml @@ -46,7 +46,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/nc_important_conversation" - android:textSize="@dimen/headline_text_size" /> + android:textSize="@dimen/headline_text_size" + android:clickable="false"/> + android:clickable="false"/> Date: Wed, 21 May 2025 17:07:21 +0200 Subject: [PATCH 06/10] revert 14.json Signed-off-by: sowjanyakch --- .../14.json | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/14.json b/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/14.json index dfabb1af3..cc73f1e94 100644 --- a/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/14.json +++ b/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/14.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 14, - "identityHash": "d977dea7f7b5cc6d466a4aeb68c538fb", + "identityHash": "506abc931eb3b657cafe6ad1b25f635d", "entities": [ { "tableName": "User", @@ -122,7 +122,7 @@ }, { "tableName": "Conversations", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`internalId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `token` TEXT NOT NULL, `displayName` TEXT NOT NULL, `actorId` TEXT NOT NULL, `actorType` TEXT NOT NULL, `avatarVersion` TEXT NOT NULL, `callFlag` INTEGER NOT NULL, `callRecording` INTEGER NOT NULL, `callStartTime` INTEGER NOT NULL, `canDeleteConversation` INTEGER NOT NULL, `canLeaveConversation` INTEGER NOT NULL, `canStartCall` INTEGER NOT NULL, `description` TEXT NOT NULL, `hasCall` INTEGER NOT NULL, `hasPassword` INTEGER NOT NULL, `isCustomAvatar` INTEGER NOT NULL, `isFavorite` INTEGER NOT NULL, `lastActivity` INTEGER NOT NULL, `lastCommonReadMessage` INTEGER NOT NULL, `lastMessage` TEXT, `lastPing` INTEGER NOT NULL, `lastReadMessage` INTEGER NOT NULL, `lobbyState` TEXT NOT NULL, `lobbyTimer` INTEGER NOT NULL, `messageExpiration` INTEGER NOT NULL, `name` TEXT NOT NULL, `notificationCalls` INTEGER NOT NULL, `notificationLevel` TEXT NOT NULL, `objectType` TEXT NOT NULL, `objectId` TEXT NOT NULL, `participantType` TEXT NOT NULL, `permissions` INTEGER NOT NULL, `readOnly` TEXT NOT NULL, `recordingConsent` INTEGER NOT NULL, `remoteServer` TEXT, `remoteToken` TEXT, `sessionId` TEXT NOT NULL, `status` TEXT, `statusClearAt` INTEGER, `statusIcon` TEXT, `statusMessage` TEXT, `type` TEXT NOT NULL, `unreadMention` INTEGER NOT NULL, `unreadMentionDirect` INTEGER NOT NULL, `unreadMessages` INTEGER NOT NULL, `hasArchived` INTEGER NOT NULL, `hasImportant` INTEGER NOT NULL, PRIMARY KEY(`internalId`), FOREIGN KEY(`accountId`) REFERENCES `User`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`internalId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `token` TEXT NOT NULL, `displayName` TEXT NOT NULL, `actorId` TEXT NOT NULL, `actorType` TEXT NOT NULL, `avatarVersion` TEXT NOT NULL, `callFlag` INTEGER NOT NULL, `callRecording` INTEGER NOT NULL, `callStartTime` INTEGER NOT NULL, `canDeleteConversation` INTEGER NOT NULL, `canLeaveConversation` INTEGER NOT NULL, `canStartCall` INTEGER NOT NULL, `description` TEXT NOT NULL, `hasCall` INTEGER NOT NULL, `hasPassword` INTEGER NOT NULL, `isCustomAvatar` INTEGER NOT NULL, `isFavorite` INTEGER NOT NULL, `lastActivity` INTEGER NOT NULL, `lastCommonReadMessage` INTEGER NOT NULL, `lastMessage` TEXT, `lastPing` INTEGER NOT NULL, `lastReadMessage` INTEGER NOT NULL, `lobbyState` TEXT NOT NULL, `lobbyTimer` INTEGER NOT NULL, `messageExpiration` INTEGER NOT NULL, `name` TEXT NOT NULL, `notificationCalls` INTEGER NOT NULL, `notificationLevel` TEXT NOT NULL, `objectType` TEXT NOT NULL, `objectId` TEXT NOT NULL, `participantType` TEXT NOT NULL, `permissions` INTEGER NOT NULL, `readOnly` TEXT NOT NULL, `recordingConsent` INTEGER NOT NULL, `remoteServer` TEXT, `remoteToken` TEXT, `sessionId` TEXT NOT NULL, `status` TEXT, `statusClearAt` INTEGER, `statusIcon` TEXT, `statusMessage` TEXT, `type` TEXT NOT NULL, `unreadMention` INTEGER NOT NULL, `unreadMentionDirect` INTEGER NOT NULL, `unreadMessages` INTEGER NOT NULL, `hasArchived` INTEGER NOT NULL, PRIMARY KEY(`internalId`), FOREIGN KEY(`accountId`) REFERENCES `User`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", "fields": [ { "fieldPath": "internalId", @@ -398,12 +398,6 @@ "columnName": "hasArchived", "affinity": "INTEGER", "notNull": true - }, - { - "fieldPath": "hasImportant", - "columnName": "hasImportant", - "affinity": "INTEGER", - "notNull": true } ], "primaryKey": { @@ -719,7 +713,7 @@ ], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd977dea7f7b5cc6d466a4aeb68c538fb')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '506abc931eb3b657cafe6ad1b25f635d')" ] } } \ No newline at end of file From a943dc1070a17cc1531cd2d64ea7a4938105267f Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 26 May 2025 10:13:47 +0200 Subject: [PATCH 07/10] modify database scheme Signed-off-by: sowjanyakch --- .../talk/data/source/local/Migrations.kt | 20 +++++++++++++++++++ .../talk/data/source/local/TalkDatabase.kt | 5 +++-- 2 files changed, 23 insertions(+), 2 deletions(-) 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 ad2318b9f..f89aefab3 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 @@ -69,6 +69,26 @@ object Migrations { } } + val MIGRATION_15_16 = object : Migration(15, 16) { + override fun migrate(db: SupportSQLiteDatabase) { + Log.i("Migrations", "Migrating 15 to 16") + addisImportant(db) + } + } + + fun addisImportant(db: SupportSQLiteDatabase) { + try { + db.execSQL( + "ALTER TABLE Conversations " + + "ADD COLUMN hasImportant INTEGER NOT NULL DEFAULT 0;" + ) + } catch (e: SQLException) { + Log.i("Migrations", "Something went wrong when adding column hasImportant to table Conversations") + } + } + + + fun migrateToRoom(db: SupportSQLiteDatabase) { db.execSQL( "CREATE TABLE User_new (" + 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 96f192511..1108fa394 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,7 +49,7 @@ import java.util.Locale ChatMessageEntity::class, ChatBlockEntity::class ], - version = 15, + version = 16, autoMigrations = [ AutoMigration(from = 9, to = 10) ], @@ -117,7 +117,8 @@ abstract class TalkDatabase : RoomDatabase() { Migrations.MIGRATION_11_12, Migrations.MIGRATION_12_13, Migrations.MIGRATION_13_14, - Migrations.MIGRATION_14_15 + Migrations.MIGRATION_14_15, + Migrations.MIGRATION_15_16 ) .allowMainThreadQueries() .addCallback( From 3f512c7b542c9e3dfe8e86d5d84a30c635e8a7b6 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 26 May 2025 10:34:52 +0200 Subject: [PATCH 08/10] modify layout Signed-off-by: sowjanyakch --- .../16.json | 731 ++++++++++++++++++ .../res/layout/item_notification_settings.xml | 7 +- 2 files changed, 735 insertions(+), 3 deletions(-) create mode 100644 app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/16.json diff --git a/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/16.json b/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/16.json new file mode 100644 index 000000000..ba7c399b6 --- /dev/null +++ b/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/16.json @@ -0,0 +1,731 @@ +{ + "formatVersion": 1, + "database": { + "version": 16, + "identityHash": "bbf526d5c78a99eb951635cc46f4c59f", + "entities": [ + { + "tableName": "User", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `userId` TEXT, `username` TEXT, `baseUrl` TEXT, `token` TEXT, `displayName` TEXT, `pushConfigurationState` TEXT, `capabilities` TEXT, `serverVersion` TEXT DEFAULT '', `clientCertificate` TEXT, `externalSignalingServer` TEXT, `current` INTEGER NOT NULL, `scheduledForDeletion` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "TEXT" + }, + { + "fieldPath": "username", + "columnName": "username", + "affinity": "TEXT" + }, + { + "fieldPath": "baseUrl", + "columnName": "baseUrl", + "affinity": "TEXT" + }, + { + "fieldPath": "token", + "columnName": "token", + "affinity": "TEXT" + }, + { + "fieldPath": "displayName", + "columnName": "displayName", + "affinity": "TEXT" + }, + { + "fieldPath": "pushConfigurationState", + "columnName": "pushConfigurationState", + "affinity": "TEXT" + }, + { + "fieldPath": "capabilities", + "columnName": "capabilities", + "affinity": "TEXT" + }, + { + "fieldPath": "serverVersion", + "columnName": "serverVersion", + "affinity": "TEXT", + "defaultValue": "''" + }, + { + "fieldPath": "clientCertificate", + "columnName": "clientCertificate", + "affinity": "TEXT" + }, + { + "fieldPath": "externalSignalingServer", + "columnName": "externalSignalingServer", + "affinity": "TEXT" + }, + { + "fieldPath": "current", + "columnName": "current", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "scheduledForDeletion", + "columnName": "scheduledForDeletion", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + } + }, + { + "tableName": "ArbitraryStorage", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountIdentifier` INTEGER NOT NULL, `key` TEXT NOT NULL, `object` TEXT, `value` TEXT, PRIMARY KEY(`accountIdentifier`, `key`))", + "fields": [ + { + "fieldPath": "accountIdentifier", + "columnName": "accountIdentifier", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "storageObject", + "columnName": "object", + "affinity": "TEXT" + }, + { + "fieldPath": "value", + "columnName": "value", + "affinity": "TEXT" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "accountIdentifier", + "key" + ] + } + }, + { + "tableName": "Conversations", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`internalId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `token` TEXT NOT NULL, `displayName` TEXT NOT NULL, `actorId` TEXT NOT NULL, `actorType` TEXT NOT NULL, `avatarVersion` TEXT NOT NULL, `callFlag` INTEGER NOT NULL, `callRecording` INTEGER NOT NULL, `callStartTime` INTEGER NOT NULL, `canDeleteConversation` INTEGER NOT NULL, `canLeaveConversation` INTEGER NOT NULL, `canStartCall` INTEGER NOT NULL, `description` TEXT NOT NULL, `hasCall` INTEGER NOT NULL, `hasPassword` INTEGER NOT NULL, `isCustomAvatar` INTEGER NOT NULL, `isFavorite` INTEGER NOT NULL, `lastActivity` INTEGER NOT NULL, `lastCommonReadMessage` INTEGER NOT NULL, `lastMessage` TEXT, `lastPing` INTEGER NOT NULL, `lastReadMessage` INTEGER NOT NULL, `lobbyState` TEXT NOT NULL, `lobbyTimer` INTEGER NOT NULL, `messageExpiration` INTEGER NOT NULL, `name` TEXT NOT NULL, `notificationCalls` INTEGER NOT NULL, `notificationLevel` TEXT NOT NULL, `objectType` TEXT NOT NULL, `objectId` TEXT NOT NULL, `participantType` TEXT NOT NULL, `permissions` INTEGER NOT NULL, `readOnly` TEXT NOT NULL, `recordingConsent` INTEGER NOT NULL, `remoteServer` TEXT, `remoteToken` TEXT, `sessionId` TEXT NOT NULL, `status` TEXT, `statusClearAt` INTEGER, `statusIcon` TEXT, `statusMessage` TEXT, `type` TEXT NOT NULL, `unreadMention` INTEGER NOT NULL, `unreadMentionDirect` INTEGER NOT NULL, `unreadMessages` INTEGER NOT NULL, `hasArchived` INTEGER NOT NULL, `hasSensitive` INTEGER NOT NULL, `hasImportant` INTEGER NOT NULL, PRIMARY KEY(`internalId`), FOREIGN KEY(`accountId`) REFERENCES `User`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "internalId", + "columnName": "internalId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "token", + "columnName": "token", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "displayName", + "columnName": "displayName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "actorId", + "columnName": "actorId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "actorType", + "columnName": "actorType", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "avatarVersion", + "columnName": "avatarVersion", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "callFlag", + "columnName": "callFlag", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "callRecording", + "columnName": "callRecording", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "callStartTime", + "columnName": "callStartTime", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "canDeleteConversation", + "columnName": "canDeleteConversation", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "canLeaveConversation", + "columnName": "canLeaveConversation", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "canStartCall", + "columnName": "canStartCall", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "hasCall", + "columnName": "hasCall", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasPassword", + "columnName": "hasPassword", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasCustomAvatar", + "columnName": "isCustomAvatar", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "favorite", + "columnName": "isFavorite", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lastActivity", + "columnName": "lastActivity", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lastCommonReadMessage", + "columnName": "lastCommonReadMessage", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lastMessage", + "columnName": "lastMessage", + "affinity": "TEXT" + }, + { + "fieldPath": "lastPing", + "columnName": "lastPing", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lastReadMessage", + "columnName": "lastReadMessage", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lobbyState", + "columnName": "lobbyState", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "lobbyTimer", + "columnName": "lobbyTimer", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "messageExpiration", + "columnName": "messageExpiration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "notificationCalls", + "columnName": "notificationCalls", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "notificationLevel", + "columnName": "notificationLevel", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "objectType", + "columnName": "objectType", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "objectId", + "columnName": "objectId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "participantType", + "columnName": "participantType", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "permissions", + "columnName": "permissions", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "conversationReadOnlyState", + "columnName": "readOnly", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "recordingConsentRequired", + "columnName": "recordingConsent", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "remoteServer", + "columnName": "remoteServer", + "affinity": "TEXT" + }, + { + "fieldPath": "remoteToken", + "columnName": "remoteToken", + "affinity": "TEXT" + }, + { + "fieldPath": "sessionId", + "columnName": "sessionId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "status", + "columnName": "status", + "affinity": "TEXT" + }, + { + "fieldPath": "statusClearAt", + "columnName": "statusClearAt", + "affinity": "INTEGER" + }, + { + "fieldPath": "statusIcon", + "columnName": "statusIcon", + "affinity": "TEXT" + }, + { + "fieldPath": "statusMessage", + "columnName": "statusMessage", + "affinity": "TEXT" + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "unreadMention", + "columnName": "unreadMention", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "unreadMentionDirect", + "columnName": "unreadMentionDirect", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "unreadMessages", + "columnName": "unreadMessages", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasArchived", + "columnName": "hasArchived", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasSensitive", + "columnName": "hasSensitive", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasImportant", + "columnName": "hasImportant", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "internalId" + ] + }, + "indices": [ + { + "name": "index_Conversations_accountId", + "unique": false, + "columnNames": [ + "accountId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_Conversations_accountId` ON `${TABLE_NAME}` (`accountId`)" + } + ], + "foreignKeys": [ + { + "table": "User", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "accountId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "ChatMessages", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`internalId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `token` TEXT NOT NULL, `id` INTEGER NOT NULL, `internalConversationId` TEXT NOT NULL, `actorDisplayName` TEXT NOT NULL, `message` TEXT NOT NULL, `actorId` TEXT NOT NULL, `actorType` TEXT NOT NULL, `deleted` INTEGER NOT NULL, `expirationTimestamp` INTEGER NOT NULL, `isReplyable` INTEGER NOT NULL, `isTemporary` INTEGER NOT NULL, `lastEditActorDisplayName` TEXT, `lastEditActorId` TEXT, `lastEditActorType` TEXT, `lastEditTimestamp` INTEGER, `markdown` INTEGER, `messageParameters` TEXT, `messageType` TEXT NOT NULL, `parent` INTEGER, `reactions` TEXT, `reactionsSelf` TEXT, `referenceId` TEXT, `sendingFailed` INTEGER NOT NULL, `silent` INTEGER NOT NULL, `systemMessage` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, PRIMARY KEY(`internalId`), FOREIGN KEY(`internalConversationId`) REFERENCES `Conversations`(`internalId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "internalId", + "columnName": "internalId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "token", + "columnName": "token", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "internalConversationId", + "columnName": "internalConversationId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "actorDisplayName", + "columnName": "actorDisplayName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "message", + "columnName": "message", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "actorId", + "columnName": "actorId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "actorType", + "columnName": "actorType", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "deleted", + "columnName": "deleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "expirationTimestamp", + "columnName": "expirationTimestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "replyable", + "columnName": "isReplyable", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isTemporary", + "columnName": "isTemporary", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lastEditActorDisplayName", + "columnName": "lastEditActorDisplayName", + "affinity": "TEXT" + }, + { + "fieldPath": "lastEditActorId", + "columnName": "lastEditActorId", + "affinity": "TEXT" + }, + { + "fieldPath": "lastEditActorType", + "columnName": "lastEditActorType", + "affinity": "TEXT" + }, + { + "fieldPath": "lastEditTimestamp", + "columnName": "lastEditTimestamp", + "affinity": "INTEGER" + }, + { + "fieldPath": "renderMarkdown", + "columnName": "markdown", + "affinity": "INTEGER" + }, + { + "fieldPath": "messageParameters", + "columnName": "messageParameters", + "affinity": "TEXT" + }, + { + "fieldPath": "messageType", + "columnName": "messageType", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "parentMessageId", + "columnName": "parent", + "affinity": "INTEGER" + }, + { + "fieldPath": "reactions", + "columnName": "reactions", + "affinity": "TEXT" + }, + { + "fieldPath": "reactionsSelf", + "columnName": "reactionsSelf", + "affinity": "TEXT" + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "TEXT" + }, + { + "fieldPath": "sendingFailed", + "columnName": "sendingFailed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "silent", + "columnName": "silent", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "systemMessageType", + "columnName": "systemMessage", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "internalId" + ] + }, + "indices": [ + { + "name": "index_ChatMessages_internalId", + "unique": true, + "columnNames": [ + "internalId" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_ChatMessages_internalId` ON `${TABLE_NAME}` (`internalId`)" + }, + { + "name": "index_ChatMessages_internalConversationId", + "unique": false, + "columnNames": [ + "internalConversationId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_ChatMessages_internalConversationId` ON `${TABLE_NAME}` (`internalConversationId`)" + } + ], + "foreignKeys": [ + { + "table": "Conversations", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "internalConversationId" + ], + "referencedColumns": [ + "internalId" + ] + } + ] + }, + { + "tableName": "ChatBlocks", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `internalConversationId` TEXT NOT NULL, `accountId` INTEGER, `token` TEXT, `oldestMessageId` INTEGER NOT NULL, `newestMessageId` INTEGER NOT NULL, `hasHistory` INTEGER NOT NULL, FOREIGN KEY(`internalConversationId`) REFERENCES `Conversations`(`internalId`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "internalConversationId", + "columnName": "internalConversationId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "INTEGER" + }, + { + "fieldPath": "token", + "columnName": "token", + "affinity": "TEXT" + }, + { + "fieldPath": "oldestMessageId", + "columnName": "oldestMessageId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "newestMessageId", + "columnName": "newestMessageId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "hasHistory", + "columnName": "hasHistory", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_ChatBlocks_internalConversationId", + "unique": false, + "columnNames": [ + "internalConversationId" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_ChatBlocks_internalConversationId` ON `${TABLE_NAME}` (`internalConversationId`)" + } + ], + "foreignKeys": [ + { + "table": "Conversations", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "internalConversationId" + ], + "referencedColumns": [ + "internalId" + ] + } + ] + } + ], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'bbf526d5c78a99eb951635cc46f4c59f')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/item_notification_settings.xml b/app/src/main/res/layout/item_notification_settings.xml index 9caf96d78..b7bc918be 100644 --- a/app/src/main/res/layout/item_notification_settings.xml +++ b/app/src/main/res/layout/item_notification_settings.xml @@ -46,8 +46,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/nc_important_conversation" - android:textSize="@dimen/headline_text_size" - android:clickable="false"/> + android:textSize="@dimen/headline_text_size" /> + android:layout_marginStart="@dimen/standard_margin" + android:checked="false" + android:clickable="false"/> From 6c5347ef720f03008a4922bb01f0ce1459d48c2a Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 26 May 2025 10:50:38 +0200 Subject: [PATCH 09/10] ktlintFormat + suppress property name Signed-off-by: sowjanyakch --- .../conversationinfo/viewmodel/ConversationInfoViewModel.kt | 2 ++ .../java/com/nextcloud/talk/data/source/local/Migrations.kt | 2 -- .../java/com/nextcloud/talk/models/domain/ConversationModel.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 428c4b4af..1c2da4000 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 @@ -124,11 +124,13 @@ class ConversationInfoViewModel @Inject constructor( val getConversationReadOnlyState: LiveData get() = _getConversationReadOnlyState + @Suppress("PropertyName") private val _markConversationAsImportantResult = MutableLiveData(MarkConversationAsImportantViewState.None) val markAsImportantResult: LiveData get() = _markConversationAsImportantResult + @Suppress("PropertyName") private val _markConversationAsUnimportantResult = MutableLiveData(MarkConversationAsUnimportantViewState.None) val markAsUnimportantResult: LiveData 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 f89aefab3..0d250979c 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 @@ -87,8 +87,6 @@ object Migrations { } } - - fun migrateToRoom(db: SupportSQLiteDatabase) { db.execSQL( "CREATE TABLE User_new (" + diff --git a/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt b/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt index fbbfc6c46..cbd005667 100644 --- a/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt +++ b/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt @@ -62,7 +62,7 @@ class ConversationModel( var remoteToken: String? = null, var hasArchived: Boolean = false, var hasSensitive: Boolean = false, - var hasImportant:Boolean = false, + var hasImportant: Boolean = false, // attributes that don't come from API. This should be changed?! var password: String? = null From 25639702f654945832e6d051bd81f7e2db0090ec Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 27 May 2025 15:25:08 +0200 Subject: [PATCH 10/10] minor refactoring Signed-off-by: Marcel Hibbe --- .../talk/data/source/local/Migrations.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) 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 0d250979c..e9a5b2832 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 @@ -65,25 +65,14 @@ object Migrations { val MIGRATION_14_15 = object : Migration(14, 15) { override fun migrate(db: SupportSQLiteDatabase) { Log.i("Migrations", "Migrating 14 to 15") - addisSensitive(db) + addIsSensitive(db) } } val MIGRATION_15_16 = object : Migration(15, 16) { override fun migrate(db: SupportSQLiteDatabase) { Log.i("Migrations", "Migrating 15 to 16") - addisImportant(db) - } - } - - fun addisImportant(db: SupportSQLiteDatabase) { - try { - db.execSQL( - "ALTER TABLE Conversations " + - "ADD COLUMN hasImportant INTEGER NOT NULL DEFAULT 0;" - ) - } catch (e: SQLException) { - Log.i("Migrations", "Something went wrong when adding column hasImportant to table Conversations") + addIsImportant(db) } } @@ -308,7 +297,7 @@ object Migrations { } } - fun addisSensitive(db: SupportSQLiteDatabase) { + fun addIsSensitive(db: SupportSQLiteDatabase) { try { db.execSQL( "ALTER TABLE Conversations " + @@ -319,6 +308,17 @@ object Migrations { } } + fun addIsImportant(db: SupportSQLiteDatabase) { + try { + db.execSQL( + "ALTER TABLE Conversations " + + "ADD COLUMN hasImportant INTEGER NOT NULL DEFAULT 0;" + ) + } catch (e: SQLException) { + Log.i("Migrations", "Something went wrong when adding column hasImportant to table Conversations") + } + } + fun addTempMessagesSupport(db: SupportSQLiteDatabase) { try { db.execSQL(