Skip to content

Commit

Permalink
Use toSpanned in validation error dialog text (#2798)
Browse files Browse the repository at this point in the history
* Use toSpanned in validation error dialog text

* spotless

* Do CI

* Fix test
  • Loading branch information
FikriMilano authored Mar 4, 2025
1 parent cc692a8 commit 0b73fb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 Google LLC
* Copyright 2023-2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,6 +32,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.google.android.fhir.datacapture.extensions.flattened
import com.google.android.fhir.datacapture.extensions.localizedFlyoverSpanned
import com.google.android.fhir.datacapture.extensions.toSpanned
import com.google.android.fhir.datacapture.validation.Invalid
import com.google.android.fhir.datacapture.validation.ValidationResult
import com.google.android.material.dialog.MaterialAlertDialogBuilder
Expand Down Expand Up @@ -90,9 +91,12 @@ internal class QuestionnaireValidationErrorMessageDialogFragment(
val viewModel: QuestionnaireValidationErrorViewModel by
activityViewModels(factoryProducer = factoryProducer)
text =
viewModel.getItemsTextWithValidationErrors().joinToString(separator = "\n") {
context.getString(R.string.questionnaire_validation_error_item_text_with_bullet, it)
}
viewModel
.getItemsTextWithValidationErrors()
.joinToString(separator = "\n") {
context.getString(R.string.questionnaire_validation_error_item_text_with_bullet, it)
}
.toSpanned()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 Google LLC
* Copyright 2022-2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -76,7 +76,7 @@ class QuestionnaireValidationErrorMessageDialogFragmentTest {
assertThat(result.findViewById<TextView>(R.id.dialog_title).text).isEqualTo("Errors found")
assertThat(result.findViewById<TextView>(R.id.dialog_subtitle).text)
.isEqualTo("Fix the following questions:")
assertThat(result.findViewById<TextView>(R.id.body).text).isEqualTo("• First Name")
assertThat(result.findViewById<TextView>(R.id.body).text.toString()).isEqualTo("• First Name")
}
}

Expand Down

0 comments on commit 0b73fb6

Please sign in to comment.