Skip to content

Commit e25ff29

Browse files
authored
Merge pull request #932 from firebase/version-2.4.0-release
Version 2.4.0 release
2 parents 29f8885 + 118ce9b commit e25ff29

File tree

19 files changed

+258
-68
lines changed

19 files changed

+258
-68
lines changed

README.md

Lines changed: 5 additions & 4 deletions
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.3.0'
42+
compile 'com.firebaseui:firebase-ui-database:2.4.0'
4343
4444
// FirebaseUI Auth only
45-
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
45+
compile 'com.firebaseui:firebase-ui-auth:2.4.0'
4646
4747
// FirebaseUI Storage only
48-
compile 'com.firebaseui:firebase-ui-storage:2.3.0'
48+
compile 'com.firebaseui:firebase-ui-storage:2.4.0'
4949
5050
// Single target that includes all FirebaseUI libraries above
51-
compile 'com.firebaseui:firebase-ui:2.3.0'
51+
compile 'com.firebaseui:firebase-ui:2.4.0'
5252
}
5353
```
5454

@@ -91,6 +91,7 @@ For convenience, here are some recent examples:
9191

9292
| FirebaseUI Version | Firebase/Play Services Version |
9393
|--------------------|--------------------------------|
94+
| 2.4.0 | 11.4.0 |
9495
| 2.3.0 | 11.0.4 |
9596
| 2.2.0 | 11.0.4 |
9697
| 2.1.1 | 11.0.2 |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void signIn(View view) {
205205
.setTosUrl(getSelectedTosUrl())
206206
.setPrivacyPolicyUrl(getSelectedPrivacyPolicyUrl())
207207
.setIsSmartLockEnabled(mEnableCredentialSelector.isChecked(),
208-
mEnableHintSelector.isChecked())
208+
mEnableHintSelector.isChecked())
209209
.setAllowNewEmailAccounts(mAllowNewEmailAccounts.isChecked())
210210
.build(),
211211
RC_SIGN_IN);

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.firebase.uidemo.database;
22

3-
import android.os.Bundle;
43
import android.view.View;
54

65
import com.firebase.ui.database.FirebaseIndexRecyclerAdapter;
@@ -13,12 +12,6 @@
1312
public class ChatIndexActivity extends ChatActivity {
1413
private DatabaseReference mChatIndicesRef;
1514

16-
@Override
17-
protected void onCreate(Bundle savedInstanceState) {
18-
super.onCreate(savedInstanceState);
19-
mChatIndicesRef = FirebaseDatabase.getInstance().getReference().child("chatIndices");
20-
}
21-
2215
@Override
2316
public void onClick(View v) {
2417
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
@@ -34,6 +27,11 @@ public void onClick(View v) {
3427

3528
@Override
3629
protected FirebaseRecyclerAdapter<Chat, ChatHolder> getAdapter() {
30+
mChatIndicesRef = FirebaseDatabase.getInstance()
31+
.getReference()
32+
.child("chatIndices")
33+
.child(FirebaseAuth.getInstance().getCurrentUser().getUid());
34+
3735
return new FirebaseIndexRecyclerAdapter<Chat, ChatHolder>(
3836
Chat.class,
3937
R.layout.message,

auth/README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ Gradle, add the dependency:
4646
```groovy
4747
dependencies {
4848
// ...
49-
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
49+
compile 'com.firebaseui:firebase-ui-auth:2.4.0'
5050
5151
// Required only if Facebook login support is required
52-
compile('com.facebook.android:facebook-android-sdk:4.22.1')
52+
compile('com.facebook.android:facebook-android-sdk:4.26.0')
5353
5454
// Required only if Twitter login support is required
5555
compile("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
@@ -256,6 +256,34 @@ startActivityForResult(
256256
RC_SIGN_IN);
257257
```
258258

259+
When using the phone verification provider and the number is known in advance, it is possible to
260+
provide a default phone number (in international format) that will be used to prepopulate the
261+
country code and phone number input fields. The user is still able to edit the number if desired.
262+
263+
```java
264+
// Use a Bundle to hold the default number, and pass it to the Builder via setParams:
265+
Bundle params = new Bundle();
266+
params.putString(AuthUI.EXTRA_DEFAULT_PHONE_NUMBER, "+123456789");
267+
IdpConfig phoneConfigWithDefaultNumber =
268+
new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER)
269+
.setParams(params)
270+
.build();
271+
```
272+
273+
It is also possible to set a default country code along with a national number if a specific country
274+
is your app's target audience. This will take precedence over the full default phone number if both
275+
are provided.
276+
277+
```java
278+
Bundle params = new Bundle();
279+
params.putString(AuthUI.EXTRA_DEFAULT_COUNTRY_CODE, "ca");
280+
params.putString(AuthUI.EXTRA_DEFAULT_NATIONAL_NUMBER, "23456789");
281+
IdpConfig phoneConfigWithDefaultCountryAndNationalNumber =
282+
new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER)
283+
.setParams(params)
284+
.build();
285+
```
286+
259287
#### Handling the sign-in response
260288

261289
##### Response codes

auth/src/main/AndroidManifest.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
android:name="com.google.android.gms.version"
1313
android:value="@integer/google_play_services_version" />
1414

15-
<meta-data
16-
android:name="io.fabric.ApiKey"
17-
android:value="@string/twitter_consumer_secret" />
18-
1915
<meta-data
2016
android:name="com.facebook.sdk.ApplicationId"
2117
android:value="@string/facebook_application_id" />

auth/src/main/java/com/firebase/ui/auth/AuthUI.java

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import android.app.Activity;
1818
import android.content.Intent;
19+
import android.os.Bundle;
1920
import android.os.Parcel;
2021
import android.os.Parcelable;
2122
import android.support.annotation.CallSuper;
@@ -28,6 +29,7 @@
2829

2930
import com.facebook.login.LoginManager;
3031
import com.firebase.ui.auth.provider.TwitterProvider;
32+
import com.firebase.ui.auth.ui.ExtraConstants;
3133
import com.firebase.ui.auth.ui.FlowParameters;
3234
import com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity;
3335
import com.firebase.ui.auth.util.GoogleSignInHelper;
@@ -104,6 +106,21 @@ public class AuthUI {
104106
*/
105107
public static final String PHONE_VERIFICATION_PROVIDER = PhoneAuthProvider.PROVIDER_ID;
106108

109+
/**
110+
* Bundle key for the default full phone number parameter.
111+
*/
112+
public static final String EXTRA_DEFAULT_PHONE_NUMBER = ExtraConstants.EXTRA_PHONE;
113+
114+
/**
115+
* Bundle key for the default phone country code parameter.
116+
*/
117+
public static final String EXTRA_DEFAULT_COUNTRY_CODE = ExtraConstants.EXTRA_COUNTRY_CODE;
118+
119+
/**
120+
* Bundle key for the default national phone number parameter.
121+
*/
122+
public static final String EXTRA_DEFAULT_NATIONAL_NUMBER = ExtraConstants.EXTRA_NATIONAL_NUMBER;
123+
107124
/**
108125
* Default value for logo resource, omits the logo from the {@link AuthMethodPickerActivity}.
109126
*/
@@ -269,15 +286,21 @@ public SignInIntentBuilder createSignInIntentBuilder() {
269286
public static class IdpConfig implements Parcelable {
270287
private final String mProviderId;
271288
private final List<String> mScopes;
289+
private final Bundle mParams;
272290

273-
private IdpConfig(@SupportedProvider @NonNull String providerId, List<String> scopes) {
291+
private IdpConfig(
292+
@SupportedProvider @NonNull String providerId,
293+
List<String> scopes,
294+
Bundle params) {
274295
mProviderId = providerId;
275296
mScopes = Collections.unmodifiableList(scopes);
297+
mParams = params;
276298
}
277299

278300
private IdpConfig(Parcel in) {
279301
mProviderId = in.readString();
280302
mScopes = Collections.unmodifiableList(in.createStringArrayList());
303+
mParams = in.readBundle(getClass().getClassLoader());
281304
}
282305

283306
@SupportedProvider
@@ -289,6 +312,10 @@ public List<String> getScopes() {
289312
return mScopes;
290313
}
291314

315+
public Bundle getParams() {
316+
return mParams;
317+
}
318+
292319
public static final Creator<IdpConfig> CREATOR = new Creator<IdpConfig>() {
293320
@Override
294321
public IdpConfig createFromParcel(Parcel in) {
@@ -310,6 +337,7 @@ public int describeContents() {
310337
public void writeToParcel(Parcel parcel, int i) {
311338
parcel.writeString(mProviderId);
312339
parcel.writeStringList(mScopes);
340+
parcel.writeBundle(mParams);
313341
}
314342

315343
@Override
@@ -332,12 +360,14 @@ public String toString() {
332360
return "IdpConfig{" +
333361
"mProviderId='" + mProviderId + '\'' +
334362
", mScopes=" + mScopes +
363+
", mParams=" + mParams +
335364
'}';
336365
}
337366

338367
public static class Builder {
339368
@SupportedProvider private String mProviderId;
340369
private List<String> mScopes = new ArrayList<>();
370+
private Bundle mParams = new Bundle();
341371

342372
/**
343373
* Builds the configuration parameters for an identity provider.
@@ -372,8 +402,13 @@ public Builder setPermissions(List<String> permissions) {
372402
return this;
373403
}
374404

405+
public Builder setParams(Bundle params) {
406+
mParams = params;
407+
return this;
408+
}
409+
375410
public IdpConfig build() {
376-
return new IdpConfig(mProviderId, mScopes);
411+
return new IdpConfig(mProviderId, mScopes, mParams);
377412
}
378413
}
379414
}
@@ -448,8 +483,8 @@ public T setAvailableProviders(@NonNull List<IdpConfig> idpConfigs) {
448483
for (IdpConfig config : idpConfigs) {
449484
if (mProviders.contains(config)) {
450485
throw new IllegalArgumentException("Each provider can only be set once. "
451-
+ config.getProviderId()
452-
+ " was set twice.");
486+
+ config.getProviderId()
487+
+ " was set twice.");
453488
} else {
454489
mProviders.add(config);
455490
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import android.app.Activity;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.os.Bundle;
67
import android.support.annotation.LayoutRes;
78

9+
import com.firebase.ui.auth.AuthUI;
810
import com.firebase.ui.auth.R;
911
import com.firebase.ui.auth.ui.FlowParameters;
1012
import com.firebase.ui.auth.ui.phone.PhoneVerificationActivity;
@@ -34,8 +36,16 @@ public int getButtonLayout() {
3436

3537
@Override
3638
public void startLogin(Activity activity) {
39+
40+
Bundle params = null;
41+
for (AuthUI.IdpConfig idpConfig : mFlowParameters.providerInfo) {
42+
if (idpConfig.getProviderId().equals(AuthUI.PHONE_VERIFICATION_PROVIDER)) {
43+
params = idpConfig.getParams();
44+
}
45+
}
46+
3747
activity.startActivityForResult(
38-
PhoneVerificationActivity.createIntent(activity, mFlowParameters, null),
48+
PhoneVerificationActivity.createIntent(activity, mFlowParameters, params),
3949
RC_PHONE_FLOW);
4050
}
4151

auth/src/main/java/com/firebase/ui/auth/ui/ExtraConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ public class ExtraConstants {
2626
public static final String EXTRA_USER = "extra_user";
2727
public static final String EXTRA_EMAIL = "extra_email";
2828
public static final String EXTRA_PHONE = "extra_phone_number";
29+
public static final String EXTRA_COUNTRY_CODE = "extra_country_code";
30+
public static final String EXTRA_NATIONAL_NUMBER = "extra_national_number";
2931
public static final String HAS_EXISTING_INSTANCE = "has_existing_instance";
32+
public static final String EXTRA_PARAMS = "extra_params";
3033
}

auth/src/main/java/com/firebase/ui/auth/ui/ImeHelper.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ public static void setImeOnDoneListener(EditText doneEditText,
1717
doneEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
1818
@Override
1919
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
20-
if (event != null
21-
&& event.getKeyCode() == KeyEvent.KEYCODE_ENTER
22-
|| actionId == EditorInfo.IME_ACTION_DONE) {
20+
if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
21+
if (event.getAction() == KeyEvent.ACTION_UP) {
22+
listener.onDonePressed();
23+
}
24+
25+
// We need to return true even if we didn't handle the event to continue
26+
// receiving future callbacks.
27+
return true;
28+
} else if (actionId == EditorInfo.IME_ACTION_DONE) {
2329
listener.onDonePressed();
2430
return true;
2531
}

auth/src/main/java/com/firebase/ui/auth/ui/phone/CompletableProgressDialog.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,23 @@ public final class CompletableProgressDialog extends DialogFragment {
3838

3939
public static CompletableProgressDialog show(FragmentManager manager) {
4040
CompletableProgressDialog dialog = new CompletableProgressDialog();
41-
dialog.show(manager, TAG);
41+
dialog.showAllowingStateLoss(manager, TAG);
4242
return dialog;
4343
}
4444

45+
/**
46+
* This method is adapted from {@link #show(FragmentManager, String)}
47+
*/
48+
public void showAllowingStateLoss(FragmentManager manager, String tag) {
49+
// This prevents us from hitting FragmentManager.checkStateLoss() which
50+
// throws a runtime exception if state has already been saved.
51+
if (manager.isStateSaved()) {
52+
return;
53+
}
54+
55+
show(manager, tag);
56+
}
57+
4558
@NonNull
4659
@Override
4760
public Dialog onCreateDialog(Bundle savedInstanceState) {
@@ -60,12 +73,18 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
6073

6174
public void onComplete(String msg) {
6275
setMessage(msg);
63-
mProgress.setVisibility(View.GONE);
64-
mSuccessImage.setVisibility(View.VISIBLE);
76+
77+
if (mProgress != null) {
78+
mProgress.setVisibility(View.GONE);
79+
}
80+
81+
if (mSuccessImage != null) {
82+
mSuccessImage.setVisibility(View.VISIBLE);
83+
}
6584
}
6685

6786
public void setMessage(CharSequence message) {
68-
if (mProgress != null) {
87+
if (mProgress != null && mMessageView != null) {
6988
mMessageView.setText(message);
7089
} else {
7190
mMessage = message;

0 commit comments

Comments
 (0)