This file contains 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
private fun initiateGoogleSignIn() { | |
val signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient) | |
startActivityForResult(signInIntent, RC_SIGN_IN) | |
} |
This file contains 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
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
when (requestCode) { | |
RC_SIGN_IN -> handleGoogleSignInResolution(resultCode, data) | |
} | |
} |
This file contains 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
private fun initGoogleApiClient() { | |
googleApiClient = GoogleApiClient.Builder(this) | |
.addConnectionCallbacks(this) | |
.enableAutoManage(this, this) | |
.addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions) | |
.addApi(Auth.CREDENTIALS_API) | |
.build() | |
} |
This file contains 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
private fun saveCredentials() { | |
val emailInvalid: Boolean = emailAddressTextInput.editText?.text.toString().trim().isNullOrEmpty() ?: false | |
val passwordInvalid: Boolean = passwordTextInput.editText?.text.toString().trim().isNullOrEmpty() ?: false | |
if (emailInvalid) { | |
emailRequirementError() | |
return | |
} |
This file contains 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
private fun requestCredentials() { | |
Auth | |
.CredentialsApi | |
.request(googleApiClient, smartlockCredentialsRequest) | |
.setResultCallback({ credentialRequestResult -> | |
handleCredentialRequestResult(credentialRequestResult) | |
}) | |
} |
This file contains 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
private fun initSmartlockCredentialsRequest() { | |
smartlockCredentialsRequest = CredentialRequest.Builder() | |
.setPasswordLoginSupported(true) | |
.build() | |
} |
This file contains 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
private fun initHintRequest() { | |
hintRequest = HintRequest.Builder() | |
.setHintPickerConfig( | |
CredentialPickerConfig.Builder() | |
.setShowCancelButton(true) | |
.setPrompt(CredentialPickerConfig.Prompt.SIGN_IN) | |
.build() | |
) | |
.setEmailAddressIdentifierSupported(true) | |
.build() |
This file contains 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
private fun requestEmailHints() { | |
val intent = Auth.CredentialsApi.getHintPickerIntent(googleApiClient, hintRequest) | |
try { | |
startIntentSenderForResult(intent.intentSender, RC_HINT_REQUEST, null, 0, 0, 0) | |
} catch (e: IntentSender.SendIntentException) { | |
emailHintRequestFailure() | |
} | |
} |
This file contains 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
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
when (requestCode) { | |
RC_HINT_REQUEST -> handleEmailHintRequestResolution(resultCode, data) | |
} | |
} |
This file contains 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
private fun handleEmailHintRequestResolution(resultCode: Int, data: Intent?) { | |
if (resultCode == AppCompatActivity.RESULT_CANCELED) { | |
emailHintRequestCancelled() | |
} else { | |
emailHintRequestSuccess(data) | |
} | |
} |