-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Adds continue as guest #1375
Conversation
There was a problem hiding this 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() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) {} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this 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. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove line
There was a problem hiding this comment.
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"; | ||
} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆❤️
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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 />
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
library/quality/lint-baseline.xml
Outdated
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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. 😆
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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. 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samtstern thoughts?
There was a problem hiding this comment.
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.
@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! |
@samtstern Seems weird to me, but alrighty then! 👍 |
@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 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? |
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. |
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">
|
@austinhodak could you file a separate bug to track that issue? Thanks! |
See #900