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

Commit

Permalink
Remove Fretboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo authored and jonalmeida committed Feb 3, 2021
1 parent 968f123 commit c44bfe6
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 126 deletions.
3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ dependencies {
implementation "org.mozilla.components:lib-crash:$mozilla_components_version"
implementation "org.mozilla.components:lib-fetch-httpurlconnection:$mozilla_components_version"
implementation "org.mozilla.components:service-telemetry:$mozilla_components_version_telemetry"
implementation "org.mozilla.components:service-fretboard:$mozilla_components_version", {
exclude group: 'android.arch.work', module: 'work-runtime'
}
implementation "org.mozilla.components:support-ktx:$mozilla_components_version"
implementation "org.mozilla.components:support-utils:$mozilla_components_version"
implementation "org.mozilla.components:ui-autocomplete:$mozilla_components_version"
Expand Down
33 changes: 0 additions & 33 deletions app/src/main/java/org/mozilla/focus/FocusApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@

package org.mozilla.focus

import android.content.Context
import android.os.StrictMode
import androidx.preference.PreferenceManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient
import mozilla.components.service.fretboard.Fretboard
import mozilla.components.service.fretboard.ValuesProvider
import mozilla.components.service.fretboard.source.kinto.KintoExperimentSource
import mozilla.components.service.fretboard.storage.flatfile.FlatFileExperimentStorage
import mozilla.components.support.base.log.Log
import mozilla.components.support.base.log.sink.AndroidLogSink
import org.mozilla.focus.locale.LocaleAwareApplication
Expand All @@ -28,19 +22,11 @@ import org.mozilla.focus.telemetry.TelemetrySessionObserver
import org.mozilla.focus.telemetry.TelemetryWrapper
import org.mozilla.focus.utils.AdjustHelper
import org.mozilla.focus.utils.AppConstants
import org.mozilla.focus.utils.EXPERIMENTS_BASE_URL
import org.mozilla.focus.utils.EXPERIMENTS_BUCKET_NAME
import org.mozilla.focus.utils.EXPERIMENTS_COLLECTION_NAME
import org.mozilla.focus.utils.EXPERIMENTS_JSON_FILENAME
import org.mozilla.focus.utils.StethoWrapper
import org.mozilla.focus.web.CleanupSessionObserver
import org.mozilla.focus.web.WebViewProvider
import java.io.File
import kotlin.coroutines.CoroutineContext

class FocusApplication : LocaleAwareApplication(), CoroutineScope {
lateinit var fretboard: Fretboard

private var job = Job()
override val coroutineContext: CoroutineContext
get() = job + Dispatchers.Main
Expand All @@ -61,7 +47,6 @@ class FocusApplication : LocaleAwareApplication(), CoroutineScope {
PreferenceManager.setDefaultValues(this, R.xml.settings, false)

TelemetryWrapper.init(this)
loadExperiments()

enableStrictMode()

Expand All @@ -86,24 +71,6 @@ class FocusApplication : LocaleAwareApplication(), CoroutineScope {
@Suppress("DEPRECATION")
register(CleanupSessionObserver(this@FocusApplication))
}

launch(IO) { fretboard.updateExperiments() }
}

private fun loadExperiments() {
val experimentsFile = File(filesDir, EXPERIMENTS_JSON_FILENAME)
val experimentSource = KintoExperimentSource(
EXPERIMENTS_BASE_URL, EXPERIMENTS_BUCKET_NAME, EXPERIMENTS_COLLECTION_NAME, HttpURLConnectionClient()
)
fretboard = Fretboard(experimentSource, FlatFileExperimentStorage(experimentsFile),
object : ValuesProvider() {
override fun getClientId(context: Context): String {
return TelemetryWrapper.clientId
}
})
fretboard.loadExperiments()
TelemetryWrapper.recordActiveExperiments(this)
WebViewProvider.determineEngine()
}

private fun enableStrictMode() {
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/org/mozilla/focus/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import org.mozilla.focus.session.ui.SessionsSheetFragment
import org.mozilla.focus.shortcut.HomeScreen
import org.mozilla.focus.telemetry.TelemetryWrapper
import org.mozilla.focus.utils.AppConstants
import org.mozilla.focus.utils.ExperimentsSyncService
import org.mozilla.focus.utils.Settings
import org.mozilla.focus.utils.SupportUtils
import org.mozilla.focus.utils.ViewUtils
Expand Down Expand Up @@ -164,7 +163,6 @@ open class MainActivity : LocaleAwareAppCompatActivity() {
super.onStop()

TelemetryWrapper.stopMainActivity()
ExperimentsSyncService.scheduleSync(this)
}

override fun onNewIntent(unsafeIntent: Intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@ import org.mozilla.focus.ext.components
import org.mozilla.focus.telemetry.TelemetryWrapper
import org.mozilla.focus.utils.AppConstants
import org.mozilla.focus.utils.SupportUtils
import org.mozilla.focus.utils.homeScreenTipsExperimentDescriptor
import org.mozilla.focus.utils.isInExperiment

class MozillaSettingsFragment : BaseSettingsFragment(),
SharedPreferences.OnSharedPreferenceChangeListener {
override fun onCreatePreferences(p0: Bundle?, p1: String?) {
addPreferencesFromResource(R.xml.mozilla_settings)

if (!requireContext().isInExperiment(homeScreenTipsExperimentDescriptor)) {
preferenceScreen.removePreference(findPreference(getString(R.string.pref_key_homescreen_tips)))
}
}

override fun onResume() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.mozilla.focus.ext.components
import org.mozilla.focus.search.CustomSearchEngineStore
import org.mozilla.focus.utils.Browsers
import org.mozilla.focus.utils.Settings
import org.mozilla.focus.utils.app
import org.mozilla.telemetry.TelemetryHolder
import org.mozilla.telemetry.measurement.SettingsMeasurement

Expand All @@ -25,13 +24,11 @@ internal class TelemetrySettingsProvider(
) : SettingsMeasurement.SharedPreferenceSettingsProvider() {
private val prefKeyDefaultBrowser: String
private val prefKeySearchEngine: String
private val prefKeyFretboardBucketNumber: String

init {
val resources = context.resources
prefKeyDefaultBrowser = resources.getString(R.string.pref_key_default_browser)
prefKeySearchEngine = resources.getString(R.string.pref_key_search_engine)
prefKeyFretboardBucketNumber = resources.getString(R.string.pref_key_fretboard_bucket_number)
}

override fun containsKey(key: String): Boolean = when (key) {
Expand All @@ -41,9 +38,6 @@ internal class TelemetrySettingsProvider(
// We always want to report the current search engine - even if it's not in settings yet.
prefKeySearchEngine -> true

// Not actually a setting - but we want to report this like a setting.
prefKeyFretboardBucketNumber -> true

else -> super.containsKey(key)
}

Expand Down Expand Up @@ -72,9 +66,6 @@ internal class TelemetrySettingsProvider(
}
value
}
prefKeyFretboardBucketNumber -> {
context.app.fretboard.getUserBucket(context)
}
else -> super.getValue(key)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.mozilla.focus.utils.AppConstants
import org.mozilla.focus.utils.MobileMetricsPingStorage
import org.mozilla.focus.utils.Settings
import org.mozilla.focus.utils.UrlUtils
import org.mozilla.focus.utils.activeExperimentNames
import org.mozilla.telemetry.Telemetry
import org.mozilla.telemetry.TelemetryHolder
import org.mozilla.telemetry.config.TelemetryConfiguration
Expand Down Expand Up @@ -256,8 +255,8 @@ object TelemetryWrapper {
resources.getString(R.string.pref_key_remote_debugging),
resources.getString(R.string.pref_key_homescreen_tips),
resources.getString(R.string.pref_key_open_new_tab),
resources.getString(R.string.pref_key_show_search_suggestions),
resources.getString(R.string.pref_key_fretboard_bucket_number))
resources.getString(R.string.pref_key_show_search_suggestions)
)
.setSettingsProvider(TelemetrySettingsProvider(context))
.setCollectionEnabled(telemetryEnabled)
.setUploadEnabled(telemetryEnabled)
Expand Down Expand Up @@ -914,11 +913,6 @@ object TelemetryWrapper {
TelemetryEvent.create(Category.ACTION, Method.CHANGE, Object.GECKO_ENGINE).queue()
}

@JvmStatic
fun recordActiveExperiments(context: Context) {
TelemetryHolder.get().recordActiveExperiments(context.activeExperimentNames)
}

@JvmStatic
fun reportSiteIssueEvent() {
TelemetryEvent.create(Category.ACTION, Method.CLICK, Object.MENU, Value.REPORT_ISSUE).queue()
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/org/mozilla/focus/tips/TipManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import org.mozilla.focus.telemetry.TelemetryWrapper
import org.mozilla.focus.utils.Browsers
import org.mozilla.focus.utils.Settings
import org.mozilla.focus.utils.SupportUtils
import org.mozilla.focus.utils.homeScreenTipsExperimentDescriptor
import org.mozilla.focus.utils.isInExperiment
import java.util.Locale
import java.util.Random

Expand Down Expand Up @@ -223,7 +221,6 @@ object TipManager {
// Will not return a tip if tips are disabled or if MAX TIPS have already been shown.
@Suppress("ReturnCount", "ComplexMethod") // Using early returns
fun getNextTipIfAvailable(context: Context): Tip? {
if (!context.isInExperiment(homeScreenTipsExperimentDescriptor)) return null
if (!Settings.getInstance(context).shouldDisplayHomescreenTips()) return null
val currentLocale = LocaleManager.getInstance().getCurrentLocale(context)

Expand Down
28 changes: 0 additions & 28 deletions app/src/main/java/org/mozilla/focus/utils/Experiments.kt

This file was deleted.

This file was deleted.

7 changes: 1 addition & 6 deletions app/src/main/java/org/mozilla/focus/web/WebViewProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ import org.mozilla.focus.webview.SystemWebView

object WebViewProvider : IWebViewProvider {

var engine: IWebViewProvider? = null

fun determineEngine(): IWebViewProvider {
engine = GeckoWebViewProvider()
return engine!!
}
var engine: IWebViewProvider? = GeckoWebViewProvider()

override fun preload(context: Context) {
engine!!.preload(context)
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/preference_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

<string name="pref_key_default_browser" translatable="false"><xliff:g id="preference_key">pref_default_browser</xliff:g></string>

<string name="pref_key_fretboard_bucket_number" translatable="false"><xliff:g id="preference_key">pref_fretboard_bucket_number</xliff:g></string>

<string name="pref_key_telemetry" translatable="false"><xliff:g id="preference_key">pref_telemetry</xliff:g></string>

<string name="pref_key_secure" translatable="false"><xliff:g id="preference_key">pref_secure</xliff:g></string>
Expand Down

0 comments on commit c44bfe6

Please sign in to comment.