Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #8592: Relocate device name in account preferences. Deactivate de…
Browse files Browse the repository at this point in the history
…vice name field while syncing. (#9255)
  • Loading branch information
Elise Richards authored Mar 20, 2020
1 parent a356b4b commit 5d8a9bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {

// Make sure out sync engine checkboxes are up-to-date and disabled if currently syncing
updateSyncEngineStates()
setCwtsDisabledWhileSyncing(accountManager.isSyncActive())
setDisabledWhileSyncing(accountManager.isSyncActive())

val historyNameKey = getPreferenceKey(R.string.pref_key_sync_history)
findPreference<CheckBoxPreference>(historyNameKey)?.apply {
Expand Down Expand Up @@ -317,10 +317,14 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
}

private fun setCwtsDisabledWhileSyncing(isSyncing: Boolean) {
private fun setDisabledWhileSyncing(isSyncing: Boolean) {
findPreference<PreferenceCategory>(
getPreferenceKey(R.string.preferences_sync_category)
)?.isEnabled = !isSyncing

findPreference<EditTextPreference>(
getPreferenceKey(R.string.pref_key_sync_device_name)
)?.isEnabled = !isSyncing
}

private val syncStatusObserver = object : SyncStatusObserver {
Expand All @@ -330,7 +334,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
view?.announceForAccessibility(getString(R.string.sync_syncing_in_progress))
pref?.title = getString(R.string.sync_syncing_in_progress)
pref?.isEnabled = false
setCwtsDisabledWhileSyncing(true)
setDisabledWhileSyncing(true)
}
}

Expand All @@ -347,7 +351,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
// Make sure out sync engine checkboxes are up-to-date.
updateSyncEngineStates()
setCwtsDisabledWhileSyncing(false)
setDisabledWhileSyncing(false)
}
}

Expand Down
14 changes: 7 additions & 7 deletions app/src/main/res/xml/account_settings_preferences.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
<?xml version="1.0" encoding="utf-8"?><!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<androidx.preference.Preference
android:key="@string/pref_key_sync_now"
android:title="@string/preferences_sync_now" />

<androidx.preference.EditTextPreference
android:key="@string/pref_key_sync_device_name"
android:title="@string/preferences_sync_device_name" />

<androidx.preference.Preference
android:key="@string/pref_key_sign_out"
android:title="@string/preferences_sign_out" />
Expand All @@ -29,10 +34,5 @@
android:defaultValue="true"
android:key="@string/pref_key_sync_logins"
android:title="@string/preferences_sync_logins" />

<androidx.preference.EditTextPreference
android:key="@string/pref_key_sync_device_name"
android:title="@string/preferences_sync_device_name" />

</androidx.preference.PreferenceCategory>
</PreferenceScreen>

0 comments on commit 5d8a9bb

Please sign in to comment.