From f777c5c093be54da3df3933f9b1a09bb2aa2230c Mon Sep 17 00:00:00 2001 From: Noelia Alcala Date: Fri, 19 Jul 2024 17:03:15 +0100 Subject: [PATCH] Fix favorites displayed underneath Dax dialog (#4778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task/Issue URL: https://app.asana.com/0/488551667048375/1207845944313951/f ### Description Fix for not showing favorites displayed underneath the 'visit site' Dax dialog ### Steps to test this PR On each step, wait for searches and sites to fully load in the browser - [x] Fresh install - [x] Perform a search - [x] Save bookmark → Add favorite - [x] Visit a site → ⚠️ Don't dismiss the trackers onboarding CTA - [x] Save bookmark → Add favorite - [x] Open a new tab - [x] Perform a search - [x] Open a new tab - [x] Check favorites are not displayed underneath Dax dialog - [x] Tap on a site suggestion - [x] Check favorites are not displayed underneath Dax dialog before site is loaded ### UI changes | Before | After | | ------ | ----- | ![Screenshot_20240718_140440](https://github.com/user-attachments/assets/e812d811-9f02-4a87-8ae6-80948f2ff2ab)|![Screenshot 2024-07-19 at 12 37 48](https://github.com/user-attachments/assets/4f683010-0599-4380-b0ce-e420a7097d53)| --- .../com/duckduckgo/app/browser/BrowserTabViewModelTest.kt | 4 ++++ .../java/com/duckduckgo/app/browser/BrowserTabViewModel.kt | 3 +-- .../main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt b/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt index c621ba795ea3..0118907405e2 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt @@ -105,6 +105,8 @@ import com.duckduckgo.app.browser.viewstate.LoadingViewState import com.duckduckgo.app.browser.webview.SslWarningLayout.Action import com.duckduckgo.app.cta.db.DismissedCtaDao import com.duckduckgo.app.cta.model.CtaId +import com.duckduckgo.app.cta.model.CtaId.DAX_DIALOG_NETWORK +import com.duckduckgo.app.cta.model.CtaId.DAX_DIALOG_TRACKERS_FOUND import com.duckduckgo.app.cta.model.CtaId.DAX_END import com.duckduckgo.app.cta.model.DismissedCta import com.duckduckgo.app.cta.ui.Cta @@ -2366,6 +2368,7 @@ class BrowserTabViewModelTest { whenever(mockWidgetCapabilities.supportsAutomaticWidgetAdd).thenReturn(false) whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(true) whenever(mockDismissedCtaDao.exists(DAX_END)).thenReturn(true) + whenever(mockDismissedCtaDao.exists(DAX_DIALOG_TRACKERS_FOUND)).thenReturn(true) testee.refreshCta() assertNull(testee.ctaViewState.value!!.cta) assertTrue(testee.ctaViewState.value!!.daxOnboardingComplete) @@ -2378,6 +2381,7 @@ class BrowserTabViewModelTest { whenever(mockWidgetCapabilities.supportsAutomaticWidgetAdd).thenReturn(false) whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(true) whenever(mockDismissedCtaDao.exists(DAX_END)).thenReturn(true) + whenever(mockDismissedCtaDao.exists(DAX_DIALOG_NETWORK)).thenReturn(true) testee.refreshCta() assertNull(testee.ctaViewState.value!!.cta) assertTrue(testee.ctaViewState.value!!.daxOnboardingComplete) diff --git a/app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt b/app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt index bc11c910334a..c9f1bf1e7009 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt @@ -113,7 +113,6 @@ import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteEntity import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteRepository import com.duckduckgo.app.fire.fireproofwebsite.ui.AutomaticFireproofSetting.ALWAYS import com.duckduckgo.app.fire.fireproofwebsite.ui.AutomaticFireproofSetting.ASK_EVERY_TIME -import com.duckduckgo.app.global.* import com.duckduckgo.app.global.events.db.UserEventKey import com.duckduckgo.app.global.events.db.UserEventsStore import com.duckduckgo.app.global.model.PrivacyShield @@ -2442,7 +2441,7 @@ class BrowserTabViewModel @Inject constructor( ) } val isOnboardingComplete = withContext(dispatchers.io()) { - ctaViewModel.daxDialogEndShown() + ctaViewModel.areBubbleDaxDialogsCompleted() } if (isBrowserShowing && cta != null) hasCtaBeenShownForCurrentPage.set(true) ctaViewState.value = currentCtaViewState().copy( diff --git a/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt b/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt index 987b0ba9d66c..30e8eeb7dc2f 100644 --- a/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt +++ b/app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt @@ -288,7 +288,10 @@ class CtaViewModel @Inject constructor( // We only want to show New Tab when the Home CTAs from Onboarding has finished // https://app.asana.com/0/1157893581871903/1207769731595075/f - fun daxDialogEndShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_END) + fun areBubbleDaxDialogsCompleted(): Boolean { + val bubbleCtasShown = daxDialogEndShown() && (daxDialogNetworkShown() || daxDialogOtherShown() || daxDialogTrackersFoundShown()) + return bubbleCtasShown || hideTips() + } private fun daxDialogSerpShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_DIALOG_SERP) @@ -300,6 +303,8 @@ class CtaViewModel @Inject constructor( private fun daxDialogFireEducationShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_FIRE_BUTTON) + private fun daxDialogEndShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_END) + private fun pulseFireButtonShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_FIRE_BUTTON_PULSE) private fun isSerpUrl(url: String): Boolean = url.contains(OnboardingDaxDialogCta.SERP)