Skip to content

Commit

Permalink
Version 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern authored Jan 22, 2018
2 parents 7ca207e + 2dff7df commit 83e6a76
Show file tree
Hide file tree
Showing 73 changed files with 2,313 additions and 1,144 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ libraries.
```groovy
dependencies {
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:3.1.3'
implementation 'com.firebaseui:firebase-ui-database:3.2.0'
// FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:3.1.3'
implementation 'com.firebaseui:firebase-ui-firestore:3.2.0'
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:3.1.3'
implementation 'com.firebaseui:firebase-ui-auth:3.2.0'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:3.1.3'
implementation 'com.firebaseui:firebase-ui-storage:3.2.0'
}
```

Expand Down Expand Up @@ -102,6 +102,7 @@ For convenience, here are some recent examples:

| FirebaseUI Version | Firebase/Play Services Version |
|--------------------|--------------------------------|
| 3.2.0 | 11.8.0 |
| 3.1.3 | 11.8.0 |
| 3.1.2 | 11.6.2 |
| 3.1.0 | 11.4.2 |
Expand Down
34 changes: 17 additions & 17 deletions app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import butterknife.OnClick;

public class AuthUiActivity extends AppCompatActivity {
private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME";
private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/";
private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/";
private static final String GOOGLE_PRIVACY_POLICY_URL = "https://www.google.com/policies/privacy/";
Expand Down Expand Up @@ -120,6 +119,9 @@ public class AuthUiActivity extends AppCompatActivity {
@BindView(R.id.allow_new_email_accounts)
CheckBox mAllowNewEmailAccounts;

@BindView(R.id.require_name)
CheckBox mRequireName;

@BindView(R.id.facebook_scopes_label)
TextView mFacebookScopesLabel;

Expand Down Expand Up @@ -204,7 +206,6 @@ public void signIn(View view) {
.setPrivacyPolicyUrl(getSelectedPrivacyPolicyUrl())
.setIsSmartLockEnabled(mEnableCredentialSelector.isChecked(),
mEnableHintSelector.isChecked())
.setAllowNewEmailAccounts(mAllowNewEmailAccounts.isChecked())
.build(),
RC_SIGN_IN);
}
Expand Down Expand Up @@ -328,29 +329,28 @@ private List<IdpConfig> getSelectedProviders() {

if (mUseGoogleProvider.isChecked()) {
selectedProviders.add(
new IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER)
.setPermissions(getGooglePermissions())
.build());
new IdpConfig.GoogleBuilder().setScopes(getGoogleScopes()).build());
}

if (mUseFacebookProvider.isChecked()) {
selectedProviders.add(
new IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER)
.setPermissions(getFacebookPermissions())
.build());
selectedProviders.add(new IdpConfig.FacebookBuilder()
.setPermissions(getFacebookPermissions())
.build());
}

if (mUseTwitterProvider.isChecked()) {
selectedProviders.add(new IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build());
selectedProviders.add(new IdpConfig.TwitterBuilder().build());
}

if (mUseEmailProvider.isChecked()) {
selectedProviders.add(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build());
selectedProviders.add(new IdpConfig.EmailBuilder()
.setRequireName(mRequireName.isChecked())
.setAllowNewAccounts(mAllowNewEmailAccounts.isChecked())
.build());
}

if (mUsePhoneProvider.isChecked()) {
selectedProviders.add(
new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build());
selectedProviders.add(new IdpConfig.PhoneBuilder().build());
}

return selectedProviders;
Expand All @@ -376,12 +376,12 @@ private String getSelectedPrivacyPolicyUrl() {

@MainThread
private boolean isGoogleMisconfigured() {
return UNCHANGED_CONFIG_VALUE.equals(getString(R.string.default_web_client_id));
return AuthUI.UNCONFIGURED_CONFIG_VALUE.equals(getString(R.string.default_web_client_id));
}

@MainThread
private boolean isFacebookMisconfigured() {
return UNCHANGED_CONFIG_VALUE.equals(getString(R.string.facebook_application_id));
return AuthUI.UNCONFIGURED_CONFIG_VALUE.equals(getString(R.string.facebook_application_id));
}

@MainThread
Expand All @@ -391,7 +391,7 @@ private boolean isTwitterMisconfigured() {
getString(R.string.twitter_consumer_secret)
);

return twitterConfigs.contains(UNCHANGED_CONFIG_VALUE);
return twitterConfigs.contains(AuthUI.UNCONFIGURED_CONFIG_VALUE);
}

