1
0
Fork 0

Add comments to AuthCustomTabActivity

master
Tiger Oakes 2019-08-29 15:36:46 -04:00 committed by Jeff Boek
parent cea18f31c4
commit fb907033bb
1 changed files with 8 additions and 5 deletions

View File

@ -6,22 +6,25 @@ package org.mozilla.fenix.customtabs
import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.service.fxa.manager.FxaAccountManager
import org.mozilla.fenix.ext.components
/**
* A special custom tab for signing into a Firefox Account. The activity is closed once the user is signed in.
*/
class AuthCustomTabActivity : CustomTabActivity() {
private lateinit var accountManager: FxaAccountManager
// Navigate away from this activity when we have successful authentication
private val accountStateObserver = object : AccountObserver {
/**
* Navigate away from this activity when we have successful authentication
*/
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) {
this@AuthCustomTabActivity.finish()
finish()
}
}
override fun onResume() {
super.onResume()
accountManager = this.components.backgroundServices.accountManager
val accountManager = components.backgroundServices.accountManager
accountManager.register(accountStateObserver, this, true)
}
}