For #6354 - Removes ETP Experiment, Removes Feature Flags, Sets Strict Default
parent
1ff5a1934e
commit
d9615108ee
@ -1,53 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
package org.mozilla.fenix
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import mozilla.components.service.experiments.Experiments
|
|
||||||
import org.mozilla.fenix.ext.components
|
|
||||||
import org.mozilla.fenix.ext.settings
|
|
||||||
|
|
||||||
object ExperimentsManager {
|
|
||||||
fun optOutEtpExperiment(context: Context) {
|
|
||||||
// If a user can see the ETP categories we don't want to change their settings
|
|
||||||
if (FeatureFlags.etpCategories) return
|
|
||||||
// Release user has opted out of ETP experiment, reset them to current default (strict)
|
|
||||||
context.settings().setUseStrictTrackingProtection()
|
|
||||||
context.components.useCases.settingsUseCases.updateTrackingProtection(
|
|
||||||
context.components.core.createTrackingProtectionPolicy()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun initEtpExperiment(context: Context) {
|
|
||||||
// When the `fenix-etp-5651` experiment is active, set up ETP settings and GV policy.
|
|
||||||
// Note that this will not take effect the first time the application has launched,
|
|
||||||
// since there won't be enough time for the experiments library to get a list of experiments.
|
|
||||||
// It will take effect the second time the application is launched.
|
|
||||||
Experiments.withExperiment("fenix-etp-5651") { branchName ->
|
|
||||||
when (branchName) {
|
|
||||||
"control_strict" -> {
|
|
||||||
context.settings().setUseStrictTrackingProtection()
|
|
||||||
context.components.useCases.settingsUseCases.updateTrackingProtection(
|
|
||||||
context.components.core.createTrackingProtectionPolicy()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
"treatment_standard" -> {
|
|
||||||
context.settings().setUseStandardTrackingProtection()
|
|
||||||
context.components.core.createTrackingProtectionPolicy()
|
|
||||||
context.components.useCases.settingsUseCases.updateTrackingProtection(
|
|
||||||
context.components.core.createTrackingProtectionPolicy()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
// No branch matches so we're defaulting to strict
|
|
||||||
context.settings().setUseStrictTrackingProtection()
|
|
||||||
context.components.useCases.settingsUseCases.updateTrackingProtection(
|
|
||||||
context.components.core.createTrackingProtectionPolicy()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
package org.mozilla.fenix.settings.quicksettings
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
|
||||||
import kotlinx.android.synthetic.main.quicksettings_tracking_protection.*
|
|
||||||
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contract declaring all possible user interactions with [TrackingProtectionView]
|
|
||||||
*/
|
|
||||||
interface TrackingProtectionInteractor {
|
|
||||||
/**
|
|
||||||
* Indicates the user wants to report a problem with the current website.
|
|
||||||
*/
|
|
||||||
fun onReportProblemSelected(websiteUrl: String)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the user want to toggle the tracking protection on / off.
|
|
||||||
*/
|
|
||||||
fun onProtectionToggled(trackingEnabled: Boolean)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the user want to see all tracking protection settings.
|
|
||||||
*/
|
|
||||||
fun onProtectionSettingsSelected()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the tracking protection status for the current website is shown to the user.
|
|
||||||
*/
|
|
||||||
fun onTrackingProtectionShown()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MVI View that knows to display a "normal" (as in not "enhanced") tracking protection panel
|
|
||||||
* containing the tracking protection status and also allowing on / off toggling.
|
|
||||||
*
|
|
||||||
* @param containerView [ViewGroup] in which this View will inflate itself.
|
|
||||||
* @param interactor [TrackingProtectionInteractor] which will have delegated to all user interactions.
|
|
||||||
*/
|
|
||||||
class TrackingProtectionView(
|
|
||||||
override val containerView: ViewGroup,
|
|
||||||
val interactor: TrackingProtectionInteractor
|
|
||||||
) : LayoutContainer {
|
|
||||||
|
|
||||||
val view: View = LayoutInflater.from(containerView.context)
|
|
||||||
.inflate(R.layout.quicksettings_tracking_protection, containerView, true)
|
|
||||||
|
|
||||||
init {
|
|
||||||
trackingProtectionSwitch.putCompoundDrawablesRelativeWithIntrinsicBounds(
|
|
||||||
start = AppCompatResources.getDrawable(
|
|
||||||
containerView.context,
|
|
||||||
R.drawable.ic_tracking_protection
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows changing what this View displays.
|
|
||||||
*
|
|
||||||
* @param state [TrackingProtectionState] to be rendered.
|
|
||||||
*/
|
|
||||||
fun update(state: TrackingProtectionState) {
|
|
||||||
if (state.isVisible) {
|
|
||||||
interactor.onTrackingProtectionShown()
|
|
||||||
}
|
|
||||||
|
|
||||||
reportSiteIssueAction.setOnClickListener { interactor.onReportProblemSelected(state.websiteUrl) }
|
|
||||||
|
|
||||||
trackingProtectionAction.isVisible = !state.isTrackingProtectionEnabledPerApp
|
|
||||||
if (!state.isTrackingProtectionEnabledPerApp) {
|
|
||||||
trackingProtectionAction.setOnClickListener { interactor.onProtectionSettingsSelected() }
|
|
||||||
}
|
|
||||||
|
|
||||||
trackingProtectionSwitch.isChecked = state.isTrackingProtectionEnabledPerWebsite
|
|
||||||
trackingProtectionSwitch.isEnabled = state.isTrackingProtectionEnabledPerApp
|
|
||||||
if (state.isTrackingProtectionEnabledPerApp) {
|
|
||||||
trackingProtectionSwitch.setOnCheckedChangeListener { _, isChecked ->
|
|
||||||
interactor.onProtectionToggled(isChecked)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue