diff --git a/app/src/main/java/com/duckduckgo/app/tabs/model/TabDataRepository.kt b/app/src/main/java/com/duckduckgo/app/tabs/model/TabDataRepository.kt index b979794f0c50..70f08a2dff60 100644 --- a/app/src/main/java/com/duckduckgo/app/tabs/model/TabDataRepository.kt +++ b/app/src/main/java/com/duckduckgo/app/tabs/model/TabDataRepository.kt @@ -35,7 +35,7 @@ import com.duckduckgo.di.scopes.AppScope import dagger.SingleInstanceIn import io.reactivex.Scheduler import io.reactivex.schedulers.Schedulers -import java.util.* +import java.util.UUID import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow @@ -186,14 +186,6 @@ class TabDataRepository @Inject constructor( } } - override suspend fun setWasAnnouncementDismissed(wasDismissed: Boolean) { - tabSwitcherDataStore.setWasAnnouncementDismissed(wasDismissed) - } - - override suspend fun setAnnouncementDisplayCount(displayCount: Int) { - tabSwitcherDataStore.setAnnouncementDisplayCount(displayCount) - } - override suspend fun setTabLayoutType(layoutType: LayoutType) { tabSwitcherDataStore.setTabLayoutType(layoutType) } diff --git a/app/src/main/java/com/duckduckgo/app/tabs/store/TabSwitcherDataStore.kt b/app/src/main/java/com/duckduckgo/app/tabs/store/TabSwitcherDataStore.kt index 85d3ab041f8b..587bdb144254 100644 --- a/app/src/main/java/com/duckduckgo/app/tabs/store/TabSwitcherDataStore.kt +++ b/app/src/main/java/com/duckduckgo/app/tabs/store/TabSwitcherDataStore.kt @@ -18,9 +18,7 @@ package com.duckduckgo.app.tabs.store import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences -import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit -import androidx.datastore.preferences.core.intPreferencesKey import androidx.datastore.preferences.core.stringPreferencesKey import com.duckduckgo.app.tabs.model.TabSwitcherData import com.duckduckgo.app.tabs.model.TabSwitcherData.LayoutType @@ -35,8 +33,6 @@ interface TabSwitcherDataStore { val data: Flow suspend fun setUserState(userState: UserState) - suspend fun setWasAnnouncementDismissed(wasDismissed: Boolean) - suspend fun setAnnouncementDisplayCount(displayCount: Int) suspend fun setTabLayoutType(layoutType: LayoutType) } @@ -46,16 +42,12 @@ class TabSwitcherPrefsDataStore @Inject constructor( ) : TabSwitcherDataStore { companion object { const val KEY_USER_STATE = "KEY_USER_STATE" - const val KEY_WAS_ANNOUNCEMENT_DISMISSED = "KEY_WAS_ANNOUNCEMENT_DISMISSED" - const val KEY_ANNOUNCEMENT_DISPLAY_COUNT = "KEY_ANNOUNCEMENT_DISPLAY_COUNT" const val KEY_LAYOUT_TYPE = "KEY_LAYOUT_TYPE" } override val data: Flow = store.data.map { preferences -> TabSwitcherData( userState = UserState.valueOf(preferences[stringPreferencesKey(KEY_USER_STATE)] ?: UserState.UNKNOWN.name), - wasAnnouncementDismissed = preferences[booleanPreferencesKey(KEY_WAS_ANNOUNCEMENT_DISMISSED)] ?: false, - announcementDisplayCount = preferences[intPreferencesKey(KEY_ANNOUNCEMENT_DISPLAY_COUNT)] ?: 0, layoutType = LayoutType.valueOf(preferences[stringPreferencesKey(KEY_LAYOUT_TYPE)] ?: LayoutType.GRID.name), ) } @@ -66,18 +58,6 @@ class TabSwitcherPrefsDataStore @Inject constructor( } } - override suspend fun setWasAnnouncementDismissed(wasDismissed: Boolean) { - store.edit { preferences -> - preferences[booleanPreferencesKey(KEY_WAS_ANNOUNCEMENT_DISMISSED)] = wasDismissed - } - } - - override suspend fun setAnnouncementDisplayCount(displayCount: Int) { - store.edit { preferences -> - preferences[intPreferencesKey(KEY_ANNOUNCEMENT_DISPLAY_COUNT)] = displayCount - } - } - override suspend fun setTabLayoutType(layoutType: LayoutType) { store.edit { preferences -> preferences[stringPreferencesKey(KEY_LAYOUT_TYPE)] = layoutType.name diff --git a/app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherActivity.kt b/app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherActivity.kt index 80c394611b54..fb5055b1e943 100644 --- a/app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherActivity.kt +++ b/app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherActivity.kt @@ -21,8 +21,6 @@ import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem -import android.view.View -import android.widget.ImageButton import android.widget.TextView import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR @@ -126,8 +124,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine private lateinit var tabsRecycler: RecyclerView private lateinit var tabItemDecorator: TabItemDecorator private lateinit var toolbar: Toolbar - private lateinit var announcement: View - private lateinit var announcementCloseButton: ImageButton private var layoutTypeMenuItem: MenuItem? = null private var layoutType: LayoutType? = null @@ -144,7 +140,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine configureRecycler() configureObservers() configureOnBackPressedListener() - configureAnnouncementBanner() } override fun onSaveInstanceState(outState: Bundle) { @@ -153,12 +148,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine outState.putBoolean(KEY_FIRST_TIME_LOADING, firstTimeLoadingTabsList) } - private fun configureAnnouncementBanner() { - announcementCloseButton.setOnClickListener { - viewModel.onFeatureAnnouncementCloseButtonTapped() - } - } - private fun extractIntentExtras() { selectedTabId = intent.getStringExtra(EXTRA_KEY_SELECTED_TAB) } @@ -166,8 +155,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine private fun configureViewReferences() { tabsRecycler = findViewById(R.id.tabsRecycler) toolbar = findViewById(R.id.toolbar) - announcement = findViewById(R.id.tabFeatureAnnouncement) - announcementCloseButton = findViewById(R.id.close) } private fun configureRecycler() { @@ -218,26 +205,11 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine } } - lifecycleScope.launch { - viewModel.isFeatureAnnouncementVisible.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED).collect { - updateFeatureAnnouncement(it) - } - } - viewModel.command.observe(this) { processCommand(it) } } - private fun updateFeatureAnnouncement(isVisible: Boolean) { - if (isVisible && !this@TabSwitcherActivity.isFinishing) { - viewModel.onTabFeatureAnnouncementDisplayed() - announcement.show() - } else { - announcement.gone() - } - } - private fun updateLayoutType(layoutType: LayoutType) { tabsRecycler.hide() diff --git a/app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModel.kt b/app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModel.kt index 54ec152efbac..9071103b364e 100644 --- a/app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModel.kt +++ b/app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModel.kt @@ -26,21 +26,17 @@ import com.duckduckgo.app.browser.session.WebViewSessionStorage import com.duckduckgo.app.pixels.AppPixelName import com.duckduckgo.app.statistics.pixels.Pixel import com.duckduckgo.app.statistics.pixels.Pixel.PixelType.DAILY -import com.duckduckgo.app.statistics.store.StatisticsDataStore import com.duckduckgo.app.tabs.model.TabEntity import com.duckduckgo.app.tabs.model.TabRepository import com.duckduckgo.app.tabs.model.TabSwitcherData.LayoutType.GRID import com.duckduckgo.app.tabs.model.TabSwitcherData.LayoutType.LIST -import com.duckduckgo.app.tabs.model.TabSwitcherData.UserState import com.duckduckgo.common.utils.DispatcherProvider import com.duckduckgo.common.utils.SingleLiveEvent import com.duckduckgo.di.scopes.ActivityScope import javax.inject.Inject import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch @@ -51,33 +47,13 @@ class TabSwitcherViewModel @Inject constructor( private val adClickManager: AdClickManager, private val dispatcherProvider: DispatcherProvider, private val pixel: Pixel, - private val statisticsDataStore: StatisticsDataStore, ) : ViewModel() { - companion object { - const val MAX_ANNOUNCEMENT_DISPLAY_COUNT = 3 - const val REINSTALL_VARIANT = "ru" - } - val tabs: LiveData> = tabRepository.liveTabs val activeTab = tabRepository.liveSelectedTab val deletableTabs: LiveData> = tabRepository.flowDeletableTabs.asLiveData( context = viewModelScope.coroutineContext, ) - private var announcementDisplayCount: Int = 0 - private var isBannerAlreadyVisible: Boolean = false - val isFeatureAnnouncementVisible = combine(tabRepository.tabSwitcherData, tabRepository.flowTabs) { data, tabs -> - val isVisible = - announcementDisplayCount < MAX_ANNOUNCEMENT_DISPLAY_COUNT && - !data.wasAnnouncementDismissed && - (data.userState == UserState.EXISTING || statisticsDataStore.variant == REINSTALL_VARIANT) && - (tabs.size > 1 || isBannerAlreadyVisible) - isBannerAlreadyVisible = isVisible - isVisible - } - .onStart { announcementDisplayCount = tabRepository.tabSwitcherData.first().announcementDisplayCount } - .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), false) - val layoutType = tabRepository.tabSwitcherData .map { it.layoutType } .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null) @@ -173,22 +149,7 @@ class TabSwitcherViewModel @Inject constructor( } } - fun onTabFeatureAnnouncementDisplayed() { - viewModelScope.launch(dispatcherProvider.io()) { - val data = tabRepository.tabSwitcherData.first() - tabRepository.setAnnouncementDisplayCount(data.announcementDisplayCount + 1) - } - } - - fun onFeatureAnnouncementCloseButtonTapped() { - dismissFeatureAnnouncementBanner() - } - fun onTabDraggingStarted() { - if (isBannerAlreadyVisible) { - dismissFeatureAnnouncementBanner() - } - viewModelScope.launch(dispatcherProvider.io()) { val params = mapOf("userState" to tabRepository.tabSwitcherData.first().userState.name) pixel.fire(AppPixelName.TAB_MANAGER_REARRANGE_TABS_DAILY, parameters = params, encodedParameters = emptyMap(), DAILY) @@ -209,10 +170,4 @@ class TabSwitcherViewModel @Inject constructor( tabRepository.setTabLayoutType(newLayoutType) } } - - private fun dismissFeatureAnnouncementBanner() { - viewModelScope.launch(dispatcherProvider.io()) { - tabRepository.setWasAnnouncementDismissed(true) - } - } } diff --git a/app/src/main/res/layout/content_tab_switcher.xml b/app/src/main/res/layout/content_tab_switcher.xml index 997ec151b5b0..433a0ed1b9e5 100644 --- a/app/src/main/res/layout/content_tab_switcher.xml +++ b/app/src/main/res/layout/content_tab_switcher.xml @@ -13,61 +13,22 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - - - - - - - - - - - - - \ No newline at end of file + diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 31f15e248382..10d3036f3854 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -111,7 +111,6 @@ Разделът е затворен Отмяна Изтеглени файлове - Вече можете да плъзгате и пускате разделите, за да ги пренаредите! Изглед в списък Изглед в решетка diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 5a34accdf57d..51971de2f25e 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -111,7 +111,6 @@ Karta zavřená Vrátit Stahování - Teď můžeš přetažením karet změnit jejich pořadí. Zobrazení seznamu Zobrazení mřížky diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 822d1fe4e70a..49c68ffbaa65 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -111,7 +111,6 @@ Fanen er lukket Fortryd Downloads - Du kan nu trække og slippe dine faner for at omarrangere dem! Listevisning Gittervisning diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 932adf355bb6..b58bc65daff4 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -111,7 +111,6 @@ Tab geschlossen Rückgängig machen Downloads - Du kannst deine Tabs jetzt per Drag-and-Drop verschieben, um sie neu anzuordnen! Listenansicht Gitteransicht diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 8b77fab8c091..5921ba91c856 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -111,7 +111,6 @@ Η καρτέλα έκλεισε Αναίρεση Λήψεις - Μπορείτε τώρα να κάνετε μεταφορά και απόθεση στις καρτέλες σας για να τις αναδιατάξετε! Προβολή λίστας Προβολή πλέγματος diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 7733125c8f10..dfbbf362711e 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -111,7 +111,6 @@ Pestaña cerrada Deshacer Descargas - ¡Ahora puedes arrastrar y soltar las pestañas para reordenarlas! Vista de lista Vista de cuadrícula diff --git a/app/src/main/res/values-et/strings.xml b/app/src/main/res/values-et/strings.xml index db3bb1cee6ea..ec01b6bbf2f9 100644 --- a/app/src/main/res/values-et/strings.xml +++ b/app/src/main/res/values-et/strings.xml @@ -111,7 +111,6 @@ Vaheleht on suletud Võta tagasi Allalaadimised - Nüüd saad oma vahekaarte lohistades ümber järjestada! Loendivaade Võrgustikuvaade diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index ade1ad41ab00..64d15a918101 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -111,7 +111,6 @@ Välilehti suljettu Kumoa Lataukset - Voit nyt järjestää välilehdet uudelleen vetämällä ja pudottamalla! Luettelonäkymä Ruudukkonäkymä diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f40dae8f7ce0..2f779d6dfcee 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -111,7 +111,6 @@ Onglet fermé Annuler Téléchargements - Vous pouvez désormais faire glisser et déposer vos onglets pour les réorganiser ! Vue liste Vue grille diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index dc330427a602..3d7ac4b1a045 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -111,7 +111,6 @@ Kartica je zatvorena Poništi Preuzimanja - Sada možeš povući i ispustiti kartice i promijeniti njihov redoslijed! Prikaz popisa Tablični prikaz diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 53cfcf4a174e..e2a8c1a628dc 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -111,7 +111,6 @@ Lap bezárva Visszavonás Letöltések - Mostantól átrendezheted a lapok sorrendjét a fogd és vidd funkcióval! Listanézet Rácsnézet diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 99b2b352bde9..cf2749601981 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -111,7 +111,6 @@ Scheda chiusa Annulla Download - Ora puoi trascinare e rilasciare le tue schede per riordinarle. Vista elenco Vista a griglia diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 298c870191b7..9cefec68d338 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -111,7 +111,6 @@ Skirtukas uždarytas Anuliuoti Atsisiuntimai - Dabar galite nutempti skirtukus, kad juos pertvarkytumėte! Sąrašo rodinys Tinklelio vaizdas diff --git a/app/src/main/res/values-lv/strings.xml b/app/src/main/res/values-lv/strings.xml index f36e400d115d..21a2f5813ff6 100644 --- a/app/src/main/res/values-lv/strings.xml +++ b/app/src/main/res/values-lv/strings.xml @@ -111,7 +111,6 @@ Cilne ir aizvērta Atsaukt Lejupielādes - Tagad vari vilkt un nomest cilnes, lai tās pārkārtotu! Saraksta skats Režģa skats diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index a881a5e67da3..6c0225ee5eeb 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -111,7 +111,6 @@ Fane lukket Angre Nedlastinger - Du kan nå dra og slippe fanene for å omorganisere dem! Listevisning Rutenettvisning diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index b8754a351120..2d61dcb50b9c 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -111,7 +111,6 @@ Tabblad gesloten Ongedaan maken Downloads - Je kunt nu je tabbladen slepen en neerzetten om ze opnieuw te ordenen! Lijstweergave Rasterweergave diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 443f06609ca6..6b7cfc816047 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -111,7 +111,6 @@ Karta zamknięta Cofnij Pobrane - Możesz teraz przeciągać i upuszczać karty, aby zmienić ich kolejność! Widok listy Widok siatki diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 28231d06a69a..3e19814cd213 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -111,7 +111,6 @@ Separador fechado Anular Transferências - Agora podes arrastar e largar os teus separadores para os reordenares! Vista de lista Vista de grelha diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index ca8071c573ed..828e30005161 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -111,7 +111,6 @@ Filă închisă Anulează Descărcări - Acum poți glisa și fixa filele pentru a le reordona! Vizualizare listă Vizualizare grilă diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index faad43263800..7382450e6c8d 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -111,7 +111,6 @@ Вкладка закрыта Отменить Загрузки - Теперь порядок вкладок можно менять путем перетаскивания. В виде списка В виде сетки diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 6c4aeb7170da..5895166e4e08 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -111,7 +111,6 @@ Karta bola zatvorená Vrátenie späť Stiahnuté - Teraz môžete karty potiahnuť a presunúť, a zmeniť ich poradie! Zobrazenie zoznamu Zobrazenie mriežky diff --git a/app/src/main/res/values-sl/strings.xml b/app/src/main/res/values-sl/strings.xml index 23428e232741..11a2e4e95e31 100644 --- a/app/src/main/res/values-sl/strings.xml +++ b/app/src/main/res/values-sl/strings.xml @@ -111,7 +111,6 @@ Zavihek zaprt Prekliči spremembe Prenosi - Zdaj lahko zavihke povlečete in spustite, da jih preuredite! Pogled seznama Mrežni pogled diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 891eab0b465d..70d8f27306e4 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -111,7 +111,6 @@ Fliken är stängd Återställ Nerladdningar - Du kan nu dra och släppa dina flikar för att ordna om dem! Listvy Rutnätsvy diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 561d8a5e5844..9ef05c0a9384 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -111,7 +111,6 @@ Sekme kapatıldı Geri al İndirilenler - Artık sekmelerinizi yeniden sıralamak için sürükleyip bırakabilirsiniz! Liste görünümü Izgara görünümü diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 860261f52e96..f985e8a883eb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -16,8 +16,8 @@ - DuckDuckGo - DuckDuckGo + DuckDuckGo + DuckDuckGo DuckDuckGo logo Privacy, simplified Yes @@ -110,7 +110,6 @@ Tab closed Undo Downloads - You can now drag and drop your tabs to reorder them! List view Grid view diff --git a/app/src/test/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModelTest.kt b/app/src/test/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModelTest.kt index dc049e496f54..8e6904cba61f 100644 --- a/app/src/test/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModelTest.kt +++ b/app/src/test/java/com/duckduckgo/app/tabs/ui/TabSwitcherViewModelTest.kt @@ -21,7 +21,6 @@ package com.duckduckgo.app.tabs.ui import androidx.arch.core.executor.testing.InstantTaskExecutorRule import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Observer -import app.cash.turbine.test import com.duckduckgo.adclick.api.AdClickManager import com.duckduckgo.app.browser.session.WebViewSessionStorage import com.duckduckgo.app.pixels.AppPixelName @@ -33,6 +32,7 @@ import com.duckduckgo.app.tabs.model.TabRepository import com.duckduckgo.app.tabs.model.TabSwitcherData import com.duckduckgo.app.tabs.model.TabSwitcherData.LayoutType.GRID import com.duckduckgo.app.tabs.model.TabSwitcherData.LayoutType.LIST +import com.duckduckgo.app.tabs.model.TabSwitcherData.UserState.EXISTING import com.duckduckgo.app.tabs.model.TabSwitcherData.UserState.NEW import com.duckduckgo.app.tabs.ui.TabSwitcherViewModel.Command import com.duckduckgo.common.test.CoroutineTestRule @@ -47,8 +47,6 @@ import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Rule import org.junit.Test @@ -94,7 +92,7 @@ class TabSwitcherViewModelTest { private val repoDeletableTabs = Channel>() private val tabs = MutableLiveData>() - private val tabSwitcherData = TabSwitcherData(NEW, false, 0, GRID) + private val tabSwitcherData = TabSwitcherData(NEW, GRID) private val flowTabs = flowOf(listOf(TabEntity("1", position = 1), TabEntity("2", position = 2))) @Before @@ -122,7 +120,6 @@ class TabSwitcherViewModelTest { mockAdClickManager, coroutinesTestRule.testDispatcherProvider, mockPixel, - statisticsDataStore, ) testee.command.observeForever(mockCommandObserver) } @@ -299,29 +296,16 @@ class TabSwitcherViewModelTest { } @Test - fun whenOnDraggingStartedAnnouncementDismissedAndThePixelSent() = runTest { - whenever(mockTabRepository.tabSwitcherData).thenReturn(flowOf(TabSwitcherData(TabSwitcherData.UserState.EXISTING, false, 2, GRID))) + fun whenOnDraggingStartedThePixelSent() = runTest { + whenever(mockTabRepository.tabSwitcherData).thenReturn(flowOf(TabSwitcherData(TabSwitcherData.UserState.EXISTING, GRID))) // we need to use the new stubbing here initializeViewModel() - coroutinesTestRule.testScope.launch { - testee.isFeatureAnnouncementVisible.collect() - } - testee.onTabDraggingStarted() - verify(mockTabRepository).setWasAnnouncementDismissed(true) - } - - @Test - fun whenAnnouncementDisplayedThePixelSent() = runTest { - testee.onTabFeatureAnnouncementDisplayed() - } - - @Test - fun whenAnnouncementDismissedThePixelIsSent() = runTest { - testee.onFeatureAnnouncementCloseButtonTapped() + val params = mapOf("userState" to EXISTING.name) + verify(mockPixel).fire(AppPixelName.TAB_MANAGER_REARRANGE_TABS_DAILY, params, emptyMap(), DAILY) } @OptIn(ExperimentalCoroutinesApi::class) @@ -335,23 +319,6 @@ class TabSwitcherViewModelTest { verify(mockPixel).fire(AppPixelName.TAB_MANAGER_REARRANGE_TABS_DAILY, params, emptyMap(), DAILY) } - @Test - fun whenOnTabFeatureAnnouncementDisplayedAnnouncementCountIncremented() = runTest { - val initialCount = 0 - val expectedCount = initialCount + 1 - - testee.onTabFeatureAnnouncementDisplayed() - - verify(mockTabRepository).setAnnouncementDisplayCount(expectedCount) - } - - @Test - fun onFeatureAnnouncementCloseButtonTapped_announcementIsMarkedAsDismissed() = runTest { - testee.onFeatureAnnouncementCloseButtonTapped() - - verify(mockTabRepository).setWasAnnouncementDismissed(true) - } - @Test fun whenOnTabMovedRepositoryUpdatesTabPosition() = runTest { val fromIndex = 0 @@ -362,63 +329,6 @@ class TabSwitcherViewModelTest { verify(mockTabRepository).updateTabPosition(fromIndex, toIndex) } - @Test - fun isFeatureAnnouncementVisible_ExistingUser_NotDismissed_BelowMaxCount_MultipleTabs() = runTest { - whenever(mockTabRepository.tabSwitcherData).thenReturn(flowOf(TabSwitcherData(TabSwitcherData.UserState.EXISTING, false, 2, GRID))) - - // we need to use the new stubbing here - initializeViewModel() - - testee.isFeatureAnnouncementVisible.test { - assertTrue(awaitItem()) - } - } - - @Test - fun isFeatureAnnouncementVisible_ReturningUser_NotDismissed_BelowMaxCount_MultipleTabs() = runTest { - whenever(statisticsDataStore.variant).thenReturn("ru") - - // we need to use the new stubbing here - initializeViewModel() - - testee.isFeatureAnnouncementVisible.test { - assertTrue(awaitItem()) - } - } - - @Test - fun isFeatureAnnouncementVisible_NewUser() = runTest { - val isVisible = testee.isFeatureAnnouncementVisible.value - assertFalse(isVisible) - } - - @Test - fun isFeatureAnnouncementVisible_Dismissed() = runTest { - whenever(mockTabRepository.tabSwitcherData).thenReturn(flowOf(TabSwitcherData(TabSwitcherData.UserState.EXISTING, true, 0, GRID))) - - val isVisible = testee.isFeatureAnnouncementVisible.value - assertFalse(isVisible) - } - - @Test - fun isFeatureAnnouncementVisible_AboveMaxDisplayCount() = runTest { - whenever(mockTabRepository.tabSwitcherData).thenReturn(flowOf(TabSwitcherData(TabSwitcherData.UserState.EXISTING, false, 4, GRID))) - - val isVisible = testee.isFeatureAnnouncementVisible.value - assertFalse(isVisible) - } - - @Test - fun isFeatureAnnouncementVisible_SingleTab() = runTest { - val data = TabSwitcherData(TabSwitcherData.UserState.EXISTING, false, 0, GRID) - - whenever(mockTabRepository.tabSwitcherData).thenReturn(flowOf(data)) - whenever(mockTabRepository.flowTabs).thenReturn(flowOf(listOf(TabEntity("1", position = 1)))) - - val isVisible = testee.isFeatureAnnouncementVisible.value - assertFalse(isVisible) - } - @Test fun whenListLayoutTypeToggledCorrectPixelsAreFired() = runTest { coroutinesTestRule.testScope.launch { diff --git a/browser-api/src/main/java/com/duckduckgo/app/tabs/model/TabRepository.kt b/browser-api/src/main/java/com/duckduckgo/app/tabs/model/TabRepository.kt index 516083013948..a96eb9f44eb5 100644 --- a/browser-api/src/main/java/com/duckduckgo/app/tabs/model/TabRepository.kt +++ b/browser-api/src/main/java/com/duckduckgo/app/tabs/model/TabRepository.kt @@ -109,9 +109,5 @@ interface TabRepository { suspend fun setIsUserNew(isUserNew: Boolean) - suspend fun setWasAnnouncementDismissed(wasDismissed: Boolean) - - suspend fun setAnnouncementDisplayCount(displayCount: Int) - suspend fun setTabLayoutType(layoutType: LayoutType) } diff --git a/browser-api/src/main/java/com/duckduckgo/app/tabs/model/TabSwitcherData.kt b/browser-api/src/main/java/com/duckduckgo/app/tabs/model/TabSwitcherData.kt index 54b64a42ca68..3dd163591bb5 100644 --- a/browser-api/src/main/java/com/duckduckgo/app/tabs/model/TabSwitcherData.kt +++ b/browser-api/src/main/java/com/duckduckgo/app/tabs/model/TabSwitcherData.kt @@ -18,8 +18,6 @@ package com.duckduckgo.app.tabs.model data class TabSwitcherData( val userState: UserState, - val wasAnnouncementDismissed: Boolean, - val announcementDisplayCount: Int, val layoutType: LayoutType, ) { enum class UserState {