-
Notifications
You must be signed in to change notification settings - Fork 80
login with external ID #403
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import android.os.Build; | ||
| import android.support.annotation.NonNull; | ||
| import android.support.annotation.StringRes; | ||
| import android.support.annotation.VisibleForTesting; | ||
| import android.support.v4.hardware.fingerprint.FingerprintManagerCompat; | ||
| import android.text.InputType; | ||
|
|
||
|
|
@@ -61,6 +62,7 @@ | |
| import org.researchstack.backbone.ui.step.layout.PasscodeCreationStepLayout; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
|
|
||
|
|
@@ -84,6 +86,16 @@ public class SurveyFactory { | |
| public static final String PASSWORD_CONFIRMATION_IDENTIFIER = "confirmation"; | ||
| public static final String CONSENT_QUIZ_IDENTIFIER = "consentQuiz"; | ||
|
|
||
| @VisibleForTesting | ||
| static final int EXTERNAL_ID_MAX_LENGTH = 128; | ||
|
|
||
| private static final List<ProfileInfoOption> EXTERNAL_ID_LOGIN_OPTIONS; | ||
| static { | ||
| List<ProfileInfoOption> tempList = new ArrayList<>(); | ||
| tempList.add(ProfileInfoOption.EXTERNAL_ID); | ||
| EXTERNAL_ID_LOGIN_OPTIONS = Collections.unmodifiableList(tempList); | ||
| } | ||
|
|
||
| // When set, this will be used | ||
| private CustomStepCreator customStepCreator; | ||
|
|
||
|
|
@@ -189,7 +201,7 @@ public Step createSurveyStep(Context context, SurveyItem item, boolean isSubtask | |
| if (!(item instanceof ProfileSurveyItem)) { | ||
| throw new IllegalStateException("Error in json parsing, ACCOUNT_LOGIN types must be ProfileSurveyItem"); | ||
| } | ||
| return createLoginStep(context, (ProfileSurveyItem)item); | ||
| return createLoginStep(context, (ProfileSurveyItem)item, defaultLoginOptions()); | ||
| case ACCOUNT_COMPLETION: | ||
| // TODO: finish the completion step layout, for now just use a simple instruction | ||
| // TODO: should show the cool check mark animation, see iOS | ||
|
|
@@ -207,7 +219,11 @@ public Step createSurveyStep(Context context, SurveyItem item, boolean isSubtask | |
| case ACCOUNT_DATA_GROUPS: | ||
| return createNotImplementedStep(item); | ||
| case ACCOUNT_EXTERNAL_ID: | ||
| return createNotImplementedStep(item); | ||
| if (!(item instanceof ProfileSurveyItem)) { | ||
| throw new IllegalStateException("Error in json parsing, " + | ||
| "ACCOUNT_EXTERNAL_ID types must be ProfileSurveyItem"); | ||
| } | ||
| return createLoginStep(context, (ProfileSurveyItem)item, EXTERNAL_ID_LOGIN_OPTIONS); | ||
| case PASSCODE: | ||
| return createPasscodeStep(context, item); | ||
| case SHARE_THE_APP: | ||
|
|
@@ -540,7 +556,7 @@ public List<QuestionStep> createQuestionSteps( | |
| createGenderQuestionStep(context, profileInfo); | ||
| break; | ||
| case EXTERNAL_ID: | ||
| // TODO: implement external ID step, which is used for internal app usage | ||
| questionSteps.add(createExternalIdQuestionStep(context, profileInfo)); | ||
| break; | ||
| case BLOOD_TYPE: // ChoiceTextAnswerFormat, see HealthKit blood types | ||
| case FITZPATRICK_SKIN_TYPE: // ChoiceTextAnswerFormat | ||
|
|
@@ -569,6 +585,22 @@ public QuestionStep createEmailQuestionStep(Context context, ProfileInfoOption p | |
| new EmailAnswerFormat()); | ||
| } | ||
|
|
||
| /** | ||
| * Create a question for External ID. | ||
| * | ||
| * @param context used to generate title and placeholder title for step | ||
| * @param profileOption used to set step identifier | ||
| * @return QuestionStep used for gathering user's external ID | ||
| */ | ||
| public QuestionStep createExternalIdQuestionStep( | ||
| Context context, ProfileInfoOption profileOption) { | ||
| return createGenericQuestionStep(context, | ||
| profileOption.getIdentifier(), | ||
| R.string.rsb_external_id, | ||
| R.string.rsb_external_id_placeholder, | ||
| new TextAnswerFormat(EXTERNAL_ID_MAX_LENGTH)); | ||
| } | ||
|
|
||
| /** | ||
| * @param context used to generate title and placeholder title for step | ||
| * @param profileOption used to set step identifier | ||
|
|
@@ -688,10 +720,13 @@ public ProfileStep createProfileStep(Context context, ProfileSurveyItem item) { | |
| /** | ||
| * @param context can be any context, activity or application, used to access "R" resources | ||
| * @param item InstructionSurveyItem from JSON | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add @param loginOptions |
||
| * @param loginOptions A list of ProfileInfoOptions representing the fields needed for login. | ||
| * Can be defaultLoginOptions() for email/password, EXTERNAL_ID_LOGIN_OPTIONS | ||
| * @return valid EmailVerificationSubStep matching the InstructionSurveyItem | ||
| */ | ||
| public LoginStep createLoginStep(Context context, ProfileSurveyItem item) { | ||
| List<ProfileInfoOption> options = createProfileInfoOptions(context, item, defaultLoginOptions()); | ||
| public LoginStep createLoginStep( | ||
| Context context, ProfileSurveyItem item, List<ProfileInfoOption> loginOptions) { | ||
| List<ProfileInfoOption> options = createProfileInfoOptions(context, item, loginOptions); | ||
| return new LoginStep( | ||
| item.identifier, item.title, item.text, | ||
| options, createQuestionSteps(context, options, false)); // false = dont create ConfirmPassword step | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
+1 for immutable