|
51 | 51 | import com.google.firebase.auth.EmailAuthProvider; |
52 | 52 | import com.google.firebase.auth.FacebookAuthProvider; |
53 | 53 | import com.google.firebase.auth.FirebaseAuth; |
54 | | -import com.google.firebase.auth.GithubAuthProvider; |
55 | 54 | import com.google.firebase.auth.GoogleAuthProvider; |
56 | 55 | import com.google.firebase.auth.PhoneAuthProvider; |
57 | 56 |
|
@@ -229,14 +228,36 @@ private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) { |
229 | 228 | for (IdpConfig idpConfig : providerConfigs) { |
230 | 229 | final String providerId = providerOrEmailLinkProvider(idpConfig.getProviderId()); |
231 | 230 |
|
232 | | - if (!providerButtonIds.containsKey(providerId)) { |
| 231 | + Integer buttonResId = providerButtonIds.get(providerId); |
| 232 | + if (buttonResId == null) { |
233 | 233 | throw new IllegalStateException("No button found for auth provider: " + idpConfig.getProviderId()); |
234 | 234 | } |
235 | 235 |
|
236 | | - @IdRes int buttonId = providerButtonIds.get(providerId); |
| 236 | + @IdRes int buttonId = buttonResId; |
237 | 237 | View loginButton = findViewById(buttonId); |
238 | 238 | handleSignInOperation(idpConfig, loginButton); |
239 | 239 | } |
| 240 | + //hide custom layout buttons that don't have their identity provider set |
| 241 | + for (String providerBtnId : providerButtonIds.keySet()) { |
| 242 | + if (providerBtnId == null) { |
| 243 | + continue; |
| 244 | + } |
| 245 | + boolean hasProvider = false; |
| 246 | + for (IdpConfig idpConfig : providerConfigs) { |
| 247 | + if (providerBtnId.equals(idpConfig.getProviderId())) { |
| 248 | + hasProvider = true; |
| 249 | + break; |
| 250 | + } |
| 251 | + } |
| 252 | + if (!hasProvider) { |
| 253 | + Integer resId = providerButtonIds.get(providerBtnId); |
| 254 | + if (resId == null) { |
| 255 | + continue; |
| 256 | + } |
| 257 | + @IdRes int buttonId = resId; |
| 258 | + findViewById(buttonId).setVisibility(View.GONE); |
| 259 | + } |
| 260 | + } |
240 | 261 | } |
241 | 262 |
|
242 | 263 | @NonNull |
|
0 commit comments