@@ -109,7 +109,6 @@ public final class AuthUI {
109
109
public static final String YAHOO_PROVIDER = "yahoo.com" ;
110
110
public static final String APPLE_PROVIDER = "apple.com" ;
111
111
112
-
113
112
/**
114
113
* Default value for logo resource, omits the logo from the {@link AuthMethodPickerActivity}.
115
114
*/
@@ -161,6 +160,9 @@ public final class AuthUI {
161
160
private final FirebaseApp mApp ;
162
161
private final FirebaseAuth mAuth ;
163
162
163
+ private String mEmulatorHost = null ;
164
+ private int mEmulatorPort = -1 ;
165
+
164
166
private AuthUI (FirebaseApp app ) {
165
167
mApp = app ;
166
168
mAuth = FirebaseAuth .getInstance (mApp );
@@ -196,6 +198,16 @@ public static AuthUI getInstance() {
196
198
return getInstance (FirebaseApp .getInstance ());
197
199
}
198
200
201
+ /**
202
+ * Retrieves the {@link AuthUI} instance associated the the specified app name.
203
+ *
204
+ * @throws IllegalStateException if the app is not initialized.
205
+ */
206
+ @ NonNull
207
+ public static AuthUI getInstance (@ NonNull String appName ) {
208
+ return getInstance (FirebaseApp .getInstance (appName ));
209
+ }
210
+
199
211
/**
200
212
* Retrieves the {@link AuthUI} instance associated the the specified app.
201
213
*/
@@ -223,6 +235,18 @@ public static AuthUI getInstance(@NonNull FirebaseApp app) {
223
235
return authUi ;
224
236
}
225
237
238
+ @ NonNull
239
+ @ RestrictTo (RestrictTo .Scope .LIBRARY_GROUP )
240
+ public FirebaseApp getApp () {
241
+ return mApp ;
242
+ }
243
+
244
+ @ NonNull
245
+ @ RestrictTo (RestrictTo .Scope .LIBRARY_GROUP )
246
+ public FirebaseAuth getAuth () {
247
+ return mAuth ;
248
+ }
249
+
226
250
/**
227
251
* Returns true if AuthUI can handle the intent.
228
252
* <p>
@@ -460,6 +484,34 @@ public Task<Void> then(@NonNull Task<Void> task) {
460
484
});
461
485
}
462
486
487
+ /**
488
+ * Connect to the Firebase Authentication emulator.
489
+ * @see FirebaseAuth#useEmulator(String, int)
490
+ */
491
+ public void useEmulator (@ NonNull String host , int port ) {
492
+ Preconditions .checkArgument (port >= 0 , "Port must be >= 0" );
493
+ Preconditions .checkArgument (port <= 65535 , "Port must be <= 65535" );
494
+ mEmulatorHost = host ;
495
+ mEmulatorPort = port ;
496
+
497
+ mAuth .useEmulator (host , port );
498
+ }
499
+
500
+ @ RestrictTo (RestrictTo .Scope .LIBRARY_GROUP )
501
+ public boolean isUseEmulator () {
502
+ return mEmulatorHost != null && mEmulatorPort >= 0 ;
503
+ }
504
+
505
+ @ RestrictTo (RestrictTo .Scope .LIBRARY_GROUP )
506
+ public String getEmulatorHost () {
507
+ return mEmulatorHost ;
508
+ }
509
+
510
+ @ RestrictTo (RestrictTo .Scope .LIBRARY_GROUP )
511
+ public int getEmulatorPort () {
512
+ return mEmulatorPort ;
513
+ }
514
+
463
515
private Task <Void > signOutIdps (@ NonNull Context context ) {
464
516
if (ProviderAvailability .IS_FACEBOOK_AVAILABLE ) {
465
517
LoginManager .getInstance ().logOut ();
@@ -1160,9 +1212,9 @@ public YahooBuilder() {
1160
1212
*/
1161
1213
public static class GenericOAuthProviderBuilder extends Builder {
1162
1214
1163
- GenericOAuthProviderBuilder (@ NonNull String providerId ,
1164
- @ NonNull String providerName ,
1165
- int buttonId ) {
1215
+ public GenericOAuthProviderBuilder (@ NonNull String providerId ,
1216
+ @ NonNull String providerName ,
1217
+ int buttonId ) {
1166
1218
super (providerId );
1167
1219
1168
1220
Preconditions .checkNotNull (providerId , "The provider ID cannot be null." );
0 commit comments