|
3 | 3 | import android.app.Activity; |
4 | 4 | import android.content.Context; |
5 | 5 | import android.content.Intent; |
6 | | -import android.content.pm.ApplicationInfo; |
7 | | -import android.content.pm.PackageManager; |
8 | 6 | import android.os.Bundle; |
9 | 7 | import android.support.v4.app.FragmentActivity; |
10 | 8 | import android.util.Log; |
@@ -44,33 +42,7 @@ public GoogleAuthProvider(Context context, Firebase ref, TokenAuthHandler handle |
44 | 42 | mRef = ref; |
45 | 43 | mHandler = handler; |
46 | 44 |
|
47 | | - String googleClientId = ""; |
48 | | - |
49 | | - try { |
50 | | - ApplicationInfo ai = mActivity.getPackageManager().getApplicationInfo(mActivity.getPackageName(), PackageManager.GET_META_DATA); |
51 | | - Bundle bundle = ai.metaData; |
52 | | - googleClientId = bundle.getString("com.firebase.ui.GoogleClientId"); |
53 | | - } catch (PackageManager.NameNotFoundException e) { |
54 | | - } catch (NullPointerException e) {} |
55 | | - |
56 | | - if (googleClientId == null) { |
57 | | - FirebaseLoginError error = new FirebaseLoginError( |
58 | | - FirebaseResponse.MISSING_PROVIDER_APP_KEY, |
59 | | - "Missing Google client ID, is it set in your AndroidManifest.xml?"); |
60 | | - mHandler.onProviderError(error); |
61 | | - return; |
62 | | - } |
63 | | - |
64 | | - if (googleClientId.compareTo("") == 0) { |
65 | | - FirebaseLoginError error = new FirebaseLoginError( |
66 | | - FirebaseResponse.INVALID_PROVIDER_APP_KEY, |
67 | | - "Invalid Google client ID, is it set in your res/values/strings.xml?"); |
68 | | - mHandler.onProviderError(error); |
69 | | - return; |
70 | | - } |
71 | | - |
72 | 45 | GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) |
73 | | - .requestIdToken(googleClientId) |
74 | 46 | .requestEmail() |
75 | 47 | .build(); |
76 | 48 |
|
@@ -99,7 +71,9 @@ public void onConnected(Bundle bundle) { |
99 | 71 | } |
100 | 72 |
|
101 | 73 | @Override |
102 | | - public void onConnectionSuspended(int i) {} |
| 74 | + public void onConnectionSuspended(int i) { |
| 75 | + |
| 76 | + } |
103 | 77 |
|
104 | 78 | public void logout() { |
105 | 79 | if (mGoogleApiClient.isConnected()) { |
@@ -154,6 +128,9 @@ private void handleSignInResult(GoogleSignInResult result) { |
154 | 128 | googleOAuthTask.setHandler(this); |
155 | 129 | googleOAuthTask.execute(acct.getEmail()); |
156 | 130 | } |
| 131 | + else { |
| 132 | + mHandler.onProviderError(new FirebaseLoginError(FirebaseResponse.MISC_PROVIDER_ERROR, result.getStatus().toString())); |
| 133 | + } |
157 | 134 | } |
158 | 135 |
|
159 | 136 |
|
|
0 commit comments