From b6f066c9edcc9265b35919f03eeba7a603c919b3 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Tue, 1 Mar 2022 10:03:14 -0500 Subject: [PATCH] For #24042- Remove inactive tabs survey --- app/metrics.yaml | 34 ------ .../mozilla/fenix/components/metrics/Event.kt | 6 - .../components/metrics/GleanMetricsService.kt | 7 -- .../fenix/settings/TabsSettingsFragment.kt | 90 +------------- .../java/org/mozilla/fenix/utils/Settings.kt | 8 -- .../layout/survey_inactive_tabs_disable.xml | 114 ------------------ app/src/main/res/values/preference_keys.xml | 4 - app/src/main/res/values/strings.xml | 17 ++- app/src/main/res/values/styles.xml | 2 +- 9 files changed, 10 insertions(+), 272 deletions(-) delete mode 100644 app/src/main/res/layout/survey_inactive_tabs_disable.xml diff --git a/app/metrics.yaml b/app/metrics.yaml index 10322d554..b843a7d67 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -2001,40 +2001,6 @@ preferences: notification_emails: - android-probes@mozilla.com expires: 107 - inactive_tabs_survey_opened: - type: event - description: > - A survey for asking the user why she intends to turn off the - inactive tabs feature is shown. - bugs: - - https://github.com/mozilla-mobile/fenix/issues/21732 - data_reviews: - - https://github.com/mozilla-mobile/fenix/pull/21862#issuecomment-949598042 - - https://github.com/mozilla-mobile/fenix/pull/23453#issuecomment-1024694220 - data_sensitivity: - - interaction - notification_emails: - - android-probes@mozilla.com - expires: 111 - turn_off_inactive_tabs_survey: - type: event - description: > - The user has disabled inactive tabs feature and responded - to our request for feedback. - extra_keys: - feedback: - description: | - The user's feedback regarding inactive tabs feature. - bugs: - - https://github.com/mozilla-mobile/fenix/issues/21732 - data_reviews: - - https://github.com/mozilla-mobile/fenix/pull/21862#issuecomment-946977614 - - https://github.com/mozilla-mobile/fenix/pull/23453#issuecomment-1024694220 - data_sensitivity: - - interaction - notification_emails: - - android-probes@mozilla.com - expires: 111 search_term_groups_enabled: type: boolean description: | diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index 21576573e..91b6a443d 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -19,7 +19,6 @@ import org.mozilla.fenix.GleanMetrics.History import org.mozilla.fenix.GleanMetrics.Logins import org.mozilla.fenix.GleanMetrics.Onboarding import org.mozilla.fenix.GleanMetrics.Pocket -import org.mozilla.fenix.GleanMetrics.Preferences import org.mozilla.fenix.GleanMetrics.SearchShortcuts import org.mozilla.fenix.GleanMetrics.SearchTerms import org.mozilla.fenix.GleanMetrics.TabsTray @@ -237,11 +236,6 @@ sealed class Event { object TabsTrayInactiveTabsCFRDismissed : Event() object TabsTrayInactiveTabsCFRIsVisible : Event() - object InactiveTabsSurveyOpened : Event() - data class InactiveTabsOffSurvey(val feedback: String) : Event() { - override val extras: Map - get() = mapOf(Preferences.turnOffInactiveTabsSurveyKeys.feedback to feedback.lowercase(Locale.ROOT)) - } data class InactiveTabsCountUpdate(val count: Int) : Event() object ProgressiveWebAppOpenFromHomescreenTap : Event() diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index 70c4a1188..a141fc8a2 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -696,13 +696,6 @@ private val Event.wrapper: EventWrapper<*>? is Event.TabsTrayOpenInactiveTab -> EventWrapper( { TabsTray.openInactiveTab.add() } ) - is Event.InactiveTabsSurveyOpened -> EventWrapper( - { Preferences.inactiveTabsSurveyOpened.record(it) } - ) - is Event.InactiveTabsOffSurvey -> EventWrapper( - { Preferences.turnOffInactiveTabsSurvey.record(it) }, - { Preferences.turnOffInactiveTabsSurveyKeys.valueOf(it) } - ) is Event.InactiveTabsCountUpdate -> EventWrapper( { Metrics.inactiveTabsCount.set(this.count.toLong()) }, ) diff --git a/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt index 58127e43d..cb9fe517d 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt @@ -4,12 +4,8 @@ package org.mozilla.fenix.settings -import android.content.res.Configuration import android.os.Bundle -import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup -import android.widget.RadioButton import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat import androidx.preference.SwitchPreference @@ -18,18 +14,14 @@ import org.mozilla.fenix.R import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.Event.TabViewSettingChanged import org.mozilla.fenix.components.metrics.Event.TabViewSettingChanged.Type -import org.mozilla.fenix.databinding.SurveyInactiveTabsDisableBinding import org.mozilla.fenix.ext.components -import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.utils.view.addToRadioGroup -import java.util.Locale /** * Lets the user customize auto closing tabs. */ -@Suppress("TooManyFunctions") class TabsSettingsFragment : PreferenceFragmentCompat() { private lateinit var listRadioButton: RadioButtonPreference private lateinit var gridRadioButton: RadioButtonPreference @@ -40,9 +32,6 @@ class TabsSettingsFragment : PreferenceFragmentCompat() { private lateinit var inactiveTabsCategory: PreferenceCategory private lateinit var inactiveTabs: SwitchPreference private lateinit var searchTermTabGroups: SwitchPreference - private val shouldShowInactiveTabsTurnOffSurvey - get() = requireContext().settings().isTelemetryEnabled && - requireContext().settings().shouldShowInactiveTabsTurnOffSurvey override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.tabs_preferences, rootKey) @@ -81,24 +70,7 @@ class TabsSettingsFragment : PreferenceFragmentCompat() { inactiveTabs = requirePreference(R.string.pref_key_inactive_tabs).also { it.isChecked = requireContext().settings().inactiveTabsAreEnabled - it.setOnPreferenceChangeListener { preference, newValue -> - if (shouldShowInactiveTabsTurnOffSurvey && newValue == false) { - // The first time the user tries to disable the feature show a little survey for her motives. - val inactiveTabsSurveyBinding = SurveyInactiveTabsDisableBinding.inflate( - LayoutInflater.from(context), - view as ViewGroup, - true - ) - setupSurvey(inactiveTabsSurveyBinding) - requireContext().metrics.track(Event.InactiveTabsSurveyOpened) - - // Don't update the preference as a direct action of user tapping the switch. - // Only disable the feature after the user selects an option in the survey or expressly closes it. - false - } else { - SharedPreferenceUpdater().onPreferenceChange(preference, newValue) - } - } + it.onPreferenceChangeListener = SharedPreferenceUpdater() } inactiveTabsCategory = requirePreference(R.string.pref_key_inactive_tabs_category).also { @@ -117,66 +89,6 @@ class TabsSettingsFragment : PreferenceFragmentCompat() { setupRadioGroups() } - private fun setupSurvey(inactiveTabsSurveyBinding: SurveyInactiveTabsDisableBinding) { - inactiveTabsSurveyBinding.closeSurvey.setOnClickListener { - finishInactiveTabsSurvey(inactiveTabsSurveyBinding) - - // Register that user closed this survey without picking any option. - requireContext().metrics.track( - Event.InactiveTabsOffSurvey("none") - ) - } - - // A map is needed to help retrieve the correct string on SEND. - // These values are also sent to Glean which will truncate anything over 100 UTF8 characters. - val radioButtonsMap: Map = mapOf( - R.id.rb_do_not_understand to R.string.inactive_tabs_survey_do_not_understand, - R.id.rb_do_it_myself to R.string.inactive_tabs_survey_do_it_myself, - R.id.rb_time_too_long to R.string.inactive_tabs_survey_time_too_long_option_1, - R.id.rb_time_too_short to R.string.inactive_tabs_survey_time_too_short_option_1, - ) - - // Sets the Radio buttons' text - radioButtonsMap.forEach { - inactiveTabsSurveyBinding.surveyGroup.findViewById(it.key)?.text = - requireContext().getText(it.value) - } - - inactiveTabsSurveyBinding.sendButton.setOnClickListener { - val checkedRadioButtonId = inactiveTabsSurveyBinding.surveyGroup.checkedRadioButtonId - // If no option has been selected the button does not need to do anything. - if (checkedRadioButtonId != -1) { - finishInactiveTabsSurvey(inactiveTabsSurveyBinding) - - // Using the stringId of the selected option an event is sent using English. - radioButtonsMap[checkedRadioButtonId]?.let { stringId -> - requireContext().metrics.track( - Event.InactiveTabsOffSurvey(getDefaultString(stringId)) - ) - } - } - } - } - - /** - * Set the inactive tabs survey completed and the feature disabled. - */ - private fun finishInactiveTabsSurvey(inactiveTabsSurveyBinding: SurveyInactiveTabsDisableBinding) { - inactiveTabsSurveyBinding.surveyContainer.visibility = View.GONE - requireContext().settings().shouldShowInactiveTabsTurnOffSurvey = false - requireContext().settings().inactiveTabsAreEnabled = false - requirePreference(R.string.pref_key_inactive_tabs).isChecked = false - } - - /** - * Get the "en-US" string value for the indicated [resourceId]. - */ - private fun getDefaultString(resourceId: Int): String { - val config = Configuration(requireContext().resources.configuration) - config.setLocale(Locale.ENGLISH) - return requireContext().createConfigurationContext(config).getText(resourceId).toString() - } - private fun setupRadioGroups() { addToRadioGroup( listRadioButton, diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index a5a9c0e5a..602704c64 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -912,14 +912,6 @@ class Settings(private val appContext: Context) : PreferencesHolder { default = true ) - /** - * Should we display a feedback request to the user when he turns off the Inactive Tabs feature - */ - var shouldShowInactiveTabsTurnOffSurvey by booleanPreference( - appContext.getPreferenceKey(R.string.pref_key_should_show_inactive_tabs_turn_off_survey), - default = false - ) - fun getSitePermissionsPhoneFeatureAction( feature: PhoneFeature, default: Action = Action.ASK_TO_ALLOW diff --git a/app/src/main/res/layout/survey_inactive_tabs_disable.xml b/app/src/main/res/layout/survey_inactive_tabs_disable.xml deleted file mode 100644 index efb5e440d..000000000 --- a/app/src/main/res/layout/survey_inactive_tabs_disable.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -