1
0
Fork 0

Part 4: Make sure 'sync is on' snackbar does not initialize account manager

master
Grisha Kruglov 2020-03-30 09:48:12 -07:00 committed by Grisha Kruglov
parent eb98df4edd
commit 029fae4559
1 changed files with 17 additions and 11 deletions

View File

@ -391,19 +391,25 @@ class HomeFragment : Fragment() {
)
)
requireComponents.backgroundServices.accountManager.register(currentMode, owner = this)
requireComponents.backgroundServices.accountManager.register(object : AccountObserver {
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
if (authType != AuthType.Existing) {
view?.let {
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT)
.setText(it.context.getString(R.string.onboarding_firefox_account_sync_is_on))
.setAnchorView(toolbarLayout)
.show()
requireComponents.backgroundServices.accountManagerAvailableQueue.runIfReadyOrQueue {
// By the time this code runs, we may not be attached to a context.
if ((this@HomeFragment).context == null) {
return@runIfReadyOrQueue
}
requireComponents.backgroundServices.accountManager.register(currentMode, owner = this@HomeFragment)
requireComponents.backgroundServices.accountManager.register(object : AccountObserver {
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
if (authType != AuthType.Existing) {
view?.let {
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT)
.setText(it.context.getString(R.string.onboarding_firefox_account_sync_is_on))
.setAnchorView(toolbarLayout)
.show()
}
}
}
}
}, owner = this)
}, owner = this@HomeFragment)
}
if (context.settings().showPrivateModeContextualFeatureRecommender &&
browsingModeManager.mode.isPrivate