Skip to content

Refactor chooseAccountActivity #357

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 114 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
05ce3b5
temporary: saving to work on another computer
SUPERCILEX Oct 7, 2016
2391efb
Merge remote-tracking branch 'firebase/master' into refactor-zombie-a…
SUPERCILEX Oct 8, 2016
05a476a
Merge remote-tracking branch 'firebase/master' into refactor-zombie-a…
SUPERCILEX Oct 14, 2016
2c0eaf5
Code compiles
SUPERCILEX Oct 14, 2016
8adeee1
Cleanup
SUPERCILEX Oct 14, 2016
11f3c2b
Cleanup
SUPERCILEX Oct 14, 2016
cb826f4
Cleanup
SUPERCILEX Oct 14, 2016
3b788f5
Update SmartLock.java with new fragment logic
SUPERCILEX Oct 14, 2016
9eaa4cd
Fix bug in SmartLock.java
SUPERCILEX Oct 14, 2016
3b76ac6
Cleanup
SUPERCILEX Oct 14, 2016
86d58a9
Cleanup
SUPERCILEX Oct 14, 2016
6ad0021
Fix broken tests
SUPERCILEX Oct 14, 2016
550acc9
Cleanup
SUPERCILEX Oct 14, 2016
b9d3ca5
Cleanup
SUPERCILEX Oct 15, 2016
a8b5cf5
Cleanup
SUPERCILEX Oct 15, 2016
83e13d8
Refactor SaveSmartLock.java
SUPERCILEX Oct 15, 2016
c529171
Initial refactor
SUPERCILEX Oct 16, 2016
5142dec
Cleanup
SUPERCILEX Oct 16, 2016
361d308
Cleanup
SUPERCILEX Oct 16, 2016
9a4921e
Bug fix
SUPERCILEX Oct 16, 2016
6af7674
Cleanup
SUPERCILEX Oct 16, 2016
35d94bb
Cleanup
SUPERCILEX Oct 16, 2016
64728b2
Cleanup and bug fixes
SUPERCILEX Oct 16, 2016
dde4160
Cleanup
SUPERCILEX Oct 16, 2016
2d5dfdc
Cleanup
SUPERCILEX Oct 16, 2016
f3bd0f1
Fix intellij messing up documentation.
SUPERCILEX Oct 16, 2016
f06845b
Cleanup
SUPERCILEX Oct 16, 2016
9782793
Cleanup
SUPERCILEX Oct 16, 2016
7d1d1c6
Remove unused strings
SUPERCILEX Oct 16, 2016
20413ee
Cleanup
SUPERCILEX Oct 16, 2016
7842c48
Refactor progress hiding and delegateSignIn()
SUPERCILEX Oct 16, 2016
135d2c5
Cleanup sample
SUPERCILEX Oct 16, 2016
23ae513
Fix null pointer for low memory devices
SUPERCILEX Oct 17, 2016
25eb137
Fix for #171
SUPERCILEX Oct 17, 2016
be7e0c3
Fix for #152
SUPERCILEX Oct 17, 2016
07beeb3
Force activity to implement onResult
SUPERCILEX Oct 17, 2016
13122c3
Fix smart lock failed flow
SUPERCILEX Oct 17, 2016
862b884
make it compile
SUPERCILEX Oct 17, 2016
a7b3336
Relaxed activity requirements to FragmentActivity
SUPERCILEX Oct 18, 2016
db96c91
Cleanup
SUPERCILEX Oct 18, 2016
19bde41
Add interface to SmartLock
SUPERCILEX Oct 18, 2016
96027d0
Merge remote-tracking branch 'firebase/version-1.0.0-dev' into refact…
SUPERCILEX Oct 18, 2016
9511a6d
Merge dev
SUPERCILEX Oct 18, 2016
cbe0cfb
working on tests
SUPERCILEX Oct 19, 2016
a81bf5a
working on tests
SUPERCILEX Oct 19, 2016
db05831
Revert interface, working on fixing tests
SUPERCILEX Oct 19, 2016
8c96216
Fix tests
SUPERCILEX Oct 19, 2016
d333302
Merge remote-tracking branch 'firebase/version-1.0.0-dev' into refact…
SUPERCILEX Oct 19, 2016
cb6efad
Merge dev
SUPERCILEX Oct 19, 2016
af644be
Fix merge mistakes
SUPERCILEX Oct 19, 2016
4152c23
Cleanup
SUPERCILEX Oct 19, 2016
2cc8adf
Final cleanup and fix tests
SUPERCILEX Oct 19, 2016
c138a51
Fix test
SUPERCILEX Oct 19, 2016
f88aab3
Fix test
SUPERCILEX Oct 19, 2016
ad115f0
Merge remote-tracking branch 'firebase/version-1.0.0-dev' into refact…
SUPERCILEX Oct 19, 2016
0a161d7
Merge remote-tracking branch 'origin/refactor-zombie-activities' into…
SUPERCILEX Oct 21, 2016
8813c8c
Fix merge mistakes
SUPERCILEX Oct 21, 2016
6f0f4da
Make git show ChooseAccountActivity renamed to SignInDelegate.java
SUPERCILEX Oct 21, 2016
099ef6d
Now shows rename
SUPERCILEX Oct 21, 2016
517f4ce
Working on fixing merge mistakes and preventing regressions
SUPERCILEX Oct 21, 2016
24ef137
Merge stuff from ChooseAccountActivity into SignInDelegate.java
SUPERCILEX Oct 21, 2016
9b568ec
Merge remote-tracking branch 'firebase/version-1.0.0-dev' into refact…
SUPERCILEX Oct 21, 2016
4a449d5
test
SUPERCILEX Oct 21, 2016
a6553d5
Remove references to enableAutoManage
SUPERCILEX Oct 22, 2016
00126d1
It compiles!
SUPERCILEX Oct 22, 2016
a9c895e
Rename public API to AuthUISignInResult and onSignInResult
SUPERCILEX Oct 22, 2016
8566118
Update public api
SUPERCILEX Oct 22, 2016
f5738b1
Cleanup
SUPERCILEX Oct 22, 2016
1fb5c08
Working on tests
SUPERCILEX Oct 22, 2016
1793dbd
working on tests
SUPERCILEX Oct 22, 2016
ca10f6c
Removed unnecessary tests
SUPERCILEX Oct 22, 2016
a0355b5
Fix bug in SaveSmartLock.java not connecting
SUPERCILEX Oct 22, 2016
e60bb5e
More refactoring!
SUPERCILEX Oct 22, 2016
7fcf057
It compiles!
SUPERCILEX Oct 22, 2016
121919a
Fix tests
SUPERCILEX Oct 22, 2016
a78480e
Fix nullPointerException
SUPERCILEX Oct 22, 2016
a94aedc
Simplify public api
SUPERCILEX Oct 22, 2016
cda7bfd
Bug fixes and prettification
SUPERCILEX Oct 22, 2016
83a0551
Fix null pointer
SUPERCILEX Oct 23, 2016
4613154
Really fix null pointer
SUPERCILEX Oct 23, 2016
058d4fe
Remove unnecessary dismiss dialog
SUPERCILEX Oct 23, 2016
c1418ef
Fix null pointer
SUPERCILEX Oct 23, 2016
6d0bf2f
Cleanup
SUPERCILEX Oct 23, 2016
4998691
Cleanup
SUPERCILEX Oct 23, 2016
e7627fa
Change public api
SUPERCILEX Nov 15, 2016
ee5810a
Merge remote-tracking branch 'firebase/master' into refactor-ChooseAc…
SUPERCILEX Nov 18, 2016
9bb8353
Cleanup
SUPERCILEX Nov 19, 2016
aff9984
Cleanup
SUPERCILEX Nov 19, 2016
a39eb0f
Add @LayoutRes
SUPERCILEX Nov 21, 2016
c5878d2
wrong branch
SUPERCILEX Nov 21, 2016
be88ece
Merge remote-tracking branch 'firebase/master' into refactor-ChooseAc…
SUPERCILEX Nov 21, 2016
8866f60
Fix merge mistakes
SUPERCILEX Nov 22, 2016
cc22d28
Address review comments
SUPERCILEX Nov 22, 2016
d0ef556
Initial cleanup
SUPERCILEX Nov 22, 2016
ea2434d
Fix accidental regressions from ChooseAccountActivity
SUPERCILEX Nov 22, 2016
c77ea5b
Another depressingly large refactor
SUPERCILEX Nov 22, 2016
d4278e7
Fix broken tests
SUPERCILEX Nov 22, 2016
e6ff3ef
Cleanup
SUPERCILEX Nov 22, 2016
3cbfed5
Fix crashes and bugs on low memory devices
SUPERCILEX Nov 22, 2016
3210e7e
Fix bug where google account sign in would be shown even if only emai…
SUPERCILEX Nov 22, 2016
eed92af
More massive reactors: using a gateway activity to not break public a…
SUPERCILEX Nov 23, 2016
80a4cb0
Fix bugs on low memory devices
SUPERCILEX Nov 23, 2016
e25e64e
Fix broken tests
SUPERCILEX Nov 23, 2016
42d695c
Final (I hope) cleanup
SUPERCILEX Nov 23, 2016
e8d5bbe
Nope, package cleanup
SUPERCILEX Nov 23, 2016
be698da
Add leakcanary and update dependencies
SUPERCILEX Nov 23, 2016
ac0a78e
Fix recovery dialog being dismissed on screen rotation
SUPERCILEX Nov 23, 2016
6cce271
Rename SmartLock to SmartLockBase.java
SUPERCILEX Nov 23, 2016
6870518
Fix typo
SUPERCILEX Nov 23, 2016
bb09653
Enable auto manage to help prevent memory leaks
SUPERCILEX Nov 23, 2016
151b8d3
Fix #348 and IllegalStateException in SaveSmartLock because of automa…
SUPERCILEX Nov 23, 2016
707f51a
Refactor GoogleApiClient auto manage constants
SUPERCILEX Nov 23, 2016
6b678e4
Remove unnecessary sign in options.
SUPERCILEX Nov 23, 2016
52d27a3
Fix possible null pointer
SUPERCILEX Nov 23, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ dependencies {
compile 'pub.devrel:easypermissions:0.2.1'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to keeping LeakCanary around

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Awesome!

releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
}

