Skip to content

Merge phone auth into version-2.0.0 #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Jun 8, 2017
Merged

Conversation

samtstern
Copy link
Contributor

As mentioned we've been working on phone auth internally. Now that the Play services 11.0.0 SDK is out we can move into the open.

This merges all of the phone auth changes into version-2.0.0-dev

ashwinraghav and others added 30 commits May 3, 2017 09:52
Change-Id: Ief6f138e79117a43aa789cc3e8ad5c9872a4e476
Change-Id: Ia3b861157127a1dee7e4625d9e786a6df45dea30
Change-Id: I989ee0354088a185d1373981532b52c9c0b0165e
1. Phone button background
2. Text changes

Change-Id: I6d1227a902f375367e6323e1ce4bdb472c12cd29
Change-Id: I18fc00185d7505408f448079563564618339a32c
Change-Id: I901c8d8132d93582f30ee1589080bb3f882fa452
Change-Id: Id2cbfdfc49e82da03f319c209799648bb9c3bfc5
Change-Id: I1d759c469567545158b5d51de847da1d6cff297f
Fix unhandled error cases

Change-Id: I39a5fb26297ebe1afd57a0687f709aee2dd529eb
Change-Id: I126347c68c0ce19604f0926f30fccb8c89532f5a
Change-Id: I6ba7ea8b8268d10cfea5db421db7a740bc20a8f7
Change-Id: I6b57fb46472367360cda4d1c4e88538f0495fa49
Change-Id: Icd1e115e51c37c1b599166422be6072fc0fd4f4c
Revert changes introduced in cred picker to support phone auth in commit a626685

Change-Id: I265be2d294218579d177c1d39b44fd6181f88767
Used the asset downloaded from:
https://icons.googleplex.com/#icon=ic_phone&search=phone

Used Android Studio to create the vector drawable, allowed RTL auto-mirroring and manually changed color from black to white.

Bug: 38454930
Change-Id: I7e55d7e95284c0e20ff3aa99d6727bddc3e795b6
Change-Id: Id5beeacdb014632b7c9438dc7d42066fc05d28f0
Change-Id: I1b07ed83741832730b4277dd65934cdf11d658db
Change-Id: I20b9ee9c24180f8de19f030371541922d0f10104
Change-Id: I9928978e188599c852f675453f59ce624bc9602d
Change-Id: I6d2bedb15d96f39e3d3e71682e33388fa41f3439
We upgrade to twitter kit 3.0 and achieve the following
1. No more fabric deps. This shaves our sdk down even more and clears related bugs.
2. We use only twitter core and not other deps. Shaves even more.
Total savings: 0.6 MB

Change-Id: I64ae5b6c7e2f238c35e25d6b2a2b7089431a3a0a
Change-Id: I57574ae9e376e3c576218b4e18e16ad914a6c496
Problem:
Apps are currently required to add the facebook and twitter dependency
even if they do not require these login methods to be supported.

Solution:
In this change, we assume a provided scope dependency on facebook and
twitter sdks and expect that the apps provide these dependencies.
If these dependencies  are not found, we fail early with an actionable
error.
Also, the size of the resulting apk reduces by about 2MB.

Change-Id: I5979039c281dd6daca265f60f9c9dcf59596ced1
samtstern added 2 commits June 5, 2017 08:25
Bug: 62309027
Change-Id: Iccbdb2a34e8c0b14c6fcf186005e0f1a68ea180e
Change-Id: Ib18e49c565e39c30bba83333aa8188fc853e1775
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@ashwinraghav
Copy link
Contributor

LGTM

@samtstern
Copy link
Contributor Author

Here is an enumeration of the changes at a high level (in no particular order):

  • Phone auth (obviously)
  • Smart Lock enable flag split into two pieces: one for the hint selector and one for actual credentials
  • Facebook and Twitter made provided dependencies. This means apps not using these providers don't need the dep.
  • Adding translation_description attributes to all library strings (preparing for internationalization)

Change-Id: I5ff1752f718b91602020147a91fe56691b09318f
@SUPERCILEX
Copy link
Collaborator

