Add comments to AuthCustomTabActivity
parent
cea18f31c4
commit
fb907033bb
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue