parent
7132229b16
commit
78c3db1fc8
|
@ -28,5 +28,5 @@ class BackgroundServices(
|
||||||
private val scopes: Array<String> = arrayOf("profile", "https://identity.mozilla.com/apps/oldsync")
|
private val scopes: Array<String> = arrayOf("profile", "https://identity.mozilla.com/apps/oldsync")
|
||||||
private val config = Config.release(CLIENT_ID, REDIRECT_URL)
|
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() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,9 @@ class ToolbarUIView(
|
||||||
hintColor = ContextCompat.getColor(context, R.color.search_text)
|
hintColor = ContextCompat.getColor(context, R.color.search_text)
|
||||||
|
|
||||||
setOnEditListener(object : mozilla.components.concept.toolbar.Toolbar.OnEditListener {
|
setOnEditListener(object : mozilla.components.concept.toolbar.Toolbar.OnEditListener {
|
||||||
|
override fun onCancelEditing(): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
override fun onTextChanged(text: String) {
|
override fun onTextChanged(text: String) {
|
||||||
url = text
|
url = text
|
||||||
actionEmitter.onNext(SearchAction.TextChanged(text))
|
actionEmitter.onNext(SearchAction.TextChanged(text))
|
||||||
|
|
|
@ -46,7 +46,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
|
||||||
private fun getClickListenerForSignOut(): Preference.OnPreferenceClickListener {
|
private fun getClickListenerForSignOut(): Preference.OnPreferenceClickListener {
|
||||||
return Preference.OnPreferenceClickListener {
|
return Preference.OnPreferenceClickListener {
|
||||||
launch {
|
launch {
|
||||||
requireComponents.backgroundServices.accountManager.logout().await()
|
requireComponents.backgroundServices.accountManager.logoutAsync().await()
|
||||||
Navigation.findNavController(view!!).popBackStack()
|
Navigation.findNavController(view!!).popBackStack()
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
|
|
@ -21,12 +21,12 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.launch
|
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 kotlin.coroutines.CoroutineContext
|
||||||
import java.io.File
|
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.FxaUnauthorizedException
|
||||||
import mozilla.components.service.fxa.Profile
|
|
||||||
import mozilla.components.support.ktx.android.graphics.toDataUri
|
import mozilla.components.support.ktx.android.graphics.toDataUri
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.BuildConfig
|
||||||
import org.mozilla.fenix.FenixApplication
|
import org.mozilla.fenix.FenixApplication
|
||||||
|
@ -246,8 +246,7 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
||||||
Navigation.findNavController(view!!).navigate(directions)
|
Navigation.findNavController(view!!).navigate(directions)
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- AccountObserver interfaces ---
|
override fun onAuthenticated(account: OAuthAccount) {
|
||||||
override fun onAuthenticated(account: FirefoxAccountShaped) {
|
|
||||||
updateAuthState(account)
|
updateAuthState(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +266,7 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Account UI helpers ---
|
// --- 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 preferenceSignIn = findPreference<Preference>(context?.getPreferenceKey(pref_key_sign_in))
|
||||||
val preferenceFirefoxAccount = findPreference<Preference>(context?.getPreferenceKey(pref_key_account))
|
val preferenceFirefoxAccount = findPreference<Preference>(context?.getPreferenceKey(pref_key_account))
|
||||||
val accountPreferenceCategory =
|
val accountPreferenceCategory =
|
||||||
|
|
Loading…
Reference in New Issue