Skip to content

Commit 7981414

Browse files
committed
Merge branch 'version-3.0.0-dev' into dev
Change-Id: Id0e192ec183dabc9a662bf5afcadfc79f9c08768
2 parents 29145b2 + 59dfda3 commit 7981414

File tree

17 files changed

+225
-42
lines changed

17 files changed

+225
-42
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 for Firebase Realtime Database
42-
compile 'com.firebaseui:firebase-ui-database:2.3.0'
42+
compile 'com.firebaseui:firebase-ui-database:2.4.0'
4343
4444
// FirebaseUI for Cloud Firestore
45-
compile 'com.firebaseui:firebase-ui-firestore:2.3.0'
45+
compile 'com.firebaseui:firebase-ui-firestore:2.4.0'
4646
4747
// FirebaseUI for Firebase Auth
48-
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
48+
compile 'com.firebaseui:firebase-ui-auth:2.4.0'
4949
5050
// FirebaseUI for Cloud Storage
51-
compile 'com.firebaseui:firebase-ui-storage:2.3.0'
51+
compile 'com.firebaseui:firebase-ui-storage:2.4.0'
5252
}
5353
```
5454

@@ -95,6 +95,7 @@ For convenience, here are some recent examples:
9595

9696
| FirebaseUI Version | Firebase/Play Services Version |
9797
|--------------------|--------------------------------|
98+
| 2.4.0 | 11.4.0 |
9899
| 2.3.0 | 11.0.4 |
99100
| 2.2.0 | 11.0.4 |
100101
| 2.1.1 | 11.0.2 |

app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies {
4545
compile "com.google.firebase:firebase-database:$firebaseVersion"
4646
compile "com.google.firebase:firebase-storage:$firebaseVersion"
4747

48-
compile('com.facebook.android:facebook-android-sdk:4.25.0')
48+
compile('com.facebook.android:facebook-login:4.27.0')
4949
compile("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
5050

5151
compile "android.arch.lifecycle:runtime:$architectureVersion"
@@ -57,12 +57,12 @@ dependencies {
5757
// The following dependencies are not required to use the Firebase UI library.
5858
// They are used to make some aspects of the demo app implementation simpler for
5959
// demonstrative purposes, and you may find them useful in your own apps; YMMV.
60-
compile 'pub.devrel:easypermissions:0.4.3'
60+
compile 'pub.devrel:easypermissions:1.0.1'
6161
compile 'com.jakewharton:butterknife:8.7.0'
6262
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
63-
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
64-
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
65-
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
63+
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4'
64+
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
65+
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
6666
}
6767

6868
apply plugin: 'com.google.gms.google-services'

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);

auth/README.md

Lines changed: 31 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
@@ -417,6 +445,7 @@ Second, ensure the three standard AppCompat color resources are defined with you
417445
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
418446
<item name="colorAccent">@color/colorAccent</item>
419447
</style>
448+
```
420449

421450
If you would like more control over FirebaseUI's styling, you can define your own custom style
422451
to override certain or all styling attributes. For example, a green sign-in theme:

auth/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ dependencies {
5151
compile "com.google.firebase:firebase-auth:$firebaseVersion"
5252
compile "com.google.android.gms:play-services-auth:$firebaseVersion"
5353

54-
provided 'com.facebook.android:facebook-android-sdk:4.25.0'
54+
provided 'com.facebook.android:facebook-login:4.27.0'
5555
provided("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
5656

5757
// The following libraries are needed to prevent incompatibilities with the facebook
@@ -62,7 +62,7 @@ dependencies {
6262
//noinspection GradleDynamicVersion
6363
testCompile 'org.mockito:mockito-core:2.8.+'
6464
testCompile 'org.robolectric:robolectric:3.4'
65-
testCompile 'com.facebook.android:facebook-android-sdk:4.25.0'
65+
testCompile 'com.facebook.android:facebook-login:4.27.0'
6666
}
6767

6868
javadoc.exclude([

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/FacebookProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import com.facebook.FacebookCallback;
2929
import com.facebook.FacebookException;
3030
import com.facebook.FacebookRequestError;
31-
import com.facebook.FacebookSdk;
3231
import com.facebook.GraphRequest;
3332
import com.facebook.GraphResponse;
33+
import com.facebook.WebDialog;
3434
import com.facebook.login.LoginManager;
3535
import com.facebook.login.LoginResult;
3636
import com.firebase.ui.auth.AuthUI;
@@ -64,7 +64,7 @@ public FacebookProvider(AuthUI.IdpConfig idpConfig, @StyleRes int theme) {
6464
} else {
6565
mScopes = scopes;
6666
}
67-
FacebookSdk.setWebDialogTheme(theme);
67+
WebDialog.setWebDialogTheme(theme);
6868
}
6969

7070
public static AuthCredential createAuthCredential(IdpResponse response) {

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/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)