Skip to content

Commit 9b9581a

Browse files
authored
Merge pull request #844 from firebase/version-2.2.0-release
Version 2.2.0
2 parents bee4c1a + ce2b77d commit 9b9581a

File tree

59 files changed

+629
-373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+629
-373
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ libraries.
3939
```groovy
4040
dependencies {
4141
// FirebaseUI Database only
42-
compile 'com.firebaseui:firebase-ui-database:2.1.1'
42+
compile 'com.firebaseui:firebase-ui-database:2.2.0'
4343
4444
// FirebaseUI Auth only
45-
compile 'com.firebaseui:firebase-ui-auth:2.1.1'
45+
compile 'com.firebaseui:firebase-ui-auth:2.2.0'
4646
4747
// FirebaseUI Storage only
48-
compile 'com.firebaseui:firebase-ui-storage:2.1.1'
48+
compile 'com.firebaseui:firebase-ui-storage:2.2.0'
4949
5050
// Single target that includes all FirebaseUI libraries above
51-
compile 'com.firebaseui:firebase-ui:2.1.1'
51+
compile 'com.firebaseui:firebase-ui:2.2.0'
5252
}
5353
```
5454

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

9292
| FirebaseUI Version | Firebase/Play Services Version |
93-
|--------------------|--------------------------------|
93+
|--------------------|--------------------------------|\
94+
| 2.2.0 | 11.0.4 |
9495
| 2.1.1 | 11.0.2 |
9596
| 2.0.1 | 11.0.1 |
9697
| 1.2.0 | 10.2.0 |
@@ -156,7 +157,7 @@ allprojects {
156157

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

161162
Before you can run the sample app, you must create a project in
162163
the Firebase console. Add an Android app to the project, and copy

app/src/main/java/com/firebase/uidemo/auth/SignedInActivity.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
public class SignedInActivity extends AppCompatActivity {
5656

57+
private static final String EXTRA_IDP_RESPONSE = "extra_idp_response";
5758
private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config";
5859

5960
@BindView(android.R.id.content)
@@ -83,7 +84,11 @@ public static Intent createIntent(
8384
Context context,
8485
IdpResponse idpResponse,
8586
SignedInConfig signedInConfig) {
86-
Intent startIntent = idpResponse == null ? new Intent() : idpResponse.toIntent();
87+
88+
Intent startIntent = new Intent();
89+
if (idpResponse != null) {
90+
startIntent.putExtra(EXTRA_IDP_RESPONSE, idpResponse);
91+
}
8792

8893
return startIntent.setClass(context, SignedInActivity.class)
8994
.putExtra(EXTRA_SIGNED_IN_CONFIG, signedInConfig);
@@ -100,7 +105,7 @@ public void onCreate(Bundle savedInstanceState) {
100105
return;
101106
}
102107

103-
mIdpResponse = IdpResponse.fromResultIntent(getIntent());
108+
mIdpResponse = getIntent().getParcelableExtra(EXTRA_IDP_RESPONSE);
104109
mSignedInConfig = getIntent().getParcelableExtra(EXTRA_SIGNED_IN_CONFIG);
105110

106111
setContentView(R.layout.signed_in_layout);

app/src/main/java/com/firebase/uidemo/database/ChatActivity.java

+19-17
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.firebase.uidemo.database;
1616

17+
import android.arch.lifecycle.LifecycleRegistry;
18+
import android.arch.lifecycle.LifecycleRegistryOwner;
1719
import android.os.Bundle;
1820
import android.support.annotation.NonNull;
1921
import android.support.v7.app.AppCompatActivity;
@@ -37,17 +39,21 @@
3739
import com.google.firebase.database.FirebaseDatabase;
3840
import com.google.firebase.database.Query;
3941

40-
public class ChatActivity extends AppCompatActivity implements FirebaseAuth.AuthStateListener, View.OnClickListener {
42+
public class ChatActivity extends AppCompatActivity
43+
implements FirebaseAuth.AuthStateListener, View.OnClickListener, LifecycleRegistryOwner {
4144
private static final String TAG = "RecyclerViewDemo";
4245

46+
// TODO remove once arch components are merged into support lib
47+
private final LifecycleRegistry mRegistry = new LifecycleRegistry(this);
48+
4349
private FirebaseAuth mAuth;
4450
protected DatabaseReference mChatRef;
4551
private Button mSendButton;
4652
protected EditText mMessageEdit;
4753

4854
private RecyclerView mMessages;
4955
private LinearLayoutManager mManager;
50-
protected FirebaseRecyclerAdapter<Chat, ChatHolder> mAdapter;
56+
private FirebaseRecyclerAdapter<Chat, ChatHolder> mAdapter;
5157
protected TextView mEmptyListMessage;
5258

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

7278
mMessages = (RecyclerView) findViewById(R.id.messagesList);
73-
mMessages.setHasFixedSize(false);
79+
mMessages.setHasFixedSize(true);
7480
mMessages.setLayoutManager(mManager);
81+
82+
if (isSignedIn()) { attachRecyclerViewAdapter(); }
7583
}
7684

7785
@Override
@@ -81,19 +89,7 @@ public void onStart() {
8189
// Default Database rules do not allow unauthenticated reads, so we need to
8290
// sign in before attaching the RecyclerView adapter otherwise the Adapter will
8391
// not be able to read any data from the Database.
84-
if (isSignedIn()) {
85-
attachRecyclerViewAdapter();
86-
} else {
87-
signInAnonymously();
88-
}
89-
}
90-
91-
@Override
92-
public void onStop() {
93-
super.onStop();
94-
if (mAdapter != null) {
95-
mAdapter.cleanup();
96-
}
92+
if (!isSignedIn()) { signInAnonymously(); }
9793
}
9894

9995
@Override
@@ -147,7 +143,8 @@ protected FirebaseRecyclerAdapter<Chat, ChatHolder> getAdapter() {
147143
Chat.class,
148144
R.layout.message,
149145
ChatHolder.class,
150-
lastFifty) {
146+
lastFifty,
147+
this) {
151148
@Override
152149
public void populateViewHolder(ChatHolder holder, Chat chat, int position) {
153150
holder.bind(chat);
@@ -182,4 +179,9 @@ private void updateUI() {
182179
mSendButton.setEnabled(isSignedIn());
183180
mMessageEdit.setEnabled(isSignedIn());
184181
}
182+
183+
@Override
184+
public LifecycleRegistry getLifecycle() {
185+
return mRegistry;
186+
}
185187
}

app/src/main/java/com/firebase/uidemo/database/ChatIndexActivity.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ protected FirebaseRecyclerAdapter<Chat, ChatHolder> getAdapter() {
3939
R.layout.message,
4040
ChatHolder.class,
4141
mChatIndicesRef.limitToLast(50),
42-
mChatRef) {
42+
mChatRef,
43+
this) {
4344
@Override
4445
public void populateViewHolder(ChatHolder holder, Chat chat, int position) {
4546
holder.bind(chat);

app/src/main/res/layout/activity_chat.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<android.support.v7.widget.RecyclerView
1717
android:id="@+id/messagesList"
1818
android:layout_width="match_parent"
19-
android:layout_height="wrap_content"
19+
android:layout_height="match_parent"
2020
android:layout_alignParentStart="true"
2121
android:layout_alignParentLeft="true"
2222
android:layout_alignParentTop="true"

auth/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ Gradle, add the dependency:
4646
```groovy
4747
dependencies {
4848
// ...
49-
compile 'com.firebaseui:firebase-ui-auth:2.1.1'
50-
49+
compile 'com.firebaseui:firebase-ui-auth:2.2.0'
50+
5151
// Required only if Facebook login support is required
5252
compile('com.facebook.android:facebook-android-sdk:4.22.1')
53-
53+
5454
// Required only if Twitter login support is required
5555
compile("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
5656
}
@@ -62,14 +62,14 @@ ensure that you only get the translations relevant to your application, we recom
6262

6363
```groovy
6464
android {
65-
65+
6666
// ...
67-
67+
6868
defaultConfig {
6969
// ...
7070
resConfigs "auto"
7171
}
72-
72+
7373
}
7474
```
7575

auth/build.gradle

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ dependencies {
6060
testCompile 'junit:junit:4.12'
6161
//noinspection GradleDynamicVersion
6262
testCompile 'org.mockito:mockito-core:2.8.+'
63-
testCompile 'org.robolectric:robolectric:3.2.2'
64-
// See https://github.com/robolectric/robolectric/issues/1932#issuecomment-219796474
65-
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
63+
testCompile 'org.robolectric:robolectric:3.4'
6664
testCompile 'com.facebook.android:facebook-android-sdk:4.23.0'
6765
}
6866

auth/src/main/java/com/firebase/ui/auth/provider/GoogleProvider.java

+5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ private void onError(GoogleSignInResult result) {
165165
.build();
166166
startLogin(mActivity);
167167
} else {
168+
if (status.getStatusCode() == CommonStatusCodes.DEVELOPER_ERROR) {
169+
Log.w(TAG, "Developer error: this application is misconfigured. Check your SHA1 " +
170+
" and package name in the Firebase console.");
171+
Toast.makeText(mActivity, "Developer error.", Toast.LENGTH_SHORT).show();
172+
}
168173
onError(status.getStatusCode() + " " + status.getStatusMessage());
169174
}
170175
}

auth/src/main/java/com/firebase/ui/auth/ui/accountlink/WelcomeBackIdpPrompt.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.content.Intent;
1919
import android.os.Bundle;
2020
import android.support.annotation.NonNull;
21+
import android.support.annotation.Nullable;
2122
import android.support.annotation.RestrictTo;
2223
import android.util.Log;
2324
import android.view.View;
@@ -64,7 +65,7 @@ public static Intent createIntent(
6465
Context context,
6566
FlowParameters flowParams,
6667
User existingUser,
67-
IdpResponse newUserResponse) {
68+
@Nullable IdpResponse newUserResponse) {
6869
return HelperActivityBase.createBaseIntent(context, WelcomeBackIdpPrompt.class, flowParams)
6970
.putExtra(ExtraConstants.EXTRA_USER, existingUser)
7071
.putExtra(ExtraConstants.EXTRA_IDP_RESPONSE, newUserResponse);
@@ -75,8 +76,10 @@ protected void onCreate(Bundle savedInstanceState) {
7576
super.onCreate(savedInstanceState);
7677
setContentView(R.layout.fui_welcome_back_idp_prompt_layout);
7778

78-
IdpResponse newUserIdpResponse = IdpResponse.fromResultIntent(getIntent());
79-
mPrevCredential = ProviderUtils.getAuthCredential(newUserIdpResponse);
79+
IdpResponse newUserResponse = IdpResponse.fromResultIntent(getIntent());
80+
if (newUserResponse != null) {
81+
mPrevCredential = ProviderUtils.getAuthCredential(newUserResponse);
82+
}
8083

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

auth/src/main/java/com/firebase/ui/auth/ui/email/CheckEmailFragment.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ public void onSuccess(String provider) {
206206
mListener.onExistingEmailUser(
207207
new User.Builder(EmailAuthProvider.PROVIDER_ID, email).build());
208208
} else {
209-
mListener.onExistingIdpUser(
210-
new User.Builder(EmailAuthProvider.PROVIDER_ID, email).build());
209+
mListener.onExistingIdpUser(new User.Builder(provider, email).build());
211210
}
212211
}
213212
})

auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailActivity.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
import com.firebase.ui.auth.IdpResponse;
2525
import com.firebase.ui.auth.R;
26+
import com.firebase.ui.auth.User;
2627
import com.firebase.ui.auth.ui.AppCompatBase;
2728
import com.firebase.ui.auth.ui.ExtraConstants;
2829
import com.firebase.ui.auth.ui.FlowParameters;
2930
import com.firebase.ui.auth.ui.HelperActivityBase;
30-
import com.firebase.ui.auth.User;
3131
import com.firebase.ui.auth.ui.accountlink.WelcomeBackIdpPrompt;
3232
import com.firebase.ui.auth.ui.accountlink.WelcomeBackPasswordPrompt;
3333

@@ -104,13 +104,9 @@ public void onExistingEmailUser(User user) {
104104
@Override
105105
public void onExistingIdpUser(User user) {
106106
// Existing social user, direct them to sign in using their chosen provider.
107-
Intent intent = WelcomeBackIdpPrompt.createIntent(
108-
this,
109-
getFlowParams(),
110-
user,
111-
new IdpResponse.Builder(user).build());
112-
113-
startActivityForResult(intent, RC_WELCOME_BACK_IDP);
107+
startActivityForResult(
108+
WelcomeBackIdpPrompt.createIntent(this, getFlowParams(), user, null),
109+
RC_WELCOME_BACK_IDP);
114110
setSlideAnimation();
115111
}
116112

auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,15 @@ public void onComplete(@NonNull Task<Void> task) {
244244
// This executes even if the name change fails, since
245245
// the account creation succeeded and we want to save
246246
// the credential to SmartLock (if enabled).
247+
IdpResponse response = new IdpResponse.Builder(
248+
new User.Builder(EmailAuthProvider.PROVIDER_ID, email)
249+
.setName(name)
250+
.setPhotoUri(mUser.getPhotoUri())
251+
.build())
252+
.build();
253+
247254
mActivity.saveCredentialsOrFinish(
248-
mSaveSmartLock, user, password,
249-
new IdpResponse.Builder(new User.Builder(
250-
EmailAuthProvider.PROVIDER_ID, email)
251-
.setName(name)
252-
.setPhotoUri(mUser.getPhotoUri())
253-
.build()).build());
255+
mSaveSmartLock, user, password, response);
254256
}
255257
});
256258
}
@@ -302,9 +304,7 @@ public void onSuccess(String provider) {
302304
getFlowParams(),
303305
new User.Builder(provider, email)
304306
.build(),
305-
new IdpResponse.Builder(new User.Builder(
306-
EmailAuthProvider.PROVIDER_ID,
307-
email).build()).build()),
307+
null),
308308
RegisterEmailActivity.RC_WELCOME_BACK_IDP);
309309
}
310310
}

0 commit comments

Comments
 (0)