-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Bugfixes for older versions of Android #382
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
import android.content.Intent; | ||
import android.content.IntentSender; | ||
import android.net.Uri; | ||
import android.os.Build.VERSION; | ||
import android.os.Build.VERSION_CODES; | ||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
|
@@ -36,6 +38,7 @@ | |
import com.google.android.gms.common.ConnectionResult; | ||
import com.google.android.gms.common.GoogleApiAvailability; | ||
import com.google.android.gms.common.api.GoogleApiClient; | ||
import com.google.android.gms.common.api.GoogleApiClient.Builder; | ||
import com.google.android.gms.common.api.ResultCallback; | ||
import com.google.android.gms.common.api.Status; | ||
import com.google.firebase.auth.FacebookAuthProvider; | ||
|
@@ -49,7 +52,7 @@ public class SmartLock extends Fragment | |
implements GoogleApiClient.ConnectionCallbacks, | ||
GoogleApiClient.OnConnectionFailedListener, | ||
ResultCallback<Status> { | ||
private static final String TAG = "CredentialsSaveBase"; | ||
private static final String TAG = "SmartLockFragment"; | ||
private static final int RC_SAVE = 100; | ||
private static final int RC_UPDATE_SERVICE = 28; | ||
|
||
|
@@ -252,12 +255,18 @@ public void saveCredentialsOrFinish(AppCompatBase activity, | |
return; | ||
} | ||
|
||
mCredentialsApiClient = new GoogleApiClient.Builder(activity) | ||
if (mActivity.isFinishing()) { | ||
finish(); | ||
return; | ||
} | ||
|
||
mCredentialsApiClient = new Builder(activity) | ||
.addConnectionCallbacks(this) | ||
.addOnConnectionFailedListener(this) | ||
.addApi(Auth.CREDENTIALS_API) | ||
.enableAutoManage(activity, this) | ||
.build(); | ||
mCredentialsApiClient.connect(); | ||
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. Nothing wrong with this but the fact that you had to do it is concerning. If you can reliably reproduce a situation where this is critical could you file a bug and tell the Gms client folks about it? 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. Sure, I'll see if I can isolate it. |
||
} | ||
|
||
public static SmartLock getInstance(AppCompatBase activity, String tag) { | ||
|
@@ -269,7 +278,11 @@ public static SmartLock getInstance(AppCompatBase activity, String tag) { | |
Fragment fragment = fm.findFragmentByTag(tag); | ||
if (fragment == null || !(fragment instanceof SmartLock)) { | ||
result = new SmartLock(); | ||
ft.add(result, tag).disallowAddToBackStack().commit(); | ||
try { | ||
ft.add(result, tag).disallowAddToBackStack().commit(); | ||
} catch (IllegalStateException e) { | ||
Log.e(TAG, "Can not add fragment", e); | ||
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. In this case should we return null or propagate the error somehow? 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. Changed this to return null, and updated the usage to check for null. |
||
} | ||
} else { | ||
result = (SmartLock) fragment; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
package com.firebase.ui.auth.test_helpers; | ||
|
||
import com.firebase.ui.auth.ui.ActivityHelper; | ||
import com.firebase.ui.auth.ui.AppCompatBase; | ||
import com.firebase.ui.auth.util.SmartLock; | ||
import com.google.android.gms.auth.api.credentials.CredentialsApi; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
|
||
|
@@ -26,6 +28,7 @@ | |
public class ActivityHelperShadow { | ||
public static FirebaseAuth firebaseAuth; | ||
public static CredentialsApi credentialsApi; | ||
public static SmartLock smartLock; | ||
|
||
public ActivityHelperShadow() { | ||
if (firebaseAuth == null) { | ||
|
@@ -34,6 +37,9 @@ public ActivityHelperShadow() { | |
if (credentialsApi == null) { | ||
credentialsApi = Mockito.mock(CredentialsApi.class); | ||
} | ||
if (smartLock == null) { | ||
smartLock = Mockito.mock(SmartLock.class); | ||
} | ||
} | ||
|
||
@Implementation | ||
|
@@ -45,4 +51,9 @@ public FirebaseAuth getFirebaseAuth() { | |
public CredentialsApi getCredentialsApi() { | ||
return credentialsApi; | ||
} | ||
|
||
@Implementation | ||
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. Ah I think I see why you implemented this method, is it just so you can shadow it easily? |
||
public SmartLock getSmartLockInstance(AppCompatBase activity, String tag) { | ||
return smartLock; | ||
} | ||
} |
This file was deleted.
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.
Does this method do anything besides pass through? Seems like we could just use the static method.
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.
It just passes through. As you noted below, this makes shadowing it possible.