Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69a90a29 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury Committed by Fahim M. Choudhury
Browse files

fix(settings): fix switching to sign-in screen while single source was checked and clicked/tapped

In the Settings screen, when only a single source was selected among the three checkboxes (GPlay, Open Source or PWA) and the selected checkbox was tapped/clicked, the code incorrectly set the state so that sign-in fragment is shown.

Without tapping/clicing on the single selected checkbox, the behaviour would follow correct user experience.

With this fix, the checkbox change is handled in the correct else block so that clicking on the only checked checkbox doesn't do anything other than showing a Toast to the user.
parent b7d1480c
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -154,16 +154,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
     */
    private val sourceCheckboxListener =
        OnPreferenceChangeListener { preference: Preference, newValue: Any? ->

            when (preference.key) {
                Constants.PREFERENCE_SHOW_GPLAY -> updateStore(Source.PLAY_STORE, newValue == true)
                Constants.PREFERENCE_SHOW_FOSS -> updateStore(Source.OPEN_SOURCE, newValue == true)
                Constants.PREFERENCE_SHOW_PWA -> updateStore(Source.PWA, newValue == true)
            }

            sourcesChangedFlag = true
            loginViewModel.authObjects.value = null

            val otherBoxesChecked =
                allSourceCheckboxes.filter { it != preference }.any { it?.isChecked == true }

@@ -174,8 +164,17 @@ class SettingsFragment : PreferenceFragmentCompat() {
                    R.string.select_one_source_of_applications,
                    Toast.LENGTH_SHORT
                ).show()

                false
            } else {
                when (preference.key) {
                    Constants.PREFERENCE_SHOW_GPLAY -> updateStore(Source.PLAY_STORE, newValue == true)
                    Constants.PREFERENCE_SHOW_FOSS -> updateStore(Source.OPEN_SOURCE, newValue == true)
                    Constants.PREFERENCE_SHOW_PWA -> updateStore(Source.PWA, newValue == true)
                }
                sourcesChangedFlag = true
                loginViewModel.authObjects.value = null

                true
            }
        }