1
0
Fork 0

Fixes #992: Updates account implementation for a-c 47.0 (#995)

master
Sawyer Blatz 2019-03-13 09:23:55 -07:00 committed by GitHub
parent 7132229b16
commit 78c3db1fc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 8 deletions

View File

@ -28,5 +28,5 @@ class BackgroundServices(
private val scopes: Array<String> = arrayOf("profile", "https://identity.mozilla.com/apps/oldsync")
private val config = Config.release(CLIENT_ID, REDIRECT_URL)
val accountManager = FxaAccountManager(context, config, scopes).also { it.init() }
val accountManager = FxaAccountManager(context, config, scopes).also { it.initAsync() }
}

View File

@ -54,6 +54,9 @@ class ToolbarUIView(
hintColor = ContextCompat.getColor(context, R.color.search_text)
setOnEditListener(object : mozilla.components.concept.toolbar.Toolbar.OnEditListener {
override fun onCancelEditing(): Boolean {
return true
}
override fun onTextChanged(text: String) {
url = text
actionEmitter.onNext(SearchAction.TextChanged(text))

View File

@ -46,7 +46,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
private fun getClickListenerForSignOut(): Preference.OnPreferenceClickListener {
return Preference.OnPreferenceClickListener {
launch {
requireComponents.backgroundServices.accountManager.logout().await()
requireComponents.backgroundServices.accountManager.logoutAsync().await()
Navigation.findNavController(view!!).popBackStack()
}
true

View File

@ -21,12 +21,12 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.concept.sync.Profile
import kotlin.coroutines.CoroutineContext
import java.io.File
import mozilla.components.service.fxa.AccountObserver
import mozilla.components.service.fxa.FirefoxAccountShaped
import mozilla.components.service.fxa.FxaUnauthorizedException
import mozilla.components.service.fxa.Profile
import mozilla.components.support.ktx.android.graphics.toDataUri
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.FenixApplication
@ -246,8 +246,7 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
Navigation.findNavController(view!!).navigate(directions)
}
// --- AccountObserver interfaces ---
override fun onAuthenticated(account: FirefoxAccountShaped) {
override fun onAuthenticated(account: OAuthAccount) {
updateAuthState(account)
}
@ -267,7 +266,7 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
}
// --- Account UI helpers ---
private fun updateAuthState(account: FirefoxAccountShaped? = null) {
private fun updateAuthState(account: OAuthAccount? = null) {
val preferenceSignIn = findPreference<Preference>(context?.getPreferenceKey(pref_key_sign_in))
val preferenceFirefoxAccount = findPreference<Preference>(context?.getPreferenceKey(pref_key_account))
val accountPreferenceCategory =