Skip to content

Commit 4e7bce1

Browse files
authored
Merge pull request #748 from firebase/version-2.0.0-dev
Merge version-2.0.0-dev into master
2 parents 19b84da + f266b33 commit 4e7bce1

File tree

153 files changed

+13174
-2281
lines changed

Some content is hidden

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

153 files changed

+13174
-2281
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cache:
1313
android:
1414
components:
1515
- tools
16-
- build-tools-25.0.2
16+
- build-tools-25.0.3
1717
- android-25
1818
- platform-tools
1919
- extra-android-m2repository

README.md

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,22 @@ A compatible FirebaseUI client is also available for [iOS](https://github.com/fi
1010

1111
## Table of Contents
1212

13-
1. [Installation](#installation)
1413
1. [Usage](#usage)
14+
1. [Installation](#installation)
15+
1. [Upgrading](#upgrading)
16+
1. [Dependencies](#dependencies)
1517
1. [Sample App](#sample-app)
1618
1. [Contributing](#contributing)
1719

20+
## Usage
21+
22+
FirebaseUI has separate modules for using Firebase Database, Auth, and Storage. To
23+
get started, see the individual instructions for each module:
24+
25+
* [firebase-ui-database](database/README.md)
26+
* [firebase-ui-auth](auth/README.md)
27+
* [firebase-ui-storage](storage/README.md)
28+
1829
## Installation
1930

2031
FirebaseUI is published as a collection of libraries separated by the
@@ -47,6 +58,15 @@ required.
4758

4859
After the project is synchronized, we're ready to start using Firebase functionality in our app.
4960

61+
## Upgrading
62+
63+
If you are using an old version of FirebaseUI and upgrading, please see the appropriate
64+
migration guide:
65+
66+
* [Upgrade from 1.2.0 to 2.0](./docs/upgrade-to-2.0.md)
67+
68+
## Dependencies
69+
5070
### Compatibility with Firebase / Google Play Services Libraries
5171

5272
FirebaseUI libraries have the following transitive dependencies on the Firebase SDK:
@@ -67,29 +87,52 @@ in `common/constants.gradle`. If you are using any dependencies in your app of
6787
`compile 'com.google.firebase:firebase-*:x.y.z'` or `compile 'com.google.android.gms:play-services-*:x.y.z'`
6888
you need to make sure that you use the same version that your chosen version of FirebaseUI requires.
6989

70-
For convenience, here are some examples:
90+
For convenience, here are some recent examples:
7191

7292
| FirebaseUI Version | Firebase/Play Services Version |
7393
|--------------------|--------------------------------|
7494
| 1.2.0 | 10.2.0 |
7595
| 1.1.1 | 10.0.0 or 10.0.1 |
7696
| 1.0.1 | 10.0.0 or 10.0.1 |
7797
| 1.0.0 | 9.8.0 |
78-
| 0.6.2 | 9.8.0 |
79-
| 0.6.1 | 9.6.1 |
80-
| 0.6.0 | 9.6.0 |
81-
| 0.5.3 | 9.4.0 |
82-
| 0.4.4 | 9.4.0 |
83-
| 0.4.3 | 9.2.1 |
84-
| 0.4.2 | 9.2.0 |
85-
| 0.4.1 | 9.0.2 |
86-
| 0.4.0 | 9.0.0 |
8798

88-
## Usage
8999

90-
* [firebase-ui-database](database/README.md)
91-
* [firebase-ui-auth](auth/README.md)
92-
* [firebase-ui-storage](storage/README.md)
100+
## Upgrading dependencies
101+
102+
If you would like to use a newer version of one of FirebaseUI's transitive dependencies, such
103+
as Firebase, Play services, or the Android support libraries you need add explicit
104+
`compile` declarations in your `build.gradle` for all of FirebaseUI's dependencies at the version
105+
you want to use. For example if you want to use Play services/Firebase version `FOO` and support
106+
libraries version `BAR` add the following extra lines for each FirebaseUI module you're using:
107+
108+
Auth:
109+
110+
```groovy
111+
compile "com.google.firebase:firebase-auth:$FOO"
112+
compile "com.google.android.gms:play-services-auth:$FOO"
113+
114+
compile "com.android.support:design:$BAR"
115+
compile "com.android.support:customtabs:$BAR"
116+
compile "com.android.support:cardview-v7:$BAR"
117+
```
118+
119+
Database:
120+
121+
```groovy
122+
compile "com.google.firebase:firebase-database:$FOO"
123+
124+
compile "com.android.support:recyclerview-v7:$BAR"
125+
compile "com.android.support:support-v4:$BAR"
126+
```
127+
128+
Storage:
129+
130+
```groovy
131+
compile "com.google.firebase:firebase-storage:$FOO"
132+
133+
compile "com.android.support:appcompat-v7:$BAR"
134+
compile "com.android.support:palette-v7:$BAR"
135+
```
93136

94137
## Sample App
95138

app/build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'com.neenbedankt.android-apt'
32
apply from: '../library/quality/quality.gradle'
43

54
android {
@@ -39,15 +38,18 @@ dependencies {
3938
compile "com.google.firebase:firebase-database:$firebaseVersion"
4039
compile "com.google.firebase:firebase-storage:$firebaseVersion"
4140

41+
compile('com.facebook.android:facebook-android-sdk:4.22.1')
42+
compile("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
43+
4244
// The following dependencies are not required to use the Firebase UI library.
4345
// They are used to make some aspects of the demo app implementation simpler for
4446
// demonstrative purposes, and you may find them useful in your own apps; YMMV.
45-
compile 'pub.devrel:easypermissions:0.3.0'
47+
compile 'pub.devrel:easypermissions:0.4.0'
4648
compile 'com.jakewharton:butterknife:8.5.1'
47-
apt 'com.jakewharton:butterknife-compiler:8.5.1'
49+
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
4850
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
49-
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
50-
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
51+
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
52+
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
5153
}
5254

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

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<activity
3131
android:name=".database.ChatActivity"
3232
android:label="@string/name_chat"/>
33+
<activity
34+
android:name=".database.ChatIndexActivity"
35+
android:label="@string/name_chat"/>
3336

3437
<!-- Auth UI demo -->
3538
<activity

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

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class AuthUiActivity extends AppCompatActivity {
5252
private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME";
5353
private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/";
5454
private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/";
55+
private static final String GOOGLE_PRIVACY_POLICY_URL = "https://www.google.com/policies/privacy/";
56+
private static final String FIREBASE_PRIVACY_POLICY_URL = "https://firebase.google.com/terms/analytics/#7_privacy";
5557
private static final int RC_SIGN_IN = 100;
5658

5759
@BindView(R.id.default_theme)
@@ -69,6 +71,9 @@ public class AuthUiActivity extends AppCompatActivity {
6971
@BindView(R.id.email_provider)
7072
CheckBox mUseEmailProvider;
7173

74+
@BindView(R.id.phone_provider)
75+
CheckBox mUsePhoneProvider;
76+
7277
@BindView(R.id.google_provider)
7378
CheckBox mUseGoogleProvider;
7479

@@ -84,6 +89,12 @@ public class AuthUiActivity extends AppCompatActivity {
8489
@BindView(R.id.firebase_tos)
8590
RadioButton mUseFirebaseTos;
8691

92+
@BindView(R.id.google_privacy)
93+
RadioButton mUseGooglePrivacyPolicy;
94+
95+
@BindView(R.id.firebase_privacy)
96+
RadioButton mUseFirebasePrivacyPolicy;
97+
8798
@BindView(R.id.sign_in)
8899
Button mSignIn;
89100

@@ -99,8 +110,11 @@ public class AuthUiActivity extends AppCompatActivity {
99110
@BindView(R.id.no_logo)
100111
RadioButton mNoLogo;
101112

102-
@BindView(R.id.smartlock_enabled)
103-
CheckBox mEnableSmartLock;
113+
@BindView(R.id.credential_selector_enabled)
114+
CheckBox mEnableCredentialSelector;
115+
116+
@BindView(R.id.hint_selector_enabled)
117+
CheckBox mEnableHintSelector;
104118

105119
@BindView(R.id.allow_new_email_accounts)
106120
CheckBox mAllowNewEmailAccounts;
@@ -120,22 +134,22 @@ public class AuthUiActivity extends AppCompatActivity {
120134
@BindView(R.id.google_scope_drive_file)
121135
CheckBox mGoogleScopeDriveFile;
122136

123-
@BindView(R.id.google_scope_games)
124-
CheckBox mGoogleScopeGames;
137+
@BindView(R.id.google_scope_youtube_data)
138+
CheckBox mGoogleScopeYoutubeData;
125139

126140
@Override
127141
public void onCreate(Bundle savedInstanceState) {
128142
super.onCreate(savedInstanceState);
143+
setContentView(R.layout.auth_ui_layout);
144+
ButterKnife.bind(this);
129145

130146
FirebaseAuth auth = FirebaseAuth.getInstance();
131147
if (auth.getCurrentUser() != null) {
132-
startActivity(SignedInActivity.createIntent(this, null));
148+
startSignedInActivity(null);
133149
finish();
150+
return;
134151
}
135152

136-
setContentView(R.layout.auth_ui_layout);
137-
ButterKnife.bind(this);
138-
139153
if (!isGoogleConfigured()) {
140154
mUseGoogleProvider.setChecked(false);
141155
mUseGoogleProvider.setEnabled(false);
@@ -183,9 +197,11 @@ public void signIn(View view) {
183197
AuthUI.getInstance().createSignInIntentBuilder()
184198
.setTheme(getSelectedTheme())
185199
.setLogo(getSelectedLogo())
186-
.setProviders(getSelectedProviders())
200+
.setAvailableProviders(getSelectedProviders())
187201
.setTosUrl(getSelectedTosUrl())
188-
.setIsSmartLockEnabled(mEnableSmartLock.isChecked())
202+
.setPrivacyPolicyUrl(getSelectedPrivacyPolicyUrl())
203+
.setIsSmartLockEnabled(mEnableCredentialSelector.isChecked(),
204+
mEnableHintSelector.isChecked())
189205
.setAllowNewEmailAccounts(mAllowNewEmailAccounts.isChecked())
190206
.build(),
191207
RC_SIGN_IN);
@@ -208,7 +224,7 @@ private void handleSignInResponse(int resultCode, Intent data) {
208224

209225
// Successfully signed in
210226
if (resultCode == ResultCodes.OK) {
211-
startActivity(SignedInActivity.createIntent(this, response));
227+
startSignedInActivity(response);
212228
finish();
213229
return;
214230
} else {
@@ -233,11 +249,25 @@ private void handleSignInResponse(int resultCode, Intent data) {
233249
showSnackbar(R.string.unknown_sign_in_response);
234250
}
235251

252+
private void startSignedInActivity(IdpResponse response) {
253+
startActivity(
254+
SignedInActivity.createIntent(
255+
this,
256+
response,
257+
new SignedInActivity.SignedInConfig(
258+
getSelectedLogo(),
259+
getSelectedTheme(),
260+
getSelectedProviders(),
261+
getSelectedTosUrl(),
262+
mEnableCredentialSelector.isChecked(),
263+
mEnableHintSelector.isChecked())));
264+
}
265+
236266
@MainThread
237267
private void setGoogleScopesEnabled(boolean enabled) {
238268
mGoogleScopesLabel.setEnabled(enabled);
239269
mGoogleScopeDriveFile.setEnabled(enabled);
240-
mGoogleScopeGames.setEnabled(enabled);
270+
mGoogleScopeYoutubeData.setEnabled(enabled);
241271
}
242272

243273
@MainThread
@@ -280,12 +310,11 @@ private int getSelectedLogo() {
280310
private List<IdpConfig> getSelectedProviders() {
281311
List<IdpConfig> selectedProviders = new ArrayList<>();
282312

283-
if (mUseEmailProvider.isChecked()) {
284-
selectedProviders.add(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build());
285-
}
286-
287-
if (mUseTwitterProvider.isChecked()) {
288-
selectedProviders.add(new IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build());
313+
if (mUseGoogleProvider.isChecked()) {
314+
selectedProviders.add(
315+
new IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER)
316+
.setPermissions(getGooglePermissions())
317+
.build());
289318
}
290319

291320
if (mUseFacebookProvider.isChecked()) {
@@ -295,11 +324,17 @@ private List<IdpConfig> getSelectedProviders() {
295324
.build());
296325
}
297326

298-
if (mUseGoogleProvider.isChecked()) {
327+
if (mUseTwitterProvider.isChecked()) {
328+
selectedProviders.add(new IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build());
329+
}
330+
331+
if (mUseEmailProvider.isChecked()) {
332+
selectedProviders.add(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build());
333+
}
334+
335+
if (mUsePhoneProvider.isChecked()) {
299336
selectedProviders.add(
300-
new IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER)
301-
.setPermissions(getGooglePermissions())
302-
.build());
337+
new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build());
303338
}
304339

305340
return selectedProviders;
@@ -314,6 +349,15 @@ private String getSelectedTosUrl() {
314349
return FIREBASE_TOS_URL;
315350
}
316351

352+
@MainThread
353+
private String getSelectedPrivacyPolicyUrl() {
354+
if (mUseGooglePrivacyPolicy.isChecked()) {
355+
return GOOGLE_PRIVACY_POLICY_URL;
356+
}
357+
358+
return FIREBASE_PRIVACY_POLICY_URL;
359+
}
360+
317361
@MainThread
318362
private boolean isGoogleConfigured() {
319363
return !UNCHANGED_CONFIG_VALUE.equals(
@@ -356,8 +400,8 @@ private List<String> getFacebookPermissions() {
356400
@MainThread
357401
private List<String> getGooglePermissions() {
358402
List<String> result = new ArrayList<>();
359-
if (mGoogleScopeGames.isChecked()) {
360-
result.add(Scopes.GAMES);
403+
if (mGoogleScopeYoutubeData.isChecked()) {
404+
result.add("https://www.googleapis.com/auth/youtube.readonly");
361405
}
362406
if (mGoogleScopeDriveFile.isChecked()) {
363407
result.add(Scopes.DRIVE_FILE);

0 commit comments

Comments
 (0)