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
Location Question Type #478
Location Question Type #478
Conversation
Includes: Location Question Location Question Answer Format Location Question Form Cell Location Survey Answer
* master: (114 commits) ResearchKit Project: add explicit 'ORK_LOG_LEVEL_WARNING=1' ORKImageSelectionView: resolve merge conflict ORKTest: fix column width not being updated after rotation ORKImageCaptureStepViewController: restore 'queue_' method prefix ORKTappingContentView: slight constraint refactor ORKSkin: hide 'ORKGetMetricForScreenType()' function; use 'ORKGetMetricForWindow()' instead Misc: remove extra newlines before 'else' Misc: remove additional space after '!' unary operator Misc: homegenize whitespace between consecutive closing and opening brackets ORKTaskViewController: whitespace Misc: homogenize for the more common 'cannot' instead of 'can not' in exception messages Misc: whitespace between '==' operator Misc: some additional constraint homogeneization of recently merged active tasks Misc: remove needless empty class extensions Misc: use 'has' instead of 'have' when refering to singular noun ORKFormItemCell: use VerticalMargin and HorizontalMargin const names Misc: remove space between '!' unary operator and operand Misc: use property syntax for accessing 'font', 'ascender', 'descender', and 'window' Misc: use property syntax for 'allValues' and 'allKeys' ORKDataLogger: use previous configuration file key for backwards compatibility ...
|
||
#pragma mark - ORKLocationAnswerFormat | ||
|
||
@implementation ORKLocationAnswerFormat |
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.
There is a warning that init
has not been implemented. To dismiss the warning, go to ORKAnswerFormat_Internal.h
and remove line 67 (marked below).
Also, although its layout looks ok, the location step logs unsatisfiable constraint warnings when shown. It'd be nice to fix those. |
In When doing this, make sure you reorder all the related code in |
isValid = false; | ||
} else if (longitude.doubleValue < -180.0 || longitude.doubleValue > 180.0) { | ||
isValid = false; | ||
} |
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.
Change all the above isValid = false
to isValid = NO
.
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.
I don't think we need to translate the coordinates into a string and then validated them here. We can just take the coordinates and validate them in isAnswerValid
instead of validating them in isAnswerValidWithString:
.
@YuanZhu-apple The changes are ready for review. |
ENTRY(ORKLocationAnswerFormat, | ||
^id(NSDictionary *dict, ORKESerializationPropertyGetter getter) { | ||
ORKLocationAnswerFormat *format = [[ORKLocationAnswerFormat alloc] init]; | ||
format.useCurrentLocation = ((NSNumber *)GETPROP(dict, useCurrentLocation)).boolValue; |
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.
This line is unnecessary, since useCurrentLocation
can be written after init.
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.
@YuanZhu-apple Removed unnecessary setting of userCurrentLocation.
_mapViewHeightConstraint = [NSLayoutConstraint constraintWithItem:_mapView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:ORKGetMetricForWindow(ORKScreenMetricLocationQuestionMapHeight, self.window)]; | ||
[constraints addObject:_mapViewHeightConstraint]; | ||
|
||
[NSLayoutConstraint activateConstraints:constraints]; |
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.
showMapViewIfNecessary
can be called again and again, more and more constraints are added?
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.
Once this method is called, the mapView will have a super view, and the method will return on its second line. The map view is not an external property, so there is no way it can be removed from outside of the class, and it is never removed internally. Also once these constraints are set, they are never going to change since the map view is never going to be hidden once open. Do you want me to switch to using a boolean to keep track of wether or not this is called, or hold on to the constraints with an array and check its count?
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 for the explanation! It's good to keep it like this.
@YuanZhu-apple Everything is ready for you to take another look at. |
@YuanZhu-apple Error handling has been updated. I've categorized the errors that would cause issues with the functionality of the location question. I've grouped other errors (like region monitoring) into an unknown error case. I'm debating whether or not those should even be displayed to the user, as it has nothing to do with the functionality of the question. |
/* Alerts for invalid location coordinates */ | ||
"LOCATION_QUESTION_PLACEHOLDER" = "Enter an address"; | ||
"LOCATION_ERROR_TITLE" = "Failed to Resolve Specified Address"; | ||
|
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.
Newly added strings are not here yet.
Generally I think there are two kinds of message can be displayed to user:
And for other types of errors, we need to handle them either internally within the view; or throw it out to taskViewController's delegate and let developer to handle. |
…ot apply to the functionality of the selection view by silently absorbing the error.
@YuanZhu-apple I added the localized strings I forgot, as well as internally absorbing the errors from the location manager that do not affect the functionality. |
…nto LocationQuestion Conflicts: ResearchKit/Common/ORKResult.m
return [[ORKLocationAnswerFormat alloc] init]; | ||
}, | ||
(@{ | ||
PROPERTY(useCurrentLocation, NSNumber, NSObject, NO, nil, nil) |
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.
Change writeAfterInit from NO
to YES
, it will fix the unit test failure in ORKTest
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.
@YuanZhu-apple Fixed issue causing tests to fail.
Great, good to go. |
This pull request adds support for a new location question and answer type. It can be used as a single question step and/or in a form task. You may have multiple entries in the form task and while interacting with each individual form item, the map will hide or show depending on your current selection. The location question handles the permission request for accessing the devices current location, when using the current location button. It will reverse geocode the current location value to an address and fill it in the question answer field.