Skip to content

Commit 1515b10

Browse files
author
Iain McGinniss
committed
Checkstyle fixes for AuthFlowFactory
This class has not yet been reviewed for consistency with iOS, that will happen later. Change-Id: I65a32f17f49e0d75c1f079b38104179d46a4d994
1 parent cf7aa8a commit 1515b10

File tree

1 file changed

+56
-35
lines changed

1 file changed

+56
-35
lines changed

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

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,76 +28,97 @@
2828
import com.google.firebase.auth.EmailAuthProvider;
2929

3030
import java.util.ArrayList;
31+
import java.util.Collections;
3132
import java.util.List;
3233

3334
/**
34-
* Factory class to configure the intent that starts the auth flow
35+
* Provides the entry point to the user authentication flow.
3536
*/
3637
public class AuthFlowFactory {
38+
39+
/**
40+
* Provider identifier for email and password credentials, for use with {@link #createIntent}.
41+
*/
3742
public static final String EMAIL_PROVIDER = "email";
43+
44+
/**
45+
* Provider identifier for Google, for use with {@link #createIntent}.
46+
*/
3847
public static final String GOOGLE_PROVIDER = "google";
48+
49+
/**
50+
* Provider identifier for Facebook, for use with {@link #createIntent}.
51+
*/
3952
public static final String FACEBOOK_PROVIDER = "facebook";
4053

4154
/**
42-
* Creates the intent that starts the auth flow
55+
* The theme identifier to use in {@link #createIntent} if no theme customization is required.
56+
*/
57+
public static final int DEFAULT_THEME = 0;
58+
59+
/**
60+
* Creates an intent to start the user authentication flow.
61+
*
62+
* <p>IDP Provider instructions:
4363
*
44-
* IDP Provider instructions:
45-
* Enabling Google Sign In: If you're using Google Services Gradle Plugin, there are no additional
46-
* steps needed. If not, please override the R.string.default_web_client_id
47-
* to provider your google oauth web client id.
48-
* Enabling Facebook Sign In: Please override the R.string.facebook_application_id to provide the
49-
* App Id from Facebook Developer Dashboard
64+
* <ul>
65+
* <li>Enabling Google Sign In: If you're using the
66+
* <a href="https://developers.google.com/android/guides/google-services-plugin">Google
67+
* Services Gradle Plugin</a>, no additional configuration is required. If not, please override
68+
* {@code R.string.default_web_client_id} to provide your
69+
* <a href="https://developers.google.com/identity/sign-in/web/devconsole-project">Google OAuth
70+
* web client id.</a>
71+
* </li>
72+
* <li>Enabling Facebook Sign In: Please override the
73+
* {@code R.string.facebook_application_id} to provide the
74+
* <a href="https://developers.facebook.com/docs/apps/register">App Id</a> from
75+
* <a href="https://developers.facebook.com/apps">Facebook Developer Dashboard</a>.
76+
* </li>
77+
* </ul>
5078
*
51-
* @param context activity context
52-
* @param firebaseApp the FirebaseApp that's to used for the authentication flow
53-
* @param termsOfServiceUrl the URL to the Term of Service page to be present to the user
54-
* @param theme the customized theme to be applied to the authentication flow. 0 will use the default theme.
55-
* @param providers the supported identity providers that you wish to enable (google, facebook, etc)
56-
* @return
79+
* @param context The context of the activity that is starting the authentication flow.
80+
* @param firebaseApp the {@link com.google.firebase.FirebaseApp FirebaseApp} instance to
81+
* that the authentication flow should use and update.
82+
* @param tosUrl the URL of the Term of Service page for your app that should be presented to
83+
* the user.
84+
* @param theme the resource identifier of the customized theme to be applied to the
85+
* authentication flow. Use {@link #DEFAULT_THEME} if no customization is required.
86+
* @param providers the identity providers that you wish to enable (e.g.
87+
* {@link #GOOGLE google}, {@link #FACEBOOK facebook}, etc).
88+
* @return An intent to launch the authentication flow.
5789
*/
5890
public static Intent createIntent(
59-
// * @param providers the supported identity providers that you wish to enable (google, facebook, etc)
6091
@NonNull Context context,
6192
@NonNull FirebaseApp firebaseApp,
62-
String termsOfServiceUrl,
93+
String tosUrl,
6394
int theme,
6495
@Nullable List<String> providers) {
65-
ArrayList<IDPProviderParcel> providerParcels = new ArrayList<>();
66-
String appName = firebaseApp.getName();
67-
String apiaryKey = firebaseApp.getOptions().getApiKey();
68-
String applicationId = firebaseApp.getOptions().getApplicationId();
6996
if (providers == null || providers.size() == 0) {
70-
return CredentialsInitActivity.createIntent(
71-
context,
72-
appName,
73-
providerParcels,
74-
apiaryKey,
75-
applicationId,
76-
termsOfServiceUrl,
77-
theme
78-
);
97+
providers = Collections.emptyList();
7998
}
8099

100+
ArrayList<IDPProviderParcel> providerParcels = new ArrayList<>();
81101
for (String provider : providers) {
82102
if (provider.equalsIgnoreCase(FACEBOOK_PROVIDER)) {
83103
providerParcels.add(FacebookProvider.createFacebookParcel(
84104
context.getString(R.string.facebook_application_id)));
85105
} else if (provider.equalsIgnoreCase(GOOGLE_PROVIDER)) {
86-
providerParcels.add(
87-
GoogleProvider.createParcel(context.getString(R.string.default_web_client_id)));
106+
providerParcels.add(GoogleProvider.createParcel(
107+
context.getString(R.string.default_web_client_id)));
88108
} else if (provider.equalsIgnoreCase(EMAIL_PROVIDER)) {
89109
providerParcels.add(
90110
new IDPProviderParcel(EmailAuthProvider.PROVIDER_ID, new Bundle())
91111
);
92112
}
93113
}
114+
94115
return CredentialsInitActivity.createIntent(
95116
context,
96-
appName,
117+
firebaseApp.getName(),
97118
providerParcels,
98-
apiaryKey,
99-
applicationId,
100-
termsOfServiceUrl,
119+
firebaseApp.getOptions().getApiKey(),
120+
firebaseApp.getOptions().getApplicationId(),
121+
tosUrl,
101122
theme
102123
);
103124
}

0 commit comments

Comments
 (0)