Skip to content

[Modal Layout Picker] Request scaled Thumbnail images#13077

Merged
antonis merged 9 commits intodevelopfrom
issue/2445-ScaledThumb
Oct 16, 2020
Merged

[Modal Layout Picker] Request scaled Thumbnail images#13077
antonis merged 9 commits intodevelopfrom
issue/2445-ScaledThumb

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Oct 7, 2020

Fixes: wordpress-mobile/gutenberg-mobile#2445

Related PRs:
API Call: wordpress-mobile/WordPress-FluxC-Android#1710
Depends on: #13022

Description
This PR is part of the effort to rework the Starter Page Template Picker for new pages. This part of the initiative will focus on modifying the API call /wpcom/v2/sites/{site}/block-layouts to include the parameters defined in wordpress-mobile/gutenberg-mobile#2416 that will allow the resulting data to include thumbnail URLs that have been optimized for the requesting client.

To test:

Layout Picker should show when creating a new page from My Site or Site Pages the Modal Layout Picker appears.

  • Start by navigating to the Modal Layout Picker

WPCom Site

  1. Select a WPcom site and ensure a valid network connection
  2. Navigate to the Modal layout picker by either:
    • Selecting the FAB icon on the site page and selecting "Site page"
    • Selecting the ➕ on the Page List
  3. Using a network logger:
    • Expect to see the preview parameter return with data like:
      "preview": "https:\/\/headstartdata.files.wordpress.com\/2020\/01\/about-3.png?w=828&zoom=2"
      
    • Expect to see a network request with:
      https://public-api.wordpress.com/wpcom/v2/sites/{{SITEID}}/block-layouts?locale=en&preview_width=828.0&scale=2.0
      

Self-Hosted Site

  1. Select a Self-Hosted site and ensure a valid network connection
  2. Navigate to the Modal layout picker by either:
    • Selecting the FAB icon on the site page and selecting "Site page"
    • Selecting the ➕ on the Page List
  3. Using a network logger:
    • Expect to see the preview parameter return with data like:
      "preview": "https:\/\/headstartdata.files.wordpress.com\/2020\/01\/about-3.png?w=828&zoom=2"
      
    • Expect to see a network request with:
      https://public-api.wordpress.com/wpcom/v2/common-block-layouts?locale=en&preview_width=828.0&scale=2.0
      

Note: Caching of the API call will be implemented with wordpress-mobile/gutenberg-mobile#2456

PR submission checklist:

  • I have considered adding unit tests where possible.
  • 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.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Oct 7, 2020

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Oct 7, 2020

You can test the changes on this Pull Request by downloading the APK here.

* Shows the MLP
* @param supportedBlocks the supported blocks to filter fetched layouts (by default no filtering occurs)
* @param previewWidth the layout preview card width
* @param scale the screen density scale
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

scale is mainly used for iOS. We use the default value 1.0 and pass the rendered pixels per device in previewWidth

@antonis antonis marked this pull request as ready for review October 8, 2020 08:39
# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java
#	WordPress/src/main/java/org/wordpress/android/ui/pages/PagesFragment.kt
#	WordPress/src/main/java/org/wordpress/android/viewmodel/mlp/ModalLayoutPickerViewModel.kt
#	build.gradle
Copy link
Copy Markdown
Contributor

@Tug Tug left a comment

Choose a reason for hiding this comment

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

Followed testing instructions, I can confirmed the requests are working as intended 👍

@antonis antonis added this to the 16.0 milestone Oct 13, 2020
# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/ModalLayoutPickerFragment.kt
#	WordPress/src/main/java/org/wordpress/android/viewmodel/mlp/ModalLayoutPickerViewModel.kt
#	build.gradle
@malinajirka malinajirka self-assigned this Oct 16, 2020
Copy link
Copy Markdown
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

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

I have reviewed the code and it LGTM. I haven't tested the changes since they were already tested by Tug.

Base automatically changed from issue/2452-Preview to develop October 16, 2020 07:22
@antonis antonis merged commit 823f234 into develop Oct 16, 2020
@antonis antonis deleted the issue/2445-ScaledThumb branch October 16, 2020 07:37
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