Skip to content

Commit 241aeb6

Browse files
authored
Version 6.4.0
Version 6.4.0
2 parents 5fb0fc1 + 873f550 commit 241aeb6

File tree

14 files changed

+240
-24
lines changed

14 files changed

+240
-24
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ libraries.
4848
```groovy
4949
dependencies {
5050
// FirebaseUI for Firebase Realtime Database
51-
implementation 'com.firebaseui:firebase-ui-database:6.3.0'
51+
implementation 'com.firebaseui:firebase-ui-database:6.4.0'
5252
5353
// FirebaseUI for Cloud Firestore
54-
implementation 'com.firebaseui:firebase-ui-firestore:6.3.0'
54+
implementation 'com.firebaseui:firebase-ui-firestore:6.4.0'
5555
5656
// FirebaseUI for Firebase Auth
57-
implementation 'com.firebaseui:firebase-ui-auth:6.3.0'
57+
implementation 'com.firebaseui:firebase-ui-auth:6.4.0'
5858
5959
// FirebaseUI for Cloud Storage
60-
implementation 'com.firebaseui:firebase-ui-storage:6.3.0'
60+
implementation 'com.firebaseui:firebase-ui-storage:6.4.0'
6161
}
6262
```
6363

auth/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Gradle, add the dependency:
6565
```groovy
6666
dependencies {
6767
// ...
68-
implementation 'com.firebaseui:firebase-ui-auth:6.3.0'
68+
implementation 'com.firebaseui:firebase-ui-auth:6.4.0'
6969
7070
// Required only if Facebook login support is required
7171
// Find the latest Facebook SDK releases here: https://github.com/facebook/facebook-android-sdk/blob/master/CHANGELOG.md

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

+59-1
Original file line numberDiff line numberDiff line change
@@ -1201,14 +1201,17 @@ public GenericOAuthProviderBuilder setCustomParameters(
12011201
@SuppressWarnings(value = "unchecked")
12021202
private abstract class AuthIntentBuilder<T extends AuthIntentBuilder> {
12031203
final List<IdpConfig> mProviders = new ArrayList<>();
1204+
IdpConfig mDefaultProvider = null;
12041205
int mLogo = NO_LOGO;
12051206
int mTheme = getDefaultTheme();
12061207
String mTosUrl;
12071208
String mPrivacyPolicyUrl;
12081209
boolean mAlwaysShowProviderChoice = false;
1210+
boolean mLockOrientation = false;
12091211
boolean mEnableCredentials = true;
12101212
boolean mEnableHints = true;
12111213
AuthMethodPickerLayout mAuthMethodPickerLayout = null;
1214+
ActionCodeSettings mPasswordSettings = null;
12121215

12131216
/**
12141217
* Specifies the theme to use for the application flow. If no theme is specified, a
@@ -1270,7 +1273,7 @@ public T setTosAndPrivacyPolicyUrls(@NonNull String tosUrl,
12701273
}
12711274

12721275
/**
1273-
* Specified the set of supported authentication providers. At least one provider must
1276+
* Specifies the set of supported authentication providers. At least one provider must
12741277
* be specified. There may only be one instance of each provider. Anonymous provider cannot
12751278
* be the only provider specified.
12761279
* <p>
@@ -1307,6 +1310,29 @@ public T setAvailableProviders(@NonNull List<IdpConfig> idpConfigs) {
13071310
return (T) this;
13081311
}
13091312

1313+
/**
1314+
* Specifies the default authentication provider, bypassing the provider selection screen.
1315+
* The provider here must already be included via {@link #setAvailableProviders(List)}, and
1316+
* this method is incompatible with {@link #setAlwaysShowSignInMethodScreen(boolean)}.
1317+
*
1318+
* @param config the default {@link IdpConfig} to use.
1319+
*/
1320+
@NonNull
1321+
public T setDefaultProvider(@Nullable IdpConfig config) {
1322+
if (config != null) {
1323+
if (!mProviders.contains(config)) {
1324+
throw new IllegalStateException(
1325+
"Default provider not in available providers list.");
1326+
}
1327+
if (mAlwaysShowProviderChoice) {
1328+
throw new IllegalStateException(
1329+
"Can't set default provider and always show provider choice.");
1330+
}
1331+
}
1332+
mDefaultProvider = config;
1333+
return (T) this;
1334+
}
1335+
13101336
/**
13111337
* Enables or disables the use of Smart Lock for Passwords in the sign in flow. To
13121338
* (en)disable hint selector and credential selector independently use {@link
@@ -1359,10 +1385,39 @@ public T setAuthMethodPickerLayout(@NonNull AuthMethodPickerLayout authMethodPic
13591385
*/
13601386
@NonNull
13611387
public T setAlwaysShowSignInMethodScreen(boolean alwaysShow) {
1388+
if (alwaysShow && mDefaultProvider != null) {
1389+
throw new IllegalStateException(
1390+
"Can't show provider choice with a default provider.");
1391+
}
13621392
mAlwaysShowProviderChoice = alwaysShow;
13631393
return (T) this;
13641394
}
13651395

1396+
/**
1397+
* Enable or disables the orientation for small devices to be locked in
1398+
* Portrait orientation
1399+
* <p>
1400+
* <p>This is false by default.
1401+
*
1402+
* @param lockOrientation if true, force the activities to be in Portrait orientation.
1403+
*/
1404+
@NonNull
1405+
public T setLockOrientation(boolean lockOrientation) {
1406+
mLockOrientation = lockOrientation;
1407+
return (T) this;
1408+
}
1409+
1410+
/**
1411+
* Set custom settings for the RecoverPasswordActivity.
1412+
*
1413+
* @param passwordSettings to allow additional state via a continue URL.
1414+
*/
1415+
@NonNull
1416+
public T setResetPasswordSettings(ActionCodeSettings passwordSettings) {
1417+
mPasswordSettings = passwordSettings;
1418+
return (T) this;
1419+
}
1420+
13661421
@CallSuper
13671422
@NonNull
13681423
public Intent build() {
@@ -1431,6 +1486,7 @@ protected FlowParameters getFlowParams() {
14311486
return new FlowParameters(
14321487
mApp.getName(),
14331488
mProviders,
1489+
mDefaultProvider,
14341490
mTheme,
14351491
mLogo,
14361492
mTosUrl,
@@ -1439,7 +1495,9 @@ protected FlowParameters getFlowParams() {
14391495
mEnableHints,
14401496
mEnableAnonymousUpgrade,
14411497
mAlwaysShowProviderChoice,
1498+
mLockOrientation,
14421499
mEmailLink,
1500+
mPasswordSettings,
14431501
mAuthMethodPickerLayout);
14441502
}
14451503
}

auth/src/main/java/com/firebase/ui/auth/data/model/FlowParameters.java

+28-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.firebase.ui.auth.AuthUI.IdpConfig;
2323
import com.firebase.ui.auth.util.ExtraConstants;
2424
import com.firebase.ui.auth.util.Preconditions;
25+
import com.google.firebase.auth.ActionCodeSettings;
2526

2627
import java.util.Collections;
2728
import java.util.List;
@@ -44,6 +45,7 @@ public class FlowParameters implements Parcelable {
4445
public FlowParameters createFromParcel(Parcel in) {
4546
String appName = in.readString();
4647
List<IdpConfig> providerInfo = in.createTypedArrayList(IdpConfig.CREATOR);
48+
IdpConfig defaultProvider = in.readParcelable(IdpConfig.class.getClassLoader());
4749
int themeId = in.readInt();
4850
int logoId = in.readInt();
4951
String termsOfServiceUrl = in.readString();
@@ -52,12 +54,15 @@ public FlowParameters createFromParcel(Parcel in) {
5254
boolean enableHints = in.readInt() != 0;
5355
boolean enableAnonymousUpgrade = in.readInt() != 0;
5456
boolean alwaysShowProviderChoice = in.readInt() != 0;
57+
boolean lockOrientation = in.readInt() != 0;
5558
String emailLink = in.readString();
59+
ActionCodeSettings passwordResetSettings = in.readParcelable(ActionCodeSettings.class.getClassLoader());
5660
AuthMethodPickerLayout customLayout = in.readParcelable(AuthMethodPickerLayout.class.getClassLoader());
5761

5862
return new FlowParameters(
5963
appName,
6064
providerInfo,
65+
defaultProvider,
6166
themeId,
6267
logoId,
6368
termsOfServiceUrl,
@@ -66,7 +71,9 @@ public FlowParameters createFromParcel(Parcel in) {
6671
enableHints,
6772
enableAnonymousUpgrade,
6873
alwaysShowProviderChoice,
74+
lockOrientation,
6975
emailLink,
76+
passwordResetSettings,
7077
customLayout);
7178
}
7279

@@ -82,6 +89,9 @@ public FlowParameters[] newArray(int size) {
8289
@NonNull
8390
public final List<IdpConfig> providers;
8491

92+
@Nullable
93+
public final IdpConfig defaultProvider;
94+
8595
@StyleRes
8696
public final int themeId;
8797

@@ -97,17 +107,22 @@ public FlowParameters[] newArray(int size) {
97107
@Nullable
98108
public String emailLink;
99109

110+
@Nullable
111+
public final ActionCodeSettings passwordResetSettings;
112+
100113
public final boolean enableCredentials;
101114
public final boolean enableHints;
102115
public final boolean enableAnonymousUpgrade;
103116
public final boolean alwaysShowProviderChoice;
117+
public final boolean lockOrientation;
104118

105119
@Nullable
106120
public final AuthMethodPickerLayout authMethodPickerLayout;
107121

108122
public FlowParameters(
109123
@NonNull String appName,
110124
@NonNull List<IdpConfig> providers,
125+
@Nullable IdpConfig defaultProvider,
111126
@StyleRes int themeId,
112127
@DrawableRes int logoId,
113128
@Nullable String termsOfServiceUrl,
@@ -116,11 +131,14 @@ public FlowParameters(
116131
boolean enableHints,
117132
boolean enableAnonymousUpgrade,
118133
boolean alwaysShowProviderChoice,
134+
boolean lockOrientation,
119135
@Nullable String emailLink,
136+
@Nullable ActionCodeSettings passwordResetSettings,
120137
@Nullable AuthMethodPickerLayout authMethodPickerLayout) {
121138
this.appName = Preconditions.checkNotNull(appName, "appName cannot be null");
122139
this.providers = Collections.unmodifiableList(
123140
Preconditions.checkNotNull(providers, "providers cannot be null"));
141+
this.defaultProvider = defaultProvider;
124142
this.themeId = themeId;
125143
this.logoId = logoId;
126144
this.termsOfServiceUrl = termsOfServiceUrl;
@@ -129,7 +147,9 @@ public FlowParameters(
129147
this.enableHints = enableHints;
130148
this.enableAnonymousUpgrade = enableAnonymousUpgrade;
131149
this.alwaysShowProviderChoice = alwaysShowProviderChoice;
150+
this.lockOrientation = lockOrientation;
132151
this.emailLink = emailLink;
152+
this.passwordResetSettings = passwordResetSettings;
133153
this.authMethodPickerLayout = authMethodPickerLayout;
134154
}
135155

@@ -144,6 +164,7 @@ public static FlowParameters fromIntent(Intent intent) {
144164
public void writeToParcel(Parcel dest, int flags) {
145165
dest.writeString(appName);
146166
dest.writeTypedList(providers);
167+
dest.writeParcelable(defaultProvider, flags);
147168
dest.writeInt(themeId);
148169
dest.writeInt(logoId);
149170
dest.writeString(termsOfServiceUrl);
@@ -152,7 +173,9 @@ public void writeToParcel(Parcel dest, int flags) {
152173
dest.writeInt(enableHints ? 1 : 0);
153174
dest.writeInt(enableAnonymousUpgrade ? 1 : 0);
154175
dest.writeInt(alwaysShowProviderChoice ? 1 : 0);
176+
dest.writeInt(lockOrientation ? 1 : 0);
155177
dest.writeString(emailLink);
178+
dest.writeParcelable(passwordResetSettings, flags);
156179
dest.writeParcelable(authMethodPickerLayout, flags);
157180
}
158181

@@ -178,6 +201,10 @@ public boolean isAnonymousUpgradeEnabled() {
178201
}
179202

180203
public boolean shouldShowProviderChoice() {
181-
return !isSingleProviderFlow() || alwaysShowProviderChoice;
204+
return defaultProvider == null && (!isSingleProviderFlow() || alwaysShowProviderChoice);
205+
}
206+
207+
public IdpConfig getDefaultOrFirstProvider() {
208+
return defaultProvider != null ? defaultProvider : providers.get(0);
182209
}
183210
}

auth/src/main/java/com/firebase/ui/auth/data/remote/GenericIdpSignInHandler.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ protected void handleNormalSignInFlow(final FirebaseAuth auth,
8686
@Override
8787
public void onSuccess(@NonNull AuthResult authResult) {
8888
handleSuccess(provider.getProviderId(),
89-
authResult.getUser(), (OAuthCredential)
90-
authResult.getCredential());
89+
authResult.getUser(),
90+
(OAuthCredential) authResult.getCredential(),
91+
authResult.getAdditionalUserInfo().isNewUser());
9192
}
9293
})
9394
.addOnFailureListener(
@@ -135,8 +136,9 @@ private void handleAnonymousUpgradeFlow(final FirebaseAuth auth,
135136
@Override
136137
public void onSuccess(@NonNull AuthResult authResult) {
137138
handleSuccess(provider.getProviderId(),
138-
authResult.getUser(), (OAuthCredential)
139-
authResult.getCredential());
139+
authResult.getUser(),
140+
(OAuthCredential) authResult.getCredential(),
141+
authResult.getAdditionalUserInfo().isNewUser());
140142
}
141143
})
142144
.addOnFailureListener(
@@ -221,6 +223,7 @@ protected OAuthProvider buildOAuthProvider(String providerId) {
221223
protected void handleSuccess(@NonNull String providerId,
222224
@NonNull FirebaseUser user,
223225
@NonNull OAuthCredential credential,
226+
boolean isNewUser,
224227
boolean setPendingCredential) {
225228
IdpResponse.Builder response = new IdpResponse.Builder(
226229
new User.Builder(
@@ -234,14 +237,16 @@ protected void handleSuccess(@NonNull String providerId,
234237
if (setPendingCredential) {
235238
response.setPendingCredential(credential);
236239
}
240+
response.setNewUser(isNewUser);
237241

238242
setResult(Resource.<IdpResponse>forSuccess(response.build()));
239243
}
240244

241245
protected void handleSuccess(@NonNull String providerId,
242246
@NonNull FirebaseUser user,
243-
@NonNull OAuthCredential credential) {
244-
handleSuccess(providerId, user, credential, /* setPendingCredential= */false);
247+
@NonNull OAuthCredential credential,
248+
boolean isNewUser) {
249+
handleSuccess(providerId, user, credential, isNewUser, /* setPendingCredential= */true);
245250
}
246251

247252

auth/src/main/java/com/firebase/ui/auth/data/remote/SignInKickstarter.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ public void onComplete(@NonNull Task<CredentialRequestResponse> task) {
135135
}
136136

137137
private void startAuthMethodChoice() {
138-
// If there is only one provider selected, launch the flow directly
139138
if (!getArguments().shouldShowProviderChoice()) {
140-
AuthUI.IdpConfig firstIdpConfig = getArguments().providers.get(0);
139+
AuthUI.IdpConfig firstIdpConfig = getArguments().getDefaultOrFirstProvider();
141140
String firstProvider = firstIdpConfig.getProviderId();
142141
switch (firstProvider) {
143142
case EMAIL_LINK_PROVIDER:

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

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.firebase.ui.auth.ui;
1616

17+
import android.annotation.SuppressLint;
18+
import android.content.pm.ActivityInfo;
1719
import android.os.Bundle;
1820

1921
import com.firebase.ui.auth.R;
@@ -31,6 +33,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3133
super.onCreate(savedInstanceState);
3234
setTheme(R.style.FirebaseUI); // Provides default values
3335
setTheme(getFlowParams().themeId);
36+
37+
if (getFlowParams().lockOrientation) {
38+
lockOrientation();
39+
}
3440
}
3541

3642
protected void switchFragment(@NonNull Fragment fragment,
@@ -53,4 +59,9 @@ protected void switchFragment(@NonNull Fragment fragment,
5359
protected void switchFragment(@NonNull Fragment fragment, int fragmentId, @NonNull String tag) {
5460
switchFragment(fragment, fragmentId, tag, false, false);
5561
}
62+
63+
@SuppressLint("SourceLockedOrientationActivity")
64+
private void lockOrientation() {
65+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
66+
}
5667
}

auth/src/main/java/com/firebase/ui/auth/ui/email/RecoverPasswordActivity.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.firebase.ui.auth.viewmodel.ResourceObserver;
3535
import com.firebase.ui.auth.viewmodel.email.RecoverPasswordHandler;
3636
import com.google.android.material.textfield.TextInputLayout;
37+
import com.google.firebase.auth.ActionCodeSettings;
3738
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
3839
import com.google.firebase.auth.FirebaseAuthInvalidUserException;
3940

@@ -118,10 +119,18 @@ public void onClick(View view) {
118119
@Override
119120
public void onDonePressed() {
120121
if (mEmailFieldValidator.validate(mEmailEditText.getText())) {
121-
mHandler.startReset(mEmailEditText.getText().toString());
122+
if (getFlowParams().passwordResetSettings != null) {
123+
resetPassword(mEmailEditText.getText().toString(), getFlowParams().passwordResetSettings);
124+
}
125+
else {
126+
resetPassword(mEmailEditText.getText().toString(), null);
127+
}
122128
}
123129
}
124130

131+
private void resetPassword(String email, @Nullable ActionCodeSettings passwordResetSettings) {
132+
mHandler.startReset(email, passwordResetSettings);
133+
}
125134
private void showEmailSentDialog(String email) {
126135
new AlertDialog.Builder(this)
127136
.setTitle(R.string.fui_title_confirm_recover_password)

0 commit comments

Comments
 (0)