Skip to content

Commit e14170d

Browse files
authored
Merge pull request #510 from firebase/version-1.1.0-dev
Merge version-1.1.0-dev into master
2 parents c04cac4 + 608a9b2 commit e14170d

File tree

154 files changed

+3332
-3518
lines changed

Some content is hidden

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

154 files changed

+3332
-3518
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
.gradle
2+
/**/*.iml
23
/local.properties
34
.idea
45
.DS_Store
56
/build
6-
/captures
7-
/library/target
8-
/**/*.iml
97
google-services.json
10-
build/

.travis.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,27 @@ cache:
99
directories:
1010
- $HOME/.gradle/caches/
1111
- $HOME/.gradle/wrapper/
12+
- $HOME/.android/build-cache
1213
android:
1314
components:
14-
- platform-tools
1515
- tools
16-
- build-tools-25.0.1
16+
- build-tools-25.0.2
1717
- android-25
18-
19-
# Extras
20-
- extra-google-m2repository
18+
- platform-tools
2119
- extra-android-m2repository
22-
script: ./gradlew clean :library:testAll :library:prepareArtifacts
20+
- extra-google-m2repository
21+
before_script: mv library/google-services.json app/google-services.json
22+
script: ./gradlew clean assembleDebug check
23+
after_failure:
24+
# tests
25+
- cat app/build/reports/tests/testDebugUnitTest/index.html
26+
- cat auth/build/reports/tests/testDebugUnitTest/index.html
27+
- cat database/build/reports/tests/testDebugUnitTest/index.html
28+
- cat storage/build/reports/tests/testDebugUnitTest/index.html
29+
30+
# app
31+
- cat app/build/reports/checkstyle.html
32+
- cat app/build/reports/lint-results.xml
33+
- cat app/build/reports/lint-results.html
34+
- cat app/build/reports/findbugs.html
35+
- cat app/build/reports/pmd.html

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ Feature parity (where it makes sense) is a strict requirement for feature develo
3030
### Code reviews
3131