@samtstern Ouch! That's a lot of changes! 😕 Glad to finally see phone auth come out though!!! 😄

I have a few questions:

  1. The facebook and twitter things aren't particularly related to phone auth, right?
    Also, I disagree with making people add them to their own deps so I think we should definitely try to figure out testing compatibility to upgrade to the 3.0 plugin and use implementation. That should be what we use for basically all our deps except the Firebase ones. Dunno if you've looked into it yet, but implementation basically means "my module needs this dep so let people compile it even if they aren't including the dep, but don't let them use it e.g. they have to include the dep if they want to use it". That seems like a much better solution than breaking everyone's dependencies when they try to upgrade.
  2. I haven't looked at the PR, but does it also fix Consider allowing email hints even when smartlock disabled #558?

@SUPERCILEX
Copy link
Collaborator

PS: The failing test is because you guys aren't using Integer.parseInt() which does unnecessary boxing:

<a href="#DM_BOXED_PRIMITIVE_FOR_PARSING">Bug type DM_BOXED_PRIMITIVE_FOR_PARSING (click for details)</a>
<br/>In class com.firebase.ui.auth.ui.phone.CountryListSpinner<br/>In method com.firebase.ui.auth.ui.phone.CountryListSpinner.setSelectedForCountry(Locale, String)<br/>Called method Integer.intValue()<br/>Should call Integer.parseInt(String) instead<br/>At CountryListSpinner.java:[line 83]</p>

@samtstern
Copy link
Contributor Author

@SUPERCILEX there's a few huge benefits of doing twitter/facebook this way:

  • Shaves 2MB+ off of your app if you were not using those providers before by avoiding the depdendency
  • No more adding that pesky twitter maven repo

I agree we should use implementation down the road, but I think in the meantime this is a big improvement.

@SUPERCILEX
Copy link
Collaborator

@samtstern Ohhhh, wait so you don't have to include them if you aren't using Facebook/Twitter? Won't there be a ClassDefNotFound exception somewhere down the line?

Change-Id: I0b884bdbe5e62713dc3a4edca8539cace74f3f18
@samtstern
Copy link
Contributor Author

@SUPERCILEX we're using a trick to check for Facebook/Twitter SDK presence if you enable those providers (and at other entry points to the flow like signOut) and then throwing a RuntimeException before you can proceed saying "add the dependency"

@samtstern
Copy link
Contributor Author

Two remaining test failures:

  1. AuthMethodPickerActivityTest. testFacebookLoginFlow
java.lang.NoClassDefFoundError: com/facebook/R$style
	at com.facebook.FacebookSdk.<clinit>(FacebookSdk.java:87)
	at com.facebook.internal.Validate.sdkInitialized(Validate.java:144)
	at com.facebook.login.LoginManager.__constructor__(LoginManager.java:72)
	at com.facebook.login.LoginManager.<init>(LoginManager.java)
	at com.facebook.login.LoginManager.getInstance(LoginManager.java:83)
	at com.firebase.ui.auth.provider.FacebookProvider.startLogin(FacebookProvider.java:97)
	at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity$1.onClick(AuthMethodPickerActivity.java:127)
	at android.view.View.performClick(View.java:5639)
  1. AuthMethodPickerActivityTest. testGoogleLoginFlow
junit.framework.ComparisonFailure: expected:<[email protected]> but was:<null>
	at junit.framework.Assert.assertEquals(Assert.java:100)
	at junit.framework.Assert.assertEquals(Assert.java:107)
	at com.firebase.ui.auth.testhelpers.TestHelper.verifySmartLockSave(TestHelper.java:82)

LoginManager.getInstance().logOut();
try {
LoginManager.getInstance().logOut();
} catch (NoClassDefFoundError e) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SUPERCILEX we're using a trick to check for Facebook/Twitter SDK presence if you enable those providers (and at other entry points to the flow like signOut) and then throwing a RuntimeException before you can proceed saying "add the dependency"

Gotcha, just saw this. Now that I think about it, I'm definitely starting to really like the idea. For Instant apps, you could limit the providers to just Google and reap massive benefits. Snazzy! 😄

