Skip to content

Commit

Permalink
Merge pull request #1258 from firebase/version-3.3.1
Browse files Browse the repository at this point in the history
Version 3.3.1
  • Loading branch information
samtstern authored Apr 16, 2018
2 parents f15b36f + 42dbd73 commit 4bedc0f
Show file tree
Hide file tree
Showing 129 changed files with 666 additions and 748 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ android:
# https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943
- tools
- tools
before_script: mv library/google-services.json app/google-services.json
script: ./gradlew clean assembleDebug check
before_script:
- cp library/google-services.json app/google-services.json
- cp library/google-services.json proguard-tests/google-services.json
script: ./gradlew clean assembleDebug proguard-tests:build check
after_success: ./scripts/artifactory.sh
after_failure:
# tests
Expand Down
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ libraries.
```groovy
dependencies {
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:3.3.0'
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
// FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:3.3.0'
implementation 'com.firebaseui:firebase-ui-firestore:3.3.1'
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:3.3.0'
implementation 'com.firebaseui:firebase-ui-storage:3.3.1'
}
```

Expand Down Expand Up @@ -103,21 +103,13 @@ For convenience, here are some recent examples:

| FirebaseUI Version | Firebase/Play Services Version |
|--------------------|--------------------------------|
| 3.3.1 | 15.0.0 |
| 3.3.0 | 12.0.1 |
| 3.2.2 | 11.8.0 |
| 3.1.3 | 11.8.0 |
| 3.1.2 | 11.6.2 |
| 3.1.0 | 11.4.2 |
| 3.0.0 | 11.4.2 |
| 2.4.0 | 11.4.0 |
| 2.3.0 | 11.0.4 |
| 2.2.0 | 11.0.4 |
| 2.1.1 | 11.0.2 |
| 2.0.1 | 11.0.1 |
| 1.2.0 | 10.2.0 |
| 1.1.1 | 10.0.0 or 10.0.1 |
| 1.0.1 | 10.0.0 or 10.0.1 |
| 1.0.0 | 9.8.0 |