3232
All submissions, including submissions by project members, require review. We
33-
use Github pull requests for this purpose. We adhere to the
33+
use GitHub pull requests for this purpose. We adhere to the
3434
[Google Java style guide](https://google.github.io/styleguide/javaguide.html).
35+
In addition, style and lint checks are run on each Travis build to ensure quality. To run the full
36+
suite of tests, checks, lint, etc, use `./gradlew check` (this will ensure the Travis build passes).
3537

3638
### The small print
3739

PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Hey there! So you want to contribute to FirebaseUI? Before you file this pull request, follow these steps:
22

33
* Read [the contribution guidelines](CONTRIBUTING.md).
4+
* Run `./gradlew check` to ensure the Travis build passes.
45
* If this has been discussed in an issue, make sure to mention the issue number here. If not, go file an issue about this to make sure this is a desirable change.
56
* If this is a new feature please co-ordinate with someone on [FirebaseUI-iOS](https://github.com/firebase/firebaseui-ios) to make sure that we can implement this on both platforms and maintain feature parity.

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ libraries.
2828
```groovy
2929
dependencies {
3030
// FirebaseUI Database only
31-
compile 'com.firebaseui:firebase-ui-database:1.0.1'
31+
compile 'com.firebaseui:firebase-ui-database:1.1.0'
3232
3333
// FirebaseUI Auth only
34-
compile 'com.firebaseui:firebase-ui-auth:1.0.1'
34+
compile 'com.firebaseui:firebase-ui-auth:1.1.0'
3535
3636
// FirebaseUI Storage only
37-
compile 'com.firebaseui:firebase-ui-storage:1.0.1'
37+
compile 'com.firebaseui:firebase-ui-storage:1.1.0'
3838
3939
// Single target that includes all FirebaseUI libraries above
40-
compile 'com.firebaseui:firebase-ui:1.0.1'
40+
compile 'com.firebaseui:firebase-ui:1.1.0'
4141
}
4242
```
4343

@@ -67,6 +67,7 @@ For convenience, here are some examples:
6767

6868
| FirebaseUI Version | Firebase/Play Services Version |
6969
|--------------------|--------------------------------|
70+
| 1.1.0 | 10.0.0 or 10.0.1 |
7071
| 1.0.1 | 10.0.0 or 10.0.1 |
7172
| 1.0.0 | 9.8.0 |
7273
| 0.6.2 | 9.8.0 |

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'com.neenbedankt.android-apt'
3-
apply from: "../common/constants.gradle"
3+
apply from: "../constants.gradle"
4+
apply from: '../library/quality/quality.gradle'
45

56
android {
67
compileSdkVersion compileSdk
@@ -42,7 +43,6 @@ dependencies {
4243
// The following dependencies are not required to use the Firebase UI library.
4344
// They are used to make some aspects of the demo app implementation simpler for
4445
// demonstrative purposes, and you may find them useful in your own apps; YMMV.
45-
compile 'com.github.bumptech.glide:glide:3.7.0'
4646
compile 'pub.devrel:easypermissions:0.2.1'
4747
compile 'com.jakewharton:butterknife:8.4.0'
4848
apt 'com.jakewharton:butterknife-compiler:8.4.0'

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest
33
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
45
package="com.firebase.uidemo">
56

67
<uses-permission android:name="android.permission.INTERNET"/>
@@ -9,9 +10,12 @@
910
<application
1011
android:name=".auth.LeakCatcher"
1112
android:allowBackup="true"
13+
android:fullBackupContent="true"
1214
android:icon="@mipmap/ic_launcher"
1315
android:label="@string/app_name"
14-
android:theme="@style/AppTheme">
16+
android:theme="@style/AppTheme"
17+
android:supportsRtl="false"
18+
tools:ignore="GoogleAppIndexingWarning">
1519
<activity android:name=".ChooserActivity">
1620
<intent-filter>
1721
<action android:name="android.intent.action.MAIN"/>

app/src/main/java/com/firebase/uidemo/ChooserActivity.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,21 @@ public void onItemClick(int position) {
7777
public static class MyArrayAdapter extends ArrayAdapter<Class> {
7878

7979
private Context mContext;
80-
private Class[] mClasses;
8180

82-
public MyArrayAdapter(Context context, int resource, Class[] objects) {
81+
public MyArrayAdapter(Context context, int resource, Class... objects) {
8382
super(context, resource, objects);
84-
8583
mContext = context;
86-
mClasses = objects;
8784
}
8885

8986
@Override
9087
public View getView(int position, View convertView, ViewGroup parent) {
91-
View view = convertView;
88+
View view;
9289

9390
if (convertView == null) {
9491
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
9592
view = inflater.inflate(android.R.layout.simple_list_item_2, null);
93+
} else {
94+
view = convertView;
9695
}
9796

9897
((TextView) view.findViewById(android.R.id.text1)).setText(DESCRIPTION_NAMES[position]);

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

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333

3434
import com.firebase.ui.auth.AuthUI;
3535
import com.firebase.ui.auth.AuthUI.IdpConfig;
36+
import com.firebase.ui.auth.ErrorCodes;
3637
import com.firebase.ui.auth.IdpResponse;
37-
import com.firebase.ui.auth.ui.ResultCodes;
38+
import com.firebase.ui.auth.ResultCodes;
3839
import com.firebase.uidemo.R;
3940
import com.google.android.gms.common.Scopes;
4041
import com.google.firebase.auth.FirebaseAuth;
@@ -50,7 +51,7 @@
5051
public class AuthUiActivity extends AppCompatActivity {
5152
private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME";
5253
private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/";
53-
private static final String FIREBASE_TOS_URL = "https://www.firebase.com/terms/terms-of-service.html";
54+
private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/";
5455
private static final int RC_SIGN_IN = 100;
5556

5657
@BindView(R.id.default_theme)
@@ -86,7 +87,7 @@ public class AuthUiActivity extends AppCompatActivity {
8687
@BindView(R.id.sign_in)
8788
Button mSignIn;
8889

89-
@BindView(android.R.id.content)
90+
@BindView(R.id.root)
9091
View mRootView;
9192

9293
@BindView(R.id.firebase_logo)
@@ -199,20 +200,30 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
199200

200201
@MainThread
201202
private void handleSignInResponse(int resultCode, Intent data) {
202-
if (resultCode == RESULT_OK) {
203-
startActivity(SignedInActivity.createIntent(this, IdpResponse.fromResultIntent(data)));
204-
finish();
205-
return;
206-
}
207-
208-
if (resultCode == RESULT_CANCELED) {
209-
showSnackbar(R.string.sign_in_cancelled);
210-
return;
211-
}
203+
IdpResponse response = IdpResponse.fromResultIntent(data);
212204

213-
if (resultCode == ResultCodes.RESULT_NO_NETWORK) {
214-
showSnackbar(R.string.no_internet_connection);
205+
// Successfully signed in
206+
if (resultCode == ResultCodes.OK) {
207+
startActivity(SignedInActivity.createIntent(this, response));
208+
finish();
215209
return;
210+
} else {
211+
// Sign in failed
212+
if (response == null) {
213+
// User pressed back button
214+
showSnackbar(R.string.sign_in_cancelled);
215+
return;
216+
}
217+
218+
if (response.getErrorCode() == ErrorCodes.NO_NETWORK) {
219+
showSnackbar(R.string.no_internet_connection);
220+
return;
221+
}
222+
223+
if (response.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
224+
showSnackbar(R.string.unknown_error);
225+
return;
226+
}
216227
}
217228

218229
showSnackbar(R.string.unknown_sign_in_response);
@@ -269,6 +280,10 @@ private List<IdpConfig> getSelectedProviders() {
269280
selectedProviders.add(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build());
270281
}
271282

283+
if (mUseTwitterProvider.isChecked()) {
284+
selectedProviders.add(new IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build());
285+
}
286+
272287
if (mUseFacebookProvider.isChecked()) {
273288
selectedProviders.add(
274289
new IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER)
@@ -283,10 +298,6 @@ private List<IdpConfig> getSelectedProviders() {
283298
.build());
284299
}
285300

286-
if (mUseTwitterProvider.isChecked()) {
287-
selectedProviders.add(new IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build());
288-
}
289-
290301
return selectedProviders;
291302
}
292303

@@ -302,20 +313,20 @@ private String getSelectedTosUrl() {
302313
@MainThread
303314
private boolean isGoogleConfigured() {
304315
return !UNCHANGED_CONFIG_VALUE.equals(
305-
getResources().getString(R.string.default_web_client_id));
316+
getString(R.string.default_web_client_id));
306317
}
307318

308319
@MainThread
309320
private boolean isFacebookConfigured() {
310321
return !UNCHANGED_CONFIG_VALUE.equals(
311-
getResources().getString(R.string.facebook_application_id));
322+
getString(R.string.facebook_application_id));
312323
}
313324

314325
@MainThread
315326
private boolean isTwitterConfigured() {
316327
List<String> twitterConfigs = Arrays.asList(
317-
getResources().getString(R.string.twitter_consumer_key),
318-
getResources().getString(R.string.twitter_consumer_secret)
328+
getString(R.string.twitter_consumer_key),
329+
getString(R.string.twitter_consumer_secret)
319330
);
320331

321332
return !twitterConfigs.contains(UNCHANGED_CONFIG_VALUE);

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
import android.view.View;
2929
import android.widget.ImageView;
3030
import android.widget.TextView;
31-
import butterknife.BindView;
32-
import butterknife.ButterKnife;
33-
import butterknife.OnClick;
31+
3432
import com.bumptech.glide.Glide;
3533
import com.firebase.ui.auth.AuthUI;
3634
import com.firebase.ui.auth.IdpResponse;
@@ -42,11 +40,14 @@
4240
import com.google.firebase.auth.FirebaseAuth;
4341
import com.google.firebase.auth.FirebaseUser;
4442
import com.google.firebase.auth.GoogleAuthProvider;
43+
4544
import java.util.Iterator;
4645

47-
public class SignedInActivity extends AppCompatActivity {
48-
private static final String EXTRA_IDP_RESPONSE = "extra_idp_response";
46+
import butterknife.BindView;
47+
import butterknife.ButterKnife;
48+
import butterknife.OnClick;
4949

50+
public class SignedInActivity extends AppCompatActivity {
5051
@BindView(android.R.id.content)
5152
View mRootView;
5253

@@ -62,6 +63,8 @@ public class SignedInActivity extends AppCompatActivity {
6263
@BindView(R.id.user_enabled_providers)
6364
TextView mEnabledProviders;
6465

66+
private IdpResponse mIdpResponse;
67+
6568
@Override
6669
public void onCreate(Bundle savedInstanceState) {
6770
super.onCreate(savedInstanceState);
@@ -73,6 +76,8 @@ public void onCreate(Bundle savedInstanceState) {
7376
return;
7477
}
7578

79+
mIdpResponse = IdpResponse.fromResultIntent(getIntent());
80+
7681
setContentView(R.layout.signed_in_layout);
7782
ButterKnife.bind(this);
7883
populateProfile();
@@ -144,7 +149,7 @@ private void populateProfile() {
144149
mUserDisplayName.setText(
145150
TextUtils.isEmpty(user.getDisplayName()) ? "No display name" : user.getDisplayName());
146151

147-
StringBuilder providerList = new StringBuilder();
152+
StringBuilder providerList = new StringBuilder(100);
148153

149154
providerList.append("Providers used: ");
150155

@@ -174,20 +179,21 @@ private void populateProfile() {
174179
}
175180

176181
private void populateIdpToken() {
177-
IdpResponse idpResponse = getIntent().getParcelableExtra(EXTRA_IDP_RESPONSE);
178-
if (idpResponse != null) {
179-
String token = idpResponse.getIdpToken();
180-
String secret = idpResponse.getIdpSecret();
181-
if (token == null) {
182-
findViewById(R.id.idp_token_layout).setVisibility(View.GONE);
183-
} else {
184-
((TextView) findViewById(R.id.idp_token)).setText(token);
185-
}
186-
if (secret == null) {
187-
findViewById(R.id.idp_secret_layout).setVisibility(View.GONE);
188-
} else {
189-
((TextView) findViewById(R.id.idp_secret)).setText(secret);
190-
}
182+
String token = null;
183+
String secret = null;
184+
if (mIdpResponse != null) {
185+
token = mIdpResponse.getIdpToken();
186+
secret = mIdpResponse.getIdpSecret();
187+
}
188+
if (token == null) {
189+
findViewById(R.id.idp_token_layout).setVisibility(View.GONE);
190+
} else {
191+
((TextView) findViewById(R.id.idp_token)).setText(token);
192+
}
193+
if (secret == null) {
194+
findViewById(R.id.idp_secret_layout).setVisibility(View.GONE);
195+
} else {
196+
((TextView) findViewById(R.id.idp_secret)).setText(secret);
191197
}
192198
}
193199

@@ -198,9 +204,8 @@ private void showSnackbar(@StringRes int errorMessageRes) {
198204
}
199205

200206
public static Intent createIntent(Context context, IdpResponse idpResponse) {
201-
Intent in = new Intent();
207+
Intent in = IdpResponse.getIntent(idpResponse);
202208
in.setClass(context, SignedInActivity.class);
203-
in.putExtra(EXTRA_IDP_RESPONSE, idpResponse);
204209
return in;
205210
}
206211
}

0 commit comments

Comments
 (0)