Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

For #21900 - Converted the Tabs Tray Synced Tabs to Compose #22798

Merged
merged 2 commits into from
Feb 15, 2022
Merged

For #21900 - Converted the Tabs Tray Synced Tabs to Compose #22798

merged 2 commits into from
Feb 15, 2022

Conversation

MozillaNoah
Copy link
Contributor

@MozillaNoah MozillaNoah commented Dec 11, 2021

Fixes #21900

Pull Request checklist

  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features. In addition, it includes a screenshot of a successful accessibility scan to ensure no new defects are added to the product.

To download an APK when reviewing a PR:

  1. click on Show All Checks,
  2. click Details next to "Taskcluster (pull_request)" after it appears and then finishes with a green checkmark,
  3. click on the "Fenix - assemble" task, then click "Run Artifacts".
  4. the APK links should be on the left side of the screen, named for each CPU architecture

@gabrielluong
Copy link
Member

gabrielluong commented Dec 11, 2021

Apologizes for the early drive by. I couldn't help myself to admiring some new Compose code.

@mergify
Copy link
Contributor

mergify bot commented Dec 14, 2021

This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Dec 15, 2021

This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏

@gabrielluong gabrielluong added the pr:work-in-progress PRs that are not ready to be reviewed yet and are actively being worked on label Dec 15, 2021
@jonalmeida
Copy link
Contributor

Screen Shot 2021-12-15 at 11 20 20 AM
external-content duckduckgo com

@MozillaNoah MozillaNoah changed the title WIP - For #21900 - Converted the Tabs Tray Synced Tabs to Compose For #21900 - Converted the Tabs Tray Synced Tabs to Compose Dec 16, 2021
@MozillaNoah MozillaNoah marked this pull request as ready for review December 16, 2021 21:51
@MozillaNoah MozillaNoah requested review from a team as code owners December 16, 2021 21:51
Copy link
Contributor

@jonalmeida jonalmeida left a comment

Choose a reason for hiding this comment

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

Great! Just some nits and questions, but it looks good.

I'll leave the final review for gl though since I only focused on Synced Tabs feature and not the Compose code.

