Skip to content

Commit 1338587

Browse files
Visual design: Preparations for rollout (#6120)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1157893581871903/task/1210327410584404?focus=true ### Description PR to allow for visual design rollout ### Steps to test this PR Testing scenarios in https://app.asana.com/1/137249556945/project/1157893581871903/task/1210341258091868?focus=true --------- Co-authored-by: Łukasz Paczos <[email protected]>
1 parent c229f3d commit 1338587

File tree

26 files changed

+477
-217
lines changed

26 files changed

+477
-217
lines changed

app/src/internal/res/drawable/ic_fire_16.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/src/internal/res/drawable/ic_fire_24.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/src/internal/res/drawable/ic_fire_color_24.xml

Lines changed: 0 additions & 44 deletions
This file was deleted.

app/src/internal/res/drawable/ic_fire_red_24.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/src/internal/res/drawable/ic_fireproof_solid_16.xml

Lines changed: 0 additions & 32 deletions
This file was deleted.

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ class BrowserTabFragment :
10461046
browserNavigationBarIntegration = BrowserNavigationBarViewIntegration(
10471047
lifecycleScope = lifecycleScope,
10481048
browserTabFragmentBinding = binding,
1049-
visualDesignExperimentDataStore = visualDesignExperimentDataStore,
1049+
isExperimentEnabled = visualDesignExperimentDataStore.isExperimentEnabled.value,
10501050
omnibar = omnibar,
10511051
browserNavigationBarObserver = observer,
10521052
)

app/src/main/java/com/duckduckgo/app/browser/navigation/bar/BrowserNavigationBarViewIntegration.kt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import com.duckduckgo.app.browser.navigation.bar.view.BrowserNavigationBarView
2323
import com.duckduckgo.app.browser.navigation.bar.view.BrowserNavigationBarView.ViewMode.Browser
2424
import com.duckduckgo.app.browser.navigation.bar.view.BrowserNavigationBarView.ViewMode.NewTab
2525
import com.duckduckgo.app.browser.omnibar.Omnibar
26-
import com.duckduckgo.common.ui.experiments.visual.store.VisualDesignExperimentDataStore
2726
import com.duckduckgo.common.ui.view.gone
2827
import com.duckduckgo.common.ui.view.show
2928
import com.duckduckgo.common.utils.keyboardVisibilityFlow
@@ -43,7 +42,7 @@ import kotlinx.coroutines.launch
4342
class BrowserNavigationBarViewIntegration(
4443
private val lifecycleScope: CoroutineScope,
4544
private val browserTabFragmentBinding: FragmentBrowserTabBinding,
46-
private val visualDesignExperimentDataStore: VisualDesignExperimentDataStore,
45+
isExperimentEnabled: Boolean,
4746
private val omnibar: Omnibar,
4847
browserNavigationBarObserver: BrowserNavigationBarObserver,
4948
) {
@@ -53,19 +52,14 @@ class BrowserNavigationBarViewIntegration(
5352
browserTabFragmentBinding.rootView.removeView(browserTabFragmentBinding.navigationBar)
5453
} ?: browserTabFragmentBinding.navigationBar
5554

56-
private var stateObserverJob: Job? = null
5755
private var keyboardVisibilityObserverJob: Job? = null
5856
private var navigationBarVisibilityChangeJob: Job? = null
5957

6058
init {
61-
stateObserverJob = lifecycleScope.launch {
62-
visualDesignExperimentDataStore.isExperimentEnabled.collect { isExperimentEnabled ->
63-
if (isExperimentEnabled) {
64-
onEnabled()
65-
} else {
66-
onDisabled()
67-
}
68-
}
59+
if (isExperimentEnabled) {
60+
onEnabled()
61+
} else {
62+
onDisabled()
6963
}
7064
navigationBarView.browserNavigationBarObserver = browserNavigationBarObserver
7165
}
@@ -87,11 +81,11 @@ class BrowserNavigationBarViewIntegration(
8781
}
8882

8983
fun onDestroyView() {
90-
stateObserverJob?.cancel()
9184
onDisabled()
9285
}
9386

9487
private fun onEnabled() {
88+
navigationBarView.show()
9589
// we're hiding the navigation bar when keyboard is shown,
9690
// to prevent it from being "pushed up" within the coordinator layout
9791
keyboardVisibilityObserverJob = lifecycleScope.launch {
@@ -110,6 +104,7 @@ class BrowserNavigationBarViewIntegration(
110104
}
111105

112106
private fun onDisabled() {
107+
navigationBarView.gone()
113108
keyboardVisibilityObserverJob?.cancel()
114109
}
115110
}

app/src/main/java/com/duckduckgo/app/browser/navigation/bar/view/BrowserNavigationBarViewModel.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import com.duckduckgo.app.pixels.AppPixelName
3535
import com.duckduckgo.app.statistics.pixels.Pixel
3636
import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter.FIRE_BUTTON_STATE
3737
import com.duckduckgo.app.tabs.model.TabRepository
38-
import com.duckduckgo.common.ui.experiments.visual.store.VisualDesignExperimentDataStore
3938
import com.duckduckgo.common.utils.DispatcherProvider
4039
import com.duckduckgo.di.scopes.ViewScope
4140
import javax.inject.Inject
@@ -53,7 +52,6 @@ import kotlinx.coroutines.flow.update
5352
@SuppressLint("NoLifecycleObserver")
5453
@ContributesViewModel(ViewScope::class)
5554
class BrowserNavigationBarViewModel @Inject constructor(
56-
private val visualDesignExperimentDataStore: VisualDesignExperimentDataStore,
5755
private val tabRepository: TabRepository,
5856
private val pixel: Pixel,
5957
private val dispatcherProvider: DispatcherProvider,
@@ -67,10 +65,9 @@ class BrowserNavigationBarViewModel @Inject constructor(
6765
_viewState.asStateFlow(),
6866
isCustomTab,
6967
tabRepository.flowTabs,
70-
visualDesignExperimentDataStore.isExperimentEnabled,
71-
) { state, isCustomTab, tabs, isExperimentEnabled ->
68+
) { state, isCustomTab, tabs ->
7269
state.copy(
73-
isVisible = isExperimentEnabled && !isCustomTab,
70+
isVisible = !isCustomTab,
7471
tabsCount = tabs.size,
7572
hasUnreadTabs = tabs.firstOrNull { !it.viewed } != null,
7673
)

app/src/main/java/com/duckduckgo/app/browser/senseofprotection/SenseOfProtectionExperimentImpl.kt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.duckduckgo.app.browser.senseofprotection.SenseOfProtectionToggles.Coh
2222
import com.duckduckgo.app.di.AppCoroutineScope
2323
import com.duckduckgo.app.statistics.pixels.Pixel
2424
import com.duckduckgo.browser.api.UserBrowserProperties
25+
import com.duckduckgo.common.ui.experiments.visual.store.VisualDesignExperimentDataStore
2526
import com.duckduckgo.common.utils.DispatcherProvider
2627
import com.duckduckgo.di.scopes.AppScope
2728
import com.duckduckgo.feature.toggles.api.MetricsPixel
@@ -31,6 +32,7 @@ import dagger.SingleInstanceIn
3132
import javax.inject.Inject
3233
import kotlinx.coroutines.CoroutineScope
3334
import kotlinx.coroutines.launch
35+
import timber.log.Timber
3436

3537
private const val EXISTING_USER_DAY_COUNT_THRESHOLD = 28
3638

@@ -57,28 +59,37 @@ class SenseOfProtectionExperimentImpl @Inject constructor(
5759
private val userBrowserProperties: UserBrowserProperties,
5860
private val senseOfProtectionToggles: SenseOfProtectionToggles,
5961
private val senseOfProtectionPixelsPlugin: SenseOfProtectionPixelsPlugin,
62+
private val visualDesignExperimentDataStore: VisualDesignExperimentDataStore,
6063
private val pixel: Pixel,
6164
) : SenseOfProtectionExperiment {
6265

6366
init {
6467
// enrol users in the existing user experiment if they are not already enrolled in the new user experiment
6568
appCoroutineScope.launch(dispatcherProvider.io()) {
6669
if (userBrowserProperties.daysSinceInstalled() > EXISTING_USER_DAY_COUNT_THRESHOLD) {
67-
if (!isEnrolledInNewUserExperiment()) {
70+
if (canBeEnrolledInExistingUserExperiment()) {
6871
enrollInExistingUserExperiment(cohortName = MODIFIED_CONTROL)
6972
}
7073
}
7174
}
7275
}
7376

77+
private fun canBeEnrolledInExistingUserExperiment(): Boolean {
78+
return !isEnrolledInNewUserExperiment() && !seesNewVisualDesign()
79+
}
80+
7481
override fun enrolUserInNewExperimentIfEligible(): Boolean {
75-
return if (userBrowserProperties.daysSinceInstalled() <= EXISTING_USER_DAY_COUNT_THRESHOLD) {
82+
return if (canBeEnrolledInNewUserExperiment()) {
7683
enrollInNewUserExperiment(cohortName = MODIFIED_CONTROL)
7784
} else {
7885
false
7986
}
8087
}
8188

89+
private fun canBeEnrolledInNewUserExperiment(): Boolean {
90+
return (userBrowserProperties.daysSinceInstalled() <= EXISTING_USER_DAY_COUNT_THRESHOLD) && !seesNewVisualDesign()
91+
}
92+
8293
override fun isUserEnrolledInModifiedControlCohortAndExperimentEnabled(): Boolean =
8394
getNewUserExperimentCohortName() == MODIFIED_CONTROL.cohortName && isNewUserExperimentEnabled(MODIFIED_CONTROL) ||
8495
getExistingUserExperimentCohortName() == MODIFIED_CONTROL.cohortName && isExistingUserExperimentEnabled(MODIFIED_CONTROL)
@@ -192,4 +203,10 @@ class SenseOfProtectionExperimentImpl @Inject constructor(
192203
private fun MetricsPixel.fire() = getPixelDefinitions().forEach {
193204
pixel.fire(it.pixelName, it.params)
194205
}
206+
207+
private fun seesNewVisualDesign(): Boolean {
208+
val seesNewVisualDesing = visualDesignExperimentDataStore.isExperimentEnabled.value
209+
Timber.d("VisualDesign: seesNewVisualDesign $seesNewVisualDesing")
210+
return seesNewVisualDesing
211+
}
195212
}

0 commit comments

Comments
 (0)