@MainThread
Expand All @@ -412,7 +412,7 @@ private List<String> getFacebookPermissions() {
}

@MainThread
private List<String> getGooglePermissions() {
private List<String> getGoogleScopes() {
List<String> result = new ArrayList<>();
if (mGoogleScopeYoutubeData.isChecked()) {
result.add("https://www.googleapis.com/auth/youtube.readonly");
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/auth_ui_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@
android:checked="true"
android:text="@string/allow_new_email_acccount" />

<CheckBox
android:id="@+id/require_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/require_name" />

</LinearLayout>

</ScrollView>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<string name="enable_credential_selector">Enable Smart Lock\'s credential selector</string>
<string name="enable_hint_selector">Enable Smart Lock\'s hint selector</string>
<string name="allow_new_email_acccount">Allow account creation if email does not exist.</string>
<string name="require_name">Require first/last name with email accounts.</string>

<string name="unknown_response">Unexpected onActivityResult response code</string>
<string name="unknown_sign_in_response">Unknown response from AuthUI sign-in</string>
Expand Down
108 changes: 53 additions & 55 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Gradle, add the dependency:
```groovy
dependencies {
// ...
implementation 'com.firebaseui:firebase-ui-auth:3.1.3'
implementation 'com.firebaseui:firebase-ui-auth:3.2.0'
// Required only if Facebook login support is required
// Find the latest Facebook SDK releases here: https://goo.gl/Ce5L94
Expand Down Expand Up @@ -216,16 +216,16 @@ You can enable sign-in providers like Google Sign-In or Facebook Log In by calli

```java
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(
Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                             new AuthUI.IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build()))
.build(),
RC_SIGN_IN);
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build()))
.build(),
RC_SIGN_IN);
```

##### Adding a ToS and privacy policy
Expand Down Expand Up @@ -260,28 +260,30 @@ startActivityForResult(
RC_SIGN_IN);
```

It is often desirable to disable Smart Lock in development but enable it in production. To achieve
this, you can use the `BuildConfig.DEBUG` flag to control Smart Lock:
###### Smart Lock hints

If you'd like to keep Smart Lock's "hints" but disable the saving/retrieving of credentials, then
you can use the two-argument version of `setIsSmartLockEnabled`:

```java
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(!BuildConfig.DEBUG)
.setIsSmartLockEnabled(false, true)
.build(),
RC_SIGN_IN);
```

###### Smart Lock hints
###### Smart Lock in dev builds

If you'd like to keep Smart Lock's "hints" but disable the saving/retrieving of credentials, then
you can use the two-argument version of `setIsSmartLockEnabled`:
It is often desirable to disable Smart Lock in development but enable it in production. To achieve
this, you can use the `BuildConfig.DEBUG` flag to control Smart Lock:

```java
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(false, true)
.setIsSmartLockEnabled(!BuildConfig.DEBUG /* credentials */, true /* hints */)
.build(),
RC_SIGN_IN);
```
Expand All @@ -293,27 +295,27 @@ provide a default phone number (in international format) that will be used to pr
country code and phone number input fields. The user is still able to edit the number if desired.

```java
// Use a Bundle to hold the default number, and pass it to the Builder via setParams:
Bundle params = new Bundle();
params.putString(AuthUI.EXTRA_DEFAULT_PHONE_NUMBER, "+123456789");
IdpConfig phoneConfigWithDefaultNumber =
new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER)
.setParams(params)
.build();
IdpConfig phoneConfigWithDefaultNumber = new IdpConfig.PhoneBuilder()
.setDefaultNumber("+123456789")
.build();
```

