Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to hide the Title bar of Authorization Activity using FirebaseUI

I tried to use the following style

<style name= "AuthStyle">
<item name="android:windowBackground">@drawable/culture</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>

and then I applied the above style here:

startActivityForResult(AuthUI.getInstance()
                .createSignInIntentBuilder()
                .setProviders(AuthUI.EMAIL_PROVIDER,
                              AuthUI.FACEBOOK_PROVIDER,
                              AuthUI.GOOGLE_PROVIDER)
                .setTheme(R.style.AuthStyle)
                .build()
                ,1);

However,the title bar is still being displayed. Any suggestions on how to remove / hide it will be appreciated

like image 270
Fahad Saleem Avatar asked Aug 25 '16 04:08

Fahad Saleem


2 Answers

Firebase UI overrides/ignores the removal of the action bar/app bar in the theme, so we have to cheat. In styles.xml:

<style name="AppThemeFirebaseAuth" parent="android:Theme.Material.Light.NoActionBar">
    <item name="android:actionBarStyle">@style/FirebaseAuthActionBarStyle</item>
    <item name="android:windowActionBarOverlay">true</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="FirebaseAuthActionBarStyle" parent="Widget.AppCompat.ActionBar">
    <item name="android:background">@color/white</item>
</style>

(or rather than @color/white, whatever your background colour.)

Where you start the activity for sign in:

    Intent signInIntent = AuthUI.getInstance().createSignInIntentBuilder()
            .setProviders(Arrays.asList(
                    new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                    new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
            .setTheme(R.style.AppThemeFirebaseAuth)
            .setLogo(R.drawable.logo)
            .setIsSmartLockEnabled(!BuildConfig.DEBUG)
            .build();

Keep in mind that in future releases of Firebase UI, the action bar/app bar might become useful or required, so this is a bit dangerous.

like image 76
Eliot Avatar answered Nov 03 '22 01:11

Eliot


As of firebase ui version 4.3.1, the following code is enough to hide tiltebar, no need to do tricks with background color:

<style name="AppThemeFirebaseAuth" parent="android:Theme.Light.NoTitleBar">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

just reference the style when creating AuthUI instance

// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
    new AuthUI.IdpConfig.PhoneBuilder().build());
AuthUI.createSignInIntentBuilder()
      .setAvailableProviders(providers)
      .setTheme(R.style.AppThemeFirebaseAuth)
      .build(),

Tested in android 4.4.2 and android 9 (Nexus emulators)

like image 33
Kartu Avatar answered Nov 03 '22 01:11

Kartu