-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Handle dynamic list of identity providers #1799
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,7 +51,6 @@ | |||||||||
| import com.google.firebase.auth.EmailAuthProvider; | ||||||||||
| import com.google.firebase.auth.FacebookAuthProvider; | ||||||||||
| import com.google.firebase.auth.FirebaseAuth; | ||||||||||
| import com.google.firebase.auth.GithubAuthProvider; | ||||||||||
| import com.google.firebase.auth.GoogleAuthProvider; | ||||||||||
| import com.google.firebase.auth.PhoneAuthProvider; | ||||||||||
|
|
||||||||||
|
|
@@ -229,14 +228,32 @@ private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) { | |||||||||
| for (IdpConfig idpConfig : providerConfigs) { | ||||||||||
| final String providerId = providerOrEmailLinkProvider(idpConfig.getProviderId()); | ||||||||||
|
|
||||||||||
| if (!providerButtonIds.containsKey(providerId)) { | ||||||||||
| Integer buttonResId = providerButtonIds.get(providerId); | ||||||||||
| if (buttonResId == null) { | ||||||||||
| throw new IllegalStateException("No button found for auth provider: " + idpConfig.getProviderId()); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @IdRes int buttonId = providerButtonIds.get(providerId); | ||||||||||
| @IdRes int buttonId = buttonResId; | ||||||||||
| View loginButton = findViewById(buttonId); | ||||||||||
| handleSignInOperation(idpConfig, loginButton); | ||||||||||
| } | ||||||||||
| //hide custom layout buttons that don't have their identity provider set | ||||||||||
| for (String providerBtnId : providerButtonIds.keySet()) { | ||||||||||
| if (providerBtnId == null) continue; | ||||||||||
| boolean hasProvider = false; | ||||||||||
| for (IdpConfig idpConfig : providerConfigs) { | ||||||||||
| if (providerBtnId.equals(idpConfig.getProviderId())) { | ||||||||||
| hasProvider = true; | ||||||||||
| break; | ||||||||||
| } | ||||||||||
| } | ||||||||||
| if (!hasProvider) { | ||||||||||
| Integer resId = providerButtonIds.get(providerBtnId); | ||||||||||
| if (resId == null) continue; | ||||||||||
|
Contributor
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.
Suggested change
Contributor
Author
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. Done.
Contributor
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. Is this null condition even possible? How would we get into this state?
Contributor
Author
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. Well, it's an unboxing, In theory I know that map should only have provider ids and layout res ids. But since that Map is passed around by reference, placing an Integer in it that's later nullified, you can end up with a null here. Better safe than sorry. |
||||||||||
| @IdRes int buttonId = resId; | ||||||||||
| findViewById(buttonId).setVisibility(View.GONE); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @NonNull | ||||||||||
|
|
||||||||||
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.
nit: we try not to use single-line if statements
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.
Done.