-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add supported providers annotation #700
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
samtstern
merged 16 commits into
firebase:version-2.0.0-dev
from
SUPERCILEX:supported-providers-annotation
Jun 1, 2017
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b027f0f
Do a whole bunch of refactoring
SUPERCILEX 92f843e
Use Builder interface in AuthUI.java
SUPERCILEX 329ed2c
Add safety net in IdpResponse.Builder#build()
SUPERCILEX bd7933a
Fix refactor mistake
SUPERCILEX 2161c50
Also include GitHub in safety net
SUPERCILEX 8c033dc
Cleanup tests
SUPERCILEX cdd4586
Fix broken tests
SUPERCILEX 501cb6b
Fix more refactor mistakes
SUPERCILEX 95c6f49
Fix broken test
SUPERCILEX 0262dcb
Add SupportedProvider annotation
SUPERCILEX 309ad7c
Merge remote-tracking branch 'upstream/version-2.0.0-dev' into suppor…
SUPERCILEX 275e330
Merge remote-tracking branch 'upstream/version-2.0.0-dev' into suppor…
SUPERCILEX 283af41
Fix mistakes and undo some changes
SUPERCILEX 2e2ccac
Add the provider in other places
SUPERCILEX d25fe42
Merge remote-tracking branch 'upstream/version-2.0.0-dev' into suppor…
SUPERCILEX 19fed2d
Merge remote-tracking branch 'upstream/version-2.0.0-dev' into suppor…
SUPERCILEX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import android.util.Pair; | ||
import android.widget.Toast; | ||
|
||
import com.firebase.ui.auth.AuthUI; | ||
import com.firebase.ui.auth.ui.FragmentBase; | ||
import com.google.android.gms.auth.api.credentials.Credential; | ||
import com.google.android.gms.auth.api.credentials.IdentityProviders; | ||
|
@@ -42,7 +43,7 @@ public abstract class SmartLockBase<R extends Result> extends FragmentBase imple | |
* Translate a Firebase Auth provider ID (such as {@link GoogleAuthProvider#PROVIDER_ID}) to | ||
* a Credentials API account type (such as {@link IdentityProviders#GOOGLE}). | ||
*/ | ||
public static String providerIdToAccountType(@NonNull String providerId) { | ||
public static String providerIdToAccountType(@AuthUI.SupportedProvider @NonNull String providerId) { | ||
switch (providerId) { | ||
case GoogleAuthProvider.PROVIDER_ID: | ||
return IdentityProviders.GOOGLE; | ||
|
@@ -58,6 +59,7 @@ public static String providerIdToAccountType(@NonNull String providerId) { | |
} | ||
} | ||
|
||
@AuthUI.SupportedProvider | ||
public static String accountTypeToProviderId(@NonNull String accountType) { | ||
switch (accountType) { | ||
case IdentityProviders.GOOGLE: | ||
|
@@ -84,7 +86,7 @@ public static List<Credential> credentialsFromFirebaseUser(@NonNull FirebaseUser | |
List<Credential> credentials = new ArrayList<>(); | ||
for (UserInfo userInfo : user.getProviderData()) { | ||
// Get provider ID from Firebase Auth | ||
String providerId = userInfo.getProviderId(); | ||
@AuthUI.SupportedProvider String providerId = userInfo.getProviderId(); | ||
|
||
// Convert to Credentials API account type | ||
String accountType = providerIdToAccountType(providerId); | ||
|
@@ -132,10 +134,6 @@ public void onStop() { | |
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
cleanup(); | ||
} | ||
|
||
public void cleanup() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @samtstern What size level of changes do you want me to split into other PRs? I'm happy to move this to another PR. (it was just a small nit Intellij complained about) |
||
if (mGoogleApiClient != null) { | ||
mGoogleApiClient.disconnect(); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 we want this to be public? I feel like it could be useful, but it also means we have to maintain backwards compatibility...