### Upgrading dependencies
Expand Down
2 changes: 1 addition & 1 deletion auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Gradle, add the dependency:
```groovy
dependencies {
// ...
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
// Required only if Facebook login support is required
// Find the latest Facebook SDK releases here: https://goo.gl/Ce5L94
Expand Down
6 changes: 3 additions & 3 deletions auth/auth-proguard.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Twitter and Facebook are optional
-dontwarn com.twitter.**
-dontwarn com.facebook.**
-dontwarn com.firebase.ui.auth.provider.**
-dontwarn com.twitter.**

# Don't note a bunch of dynamically referenced classes
-dontnote com.google.**
Expand All @@ -16,5 +15,6 @@

# Retrofit config
-dontnote retrofit2.Platform
-dontwarn retrofit2.Platform$Java8
-dontwarn retrofit2.** # Also keeps Twitter at bay as long as they keep using Retrofit
-dontwarn okio.**
-keepattributes Exceptions
75 changes: 43 additions & 32 deletions auth/src/main/java/com/firebase/ui/auth/AuthUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.firebase.ui.auth.data.remote.FacebookSignInHandler;
import com.firebase.ui.auth.data.remote.TwitterSignInHandler;
import com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity;
import com.firebase.ui.auth.util.CredentialUtils;
import com.firebase.ui.auth.util.ExtraConstants;
import com.firebase.ui.auth.util.GoogleApiUtils;
import com.firebase.ui.auth.util.Preconditions;
Expand Down Expand Up @@ -210,7 +211,11 @@ private AuthUI(FirebaseApp app) {
mApp = app;
mAuth = FirebaseAuth.getInstance(mApp);

mAuth.setFirebaseUIVersion(BuildConfig.VERSION_NAME);
try {
mAuth.setFirebaseUIVersion(BuildConfig.VERSION_NAME);
} catch (Exception e) {
Log.e(TAG, "Couldn't set the FUI version.", e);
}
mAuth.useAppLanguage();
}

Expand Down Expand Up @@ -272,32 +277,36 @@ public static int getDefaultTheme() {
*/
@NonNull
public Task<Void> signOut(@NonNull Context context) {
mAuth.signOut();

Task<Void> maybeDisableAutoSignIn = GoogleApiUtils.getCredentialsClient(context)
.disableAutoSignIn()
.continueWithTask(new Continuation<Void, Task<Void>>() {
.continueWith(new Continuation<Void, Void>() {
@Override
public Task<Void> then(@NonNull Task<Void> task) {
public Void then(@NonNull Task<Void> task) {
// We want to ignore a specific exception, since it's not a good reason
// to fail (see Issue 1156).
if (!task.isSuccessful() && (task.getException() instanceof ApiException)) {
ApiException ae = (ApiException) task.getException();
if (ae.getStatusCode() == CommonStatusCodes.CANCELED) {
Log.w(TAG, "Could not disable auto-sign in, maybe there are no " +
"SmartLock accounts available?", ae);

return Tasks.forResult(null);
}
Exception e = task.getException();
if (e instanceof ApiException
&& ((ApiException) e).getStatusCode() == CommonStatusCodes.CANCELED) {
Log.w(TAG, "Could not disable auto-sign in, maybe there are no " +
"SmartLock accounts available?", e);
return null;
}

return task;
return task.getResult();
}
});

return Tasks.whenAll(
signOutIdps(context),
maybeDisableAutoSignIn);
maybeDisableAutoSignIn
).continueWith(new Continuation<Void, Void>() {
@Override
public Void then(@NonNull Task<Void> task) {
task.getResult(); // Propagate exceptions
mAuth.signOut();
return null;
}
});
}

/**
Expand All @@ -322,12 +331,6 @@ public Task<Void> delete(@NonNull Context context) {

// Ensure the order in which tasks are executed properly destructures the user.
return signOutIdps(context).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(@NonNull Task<Void> task) {
task.getResult(); // Propagate exception if there was one
return currentUser.delete();
}
}).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(@NonNull Task<Void> task) {
task.getResult(); // Propagate exception if there was one
Expand All @@ -337,9 +340,9 @@ public Task<Void> then(@NonNull Task<Void> task) {
credentialTasks.add(client.delete(credential));
}
return Tasks.whenAll(credentialTasks)
.continueWithTask(new Continuation<Void, Task<Void>>() {
.continueWith(new Continuation<Void, Void>() {
@Override
public Task<Void> then(@NonNull Task<Void> task) {
public Void then(@NonNull Task<Void> task) {
Exception e = task.getException();
Throwable t = e == null ? null : e.getCause();
if (!(t instanceof ApiException)
Expand All @@ -348,13 +351,19 @@ public Task<Void> then(@NonNull Task<Void> task) {
// one. This can occur if we failed to save the credential or it
// was deleted elsewhere. However, a lack of stored credential
// doesn't mean fully deleting the user failed.
task.getResult();
return task.getResult();
}

return Tasks.forResult(null);
return null;
}
});
}
}).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(@NonNull Task<Void> task) {
task.getResult(); // Propagate exception if there was one
return currentUser.delete();
}
});
}

Expand Down Expand Up @@ -384,11 +393,13 @@ private static List<Credential> getCredentialsFromFirebaseUser(@NonNull Firebase
}

String type = ProviderUtils.providerIdToAccountType(userInfo.getProviderId());

credentials.add(new Credential.Builder(
user.getEmail() == null ? user.getPhoneNumber() : user.getEmail())
.setAccountType(type)
.build());
if (type == null) {
// Since the account type is null, we've got an email credential. Adding a fake
// password is the only way to tell Smart Lock that this is an email credential.
credentials.add(CredentialUtils.buildCredentialOrThrow(user, "pass", null));
} else {
credentials.add(CredentialUtils.buildCredentialOrThrow(user, null, type));
}
}

return credentials;
Expand Down Expand Up @@ -623,8 +634,8 @@ public EmailBuilder setAllowNewAccounts(boolean allow) {
}

/**
* Configures the requirement for the user to enter first and last name
* in the email sign up flow.
* Configures the requirement for the user to enter first and last name in the email
* sign up flow.
* <p>
* Name is required by default.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.firebase.ui.auth.data.model;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.DrawableRes;
Expand Down Expand Up @@ -84,13 +83,6 @@ public static FlowParameters fromIntent(Intent intent) {
return intent.getParcelableExtra(ExtraConstants.FLOW_PARAMS);
}

/**
* Extract FlowParameters from a Bundle.
*/
public static FlowParameters fromBundle(Bundle bundle) {
return bundle.getParcelable(ExtraConstants.FLOW_PARAMS);
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(appName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ private Resource(State state, T value, Exception exception) {
mException = exception;
}

/**
* Creates a successful, empty Resource.
*/
@NonNull
public static Resource<Void> forVoidSuccess() {
return new Resource<>(State.SUCCESS, null, null);
}

/**
* Creates a successful resource containing a value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookRequestError;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.GraphResponse;
import com.facebook.WebDialog;
Expand Down Expand Up @@ -43,13 +42,11 @@ public class FacebookSignInHandler extends ProviderSignInBase<AuthUI.IdpConfig>
static {
boolean available;
try {
//noinspection unused to possibly throw
Class c = FacebookSdk.class;
Class.forName("com.facebook.login.LoginManager");
available = true;
} catch (NoClassDefFoundError e) {
} catch (ClassNotFoundException e) {
available = false;
}
//noinspection ConstantConditions IntelliJ is wrong
IS_AVAILABLE = available;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ private void handleCredential(final Credential credential) {
final IdpResponse response = new IdpResponse.Builder(
new User.Builder(EmailAuthProvider.PROVIDER_ID, id).build()).build();

setResult(Resource.<IdpResponse>forLoading());
getAuth().signInWithEmailAndPassword(id, password)
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@ public class TwitterSignInHandler extends ProviderSignInBase<Void> {
static {
boolean available;
try {
//noinspection unused to possibly throw
Class c = TwitterCore.class;
Class.forName("com.twitter.sdk.android.core.identity.TwitterAuthClient");
available = true;
} catch (NoClassDefFoundError e) {
} catch (ClassNotFoundException e) {
available = false;
}
//noinspection ConstantConditions IntelliJ is wrong
IS_AVAILABLE = available;

//noinspection ConstantConditions IntelliJ is still wrong
if (IS_AVAILABLE) {
Context context = AuthUI.getApplicationContext();
Twitter.initialize(new TwitterConfig.Builder(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public class AppCompatBase extends HelperActivityBase {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.FirebaseUI); // Provides default values
setTheme(getFlowHolder().getArguments().themeId);
setTheme(getFlowParams().themeId);
}
}
41 changes: 16 additions & 25 deletions auth/src/main/java/com/firebase/ui/auth/ui/FragmentBase.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package com.firebase.ui.auth.ui;

import android.content.IntentSender;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.v4.app.Fragment;
import android.view.ContextThemeWrapper;

import com.firebase.ui.auth.IdpResponse;
import com.firebase.ui.auth.data.model.FlowParameters;
import com.firebase.ui.auth.util.AuthHelper;
import com.google.firebase.auth.FirebaseUser;

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class FragmentBase extends Fragment {

private FlowParameters mFlowParameters;
private AuthHelper mAuthHelper;
private HelperActivityBase mActivity;
private ProgressDialogHolder mProgressDialogHolder;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mAuthHelper = new AuthHelper(getFlowParams());
ContextThemeWrapper context = new ContextThemeWrapper(
getContext(), getFlowParams().themeId);
mProgressDialogHolder = new ProgressDialogHolder(context);
if (!(getActivity() instanceof HelperActivityBase)) {
throw new IllegalStateException("Cannot use this fragment without the helper activity");
}
mActivity = (HelperActivityBase) getActivity();

mProgressDialogHolder = new ProgressDialogHolder(new ContextThemeWrapper(
getContext(), getFlowParams().themeId));
}

@Override
Expand All @@ -34,23 +35,13 @@ public void onDestroy() {
}

public FlowParameters getFlowParams() {
if (mFlowParameters == null) {
mFlowParameters = FlowParameters.fromBundle(getArguments());
}

return mFlowParameters;
}

public AuthHelper getAuthHelper() {
return mAuthHelper;
}

public ProgressDialogHolder getDialogHolder() {
return mProgressDialogHolder;
return mActivity.getFlowParams();
}

public void startIntentSenderForResult(IntentSender sender, int requestCode)
throws IntentSender.SendIntentException {
startIntentSenderForResult(sender, requestCode, null, 0, 0, 0, null);
public void startSaveCredentials(
FirebaseUser firebaseUser,
IdpResponse response,
@Nullable String password) {
mActivity.startSaveCredentials(firebaseUser, response, password);
}
}
Loading

0 comments on commit 4bedc0f

Please sign in to comment.