Skip to content

Commit

Permalink
Merge pull request #844 from firebase/version-2.2.0-release
Browse files Browse the repository at this point in the history
Version 2.2.0
  • Loading branch information
samtstern authored Aug 2, 2017
2 parents bee4c1a + ce2b77d commit 9b9581a
Show file tree
Hide file tree
Showing 59 changed files with 629 additions and 373 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ libraries.
```groovy
dependencies {
// FirebaseUI Database only
compile 'com.firebaseui:firebase-ui-database:2.1.1'
compile 'com.firebaseui:firebase-ui-database:2.2.0'
// FirebaseUI Auth only
compile 'com.firebaseui:firebase-ui-auth:2.1.1'
compile 'com.firebaseui:firebase-ui-auth:2.2.0'
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:2.1.1'
compile 'com.firebaseui:firebase-ui-storage:2.2.0'
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:2.1.1'
compile 'com.firebaseui:firebase-ui:2.2.0'
}
```

Expand Down Expand Up @@ -90,7 +90,8 @@ you need to make sure that you use the same version that your chosen version of
For convenience, here are some recent examples:

| FirebaseUI Version | Firebase/Play Services Version |
|--------------------|--------------------------------|
|--------------------|--------------------------------|\
| 2.2.0 | 11.0.4 |
| 2.1.1 | 11.0.2 |
| 2.0.1 | 11.0.1 |
| 1.2.0 | 10.2.0 |
Expand Down Expand Up @@ -156,7 +157,7 @@ allprojects {

There is a sample app in the `app/` directory that demonstrates most
of the features of FirebaseUI. Load the project in Android Studio and
run it on your Android device to see a demonstration.
run it on your Android device to see a demonstration.

Before you can run the sample app, you must create a project in
the Firebase console. Add an Android app to the project, and copy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

public class SignedInActivity extends AppCompatActivity {

private static final String EXTRA_IDP_RESPONSE = "extra_idp_response";
private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config";

@BindView(android.R.id.content)
Expand Down Expand Up @@ -83,7 +84,11 @@ public static Intent createIntent(
Context context,
IdpResponse idpResponse,
SignedInConfig signedInConfig) {
Intent startIntent = idpResponse == null ? new Intent() : idpResponse.toIntent();

Intent startIntent = new Intent();
if (idpResponse != null) {
startIntent.putExtra(EXTRA_IDP_RESPONSE, idpResponse);
}

return startIntent.setClass(context, SignedInActivity.class)
.putExtra(EXTRA_SIGNED_IN_CONFIG, signedInConfig);
Expand All @@ -100,7 +105,7 @@ public void onCreate(Bundle savedInstanceState) {
return;
}

mIdpResponse = IdpResponse.fromResultIntent(getIntent());
mIdpResponse = getIntent().getParcelableExtra(EXTRA_IDP_RESPONSE);
mSignedInConfig = getIntent().getParcelableExtra(EXTRA_SIGNED_IN_CONFIG);

setContentView(R.layout.signed_in_layout);
Expand Down
36 changes: 19 additions & 17 deletions app/src/main/java/com/firebase/uidemo/database/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.firebase.uidemo.database;

import android.arch.lifecycle.LifecycleRegistry;
import android.arch.lifecycle.LifecycleRegistryOwner;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -37,17 +39,21 @@
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;

public class ChatActivity extends AppCompatActivity implements FirebaseAuth.AuthStateListener, View.OnClickListener {
public class ChatActivity extends AppCompatActivity
implements FirebaseAuth.AuthStateListener, View.OnClickListener, LifecycleRegistryOwner {
private static final String TAG = "RecyclerViewDemo";

// TODO remove once arch components are merged into support lib
private final LifecycleRegistry mRegistry = new LifecycleRegistry(this);

private FirebaseAuth mAuth;
protected DatabaseReference mChatRef;
private Button mSendButton;
protected EditText mMessageEdit;

private RecyclerView mMessages;
private LinearLayoutManager mManager;
protected FirebaseRecyclerAdapter<Chat, ChatHolder> mAdapter;
private FirebaseRecyclerAdapter<Chat, ChatHolder> mAdapter;
protected TextView mEmptyListMessage;

@Override
Expand All @@ -70,8 +76,10 @@ protected void onCreate(Bundle savedInstanceState) {
mManager.setReverseLayout(false);

mMessages = (RecyclerView) findViewById(R.id.messagesList);
mMessages.setHasFixedSize(false);
mMessages.setHasFixedSize(true);
mMessages.setLayoutManager(mManager);

if (isSignedIn()) { attachRecyclerViewAdapter(); }
}

@Override
Expand All @@ -81,19 +89,7 @@ public void onStart() {
// Default Database rules do not allow unauthenticated reads, so we need to
// sign in before attaching the RecyclerView adapter otherwise the Adapter will
// not be able to read any data from the Database.
if (isSignedIn()) {
attachRecyclerViewAdapter();
} else {
signInAnonymously();
}
}

@Override
public void onStop() {
super.onStop();
if (mAdapter != null) {
mAdapter.cleanup();
}
if (!isSignedIn()) { signInAnonymously(); }
}

@Override
Expand Down Expand Up @@ -147,7 +143,8 @@ protected FirebaseRecyclerAdapter<Chat, ChatHolder> getAdapter() {
Chat.class,
R.layout.message,
ChatHolder.class,
lastFifty) {
lastFifty,
this) {
@Override
public void populateViewHolder(ChatHolder holder, Chat chat, int position) {
holder.bind(chat);
Expand Down Expand Up @@ -182,4 +179,9 @@ private void updateUI() {
mSendButton.setEnabled(isSignedIn());
mMessageEdit.setEnabled(isSignedIn());
}

@Override
public LifecycleRegistry getLifecycle() {
return mRegistry;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ protected FirebaseRecyclerAdapter<Chat, ChatHolder> getAdapter() {
R.layout.message,
ChatHolder.class,
mChatIndicesRef.limitToLast(50),
mChatRef) {
mChatRef,
this) {
@Override
public void populateViewHolder(ChatHolder holder, Chat chat, int position) {
holder.bind(chat);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<android.support.v7.widget.RecyclerView
android:id="@+id/messagesList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
Expand Down
12 changes: 6 additions & 6 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ Gradle, add the dependency:
```groovy
dependencies {
// ...
compile 'com.firebaseui:firebase-ui-auth:2.1.1'
compile 'com.firebaseui:firebase-ui-auth:2.2.0'
// Required only if Facebook login support is required
compile('com.facebook.android:facebook-android-sdk:4.22.1')
// Required only if Twitter login support is required
compile("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
}
Expand All @@ -62,14 +62,14 @@ ensure that you only get the translations relevant to your application, we recom

```groovy
android {
// ...
defaultConfig {
// ...
resConfigs "auto"
}
}
```

Expand Down
4 changes: 1 addition & 3 deletions auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ dependencies {
testCompile 'junit:junit:4.12'
//noinspection GradleDynamicVersion
testCompile 'org.mockito:mockito-core:2.8.+'
testCompile 'org.robolectric:robolectric:3.2.2'
// See https://github.com/robolectric/robolectric/issues/1932#issuecomment-219796474
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
testCompile 'org.robolectric:robolectric:3.4'
testCompile 'com.facebook.android:facebook-android-sdk:4.23.0'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ private void onError(GoogleSignInResult result) {
.build();
startLogin(mActivity);
} else {
if (status.getStatusCode() == CommonStatusCodes.DEVELOPER_ERROR) {
Log.w(TAG, "Developer error: this application is misconfigured. Check your SHA1 " +
" and package name in the Firebase console.");
Toast.makeText(mActivity, "Developer error.", Toast.LENGTH_SHORT).show();
}
onError(status.getStatusCode() + " " + status.getStatusMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -64,7 +65,7 @@ public static Intent createIntent(
Context context,
FlowParameters flowParams,
User existingUser,
IdpResponse newUserResponse) {
@Nullable IdpResponse newUserResponse) {
return HelperActivityBase.createBaseIntent(context, WelcomeBackIdpPrompt.class, flowParams)
.putExtra(ExtraConstants.EXTRA_USER, existingUser)
.putExtra(ExtraConstants.EXTRA_IDP_RESPONSE, newUserResponse);
Expand All @@ -75,8 +76,10 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fui_welcome_back_idp_prompt_layout);

IdpResponse newUserIdpResponse = IdpResponse.fromResultIntent(getIntent());
mPrevCredential = ProviderUtils.getAuthCredential(newUserIdpResponse);
IdpResponse newUserResponse = IdpResponse.fromResultIntent(getIntent());
if (newUserResponse != null) {
mPrevCredential = ProviderUtils.getAuthCredential(newUserResponse);
}

User oldUser = User.getUser(getIntent());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public void onSuccess(String provider) {
mListener.onExistingEmailUser(
new User.Builder(EmailAuthProvider.PROVIDER_ID, email).build());
} else {
mListener.onExistingIdpUser(
new User.Builder(EmailAuthProvider.PROVIDER_ID, email).build());
mListener.onExistingIdpUser(new User.Builder(provider, email).build());
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

import com.firebase.ui.auth.IdpResponse;
import com.firebase.ui.auth.R;
import com.firebase.ui.auth.User;
import com.firebase.ui.auth.ui.AppCompatBase;
import com.firebase.ui.auth.ui.ExtraConstants;
import com.firebase.ui.auth.ui.FlowParameters;
import com.firebase.ui.auth.ui.HelperActivityBase;
import com.firebase.ui.auth.User;
import com.firebase.ui.auth.ui.accountlink.WelcomeBackIdpPrompt;
import com.firebase.ui.auth.ui.accountlink.WelcomeBackPasswordPrompt;

Expand Down Expand Up @@ -104,13 +104,9 @@ public void onExistingEmailUser(User user) {
@Override
public void onExistingIdpUser(User user) {
// Existing social user, direct them to sign in using their chosen provider.
Intent intent = WelcomeBackIdpPrompt.createIntent(
this,
getFlowParams(),
user,
new IdpResponse.Builder(user).build());

startActivityForResult(intent, RC_WELCOME_BACK_IDP);
startActivityForResult(
WelcomeBackIdpPrompt.createIntent(this, getFlowParams(), user, null),
RC_WELCOME_BACK_IDP);
setSlideAnimation();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,15 @@ public void onComplete(@NonNull Task<Void> task) {
// This executes even if the name change fails, since
// the account creation succeeded and we want to save
// the credential to SmartLock (if enabled).
IdpResponse response = new IdpResponse.Builder(
new User.Builder(EmailAuthProvider.PROVIDER_ID, email)
.setName(name)
.setPhotoUri(mUser.getPhotoUri())
.build())
.build();

mActivity.saveCredentialsOrFinish(
mSaveSmartLock, user, password,
new IdpResponse.Builder(new User.Builder(
EmailAuthProvider.PROVIDER_ID, email)
.setName(name)
.setPhotoUri(mUser.getPhotoUri())
.build()).build());
mSaveSmartLock, user, password, response);
}
});
}
Expand Down Expand Up @@ -302,9 +304,7 @@ public void onSuccess(String provider) {
getFlowParams(),
new User.Builder(provider, email)
.build(),
new IdpResponse.Builder(new User.Builder(
EmailAuthProvider.PROVIDER_ID,
email).build()).build()),
null),
RegisterEmailActivity.RC_WELCOME_BACK_IDP);
}
}
Expand Down
Loading

0 comments on commit 9b9581a

Please sign in to comment.