*/
@Composable
fun SyncedTabsDeviceItem(deviceName: String) {
PrimaryText(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: in the designs, we needed to add a horizontal line above the device name. I think it's fine to leave out if you're planning on picking up #19942 next.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I noticed that without sticky headers it did become hard to tell one section from the other. My intent was to immediately do the sticky header issue next.

@MozillaNoah
Copy link
Contributor Author

MozillaNoah commented Dec 20, 2021

Most recent push was to fix some of the previews. Fun fact: the Compose previews don't like using stuff in the Components class, so the preview builds error out since Components is dependent on FenixApplication. So the most recent changes were to move the URL parsing to make URLs text-friendly out of the Composables and into one of the helper functions.

@mergify
Copy link
Contributor

mergify bot commented Dec 22, 2021

This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏

@gabrielluong gabrielluong removed the pr:work-in-progress PRs that are not ready to be reviewed yet and are actively being worked on label Jan 12, 2022
@@ -69,4 +70,18 @@ class TabsTrayStoreReducerTest {

assertEquals(expectedState, resultState)
}

@Test
fun `WHEN UpdateSyncedTabs THEN synced tabs are added`() {
Copy link
Member

Choose a reason for hiding this comment

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

@jonalmeida Hm.. it's actually interesting to see that we have a Reducer and Store test separately. Usually I see we use the Store test to test the underlying Reducer. Is there any benefit from having them separate like this? I can imagine we end up picking and choosing which actions are dispatched and resulting state in different files.

Copy link
Contributor

Choose a reason for hiding this comment

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

I missed this comment.

What does the store add that needs to be tested? In most of the stores, the store doesn't do anything for us within the structure. The logic is within the state/reducer. Put state in, reduce, test state out.

The store holds an executor and provides single access to the state and to dispatch actions. Nothing worth testing in tabs tray.

@@ -76,30 +70,38 @@ class TrayPagerAdapter(
}
PrivateBrowserPageViewHolder.LAYOUT_ID -> {
PrivateBrowserPageViewHolder(
itemView,
LayoutInflater.from(parent.context).inflate(viewType, parent, false),
tabsTrayStore,
browserStore,
interactor
)
}
SyncedTabsPageViewHolder.LAYOUT_ID -> {
SyncedTabsPageViewHolder(
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering if we need to do something similar to ComposeViewHolder to avoid #22383

when (viewHolder) {
is NormalBrowserPageViewHolder -> viewHolder.bind(normalAdapter)
is PrivateBrowserPageViewHolder -> viewHolder.bind(privateAdapter)
is SyncedTabsPageViewHolder -> viewHolder.bind()
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

align with which part? not needing bind() call?

Copy link
Member

@gabrielluong gabrielluong Jan 21, 2022

Choose a reason for hiding this comment

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

Ya not needing to call bind(), I don't think we need to do this in the current PR. This can be a followup.

Copy link
Contributor Author

@MozillaNoah MozillaNoah Jan 24, 2022

Choose a reason for hiding this comment

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

Reading back through this, we also may not even need to file a separate follow-up, since the real follow-up is converting the rest of TabsTray to Compose. I'm happy to still do so though, since the timeline for the rest of the stuff is fluctuating.

@@ -191,7 +191,7 @@
<!-- Browser menu toggle that installs a Progressive Web App shortcut to the site on the device home screen. -->
<string name="browser_menu_install_on_homescreen">Install</string>
<!-- Menu option on the toolbar that takes you to synced tabs page-->
<string name="synced_tabs">Synced tabs</string>
<string name="synced_tabs" moz:removedIn="98" tools:ignore="UnusedResources">Synced tabs</string>
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering about this removal. Are we removing view_synced_tabs_title because it is never used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Based on some context clues of git annotations, I am under the impression that Sync previously lived under its own screen + screen title, and the layout + string are leftover from that era after synced tabs were moved to the tabs tray.

accountManager = accountManager,
view = this,
lifecycleOwner = lifecycleOwner,
onTabClicked = {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe file something for AC about cleaning this up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd assume it'd be a part of this mozilla-mobile/android-components#11552

SyncButtonBinding(store) { listener?.onRefresh() }
}

override var listener: SyncedTabsView.Listener? = null
Copy link
Member

Choose a reason for hiding this comment

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

This is a followup. Same as above about cleaning this up in AC. I would verify with @jonalmeida and make sure there's no other consumers here.

Copy link
Member

Choose a reason for hiding this comment

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

While I am here, is there an actual listener that is attached to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is some of the weirdness of the Observable<SyncedTabsView.Listener> by ObserverRegistry(). From my understanding it's initialized at runtime but none of that should be necessary, hopefully, after mozilla-mobile/android-components#11552.

@MozillaNoah
Copy link
Contributor Author

MozillaNoah commented Feb 7, 2022

Most recent push simply increases the spacing between the error text and the error button from 8dp to 12dp.

@MozillaNoah
Copy link
Contributor Author

Push to update from main to fix colors + build issue

@mergify
Copy link
Contributor

mergify bot commented Feb 8, 2022

This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏

onClick = onClick
)
.padding(horizontal = 16.dp)
.defaultMinSize(minHeight = 56.dp),
Copy link
Member

Choose a reason for hiding this comment

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

General question outside of the review, I am wondering how we decide to uses defaultMinSize and height(IntrinsicSize.Min) (in general, nothing in particular about the current code).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used defaultMinSize to be a more direct 1:1 to android:minHeight in XML (to help ensure with a default text size that there would be enough padding), and the height(IntrinsicSize.Min) was used when I was specifically trying out random things to get the dashed border for the error UI to show. The documentation for Modifier.height() and Modifier.defaultMinSize() aren't the clearest though on when to use either.

@mergify
Copy link
Contributor

mergify bot commented Feb 14, 2022

This pull request has conflicts when rebasing. Could you fix it @MozillaNoah? 🙏

@MozillaNoah MozillaNoah added the pr:needs-landing PRs that are ready to land [Will be merged by Mergify] label Feb 14, 2022
@MozillaNoah MozillaNoah reopened this Feb 14, 2022
@mergify mergify bot merged commit 48141b2 into mozilla-mobile:main Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr:needs-landing PRs that are ready to land [Will be merged by Mergify]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move Tabs Tray to compose: Synced Tabs list
4 participants