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) | |
} | |
} |
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 emailHintRequestSuccess(data: Intent?) { | |
val credential: Credential? = data?.getParcelableExtra(Credential.EXTRA_KEY) | |
credential?.let { | |
proceedOnMainScreen(it.id) | |
} | |
} |
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 handleCredentialRequestResult(credentialRequestResult: CredentialRequestResult) { | |
if (credentialRequestResult.status.isSuccess) { | |
proceedOnMainScreen(credentialRequestResult.credential.id) | |
} else { | |
resolveCredentialRequest(credentialRequestResult.status) | |
} | |
} |
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 resolveCredentialRequest(status: Status?) { | |
if (status?.statusCode == CommonStatusCodes.RESOLUTION_REQUIRED) { | |
initiateCredentialRequestResolution(status) | |
} else { | |
credentialRequestFailure() | |
} | |
} |
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 initiateCredentialRequestResolution(status: Status?) { | |
try { | |
status?.startResolutionForResult(this, RC_CREDENTIALS_REQUEST) | |
} catch (sendIntentException: IntentSender.SendIntentException) { | |
credentialRequestResolutionFailure() | |
} | |
} |
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 lateinit var signInButton: SignInButton | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_sign_in) | |
initViews() | |
} |