Skip to content

Commit 0b73fb6

Browse files
authored
Use toSpanned in validation error dialog text (#2798)
* Use toSpanned in validation error dialog text * spotless * Do CI * Fix test
1 parent cc692a8 commit 0b73fb6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireValidationErrorMessageDialogFragment.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Google LLC
2+
* Copyright 2023-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ import androidx.lifecycle.ViewModel
3232
import androidx.lifecycle.ViewModelProvider
3333
import com.google.android.fhir.datacapture.extensions.flattened
3434
import com.google.android.fhir.datacapture.extensions.localizedFlyoverSpanned
35+
import com.google.android.fhir.datacapture.extensions.toSpanned
3536
import com.google.android.fhir.datacapture.validation.Invalid
3637
import com.google.android.fhir.datacapture.validation.ValidationResult
3738
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -90,9 +91,12 @@ internal class QuestionnaireValidationErrorMessageDialogFragment(
9091
val viewModel: QuestionnaireValidationErrorViewModel by
9192
activityViewModels(factoryProducer = factoryProducer)
9293
text =
93-
viewModel.getItemsTextWithValidationErrors().joinToString(separator = "\n") {
94-
context.getString(R.string.questionnaire_validation_error_item_text_with_bullet, it)
95-
}
94+
viewModel
95+
.getItemsTextWithValidationErrors()
96+
.joinToString(separator = "\n") {
97+
context.getString(R.string.questionnaire_validation_error_item_text_with_bullet, it)
98+
}
99+
.toSpanned()
96100
}
97101
}
98102
}

datacapture/src/test/java/com/google/android/fhir/datacapture/QuestionnaireValidationErrorMessageDialogFragmentTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2024 Google LLC
2+
* Copyright 2022-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ class QuestionnaireValidationErrorMessageDialogFragmentTest {
7676
assertThat(result.findViewById<TextView>(R.id.dialog_title).text).isEqualTo("Errors found")
7777
assertThat(result.findViewById<TextView>(R.id.dialog_subtitle).text)
7878
.isEqualTo("Fix the following questions:")
79-
assertThat(result.findViewById<TextView>(R.id.body).text).isEqualTo("• First Name")
79+
assertThat(result.findViewById<TextView>(R.id.body).text.toString()).isEqualTo("• First Name")
8080
}
8181
}
8282

0 commit comments

Comments
 (0)