@samtstern
Copy link
Contributor Author

cc: @ashwinraghav two remaining test failures in the phone auth branch. I pushed commits to fix all the lint/checkstyle/findbugs errors.

Change-Id: If1686bde8906f2e06d87c51fb8399be0b960028d
@samtstern
Copy link
Contributor Author

@SUPERCILEX got all the tests to pass now but findbugs is erroring out. It only happens when I do a clean in the same command (./gradlew findbugs works ./gradlew clean assembleDebug check fails)

Copy link
Collaborator

@SUPERCILEX SUPERCILEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general comments, questions, and code quality improvements.


if (config.getProviderId().equals(FACEBOOK_PROVIDER)) {
try {
Class c = com.facebook.FacebookCallback.class;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why FacebookCallback? Wouldn't FacebookSdk make more sense since it's something Facebook will probably never get rid of?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good call.


if (config.getProviderId().equals(TWITTER_PROVIDER)) {
try {
Class c = com.twitter.sdk.android.core.TwitterCore.class;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, Twitter makes more sense than TwitterCore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're actually only depending on Twitter core now (which means we don't pull in Fabric). This is new with the upgrade to Twitter SDK 3.0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, awesome! Gotta love that smaller APK size! 😄

@@ -34,22 +34,25 @@
public class IdpResponse implements Parcelable {
private final String mProviderId;
private final String mEmail;
private final String mPhoneNumber;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, this isn't being used anywhere. 😆 There's no getter anywhere so we should just get rid of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are setting it in PhoneVerificationActivity so I'll add a getter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, K so we do want the dev to get the phone number from IdpResponse. Cool beans! 😄

}

@Override
public String getProviderId() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add @AuthUI.SupportedProvider?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added on email too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

}

@Override
public int getButtonLayout() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add @LayoutRes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -93,7 +93,6 @@ public void onConnected(Bundle bundle) {
finish();
return;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? nit: this space reduces cram so we should keep it.

@@ -21,6 +21,7 @@
import com.google.firebase.auth.FacebookAuthProvider;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.auth.PhoneAuthProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look necessary since there are no other changes in this class. Should there be some though? Wouldn't we want to update and use providerIdToAccountType somewhere?

@@ -16,6 +16,7 @@

import com.firebase.ui.auth.ui.ActivityHelper;
import com.firebase.ui.auth.util.signincontainer.SaveSmartLock;
import com.google.firebase.auth.PhoneAuthProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probs a refactor mistake, we don't need it.

@@ -18,6 +18,7 @@

public class TestConstants {
public static final String EMAIL = "[email protected]";
public static final String PHONE = "+14347565353";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, is this a real phone number? We should probably go with +15555555555 or something similar.

@@ -81,4 +83,26 @@ public static void verifySmartLockSave(String providerId, String email, String p
assertEquals(password, passwordCaptor.getValue());
assertEquals(providerId, idpResponseCaptor.getValue().getProviderType());
}

public static void verifySmartLockSave(String providerId, String email, String phoneNumber,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we fold this into the method above? I know this is a test, but still the method below is almost unreadable. We could just pass in null for the phoneNumber or have a simple overload that does that for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, will make this DRY

@SUPERCILEX
Copy link
Collaborator

@SUPERCILEX got all the tests to pass now but findbugs is erroring out. It only happens when I do a clean in the same command (./gradlew findbugs works but ./gradlew clean assembleDebug check fails)

@samtstern Looks like an issue with your machine 😄 (The Travis tests are passing)

Change-Id: I6eac4c2e92c13b1e5ad9a2953441566ad2d7c29e
@samtstern
Copy link
Contributor Author

@SUPERCILEX thank you for the thorough review! I believe I have addressed all feedback with the following TODO items (which can be handled later):

  • Use RecyclerView for the country list
  • Consider removing TermsTextView and just making a static method in PreambleHandler

@SUPERCILEX
Copy link
Collaborator

@samtstern Awesome, LGTM!

@samtstern samtstern merged commit 4137a21 into version-2.0.0-dev Jun 8, 2017
@samtstern samtstern deleted the phone-auth branch June 15, 2017 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants