Skip to content
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

Adds continue as guest #1375

Merged
merged 5 commits into from
Jun 29, 2018
Merged

Adds continue as guest #1375

merged 5 commits into from
Jun 29, 2018

Conversation

lsirac
Copy link
Contributor

@lsirac lsirac commented Jun 26, 2018

See #900

image

@lsirac lsirac requested a review from samtstern as a code owner June 26, 2018 21:54
@lsirac lsirac changed the title Adds continue as guest functionality Adds continue as guest Jun 26, 2018
@samtstern samtstern added this to the 4.2.0 milestone Jun 26, 2018
Copy link
Contributor

@samtstern samtstern left a comment

Choose a reason for hiding this comment

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

Mostly LGTM! Just a few comments.

.build();
}

private void showTopProgressBar() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should either rename this to setLoading() or just inline it at all call sites. The handlers should not have UI logic, it's up to the observer to decide how to display (or ignore) progress events. Top progress bar is our current favorite pattern but it was a dialog before that and could easily change again.

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.


}

public IdpResponse getResponse(boolean isNewUser) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used in more than one place? Could we just inline it? Also does it need to be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely should be private.

setResult(Resource.<IdpResponse>forLoading());
}

private FirebaseAuth getAuth() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can get this from AuthUI right? The other handlers don't duplicate this logic afaik.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other handlers extend from AuthViewModelBase. Added a todo for this.

}

@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: move this up with the other @Override methods.

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.

build.gradle.kts Outdated
@@ -101,7 +101,8 @@ fun Project.configureAndroid() {
"IconExpectedSize",
"InvalidPackage", // Firestore uses GRPC which makes lint mad
"NewerVersionAvailable", "GradleDependency", // For reproducible builds
"SelectableText", "SyntheticAccessor" // We almost never care about this
"SelectableText", "SyntheticAccessor", // We almost never care about this
"InvalidVectorPath" // false positive for fui_ic_anonymous_white_24dp
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we may just want to add a single exception for this to the lint baseline rather than ignoring all InvalidVectorPath errors since they could be serious in the future.

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.

@lsirac lsirac requested a review from SUPERCILEX June 26, 2018 23:38
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.

Looks good, mostly have some comments about the provider handler stuff.

PS: @samtstern why are we deciding to show UI? I still feel like devs should sign in anonymously on boot as opposed to letting users think they signed in and then lose all their data when they switch devices.

/**
* {@link IdpConfig} builder for the Anonymous provider.
*/

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: remove line

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.


public class AnonymousAuthProvider {
public static final String PROVIDER_ID = "anonymous";
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not quite sure I see why we need this... Can't we just use AnonymousAuthProvider.PROVIDER_ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where is this AnonymousAuthProvider that you speak of? 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

😆❤️

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh lol, you named it so well I thought you were joking. 😊 Anyway... since Firebase doesn't have a built-in AnonymousAuthProvider, shouldn't the FirebaseAuthProvider essentially be the same thing? @samtstern Am I mixing it up or is FirebaseAuthProvider intended to represent anon auth?

Copy link
Contributor

Choose a reason for hiding this comment

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

No idea, @lsirac might know better than I do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think FirebaseAuthProvider is intended to represent anon auth. Every signed in user has a "firebase" provider.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Gotya, then I think we should stick to a field in AuthUI directly. We used to have stuff like this:

-    /**
-     * Provider identifier for email and password credentials, for use with {@link
-     * SignInIntentBuilder#setAvailableProviders(List)}.
-     */
-    public static final String EMAIL_PROVIDER = EmailAuthProvider.PROVIDER_ID;

So we could do ANONYMOUS_PROVIDER. Also, does it need to be publicly accessible? I think we could mark it with @RestrictTo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we'd do AuthUI.ANONYMOUS_PROVIDER instead of AuthUI.AnonymousAuthProvider.PROVIDER_ID? and yeah we can mark it with @RestrictTo

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup! 😊

android:id="@+id/anonymous_button"
style="@style/FirebaseUI.Button.AccountChooser.AnonymousButton"
android:text="@string/fui_sign_in_anonymously">
</com.firebase.ui.auth.util.ui.SupportVectorDrawablesButton>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: unnecessary tag (could just be />)

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.

id="InvalidVectorPath"
message="Use 0.94 instead of .94 to avoid crashes on some devices">
<location file="src/main/res/drawable/fui_ic_anonymous_white_24dp.xml"></location>
</issue>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want this to be in our baseline since we're purposefully ignoring it. The baseline is meant to be a baseline (for lack of a better word 😆) that you're trying to slowly shrink over time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know how to purposefully ignore a warning like this? Can we add something in the vector XML itself?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, should be the same tools:ignore="InvalidVectorPath" we all know and love. 😆

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.

.build();
}

// TODO: Change ProviderSignInBase to extend from AuthViewModelBase
Copy link
Collaborator

Choose a reason for hiding this comment

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

ProviderSignInBase classes are meant to only retrieve remote provider data, hence making it difficult to get an auth instance as you've noticed. It was also supposed to be UI focused which is why there's a bunch of activity related stuff.

I feel like we should make this class be a bare bones middle man that sends an IdpResponse to an AnonymousProviderResponseHandler with the auth stuff. @samtstern What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

@SUPERCILEX in this version which class actually would call signInAnonymously?

Copy link
Collaborator

Choose a reason for hiding this comment

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

signInAnonymously would be called in the AnonymousProviderResponseHandler. And AnonymousSignInHandler would be something as simple as:

// ...

@Override
public void startSignIn(@NonNull HelperActivityBase activity) {
    setResult(Resource.<IdpResponse>forSuccess(new IdpResponse.Builder(
                new User.Builder(AuthUI.AnonymousAuthProvider.PROVIDER_ID, null).build())
                .build()));
}

Not sure if that's actually better though since having AnonymousSignInHandler becomes kinda pointless. I'm just not a huge fan of doing auth stuff in a non-auth view model. 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@samtstern thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we compromise and only have the ResponseHandler but call it immediately, rather than having the useless ViewModel. I agree we shouldn't do the signing in in the non-auth view model if we can avoid it.

@samtstern
Copy link
Contributor

@SUPERCILEX agree, but enough devs have asked for this (across all platforms) that we just decided to give them the option. Apparently some people like the UX of the "continue as guest" button. I am not one of those people but hey, free choice!

@SUPERCILEX
Copy link
Collaborator

@samtstern Seems weird to me, but alrighty then! 👍

@samtstern
Copy link
Contributor

@SUPERCILEX after talking to Leo, we think the right move is to stick with the original organization and have the anon sign-in code be part of the SignInHandler rather than a ResponseHandler.

I know this breaks your class hierarchy a bit, but I don't think adding a useless class is any better. If we just pretend that the Anonymous sign in is some IDP called "Anonymous, Incorporated" it's not hard to imagine why the Firebase Auth code belongs there.

Maybe we can find a future way to bring the two ViewModel class hierarchy trees closer together in the future?

@samtstern
Copy link
Contributor

Ok I am going to be out all of next week so I am going to merge this now as I think it LGTM. But not opposed to future discussion on the organization if we're not all on the same page.

@samtstern samtstern merged commit 2631d09 into version-4.2.0-dev Jun 29, 2018
@austinhodak
Copy link

Not sure if this is related to this pull. When using a dark theme for the FirebaseUI using .setTheme(), the shadow underneath the anon login is still white whereas the others are the correct dark theme.

` <style name="SignInTheme" parent="Theme.AppCompat">
@color/timelineBG
@color/timelineDark
@color/md_orange_500

    <item name="colorControlNormal">@color/md_orange_500</item>
    <item name="colorControlActivated">@color/md_orange_A700</item>
    <item name="colorControlHighlight">@color/md_orange_A200</item>
    <item name="android:windowBackground">@color/timelineBG</item>
</style>`

smartselect_20181009-122203_battle buddy

@samtstern
Copy link
Contributor

@austinhodak could you file a separate bug to track that issue? Thanks!

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.

4 participants