From 8bf7fd8553f34139a47ae458940227e4c72de09c Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 25 Nov 2024 11:44:57 +0100 Subject: [PATCH 1/3] show backup status when only when status message is previously set Signed-off-by: sowjanyakch --- .../talk/ui/dialog/SetStatusDialogFragment.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index 567c16af3..84aaaf3cd 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -177,17 +177,19 @@ class SetStatusDialogFragment : override fun onNext(statusOverall: StatusOverall) { if (statusOverall.ocs?.meta?.statusCode == HTTP_STATUS_CODE_OK) { backupStatus = statusOverall.ocs?.data!! - isBackupStatusAvailable = true - val backupPredefinedStatus = PredefinedStatus( - backupStatus.userId!!, - backupStatus.icon, - backupStatus.message!!, - ClearAt(type = "period", time = backupStatus.clearAt.toString()) - ) - binding.automaticStatus.visibility = View.VISIBLE - adapter.isBackupStatusAvailable = true - predefinedStatusesList.add(0, backupPredefinedStatus) - adapter.notifyDataSetChanged() + if(backupStatus.message!= null){ + isBackupStatusAvailable = true + val backupPredefinedStatus = PredefinedStatus( + backupStatus.userId!!, + backupStatus.icon, + backupStatus.message!!, + ClearAt(type = "period", time = backupStatus.clearAt.toString()) + ) + binding.automaticStatus.visibility = View.VISIBLE + adapter.isBackupStatusAvailable = true + predefinedStatusesList.add(0, backupPredefinedStatus) + adapter.notifyDataSetChanged() + } } } From 2da78f69f2492ae7958d324c94a90451c937bfba Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 25 Nov 2024 11:46:31 +0100 Subject: [PATCH 2/3] ktlintFormat Signed-off-by: sowjanyakch --- .../conversationinfo/viewmodel/ConversationInfoViewModel.kt | 1 - .../com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt | 2 +- 2 files changed, 1 insertion(+), 2 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 a9ed147e7..10f395026 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 @@ -18,7 +18,6 @@ import com.nextcloud.talk.chat.data.network.ChatNetworkDataSource import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.models.domain.ConversationModel import com.nextcloud.talk.models.json.capabilities.SpreedCapability -import com.nextcloud.talk.models.json.generic.GenericOverall import com.nextcloud.talk.models.json.participants.TalkBan import com.nextcloud.talk.repositories.conversations.ConversationsRepository import com.nextcloud.talk.utils.ApiUtils diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index 84aaaf3cd..ff4ddb401 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -177,7 +177,7 @@ class SetStatusDialogFragment : override fun onNext(statusOverall: StatusOverall) { if (statusOverall.ocs?.meta?.statusCode == HTTP_STATUS_CODE_OK) { backupStatus = statusOverall.ocs?.data!! - if(backupStatus.message!= null){ + if (backupStatus.message != null) { isBackupStatusAvailable = true val backupPredefinedStatus = PredefinedStatus( backupStatus.userId!!, From fdbff4a8e67153e79514450a84da14b8d8b46c82 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Tue, 26 Nov 2024 12:12:03 +0100 Subject: [PATCH 3/3] use safe call operator Signed-off-by: sowjanyakch --- .../talk/ui/dialog/SetStatusDialogFragment.kt | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index ff4ddb401..a411de7d5 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -176,19 +176,21 @@ class SetStatusDialogFragment : @SuppressLint("NotifyDataSetChanged") override fun onNext(statusOverall: StatusOverall) { if (statusOverall.ocs?.meta?.statusCode == HTTP_STATUS_CODE_OK) { - backupStatus = statusOverall.ocs?.data!! - if (backupStatus.message != null) { - isBackupStatusAvailable = true - val backupPredefinedStatus = PredefinedStatus( - backupStatus.userId!!, - backupStatus.icon, - backupStatus.message!!, - ClearAt(type = "period", time = backupStatus.clearAt.toString()) - ) - binding.automaticStatus.visibility = View.VISIBLE - adapter.isBackupStatusAvailable = true - predefinedStatusesList.add(0, backupPredefinedStatus) - adapter.notifyDataSetChanged() + statusOverall.ocs?.data?.let { status -> + backupStatus = status + if (backupStatus.message != null) { + isBackupStatusAvailable = true + val backupPredefinedStatus = PredefinedStatus( + backupStatus.userId!!, + backupStatus.icon, + backupStatus.message!!, + ClearAt(type = "period", time = backupStatus.clearAt.toString()) + ) + binding.automaticStatus.visibility = View.VISIBLE + adapter.isBackupStatusAvailable = true + predefinedStatusesList.add(0, backupPredefinedStatus) + adapter.notifyDataSetChanged() + } } } }