1
0
Fork 0
fenix/app/src/main/java/org/mozilla/fenix/settings/account/AuthCustomTabActivity.kt

33 lines
1.2 KiB
Kotlin
Raw Normal View History

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.settings.account
import mozilla.components.concept.sync.AccountObserver
2019-09-04 22:56:22 +02:00
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
import org.mozilla.fenix.ext.components
2019-08-29 21:36:46 +02:00
/**
* A special custom tab for signing into a Firefox Account. The activity is closed once the user is signed in.
*/
2019-09-19 18:12:42 +02:00
class AuthCustomTabActivity : ExternalAppBrowserActivity() {
private val accountStateObserver = object : AccountObserver {
2019-08-29 21:36:46 +02:00
/**
* Navigate away from this activity when we have successful authentication
*/
2019-09-04 22:56:22 +02:00
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
2019-08-29 21:36:46 +02:00
finish()
}
}
override fun onResume() {
super.onResume()
2019-08-29 21:36:46 +02:00
val accountManager = components.backgroundServices.accountManager
accountManager.register(accountStateObserver, this, true)
}
}