apply plugin: 'com.google.gms.google-services'
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
android:name=".auth.LeakCatcher"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
43 changes: 17 additions & 26 deletions app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;

import android.widget.TextView;

import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.AuthUI.IdpConfig;
import com.firebase.ui.auth.IdpResponse;
Expand All @@ -48,16 +48,9 @@
import butterknife.OnClick;

public class AuthUiActivity extends AppCompatActivity {

private static final String TAG = "AuthUIActivity";

private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME";

private static final String GOOGLE_TOS_URL =
"https://www.google.com/policies/terms/";
private static final String FIREBASE_TOS_URL =
"https://www.firebase.com/terms/terms-of-service.html";

private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/";
private static final String FIREBASE_TOS_URL = "https://www.firebase.com/terms/terms-of-service.html";
private static final int RC_SIGN_IN = 100;

@BindView(R.id.default_theme)
Expand Down Expand Up @@ -178,7 +171,6 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
if (!isGoogleConfigured() || !isFacebookConfigured() || !isTwitterConfigured()) {
showSnackbar(R.string.configuration_required);
}

}

@OnClick(R.id.sign_in)
Expand All @@ -205,21 +197,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
showSnackbar(R.string.unknown_response);
}


@MainThread
private void setGoogleScopesEnabled(boolean enabled) {
mGoogleScopesLabel.setEnabled(enabled);
mGoogleScopeDriveFile.setEnabled(enabled);
mGoogleScopeGames.setEnabled(enabled);
}

