Skip to content

Version 9.0.0 #2192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Gradle
run: ./scripts/build.sh
- name: Print Logs
if: failure()
run: ./scripts/print_build_logs.sh
- uses: actions/checkout@v2
- name: set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Build with Gradle
run: ./scripts/build.sh
- name: Print Logs
if: failure()
run: ./scripts/print_build_logs.sh
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ libraries.
```groovy
dependencies {
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:8.0.2'
implementation 'com.firebaseui:firebase-ui-database:9.0.0'

// FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:8.0.2'
implementation 'com.firebaseui:firebase-ui-firestore:9.0.0'

// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:8.0.2'
implementation 'com.firebaseui:firebase-ui-auth:9.0.0'

// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:8.0.2'
implementation 'com.firebaseui:firebase-ui-storage:9.0.0'
}
```

Expand All @@ -71,6 +71,7 @@ After the project is synchronized, we're ready to start using Firebase functiona
If you are using an old version of FirebaseUI and upgrading, please see the appropriate
migration guide:

* [Upgrade from 8.0.2 to 9.x.x](./docs/upgrade-to-9.0.md)
* [Upgrade from 7.2.0 to 8.x.x](./docs/upgrade-to-8.0.md)
* [Upgrade from 6.4.0 to 7.x.x](./docs/upgrade-to-7.0.md)
* [Upgrade from 5.1.0 to 6.x.x](./docs/upgrade-to-6.0.md)
Expand Down
9 changes: 4 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ plugins {
android {
compileSdk = Config.SdkVersions.compile

namespace = "com.firebase.uidemo"

defaultConfig {
minSdk = Config.SdkVersions.min
targetSdk = Config.SdkVersions.target
Expand Down Expand Up @@ -60,8 +62,8 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

buildFeatures {
Expand Down Expand Up @@ -95,9 +97,6 @@ dependencies {
implementation(Config.Libs.Misc.permissions)
implementation(Config.Libs.Androidx.constraint)
debugImplementation(Config.Libs.Misc.leakCanary)
debugImplementation(Config.Libs.Misc.leakCanaryFragments)
releaseImplementation(Config.Libs.Misc.leakCanaryNoop)
testImplementation(Config.Libs.Misc.leakCanaryNoop)
}

apply(plugin = "com.google.gms.google-services")
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.firebase.uidemo">
>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand Down Expand Up @@ -41,7 +41,7 @@
android:label="@string/title_auth_activity" />
<activity
android:name=".auth.AnonymousUpgradeActivity"
android:label="@string/title_anonymous_upgrade"/>
android:label="@string/title_anonymous_upgrade" />

<!-- Firestore demo -->
<activity
Expand Down Expand Up @@ -74,4 +74,4 @@

</application>

</manifest>
</manifest>
13 changes: 0 additions & 13 deletions app/src/main/java/com/firebase/uidemo/FirebaseUIDemo.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
package com.firebase.uidemo;

import com.squareup.leakcanary.LeakCanary;

import androidx.appcompat.app.AppCompatDelegate;
import androidx.multidex.MultiDexApplication;

public class FirebaseUIDemo extends MultiDexApplication {
static {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
}

@Override
public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
}
}
18 changes: 3 additions & 15 deletions app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

mBinding.signIn.setOnClickListener(view -> signIn());

mBinding.signInSilent.setOnClickListener(view -> silentSignIn());

if (ConfigurationUtils.isGoogleMisconfigured(this)
|| ConfigurationUtils.isFacebookMisconfigured(this)) {
showSnackbar(R.string.configuration_required);
Expand Down Expand Up @@ -196,8 +194,7 @@ private Intent getSignInIntent(@Nullable String link) {
.setTheme(getSelectedTheme())
.setLogo(getSelectedLogo())
.setAvailableProviders(getSelectedProviders())
.setIsSmartLockEnabled(mBinding.credentialSelectorEnabled.isChecked(),
mBinding.hintSelectorEnabled.isChecked());
.setCredentialManagerEnabled(mBinding.credentialSelectorEnabled.isChecked());

if (mBinding.customLayout.isChecked()) {
AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout
Expand Down Expand Up @@ -226,18 +223,9 @@ private Intent getSignInIntent(@Nullable String link) {
if (auth.getCurrentUser() != null && auth.getCurrentUser().isAnonymous()) {
builder.enableAnonymousUsersAutoUpgrade();
}
return builder.build();
}

public void silentSignIn() {
getAuthUI().silentSignIn(this, getSelectedProviders())
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
startSignedInActivity(null);
} else {
showSnackbar(R.string.sign_in_failed);
}
});
builder.setAlwaysShowSignInMethodScreen(true);
return builder.build();
}

@Override
Expand Down
23 changes: 4 additions & 19 deletions app/src/main/res/layout/auth_ui_layout.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
Expand Down Expand Up @@ -27,7 +28,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/launch_title"
app:drawableTopCompat="@drawable/firebase_auth_120dp"/>
app:drawableTopCompat="@drawable/firebase_auth_120dp" />

<Button
android:id="@+id/sign_in"
Expand All @@ -38,15 +39,6 @@
android:layout_marginTop="16dp"
android:text="@string/sign_in_start" />

<Button
android:id="@+id/sign_in_silent"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="16dp"
android:text="@string/sign_in_silent" />

<TextView
style="@style/TextAppearance.MaterialComponents.Subtitle1"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -320,13 +312,6 @@
android:checked="true"
android:text="@string/options_enable_credential_selector" />

<CheckBox
android:id="@+id/hint_selector_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/options_enable_hint_selector" />

<CheckBox
android:id="@+id/allow_new_email_accounts"
android:layout_width="wrap_content"
Expand All @@ -352,4 +337,4 @@

</ScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
3 changes: 1 addition & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
<string name="facebook_permission_photos">Photos</string>

<string name="options_header">Other Options</string>
<string name="options_enable_credential_selector">Enable Smart Lock\'s credential selector</string>
<string name="options_enable_hint_selector">Enable Smart Lock\'s hint selector</string>
<string name="options_enable_credential_selector">Enable Credential Manager\'s credential selector</string>
<string name="options_allow_new_email_acccount">Allow new account creation</string>
<string name="options_require_name">Require first/last name with email accounts.</string>
<string name="options_use_auth_emulator">Connect to auth emulator (localhost:9099).</string>
Expand Down
84 changes: 11 additions & 73 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ providers such as Google Sign-In, and Facebook Login. It is built on top of

The best practices embodied in FirebaseUI aim to maximize sign-in
and sign-up conversion for your app. It integrates with
[Smart Lock for Passwords](https://developers.google.com/identity/smartlock-passwords/android/)
[Credential Manager](https://developer.android.com/identity/sign-in/credential-manager)
to store and retrieve credentials, enabling automatic and single-tap sign-in to
your app for returning users. It also handles tricky use cases like
account recovery and account linking that are security sensitive and
Expand All @@ -38,7 +38,6 @@ and [Web](https://github.com/firebase/firebaseui-web/).
1. [Usage instructions](#using-firebaseui-for-authentication)
1. [AuthUI sign-in](#authui-sign-in)
1. [Handling responses](#handling-the-sign-in-response)
1. [Silent sign-in](#silent-sign-in)
1. [Sign out](#sign-out)
1. [Account deletion](#deleting-accounts)
1. [Upgrading Anonymous Users](#upgrading-anonymous-users)
Expand All @@ -65,7 +64,7 @@ Gradle, add the dependency:
```groovy
dependencies {
// ...
implementation 'com.firebaseui:firebase-ui-auth:8.0.2'
implementation 'com.firebaseui:firebase-ui-auth:9.0.0'

// Required only if Facebook login support is required
// Find the latest Facebook SDK releases here: https://github.com/facebook/facebook-android-sdk/blob/master/CHANGELOG.md
Expand Down Expand Up @@ -406,45 +405,19 @@ Intent signInIntent =
.build();
```

##### Smart Lock
##### Credential Manager

By default, FirebaseUI uses [Smart Lock for Passwords](https://developers.google.com/identity/smartlock-passwords/android/)
By default, FirebaseUI uses [Credential Manager](https://developer.android.com/identity/sign-in/credential-manager)
to store the user's credentials and automatically sign users into your app on subsequent attempts.
Using Smart Lock is recommended to provide the best user experience, but in some cases you may want
to disable Smart Lock for testing or development. To disable Smart Lock, you can use the
`setIsSmartLockEnabled` method when building your sign-in Intent:
Using Credential Manager is recommended to provide the best user experience, but in some cases you may want
to disable Credential Manager for testing or development. To disable Credential Manager, you can use the
`setCredentialManagerEnabled` method when building your sign-in Intent:

```java
Intent signInIntent =
AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(false)
.build();
```

###### Smart Lock hints

If you'd like to keep Smart Lock's "hints" but disable the saving/retrieving of credentials, then
you can use the two-argument version of `setIsSmartLockEnabled`:

```java
Intent signInIntent =
AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(false, true)
.build();
```

###### Smart Lock in dev builds

It is often desirable to disable Smart Lock in development but enable it in production. To achieve
this, you can use the `BuildConfig.DEBUG` flag to control Smart Lock:

```java
Intent signInIntent =
AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(!BuildConfig.DEBUG /* credentials */, true /* hints */)
.setCredentialManagerEnabled(false)
.build();
```

Expand Down Expand Up @@ -603,48 +576,13 @@ if (metadata.getCreationTimestamp() == metadata.getLastSignInTimestamp()) {
}
```

### Silent sign-in

If a user is not currently signed in, then a silent sign-in process can be started first before
displaying any UI to provide a seamless experience. Silent sign-in uses saved Smart Lock credentials
and returns a successful `Task` only if the user has been fully signed in with Firebase.

Here's an example of how you could use silent sign-in paired with Firebase anonymous sign-in to get
your users up and running as fast as possible:

```java
List<IdpConfig> providers = getSelectedProviders();
AuthUI.getInstance().silentSignIn(this, providers)
.continueWithTask(this, new Continuation<AuthResult, Task<AuthResult>>() {
@Override
public Task<AuthResult> then(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
return task;
} else {
// Ignore any exceptions since we don't care about credential fetch errors.
return FirebaseAuth.getInstance().signInAnonymously();
}
}
}).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Signed in! Start loading data
} else {
// Uh oh, show error message
}
}
});
```

### Sign out

With the integrations provided by AuthUI, signing out a user is a multi-stage process:

1. The user must be signed out of the FirebaseAuth instance.
1. Smart Lock for Passwords must be instructed to disable automatic sign-in, in
order to prevent an automatic sign-in loop that prevents the user from
switching accounts.
1. Credential Manager must be instructed to clear the current user credential state from
all credential providers.
1. If the current user signed in using either Google or Facebook, the user must
also be signed out using the associated API for that authentication method.
This typically ensures that the user will not be automatically signed-in
Expand Down Expand Up @@ -677,7 +615,7 @@ if (v.getId() == R.id.sign_out) {
With the integrations provided by FirebaseUI Auth, deleting a user is a multi-stage process:

1. The user must be deleted from Firebase Auth.
1. Smart Lock for Passwords must be told to delete any existing Credentials for the user, so
1. Credential Manager must be told to delete any existing Credentials for the user, so
that they are not automatically prompted to sign in with a saved credential in the future.

This process is encapsulated by the `AuthUI.delete()` method, which returns a `Task` representing
Expand Down
Loading
Loading