Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import kotlinx.android.synthetic.main.fragment_browser_tab.*
import kotlinx.android.synthetic.main.include_add_widget_instruction_buttons.view.*
import kotlinx.android.synthetic.main.include_cta_buttons.view.*
import kotlinx.android.synthetic.main.include_dax_dialog_cta.*
import kotlinx.android.synthetic.main.include_dax_dialog_cta.view.*
import kotlinx.android.synthetic.main.include_find_in_page.*
import kotlinx.android.synthetic.main.include_new_browser_tab.*
import kotlinx.android.synthetic.main.include_omnibar_toolbar.*
Expand Down Expand Up @@ -1793,6 +1794,7 @@ class BrowserTabFragment :

ddgLogo.show()
lastSeenCtaViewState = viewState
removeNewTabLayoutClickListener()
if (viewState.cta != null) {
showCta(viewState.cta)
} else {
Expand Down Expand Up @@ -1835,6 +1837,11 @@ class BrowserTabFragment :
hideHomeCta()
hideHomeTopCta()
configuration.showCta(daxCtaContainer)
newTabLayout.setOnClickListener { daxCtaContainer.dialogTextCta.finishAnimation() }
}

private fun removeNewTabLayoutClickListener() {
newTabLayout.setOnClickListener(null)
}

private fun showHomeTopCta(configuration: HomeTopPanelCta) {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/duckduckgo/app/cta/ui/Cta.kt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ sealed class DaxDialogCta(
) : Cta, DialogCta, DaxCta {

override fun createCta(activity: FragmentActivity): DaxDialog =
TypewriterDaxDialog.newInstance(getDaxText(activity), activity.resources.getString(okButton))
TypewriterDaxDialog.newInstance(daxText = getDaxText(activity), primaryButtonText = activity.resources.getString(okButton))

override fun pixelCancelParameters(): Map<String, String> = mapOf(Pixel.PixelParameter.CTA_SHOWN to ctaPixelParam)

Expand Down Expand Up @@ -255,7 +255,6 @@ sealed class DaxDialogCta(
private const val MAX_TRACKERS_SHOWS = 2
const val SERP = "duckduckgo"
private val mainTrackerDomains = listOf("facebook", "google")
private val networkPropertyPercentages = mapOf(Pair("Google", "90%"), Pair("Facebook", "40%"))
val mainTrackerNetworks = listOf("Facebook", "Google")
}
}
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/com/duckduckgo/app/global/view/DaxDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TypewriterDaxDialog : DialogFragment(), DaxDialog {
private var primaryButtonText: String = ""
private var secondaryButtonText: String = ""
private var toolbarDimmed: Boolean = true
private var dismissible: Boolean = true
private var dismissible: Boolean = false
private var typingDelayInMs: Long = DEFAULT_TYPING_DELAY
private var showHideButton: Boolean = true

Expand Down Expand Up @@ -161,10 +161,14 @@ class TypewriterDaxDialog : DialogFragment(), DaxDialog {
dismiss()
}

if (dismissible) {
dialogContainer.setOnClickListener {
dialogContainer.setOnClickListener {
if (dismissible) {
dialogText.cancelAnimation()
dismiss()
} else {
if (!dialogText.hasAnimationFinished()) {
dialogText.finishAnimation()
}
}
}
}
Expand Down Expand Up @@ -194,7 +198,7 @@ class TypewriterDaxDialog : DialogFragment(), DaxDialog {
primaryButtonText: String,
secondaryButtonText: String? = "",
toolbarDimmed: Boolean = true,
dismissible: Boolean = true,
dismissible: Boolean = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is perfect, but I would also change line 53 in this same file. Just to keep this aligned with default property

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 changed!

typingDelayInMs: Long = DEFAULT_TYPING_DELAY,
showHideButton: Boolean = true
): TypewriterDaxDialog {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.duckduckgo.app.global.view

import android.content.Context
import android.text.Spanned
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
import kotlinx.coroutines.*
Expand All @@ -34,29 +35,40 @@ class TypeAnimationTextView @JvmOverloads constructor(
private var typingAnimationJob: Job? = null
private var delayAfterAnimationInMs: Long = 300
var typingDelayInMs: Long = 20
var textInDialog: Spanned? = null

fun startTypingAnimation(textDialog: String, isCancellable: Boolean = true, afterAnimation: () -> Unit = {}) {
val inputText = textDialog.html(context)
textInDialog = textDialog.html(context)
if (isCancellable) {
setOnClickListener {
if (typingAnimationJob?.isActive == true) {
cancelAnimation()
text = inputText
if (hasAnimationStarted()) {
finishAnimation()
afterAnimation()
}
}
}

typingAnimationJob = launch {
inputText.mapIndexed { index, _ ->
text = inputText.subSequence(0, index + 1)
delay(typingDelayInMs)
textInDialog?.let {
it.mapIndexed { index, _ ->
text = it.subSequence(0, index + 1)
delay(typingDelayInMs)
}
delay(delayAfterAnimationInMs)
afterAnimation()
}
delay(delayAfterAnimationInMs)
afterAnimation()
}
}

fun hasAnimationStarted() = typingAnimationJob?.isActive == true

fun hasAnimationFinished() = typingAnimationJob?.isCompleted == true

fun finishAnimation() {
cancelAnimation()
textInDialog?.let { text = it }
}

fun cancelAnimation() = typingAnimationJob?.cancel()

override fun onDetachedFromWindow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class WelcomePage : OnboardingPageFragment() {
private var ctaText: String = ""
private var welcomeAnimation: ViewPropertyAnimatorCompat? = null
private var typingAnimation: ViewPropertyAnimatorCompat? = null
private var welcomeAnimationFinished = false

// we use a BroadcastChannel because we don't want to emit the last value upon subscription
private val events = BroadcastChannel<WelcomePageView.Event>(1)
Expand All @@ -65,7 +66,8 @@ class WelcomePage : OnboardingPageFragment() {
super.onActivityCreated(savedInstanceState)

configureDaxCta()
beginWelcomeAnimation(ctaText)
scheduleWelcomeAnimation()
setSkipAnimationListener()
}

override fun onAttach(context: Context) {
Expand Down Expand Up @@ -145,28 +147,48 @@ class WelcomePage : OnboardingPageFragment() {
context?.let {
ctaText = it.getString(R.string.onboardingDaxText)
hiddenTextCta.text = ctaText.html(it)
dialogTextCta.textInDialog = ctaText.html(it)
dialogTextCta.setTextColor(ContextCompat.getColor(it, R.color.grayishBrown))
cardView.backgroundTintList = ContextCompat.getColorStateList(it, R.color.white)
}
triangle.setImageResource(R.drawable.ic_triangle_bubble_white)
}

private fun beginWelcomeAnimation(ctaText: String) {
private fun setSkipAnimationListener() {
longDescriptionContainer.setOnClickListener {
if (dialogTextCta.hasAnimationStarted()) {
finishTypingAnimation()
} else if (!welcomeAnimationFinished) {
welcomeAnimation?.cancel()
scheduleWelcomeAnimation(0L)
}
welcomeAnimationFinished = true
}
}

private fun scheduleWelcomeAnimation(startDelay: Long = ANIMATION_DELAY) {
welcomeAnimation = ViewCompat.animate(welcomeContent as View)
.alpha(MIN_ALPHA)
.setDuration(ANIMATION_DURATION)
.setStartDelay(ANIMATION_DELAY)
.setStartDelay(startDelay)
.withEndAction {
typingAnimation = ViewCompat.animate(daxCtaContainer)
.alpha(MAX_ALPHA)
.setDuration(ANIMATION_DURATION)
.withEndAction {
welcomeAnimationFinished = true
dialogTextCta.startTypingAnimation(ctaText)
setPrimaryCtaListenerAfterWelcomeAlphaAnimation()
}
}
}

private fun finishTypingAnimation() {
welcomeAnimation?.cancel()
dialogTextCta.finishAnimation()
setPrimaryCtaListenerAfterWelcomeAlphaAnimation()
}

private fun setPrimaryCtaListenerAfterWelcomeAlphaAnimation() {
primaryCta.setOnClickListener { event(WelcomePageView.Event.OnPrimaryCtaClicked) }
}
Expand Down
75 changes: 37 additions & 38 deletions app/src/main/res/drawable/ic_dax_icon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
~ Copyright (c) 2019 DuckDuckGo
~ Copyright (c) 2021 DuckDuckGo
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -14,41 +14,40 @@
~ limitations under the License.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="54dp"
android:height="54dp"
android:viewportWidth="54"
android:viewportHeight="54">
<path
android:pathData="M27,27m-27,0a27,27 0,1 1,54 0a27,27 0,1 1,-54 0"
android:fillColor="#FFF"
android:fillType="evenOdd"/>
<path
android:pathData="M27,2.314c-13.653,0 -24.686,11.036 -24.686,24.693 0,11.218 7.497,20.73 17.737,23.717 -1.28,-6.28 -4.998,-23.29 -5.79,-28.046 -0.853,-4.878 0,-8.353 3.291,-10.06 1.158,-0.61 2.743,-1.036 4.51,-1.22 -2.132,-0.975 -4.753,-1.34 -7.13,-1.097 0,-1.036 1.767,-0.975 2.438,-1.402 -0.427,-0.061 -1.524,-1.037 -2.012,-1.097 2.987,-0.55 6.217,0 8.838,1.402 1.402,0.731 2.377,1.524 2.987,2.378 1.585,0.304 2.987,0.853 3.9,1.768 2.744,2.804 5.243,9.145 4.207,12.803 -0.305,1.037 -0.976,1.768 -1.829,2.378 -1.646,1.22 -1.341,-1.341 -5.425,1.28 -0.487,0.305 -0.487,2.927 -0.67,3.537 -0.854,3.475 1.097,8.84 2.986,12.681a241.88,241.88 0,0 0,2.56 4.939c10.789,-2.622 18.774,-12.377 18.774,-23.961C51.686,13.35 40.653,2.314 27,2.314z"
android:fillColor="#DE5833"
android:fillType="nonZero"/>
<path
android:pathData="M21.392,11.52c-1.402,-0.426 -3.291,-0.67 -5.242,-0.67 -0.67,0 -1.28,0 -1.828,0.061h-0.061v-0.061c0,-0.305 0.244,-1.22 1.524,-1.524l-0.366,0.244c-0.305,0.183 -0.427,0.365 -0.427,0.61 0.427,-0.062 0.915,-0.062 1.402,-0.062 2.012,0 4.023,0.427 5.73,1.159l0.183,0.122h-0.244a2.19,2.19 0,0 1,-0.67 0.122zM18.65,50.236a811.67,811.67 0,0 0,-1.585 -7.255c-1.524,-7.195 -3.414,-16.157 -3.962,-19.388 -0.853,-4.756 0.792,-8.78 3.9,-10.67l-0.182,0.244c-2.5,1.707 -3.291,4.816 -2.438,9.511 0.61,3.536 2.865,13.962 4.45,21.583 0.548,2.56 1.28,6.28 1.28,6.463 -0.244,-0.061 -1.463,-0.427 -1.463,-0.488zM16.882,9.143c-0.244,-0.122 -0.488,-0.183 -0.792,-0.305 -0.671,-0.305 -1.707,-0.793 -1.707,-0.793 0.183,-0.06 0.487,-0.183 1.28,-0.304 0.305,0.06 0.366,0.365 0.731,0.61 0.366,0.243 0.732,0.487 0.915,0.487h0.182l-0.121,0.061c-0.061,0.122 -0.244,0.183 -0.488,0.244z"
android:fillColor="#CCC"
android:fillType="nonZero"/>
<path
android:pathData="M27.792,44.261s-6.826,-3.597 -6.887,-2.134c-0.122,1.464 0,7.5 0.792,7.926 0.793,0.427 6.461,-2.926 6.461,-2.926l-0.366,-2.866zM30.413,44.017s4.633,-3.536 5.669,-3.292c1.036,0.244 1.219,7.5 0.366,7.804 -0.915,0.305 -6.218,-1.83 -6.218,-1.83l0.183,-2.682z"
android:fillColor="#65BC46"
android:fillType="nonZero"/>
<path
android:pathData="M26.147,44.627c0,2.378 -0.366,3.414 0.67,3.597 1.036,0.244 2.926,0 3.657,-0.427 0.67,-0.426 0.122,-3.536 -0.122,-4.085 -0.243,-0.548 -4.205,-0.121 -4.205,0.915z"
android:fillColor="#43A244"
android:fillType="nonZero"/>
<path
android:pathData="M26.573,44.078c0,2.378 -0.365,3.415 0.67,3.597 1.037,0.244 2.927,0 3.597,-0.426 0.67,-0.427 0.122,-3.537 -0.122,-4.085 -0.183,-0.549 -4.145,-0.122 -4.145,0.914z"
android:fillColor="#65BC46"
android:fillType="nonZero"/>
<path
android:pathData="M25.598,30.055c0.183,-1.097 3.048,-3.17 5.06,-3.292 2.01,-0.122 2.681,-0.122 4.327,-0.488 1.706,-0.427 6.034,-1.463 7.253,-2.073 1.22,-0.548 6.34,0.305 2.743,2.256 -1.585,0.854 -5.73,2.5 -8.777,3.353 -2.987,0.915 -4.815,-0.853 -5.79,0.61 -0.793,1.159 -0.184,2.805 3.413,3.11 4.815,0.426 9.508,-2.195 9.996,-0.793 0.487,1.402 -4.145,3.11 -7.01,3.17 -2.864,0.061 -8.594,-1.89 -9.447,-2.5 -0.854,-0.487 -2.012,-1.89 -1.768,-3.353z"
android:fillColor="#FDD20A"
android:fillType="nonZero"/>
<path
android:pathData="M19.99,21.215c1.037,0 1.829,0.792 1.829,1.829 0,1.036 -0.792,1.829 -1.829,1.829 -0.975,0 -1.828,-0.854 -1.828,-1.83 0,-1.036 0.792,-1.828 1.828,-1.828zM20.844,21.946a0.48,0.48 0,0 0,-0.488 0.488c0,0.244 0.183,0.427 0.488,0.488a0.48,0.48 0,0 0,0.487 -0.488,0.48 0.48,0 0,0 -0.487,-0.488zM30.657,21.946c0,-0.853 0.732,-1.585 1.585,-1.585s1.585,0.732 1.585,1.585c0,0.854 -0.732,1.586 -1.585,1.586a1.574,1.574 0,0 1,-1.585 -1.586zM32.486,21.398c0,0.244 0.183,0.426 0.426,0.426a0.417,0.417 0,0 0,0.427 -0.426,0.417 0.417,0 0,0 -0.427,-0.427 0.417,0.417 0,0 0,-0.426 0.427zM20.539,17.74s-1.402,-0.61 -2.743,0.243c-1.34,0.854 -1.28,1.708 -1.28,1.708s-0.731,-1.586 1.158,-2.378c1.89,-0.793 2.865,0.427 2.865,0.427zM33.156,17.618s-0.975,-0.55 -1.767,-0.55c-1.585,0 -2.012,0.732 -2.012,0.732s0.244,-1.646 2.255,-1.34c1.158,0.182 1.524,1.158 1.524,1.158z"
android:fillColor="#2D4F8E"
android:fillType="nonZero"/>
<vector android:height="54dp" android:viewportHeight="380"
android:viewportWidth="380" android:width="54dp"
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#DE5833" android:fillType="evenOdd" android:pathData="M190,380C294.934,380 380,294.934 380,190C380,85.066 294.934,0 190,0C85.066,0 0,85.066 0,190C0,294.934 85.066,380 190,380Z"/>
<group>
<clip-path android:fillType="evenOdd" android:pathData="M189.999,354.665C280.942,354.665 354.665,280.942 354.665,189.999C354.665,99.056 280.942,25.332 189.999,25.332C99.056,25.332 25.332,99.056 25.332,189.999C25.332,280.942 99.056,354.665 189.999,354.665Z"/>
<path android:fillColor="#D5D7D8" android:fillType="evenOdd" android:pathData="M225.236,359.608C217.287,344.155 209.687,329.936 204.969,320.531C192.429,295.42 179.826,260.016 185.557,237.185C186.602,233.036 173.746,83.57 164.657,78.756C154.556,73.373 132.611,66.28 121.242,64.38C113.326,63.113 111.521,65.33 108.196,65.836C111.331,66.153 126.246,73.5 129.127,73.911C126.246,75.875 117.727,73.848 112.281,76.255C109.526,77.521 107.467,82.208 107.531,84.425C123.047,82.841 147.304,84.393 161.681,90.758C150.249,92.056 132.896,93.513 125.422,97.44C103.762,108.84 94.199,135.535 99.899,167.518C105.567,199.438 130.679,315.876 138.691,354.763C146.671,393.618 238.472,385.48 225.204,359.608H225.236Z"/>
<path android:fillColor="#ffffff" android:pathData="M192.47,231.835C186.77,254.666 199.31,290.038 211.882,315.181C216.105,323.581 222.623,335.84 229.636,349.413C213.278,353.466 173.59,359.141 145.698,349.413C137.718,310.621 112.607,194.151 106.875,162.168C101.175,130.185 106.875,107.353 128.598,95.953C136.04,92.026 146.68,89.176 158.08,87.91C143.703,81.513 126.667,79.043 111.087,80.626C111.023,74.039 122.645,74.42 127.015,71.443C124.133,71.031 116.977,64.571 113.81,64.255C133.573,60.865 153.903,64.07 171.665,73.374C180.722,78.219 187.118,83.413 191.077,88.859C201.4,90.823 210.52,94.56 216.473,100.513C234.777,118.785 251.117,160.553 244.277,184.556C242.345,191.206 237.943,196.051 232.433,200.073C221.73,207.863 223.63,191.048 196.998,208.465C193.547,210.713 193.547,227.686 192.47,231.835Z"/>
</group>
<path android:fillColor="#2D4F8E" android:fillType="evenOdd" android:pathData="M143.994,175.781C150.622,175.781 155.996,170.407 155.996,163.779C155.996,157.151 150.622,151.777 143.994,151.777C137.366,151.777 131.992,157.151 131.992,163.779C131.992,170.407 137.366,175.781 143.994,175.781Z"/>
<path android:fillColor="#ffffff" android:fillType="evenOdd" android:pathData="M149.334,162.896C151.048,162.896 152.437,161.507 152.437,159.793C152.437,158.079 151.048,156.689 149.334,156.689C147.62,156.689 146.23,158.079 146.23,159.793C146.23,161.507 147.62,162.896 149.334,162.896Z"/>
<path android:fillColor="#2D4F8E" android:fillType="evenOdd" android:pathData="M224.159,166.941C229.843,166.941 234.451,162.333 234.451,156.649C234.451,150.965 229.843,146.357 224.159,146.357C218.475,146.357 213.867,150.965 213.867,156.649C213.867,162.333 218.475,166.941 224.159,166.941Z"/>
<path android:fillColor="#ffffff" android:fillType="evenOdd" android:pathData="M228.754,155.896C230.223,155.896 231.414,154.705 231.414,153.236C231.414,151.767 230.223,150.576 228.754,150.576C227.285,150.576 226.094,151.767 226.094,153.236C226.094,154.705 227.285,155.896 228.754,155.896Z"/>
<path android:fillType="evenOdd" android:pathData="M147.431,129.041C147.431,129.041 138.375,124.924 129.603,130.466C120.831,135.976 121.148,141.613 121.148,141.613C121.148,141.613 116.493,131.226 128.906,126.128C141.351,121.061 147.431,129.041 147.431,129.041Z">
<aapt:attr name="android:fillColor">
<gradient android:endX="147.431" android:endY="141.616"
android:startX="120.293" android:startY="141.616" android:type="linear">
<item android:color="#FF6176B9" android:offset="0.01"/>
<item android:color="#FF394A9F" android:offset="0.69"/>
</gradient>
</aapt:attr>
</path>
<path android:fillType="evenOdd" android:pathData="M230.376,128.217C230.376,128.217 223.885,124.512 218.818,124.575C208.463,124.702 205.645,129.262 205.645,129.262C205.645,129.262 207.386,118.368 220.623,120.553C224.939,121.343 228.588,124.21 230.376,128.217Z">
<aapt:attr name="android:fillColor">
<gradient android:endX="230.376" android:endY="129.264"
android:startX="205.645" android:startY="129.264" android:type="linear">
<item android:color="#FF6176B9" android:offset="0.01"/>
<item android:color="#FF394A9F" android:offset="0.69"/>
</gradient>
</aapt:attr>
</path>
<path android:fillColor="#FDD20A" android:fillType="evenOdd" android:pathData="M180.715,210.046C181.918,202.763 200.665,189.051 213.965,188.196C227.265,187.373 231.381,187.563 242.465,184.903C253.58,182.275 282.175,175.15 290.06,171.476C297.976,167.835 331.543,173.281 307.888,186.486C297.66,192.218 270.078,202.731 250.35,208.621C230.653,214.511 218.715,202.985 212.16,212.675C206.966,220.37 211.115,230.915 234.643,233.1C266.436,236.045 296.9,218.786 300.256,227.97C303.613,237.153 272.96,248.553 254.276,248.933C235.593,249.281 197.973,236.583 192.336,232.656C186.668,228.761 179.163,219.578 180.715,210.046Z"/>
<path android:fillColor="#65BC46" android:fillType="evenOdd" android:pathData="M249.435,274.962C242.722,273.473 212.195,296.558 212.195,296.558H212.227L210.802,314.292C210.802,314.292 245.698,328.573 251.652,326.357C257.605,324.077 256.117,276.482 249.435,274.962ZM149.723,283.894C150.452,274.236 195.102,298.081 195.102,298.081L195.133,298.049L197.35,316.669C197.35,316.669 160.142,338.963 154.917,335.986C149.723,333.009 148.963,293.584 149.723,283.894Z"/>
<path android:fillColor="#43A244" android:fillType="evenOdd" android:pathData="M184.309,300.582C184.309,316.194 182.061,322.907 188.742,324.396C195.456,325.884 208.091,324.396 212.587,321.419C217.021,318.442 213.316,298.366 211.827,294.629C210.339,290.892 184.277,293.869 184.277,300.582H184.309Z"/>
<path android:fillColor="#65BC46" android:fillType="evenOdd" android:pathData="M187.161,297.131C187.161,312.743 184.912,319.425 191.594,320.913C198.276,322.433 210.911,320.913 215.407,317.936C219.872,314.96 216.167,294.883 214.679,291.146C213.191,287.41 187.129,290.418 187.129,297.1L187.161,297.131Z"/>
<path android:fillColor="#ffffff" android:fillType="evenOdd" android:pathData="M190.006,349.32C277.998,349.32 349.329,277.988 349.329,189.997C349.329,102.005 277.998,30.674 190.006,30.674C102.015,30.674 30.684,102.005 30.684,189.997C30.684,277.988 102.015,349.32 190.006,349.32ZM190.006,364.163C286.196,364.163 364.173,286.186 364.173,189.997C364.173,93.807 286.196,15.83 190.006,15.83C93.817,15.83 15.84,93.807 15.84,189.997C15.84,286.186 93.817,364.163 190.006,364.163Z"/>
</vector>
Loading