-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Prep for final refactors #1188
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
Prep for final refactors #1188
Changes from all commits
a1c7dda
3325fda
fde1bca
6f0e2c9
624aa6e
3acea2d
dd9ae69
887ae0d
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.firebase.ui.auth.data.model; | ||
|
||
import android.content.Intent; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.RestrictTo; | ||
|
||
import com.firebase.ui.auth.ErrorCodes; | ||
import com.firebase.ui.auth.FirebaseUiException; | ||
|
||
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) | ||
public class IntentRequiredException extends FirebaseUiException { | ||
private final Intent mIntent; | ||
private final int mRequestCode; | ||
|
||
public IntentRequiredException(@NonNull Intent intent, int requestCode) { | ||
super(ErrorCodes.UNKNOWN_ERROR); | ||
mIntent = intent; | ||
mRequestCode = requestCode; | ||
} | ||
|
||
@NonNull | ||
public Intent getIntent() { | ||
return mIntent; | ||
} | ||
|
||
public int getRequestCode() { | ||
return mRequestCode; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.firebase.ui.auth.data.model; | ||
|
||
import android.app.PendingIntent; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.RestrictTo; | ||
|
||
import com.firebase.ui.auth.ErrorCodes; | ||
import com.firebase.ui.auth.FirebaseUiException; | ||
|
||
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) | ||
public class PendingIntentRequiredException extends FirebaseUiException { | ||
private final PendingIntent mPendingIntent; | ||
private final int mRequestCode; | ||
|
||
public PendingIntentRequiredException(@NonNull PendingIntent pendingIntent, int requestCode) { | ||
super(ErrorCodes.UNKNOWN_ERROR); | ||
mPendingIntent = pendingIntent; | ||
mRequestCode = requestCode; | ||
} | ||
|
||
@NonNull | ||
public PendingIntent getPendingIntent() { | ||
return mPendingIntent; | ||
} | ||
|
||
public int getRequestCode() { | ||
return mRequestCode; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.firebase.ui.auth.util.data; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.util.Log; | ||
|
||
import com.google.android.gms.tasks.OnFailureListener; | ||
|
||
public class TaskFailureLogger implements OnFailureListener { | ||
private String mTag; | ||
private String mMessage; | ||
|
||
public TaskFailureLogger(@NonNull String tag, @NonNull String message) { | ||
mTag = tag; | ||
mMessage = message; | ||
} | ||
|
||
@Override | ||
public void onFailure(@NonNull Exception e) { | ||
Log.w(mTag, mMessage, e); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.firebase.ui.auth.util.ui; | ||
|
||
import android.app.Activity; | ||
import android.app.PendingIntent; | ||
import android.content.IntentSender; | ||
import android.support.annotation.NonNull; | ||
|
||
import com.firebase.ui.auth.IdpResponse; | ||
import com.firebase.ui.auth.data.model.IntentRequiredException; | ||
import com.firebase.ui.auth.data.model.PendingIntentRequiredException; | ||
import com.firebase.ui.auth.ui.HelperActivityBase; | ||
|
||
public final class FlowUtils { | ||
private FlowUtils() { | ||
throw new AssertionError("No instance for you!"); | ||
} | ||
|
||
public static boolean handleError(@NonNull HelperActivityBase activity, @NonNull Exception 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. I am totally fine with this, but do you think it makes sense to just have all of our 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. I'd like to, but we already have code that sets the failure to |
||
if (e instanceof IntentRequiredException) { | ||
IntentRequiredException typed = (IntentRequiredException) e; | ||
activity.startActivityForResult(typed.getIntent(), typed.getRequestCode()); | ||
return true; | ||
} else if (e instanceof PendingIntentRequiredException) { | ||
PendingIntentRequiredException typed = (PendingIntentRequiredException) e; | ||
startIntentSenderForResult(activity, typed.getPendingIntent(), typed.getRequestCode()); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private static void startIntentSenderForResult(HelperActivityBase activity, | ||
PendingIntent intent, | ||
int requestCode) { | ||
try { | ||
activity.startIntentSenderForResult( | ||
intent.getIntentSender(), requestCode, null, 0, 0, 0); | ||
} catch (IntentSender.SendIntentException e) { | ||
activity.finish(Activity.RESULT_CANCELED, IdpResponse.getErrorIntent(e)); | ||
} | ||
} | ||
} |
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.
Are we sure there's no issue unconditionally calling both?
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.
Yeah, as long as we have different request codes (we do: 100 and 101). I felt like we'd get nipped in the behind later if
onActivityResult
was called non-deterministically. (Especially since fragments rely on that call.)