No issue: update Androidx dependencies
parent
2b00d1120f
commit
4f6cc8efec
|
@ -44,22 +44,24 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
|
|||
setPreferencesFromResource(R.xml.account_settings_preferences, rootKey)
|
||||
|
||||
// Sign out
|
||||
val signOut = context?.getPreferenceKey(R.string.pref_key_sign_out)
|
||||
val signOut = context!!.getPreferenceKey(R.string.pref_key_sign_out)
|
||||
val preferenceSignOut = findPreference<Preference>(signOut)
|
||||
preferenceSignOut.onPreferenceClickListener = getClickListenerForSignOut()
|
||||
preferenceSignOut?.onPreferenceClickListener = getClickListenerForSignOut()
|
||||
|
||||
// Sync now
|
||||
val syncNow = context?.getPreferenceKey(R.string.pref_key_sync_now)
|
||||
val syncNow = context!!.getPreferenceKey(R.string.pref_key_sync_now)
|
||||
val preferenceSyncNow = findPreference<Preference>(syncNow)
|
||||
preferenceSyncNow.onPreferenceClickListener = getClickListenerForSyncNow()
|
||||
preferenceSyncNow?.let {
|
||||
preferenceSyncNow.onPreferenceClickListener = getClickListenerForSyncNow()
|
||||
|
||||
// Current sync state
|
||||
updateLastSyncedTimePref(context!!, preferenceSyncNow)
|
||||
if (requireComponents.backgroundServices.syncManager.isSyncRunning()) {
|
||||
preferenceSyncNow.title = getString(R.string.sync_syncing)
|
||||
preferenceSyncNow.isEnabled = false
|
||||
} else {
|
||||
preferenceSyncNow.isEnabled = true
|
||||
// Current sync state
|
||||
updateLastSyncedTimePref(context!!, preferenceSyncNow)
|
||||
if (requireComponents.backgroundServices.syncManager.isSyncRunning()) {
|
||||
preferenceSyncNow.title = getString(R.string.sync_syncing)
|
||||
preferenceSyncNow.isEnabled = false
|
||||
} else {
|
||||
preferenceSyncNow.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
// NB: ObserverRegistry will take care of cleaning up internal references to 'observer' and
|
||||
|
@ -87,30 +89,34 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
|
|||
private val syncStatusObserver = object : SyncStatusObserver {
|
||||
override fun onStarted() {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
val pref = findPreference<Preference>(context?.getPreferenceKey(R.string.pref_key_sync_now))
|
||||
val pref = findPreference<Preference>(context!!.getPreferenceKey(R.string.pref_key_sync_now))
|
||||
|
||||
pref.title = getString(R.string.sync_syncing)
|
||||
pref.isEnabled = false
|
||||
pref?.title = getString(R.string.sync_syncing)
|
||||
pref?.isEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
// Sync stopped successfully.
|
||||
override fun onIdle() {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
val pref = findPreference<Preference>(context?.getPreferenceKey(R.string.pref_key_sync_now))
|
||||
pref.title = getString(R.string.preferences_sync_now)
|
||||
pref.isEnabled = true
|
||||
updateLastSyncedTimePref(context!!, pref, failed = false)
|
||||
val pref = findPreference<Preference>(context!!.getPreferenceKey(R.string.pref_key_sync_now))
|
||||
pref?.let {
|
||||
pref.title = getString(R.string.preferences_sync_now)
|
||||
pref.isEnabled = true
|
||||
updateLastSyncedTimePref(context!!, pref, failed = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sync stopped after encountering a problem.
|
||||
override fun onError(error: Exception?) {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
val pref = findPreference<Preference>(context?.getPreferenceKey(R.string.pref_key_sync_now))
|
||||
pref.title = getString(R.string.preferences_sync_now)
|
||||
pref.isEnabled = true
|
||||
updateLastSyncedTimePref(context!!, pref, failed = true)
|
||||
val pref = findPreference<Preference>(context!!.getPreferenceKey(R.string.pref_key_sync_now))
|
||||
pref?.let {
|
||||
pref.title = getString(R.string.preferences_sync_now)
|
||||
pref.isEnabled = true
|
||||
updateLastSyncedTimePref(context!!, pref, failed = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class DataChoicesFragment : PreferenceFragmentCompat() {
|
|||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.data_choices_preferences, rootKey)
|
||||
|
||||
findPreference<SwitchPreference>(getString(R.string.pref_key_telemetry)).apply {
|
||||
findPreference<SwitchPreference>(getString(R.string.pref_key_telemetry))?.apply {
|
||||
isChecked = Settings.getInstance(context).isTelemetryEnabled
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,9 +70,9 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
|||
|
||||
(activity as AppCompatActivity).supportActionBar?.show()
|
||||
val preference =
|
||||
findPreference(getString(R.string.pref_key_make_default_browser)) as DefaultBrowserPreference
|
||||
findPreference<DefaultBrowserPreference>(getString(R.string.pref_key_make_default_browser))
|
||||
|
||||
preference.updateSwitch()
|
||||
preference?.updateSwitch()
|
||||
generateWordmark()
|
||||
setupPreferences()
|
||||
setupAccountUI()
|
||||
|
@ -176,18 +176,18 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
|||
}
|
||||
|
||||
private fun setupPreferences() {
|
||||
val makeDefaultBrowserKey = context?.getPreferenceKey(pref_key_make_default_browser)
|
||||
val leakKey = context?.getPreferenceKey(pref_key_leakcanary)
|
||||
val makeDefaultBrowserKey = context!!.getPreferenceKey(pref_key_make_default_browser)
|
||||
val leakKey = context!!.getPreferenceKey(pref_key_leakcanary)
|
||||
|
||||
val preferenceMakeDefaultBrowser = findPreference<Preference>(makeDefaultBrowserKey)
|
||||
val preferenceLeakCanary = findPreference<Preference>(leakKey)
|
||||
|
||||
preferenceMakeDefaultBrowser.onPreferenceClickListener =
|
||||
preferenceMakeDefaultBrowser?.onPreferenceClickListener =
|
||||
getClickListenerForMakeDefaultBrowser()
|
||||
|
||||
preferenceLeakCanary.isVisible = BuildConfig.DEBUG
|
||||
preferenceLeakCanary?.isVisible = BuildConfig.DEBUG
|
||||
if (BuildConfig.DEBUG) {
|
||||
preferenceLeakCanary.onPreferenceChangeListener =
|
||||
preferenceLeakCanary?.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
(context?.applicationContext as FenixApplication).toggleLeakCanary(newValue as Boolean)
|
||||
true
|
||||
|
@ -220,7 +220,8 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
|||
}
|
||||
|
||||
private fun navigateToSitePermissions() {
|
||||
val directions = SettingsFragmentDirections.actionSettingsFragmentToSitePermissionsFragment()
|
||||
val directions =
|
||||
SettingsFragmentDirections.actionSettingsFragmentToSitePermissionsFragment()
|
||||
Navigation.findNavController(view!!).navigate(directions)
|
||||
}
|
||||
|
||||
|
@ -242,7 +243,8 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
|||
}
|
||||
|
||||
private fun navigateToAccountSettings() {
|
||||
val directions = SettingsFragmentDirections.actionSettingsFragmentToAccountSettingsFragment()
|
||||
val directions =
|
||||
SettingsFragmentDirections.actionSettingsFragmentToAccountSettingsFragment()
|
||||
Navigation.findNavController(view!!).navigate(directions)
|
||||
}
|
||||
|
||||
|
@ -267,29 +269,32 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
|||
|
||||
// --- Account UI helpers ---
|
||||
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 preferenceSignIn =
|
||||
findPreference<Preference>(context!!.getPreferenceKey(pref_key_sign_in))
|
||||
val preferenceFirefoxAccount =
|
||||
findPreference<Preference>(context!!.getPreferenceKey(pref_key_account))
|
||||
val accountPreferenceCategory =
|
||||
findPreference<PreferenceCategory>(context?.getPreferenceKey(pref_key_account_category))
|
||||
findPreference<PreferenceCategory>(context!!.getPreferenceKey(pref_key_account_category))
|
||||
|
||||
if (account != null) {
|
||||
preferenceSignIn.isVisible = false
|
||||
preferenceSignIn.onPreferenceClickListener = null
|
||||
preferenceFirefoxAccount.isVisible = true
|
||||
accountPreferenceCategory.isVisible = true
|
||||
preferenceSignIn?.isVisible = false
|
||||
preferenceSignIn?.onPreferenceClickListener = null
|
||||
preferenceFirefoxAccount?.isVisible = true
|
||||
accountPreferenceCategory?.isVisible = true
|
||||
} else {
|
||||
preferenceSignIn.isVisible = true
|
||||
preferenceSignIn.onPreferenceClickListener = getClickListenerForSignIn()
|
||||
preferenceFirefoxAccount.isVisible = false
|
||||
accountPreferenceCategory.isVisible = false
|
||||
preferenceSignIn?.isVisible = true
|
||||
preferenceSignIn?.onPreferenceClickListener = getClickListenerForSignIn()
|
||||
preferenceFirefoxAccount?.isVisible = false
|
||||
accountPreferenceCategory?.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAccountProfile(profile: Profile) {
|
||||
launch {
|
||||
val preferenceFirefoxAccount = findPreference<Preference>(context?.getPreferenceKey(pref_key_account))
|
||||
preferenceFirefoxAccount.title = profile.displayName.orEmpty()
|
||||
preferenceFirefoxAccount.summary = profile.email.orEmpty()
|
||||
val preferenceFirefoxAccount =
|
||||
findPreference<Preference>(context!!.getPreferenceKey(pref_key_account))
|
||||
preferenceFirefoxAccount?.title = profile.displayName.orEmpty()
|
||||
preferenceFirefoxAccount?.summary = profile.email.orEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,13 +13,13 @@ private object Versions {
|
|||
const val leakcanary = "1.6.3"
|
||||
const val leanplum = "4.3.1"
|
||||
|
||||
const val androidx_appcompat = "1.1.0-alpha02"
|
||||
const val androidx_appcompat = "1.1.0-alpha03"
|
||||
const val androidx_constraint_layout = "2.0.0-alpha2"
|
||||
const val androidx_preference = "1.1.0-alpha03"
|
||||
const val androidx_preference = "1.1.0-alpha04"
|
||||
const val androidx_legacy = "1.0.0"
|
||||
const val androidx_annotation = "1.0.1"
|
||||
const val androidx_lifecycle = "2.0.0"
|
||||
const val androidx_fragment = "1.1.0-alpha04"
|
||||
const val androidx_annotation = "1.1.0-alpha02"
|
||||
const val androidx_lifecycle = "2.1.0-alpha03"
|
||||
const val androidx_fragment = "1.1.0-alpha05"
|
||||
const val androidx_safeargs = "1.0.0-beta01"
|
||||
const val androidx_navigation = "2.0.0-rc02"
|
||||
|
||||
|
|
Loading…
Reference in New Issue