-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix broken play services checks #462
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 12 commits into
firebase:version-1.1.0-dev
from
SUPERCILEX:api-availability
Dec 22, 2016
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a59b111
Fix play services check
SUPERCILEX 89add90
Fix rotation bugs
SUPERCILEX 2361932
Merge remote-tracking branch 'samtstern/email-refactor' into api-avai…
SUPERCILEX a57fdf3
Fix merge mistakes
SUPERCILEX a289a01
Fix more conflicts
SUPERCILEX 53a99f7
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into api-av…
SUPERCILEX 6bf3220
Finish with an IdpResponse
SUPERCILEX c056b0f
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into api-av…
SUPERCILEX e2b195d
Address review comments
SUPERCILEX 659bc5f
Cleanup
SUPERCILEX c05964e
Remove a truck load of unused code
SUPERCILEX ca699bb
Fix typo
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
69 changes: 62 additions & 7 deletions
69
auth/src/main/java/com/firebase/ui/auth/KickoffActivity.java
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 |
---|---|---|
@@ -1,41 +1,96 @@ | ||
package com.firebase.ui.auth; | ||
|
||
import android.content.Context; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.net.ConnectivityManager; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
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.PlayServicesHelper; | ||
import com.firebase.ui.auth.util.signincontainer.SignInDelegate; | ||
|
||
public class KickoffActivity extends AppCompatBase { | ||
private static final String TAG = "KickoffActivity"; | ||
private static final String IS_WAITING_FOR_PLAY_SERVICES = "is_waiting_for_play_services"; | ||
private static final int RC_PLAY_SERVICES = 1; | ||
|
||
private boolean mIsWaitingForPlayServices = false; | ||
|
||
public static Intent createIntent(Context context, FlowParameters flowParams) { | ||
return ActivityHelper.createBaseIntent(context, KickoffActivity.class, flowParams); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstance) { | ||
super.onCreate(savedInstance); | ||
if (savedInstance == null) { | ||
SignInDelegate.delegate(this, mActivityHelper.getFlowParams()); | ||
if (savedInstance == null || savedInstance.getBoolean(IS_WAITING_FOR_PLAY_SERVICES)) { | ||
if (isOffline()) { | ||
Log.d(TAG, "No network connection"); | ||
finish(ErrorCodes.NO_NETWORK, | ||
IdpResponse.getErrorCodeIntent(ErrorCodes.NO_NETWORK)); | ||
return; | ||
} | ||
|
||
boolean isPlayServicesAvailable = PlayServicesHelper.makePlayServicesAvailable( | ||
this, | ||
RC_PLAY_SERVICES, | ||
new DialogInterface.OnCancelListener() { | ||
@Override | ||
public void onCancel(DialogInterface dialog) { | ||
finish(ResultCodes.CANCELED, | ||
IdpResponse.getErrorCodeIntent( | ||
ErrorCodes.UNKNOWN_ERROR)); | ||
} | ||
}); | ||
|
||
if (isPlayServicesAvailable) { | ||
SignInDelegate.delegate(KickoffActivity.this, mActivityHelper.getFlowParams()); | ||
} else { | ||
mIsWaitingForPlayServices = true; | ||
} | ||
} | ||
} | ||
|
||
@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); | ||
outState.putBoolean(IS_WAITING_FOR_PLAY_SERVICES, mIsWaitingForPlayServices); | ||
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); | ||
if (requestCode == RC_PLAY_SERVICES) { | ||
if (resultCode == ResultCodes.OK) { | ||
SignInDelegate.delegate(KickoffActivity.this, mActivityHelper.getFlowParams()); | ||
} else { | ||
finish(ResultCodes.CANCELED, | ||
IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR)); | ||
} | ||
} else { | ||
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); | ||
/** | ||
* Check if there is an active or soon-to-be-active network connection. | ||
* | ||
* @return true if there is no network connection, false otherwise. | ||
*/ | ||
private boolean isOffline() { | ||
ConnectivityManager manager = | ||
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | ||
|
||
return !(manager != null | ||
&& manager.getActiveNetworkInfo() != null | ||
&& manager.getActiveNetworkInfo().isConnectedOrConnecting()); | ||
} | ||
} |
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
76 changes: 0 additions & 76 deletions
76
auth/src/main/java/com/firebase/ui/auth/util/FirebaseAuthWrapper.java
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
auth/src/main/java/com/firebase/ui/auth/util/FirebaseAuthWrapperFactory.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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 to move this to
PlayServicesHelper
or leave it here?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.
This can stay