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

For #6396 For #6553 - Update sync engine checkboxes and send telemetry once #7777

Merged
merged 1 commit into from
Jan 18, 2020

Conversation

ekager
Copy link
Contributor

@ekager ekager commented Jan 16, 2020

Pull Request checklist

  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features. In addition, it includes a screenshot of a successful accessibility scan to ensure no new defects are added to the product.

After merge

  • Milestone: Make sure issues finished by this pull request are added to the milestone of the version currently in development.

To download an APK when reviewing a PR:

  1. click on Show All Checks,
  2. click Details next to "Taskcluster (pull_request)" after it appears and then finishes with a green checkmark,
  3. click on the "Fenix - assemble" task, then click "Run Artifacts".
  4. the APK links should be on the left side of the screen, named for each CPU architecture

@ekager ekager force-pushed the logins-true branch 2 times, most recently from 2e452cd to d30d91a Compare January 16, 2020 23:20
@codecov-io
Copy link

codecov-io commented Jan 16, 2020

Codecov Report

Merging #7777 into master will increase coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #7777      +/-   ##
============================================
+ Coverage     19.14%   19.15%   +<.01%     
  Complexity      452      452              
============================================
  Files           301      301              
  Lines         11668    11673       +5     
  Branches       1585     1586       +1     
============================================
+ Hits           2234     2236       +2     
- Misses         9249     9253       +4     
+ Partials        185      184       -1
Impacted Files Coverage Δ Complexity Δ
...ava/org/mozilla/fenix/settings/SettingsFragment.kt 0% <0%> (ø) 0 <0> (ø) ⬇️
.../fenix/settings/account/AccountSettingsFragment.kt 0% <0%> (ø) 0 <0> (ø) ⬇️
...mponents/searchengine/FenixSearchEngineProvider.kt 63.01% <0%> (+2.73%) 10% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e4eba42...449ea7c. Read the comment docs.

@@ -166,12 +165,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
val historyNameKey = getPreferenceKey(R.string.pref_key_sync_history)
findPreference<CheckBoxPreference>(historyNameKey)?.apply {
setOnPreferenceChangeListener { _, newValue ->
requireComponents.analytics.metrics.track(Event.PreferenceToggled(
Copy link
Contributor Author

@ekager ekager Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already tracking these events in SettingsFragment so we were getting 2 pings here every time someone changed their setting (#6396).

@@ -327,13 +315,29 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
}

private fun setEnginesDisabledWhileSyncing(isSyncing: Boolean) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was weird behavior when you could interact with the toggles while syncing #6553 so I disabled them while syncing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good solution to me

isEnabled = syncEnginesStatus.containsKey(SyncEngine.Passwords)
isChecked = syncEnginesStatus.getOrElse(SyncEngine.Passwords) { false }
isChecked = syncEnginesStatus.getOrElse(SyncEngine.Passwords) { true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #6737 (comment) it sounds like AS changes should paper over this problem, but shouldn't we default to false here anyway (in case of network problems, for example)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I should have updated the bug! Since we have all the biometrics/pin checking set up now and we are removing the nightly flag, we are changing the default for syncing logins to true. cc @liuche to confirm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm changing this is dependent on #6704 being on for release users

@@ -327,13 +315,29 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
}

private fun setEnginesDisabledWhileSyncing(isSyncing: Boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good solution to me

}
val loginsNameKey = getPreferenceKey(R.string.pref_key_sync_logins)
findPreference<CheckBoxPreference>(loginsNameKey)?.apply {
isEnabled = !isSyncing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, but this could also be written as:

    private fun setEnginesDisabledWhileSyncing(isSyncing: Boolean) {
        listOf(
            R.string.pref_key_sync_bookmarks,
            R.string.pref_key_sync_history,
            R.string.pref_key_sync_logins
        )
            .map { getPreferenceKey(it) }
            .map { findPreference<CheckBoxPreference>(it) }
            .forEach { it?.isEnabled = !isSyncing }
    }

or if you prefer a more imperative structure

    private fun setEnginesDisabledWhileSyncing(isSyncing: Boolean) {
        fun setEnabled(@StringRes strId: Int) {
            val key = getPreferenceKey(strId)
            findPreference<CheckBoxPreference>(key)?.apply {
                isEnabled = !isSyncing
            }
        }
        
        setEnabled(R.string.pref_key_sync_bookmarks)
        setEnabled(R.string.pref_key_sync_history)
        setEnabled(R.string.pref_key_sync_logins)
    }

Both communicate to the reader that the same changes are being made to each pref, and reduce the space for typos to hide. But it's up to you if you want to change it, the original code is fine too.

@@ -350,6 +354,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
// Make sure out sync engine checkboxes are up-to-date.
updateSyncEngineStates()
setEnginesDisabledWhileSyncing(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're intentionally leaving the keys disabled in onError (by not calling setEnginesDisabledWhileSyncing(false)). Is that correct? That makes sense to me (we can't do anything with their clicks until they reconnect anyway), but would you mind adding a comment in onError that states it explicitly?

@@ -27,10 +26,9 @@
android:title="@string/preferences_sync_history" />

<androidx.preference.CheckBoxPreference
android:defaultValue="false"
android:defaultValue="true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above, I'm not clear on why this should default to true.

@ekager ekager force-pushed the logins-true branch 3 times, most recently from a551a74 to a1d5880 Compare January 18, 2020 00:04
@ekager ekager changed the title For #6396 For #6737 For #6553 - Update sync engine checkboxes and sen… For #6396 For #6553 - Update sync engine checkboxes and send telemetry once Jan 18, 2020
@ekager ekager added the pr:needs-landing PRs that are ready to land [Will be merged by Mergify] label Jan 18, 2020
@ekager
Copy link
Contributor Author

ekager commented Jan 18, 2020

Okay sorry for the confusion, the final decision was to keep the feature flags for logins for now. So this PR really is just fixing telemetry for sync and adding the disabled state for the engine checkboxes. Thanks for your help!!

@ekager ekager merged commit 053e5b8 into mozilla-mobile:master Jan 18, 2020
@ekager ekager deleted the logins-true branch January 18, 2020 00:39
@liuche
Copy link
Contributor

liuche commented Jan 18, 2020

Filed #7796 to detail the steps required for turning on Logins, there are a few dependencies still.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr:needs-landing PRs that are ready to land [Will be merged by Mergify]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants