Skip to content

Commit

Permalink
Update Settings: Update feature flag (#5480)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/0/1209171570131451/f 

### Description

Updates the feature toggle to `settingsPage` and add two new sub-flags
for controlling the rollout:

- `newSettingsPage` for showing the screen and all changes **except**
the privacy pro section
- `newPrivacyProSection` for showing/hiding the new privacy pro section
items

### Steps to test this PR

_New Settings_
- [ ] Enable `newSettingsPage` in the Feature Flag Inventory
- [ ] Press back
- [ ] Open Settings again
- [ ] The new settings screen should be displayed
- [ ] Privacy Pro should remain unchanged

_New Privacy Pro Section_
- [ ] Enable `newPrivacyProSection` in the Feature Flag Inventory
- [ ] Press back
- [ ] Open Settings again
- [ ] The new settings screen should be displayed
- [ ] The new Privacy Pro section should be displayed

_New Privacy Pro Section and legacy settings_
- [ ] Disable `newSettingsPage` in the Feature Flag Inventory
- [ ] Press back
- [ ] Open Settings again
- [ ] The legacy settings screen should be displayed
- [ ] The new Privacy Pro section should be displayed

### UI changes

N/A
  • Loading branch information
mikescamell authored Jan 17, 2025
1 parent b8b57d1 commit f95f022
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import com.duckduckgo.common.utils.AppUrl.Url
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.mobile.android.R.attr
import com.duckduckgo.navigation.api.GlobalActivityStarter
import com.duckduckgo.settings.api.NewSettingsFeature
import com.duckduckgo.settings.api.SettingsPageFeature
import com.duckduckgo.subscriptions.api.PrivacyProFeedbackScreens.GeneralPrivacyProFeedbackScreenNoParams
import com.google.android.material.snackbar.Snackbar
import javax.inject.Inject
Expand All @@ -57,7 +57,7 @@ import kotlinx.coroutines.flow.onEach
class AboutDuckDuckGoActivity : DuckDuckGoActivity() {

@Inject
lateinit var settingsFeature: NewSettingsFeature
lateinit var settingsPageFeature: SettingsPageFeature

private val viewModel: AboutDuckDuckGoViewModel by bindViewModel()
private val binding: ActivityAboutDuckDuckGoBinding by viewBinding()
Expand All @@ -81,7 +81,7 @@ class AboutDuckDuckGoActivity : DuckDuckGoActivity() {
setContentView(binding.root)
setupToolbar(binding.includeToolbar.toolbar)

if (settingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
supportActionBar?.setTitle(R.string.aboutActivityTitleNew)
binding.includeContent.aboutTextNew.isVisible = true

Expand All @@ -100,7 +100,7 @@ class AboutDuckDuckGoActivity : DuckDuckGoActivity() {
}

private fun configureClickableLinks() {
if (settingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
with(binding.includeContent.aboutTextNew) {
text = addClickableLinks()
movementMethod = LinkMovementMethod.getInstance()
Expand All @@ -115,7 +115,7 @@ class AboutDuckDuckGoActivity : DuckDuckGoActivity() {

private fun addClickableLinks(): SpannableString {
val fullText = getText(
if (settingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
R.string.aboutDescriptionNew
} else {
R.string.aboutDescription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import com.duckduckgo.common.ui.DuckDuckGoActivity
import com.duckduckgo.common.ui.view.dialog.RadioListAlertDialogBuilder
import com.duckduckgo.common.ui.viewbinding.viewBinding
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.settings.api.NewSettingsFeature
import com.duckduckgo.settings.api.SettingsPageFeature
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -61,7 +61,7 @@ class FireButtonActivity : DuckDuckGoActivity() {
lateinit var appBuildConfig: AppBuildConfig

@Inject
lateinit var newSettingsFeature: NewSettingsFeature
lateinit var settingsPageFeature: SettingsPageFeature

private val viewModel: FireButtonViewModel by bindViewModel()
private val legacyBinding: ActivityFireButtonBinding by viewBinding() // TODO remove
Expand All @@ -70,7 +70,7 @@ class FireButtonActivity : DuckDuckGoActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
setContentView(binding.root)
setupToolbar(binding.includeToolbar.toolbar)
supportActionBar?.setTitle(R.string.dataClearingActivityTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import com.duckduckgo.common.ui.DuckDuckGoActivity
import com.duckduckgo.common.ui.viewbinding.viewBinding
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.navigation.api.GlobalActivityStarter
import com.duckduckgo.settings.api.NewSettingsFeature
import com.duckduckgo.settings.api.SettingsPageFeature
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -46,7 +46,7 @@ class PrivateSearchActivity : DuckDuckGoActivity() {
lateinit var globalActivityStarter: GlobalActivityStarter

@Inject
lateinit var newSettingsFeature: NewSettingsFeature
lateinit var settingsPageFeature: SettingsPageFeature

private val viewModel: PrivateSearchViewModel by bindViewModel()
private val binding: ActivityPrivateSearchBinding by viewBinding()
Expand All @@ -65,7 +65,7 @@ class PrivateSearchActivity : DuckDuckGoActivity() {
setContentView(binding.root)
setupToolbar(binding.includeToolbar.toolbar)

if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
with(binding) {
privateSearchHeaderImage.isGone = true
privateSearchTitle.isGone = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ import com.duckduckgo.mobile.android.app.tracking.ui.AppTrackingProtectionScreen
import com.duckduckgo.mobile.android.app.tracking.ui.AppTrackingProtectionScreens.AppTrackerOnboardingActivityWithEmptyParamsParams
import com.duckduckgo.navigation.api.GlobalActivityStarter
import com.duckduckgo.settings.api.DuckPlayerSettingsPlugin
import com.duckduckgo.settings.api.NewSettingsFeature
import com.duckduckgo.settings.api.ProSettingsPlugin
import com.duckduckgo.settings.api.SettingsPageFeature
import com.duckduckgo.sync.api.SyncActivityWithEmptyParams
import com.duckduckgo.windows.api.ui.WindowsScreenWithEmptyParams
import javax.inject.Inject
Expand Down Expand Up @@ -107,7 +107,7 @@ class LegacySettingsActivity : DuckDuckGoActivity() {
}

@Inject
lateinit var newSettingsFeature: NewSettingsFeature
lateinit var settingsPageFeature: SettingsPageFeature

private val viewsPrivacy
get() = binding.includeSettings.contentSettingsPrivacy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.browser.api.ui.BrowserScreens.SettingsScreenNoParams
import com.duckduckgo.common.ui.DuckDuckGoActivity
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.settings.api.NewSettingsFeature
import com.duckduckgo.settings.api.SettingsPageFeature
import javax.inject.Inject

@InjectWith(ActivityScope::class)
@ContributeToActivityStarter(SettingsScreenNoParams::class, screenName = "settings")
class SettingsActivity : DuckDuckGoActivity() {

@Inject
lateinit var newSettingsFeature: NewSettingsFeature
lateinit var settingsPageFeature: SettingsPageFeature

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
startActivity(NewSettingsActivity.intent(this))
} else {
startActivity(LegacySettingsActivity.intent(this))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import com.duckduckgo.common.utils.extensions.html
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.navigation.api.GlobalActivityStarter
import com.duckduckgo.settings.api.NewSettingsFeature
import com.duckduckgo.settings.api.SettingsPageFeature
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -57,7 +57,7 @@ class WebTrackingProtectionActivity : DuckDuckGoActivity() {
lateinit var globalActivityStarter: GlobalActivityStarter

@Inject
lateinit var newSettingsFeature: NewSettingsFeature
lateinit var settingsPageFeature: SettingsPageFeature

private val viewModel: WebTrackingProtectionViewModel by bindViewModel()
private val binding: ActivityWebTrackingProtectionBinding by viewBinding()
Expand All @@ -70,7 +70,7 @@ class WebTrackingProtectionActivity : DuckDuckGoActivity() {

override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
ds.color = getColorFromAttr(CommonR.attr.daxColorAccentBlue)
ds.isUnderlineText = false
}
Expand All @@ -83,7 +83,7 @@ class WebTrackingProtectionActivity : DuckDuckGoActivity() {
setContentView(binding.root)
setupToolbar(binding.includeToolbar.toolbar)

if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
with(binding) {
webTrackingProtectionHeaderImage.isGone = true
webTrackingProtectionTitle.isGone = true
Expand All @@ -108,7 +108,7 @@ class WebTrackingProtectionActivity : DuckDuckGoActivity() {

private fun configureClickableLink() {
val htmlGPCText = getString(
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
R.string.webTrackingProtectionDescriptionNew
} else {
R.string.webTrackingProtectionDescription
Expand All @@ -118,7 +118,7 @@ class WebTrackingProtectionActivity : DuckDuckGoActivity() {
val urlSpans = htmlGPCText.getSpans(0, htmlGPCText.length, URLSpan::class.java)
urlSpans?.forEach {
gpcSpannableString.apply {
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
insert(getSpanStart(it), "\n")
}
setSpan(
Expand All @@ -131,7 +131,7 @@ class WebTrackingProtectionActivity : DuckDuckGoActivity() {
trim()
}
}
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
binding.webTrackingProtectionDescriptionNew.apply {
text = gpcSpannableString
movementMethod = LinkMovementMethod.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import com.duckduckgo.common.utils.extensions.html
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.mobile.android.R as CommonR
import com.duckduckgo.navigation.api.GlobalActivityStarter
import com.duckduckgo.settings.api.NewSettingsFeature
import com.duckduckgo.settings.api.SettingsPageFeature
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -57,7 +57,7 @@ class AutoconsentSettingsActivity : DuckDuckGoActivity() {
lateinit var globalActivityStarter: GlobalActivityStarter

@Inject
lateinit var newSettingsFeature: NewSettingsFeature
lateinit var settingsPageFeature: SettingsPageFeature

private val binding: ActivityAutoconsentSettingsBinding by viewBinding()

Expand All @@ -77,7 +77,7 @@ class AutoconsentSettingsActivity : DuckDuckGoActivity() {

override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
ds.color = getColorFromAttr(CommonR.attr.daxColorAccentBlue)
ds.isUnderlineText = false
}
Expand All @@ -90,7 +90,7 @@ class AutoconsentSettingsActivity : DuckDuckGoActivity() {
setContentView(binding.root)
setupToolbar(toolbar)

if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
with(binding) {
autoconsentHeaderImage.isVisible = true
autoconsentTitle.isVisible = true
Expand Down Expand Up @@ -121,7 +121,7 @@ class AutoconsentSettingsActivity : DuckDuckGoActivity() {
}

private fun render(viewState: ViewState) {
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
with(binding) {
autoconsentHeaderImage.setImageResource(
if (viewState.autoconsentEnabled) R.drawable.cookie_popups_check_128 else R.drawable.cookie_block_128,
Expand All @@ -145,7 +145,7 @@ class AutoconsentSettingsActivity : DuckDuckGoActivity() {

private fun configureClickableLink() {
val htmlText = getString(
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
R.string.autoconsentDescriptionNew
} else {
R.string.autoconsentDescription
Expand All @@ -155,7 +155,7 @@ class AutoconsentSettingsActivity : DuckDuckGoActivity() {
val urlSpans = htmlText.getSpans(0, htmlText.length, URLSpan::class.java)
urlSpans?.forEach {
spannableString.apply {
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
insert(spannableString.getSpanStart(it), "\n")
}
setSpan(
Expand All @@ -168,7 +168,7 @@ class AutoconsentSettingsActivity : DuckDuckGoActivity() {
trim()
}
}
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
binding.autoconsentDescriptionNew.apply {
text = spannableString
movementMethod = LinkMovementMethod.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.duckduckgo.autoconsent.impl.pixels.AutoConsentPixel.SETTINGS_AUTOCONS
import com.duckduckgo.autoconsent.impl.pixels.AutoConsentPixel.SETTINGS_AUTOCONSENT_ON
import com.duckduckgo.autoconsent.impl.pixels.AutoConsentPixel.SETTINGS_AUTOCONSENT_SHOWN
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.settings.api.NewSettingsFeature
import com.duckduckgo.settings.api.SettingsPageFeature
import javax.inject.Inject
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
Expand All @@ -41,7 +41,7 @@ import kotlinx.coroutines.launch
class AutoconsentSettingsViewModel @Inject constructor(
private val autoconsent: Autoconsent,
private val pixel: Pixel,
private val newSettingsFeature: NewSettingsFeature,
private val settingsPageFeature: SettingsPageFeature,
) : ViewModel() {
data class ViewState(
val autoconsentEnabled: Boolean,
Expand All @@ -57,7 +57,7 @@ class AutoconsentSettingsViewModel @Inject constructor(
val viewState: StateFlow<ViewState> = viewStateFlow

init {
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
pixel.fire(SETTINGS_AUTOCONSENT_SHOWN)
}
}
Expand All @@ -68,7 +68,7 @@ class AutoconsentSettingsViewModel @Inject constructor(

fun onUserToggleAutoconsent(enabled: Boolean) {
viewModelScope.launch {
if (newSettingsFeature.self().isEnabled()) {
if (settingsPageFeature.newSettingsPage().isEnabled()) {
pixel.fire(
if (enabled) {
SETTINGS_AUTOCONSENT_ON
Expand Down
Loading

0 comments on commit f95f022

Please sign in to comment.