Skip to content

Tab Switcher Animation: Ship Review Changes #5783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 @@ -28,6 +28,8 @@ interface WebTrackersBlockedRepository {
endTime: String = noEndDate(),
): Flow<List<WebTrackerBlocked>>

suspend fun deleteAll()

private fun noEndDate(): String {
return DatabaseDateFormatter.timestamp(LocalDateTime.of(9999, 1, 1, 0, 0))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ import com.duckduckgo.app.fire.UnsentForgetAllPixelStore
import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteEntity
import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteRepository
import com.duckduckgo.app.settings.db.SettingsDataStore
import com.duckduckgo.app.tabs.TabSwitcherAnimationFeature
import com.duckduckgo.app.tabs.model.TabRepository
import com.duckduckgo.app.tabs.store.TabSwitcherDataStore
import com.duckduckgo.app.trackerdetection.api.WebTrackersBlockedRepository
import com.duckduckgo.cookies.api.DuckDuckGoCookieManager
import com.duckduckgo.history.api.NavigationHistory
import com.duckduckgo.privacyprotectionspopup.api.PrivacyProtectionsPopupDataClearer
Expand All @@ -40,7 +39,6 @@ import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.mockito.kotlin.any
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify
Expand All @@ -66,10 +64,7 @@ class ClearPersonalDataActionTest {
private val mockSitePermissionsManager: SitePermissionsManager = mock()
private val mockPrivacyProtectionsPopupDataClearer: PrivacyProtectionsPopupDataClearer = mock()
private val mockNavigationHistory: NavigationHistory = mock()
private val mockTabSwitcherAnimationFeature: TabSwitcherAnimationFeature = mock {
on { self() } doReturn mock()
}
private val mockTabSwitcherDataStore: TabSwitcherDataStore = mock()
private val mockWebTrackersBlockedRepository: WebTrackersBlockedRepository = mock()

private val fireproofWebsites: LiveData<List<FireproofWebsiteEntity>> = MutableLiveData()

Expand All @@ -91,8 +86,7 @@ class ClearPersonalDataActionTest {
privacyProtectionsPopupDataClearer = mockPrivacyProtectionsPopupDataClearer,
sitePermissionsManager = mockSitePermissionsManager,
navigationHistory = mockNavigationHistory,
tabSwitcherAnimationFeature = mockTabSwitcherAnimationFeature,
tabSwitcherDataStore = mockTabSwitcherDataStore,
webTrackersBlockedRepository = mockWebTrackersBlockedRepository,
)
whenever(mockFireproofWebsiteRepository.getFireproofWebsites()).thenReturn(fireproofWebsites)
whenever(mockDeviceSyncState.isUserSignedInOnDevice()).thenReturn(true)
Expand Down Expand Up @@ -166,19 +160,8 @@ class ClearPersonalDataActionTest {
}

@Test
fun whenClearCalledAndAnimationTileEnabledThenAnimationTileIsReset() = runTest {
whenever(mockTabSwitcherAnimationFeature.self().isEnabled(any())).thenReturn(true)

testee.clearTabsAndAllDataAsync(appInForeground = false, shouldFireDataClearPixel = false)
verify(mockTabSwitcherDataStore, never()).setIsAnimationTileDismissed(false)
verify(mockTabSwitcherDataStore).setAnimationTileSeen(false)
}

@Test
fun whenClearCalledAndAnimationTileDisabledThenAnimationTileIsNotReset() = runTest {
whenever(mockTabSwitcherAnimationFeature.self().isEnabled(any())).thenReturn(false)

fun whenClearCalledThenWebTrackersAreCleared() = runTest {
testee.clearTabsAndAllDataAsync(appInForeground = false, shouldFireDataClearPixel = false)
verifyNoInteractions(mockTabSwitcherDataStore)
verify(mockWebTrackersBlockedRepository).deleteAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ class DevSettingsViewModel @Inject constructor(
fun showAnimatedTileClicked() {
viewModelScope.launch {
tabSwitcherPrefsDataStore.setIsAnimationTileDismissed(isDismissed = false)
tabSwitcherPrefsDataStore.setAnimationTileSeen(isSeen = false)
command.send(Command.Toast("Animated tile dismissal has been reset"))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package com.duckduckgo.app.browser.tabs.adapter
import android.os.Bundle
import androidx.recyclerview.widget.DiffUtil
import com.duckduckgo.app.tabs.ui.TabSwitcherItem
import com.duckduckgo.app.tabs.ui.TabSwitcherItem.TrackerAnimationTile.Companion.ANIMATED_TILE_DEFAULT_ALPHA
import com.duckduckgo.app.tabs.ui.TabSwitcherItem.TrackerAnimationTile.Companion.ANIMATED_TILE_NO_REPLACE_ALPHA
import com.duckduckgo.app.tabs.ui.TabSwitcherItem.TrackerAnimationInfoPanel.Companion.ANIMATED_TILE_DEFAULT_ALPHA
import com.duckduckgo.app.tabs.ui.TabSwitcherItem.TrackerAnimationInfoPanel.Companion.ANIMATED_TILE_NO_REPLACE_ALPHA

class TabSwitcherItemDiffCallback(
old: List<TabSwitcherItem>,
Expand Down Expand Up @@ -78,7 +78,7 @@ class TabSwitcherItemDiffCallback(
diffBundle.putString(DIFF_KEY_PREVIEW, newItem.tabEntity.tabPreviewFile)
}
}
oldItem is TabSwitcherItem.TrackerAnimationTile && newItem is TabSwitcherItem.TrackerAnimationTile -> {
oldItem is TabSwitcherItem.TrackerAnimationInfoPanel && newItem is TabSwitcherItem.TrackerAnimationInfoPanel -> {
diffBundle.putFloat(
DIFF_ALPHA,
if (isDragging) ANIMATED_TILE_NO_REPLACE_ALPHA else ANIMATED_TILE_DEFAULT_ALPHA,
Expand Down
9 changes: 3 additions & 6 deletions app/src/main/java/com/duckduckgo/app/di/PrivacyModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ import com.duckduckgo.app.location.data.LocationPermissionsDao
import com.duckduckgo.app.location.data.LocationPermissionsRepository
import com.duckduckgo.app.location.data.LocationPermissionsRepositoryImpl
import com.duckduckgo.app.settings.db.SettingsDataStore
import com.duckduckgo.app.tabs.TabSwitcherAnimationFeature
import com.duckduckgo.app.tabs.model.TabRepository
import com.duckduckgo.app.tabs.store.TabSwitcherPrefsDataStore
import com.duckduckgo.app.trackerdetection.EntityLookup
import com.duckduckgo.app.trackerdetection.TdsEntityLookup
import com.duckduckgo.app.trackerdetection.api.WebTrackersBlockedRepository
import com.duckduckgo.app.trackerdetection.db.TdsDomainEntityDao
import com.duckduckgo.app.trackerdetection.db.TdsEntityDao
import com.duckduckgo.common.utils.DispatcherProvider
Expand Down Expand Up @@ -86,8 +85,7 @@ object PrivacyModule {
privacyProtectionsPopupDataClearer: PrivacyProtectionsPopupDataClearer,
navigationHistory: NavigationHistory,
dispatcherProvider: DispatcherProvider,
tabSwitcherAnimationFeature: TabSwitcherAnimationFeature,
tabSwitcherPrefsDataStore: TabSwitcherPrefsDataStore,
webTrackingRepository: WebTrackersBlockedRepository,
): ClearDataAction {
return ClearPersonalDataAction(
context,
Expand All @@ -106,8 +104,7 @@ object PrivacyModule {
privacyProtectionsPopupDataClearer,
navigationHistory,
dispatcherProvider,
tabSwitcherAnimationFeature,
tabSwitcherPrefsDataStore,
webTrackingRepository,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import com.duckduckgo.app.fire.FireActivity
import com.duckduckgo.app.fire.UnsentForgetAllPixelStore
import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteRepository
import com.duckduckgo.app.settings.db.SettingsDataStore
import com.duckduckgo.app.tabs.TabSwitcherAnimationFeature
import com.duckduckgo.app.tabs.model.TabRepository
import com.duckduckgo.app.tabs.store.TabSwitcherDataStore
import com.duckduckgo.app.trackerdetection.api.WebTrackersBlockedRepository
import com.duckduckgo.common.utils.DefaultDispatcherProvider
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.cookies.api.DuckDuckGoCookieManager
Expand Down Expand Up @@ -75,8 +74,7 @@ class ClearPersonalDataAction(
private val privacyProtectionsPopupDataClearer: PrivacyProtectionsPopupDataClearer,
private val navigationHistory: NavigationHistory,
private val dispatchers: DispatcherProvider = DefaultDispatcherProvider(),
private val tabSwitcherAnimationFeature: TabSwitcherAnimationFeature,
private val tabSwitcherDataStore: TabSwitcherDataStore,
private val webTrackersBlockedRepository: WebTrackersBlockedRepository,
) : ClearDataAction {

override fun killAndRestartProcess(notifyDataCleared: Boolean, enableTransitionAnimation: Boolean) {
Expand Down Expand Up @@ -108,6 +106,8 @@ class ClearPersonalDataAction(

clearTabsAsync(appInForeground)

webTrackersBlockedRepository.deleteAll()

navigationHistory.clearHistory()
}

Expand All @@ -125,9 +125,6 @@ class ClearPersonalDataAction(
dataManager.clearWebViewSessions()
tabRepository.deleteAll()
adClickManager.clearAll()
if (tabSwitcherAnimationFeature.self().isEnabled()) {
tabSwitcherDataStore.setAnimationTileSeen(isSeen = false)
}
setAppUsedSinceLastClearFlag(appInForeground)
Timber.d("Finished clearing tabs")
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/duckduckgo/app/pixels/AppPixelName.kt
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,8 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
SET_AS_DEFAULT_IN_MENU_CLICK("m_set-as-default_in-menu_click"),

MALICIOUS_SITE_DETECTED_IN_IFRAME("m_malicious-site-protection_iframe-loaded"),

TAB_MANAGER_INFO_PANEL_IMPRESSIONS("m_tab_manager_info_panel_impressions"),
TAB_MANAGER_INFO_PANEL_DISMISSED("m_tab_manager_info_panel_dismissed"),
TAB_MANAGER_INFO_PANEL_TAPPED("m_tab_manager_info_panel_tapped"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ interface TabSwitcherDataStore {
suspend fun setTabLayoutType(layoutType: LayoutType)
fun isAnimationTileDismissed(): Flow<Boolean>
suspend fun setIsAnimationTileDismissed(isDismissed: Boolean)
fun hasAnimationTileBeenSeen(): Flow<Boolean>
suspend fun setAnimationTileSeen(isSeen: Boolean)
}

@ContributesBinding(AppScope::class)
Expand All @@ -49,7 +47,6 @@ class TabSwitcherPrefsDataStore @Inject constructor(
const val KEY_USER_STATE = "KEY_USER_STATE"
const val KEY_LAYOUT_TYPE = "KEY_LAYOUT_TYPE"
const val KEY_IS_ANIMATION_TILE_DISMISSED = "KEY_IS_ANIMATION_TILE_DISMISSED"
const val KEY_HAS_ANIMATION_TILE_BEEN_SEEN = "KEY_HAS_ANIMATION_TILE_BEEN_SEEN"
}

override val data: Flow<TabSwitcherData> = store.data.map { preferences ->
Expand Down Expand Up @@ -82,16 +79,4 @@ class TabSwitcherPrefsDataStore @Inject constructor(
preferences[booleanPreferencesKey(KEY_IS_ANIMATION_TILE_DISMISSED)] = isDismissed
}
}

override fun hasAnimationTileBeenSeen(): Flow<Boolean> {
return store.data.map { preferences ->
preferences[booleanPreferencesKey(KEY_HAS_ANIMATION_TILE_BEEN_SEEN)] ?: false
}
}

override suspend fun setAnimationTileSeen(isSeen: Boolean) {
store.edit { preferences ->
preferences[booleanPreferencesKey(KEY_HAS_ANIMATION_TILE_BEEN_SEEN)] = isSeen
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TabItemDecorator(
drawSelectedTabDecoration(child, canvas)
}
}
is TabSwitcherItem.TrackerAnimationTile -> Unit // No border for animation tile
is TabSwitcherItem.TrackerAnimationInfoPanel -> Unit // No border for animation tile
}
}
}
Expand Down
Loading
Loading