-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add boolean type widget with support for error correction (unselect by tapping again) #781
Add boolean type widget with support for error correction (unselect by tapping again) #781
Conversation
6b6657e
to
874440e
Compare
Codecov Report
@@ Coverage Diff @@
## master #781 +/- ##
============================================
- Coverage 88.78% 88.56% -0.22%
- Complexity 467 469 +2
============================================
Files 106 107 +1
Lines 9095 9157 +62
Branches 580 611 +31
============================================
+ Hits 8075 8110 +35
Misses 715 715
- Partials 305 332 +27
Continue to review full report at Codecov.
|
9a13d2c
to
953f431
Compare
953f431
to
81608ec
Compare
Do we have to add "Not answered" even in the check box type? I have not yet added it. Since users can unselect the check box and remove answers unlike radio groups or dropdown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maanuanubhav999! 👍 A couple of high-level comments:
- Can you please remove
QuestionnaireItemCheckBoxViewHolderFactory
and all references to it? - Can you reuse
QuestionnaireItemRadioGroupviewHolderFactory
instead of creating a new widget type (QuestionnaireItemBooleanTypePickerViewHolderFactory
)? The new widget factory you created does pretty much what the radio group does. I think the only difference is that if the question is boolean type it needs to generate two answer options true/false, and you have to translate them to the correct answers when the user answers the questions.
If you're talking about checkox group - you're right we don't need not answered option, because the user can just untick everything. If you're talking about a single checkbox - I think we should just get rid of it since there won't be any use for it (I commented in my review already). |
Please also rename your PR title to something that reads better e.g. "Add 'not answered' option to radio button group and use it for boolean type questions" |
HI @maanuanubhav999 -- thanks for working on this! any update on changing this to use the existing radio button group widget? |
Hey, @jingtang10 I will try to complete it in 2-3 days. |
@shelaghm and I are discussing some alternative solutions - will update and hopefully will provide some mocks to guide implementation |
Okay, that would be great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks so much for this - can you add a couple of screenshots for your new widget?
...android/fhir/datacapture/views/QuestionnaireItemDropDownViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/res/layout/questionnaire_item_boolean_type_picker_view.xml
Outdated
Show resolved
Hide resolved
datacapture/src/main/res/layout/questionnaire_item_boolean_type_picker_view.xml
Outdated
Show resolved
Hide resolved
...capture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemViewHolderType.kt
Show resolved
Hide resolved
datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireItemAdapter.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
datacapture/src/main/res/layout/questionnaire_item_boolean_type_picker_view.xml
Show resolved
Hide resolved
...google/android/fhir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactory.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for perseverance - this should be the last round of comments.
Following the same design pattern of the yes/no radio button, I don't believe we want to add another radio button for the radio button group. I would suggest revert the changes for the radio button group and drop down and create two separate issues (and raise 2 separate PRs if you wish) for them.
...google/android/fhir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactory.kt
Outdated
Show resolved
Hide resolved
questionnaireItemViewItem.singleAnswerOrNull?.valueBooleanType?.value ?: false | ||
val (questionnaireItem, questionnaireResponseItem) = questionnaireItemViewItem | ||
val answer = questionnaireResponseItem.answer.singleOrNull()?.valueBooleanType | ||
boolTypeHeader.text = questionnaireItem.localizedText |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this 2 lines above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, didn't get this, why would we need to shift this? @jingtang10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move this line to the top:
val (questionnaireItem, questionnaireResponseItem) = questionnaireItemViewItem
so that the if else block can use questionnaireItem
rather than questionnaireItemViewItem.questionnaireItem
also, move boolTypeHeader
setup before the answer
setup because that's consistent with the order of the widgets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, also removed answer
since it was not needed anywhere.
...google/android/fhir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactory.kt
Outdated
Show resolved
Hide resolved
...google/android/fhir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactory.kt
Outdated
Show resolved
Hide resolved
...google/android/fhir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactory.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
373b97d
to
7fcac70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you push the changes addressing the comments from the previous review? i can't seem to see any.
thanks!
...android/fhir/datacapture/views/QuestionnaireItemDropDownViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...java/com/google/android/fhir/datacapture/views/QuestionnaireItemDropDownViewHolderFactory.kt
Outdated
Show resolved
Hide resolved
...java/com/google/android/fhir/datacapture/views/QuestionnaireItemDropDownViewHolderFactory.kt
Outdated
Show resolved
Hide resolved
questionnaireItemViewItem.singleAnswerOrNull?.valueBooleanType?.value ?: false | ||
val (questionnaireItem, questionnaireResponseItem) = questionnaireItemViewItem | ||
val answer = questionnaireResponseItem.answer.singleOrNull()?.valueBooleanType | ||
boolTypeHeader.text = questionnaireItem.localizedText |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move this line to the top:
val (questionnaireItem, questionnaireResponseItem) = questionnaireItemViewItem
so that the if else block can use questionnaireItem
rather than questionnaireItemViewItem.questionnaireItem
also, move boolTypeHeader
setup before the answer
setup because that's consistent with the order of the widgets.
fd647a4
to
c01a176
Compare
c01a176
to
98e997b
Compare
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Outdated
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Show resolved
Hide resolved
...hir/datacapture/views/QuestionnaireItemBooleanTypePickerViewHolderFactoryInstrumentedTest.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thanks @maanuanubhav999! 👍 🎉
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #530
Description
Added Boolean type widget which would replace checkbox type widget.
Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
#546
Type
Choose one:Bug fix
Screenshots (if applicable)
![image](https://user-images.githubusercontent.com/26630009/139584251-bb06de8c-b02f-4182-902a-0fbcd9f30bb0.png)
Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project./gradlew check
and./gradlew connectedCheck
to test my changes locally