Skip to content

Commit 214fb7a

Browse files
committed
clean up and remove test setup
1 parent fd818ae commit 214fb7a

7 files changed

Lines changed: 27 additions & 29 deletions

File tree

app/src/main/java/com/duckduckgo/app/onboarding/CustomDuckAiOnboardingFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ interface CustomDuckAiOnboardingFeature {
3030
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
3131
fun self(): Toggle
3232

33-
@Toggle.DefaultValue(DefaultFeatureValue.INTERNAL)
33+
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
3434
fun introAnimation(): Toggle
3535
}

app/src/main/java/com/duckduckgo/app/onboarding/ui/OnboardingViewModel.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ class OnboardingViewModel @Inject constructor(
5454
val viewState = _viewState.asStateFlow()
5555

5656
fun initializePages() {
57-
// pageLayoutManager.buildPageBlueprints()
58-
pageLayoutManager.buildBrandDesignUpdatePageBlueprints()
57+
pageLayoutManager.buildPageBlueprints()
5958
}
6059

6160
fun pageCount(): Int {
@@ -101,7 +100,6 @@ class OnboardingViewModel @Inject constructor(
101100
}
102101

103102
fun initializeOnboardingSkipper() {
104-
return
105103
if (!appBuildConfig.canSkipOnboarding) return
106104

107105
// delay showing skip button until privacy config downloaded

app/src/main/java/com/duckduckgo/app/onboarding/ui/page/BrandDesignUpdateWelcomePage.kt

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
126126
private var walkingDaxDelayedRunnable: Runnable? = null
127127
private var bottomWingDelayedRunnable: Runnable? = null
128128
private var leftWingDelayedRunnable: Runnable? = null
129-
private var duckAiIntroDelayedRunnable: Runnable? = null
130129
private var welcomeFadeInAnimatorSet: AnimatorSet? = null
131130
private var comparisonChartFadeInAnimatorSet: AnimatorSet? = null
132131
private var comparisonChartDetailAnimatorSet: AnimatorSet? = null
@@ -361,7 +360,7 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
361360
}
362361
}
363362

364-
private fun playIntroAnimation() {
363+
private fun playIntroAnimation(isDuckAiIntroAnimationEnabled: Boolean) {
365364
binding.backgroundPrimary.setMinFrame(BACKGROUND_MIN_FRAME)
366365

367366
backgroundIntroAnimatorSet = buildBackgroundIntroAnimatorSet()
@@ -378,7 +377,7 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
378377
}
379378
addAnimatorListener(object : AnimatorListenerAdapter() {
380379
override fun onAnimationEnd(animation: android.animation.Animator) {
381-
if (!viewModel.viewState.value.isDuckAiIntroAnimationEnabled) {
380+
if (!isDuckAiIntroAnimationEnabled) {
382381
viewModel.onIntroAnimationFinished()
383382
}
384383
}
@@ -388,12 +387,12 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
388387
introAnimatorSet = buildIntroAnimatorSet().apply {
389388
start()
390389
doOnEnd {
391-
if (viewModel.viewState.value.isDuckAiIntroAnimationEnabled) {
390+
if (isDuckAiIntroAnimationEnabled) {
392391
prepareDuckAiIntroAnimation()
393392
binding.duckAiIntroAnimation.isVisible = true
394393
binding.duckAiIntroAnimation.addAnimatorListener(object : AnimatorListenerAdapter() {
395394
override fun onAnimationEnd(animation: Animator) {
396-
// viewModel.onIntroAnimationFinished()
395+
viewModel.onIntroAnimationFinished()
397396
}
398397
})
399398
binding.duckAiIntroAnimation.playAnimation()
@@ -402,20 +401,20 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
402401
}
403402
}
404403

405-
private fun sizeDuckAiIntroAnimationToTextSp() {
406-
val targetTextPx = TypedValue.applyDimension(
407-
TypedValue.COMPLEX_UNIT_SP,
408-
DUCK_AI_INTRO_TEXT_SP,
409-
resources.displayMetrics,
410-
)
411-
val viewHeightPx = (targetTextPx * DUCK_AI_INTRO_CANVAS_H / DUCK_AI_INTRO_TEXT_CANVAS_UNITS).toInt()
412-
binding.duckAiIntroAnimation.updateLayoutParams {
413-
height = viewHeightPx
414-
}
415-
}
416-
417404
private fun prepareDuckAiIntroAnimation() {
418405
binding.duckAiIntroAnimation.apply {
406+
// compute the view height so that it scales correctly with font size
407+
val targetTextPx = TypedValue.applyDimension(
408+
TypedValue.COMPLEX_UNIT_SP,
409+
DUCK_AI_INTRO_TEXT_SP,
410+
resources.displayMetrics,
411+
)
412+
val viewHeightPx = (targetTextPx * DUCK_AI_INTRO_CANVAS_H / DUCK_AI_INTRO_TEXT_CANVAS_UNITS).toInt()
413+
updateLayoutParams {
414+
height = viewHeightPx
415+
}
416+
417+
// set a text delegate for 'with' word so that it can use translated values
419418
setTextDelegate(
420419
TextDelegate(this).apply {
421420
setText("with", getString(R.string.onboardingWelcomeIntroWith))
@@ -427,6 +426,8 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
427426
?: Typeface.DEFAULT
428427
}
429428
})
429+
430+
// set text color
430431
val textColor = resolveOnboardingTextPrimary(context)
431432
addValueCallback(KeyPath("**", "with Duck.ai"), LottieProperty.COLOR) { textColor }
432433
addValueCallback(KeyPath("**", "with Duck.ai 2"), LottieProperty.COLOR) { textColor }
@@ -506,8 +507,6 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
506507
) {
507508
super.onViewCreated(view, savedInstanceState)
508509

509-
sizeDuckAiIntroAnimationToTextSp()
510-
511510
ViewGroupCompat.installCompatInsetsDispatch(binding.root)
512511
if (deviceInfo.isTablet()) {
513512
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, windowInsets ->
@@ -546,7 +545,7 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
546545
.flowWithLifecycle(viewLifecycleOwner.lifecycle, Lifecycle.State.STARTED)
547546
.onEach { state ->
548547
when {
549-
!state.hasPlayedIntroAnimation -> binding.root.doOnLayout { playIntroAnimation() }
548+
!state.hasPlayedIntroAnimation -> binding.root.doOnLayout { playIntroAnimation(state.isDuckAiIntroAnimationEnabled) }
550549
state.hasPlayedIntroAnimation && state.currentDialog == null -> snapToIntroEndState()
551550
isAnimating -> { /* animation in progress — ignore re-emissions from onDialogAnimationStarted() */ }
552551
state.hasAnimatedCurrentDialog -> {
@@ -607,8 +606,6 @@ class BrandDesignUpdateWelcomePage : OnboardingPageFragment(R.layout.content_onb
607606
bottomWingDelayedRunnable = null
608607
leftWingDelayedRunnable?.let { binding.leftWingAnimation?.removeCallbacks(it) }
609608
leftWingDelayedRunnable = null
610-
duckAiIntroDelayedRunnable?.let { binding.duckAiIntroAnimation.removeCallbacks(it) }
611-
duckAiIntroDelayedRunnable = null
612609
welcomeFadeInAnimatorSet?.cancel()
613610
welcomeFadeInAnimatorSet = null
614611
comparisonChartFadeInAnimatorSet?.cancel()

app/src/main/java/com/duckduckgo/app/onboardingbranddesignupdate/OnboardingBrandDesignUpdateToggles.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ interface OnboardingBrandDesignUpdateToggles {
3434
* Main toggle for the onboarding brand design update feature.
3535
* Default value: false (disabled).
3636
*/
37-
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
37+
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
3838
fun self(): Toggle
3939

4040
/**
4141
* Toggle for the brand design update variant.
4242
* Default value: false (disabled).
4343
*/
44-
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
44+
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
4545
fun brandDesignUpdate(): Toggle
4646
}

app/src/main/res/layout-land/content_onboarding_welcome_page_update.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
style="@style/Typography.DuckDuckGo.Onboarding.WelcomeTitle"
7575
android:layout_width="0dp"
7676
android:layout_height="wrap_content"
77+
android:layout_marginHorizontal="16dp"
7778
android:alpha="0"
7879
android:gravity="center"
7980
android:text="@string/onboardingWelcomeTitle"

app/src/main/res/values/donottranslate.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,7 @@
124124
<string name="preOnboardingReinstallAddressBarSearchOptionsValue">Search and Duck.ai</string>
125125
<string name="preOnboardingReinstallEditAction">Edit</string>
126126
<string name="preOnboardingReinstallStartBrowsing">Start Browsing</string>
127+
128+
<!-- Custom Duck.ai onboarding -->
129+
<string name="onboardingWelcomeIntroWith" instruction="Short connector word shown in the welcome animation, immediately before the brand name 'Duck.ai'. Example: 'with Duck.ai'.">with</string>
127130
</resources>

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@
508508

509509
<!-- New Onboarding Experience -->
510510
<string name="onboardingWelcomeTitle">"Welcome to DuckDuckGo!"</string>
511-
<string name="onboardingWelcomeIntroWith" instruction="Short connector word shown in the welcome animation, immediately before the brand name 'Duck.ai'. Example: 'with Duck.ai'.">with</string>
512511
<string name="onboardingDaxText"><![CDATA[The Internet can be kinda creepy.<br/><br/>Not to worry! Searching and browsing privately is easier than you think.]]></string>
513512
<string name="onboardingLetsDoItButton">Let\'s Do It!</string>
514513
<string name="daxNonSerpCtaText"><![CDATA[As you tap and scroll, I\'ll block pesky trackers. <br/><br/>Go ahead — keep browsing!]]></string>

0 commit comments

Comments
 (0)