Fixes #945 - Ties leanplum to telemetry toggle

nightly-build-test
Jeff Boek 5 years ago
parent 7cbafa58ee
commit dae42a7451

@ -7,9 +7,12 @@ package org.mozilla.fenix
import com.leanplum.Leanplum import com.leanplum.Leanplum
import com.leanplum.LeanplumActivityHelper import com.leanplum.LeanplumActivityHelper
import com.leanplum.annotations.Parser import com.leanplum.annotations.Parser
import org.mozilla.fenix.utils.Settings
object LeanplumHelper { object LeanplumHelper {
fun setupLeanplumIfNeeded(application: FenixApplication) { fun setupLeanplumIfNeeded(application: FenixApplication) {
if (!Settings.getInstance(application).isTelemetryEnabled) { return }
Leanplum.setApplicationContext(application) Leanplum.setApplicationContext(application)
Parser.parseVariables(application) Parser.parseVariables(application)
LeanplumActivityHelper.enableLifecycleCallbacks(application) LeanplumActivityHelper.enableLifecycleCallbacks(application)

@ -7,7 +7,9 @@ package org.mozilla.fenix.settings
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.utils.Settings
class DataChoicesFragment : PreferenceFragmentCompat() { class DataChoicesFragment : PreferenceFragmentCompat() {
@ -19,5 +21,9 @@ class DataChoicesFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.data_choices_preferences, rootKey) setPreferencesFromResource(R.xml.data_choices_preferences, rootKey)
findPreference<SwitchPreference>(getString(R.string.pref_key_telemetry)).apply {
isChecked = Settings.getInstance(context).isTelemetryEnabled
}
} }
} }

@ -34,10 +34,10 @@ class Settings private constructor(context: Context) {
PreferenceManager.getDefaultSharedPreferences(context) PreferenceManager.getDefaultSharedPreferences(context)
val defaultSearchEngineName: String val defaultSearchEngineName: String
get() = preferences.getString( get() = preferences.getString(appContext.getPreferenceKey(R.string.pref_key_search_engine), "") ?: ""
appContext.getPreferenceKey(R.string.pref_key_search_engine),
"" val isTelemetryEnabled: Boolean
) ?: "" get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_telemetry), true)
fun setDefaultSearchEngineByName(name: String) { fun setDefaultSearchEngineByName(name: String) {
preferences.edit() preferences.edit()

@ -5,15 +5,15 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.SwitchPreference <androidx.preference.SwitchPreference
android:key="@string/pref_key_make_default_browser" android:key="@string/pref_key_telemetry"
android:title="@string/preferences_telemetry" /> android:title="@string/preferences_telemetry" />
<androidx.preference.SwitchPreference <androidx.preference.SwitchPreference
android:key="@string/pref_key_make_default_browser" android:key="@string/pref_key_crash_reporter"
android:title="@string/preferences_crash_reporter" /> android:title="@string/preferences_crash_reporter" />
<androidx.preference.SwitchPreference <androidx.preference.SwitchPreference
android:key="@string/pref_key_make_default_browser" android:key="@string/pref_key_mozilla_location_service"
android:title="@string/preferences_mozilla_location_service" /> android:title="@string/preferences_mozilla_location_service" />
<androidx.preference.SwitchPreference <androidx.preference.SwitchPreference
android:key="@string/pref_key_make_default_browser" android:key="@string/pref_key_fenix_health_report"
android:title="@string/preferences_fenix_health_report" /> android:title="@string/preferences_fenix_health_report" />
</PreferenceScreen> </PreferenceScreen>
Loading…
Cancel
Save