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

Dashboard Cards: Display 3 latest pages card #18337

Merged
merged 32 commits into from
May 1, 2023

Conversation

AjeshRPai
Copy link
Contributor

@AjeshRPai AjeshRPai commented Apr 28, 2023

Related Issue

Closes #18212

Description

This PR adds support for showing the Pages item in pages card.

Explanation of Changes

  • ⊕ Adds the UI for pages item in Pages card in Light and Dark mode
  • ⊕ The logic for showing the status icon and text according to the page status
  • ⊕ The logic for showing Last modified or Scheduled time in pages card according to status
  • ⊕ Adds unit tests in PagesCardBuilderTest.kt
  • ⊘ Does not implement the click listener for the page items - will be taken up in a separate PR
  • ⊘ Does not implement any tracking logic

📷 Screenshots

Pages card

Light Mode Dark Mode
screenshot_pages_card_lightMode_ screenshot_pages_card_night_mode_

Scheduled relative time

👁️ Note the relative time in Scheduled Page item in Card

In Minutes In Hours In Days In more than a week
screenshot_scheduled_in_minutes_ screenshot_scheduled_in_hours_ screenshot_scheduled_in_days_ screenshot_scheduled_in_months_

Test

Prerequisite

◐ Toggle the dashboard_card_pages flag
  1. Go to MeApp SettingsDebug settings
  2. Scroll to the Features in development section
  3. Tap on the item corresponding to the flag
  4. Tap RESTART THE APP button
Screenshot 2023-04-27 at 10 59 09 AM

Card UI is as expected in the Project spec and Designs

Project spec - pe7hp4-gi-p2
Design p2 - pcdRpT-2bP-p2
Design ref Figma - YSMw2nbFAgPpjZLLbYvTfT-fi-310_3783

  • Go to app → Dashboard
  • ✅ Verify that the Pages are shown with the correct title
    • Long titles are truncated
    • If no title is present for a page, then Untitiled is shown
  • ✅ Verify that the correct icon and text are shown for the Page status
    • Published, Draft and Scheduled
  • ✅ Verify that the correct time is shown next to the status icon and text
    • For Published and Draft page → the last modified time is shown
      • Modified date is Less than an hour → N minutes ago
      • Modified date is Less than a day but more than an hour → N Hours ago
      • Modified date is Less than a week → N Days ago
      • Modified date is More than 1 week → Date is shown
    • For Scheduled Page → the relative Scheduled time is shown
      • Scheduled date is in Less than an hour → In N minutes
      • Scheduled date is Less than a day but more than an hour → In N hours
      • Scheduled date is Less than a week → In N Days
      • Scheduled date is More than 1 week → Date is shown

💡 Note: To test the relative time, modify or schedule a page and go to Settings on device and change the device time.

Verify the Unit tests

Code review the unit tests in PagesCardBuilderTest.kt pass, sufficient and doesn't miss any scenario

Regression Notes

  1. Potential unintended areas of impact
    Pages card is not shown as expected

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manual testing and Unit tests

  3. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

UI Changes testing checklist:

  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

+ Adds: the logic to get the status text
+ Adds: the string resources for status text in pages card
+ Adds: the logic to get the status icon
+ Adds: the drawable resources for status icon in pages card
* Refactors: the status icon to be nullable in case status is
not identified
Updates: the status icon and text mapping of the pages card item with
 correct PagesCardContentType.kt
Updates: the logic of building the create page card with
mapped page items instead of api response
Updates: the params of create page card with footer click function
instead of the entire params
Updates: the logic of creating the pages items from api response by
filtering the supported status in pages card
@AjeshRPai AjeshRPai added this to the 22.4 milestone Apr 28, 2023
@AjeshRPai AjeshRPai self-assigned this Apr 28, 2023
@AjeshRPai AjeshRPai changed the title Display 3 latest pages card Dashboard Cards: Display 3 latest pages card Apr 28, 2023
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 28, 2023

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr18337-ffbe3fe
Commitffbe3fe
Direct Downloadjetpack-prototype-build-pr18337-ffbe3fe.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 28, 2023

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr18337-ffbe3fe
Commitffbe3fe
Direct Downloadwordpress-prototype-build-pr18337-ffbe3fe.apk
Note: Google Login is not supported on these builds.

Adds: the logic for getting the last edited or scheduled time using
date or modified time depending on status
Adds: the logic in PagesItemViewHolder to show the data
* Makes test statement shorter to fix lint errors
+ Adds mock for date time utils wrapper dependancy
}
}

