Skip to content

Commit bad1aac

Browse files
author
Aaron Mandle
committed
Make the email login button optional
This was requested by a DPE who is preparing the IO demo. Change-Id: Ia119aa87bf783d256dbee24bc9ca3e5de9def3ee
1 parent 9ccc7ef commit bad1aac

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import android.content.Context;
1818
import android.content.Intent;
19+
import android.os.Bundle;
1920
import android.support.annotation.NonNull;
2021
import android.support.annotation.Nullable;
2122

@@ -24,6 +25,7 @@
2425
import com.firebase.ui.auth.choreographer.idp.provider.IDPProviderParcel;
2526
import com.firebase.ui.auth.ui.credentials.CredentialsInitActivity;
2627
import com.google.firebase.FirebaseApp;
28+
import com.google.firebase.auth.EmailAuthProvider;
2729

2830
import java.util.ArrayList;
2931
import java.util.List;
@@ -32,6 +34,10 @@
3234
* Factory class to configure the intent that starts the auth flow
3335
*/
3436
public class AuthFlowFactory {
37+
public static final String EMAIL_PROVIDER = "email";
38+
public static final String GOOGLE_PROVIDER = "google";
39+
public static final String FACEBOOK_PROVIDER = "facebook";
40+
3541
/**
3642
* Creates the intent that starts the auth flow
3743
*
@@ -73,12 +79,16 @@ public static Intent createIntent(
7379
}
7480

7581
for (String provider : providers) {
76-
if (provider.equalsIgnoreCase("facebook")) {
82+
if (provider.equalsIgnoreCase(FACEBOOK_PROVIDER)) {
7783
providerParcels.add(FacebookProvider.createFacebookParcel(
7884
context.getString(R.string.facebook_application_id)));
79-
} else if (provider.equalsIgnoreCase("google")) {
85+
} else if (provider.equalsIgnoreCase(GOOGLE_PROVIDER)) {
8086
providerParcels.add(
8187
GoogleProvider.createParcel(context.getString(R.string.default_web_client_id)));
88+
} else if (provider.equalsIgnoreCase(EMAIL_PROVIDER)) {
89+
providerParcels.add(
90+
new IDPProviderParcel(EmailAuthProvider.PROVIDER_ID, new Bundle())
91+
);
8292
}
8393
}
8494
return CredentialsInitActivity.createIntent(

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.firebase.ui.auth.choreographer.idp.provider.IDPProvider;
3232
import com.firebase.ui.auth.choreographer.idp.provider.IDPProviderParcel;
3333
import com.firebase.ui.auth.choreographer.idp.provider.IDPResponse;
34+
import com.google.firebase.auth.EmailAuthProvider;
3435
import com.google.firebase.auth.FacebookAuthProvider;
3536
import com.google.firebase.auth.GoogleAuthProvider;
3637

@@ -73,6 +74,9 @@ private void populateIDPList(ArrayList<IDPProviderParcel> mProviders) {
7374
case GoogleAuthProvider.PROVIDER_ID:
7475
mIDPProviders.add(new GoogleProvider(this, providerParcel));
7576
break;
77+
case EmailAuthProvider.PROVIDER_ID:
78+
findViewById(R.id.email_provider).setVisibility(View.VISIBLE);
79+
break;
7680
default:
7781
if (BuildConfig.DEBUG) {
7882
Log.d(TAG, "Encountered unknown IDPProvider parcel with type: "

auth/src/main/res/values/styles.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215

216216
<style name="FirebaseUI.Button.AccountChooser.EmailButton">
217217
<item name="android:drawableLeft">@drawable/ic_email_white_18dp</item>
218+
<item name="android:visibility">gone</item>
218219
<item name="android:background">@drawable/idp_button_background_email</item>
219220
<item name="android:textColor">#ffffff</item>
220221
</style>

0 commit comments

Comments
 (0)