Alternatively, you can set only the default phone number country.

```java
IdpConfig phoneConfigWithDefaultNumber = new IdpConfig.PhoneBuilder()
.setDefaultCountryIso("ca")
.build();
```

It is also possible to set a default country code along with a national number if a specific country
is your app's target audience. This will take precedence over the full default phone number if both
are provided.

```java
Bundle params = new Bundle();
params.putString(AuthUI.EXTRA_DEFAULT_COUNTRY_CODE, "ca");
params.putString(AuthUI.EXTRA_DEFAULT_NATIONAL_NUMBER, "23456789");
IdpConfig phoneConfigWithDefaultCountryAndNationalNumber =
new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER)
.setParams(params)
.build();
IdpConfig phoneConfigWithDefaultNumber = new IdpConfig.PhoneBuilder()
.setDefaultNumber("ca", "23456789")
.build();
```

### Handling the sign-in response
Expand Down Expand Up @@ -561,50 +563,46 @@ at a diff of the `strings.xml` file before updating FirebaseUI.

### Google
By default, FirebaseUI requests the `email` and `profile` scopes when using Google Sign-In. If you
would like to request additional scopes from the user, call `setPermissions` on the
`AuthUI.IdpConfig.Builder` when initializing FirebaseUI.
would like to request additional scopes from the user, call `setScopes` on the
`AuthUI.IdpConfig.GoogleBuilder` when initializing FirebaseUI.


```java
// For a list of all scopes, see:
// https://developers.google.com/identity/protocols/googlescopes
AuthUI.IdpConfig googleIdp = new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER)
.setPermissions(Arrays.asList(Scopes.GAMES))
.build();
AuthUI.IdpConfig googleIdp = new AuthUI.IdpConfig.GoogleBuilder()
.setScopes(Arrays.asList(Scopes.GAMES))
.build();

startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(Arrays.asList(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
googleIdp,
new IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
.build(),
RC_SIGN_IN);
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(Arrays.asList(googleIdp, ...))
.build(),
RC_SIGN_IN);
```


### Facebook

By default, FirebaseUI requests the `email` and `public_profile` permissions when initiating
Facebook Login. If you would like to request additional permissions from the user, call
`setPermissions` on the `AuthUI.IdpConfig.Builder` when initializing FirebaseUI.
`setPermissions` on the `AuthUI.IdpConfig.FacebookBuilder` when initializing FirebaseUI.

```java
// For a list of permissions see:
// https://developers.facebook.com/docs/facebook-login/android
// https://developers.facebook.com/docs/facebook-login/permissions

AuthUI.IdpConfig facebookIdp = new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER)
.setPermissions(Arrays.asList("user_friends"))
.build();
AuthUI.IdpConfig facebookIdp = new AuthUI.IdpConfig.FacebookBuilder()
.setPermissions(Arrays.asList("user_friends"))
.build();

startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
facebookIdp))
.build(),
RC_SIGN_IN);
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(Arrays.asList(facebookIdp, ...))
.build(),
RC_SIGN_IN);
```

### Twitter
Expand Down
4 changes: 2 additions & 2 deletions auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
dependencies {
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support:customtabs:$supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta3'

implementation "android.arch.lifecycle:extensions:$architectureVersion"
annotationProcessor "android.arch.lifecycle:compiler:$architectureVersion"
Expand All @@ -57,7 +57,7 @@ dependencies {
testImplementation 'com.facebook.android:facebook-login:4.29.0'
testImplementation("com.twitter.sdk.android:twitter-core:3.1.1@aar") { transitive = true }

lintChecks project(':lint')
implementation project(':internal:lintchecks')
}

javadoc.include([
Expand Down
6 changes: 6 additions & 0 deletions auth/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
</intent-filter>
</activity>

<provider
android:name=".data.client.AuthUiInitProvider"
android:authorities="${applicationId}.authuiinitprovider"
android:exported="false"
android:initOrder="90" />

</application>

</manifest>
Loading

0 comments on commit 83e6a76

Please sign in to comment.