File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
main/java/com/firebase/ui/auth/ui/idp
test/java/com/firebase/ui/auth/ui/idp Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -206,7 +206,8 @@ private void populateIdpList(List<IdpConfig> providerConfigs) {
206
206
private void populateIdpListCustomLayout (List <IdpConfig > providerConfigs ) {
207
207
Map <String , Integer > providerButtonIds = customLayout .getProvidersButton ();
208
208
for (IdpConfig idpConfig : providerConfigs ) {
209
- final String providerId = idpConfig .getProviderId ();
209
+ final String providerId = providerOrEmailLinkProvider (idpConfig .getProviderId ());
210
+
210
211
if (!providerButtonIds .containsKey (providerId )) {
211
212
throw new IllegalStateException ("No button found for auth provider: " + providerId );
212
213
}
@@ -217,6 +218,15 @@ private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) {
217
218
}
218
219
}
219
220
221
+ @ NonNull
222
+ private String providerOrEmailLinkProvider (@ NonNull String providerId ) {
223
+ if (providerId .equals (EmailAuthProvider .EMAIL_LINK_SIGN_IN_METHOD )) {
224
+ return EmailAuthProvider .PROVIDER_ID ;
225
+ }
226
+
227
+ return providerId ;
228
+ }
229
+
220
230
private void handleSignInOperation (IdpConfig idpConfig , View view ) {
221
231
ViewModelProvider supplier = ViewModelProviders .of (this );
222
232
final String providerId = idpConfig .getProviderId ();
Original file line number Diff line number Diff line change @@ -122,6 +122,28 @@ public void testCustomAuthMethodPickerLayout() {
122
122
nextIntent .intent .getComponent ().getClassName ());
123
123
}
124
124
125
+ @ Test
126
+ public void testCustomAuthMethodPickerLayoutWithEmailLink () {
127
+ List <String > providers = Arrays .asList (EmailAuthProvider .EMAIL_LINK_SIGN_IN_METHOD );
128
+
129
+ AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout
130
+ .Builder (R .layout .fui_provider_button_email )
131
+ .setEmailButtonId (R .id .email_button )
132
+ .build ();
133
+
134
+ AuthMethodPickerActivity authMethodPickerActivity = createActivityWithCustomLayout (providers , customLayout );
135
+
136
+ Button emailButton = authMethodPickerActivity .findViewById (R .id .email_button );
137
+ emailButton .performClick ();
138
+
139
+ //Expected result -> Directing users to EmailActivity
140
+ ShadowActivity .IntentForResult nextIntent =
141
+ Shadows .shadowOf (authMethodPickerActivity ).getNextStartedActivityForResult ();
142
+ assertEquals (
143
+ EmailActivity .class .getName (),
144
+ nextIntent .intent .getComponent ().getClassName ());
145
+ }
146
+
125
147
private AuthMethodPickerActivity createActivityWithCustomLayout (List <String > providers ,
126
148
AuthMethodPickerLayout layout ) {
127
149
Intent startIntent = AuthMethodPickerActivity .createIntent (
You can’t perform that action at this time.
0 commit comments