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

Android: Migrate auto-complete to Flow and Coroutines #5123

Conversation

anikiki
Copy link
Contributor

@anikiki anikiki commented Oct 10, 2024

Task/Issue URL: https://app.asana.com/0/1200581511062568/1208040472309277/f

Description

Removed rxjava from autosuggest.

Steps to test this PR

Smoke test the autosuggest. There should be no user facing changes.

This is the final PR. See scenarios and screenshots in https://app.asana.com/0/1200581511062568/1208264037618741/f

NO UI changes

@anikiki anikiki changed the title Removed rxjava from autosuggest. Android: Migrate auto-complete to Flow and Coroutines Oct 10, 2024
@anikiki anikiki marked this pull request as ready for review October 10, 2024 13:40
@anikiki anikiki marked this pull request as draft October 10, 2024 13:41
@anikiki anikiki force-pushed the feature/ana/address_the_tasks_in_the_meta_section branch from 418720f to cabd77b Compare October 10, 2024 15:29
@anikiki anikiki force-pushed the feature/ana/android_migrate_auto_complete_to_flow_and_coroutines branch from 60cab4e to c3e69d7 Compare October 10, 2024 15:29
@anikiki anikiki force-pushed the feature/ana/address_the_tasks_in_the_meta_section branch from cabd77b to 16012e8 Compare October 10, 2024 15:39
@anikiki anikiki force-pushed the feature/ana/android_migrate_auto_complete_to_flow_and_coroutines branch from c3e69d7 to 6ec2529 Compare October 10, 2024 15:40
@anikiki anikiki force-pushed the feature/ana/address_the_tasks_in_the_meta_section branch from 16012e8 to ed1fee2 Compare October 10, 2024 15:45
@anikiki anikiki force-pushed the feature/ana/android_migrate_auto_complete_to_flow_and_coroutines branch from 6ec2529 to 37a6efa Compare October 10, 2024 15:45
@anikiki anikiki force-pushed the feature/ana/address_the_tasks_in_the_meta_section branch from ed1fee2 to f679db7 Compare October 11, 2024 16:07
@anikiki anikiki force-pushed the feature/ana/android_migrate_auto_complete_to_flow_and_coroutines branch 2 times, most recently from e412c4c to b33504d Compare October 11, 2024 20:45
@anikiki anikiki marked this pull request as ready for review October 14, 2024 11:53
Copy link
Contributor

@CrisBarreiro CrisBarreiro 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. Left a coupe of small comments, but great work! 🎉

Now that we aren't using Rx for autocomplete anymore, can we remove the rxjava dependencies somewhere? I believe we should be able to remove them from at least the history modules

.sortedByDescending { it.score }
.map { it.suggestion }
}
val savedSites = getAutoCompleteBookmarkResults(query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity, can we just combine all flows in one single operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion 👍 Updated.


return savedSitesObservable.zipWith(getAutoCompleteSearchResults(query)) { bookmarksAndTabsAndHistory, searchResults ->
val topHits = (searchResults + bookmarksAndTabsAndHistory).filter {
savedSites.collect { (bookmarksAndFavoritesAndTabsAndHistory, searchResults) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just map instead of collect and emit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion 👍 Updated.

@@ -468,3 +466,15 @@ class AutoCompleteApi @Inject constructor(
val score: Int = DEFAULT_SCORE,
)
}

@VisibleForTesting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the annotation since this is internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation is there to mark the fact that this function should be private, but the visibility was changed for testing purposes. I didn't add what the visibility should have been. By default, if not mentioned, is private (as in this case).

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)

@@ -1681,6 +1681,9 @@ class BrowserTabFragment :
duckPlayerScripts.sendSubscriptionEvent(it.duckPlayerData)
}
is Command.SwitchToTab -> {
binding.focusedView.gone()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why we need this, since it doesn't seem to be related to the migration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was added to cover the scenario where the Switch to tab suggestion matches the current tab. In this case we need to close the suggestions and have the UI in a state similar as when opening a different tab.

@anikiki anikiki force-pushed the feature/ana/address_the_tasks_in_the_meta_section branch from 4b8c8a2 to e5b9a08 Compare October 18, 2024 12:10
@anikiki anikiki force-pushed the feature/ana/android_migrate_auto_complete_to_flow_and_coroutines branch from cc552b6 to 03a8d05 Compare October 18, 2024 12:10
@anikiki anikiki force-pushed the feature/ana/address_the_tasks_in_the_meta_section branch from e5b9a08 to bb5d02d Compare October 21, 2024 15:15
@anikiki anikiki force-pushed the feature/ana/android_migrate_auto_complete_to_flow_and_coroutines branch from 03a8d05 to 7a4e8c7 Compare October 21, 2024 15:15
val testObserver = TestObserver.create<String>()
testee.resultsPublishSubject.subscribe(testObserver)
// val testObserver = TestObserver.create<String>()
// testee.resultsStateFlow.subscribe(testObserver)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete the commented-out lines in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Removed :)

anikiki and others added 2 commits October 22, 2024 09:20
Task/Issue URL: https://app.asana.com/0/0/1208581391309609/f

### Description
Fixed autocomplete flow and pixels.

### Steps to test this PR

Steps to repro:
- [x] Install from branch
`feature/ana/android_migrate_auto_complete_to_flow_and_coroutines`
- [x] Visit a site in a new tab
- [x] Open ... menu
- [x] Click add bookmark
- [x] Observe that autocomplete pixels are firing (they should not):
m_autocomplete_displayed_bookmark
m_autocomplete_displayed_switch_to_tab

Test the fix:
- [x] Install from this branch
- [x] Visit a site in a new tab
- [x] Open ... menu
- [x] Click add bookmark
- [x] Autocomplete pixels are not firing (check for "m_autocomplete" in
logs)

### NO UI changes
@anikiki anikiki merged commit 92090e4 into feature/ana/address_the_tasks_in_the_meta_section Oct 22, 2024
4 checks passed
@anikiki anikiki deleted the feature/ana/android_migrate_auto_complete_to_flow_and_coroutines branch October 22, 2024 11:41
anikiki added a commit that referenced this pull request Oct 25, 2024
…ggest (#5018)

Task/Issue URL:
https://app.asana.com/0/1200581511062568/1208260875798966/f

### Description
The full implementation will span across a few tasks.

This is the main task for the implementation of [Android: Include
existing open tabs in search
autosuggest](https://app.asana.com/0/715106103902962/1208040193300233/f)

### Steps to test this PR

See:
- #5019
- #5042
- #5063
- #5064
- #5065
- #5105
- #5123

See scenarios and screenshots in
https://app.asana.com/0/1200581511062568/1208264037618741/f

---------

Co-authored-by: Dax The Translator <[email protected]>
aitorvs pushed a commit that referenced this pull request Nov 6, 2024
…ggest (#5018)

Task/Issue URL:
https://app.asana.com/0/1200581511062568/1208260875798966/f

### Description
The full implementation will span across a few tasks.

This is the main task for the implementation of [Android: Include
existing open tabs in search
autosuggest](https://app.asana.com/0/715106103902962/1208040193300233/f)

### Steps to test this PR

See:
- #5019
- #5042
- #5063
- #5064
- #5065
- #5105
- #5123

See scenarios and screenshots in
https://app.asana.com/0/1200581511062568/1208264037618741/f

---------

Co-authored-by: Dax The Translator <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants