Skip to content
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

Open
wants to merge 39 commits into
base: develop
Choose a base branch
from
Open

Tab swiping #5408

wants to merge 39 commits into from

Conversation

0nko
Copy link
Member

@0nko 0nko commented Dec 18, 2024

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

  • Long press on a tabs button
  • Verify a new tab is opened

New tab from the menu

  • Tap on the New tab menu item
  • Verify a new tab is opened

New tab from tab switcher

  • Go to tab switcher
  • Tap on the New tab button
  • Verify a new tab is opened

New tab recreation

  • Open a few tabs
  • Go to the tab switcher
  • Add a new tab
  • Verify a new tab is correctly displayed
  • Go back to the tab switcher
  • Close the NTP
  • Tap on the new tab button
  • Verify the new tab is correctly opened

Swiping position

  • Open at least 3 tabs
  • Select the 1st one in the tab switcher
  • Swipe to the last one
  • Go to tab switcher and verify the correct tab is selected
  • Tap on the 2nd tab
  • Verify the correct tab is opened

New link

  • Open any website
  • Long press on a link to open in new tab
  • Verify the link is opened in a new tab

New link in the background

  • Open any website
  • Long press on a link to open in background tab
  • Verify the link is opened in a new tab in the background

New link in the background

  • Make sure the DDG app is the default browser app
  • Open an app that can open links in custom tabs (i.e. Twitter, Facebook)
  • Open a link in a custom tab
  • Verify the link opens correctly
  • Move the tab to the app
  • Verify the tab is correctly displayed within the app

Switch to tab

  • Start typing a site address that’s already opened in another tab
  • Tap on the “Switch to tab” item
  • Verify the existing tab with the link is shown instead of opening a new tab

Changing the omnibar position

  • Open a few tabs
  • Go to settings and change the omnibar position
  • The app will reload (the cached sites are cleared)
  • Swipe through the tabs and verify the load correctly

Bookmarks

  • Load a site
  • Add it to the boorkmarks
  • Open a different tab
  • Go to Bookmarks and select the saved boormark
  • Verify the bookmark loads correctly

Default site

  • Set some default URL in Settings -> General -> Show on App Launch
  • Kill the app and relaunch it
  • Verify the default site is correctly loaded in a new tab
  • Kill the app and relaunch it
  • Verify the default site is loaded in the same tab as before (no new tab is added)

0nko and others added 22 commits November 9, 2024 11:04
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
@0nko 0nko requested review from malmstein and anikiki and removed request for malmstein December 20, 2024 13:18
@0nko 0nko marked this pull request as ready for review December 20, 2024 13:19

private val viewModel: BrowserViewModel by bindViewModel()
val viewModel: BrowserViewModel by bindViewModel()
Copy link
Contributor

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()
Copy link
Contributor

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

Copy link
Member Author

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)!!
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Member Author

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))
Copy link
Contributor

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))

Copy link
Member Author

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.

@anikiki anikiki self-assigned this Jan 3, 2025
@0nko
Copy link
Member Author

0nko commented Jan 7, 2025

Thanks for the thorough review @anikiki! I’ve addressed your feedback — ready for another round.

@0nko 0nko requested a review from anikiki January 7, 2025 18:42
0nko and others added 4 commits January 8, 2025 10:01
Copy link
Contributor

@anikiki anikiki left a 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! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants