diff --git a/app/src/main/java/com/nextcloud/client/assistant/AssistantViewModel.kt b/app/src/main/java/com/nextcloud/client/assistant/AssistantViewModel.kt
index 2967c17395..3d18c6cd78 100644
--- a/app/src/main/java/com/nextcloud/client/assistant/AssistantViewModel.kt
+++ b/app/src/main/java/com/nextcloud/client/assistant/AssistantViewModel.kt
@@ -84,14 +84,16 @@ class AssistantViewModel(client: NextcloudClient) : ViewModel() {
private fun getTaskTypes() {
viewModelScope.launch(Dispatchers.IO) {
- val result = repository.getTaskTypes().resultData.types
+ val result = arrayListOf(TaskType(null, "All", null))
+ val taskTypes = repository.getTaskTypes().resultData.types ?: listOf()
+ result.addAll(taskTypes)
_taskTypes.update {
- result
+ result.toList()
}
_selectedTaskType.update {
- result?.first()
+ result.first()
}
}
}
diff --git a/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt b/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt
index 5a8171ad87..a646d08178 100644
--- a/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt
+++ b/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt
@@ -89,7 +89,14 @@ fun AssistantScreen(viewModel: AssistantViewModel, floatingActionButton: Floatin
}
floatingActionButton.setOnClickListener {
- showAddTaskAlertDialog = true
+ if (selectedTaskType?.id != null) {
+ showAddTaskAlertDialog = true
+ } else {
+ DisplayUtils.showSnackMessage(
+ activity,
+ activity.getString(R.string.assistant_screen_select_different_task_type_to_add)
+ )
+ }
}
Box(Modifier.nestedScroll(pullRefreshState.nestedScrollConnection)) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7d29fbd1c3..ad16d86ae0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -23,6 +23,8 @@
Delete Task
Are you sure you want to delete this task?
+ Please select different task type to create a new task
+
Delete Task
Task successfully created