Skip to content
Draft
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Then you can depend on snapshot versions:
implementation 'com.firebaseui:firebase-ui-auth:$X.Y.Z-SNAPSHOT'
```

You can see which `SNAPSHOT` builds are avaiable here:
You can see which `SNAPSHOT` builds are available here:
https://oss.jfrog.org/webapp/#/artifacts/browse/tree/General/oss-snapshot-local/com/firebaseui

Snapshot builds come with absolutely no guarantees and we will close any issues asking to troubleshoot
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,37 @@
android:label="Custom Slots & Theming Demo"
android:exported="false"
android:theme="@style/Theme.FirebaseUIAndroid" />

<activity
android:name=".CredentialLinkingDemoActivity"
android:label="Credential Linking Demo"
android:exported="false"
android:theme="@style/Theme.FirebaseUIAndroid" />

<activity
android:name=".EmailAuthSlotDemoActivity"
android:label="Email Auth — Custom Slot"
android:exported="false"
android:theme="@style/Theme.FirebaseUIAndroid" />

<activity
android:name=".PhoneAuthSlotDemoActivity"
android:label="Phone Auth — Custom Slot"
android:exported="false"
android:theme="@style/Theme.FirebaseUIAndroid" />

<activity
android:name=".ShapeCustomizationDemoActivity"
android:label="Shape Customization"
android:exported="false"
android:theme="@style/Theme.FirebaseUIAndroid" />

<activity
android:name=".CustomMethodPickerDemoActivity"
android:label="Custom Method Picker Layout"
android:exported="false"
android:theme="@style/Theme.FirebaseUIAndroid" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
package com.firebaseui.android.demo

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.firebase.ui.auth.AuthException
import com.firebase.ui.auth.AuthState
import com.firebase.ui.auth.FirebaseAuthUI
import com.firebase.ui.auth.configuration.authUIConfiguration
import com.firebase.ui.auth.configuration.auth_provider.AuthProvider
import com.firebase.ui.auth.ui.screens.AuthRoute
import com.firebase.ui.auth.ui.screens.AuthSuccessUiContext
import com.firebase.ui.auth.ui.screens.FirebaseAuthScreen

class CredentialLinkingDemoActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()

val authUI = FirebaseAuthUI.getInstance()

val configuration = authUIConfiguration {
context = applicationContext
isCredentialLinkingEnabled = true
providers {
provider(
AuthProvider.Email(
isNewAccountsAllowed = true,
emailLinkActionCodeSettings = null,
passwordValidationRules = emptyList(),
)
)
provider(
AuthProvider.Google(
scopes = listOf("email"),
serverClientId = "406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com",
)
)
provider(
AuthProvider.Phone(
defaultNumber = null,
defaultCountryCode = null,
allowedCountries = emptyList(),
timeout = 120L,
)
)
}
}

setContent {
MaterialTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
FirebaseAuthScreen(
configuration = configuration,
authUI = authUI,
onSignInSuccess = {},
onSignInFailure = { _: AuthException -> },
onSignInCancelled = {},
authenticatedContent = { state, uiContext ->
CredentialLinkingAuthenticatedContent(state, uiContext)
}
)
}
}
}
}
}

@Composable
private fun CredentialLinkingAuthenticatedContent(
state: AuthState,
uiContext: AuthSuccessUiContext,
) {
when (state) {
is AuthState.Success -> {
val user = state.user
Column(
modifier = Modifier
.fillMaxSize()
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Text(
text = "Signed in",
style = MaterialTheme.typography.headlineSmall,
)
Spacer(modifier = Modifier.height(16.dp))
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant
)
) {
Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text("UID: ${user.uid}", style = MaterialTheme.typography.bodySmall)
Text("Email: ${user.email ?: "—"}")
Text("Phone: ${user.phoneNumber ?: "—"}")
Text(
"Providers: ${user.providerData.map { it.providerId }}",
style = MaterialTheme.typography.bodySmall,
textAlign = TextAlign.Start
)
}
}
Spacer(modifier = Modifier.height(24.dp))
Button(
modifier = Modifier.fillMaxWidth(),
onClick = { uiContext.onNavigate(AuthRoute.MethodPicker) }
) {
Text("Add sign-in method")
}
Spacer(modifier = Modifier.height(8.dp))
OutlinedButton(
modifier = Modifier.fillMaxWidth(),
onClick = uiContext.onSignOut
) {
Text("Sign out")
}
}
}

is AuthState.RequiresEmailVerification -> {
Column(
modifier = Modifier
.fillMaxSize()
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Text(
text = "Verify your email",
style = MaterialTheme.typography.headlineSmall,
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "A verification link was sent to ${state.email}. Once verified, tap the button below.",
textAlign = TextAlign.Center,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(modifier = Modifier.height(24.dp))
Button(
modifier = Modifier.fillMaxWidth(),
onClick = uiContext.onReloadUser
) {
Text("I've verified my email")
}
Spacer(modifier = Modifier.height(8.dp))
OutlinedButton(
modifier = Modifier.fillMaxWidth(),
onClick = uiContext.onSignOut
) {
Text("Sign out")
}
}
}

else -> {}
}
}
Loading
Loading