Skip to content

Country selector fixes #1345

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 5 commits into from
Jun 12, 2018
Merged

Country selector fixes #1345

merged 5 commits into from
Jun 12, 2018

Conversation

lsirac
Copy link
Contributor

@lsirac lsirac commented Jun 8, 2018

Fixed a merge issue where another PR broke the selector (we need more tests.. 😃)

Added some validation for when the default country is set in the selector via the two overloaded setDefaultNumber() methods.

When the developer does not provide a default country, we get the user’s locale based on their SIM. If the resulting country is not whitelisted or has been blacklisted, we now choose the first valid country, where the valid countries are sorted in alphabetical order. Before this, an invalid country was displayed in the picker.

When we successfully fetch the users' number, we'll input it, set the country code, and simulate a 'Verify Phone Number' button click. We now confirm that their country code is valid. If it isn't, we will still auto fill their number, but we don't continue to verify their number.

I also removed the CountryListLoadTask.

@lsirac lsirac requested review from samtstern and SUPERCILEX June 8, 2018 20:30
Copy link
Collaborator

@SUPERCILEX SUPERCILEX left a comment

Choose a reason for hiding this comment

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

Overall looks good, though I do have a few concerns:

  • There's too much logic in the fragment—I tried very hard to dumb it down in the phone auth refactor and I'd be sad to see it get gnarly again. Ideally some of your code could be moved to the phone utils class or another helper.
  • Too many methods depend on each other being called in a very specific order. For example, the country code setup method somehow initializes the whitelist fields and also shows the Smart Lock dialog making it so if anything order wise is changed, it all blows up at runtime. That's scary for anyone touching those files. 😉

@lsirac
Copy link
Contributor Author

lsirac commented Jun 12, 2018

@SUPERCILEX I moved the logic away from the fragment but I decided against creating a manager/helper. We're not going to reuse the country spinner so I moved the logic there 😃.

Also, based on the params needed & the changes I made I don't think it's easy to make a mistake editing the files now. Let me know if you disagree.

Copy link
Contributor

@samtstern samtstern left a comment

Choose a reason for hiding this comment

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

LGTM, will wait for @SUPERCILEX to take one more look.

@@ -678,6 +678,12 @@ public PhoneBuilder setWhitelistedCountries(
"You can either whitelist or blacklist country codes for phone " +
"authentication.");
}

String message = "Invalid argument: The whitelist is %s. For this case, " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of: "For this case, don't use this method" how about something like "Only non-null and non-empty whitelists are valid. To specify no whitelist, do not call this method."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much better. 👍

Copy link
Collaborator

@SUPERCILEX SUPERCILEX left a comment

Choose a reason for hiding this comment

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

Just a few more comments 👍

});
}

private void setDefaultCountryForSpinner() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method needs to move back to where it was unfortunately (in onActivityCreated). Try clicking the phone number in your PR when you're at the submit code fragment. It will go back, but it will also show the phone picker again assuming you didn't pre-fill it in the AuthUI builder.

To see why that happens, read the comment where mCalled is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch 👍

}

private void getCountrySpinnerIsosFromParams(Bundle params) {
if (params != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's:

  • rename this method init... since it returns void
  • remove the null check
  • add nullability annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: unnecessary new line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@SUPERCILEX SUPERCILEX left a comment

Choose a reason for hiding this comment

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

Awesome sauce!

@samtstern samtstern added this to the 4.1.0 milestone Jun 12, 2018
@samtstern samtstern merged commit a346bf2 into version-4.1.0-dev Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants