|
47 | 47 | import com.firebase.ui.auth.viewmodel.ProviderSignInBase;
|
48 | 48 | import com.firebase.ui.auth.viewmodel.ResourceObserver;
|
49 | 49 | import com.firebase.ui.auth.viewmodel.idp.SocialProviderResponseHandler;
|
| 50 | +import com.google.android.material.snackbar.Snackbar; |
50 | 51 | import com.google.firebase.FirebaseApp;
|
51 | 52 | import com.google.firebase.auth.EmailAuthProvider;
|
52 | 53 | import com.google.firebase.auth.FacebookAuthProvider;
|
53 | 54 | import com.google.firebase.auth.FirebaseAuth;
|
54 |
| -import com.google.firebase.auth.GithubAuthProvider; |
55 | 55 | import com.google.firebase.auth.GoogleAuthProvider;
|
56 | 56 | import com.google.firebase.auth.PhoneAuthProvider;
|
57 | 57 |
|
@@ -229,14 +229,36 @@ private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) {
|
229 | 229 | for (IdpConfig idpConfig : providerConfigs) {
|
230 | 230 | final String providerId = providerOrEmailLinkProvider(idpConfig.getProviderId());
|
231 | 231 |
|
232 |
| - if (!providerButtonIds.containsKey(providerId)) { |
| 232 | + Integer buttonResId = providerButtonIds.get(providerId); |
| 233 | + if (buttonResId == null) { |
233 | 234 | throw new IllegalStateException("No button found for auth provider: " + idpConfig.getProviderId());
|
234 | 235 | }
|
235 | 236 |
|
236 |
| - @IdRes int buttonId = providerButtonIds.get(providerId); |
| 237 | + @IdRes int buttonId = buttonResId; |
237 | 238 | View loginButton = findViewById(buttonId);
|
238 | 239 | handleSignInOperation(idpConfig, loginButton);
|
239 | 240 | }
|
| 241 | + //hide custom layout buttons that don't have their identity provider set |
| 242 | + for (String providerBtnId : providerButtonIds.keySet()) { |
| 243 | + if (providerBtnId == null) { |
| 244 | + continue; |
| 245 | + } |
| 246 | + boolean hasProvider = false; |
| 247 | + for (IdpConfig idpConfig : providerConfigs) { |
| 248 | + if (providerBtnId.equals(idpConfig.getProviderId())) { |
| 249 | + hasProvider = true; |
| 250 | + break; |
| 251 | + } |
| 252 | + } |
| 253 | + if (!hasProvider) { |
| 254 | + Integer resId = providerButtonIds.get(providerBtnId); |
| 255 | + if (resId == null) { |
| 256 | + continue; |
| 257 | + } |
| 258 | + @IdRes int buttonId = resId; |
| 259 | + findViewById(buttonId).setVisibility(View.GONE); |
| 260 | + } |
| 261 | + } |
240 | 262 | }
|
241 | 263 |
|
242 | 264 | @NonNull
|
@@ -341,7 +363,7 @@ private void handleResponse(@NonNull IdpResponse response) {
|
341 | 363 | @Override
|
342 | 364 | public void onClick(View view) {
|
343 | 365 | if (isOffline()) {
|
344 |
| - Toast.makeText(AuthMethodPickerActivity.this, getString(R.string.fui_no_internet), Toast.LENGTH_SHORT).show(); |
| 366 | + Snackbar.make(findViewById(android.R.id.content), getString(R.string.fui_no_internet), Snackbar.LENGTH_SHORT).show(); |
345 | 367 | return;
|
346 | 368 | }
|
347 | 369 |
|
|
0 commit comments