forked from mozilla-mobile/fenix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For mozilla-mobile#3240 - Create AuthCustomTabActivity to fix dead en…
…d on auth
- Loading branch information
Showing
6 changed files
with
115 additions
and
41 deletions.
There are no files selected for viewing
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
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
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
37 changes: 37 additions & 0 deletions
37
app/src/main/java/org/mozilla/fenix/customtabs/AuthCustomTabActivity.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.mozilla.fenix.customtabs | ||
|
||
/* 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/. */ | ||
|
||
import mozilla.components.concept.sync.AccountObserver | ||
import mozilla.components.concept.sync.OAuthAccount | ||
import mozilla.components.concept.sync.Profile | ||
import mozilla.components.service.fxa.manager.FxaAccountManager | ||
import org.mozilla.fenix.ext.components | ||
|
||
class AuthCustomTabActivity : CustomTabActivity() { | ||
private lateinit var accountManager: FxaAccountManager | ||
|
||
// Navigate away from this activity when we have successful authentication | ||
private val accountStateObserver = object : AccountObserver { | ||
override fun onAuthenticated(account: OAuthAccount) { | ||
this@AuthCustomTabActivity.finish() | ||
} | ||
|
||
override fun onAuthenticationProblems() {} | ||
|
||
override fun onError(error: Exception) {} | ||
|
||
override fun onLoggedOut() {} | ||
|
||
override fun onProfileUpdated(profile: Profile) {} | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
accountManager = this.components.backgroundServices.accountManager | ||
accountManager.register(accountStateObserver, this, true) | ||
this.components.backgroundServices.accountManager.register(accountStateObserver, owner = this) | ||
} | ||
} |
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
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