-
Notifications
You must be signed in to change notification settings - Fork 957
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
Tab Switcher Animation: Add show/hide behaviour #5729
Merged
mikescamell
merged 24 commits into
feature/mike/tab-switcher-tile-animation/translations
from
feature/mike/tab-switcher-tile-animation/add-show-hide-logic
Mar 17, 2025
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ab7be9a
Add methods to manage animation tile dismissal state in TabSwitcherDa…
mikescamell 5abdceb
Add functionality to show animated tile in DevSettingsActivity
mikescamell ee4eaed
Implement logic to conditionally show tracker animation tile based on…
mikescamell b2c3138
Add click listener for tracker animation tile close action
mikescamell b20782c
Remove redundant qualifier names
mikescamell 01f2b25
formatting
mikescamell 1ae4adc
Fix tests
mikescamell e28b958
Add tracker animation tile conditionally based on tracker count
mikescamell eedce31
Update tracker animation tile dismissal logic and conditionally inclu…
mikescamell d48ee6a
Move Tracker Animation Tile logic to TabSwitcherTileAnimationMonitor
mikescamell d8e8fab
Introduce Animation Tile Seen State
mikescamell 8af5cd1
Add animation tile visibility logic and tests
mikescamell 93f1274
Add tests for Animation Tile visibility in TabSwitcherViewModel
mikescamell f5ebb86
Formatting
mikescamell 23ed0b2
Use new gradient background
mikescamell fdcacc1
Ensure list view text matches regular tab text
mikescamell c6ce1ef
Reset animation when "Close All Tabs" is pressed
mikescamell ff33b1b
Reset seen animation tile state on clear data
mikescamell 8c12631
Reset setAnimationTileSeen in DevSettings
mikescamell a5c664a
Fix tests
mikescamell e14ac01
Add dark ripple background for close button and update layout
mikescamell 22461c4
Switch to new shield animation with gradient
mikescamell fa14769
Prevent setting animation tile seen if the first item is already a Tr…
mikescamell 4d29f15
Adjust animation speeds
mikescamell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherTileAnimationMonitor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2025 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.app.tabs.ui | ||
|
||
import com.duckduckgo.app.tabs.model.TabDataRepository | ||
import com.duckduckgo.app.tabs.store.TabSwitcherDataStore | ||
import com.duckduckgo.app.trackerdetection.api.WebTrackersBlockedAppRepository | ||
import com.duckduckgo.common.utils.DispatcherProvider | ||
import javax.inject.Inject | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.combine | ||
import kotlinx.coroutines.flow.flowOn | ||
|
||
private const val MINIMUM_TRACKER_COUNT = 10 | ||
private const val MINIMUM_TAB_COUNT = 2 | ||
|
||
class TabSwitcherTileAnimationMonitor @Inject constructor( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
private val dispatchProvider: DispatcherProvider, | ||
private val tabSwitcherPrefsDataStore: TabSwitcherDataStore, | ||
private val tabDataRepository: TabDataRepository, | ||
private val webTrackersBlockedAppRepository: WebTrackersBlockedAppRepository, | ||
) { | ||
|
||
fun observeAnimationTileVisibility(): Flow<Boolean> = combine( | ||
tabSwitcherPrefsDataStore.isAnimationTileDismissed(), | ||
tabSwitcherPrefsDataStore.hasAnimationTileBeenSeen(), | ||
) { isAnimationTileDismissed, hasAnimationTileBeenSeen -> | ||
when { | ||
isAnimationTileDismissed -> false | ||
hasAnimationTileBeenSeen -> true | ||
else -> shouldDisplayAnimationTile() | ||
} | ||
}.flowOn(dispatchProvider.io()) | ||
|
||
private suspend fun shouldDisplayAnimationTile(): Boolean { | ||
val openedTabs = tabDataRepository.getOpenTabCount() | ||
val trackerCountForLast7Days = webTrackersBlockedAppRepository.getTrackerCountForLast7Days() | ||
|
||
return trackerCountForLast7Days >= MINIMUM_TRACKER_COUNT && | ||
openedTabs >= MINIMUM_TAB_COUNT | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already a
TabSwitcherListener
supplied in the constructor that contains a couple of callbacks, WDYT about moving it there?