Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefix added to questions #333

Merged
merged 8 commits into from
Mar 22, 2021
Merged

Conversation

MuhammadSalman-7214
Copy link
Contributor

No description provided.

@jingtang10
Copy link
Collaborator

please add a description of your approach here in the PR description. thanks!

Copy link
Collaborator

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @MuhammadSalman-7214!

Please add tests.

@@ -56,6 +59,10 @@ internal object QuestionnaireItemCheckBoxViewHolderFactory :

override fun bind(questionnaireItemViewItem: QuestionnaireItemViewItem) {
this.questionnaireItemViewItem = questionnaireItemViewItem
if (questionnaireItemViewItem.questionnaireItem.prefix.toString().isNotEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're setting visibility, you need to make sure to set it both ways. this is because the same view holder may get recycled and reused for a different data item.

for example, if you have a data item that has prefix, so you set the view holder's prefix to be visiblt, but if the same view holder gets recycled and is bound to a data item that doesn't have prefix, you're not hiding the prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

@@ -27,10 +28,12 @@ internal object QuestionnaireItemCheckBoxViewHolderFactory :
override fun getQuestionnaireItemViewHolderDelegate() =
object : QuestionnaireItemViewHolderDelegate {
private lateinit var checkBox: CheckBox
private lateinit var prefix: TextView
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throughout this PR, please change the order of the widgets roughly follows the order of display in the actual UI.

in this case put the prefix before checkbox. Also please rename to prefixTextView?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

private lateinit var questionnaireItemViewItem: QuestionnaireItemViewItem

override fun init(itemView: View) {
checkBox = itemView.findViewById(R.id.check_box)
prefix = itemView.findViewById(R.id.prefix)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move 1 line above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

android:id="@+id/prefix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you not need a margin between the prefix and the question iteself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, otherwise we can't be able to differentiate, and it doesn't look too good either

Comment on lines 38 to 39
android:layout_marginStart="@dimen/item_margin_vertical"
android:layout_marginEnd="@dimen/item_margin_horizontal" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these be on the linear layout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are there as well, but it is there to add some margin between prefix and question

@jingtang10
Copy link
Collaborator

With #334 merged, please rebase/merge and run ./gradlew sA to format your XML files. Also see https://github.com/google/android-fhir/wiki/Developer's-Guide#kotlin-style.

salman added 3 commits March 18, 2021 16:12
# Conflicts:
#	datacapture/src/androidTest/java/com/google/android/fhir/datacapture/views/QuestionnaireItemEditTextQuantityViewHolderFactoryInstrumentedTest.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemCheckBoxViewHolderFactory.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemDatePickerViewHolderFactory.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemDateTimePickerViewHolderFactory.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemDisplayViewHolderFactory.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemDropDownViewHolderFactory.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemEditTextViewHolderFactory.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemGroupViewHolderFactory.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemRadioGroupViewHolderFactory.kt
#	datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemSliderViewHolderFactory.kt
#	datacapture/src/main/res/layout/questionnaire_item_check_box_view.xml
#	datacapture/src/main/res/layout/questionnaire_item_date_picker_view.xml
#	datacapture/src/main/res/layout/questionnaire_item_date_time_picker_view.xml
#	datacapture/src/main/res/layout/questionnaire_item_display_view.xml
#	datacapture/src/main/res/layout/questionnaire_item_drop_down_view.xml
#	datacapture/src/main/res/layout/questionnaire_item_edit_text_view.xml
#	datacapture/src/main/res/layout/questionnaire_item_group_header_view.xml
#	datacapture/src/main/res/layout/questionnaire_item_radio_group_view.xml
#	datacapture/src/main/res/layout/questionnaire_item_slider.xml
Copy link
Collaborator

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @MuhammadSalman-7214! can you add a screenshot just so we can see what it looks like now? (i think the my pain questionnaire has some prefixes in it).

you'll need to update the tests (my comments in the first file applies to all test files).

) {}
)

assertThat(!viewHolder.itemView.findViewById<TextView>(R.id.prefix).isVisible)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't complete. it's not asserting anything. it should be assertThat(...).isFalse().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sure

}

@Test
fun shouldNotSetPrefixText() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fun shouldNotSetPrefixText() {
fun shouldHidePrefixText() {

) {}
)

assertThat(viewHolder.itemView.findViewById<TextView>(R.id.prefix).text).isEqualTo("Prefix?")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also assert on visibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

@@ -34,6 +36,30 @@ class QuestionnaireItemCheckBoxViewHolderFactoryInstrumentedTest {
private val parent = FrameLayout(InstrumentationRegistry.getInstrumentation().context)
private val viewHolder = QuestionnaireItemCheckBoxViewHolderFactory.create(parent)

@Test
fun shouldSetPrefixText() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fun shouldSetPrefixText() {
fun shouldShowPrefixText() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

salman added 2 commits March 22, 2021 12:02
# Conflicts:
#	datacapture/src/main/res/layout/questionnaire_item_radio_group_view.xml
@MuhammadSalman-7214
Copy link
Contributor Author

Screenshot_1616400912
Please find attached @jingtang10

Copy link
Collaborator

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks @MuhammadSalman-7214 🎉

@MuhammadSalman-7214 MuhammadSalman-7214 merged commit be99f76 into master Mar 22, 2021
@MuhammadSalman-7214 MuhammadSalman-7214 deleted the ms/add-prefix-to-questions branch March 22, 2021 09:49
@MuhammadSalman-7214
Copy link
Contributor Author

Looks good. Thanks @MuhammadSalman-7214

your welcome @jingtang10 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Display prefixes in questions
2 participants