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

For FNX-22339: UI components for recently added bookmarks #19953

Merged

Conversation

eliserichards
Copy link
Contributor

@eliserichards eliserichards commented Jun 10, 2021

For FNX-22339
Designs are here

UI components for recently added bookmarks on the homescreen. This is broken out of #19835 so it's not so large. Diagram for how these are broken down: https://docs.google.com/drawings/d/1oiHqRl9f_LwsLbQ98zUBjChyDn5xm7us-iDF4rqhRak/edit?usp=sharing

  • Header with "show all" button
  • Bookmark item
  • "Component" to house the items (contains recent_bookmarks_list)
  • New styles & dimens to match the designs

Screenshots

header with show all button
image

button padding (accessibility)
image

Bookmark item with image, title, and subtitle
image image

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

@eliserichards eliserichards requested review from a team as code owners June 10, 2021 18:07
@eliserichards eliserichards added the needs:review PRs that need to be reviewed label Jun 10, 2021
android:layout_height="@dimen/recent_bookmark_item_height"
android:orientation="vertical">

<com.google.android.material.card.MaterialCardView
Copy link
Contributor

Choose a reason for hiding this comment

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

Just dropping a passing-by comment: favicon_card is the single child of the ConstraintLayout. Is this intentional?

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! You can see the difference between this file and top_site_item: for the top site cards, we want a card view with a title beneath it. For these bookmarks, we want the text and and the icon/image inside the card itself (lines 29/44)

