[fenix] For https://github.com/mozilla-mobile/fenix/issues/19564: Explicitly update switch state for a11y event announcements. (https://github.com/mozilla-mobile/fenix/pull/19589)

pull/600/head
Mihai Adrian Carare 3 years ago committed by GitHub
parent 635bd579c4
commit fc5f56c9ba

@ -32,6 +32,13 @@ class SyncPreference @JvmOverloads constructor(
widgetLayoutResource = R.layout.preference_sync
}
/**
* Updates the switch state.
* */
internal fun setSwitchCheckedState(isChecked: Boolean) {
switchView?.isChecked = isChecked
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)

@ -83,6 +83,7 @@ class SyncPreferenceView(
setOnPreferenceChangeListener { _, newValue ->
SyncEnginesStorage(context).setStatus(syncEngine, newValue as Boolean)
setSwitchCheckedState(newValue)
true
}
}

@ -137,6 +137,7 @@ class SyncPreferenceViewTest {
SyncEngine.Passwords to true
)
every { anyConstructed<SyncEnginesStorage>().setStatus(any(), any()) } just Runs
every { syncPreference.setSwitchCheckedState(any()) } just Runs
createView()
@ -155,6 +156,7 @@ class SyncPreferenceViewTest {
SyncEngine.Passwords to false
)
every { anyConstructed<SyncEnginesStorage>().setStatus(any(), any()) } just Runs
every { syncPreference.setSwitchCheckedState(any()) } just Runs
createView()

Loading…
Cancel
Save