Skip to content

Auth code cleanup #376

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 37 commits into from
Nov 18, 2016
Merged

Auth code cleanup #376

merged 37 commits into from
Nov 18, 2016

Conversation

SUPERCILEX
Copy link
Collaborator

For the removed todo, see http://stackoverflow.com/questions/2643949/can-i-use-a-static-variable-from-a-java-class-in-res-values-styles-xml.

I added RTL support, a wee bit of accessibility, and removed unused resources.

For other stuff, see the review below:

Copy link
Collaborator Author

@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.

Cleaner code! 😄

public static final int RC_SIGN_IN = 16;
public static final List<Integer> REQUEST_CODES = Arrays.asList(
private static final List<Integer> REQUEST_CODES = Arrays.asList(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was there a reason for keeping this stuff public?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope this LGTM, not meant to be part of the public API/

@@ -80,30 +80,22 @@ private void startEmailHandler(String email, List<String> providers) {
mActivityHelper.startActivityForResult(registerIntent, RC_REGISTER_ACCOUNT);
} else {
// account does exist
for (String provider : providers) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here's the most important change in this PR: the for loop doesn't loop! Is my change appropriate or should we be doing something else here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we be sure that if the email provider is in the providers collection that it will be at index 0? I agree the loop was not needed but not sure that get(0) will always be equivalent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

List<String> providers so isn't the first item in the for loop always going to be at index 0?

@@ -76,8 +78,7 @@ public CredentialRequest createCredentialRequest(List<IdpConfig> providers) {
@Override
protected void process(
final GoogleApiClient client,
final TaskCompletionSource<CredentialRequestResult> source)
throws Exception {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed all the throws exception here. Did they serve a purpose?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess not? @amandle see anything?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why these are throwing Exception, @iainmcgin might know


<!-- accessibility -->
<string name="accessibility_logo">App logo</string>
<string name="accessibility_toggle">Toggle password visibility</string>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are these descriptions adequate?

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The rest is all unused layouts and resources.

@SUPERCILEX
Copy link
Collaborator Author

Lint and Intellij are mostly happy now.

@SUPERCILEX SUPERCILEX changed the title Auh code cleanup Auth code cleanup Oct 23, 2016
@SUPERCILEX
Copy link
Collaborator Author

I also updated the travis file to make builds faster. We're now at around 3 minutes!

@SUPERCILEX
Copy link
Collaborator Author

@samtstern could you merge master into dev or should I just add it here since it only has 2 commits?

@samtstern
Copy link
Contributor

@SUPERCILEX merged master into 1.0.0-dev

@SUPERCILEX
Copy link
Collaborator Author

@samtstern Awesome, we're all green now!

public static final int RC_SIGN_IN = 16;
public static final List<Integer> REQUEST_CODES = Arrays.asList(
private static final List<Integer> REQUEST_CODES = Arrays.asList(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nope this LGTM, not meant to be part of the public API/

mActivityHelper.getApplicationContext(), SignInActivity.class);
signInIntent.putExtra(ExtraConstants.EXTRA_EMAIL, email);
mActivityHelper.startActivityForResult(signInIntent, RC_SIGN_IN);
Intent intent = WelcomeBackIdpPrompt.createIntent(
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be a behavior change from SignInActivity to WelcomeBackIDPPrompt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, the git diff just got really messed up. See the old vs the new:

image

@@ -80,30 +80,22 @@ private void startEmailHandler(String email, List<String> providers) {
mActivityHelper.startActivityForResult(registerIntent, RC_REGISTER_ACCOUNT);
} else {
// account does exist
for (String provider : providers) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we be sure that if the email provider is in the providers collection that it will be at index 0? I agree the loop was not needed but not sure that get(0) will always be equivalent.

@@ -76,8 +78,7 @@ public CredentialRequest createCredentialRequest(List<IdpConfig> providers) {
@Override
protected void process(
final GoogleApiClient client,
final TaskCompletionSource<CredentialRequestResult> source)
throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess not? @amandle see anything?


<!-- accessibility -->
<string name="accessibility_logo">App logo</string>
<string name="accessibility_toggle">Toggle password visibility</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

@@ -44,8 +41,6 @@ public FacebookProviderShadow() {
}
}

public void __constructor__(Activity activity, List<String> scopes) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure none of the tests are implicitly using this? Android Studio would not be able to tell if this was unused.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From what I've read (see Shadowing Constructors at the bottom of the page), this would be used to collect variables from the constructor, but it was empty. If you believe it serves a purpose, I will add it back.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually used to prevent the real constructor from being called. Should have left a comment, sorry.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@amandle Do you want me to add it back? Why aren't the tests failing then?

Copy link
Collaborator Author

@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.

Addressed your comments.

@@ -80,30 +80,22 @@ private void startEmailHandler(String email, List<String> providers) {
mActivityHelper.startActivityForResult(registerIntent, RC_REGISTER_ACCOUNT);
} else {
// account does exist
for (String provider : providers) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

List<String> providers so isn't the first item in the for loop always going to be at index 0?

mActivityHelper.getApplicationContext(), SignInActivity.class);
signInIntent.putExtra(ExtraConstants.EXTRA_EMAIL, email);
mActivityHelper.startActivityForResult(signInIntent, RC_SIGN_IN);
Intent intent = WelcomeBackIdpPrompt.createIntent(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, the git diff just got really messed up. See the old vs the new:

image

@@ -44,8 +41,6 @@ public FacebookProviderShadow() {
}
}

public void __constructor__(Activity activity, List<String> scopes) {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From what I've read (see Shadowing Constructors at the bottom of the page), this would be used to collect variables from the constructor, but it was empty. If you believe it serves a purpose, I will add it back.

Copy link
Collaborator Author

@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.

Updated dependencies and reorganized auth ones to follow a more conventional style: support/firebase -> third party -> test.

compile "com.android.support:design:${project.ext.support_library_version}"

compile "com.google.firebase:firebase-auth:${project.ext.firebase_version}"
compile "com.google.android.gms:play-services-auth:${project.ext.firebase_version}"

compile 'com.facebook.android:facebook-android-sdk:4.16.1'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

old: v4.14.1

compile "com.android.support:design:${project.ext.support_library_version}"

compile "com.google.firebase:firebase-auth:${project.ext.firebase_version}"
compile "com.google.android.gms:play-services-auth:${project.ext.firebase_version}"

compile 'com.facebook.android:facebook-android-sdk:4.16.1'
compile("com.twitter.sdk.android:twitter:2.1.1@aar") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

old: 2.0.0

}

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.2.6'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

old: 2.2.0

classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.fabric.tools:gradle:1.21.7'
classpath 'io.fabric.tools:gradle:1.+'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Twitter recommends using open ended versions: https://fabric.io/kits/android/twitterkit/install

The Fabric Gradle plugin uses an open ended version to react quickly to Android tooling updates

@@ -1,4 +1,4 @@
project.ext.firebase_version = '9.6.1'
project.ext.firebase_version = '9.8.00'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@samtstern (or any other firebase dev) Why the extra zero? It won't compile with just one zero.

Copy link
Collaborator Author

@SUPERCILEX SUPERCILEX Oct 25, 2016

Choose a reason for hiding this comment

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

@samtstern That's really weird. It won't compile on my machine without the extra zero and it won't compile with the extra zero on Travis. I'll have to try clearing the cache and such.

@SUPERCILEX
Copy link
Collaborator Author

I upgraded the EditTexts in android.support.design.widget.TextInputLayout to android.support.design.widget.TextInputEditText. See http://stackoverflow.com/questions/35775919/edittext-added-is-not-a-textinputedittext-please-switch-to-using-that-class-ins. Apparently, it makes things prettier in landscape mode.

I also made the xml style more consistent. (any objections to the style I chose?)

Removed duplicate code and cleaned stuff up.
@SUPERCILEX
Copy link
Collaborator Author

SUPERCILEX commented Oct 25, 2016

I did some final cleanup.

Sorry for making this a big PR in the end. However, I do think it really cleans things up nicely.

@SUPERCILEX
Copy link
Collaborator Author

@samtstern @amandle I added back the constructors for the tests and merged v1.0.0. We should be good to go now!

@amandle
Copy link
Contributor

amandle commented Oct 27, 2016

@SUPERCILEX cool, will take a look. Just a heads up, we're nearing 1.0 release and trying to stabilize things at the moment, so it may make sense to hold off on merging this for the time being.

@SUPERCILEX
Copy link
Collaborator Author

@amandle Awesome, can't wait for 1.0! We'll finally have official Twitter support and keeping track of changes between master and v1.0.0-dev will no longer be a thing.

For this PR, there shouldn't be an behavioral changes. Just code cleanup.

@SUPERCILEX SUPERCILEX changed the base branch from version-1.0.0-dev to master November 5, 2016 05:40
@samtstern
Copy link
Contributor

@SUPERCILEX just reviewed all of this again, it all LGTM. I believe merging your other CL caused a conflict but once that's fixed I will merge this as well.

Again sorry for the delay here, after 1.0 we had to go tend to other projects which we had neglected due to the 1.0 release 😄 there's never enough time to go around!

# Conflicts:
#	auth/build.gradle
#	auth/src/main/AndroidManifest.xml
#	auth/src/main/res/layout/auth_method_picker_layout.xml
@SUPERCILEX
Copy link
Collaborator Author

@samtstern Sounds busy! 🏗
Things should be ready to go now as I just finished merging.

@samtstern samtstern merged commit 42fa51c into firebase:master Nov 18, 2016
@samtstern
Copy link
Contributor

Squashed and merged! Thanks @SUPERCILEX

@SUPERCILEX SUPERCILEX deleted the cleanup branch November 18, 2016 18:00
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.

3 participants