Skip to content

Commit 457ea61

Browse files
authored
Version 5.1.0
Version 5.1.0
2 parents 92965d8 + 24a3b23 commit 457ea61

File tree

12 files changed

+112
-15
lines changed

12 files changed

+112
-15
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ libraries.
4848
```groovy
4949
dependencies {
5050
// FirebaseUI for Firebase Realtime Database
51-
implementation 'com.firebaseui:firebase-ui-database:5.0.0'
51+
implementation 'com.firebaseui:firebase-ui-database:5.1.0'
5252
5353
// FirebaseUI for Cloud Firestore
54-
implementation 'com.firebaseui:firebase-ui-firestore:5.0.0'
54+
implementation 'com.firebaseui:firebase-ui-firestore:5.1.0'
5555
5656
// FirebaseUI for Firebase Auth
57-
implementation 'com.firebaseui:firebase-ui-auth:5.0.0'
57+
implementation 'com.firebaseui:firebase-ui-auth:5.1.0'
5858
5959
// FirebaseUI for Cloud Storage
60-
implementation 'com.firebaseui:firebase-ui-storage:5.0.0'
60+
implementation 'com.firebaseui:firebase-ui-storage:5.1.0'
6161
}
6262
```
6363

auth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Gradle, add the dependency:
6565
```groovy
6666
dependencies {
6767
// ...
68-
implementation 'com.firebaseui:firebase-ui-auth:5.0.0'
68+
implementation 'com.firebaseui:firebase-ui-auth:5.1.0'
6969
7070
// Required only if Facebook login support is required
7171
// Find the latest Facebook SDK releases here: https://goo.gl/Ce5L94

auth/src/main/java/com/firebase/ui/auth/ui/idp/AuthMethodPickerActivity.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ private void populateIdpList(List<IdpConfig> providerConfigs) {
206206
private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) {
207207
Map<String, Integer> providerButtonIds = customLayout.getProvidersButton();
208208
for (IdpConfig idpConfig : providerConfigs) {
209-
final String providerId = idpConfig.getProviderId();
209+
final String providerId = providerOrEmailLinkProvider(idpConfig.getProviderId());
210+
210211
if (!providerButtonIds.containsKey(providerId)) {
211212
throw new IllegalStateException("No button found for auth provider: " + providerId);
212213
}
@@ -217,6 +218,15 @@ private void populateIdpListCustomLayout(List<IdpConfig> providerConfigs) {
217218
}
218219
}
219220

221+
@NonNull
222+
private String providerOrEmailLinkProvider(@NonNull String providerId) {
223+
if (providerId.equals(EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD)) {
224+
return EmailAuthProvider.PROVIDER_ID;
225+
}
226+
227+
return providerId;
228+
}
229+
220230
private void handleSignInOperation(IdpConfig idpConfig, View view) {
221231
ViewModelProvider supplier = ViewModelProviders.of(this);
222232
final String providerId = idpConfig.getProviderId();

auth/src/test/java/com/firebase/ui/auth/ui/idp/AuthMethodPickerActivityTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,28 @@ public void testCustomAuthMethodPickerLayout() {
122122
nextIntent.intent.getComponent().getClassName());
123123
}
124124

125+
@Test
126+
public void testCustomAuthMethodPickerLayoutWithEmailLink() {
127+
List<String> providers = Arrays.asList(EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD);
128+
129+
AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout
130+
.Builder(R.layout.fui_provider_button_email)
131+
.setEmailButtonId(R.id.email_button)
132+
.build();
133+
134+
AuthMethodPickerActivity authMethodPickerActivity = createActivityWithCustomLayout(providers, customLayout);
135+
136+
Button emailButton = authMethodPickerActivity.findViewById(R.id.email_button);
137+
emailButton.performClick();
138+
139+
//Expected result -> Directing users to EmailActivity
140+
ShadowActivity.IntentForResult nextIntent =
141+
Shadows.shadowOf(authMethodPickerActivity).getNextStartedActivityForResult();
142+
assertEquals(
143+
EmailActivity.class.getName(),
144+
nextIntent.intent.getComponent().getClassName());
145+
}
146+
125147
private AuthMethodPickerActivity createActivityWithCustomLayout(List<String> providers,
126148
AuthMethodPickerLayout layout) {
127149
Intent startIntent = AuthMethodPickerActivity.createIntent(

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ repositories {
44

55
plugins {
66
`kotlin-dsl`
7-
}
7+
}

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object Config {
2-
const val version = "5.0.0"
2+
const val version = "5.1.0"
33
val submodules = listOf("auth", "auth-github", "common", "firestore", "database", "storage")
44

55
private const val kotlinVersion = "1.2.61"

common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ public boolean isListening(@NonNull L listener) {
160160
return mListeners.contains(listener);
161161
}
162162

163+
/**
164+
* Clear data and notify all listeners.
165+
*/
166+
public void clear() {
167+
getSnapshots().clear();
168+
notifyOnDataChanged();
169+
}
170+
163171
protected final void notifyOnChildChanged(@NonNull ChangeEventType type,
164172
@NonNull S snapshot,
165173
int newIndex,

database/src/main/java/com/firebase/ui/database/FirebaseArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
public class FirebaseArray<T> extends ObservableSnapshotArray<T>
3434
implements ChildEventListener, ValueEventListener {
35-
private final Query mQuery;
35+
private Query mQuery;
3636
private final List<DataSnapshot> mSnapshots = new ArrayList<>();
3737

3838
/**

database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class FirebaseIndexArray<T> extends ObservableSnapshotArray<T>
3434
implements ChangeEventListener {
3535
private static final String TAG = "FirebaseIndexArray";
3636

37-
private final DatabaseReference mDataRef;
37+
private DatabaseReference mDataRef;
3838
private final Map<DatabaseReference, ValueEventListener> mRefs = new HashMap<>();
3939

4040
private final FirebaseArray<String> mKeySnapshots;

database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ public abstract class FirebaseRecyclerAdapter<T, VH extends RecyclerView.ViewHol
2828
extends RecyclerView.Adapter<VH> implements FirebaseAdapter<T> {
2929
private static final String TAG = "FirebaseRecyclerAdapter";
3030

31-
private final ObservableSnapshotArray<T> mSnapshots;
31+
private FirebaseRecyclerOptions<T> mOptions;
32+
private ObservableSnapshotArray<T> mSnapshots;
3233

3334
/**
3435
* Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See
3536
* {@link FirebaseRecyclerOptions} for configuration options.
3637
*/
3738
public FirebaseRecyclerAdapter(@NonNull FirebaseRecyclerOptions<T> options) {
39+
mOptions = options;
3840
mSnapshots = options.getSnapshots();
3941

40-
if (options.getOwner() != null) {
41-
options.getOwner().getLifecycle().addObserver(this);
42+
if (mOptions.getOwner() != null) {
43+
mOptions.getOwner().getLifecycle().addObserver(this);
4244
}
4345
}
4446

@@ -117,6 +119,30 @@ public int getItemCount() {
117119
return mSnapshots.isListening(this) ? mSnapshots.size() : 0;
118120
}
119121

122+
/**
123+
* Re-initialize the Adapter with a new set of options. Can be used to change the query
124+
* without re-constructing the entire adapter.
125+
*/
126+
public void updateOptions(@NonNull FirebaseRecyclerOptions<T> options) {
127+
// Tear down old options
128+
boolean wasListening = mSnapshots.isListening(this);
129+
if (mOptions.getOwner() != null) {
130+
mOptions.getOwner().getLifecycle().removeObserver(this);
131+
}
132+
mSnapshots.clear();
133+
stopListening();
134+
135+
// Set up new options
136+
mOptions = options;
137+
mSnapshots = options.getSnapshots();
138+
if (options.getOwner() != null) {
139+
options.getOwner().getLifecycle().addObserver(this);
140+
}
141+
if (wasListening) {
142+
startListening();
143+
}
144+
}
145+
120146
@Override
121147
public void onBindViewHolder(@NonNull VH holder, int position) {
122148
onBindViewHolder(holder, position, getItem(position));

firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
public class FirestoreArray<T> extends ObservableSnapshotArray<T>
2424
implements EventListener<QuerySnapshot> {
25-
private final Query mQuery;
25+
private Query mQuery;
2626
private final MetadataChanges mMetadataChanges;
2727
private ListenerRegistration mRegistration;
2828

firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerAdapter.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public abstract class FirestoreRecyclerAdapter<T, VH extends RecyclerView.ViewHo
2525

2626
private static final String TAG = "FirestoreRecycler";
2727

28-
private final ObservableSnapshotArray<T> mSnapshots;
28+
private FirestoreRecyclerOptions<T> mOptions;
29+
private ObservableSnapshotArray<T> mSnapshots;
2930

3031
/**
3132
* Create a new RecyclerView adapter that listens to a Firestore Query. See {@link
@@ -83,11 +84,41 @@ public T getItem(int position) {
8384
return mSnapshots.get(position);
8485
}
8586

87+
/**
88+
* Gets the size of snapshots in adapter.
89+
*
90+
* @return the total count of snapshots in adapter.
91+
* @see ObservableSnapshotArray#size()
92+
*/
8693
@Override
8794
public int getItemCount() {
8895
return mSnapshots.isListening(this) ? mSnapshots.size() : 0;
8996
}
9097

98+
/**
99+
* Re-initialize the Adapter with a new set of options. Can be used to change the query without
100+
* re-constructing the entire adapter.
101+
*/
102+
public void updateOptions(@NonNull FirestoreRecyclerOptions<T> options) {
103+
// Tear down old options
104+
boolean wasListening = mSnapshots.isListening(this);
105+
if (mOptions.getOwner() != null) {
106+
mOptions.getOwner().getLifecycle().removeObserver(this);
107+
}
108+
mSnapshots.clear();
109+
stopListening();
110+
111+
// Set up new options
112+
mOptions = options;
113+
mSnapshots = options.getSnapshots();
114+
if (options.getOwner() != null) {
115+
options.getOwner().getLifecycle().addObserver(this);
116+
}
117+
if (wasListening) {
118+
startListening();
119+
}
120+
}
121+
91122
@Override
92123
public void onChildChanged(@NonNull ChangeEventType type,
93124
@NonNull DocumentSnapshot snapshot,

0 commit comments

Comments
 (0)