(Link to the design if you're curious: https://www.figma.com/file/am9EJGg6ow29PXWkc9jcOH/MR2.1?node-id=11%3A396)

@mergify
Copy link
Contributor

mergify bot commented Jun 10, 2021

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

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2021

Codecov Report

Merging #19953 (79888d8) into master (9d3cf79) will decrease coverage by 0.00%.
The diff coverage is n/a.

❗ Current head 79888d8 differs from pull request most recent head f3d13a7. Consider uploading reports for the commit f3d13a7 to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##             master   #19953      +/-   ##
============================================
- Coverage     36.87%   36.86%   -0.01%     
- Complexity     1629     1630       +1     
============================================
  Files           541      541              
  Lines         21021    21021              
  Branches       3124     3124              
============================================
- Hits           7751     7750       -1     
+ Misses        12379    12378       -1     
- Partials        891      893       +2     
Impacted Files Coverage Δ
...rg/mozilla/fenix/settings/account/AccountUiView.kt 34.14% <0.00%> (-2.44%) ⬇️
...in/java/org/mozilla/fenix/perf/NavGraphProvider.kt 62.50% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d3cf79...f3d13a7. Read the comment docs.

android:layout_height="match_parent"
android:isScrollContainer="true"
android:gravity="start">

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the contents of recent_bookmarks_header be here (above the RecyclerView)? Is there a situation where you can have a bookmarks header without the list?

You can use <include layout="" /> if you want to keep some separation of concerns between the header and this instead of in-lining.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point! I want to keep them separate for now in case we decide to do a placeholder component (like collections), so I think <include layout..> would be a good solution.

Copy link
Member

@gabrielluong gabrielluong left a comment

Choose a reason for hiding this comment

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

I only looked at the header. You probably want another review for the bookmarks component.

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

Instead of having 2 exactly identical layouts, we might want to refactor https://searchfox.org/mozilla-mobile/source/fenix/app/src/main/res/layout/recent_tabs_header.xml into recent_header.xml and specify the header.text and header.contentDescription in the view holder instead.

We managed to align the blueprint to be similar to the figma frame structure (think of this as header bounding box that you can see in the layers in figma), which you might appreciate.

Screen Shot 2021-06-11 at 11 22 04 AM

Screen Shot 2021-06-11 at 11 15 22 AM

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 can be in a different PR. There are a number of things that my components are going to add that are missing from first glance in the "Jump back in" pr and I'd rather get this landed first then deal with that.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, I think you can duplicate https://searchfox.org/mozilla-mobile/source/fenix/app/src/main/res/layout/recent_tabs_header.xml more or less here. It will help you cut back on the number of variables and really simplify your layout.

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 prefer to keep it as-is

app/src/main/res/layout/component_recent_bookmarks.xml Outdated Show resolved Hide resolved
app/src/main/res/values/strings.xml Show resolved Hide resolved
app/src/main/res/values/styles.xml Outdated Show resolved Hide resolved
@@ -403,7 +403,14 @@
<item name="android:textColor">?primaryText</item>
</style>

<style name="Body12TextStyle" parent="TextAppearance.MaterialComponents.Body1">
<item name="android:textColor">@color/photonDarkGrey05</item>
Copy link
Member

Choose a reason for hiding this comment

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

Same as below, but we should probably stick to using:

item name="android:textColor">?primaryText</item>

to keep these generic Body text styles consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not the primaryText color.. I'll have to see if one exists for photonDarkGrey05 and if not I'll set one 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.

looks like "Jump back in" tabs is using a pre-defined color as well (<color name="home_show_all_button_text">@color/photonDarkGrey05</color>). I'm going to keep this as-is for now and fix them together in a separate PR when we get the Dark values

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 got the dark theme colors from Nicole. Fixed it here and filed a new issue to add them to "Jump back in"

Copy link
Member

Choose a reason for hiding this comment

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

I got the dark theme colors from Nicole. Fixed it here and filed a new issue to add them to "Jump back in"

Ah yes, we just added home_show_all_button_text. It is using photoLightGrey50 for the dark theme in the "Show all" button - see https://searchfox.org/mozilla-mobile/source/fenix/app/src/main/res/values-night/colors.xml#99 (note the values-nightly/colors.xml). I checked with Nicole about the header colours since I didn't see this response before. I still hold that we probably want to keep the textColor as ?primaryText in these BodyXXTextStyle since it would be strange to have "12" be different from the rest and we can just add the textColor locally.

Copy link
Member

Choose a reason for hiding this comment

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

The "Jump back in" header actually also uses the correct dark theme color with using style="@style/Header20TextStyle". In our existing color variables and component system, ?primaryText maps to https://searchfox.org/mozilla-mobile/source/fenix/app/src/main/res/values-night/colors.xml#7 which maps to https://searchfox.org/mozilla-mobile/source/fenix/app/src/main/res/values/colors.xml#80 which is photonLightGrey05. I will close the Jira issue since there's no change necessary.

You might be interested in reusing home_show_all_button_text since we anticipated the need for a generic "Show all" button text color.

app/src/main/res/values/styles.xml Outdated Show resolved Hide resolved
app/src/main/res/values/dimens.xml Show resolved Hide resolved
app/src/main/res/values/dimens.xml Show resolved Hide resolved
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
Copy link
Member

Choose a reason for hiding this comment

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

I feel this change was in response to the dark theme feedback. I am not entirely sure since we can't really test its usage since it's not being used. However, if this is to adjust for dark theme, we actually do this quite differently without selectors and in nightly/colors.xml

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 is being used in another PR. I just want to get this landed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear, there is additional work needed to add dark themes for "Jump back in" as well. This doesn't have to happen in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I guess this is what makes the PR and review a bit weird since it's just xml.

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 believe I made it clear why this was broken out. You can see the link to the main PR in the description

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 what the additional work needed for the dark theme header since we already use ?primaryText in Header20TextStyle. I think that's probably even more reasons we should just not have 2 headers and aim to write a single component.

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, and this will happen in another PR.

<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
Copy link
Member

Choose a reason for hiding this comment

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

There's nothing wrong with using <selector> for the different text color state between light and dark theme. I personally would be interested in getting feedback from everyone on whether or not we should be moving towards doing it this way or just adding the color variables in colors.xml and values-night/colors.xml (https://searchfox.org/mozilla-mobile/search?q=home_show_all_button_text&path= for example).

<item name="cardElevation">@dimen/recent_bookmark_item_card_elevation</item>
</style>

<style name="recentBookmarkFavicon">
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, we should avoid adding these kinds of styles in future work, it's a strange precedence that exists in the code base because, the way we're using it in Fenix, doesn't seem to add any value from just setting these one-time used styles directly in the layout files.

Nothing to change here for now, just food for thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's good to know. We definitely don't want to make styles so huge that it becomes unusable

@@ -403,7 +403,14 @@
<item name="android:textColor">?primaryText</item>
</style>

<style name="Body12TextStyle" parent="TextAppearance.MaterialComponents.Body1">
<item name="android:textColor">@color/primary_state_title_text_color</item>
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I am gonna blocked this on one change here, which might've been missed in the comments #19953 (comment). Realistically, I think this textColor should be define in recentBookmarkItemSubTitleText as Body12 shouldn't be using a different text color compare to all its BodyXXTextStyle.

Suggested change
<item name="android:textColor">@color/primary_state_title_text_color</item>
<item name="android:textColor">?primaryText</item>

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 is happening in the other PR, and I can't do that until this is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, this is not supposed to be ?primaryText color, it's a different value

Copy link
Member

Choose a reason for hiding this comment

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

Also, this is not supposed to be ?primaryText color, it's a different value

I think there's some misunderstanding here. We want this to be ?primaryText here since all the other BodyXXTextStyle uses ?primaryText.

Since Body12TextStyle is extended in recentBookmarkItemSubTitleText, we can just move <item name="android:textColor">@color/primary_state_title_text_color</item> over.

@eliserichards eliserichards merged commit e373f50 into mozilla-mobile:master Jun 11, 2021
@eliserichards eliserichards removed the needs:review PRs that need to be reviewed label Jun 11, 2021
grigoryk pushed a commit to grigoryk/fenix that referenced this pull request Jun 15, 2021
…bile#19953)

* Top level layout with recyclerview for recent bookmarks

* Add layout for recent bookmarked item, including strings and styles.

* Header layout for recently saved bookmarks

* Address review comments

* Include the header for recent bookmarks in the component layout

* Add dark theme colors for button and title styles

* Recent bookmark card title text color for dark mode/light mode
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants