Complete rewrite/refactor of email sign in flow#418
Complete rewrite/refactor of email sign in flow#418samtstern merged 15 commits intofirebase:version-1.1.0-devfrom SUPERCILEX:register-email-refactor
Conversation
| RC_WELCOME_BACK_IDP); | ||
| } | ||
| } | ||
| } // TODO: 11/23/2016 what happens if we fail? |
There was a problem hiding this comment.
Thoughts? We didn't do anything before, but I think we should display a message or at least do something.
There was a problem hiding this comment.
Yeah not sure what the best course of action is here ... since we didn't do anything before let's leave this for another time.
| <string name="progress_dialog_sending">Sending…</string> | ||
| <string name="progress_dialog_signing_in">Signing in…</string> | ||
| <string name="progress_dialog_signing_up">Signing up…</string> | ||
| <string name="progress_dialog_checking_accounts">Checking for existing accounts…</string> |
There was a problem hiding this comment.
Does this sound good?
…factor # Conflicts: # auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailActivity.java
|
I've been off and on trying to figure out if a memory leak was caused by my changes in this PR and I finally figured it out! Turns out this PR wasn't the cause, but Full explanation:I've stubbed my toe several times now with TLDRKeep an eye out for |
| Button createButton = (Button) findViewById(R.id.button_create); | ||
| createButton.setOnClickListener(this); | ||
|
|
||
| showEmailAutoCompleteHint(); |
There was a problem hiding this comment.
Me previously:
Why are we doing this only if smart lock is enabled? I think users should get autocomplete whether or not devs have an aversion to smart lock.
I went through with that idea so unless anyone has any objections, I really think autocomplete should be available whether or not smart lock is enabled.
There was a problem hiding this comment.
Technically the email hint is provided by SmartLock, so this would make the API somewhat dishonest. Although I agree with you that enabling the hint for everyone may be a superior UX, I want to respect the intent of the developer when they say "disable smartlock".
There was a problem hiding this comment.
Sounds fair, but still it makes me sad inside. 😄
samtstern
left a comment
There was a problem hiding this comment.
Mostly LGTM! Just double-checking that I understand the full scope here: rather than have SignInNoPasswordActivity which takes an email alone and checks for existing accounts, we are moving all of that into RegisterEmailActivity and doing the check right there behind a progress dialog.
Any other major changes?
| Button createButton = (Button) findViewById(R.id.button_create); | ||
| createButton.setOnClickListener(this); | ||
|
|
||
| showEmailAutoCompleteHint(); |
There was a problem hiding this comment.
Technically the email hint is provided by SmartLock, so this would make the API somewhat dishonest. Although I agree with you that enabling the hint for everyone may be a superior UX, I want to respect the intent of the developer when they say "disable smartlock".
|
|
||
| @Override | ||
| public void onFocusChange(View view, boolean hasFocus) { | ||
| if (hasFocus) return; |
There was a problem hiding this comment.
Just a general style comment (first noticed it here) but let's add some more comments in meaty methods like this. For instance in this method the first line could use a comment like // Only consider fields losing focus.
| if (task.isSuccessful()) { | ||
| List<String> providers = task.getResult().getProviders(); | ||
| if (providers != null && !providers.isEmpty()) { | ||
| // Account does exist |
There was a problem hiding this comment.
Recommended to expand comments to something like this:
// There is an account tied to this email. If only the email provider is associated with the account, direct the user
// to the email sign in flow. Otherwise, direct the user to sign in with the IDP they previously selected.| new OnCompleteListener<ProviderQueryResult>() { | ||
| @Override | ||
| public void onComplete(@NonNull Task<ProviderQueryResult> task) { | ||
| if (task.isSuccessful()) { |
There was a problem hiding this comment.
nit: use separate success and failure listeners rather than checking task.isSuccessful()
| RC_WELCOME_BACK_IDP); | ||
| } | ||
| } | ||
| } // TODO: 11/23/2016 what happens if we fail? |
There was a problem hiding this comment.
Yeah not sure what the best course of action is here ... since we didn't do anything before let's leave this for another time.
| } | ||
| }) | ||
| .addOnFailureListener(new OnFailureListener() { | ||
| .addOnFailureListener(this, new OnFailureListener() { |
There was a problem hiding this comment.
Any reason we're only tying the failure listener to the Activity and not the success listener?
There was a problem hiding this comment.
Here was my logic:
If the request succeeds, we to continue whether or not the original activity is still there because mSaveSmartLock is already initialized and not tied to the activity lifecycles. That way, the activity will finish and the sign in will proceed.
If it fails, the only thing we are doing in the failure listener is updating views. I'm not sure how that works, but I would think something bad will happen if we try to update a view from a previous instance of an activity. Am I wrong?
Update:
I found RecoverEmailActivity doing the same thing, so I think my logic is correct.
| <string name="progress_dialog_sending">Sending…</string> | ||
| <string name="progress_dialog_signing_in">Signing in…</string> | ||
| <string name="progress_dialog_signing_up">Signing up…</string> | ||
| <string name="progress_dialog_checking_accounts">Checking for existing accounts…</string> |
SUPERCILEX
left a comment
There was a problem hiding this comment.
Yup, this is mostly just unifying the email sign in experience with some small improvements peppered here and there.
| private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME"; | ||
| private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/"; | ||
| private static final String FIREBASE_TOS_URL = "https://www.firebase.com/terms/terms-of-service.html"; | ||
| private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/"; |
There was a problem hiding this comment.
Just noticed this was using the old Firebase.
| .build() | ||
| .launchUrl( | ||
| RegisterEmailActivity.this, | ||
| Uri.parse(mActivityHelper.getFlowParams().termsOfServiceUrl)); |
There was a problem hiding this comment.
Since Facebook forces us to use CCT, I don't see why we shouldn't modernize.
There was a problem hiding this comment.
Agreed, looks great in your screencast!
| startActivity(intent); | ||
| // Getting default color | ||
| TypedValue typedValue = new TypedValue(); | ||
| getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true); |
There was a problem hiding this comment.
This works, but what if they don't have a colorPrimary. (Actually, is it even possible to not have a colorPrimary? I'm pretty sure AppCompatActivity uses that for all default theming)
There was a problem hiding this comment.
I think this should be fine ... and if people see a crash I think saying "you must define colorPrimary" is a reasonable response so not too worried.
| } else if (e instanceof FirebaseAuthUserCollisionException) { | ||
| // Collision with existing user email | ||
| emailInput.setError(getString(R.string.error_user_collision)); | ||
| checkAccountExists(mEmailEditText.getText().toString()); |
There was a problem hiding this comment.
Come to think of it, this could be our error handling if fetchProvidersForEmail fails: the user can't sign up if a user already exists and we will retry loading that user.
samtstern
left a comment
There was a problem hiding this comment.
LGTM! I think I will create a 1.1.0 branch for your three outstanding PRs.
| private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME"; | ||
| private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/"; | ||
| private static final String FIREBASE_TOS_URL = "https://www.firebase.com/terms/terms-of-service.html"; | ||
| private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/"; |
| startActivity(intent); | ||
| // Getting default color | ||
| TypedValue typedValue = new TypedValue(); | ||
| getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true); |
There was a problem hiding this comment.
I think this should be fine ... and if people see a crash I think saying "you must define colorPrimary" is a reasonable response so not too worried.
| .build() | ||
| .launchUrl( | ||
| RegisterEmailActivity.this, | ||
| Uri.parse(mActivityHelper.getFlowParams().termsOfServiceUrl)); |
There was a problem hiding this comment.
Agreed, looks great in your screencast!
| } | ||
| }) | ||
| .addOnFailureListener(new OnFailureListener() { | ||
| .addOnFailureListener(this, new OnFailureListener() { |
|
I just tried to test all of your PRs together and there are some small lingering conflicts. So I made a branch called Let's move PRs #418, #420, and #426 to target that branch and then merge them into there one by one (fixing conflicts as we go). Then we can do some poke-around QA, make sure all dependencies are up to date, and cut a version 1.1.0 release. Sound good? |
|
@samtstern Sounds good, I changed the base for all my PRs and pulled from master. |
I'm really excited about this one!!! The performance/ui/code is massively improved: we've gone from jumping through 3 activities to just saying on
RegisterEmailActivityand everything regarding email flow is so much simpler and easier to understand now! Here are some of the important changes:RegisterEmailActivity