@MainThread
private void setFacebookScopesEnabled(boolean enabled) {
mFacebookScopesLabel.setEnabled(enabled);
mFacebookScopeFriends.setEnabled(enabled);
mFacebookScopePhotos.setEnabled(enabled);
}

@MainThread
private void handleSignInResponse(int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
Expand All @@ -241,6 +218,20 @@ private void handleSignInResponse(int resultCode, Intent data) {
showSnackbar(R.string.unknown_sign_in_response);
}

@MainThread
private void setGoogleScopesEnabled(boolean enabled) {
mGoogleScopesLabel.setEnabled(enabled);
mGoogleScopeDriveFile.setEnabled(enabled);
mGoogleScopeGames.setEnabled(enabled);
}

@MainThread
private void setFacebookScopesEnabled(boolean enabled) {
mFacebookScopesLabel.setEnabled(enabled);
mFacebookScopeFriends.setEnabled(enabled);
mFacebookScopePhotos.setEnabled(enabled);
}

@MainThread
@StyleRes
private int getSelectedTheme() {
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/com/firebase/uidemo/auth/LeakCatcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.firebase.uidemo.auth;

import android.app.Application;
import android.content.Context;

import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

public class LeakCatcher extends Application {
private RefWatcher mRefWatcher;

public static RefWatcher getRefWatcher(Context context) {
return ((LeakCatcher) context.getApplicationContext()).mRefWatcher;
}

@Override
public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
mRefWatcher = LeakCanary.install(this);
}
}
4 changes: 2 additions & 2 deletions auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
compile "com.google.android.gms:play-services-auth:$firebase_version"

compile 'com.facebook.android:facebook-android-sdk:4.17.0'
compile("com.twitter.sdk.android:twitter:2.1.1@aar") { transitive = true }
compile("com.twitter.sdk.android:twitter:2.2.0@aar") { transitive = true }

// The following libraries are needed to prevent incompatibilities with the facebook
// library when updating com.android.support libraries:
Expand All @@ -44,7 +44,7 @@ dependencies {


testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.2.20'
testCompile 'org.mockito:mockito-core:2.2.22'
testCompile 'org.robolectric:robolectric:3.1.2'
// See https://github.com/robolectric/robolectric/issues/1932#issuecomment-219796474
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
Expand Down
22 changes: 5 additions & 17 deletions auth/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
android:value="@string/twitter_consumer_secret"/>

<activity
android:name="com.firebase.ui.auth.ui.email.ConfirmRecoverPasswordActivity"
android:label="@string/title_confirm_recover_password_activity"
android:name=".KickoffActivity"
android:label="@string/default_toolbar_title"
android:exported="false"
android:theme="@style/FirebaseUI.Dialog"/>
android:theme="@style/Theme.AppCompat.NoActionBar"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this make the Activity visible? Any reason not to use the totally transparent theme from my gist? I'm sure an AppCompat-based one could be made as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Neither your solution nor mine works. Everything I tried had no effect; even the actionbar is still there. I think something is going on with the style not being applied properly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok we can address that separately, since having a kickoff activity is not a regression.


<activity
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See below, this was useless. (You guys were a bit too heavy on activities while writing this library! 😄)

android:name=".ui.email.EmailHintContainerActivity"
android:label="@string/default_toolbar_title"
android:exported="false"
android:theme="@style/FirebaseUI.Translucent"/>
android:theme="@style/Theme.AppCompat.NoActionBar"/>

<activity
android:name=".ui.email.RecoverPasswordActivity"
Expand Down Expand Up @@ -69,23 +69,11 @@
android:exported="false"
android:theme="@style/FirebaseUI"/>

<activity
android:name=".ui.idp.IdpSignInContainerActivity"
android:label="@string/default_toolbar_title"
android:exported="false"
android:theme="@style/FirebaseUI.Translucent"/>

<activity
android:name=".ui.ChooseAccountActivity"
android:label="@string/default_toolbar_title"
android:exported="false"
android:theme="@style/FirebaseUI.Translucent"/>

<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@style/FirebaseUI.Translucent"
android:theme="@style/Theme.AppCompat.NoActionBar"
tools:replace="android:theme"/>

<activity
Expand Down
41 changes: 18 additions & 23 deletions auth/src/main/java/com/firebase/ui/auth/AuthUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.firebase.ui.auth;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
Expand All @@ -27,13 +26,12 @@

import com.facebook.FacebookSdk;
import com.facebook.login.LoginManager;
import com.firebase.ui.auth.ui.ChooseAccountActivity;
import com.firebase.ui.auth.ui.FlowParameters;
import com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity;
import com.firebase.ui.auth.util.CredentialsApiHelper;
import com.firebase.ui.auth.util.GoogleApiClientTaskHelper;
import com.firebase.ui.auth.util.Preconditions;
import com.firebase.ui.auth.util.SmartLockUtil;
import com.firebase.ui.auth.util.signincontainer.SmartLockBase;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.credentials.Credential;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
Expand Down Expand Up @@ -346,7 +344,7 @@ public Task<Void> delete(@NonNull Activity activity) {
CredentialsApiHelper credentialHelper = CredentialsApiHelper.getInstance(gacHelper);

// Get all SmartLock credentials associated with the user
List<Credential> credentials = SmartLockUtil.credentialsFromFirebaseUser(firebaseUser);
List<Credential> credentials = SmartLockBase.credentialsFromFirebaseUser(firebaseUser);

// For each Credential in the list, create a task to delete it.
List<Task<?>> credentialTasks = new ArrayList<>();
Expand Down Expand Up @@ -571,7 +569,8 @@ public SignInIntentBuilder setProviders(@NonNull List<IdpConfig> idpConfigs) {
for (IdpConfig idpConfig : idpConfigs) {
if (configuredProviders.contains(idpConfig.getProviderId())) {
throw new IllegalArgumentException("Each provider can only be set once. "
+ idpConfig.getProviderId() + " was set twice.");
+ idpConfig.getProviderId()
+ " was set twice.");
}
configuredProviders.add(idpConfig.getProviderId());
mProviders.add(idpConfig);
Expand Down Expand Up @@ -613,24 +612,6 @@ public SignInIntentBuilder setIsSmartLockEnabled(boolean enabled) {
return this;
}

public Intent build() {
Context context = mApp.getApplicationContext();
return build(context);
}

@VisibleForTesting
public Intent build(Context context) {
return ChooseAccountActivity.createIntent(
context,
new FlowParameters(
mApp.getName(),
new ArrayList<>(mProviders),
mTheme,
mLogo,
mTosUrl,
mIsSmartLockEnabled));
}

private boolean isIdpAlreadyConfigured(@NonNull String providerId) {
for (IdpConfig config : mProviders) {
if (config.getProviderId().equals(providerId)) {
Expand All @@ -639,5 +620,19 @@ private boolean isIdpAlreadyConfigured(@NonNull String providerId) {
}
return false;
}

public Intent build() {
return KickoffActivity.createIntent(mApp.getApplicationContext(), getFlowParams());
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public FlowParameters getFlowParams() {
return new FlowParameters(mApp.getName(),
new ArrayList<>(mProviders),
mTheme,
mLogo,
mTosUrl,
mIsSmartLockEnabled);
}
}
}
41 changes: 41 additions & 0 deletions auth/src/main/java/com/firebase/ui/auth/KickoffActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.firebase.ui.auth;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.firebase.ui.auth.ui.ActivityHelper;
import com.firebase.ui.auth.ui.AppCompatBase;
import com.firebase.ui.auth.ui.ExtraConstants;
import com.firebase.ui.auth.ui.FlowParameters;
import com.firebase.ui.auth.util.signincontainer.SignInDelegate;

public class KickoffActivity extends AppCompatBase {
@Override
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
if (savedInstance == null) {
SignInDelegate.delegate(this, mActivityHelper.getFlowParams());
}
}

@Override
public void onSaveInstanceState(Bundle outState) {
// It doesn't matter what we put here, we just don't want outState to be empty
outState.putBoolean(ExtraConstants.HAS_EXISTING_INSTANCE, true);
super.onSaveInstanceState(outState);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
SignInDelegate delegate = SignInDelegate.getInstance(this);
if (delegate != null) {
delegate.onActivityResult(requestCode, resultCode, data);
}
}

public static Intent createIntent(Context context, FlowParameters flowParams) {
return ActivityHelper.createBaseIntent(context, KickoffActivity.class, flowParams);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
* limitations under the License.
*/

package com.firebase.ui.auth.ui;
package com.firebase.ui.auth.provider;

import android.support.annotation.Nullable;

import com.firebase.ui.auth.provider.FacebookProvider;
import com.firebase.ui.auth.provider.GoogleProvider;
import com.firebase.ui.auth.IdpResponse;
import com.firebase.ui.auth.provider.TwitterProvider;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.FacebookAuthProvider;
import com.google.firebase.auth.GoogleAuthProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.firebase.ui.auth.AuthUI.IdpConfig;
import com.firebase.ui.auth.IdpResponse;
import com.firebase.ui.auth.R;
import com.firebase.ui.auth.util.GoogleApiConstants;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
Expand All @@ -43,7 +44,6 @@ public class GoogleProvider implements
IdpProvider, OnClickListener, GoogleApiClient.OnConnectionFailedListener {

private static final String TAG = "GoogleProvider";
private static final int AUTO_MANAGE_ID = 1;
private static final int RC_SIGN_IN = 20;
private static final String ERROR_KEY = "error";
private GoogleApiClient mGoogleApiClient;
Expand All @@ -56,12 +56,12 @@ public GoogleProvider(FragmentActivity activity, IdpConfig idpConfig) {

public GoogleProvider(FragmentActivity activity, IdpConfig idpConfig, @Nullable String email) {
mActivity = activity;
String mClientId = activity.getString(R.string.default_web_client_id);
String clientId = activity.getString(R.string.default_web_client_id);

GoogleSignInOptions.Builder builder =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(mClientId);
.requestIdToken(clientId);

if (activity.getResources().getIdentifier(
"google_permissions", "array", activity.getPackageName()) != 0) {
Expand All @@ -80,7 +80,7 @@ public GoogleProvider(FragmentActivity activity, IdpConfig idpConfig, @Nullable
}

mGoogleApiClient = new GoogleApiClient.Builder(activity)
.enableAutoManage(activity, AUTO_MANAGE_ID, this)
.enableAutoManage(activity, GoogleApiConstants.AUTO_MANAGE_ID0, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, builder.build())
.build();
}
Expand Down
Loading