-
Notifications
You must be signed in to change notification settings - Fork 928
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 swiping #5408
base: develop
Are you sure you want to change the base?
Tab swiping #5408
Conversation
…ilability.kt Co-authored-by: Noelia Alcala <[email protected]>
Task/Issue URL: https://app.asana.com/0/1202552961248957/1208659739219426/f ### Description This PR adds a feature flag that will allow us to disable the tab swiping. --------- Co-authored-by: Noelia Alcala <[email protected]>
Task/Issue URL: https://app.asana.com/0/72649045549333/1208648123066959/f ### Description This PR refactors the tab-related code into a separate `TabManager` class to ease the integration of the tab-swiping functionality. The refactoring doesn’t change the existing functionality. ### Steps to test this PR Smoke testing of tab-related functionality is sufficient (changing of tabs in the tab switcher, creating a new tab, etc.) --------- Co-authored-by: Noelia Alcala <[email protected]>
Task/Issue URL: https://app.asana.com/0/1207418217763355/1208852760335259/f ### Description This PR just caches the feature flag value. I’ve set the scope of the `IsSwipingTabsFeatureEnabled` to `AppScope` because it’s used inside the `TabManager`, which is used across 2 different activities (`BrowserActivity` and `TabSwitcherActivity`). ### Steps to test this PR Testing optional.
Task/Issue URL: https://app.asana.com/0/72649045549333/1208648123066962/f ### Description This PR includes the complete implementation of the tab-swiping functionality. ### Steps to test this PR **Make sure you’ve completed the onboarding!** #### New tab from long press - [x] Long press on a tabs button - [x] Verify a new tab is opened #### New tab from the menu - [x] Tap on the New tab menu item - [x] Verify a new tab is opened #### New tab from tab switcher - [x] Go to tab switcher - [x] Tap on the New tab button - [x] Verify a new tab is opened #### New tab recreation - [x] Open a few tabs - [x] Go to the tab switcher - [x] Add a new tab - [x] Verify a new tab is correctly displayed - [x] Go back to the tab switcher - [x] Close the NTP - [x] Tap on the new tab button - [x] Verify the new tab is correctly opened #### Swiping position - [x] Open at least 3 tabs - [x] Select the 1st one in the tab switcher - [x] Swipe to the last one - [x] Go to tab switcher and verify the correct tab is selected - [x] Tap on the 2nd tab - [x] Verify the correct tab is opened #### New link - [x] Open any website - [x] Long press on a link to open in new tab - [x] Verify the link is opened in a new tab #### New link in the background - [x] Open any website - [x] Long press on a link to open in background tab - [x] Verify the link is opened in a new tab in the background #### New link in the background - [x] Make sure the DDG app is the default browser app - [x] Open an app that can open links in custom tabs (i.e. Twitter, Facebook) - [x] Open a link in a custom tab - [x] Verify the link opens correctly - [x] Move the tab to the app - [x] Verify the tab is correctly displayed within the app #### Switch to tab - [x] Start typing a site address that’s already opened in another tab - [x] Tap on the “Switch to tab” item - [x] Verify the existing tab with the link is shown instead of opening a new tab #### Changing the omnibar position - [x] Open a few tabs - [x] Go to settings and change the omnibar position - [x] The app will reload (the cached sites are cleared) - [x] Swipe through the tabs and verify the load correctly #### Bookmarks - [x] Load a site - [x] Add it to the boorkmarks - [x] Open a different tab - [x] Go to Bookmarks and select the saved boormark - [x] Verify the bookmark loads correctly #### Default site - [x] Set some default URL in Settings -> General -> Show on App Launch - [x] Kill the app and relaunch it - [x] Verify the default site is correctly loaded in a new tab - [x] Kill the app and relaunch it - [x] Verify the default site is loaded in the same tab as before (no new tab is added)
Task/Issue URL: https://app.asana.com/0/72649045549333/1208648123066972/f ### Description This PR adds pixel for tab swiping. ### Steps to test this PR _Change tabs with swiping_ - [x] Add a few tabs - [x] Swipe tabs 3 times - [x] Verify `m_swipe_tabs_used` pixel is fired 3 times - [x] Verify `m_swipe_tabs_used_daily` pixel is fired once _Change tabs with not swiping_ - [x] Add a few tabs - [x] Long press on a tabs button to open a new tab - [x] Go to tab switch - [x] Select a different tab - [x] Add a new tab from the menu - [x] Verify `m_swipe_tabs_used` pixel is never fired
|
||
private val viewModel: BrowserViewModel by bindViewModel() | ||
val viewModel: BrowserViewModel by bindViewModel() |
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.
This should be private.
@@ -1144,7 +1177,11 @@ class BrowserTabFragment : | |||
super.onResume() | |||
|
|||
if (viewModel.hasOmnibarPositionChanged(omnibar.omnibarPosition)) { | |||
requireActivity().recreate() | |||
if (swipingTabsFeature.isEnabled) { | |||
(requireActivity() as BrowserActivity).clearTabsAndRecreate() |
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.
This code can crash the Custom tab. See scenario:
- open the DDG app with the Address bar set at the top
- open a DDG custom tab from another app
- go back to the DDG app and change the Address bar to the bottom
- go back to the DG custom tab and see it crashes as there is no BrowserActivity there
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.
Nice catch, thanks! It’s fixed here.
binding.daxDialogOnboardingCtaContent.layoutTransition.enableTransitionType(LayoutTransition.CHANGING) | ||
|
||
webView = layoutInflater.inflate( | ||
R.layout.include_duckduckgo_browser_webview, | ||
binding.webViewContainer, | ||
true, | ||
).findViewById(R.id.browserWebView) as DuckDuckGoWebView | ||
).findViewById<DuckDuckGoWebView>(R.id.browserWebView)!! |
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.
!!
is not needed, should be removed.
@@ -773,6 +776,8 @@ class BrowserTabFragment : | |||
|
|||
private lateinit var privacyProtectionsPopup: PrivacyProtectionsPopup | |||
|
|||
private fun requireBrowserActivity(): BrowserActivity = requireNotNull(browserActivity) |
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.
This is unused, can be removed.
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.
Good catch.
@Before | ||
fun before() { | ||
MockitoAnnotations.openMocks(this) | ||
|
||
doReturn(MutableLiveData<AppEnjoymentPromptOptions>()).whenever(mockAppEnjoymentPromptEmitter).promptType | ||
|
||
configureSkipUrlConversionInNewTabState(enabled = true) | ||
swipingTabsFeature.self().setRawStoredState(State(enable = true)) |
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.
Should we have tests with this feature disabled?
swipingTabsFeature.self().setRawStoredState(State(enable = false))
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.
I set the flag to false by default and only enable it for new tests.
…e it for new tests
# Conflicts: # app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
Thanks for the thorough review @anikiki! I’ve addressed your feedback — ready for another round. |
Task/Issue URL: https://app.asana.com/0/0/1208648123066970/f ### Description Adds unit tests for DefaultTabManager. ### Steps to test this PR Run the unit tests and make sure they’re passing.
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.
Looks good and works as expected! 🎉
Task/Issue URL: https://app.asana.com/0/1207418217763355/1209006734942815/f
Description
This PR includes the complete implementation of the tab-swiping functionality.
Steps to test this PR
Make sure you’ve completed the onboarding!
New tab from long press
New tab from the menu
New tab from tab switcher
New tab recreation
Swiping position
New link
New link in the background
New link in the background
Switch to tab
Changing the omnibar position
Bookmarks
Default site