private fun createNewPageCardWithAddPageMessage(params: PagesCardBuilderParams): CreatNewPageItem {
private fun createNewPageCardWithAddPageMessage(onFooterLinkClick: () -> Unit): CreatNewPageItem {
return CreatNewPageItem(
label = UiString.UiStringRes(R.string.dashboard_pages_card_no_pages_create_page_button),
Copy link
Contributor

Choose a reason for hiding this comment

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

(early np - since this is a draft) but you could statically import the namespace and drop the UiString prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, Thanks. Done in 574b12e

tools:text="@string/dashboard_card_page_item_status_published"
android:drawablePadding="@dimen/margin_medium"
app:layout_constraintStart_toStartOf="parent"
android:paddingStart="10dp"
Copy link
Contributor

Choose a reason for hiding this comment

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

np (again, a bit early) - just a reminder to use android:paddingHorizontal and android:paddingVertical. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, Thanks for point it out. Done in b4269b0

}

private fun getCreatePageCard(params: PagesCardBuilderParams): CreatNewPageItem {
private fun getCreatePageCard(pages: List<PageContentItem>, onFooterLinkClick: () -> Unit): CreatNewPageItem {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice refactor ❤️

AjeshRPai added 2 commits May 1, 2023 10:48
+ Adds: the logic to return relative time span for future dates in
 DateTimeUtilsWrapper.kt
AjeshRPai added 11 commits May 1, 2023 11:51
- Removes: redundant UiString in all the usages
+ Adds: test for scheduled and published page relative time shown
* Updates: test statements by moving the common mock to setUpMocks
function
* Updates: Models used in tests with status identifier
- Removes: redundant MySiteCardAndItemBuilderParams in all the usages
- Removes: PagesCardBuilderParams in tests with helper function
* Updates: the test statement to invoke BuilderParams generator
function to only build with relevant model(Scheduled/Published/Drafts)
 instead of all the models
+ Adds: the list divider element to the xml for pages item in card
* Updates: the padding attributes and margin attributes with
paddingHorizontal, paddingVertical and marginHorizontal
* Implements: the light/dark text color for status and
 last modified text
* Updates: the status icon color on light and dark mode
Adds: dimension values for pages item components
Replaces: the hardcoded references with values from dimens.xml
@AjeshRPai AjeshRPai added the [Status] Needs Design Review A designer needs to sign off on the implemented design. label May 1, 2023
@AjeshRPai AjeshRPai marked this pull request as ready for review May 1, 2023 12:02
@AjeshRPai AjeshRPai requested review from zwarm and osullivanchris May 1, 2023 12:02
Copy link
Contributor

@zwarm zwarm left a comment

Choose a reason for hiding this comment

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

@AjeshRPai - All works as expected. Dark/light mode, dates + relative time (future and past). 👍

Once CI finishes I am going to merge. @osullivanchris - any UI issues you may find will be addressed in a separate PR - we want to keep development moving along. Thanks for understanding.

* Use getRelativeTimeSpanString function if the date is in the future.
* Time spans in future are formatted like "In 42 minutes | In 2 days".
* */
fun getRelativeTimeSpanString(date: Date): String {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@zwarm zwarm removed the [Status] Needs Design Review A designer needs to sign off on the implemented design. label May 1, 2023
@zwarm zwarm merged commit 5b9dc0a into trunk May 1, 2023
@zwarm zwarm deleted the issue/18212-display-3-latest-pages-in-card branch May 1, 2023 17:49
@osullivanchris
Copy link

@zwarm @AjeshRPai this looks great 👍 3 small details (which are fine for another PR as mentioned)

  • The background for the label (draft/scheduled/published) seems to be using the color from the iOS design rather than the Android design. For Android I tried to use something existing, and took it from the Reader tags.
  • The text color of the secondary text (in 2 hours etc) isn't the same as the other cards. I think again it has grabbed a value from the iOS design. Can we use the same text color as the other cards (e.g. posts).
  • This one is per design, but think we should tweak it. The rows are optically off centre vertically. Could we move everything up by 2dp while keeping the row height? Might mean reducing top padding by 2dp, adding bottom padding by 2dp, or similar

@AjeshRPai
Copy link
Contributor Author

Hey @osullivanchris

I will implement these changes in a separate PR by tomorrow. I have added the improvements you mentioned in this issue.

cc: @zwarm

@AjeshRPai AjeshRPai mentioned this pull request May 3, 2023
12 tasks
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.

Dashboard Cards: Display 3 latest pages in Pages card
4 participants