Skip to content

Commit a2da107

Browse files
committed
fix email link sign in button not shown when using custom layout
1 parent 735bf7b commit a2da107

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

auth/src/main/java/com/firebase/ui/auth/AuthMethodPickerLayout.java

+8
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ public AuthMethodPickerLayout.Builder setEmailButtonId(@IdRes int emailButton) {
143143
return this;
144144
}
145145

146+
/**
147+
* Set the ID of the Email link sign in button in the custom layout.
148+
*/
149+
public AuthMethodPickerLayout.Builder setEmailLinkButtonId(@IdRes int emailLinkButton) {
150+
providersMapping.put(EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD, emailLinkButton);
151+
return this;
152+
}
153+
146154
/**
147155
* Set the ID of the Phone Number sign in button in the custom layout.
148156
*/

auth/src/main/java/com/firebase/ui/auth/ui/idp/AuthMethodPickerActivity.java

+1-12
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ private void populateIdpList(List<IdpConfig> providerConfigs) {
224224
private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) {
225225
Map<String, Integer> providerButtonIds = customLayout.getProvidersButton();
226226
for (IdpConfig idpConfig : providerConfigs) {
227-
final String providerId = providerOrEmailLinkProvider(idpConfig.getProviderId());
228-
229-
Integer buttonResId = providerButtonIds.get(providerId);
227+
Integer buttonResId = providerButtonIds.get(idpConfig.getProviderId());
230228
if (buttonResId == null) {
231229
throw new IllegalStateException("No button found for auth provider: " + idpConfig.getProviderId());
232230
}
@@ -258,15 +256,6 @@ private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) {
258256
}
259257
}
260258

261-
@NonNull
262-
private String providerOrEmailLinkProvider(@NonNull String providerId) {
263-
if (providerId.equals(EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD)) {
264-
return EmailAuthProvider.PROVIDER_ID;
265-
}
266-
267-
return providerId;
268-
}
269-
270259
private void handleSignInOperation(final IdpConfig idpConfig, View view) {
271260
ViewModelProvider supplier = new ViewModelProvider(this);
272261
final String providerId = idpConfig.getProviderId();

auth/src/test/java/com/firebase/ui/auth/ui/idp/AuthMethodPickerActivityTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void testCustomAuthMethodPickerLayoutWithEmailLink() {
130130

131131
AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout
132132
.Builder(R.layout.fui_provider_button_email)
133-
.setEmailButtonId(R.id.email_button)
133+
.setEmailLinkButtonId(R.id.email_button)
134134
.build();
135135

136136
AuthMethodPickerActivity authMethodPickerActivity = createActivityWithCustomLayout(providers, customLayout, false);

0 commit comments

Comments
 (0)