Skip to content

Commit

Permalink
Version 6.3.0
Browse files Browse the repository at this point in the history
Version 6.3.0
  • Loading branch information
samtstern authored Jul 31, 2020
2 parents 6d41fb2 + 47cb77d commit 5fb0fc1
Show file tree
Hide file tree
Showing 113 changed files with 451 additions and 557 deletions.
Empty file added CHANGELOG.md
Empty file.
10 changes: 5 additions & 5 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:6.2.1'
implementation 'com.firebaseui:firebase-ui-database:6.3.0'
// FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:6.2.1'
implementation 'com.firebaseui:firebase-ui-firestore:6.3.0'
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:6.2.1'
implementation 'com.firebaseui:firebase-ui-auth:6.3.0'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:6.2.1'
implementation 'com.firebaseui:firebase-ui-storage:6.3.0'
}
```

Expand Down Expand Up @@ -113,7 +113,7 @@ you want to use. Here are some examples listing all of the critical dependencies
implementation "com.google.firebase:firebase-auth:$X.Y.Z"
implementation "com.google.android.gms:play-services-auth:$X.Y.Z"
implementation "android.arch.lifecycle:extensions:$X.Y.Z"
implementation "androidx.lifecycle:lifecycle-extensions:$X.Y.Z"
implementation "androidx.browser:browser:$X.Y.Z"
implementation "androidx.cardview:cardview:$X.Y.Z"
implementation "androidx.constraintlayout:constraintlayout:$X.Y.Z"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.firebase.uidemo.database.firestore;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -39,6 +40,7 @@
* For a general intro to the RecyclerView, see <a href="https://developer.android.com/training/material/lists-cards.html">Creating
* Lists</a>.
*/
@SuppressLint("RestrictedApi")
public class FirestoreChatActivity extends AppCompatActivity
implements FirebaseAuth.AuthStateListener {
private static final String TAG = "FirestoreChatActivity";
Expand Down Expand Up @@ -104,7 +106,9 @@ public void onDonePressed() {
@Override
public void onStart() {
super.onStart();
if (isSignedIn()) { attachRecyclerViewAdapter(); }
if (isSignedIn()) {
attachRecyclerViewAdapter();
}
FirebaseAuth.getInstance().addAuthStateListener(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

public class FirebaseDbPagingActivity extends AppCompatActivity {

private final String TAG = "PagingActivity";
private static final String TAG = "PagingActivity";

@BindView(R.id.paging_recycler)
RecyclerView mRecycler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.firebase.uidemo.database.realtime;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -39,6 +40,7 @@
* For a general intro to the RecyclerView, see <a href="https://developer.android.com/training/material/lists-cards.html">Creating
* Lists</a>.
*/
@SuppressLint("RestrictedApi")
public class RealtimeDbChatActivity extends AppCompatActivity
implements FirebaseAuth.AuthStateListener {
private static final String TAG = "RealtimeDatabaseDemo";
Expand All @@ -47,7 +49,7 @@ public class RealtimeDbChatActivity extends AppCompatActivity
* Get the last 50 chat messages.
*/
@NonNull
protected static final Query sChatQuery =
protected final Query sChatQuery =
FirebaseDatabase.getInstance().getReference().child("chats").limitToLast(50);

@BindView(R.id.messagesList)
Expand Down Expand Up @@ -82,7 +84,9 @@ public void onDonePressed() {
@Override
public void onStart() {
super.onStart();
if (isSignedIn()) { attachRecyclerViewAdapter(); }
if (isSignedIn()) {
attachRecyclerViewAdapter();
}
FirebaseAuth.getInstance().addAuthStateListener(this);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.firebase.uidemo.util;

import android.annotation.SuppressLint;
import android.content.Context;

import com.firebase.ui.auth.AuthUI;
Expand All @@ -12,6 +13,7 @@

import androidx.annotation.NonNull;

@SuppressLint("RestrictedApi")
public final class ConfigurationUtils {

private ConfigurationUtils() {
Expand Down
28 changes: 14 additions & 14 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Gradle, add the dependency:
```groovy
dependencies {
// ...
implementation 'com.firebaseui:firebase-ui-auth:6.2.1'
implementation 'com.firebaseui:firebase-ui-auth:6.3.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 @@ -273,19 +273,19 @@ pass it to us via `setEmailLink`.

```java
if (AuthUI.canHandleIntent(getIntent())) {
if (getIntent().getExtras() != null) {
return;
}
String link = getIntent().getExtras().getString(ExtraConstants.EMAIL_LINK_SIGN_IN);
if (link != null) {
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setEmailLink(link)
.setAvailableProviders(getAvailableProviders())
.build(),
RC_SIGN_IN);
}
if (getIntent().getExtras() == null) {
return;
}
String link = getIntent().getData().toString();
if (link != null) {
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setEmailLink(link)
.setAvailableProviders(getAvailableProviders())
.build(),
RC_SIGN_IN);
}
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.google.firebase.auth.EmailAuthProvider;
import com.google.firebase.auth.FacebookAuthProvider;
import com.google.firebase.auth.GithubAuthProvider;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.firebase.auth.TwitterAuthProvider;
Expand Down Expand Up @@ -158,6 +159,12 @@ public AuthMethodPickerLayout.Builder setAnonymousButtonId(@IdRes int anonymousB
return this;
}

public AuthMethodPickerLayout.Builder setGithubButtonId(
@IdRes int githubButtonId) {
providersMapping.put(GithubAuthProvider.PROVIDER_ID, githubButtonId);
return this;
}

public AuthMethodPickerLayout.Builder setMicrosoftButtonId(
@IdRes int microsoftButtonId) {
providersMapping.put(AuthUI.MICROSOFT_PROVIDER, microsoftButtonId);
Expand Down
3 changes: 1 addition & 2 deletions auth/src/main/java/com/firebase/ui/auth/AuthUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ public final class AuthUI {
public static final Set<String> SOCIAL_PROVIDERS =
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
GoogleAuthProvider.PROVIDER_ID,
FacebookAuthProvider.PROVIDER_ID,
GithubAuthProvider.PROVIDER_ID)));
FacebookAuthProvider.PROVIDER_ID)));

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public static final String UNCONFIGURED_CONFIG_VALUE = "CHANGE-ME";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.firebase.auth.OAuthCredential;
import com.google.firebase.auth.OAuthProvider;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -200,9 +201,12 @@ protected OAuthProvider buildOAuthProvider(String providerId) {

List<String> scopes =
getArguments().getParams().getStringArrayList(ExtraConstants.GENERIC_OAUTH_SCOPES);
Map<String, String> customParams =
getArguments().getParams()
.getParcelable(ExtraConstants.GENERIC_OAUTH_CUSTOM_PARAMETERS);

// This unchecked cast is safe, this extra is put in as a serializable
// in AuthUI.setCustomParameters
HashMap<String, String> customParams =
(HashMap<String, String>) getArguments().getParams()
.getSerializable(ExtraConstants.GENERIC_OAUTH_CUSTOM_PARAMETERS);

if (scopes != null) {
providerBuilder.setScopes(scopes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import com.firebase.ui.auth.util.ui.ImeHelper;
import com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator;
import com.firebase.ui.auth.viewmodel.ResourceObserver;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputLayout;
import com.google.firebase.FirebaseNetworkException;
import com.google.firebase.auth.EmailAuthProvider;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -150,6 +152,11 @@ protected void onFailure(@NonNull Exception e) {
&& ((FirebaseUiException) e).getErrorCode() == ErrorCodes.DEVELOPER_ERROR) {
mListener.onDeveloperFailure(e);
}

if (e instanceof FirebaseNetworkException) {
Snackbar.make(getView(), getString(R.string.fui_no_internet), Snackbar.LENGTH_SHORT).show();
}

// Otherwise just let the user enter their data
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
import com.firebase.ui.auth.viewmodel.ProviderSignInBase;
import com.firebase.ui.auth.viewmodel.ResourceObserver;
import com.firebase.ui.auth.viewmodel.idp.SocialProviderResponseHandler;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.EmailAuthProvider;
import com.google.firebase.auth.FacebookAuthProvider;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.GithubAuthProvider;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.auth.PhoneAuthProvider;

Expand Down Expand Up @@ -229,14 +229,36 @@ private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) {
for (IdpConfig idpConfig : providerConfigs) {
final String providerId = providerOrEmailLinkProvider(idpConfig.getProviderId());

if (!providerButtonIds.containsKey(providerId)) {
Integer buttonResId = providerButtonIds.get(providerId);
if (buttonResId == null) {
throw new IllegalStateException("No button found for auth provider: " + idpConfig.getProviderId());
}

@IdRes int buttonId = providerButtonIds.get(providerId);
@IdRes int buttonId = buttonResId;
View loginButton = findViewById(buttonId);
handleSignInOperation(idpConfig, loginButton);
}
//hide custom layout buttons that don't have their identity provider set
for (String providerBtnId : providerButtonIds.keySet()) {
if (providerBtnId == null) {
continue;
}
boolean hasProvider = false;
for (IdpConfig idpConfig : providerConfigs) {
if (providerBtnId.equals(idpConfig.getProviderId())) {
hasProvider = true;
break;
}
}
if (!hasProvider) {
Integer resId = providerButtonIds.get(providerBtnId);
if (resId == null) {
continue;
}
@IdRes int buttonId = resId;
findViewById(buttonId).setVisibility(View.GONE);
}
}
}

@NonNull
Expand Down Expand Up @@ -341,7 +363,7 @@ private void handleResponse(@NonNull IdpResponse response) {
@Override
public void onClick(View view) {
if (isOffline()) {
Toast.makeText(AuthMethodPickerActivity.this, getString(R.string.fui_no_internet), Toast.LENGTH_SHORT).show();
Snackbar.make(findViewById(android.R.id.content), getString(R.string.fui_no_internet), Snackbar.LENGTH_SHORT).show();
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ public Task<List<String>> then(@NonNull Task<SignInMethodQueryResult> task) {
}
}

// In this case the developer has configured EMAIL_LINK sign in but the
// user is a password user. The valid use case here is that the developer
// is using admin-created accounts and combining email-link sign in with
// setAllowNewAccounts(false). So we manually enable EMAIL_LINK. See:
// https://github.com/firebase/FirebaseUI-Android/issues/1762#issuecomment-661115293
if (allowedProviders.contains(EMAIL_LINK_PROVIDER)
&& methods.contains(EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD)
&& !methods.contains(EMAIL_LINK_PROVIDER)) {
lastSignedInProviders.add(0, signInMethodToProviderId(EMAIL_LINK_PROVIDER));
}

if (task.isSuccessful() && lastSignedInProviders.isEmpty()
&& !methods.isEmpty()) {
// There is an existing user who only has unsupported sign in methods
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.firebase.ui.auth.viewmodel.email;

import android.app.Application;
import android.util.Log;

import com.firebase.ui.auth.ErrorCodes;
import com.firebase.ui.auth.FirebaseUiException;
import com.firebase.ui.auth.IdpResponse;
import com.firebase.ui.auth.data.model.IntentRequiredException;
import com.firebase.ui.auth.data.model.Resource;
Expand All @@ -23,6 +26,7 @@
import com.google.firebase.auth.FirebaseAuthUserCollisionException;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;

import static com.firebase.ui.auth.AuthUI.EMAIL_LINK_PROVIDER;
Expand Down Expand Up @@ -70,6 +74,8 @@ public void onFailure(@NonNull Exception e) {
password);
handleMergeFailure(credential);
} else {
Log.w(TAG, "Got a collision error during a non-upgrade flow", e);

// Collision with existing user email without anonymous upgrade
// it should be very hard for the user to even get to this error
// due to CheckEmailFragment.
Expand Down Expand Up @@ -97,10 +103,14 @@ public StartWelcomeBackFlow(String email) {
}

@Override
public void onSuccess(String provider) {
public void onSuccess(@Nullable String provider) {
if (provider == null) {
throw new IllegalStateException(
"User has no providers even though we got a collision.");
Log.w(TAG, "No providers known for user ("
+ mEmail
+ ") this email address may be reserved.");
setResult(Resource.<IdpResponse>forFailure(
new FirebaseUiException(ErrorCodes.UNKNOWN_ERROR)));
return;
}

if (EmailAuthProvider.PROVIDER_ID.equalsIgnoreCase(provider)) {
Expand Down
2 changes: 1 addition & 1 deletion auth/src/main/res/layout/fui_register_email_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_layout"
style="@style/FirebaseUI.TextInputLayout.PasswordField"
style="@style/FirebaseUI.TextInputLayout.NewPasswordField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/fui_field_padding_vert"
Expand Down
Loading

0 comments on commit 5fb0fc1

Please sign in to comment.