|
|
@ -9,6 +9,7 @@ import android.content.Context
|
|
|
|
import android.content.Intent
|
|
|
|
import android.content.Intent
|
|
|
|
import android.net.Uri
|
|
|
|
import android.net.Uri
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.os.Bundle
|
|
|
|
|
|
|
|
import androidx.appcompat.content.res.AppCompatResources
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import androidx.navigation.NavDirections
|
|
|
|
import androidx.navigation.NavDirections
|
|
|
|
import androidx.navigation.findNavController
|
|
|
|
import androidx.navigation.findNavController
|
|
|
@ -17,7 +18,10 @@ import androidx.preference.Preference
|
|
|
|
import androidx.preference.Preference.OnPreferenceClickListener
|
|
|
|
import androidx.preference.Preference.OnPreferenceClickListener
|
|
|
|
import androidx.preference.PreferenceCategory
|
|
|
|
import androidx.preference.PreferenceCategory
|
|
|
|
import androidx.preference.PreferenceFragmentCompat
|
|
|
|
import androidx.preference.PreferenceFragmentCompat
|
|
|
|
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO
|
|
|
|
|
|
|
|
import kotlinx.coroutines.Dispatchers.Main
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
|
|
import kotlinx.coroutines.withContext
|
|
|
|
import mozilla.components.concept.sync.AccountObserver
|
|
|
|
import mozilla.components.concept.sync.AccountObserver
|
|
|
|
import mozilla.components.concept.sync.AuthType
|
|
|
|
import mozilla.components.concept.sync.AuthType
|
|
|
|
import mozilla.components.concept.sync.OAuthAccount
|
|
|
|
import mozilla.components.concept.sync.OAuthAccount
|
|
|
@ -30,6 +34,7 @@ import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
import org.mozilla.fenix.ext.application
|
|
|
|
import org.mozilla.fenix.ext.application
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
|
|
|
|
import org.mozilla.fenix.ext.decodeUrlToRoundedDrawable
|
|
|
|
import org.mozilla.fenix.ext.getPreferenceKey
|
|
|
|
import org.mozilla.fenix.ext.getPreferenceKey
|
|
|
|
import org.mozilla.fenix.ext.metrics
|
|
|
|
import org.mozilla.fenix.ext.metrics
|
|
|
|
import org.mozilla.fenix.ext.requireComponents
|
|
|
|
import org.mozilla.fenix.ext.requireComponents
|
|
|
@ -320,6 +325,19 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|
|
|
// Signed-in, no problems.
|
|
|
|
// Signed-in, no problems.
|
|
|
|
if (account != null && !accountManager.accountNeedsReauth()) {
|
|
|
|
if (account != null && !accountManager.accountNeedsReauth()) {
|
|
|
|
preferenceSignIn?.isVisible = false
|
|
|
|
preferenceSignIn?.isVisible = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
profile?.avatar?.url?.let {
|
|
|
|
|
|
|
|
lifecycleScope.launch(IO) {
|
|
|
|
|
|
|
|
val roundedDrawable = it.decodeUrlToRoundedDrawable(context)
|
|
|
|
|
|
|
|
withContext(Main) {
|
|
|
|
|
|
|
|
preferenceFirefoxAccount?.icon =
|
|
|
|
|
|
|
|
roundedDrawable ?: AppCompatResources.getDrawable(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
R.drawable.ic_account
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
preferenceSignIn?.onPreferenceClickListener = null
|
|
|
|
preferenceSignIn?.onPreferenceClickListener = null
|
|
|
|
preferenceFirefoxAccountAuthError?.isVisible = false
|
|
|
|
preferenceFirefoxAccountAuthError?.isVisible = false
|
|
|
|
preferenceFirefoxAccount?.isVisible = true
|
|
|
|
preferenceFirefoxAccount?.isVisible = true
|
|
|
|