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

iOS 16 Lock Screen Widgets: Today Views Widget #20435

Merged
merged 11 commits into from
Sep 4, 2023

Conversation

staskus
Copy link
Contributor

@staskus staskus commented Mar 30, 2023

Note:

  • All the work is done by @tzef,
  • Feature Flag Disabled (will be enabled once the feature is decided to be released)
  • All the PRs merged into this branch are reviewed

Description

This is the PR to merge the feature branch into the trunk. All commits are simply merging sub PR into this branch without introducing any new changes. All sub PR have been reviewed and are listed below for reference.

  1. Add new feature flag for lock screen widgets in Jetpack  #20309
  2. Implement lock screen widgets UI #20312
  3. Add localizable string for "Views Today" title #20353
  4. [BugFix] Fix widget of home screen for WordPress disappeared #20371
  5. Extract content logic to config from lock screen widget #20317
  6. Create a standalone TimeLineProvider and TimelineEntry for the lock screen  #20368
  7. Implement view for logged-out, no-site, and no-data status #20399
  8. Notify to reload the timelines for lock screen widget #20405
  9. Implement event tracking for the new lock screen widget  #20422
  10. Disable lockScreenWidget feature flag #20427

Testing Instructions

Feature flag protect

Given lockScreenWidget feature flag disabled, note that this needs to be programmatically changed. It can't be overwritten in the app setting because the widget list updates along with the app installation.

  1. Long press the lock screen to turn on editor mode
  2. The Jetpack application shouldn't be in the selection page

Enable lockScreenWidget feature flag the following testings

Only for Jetpack

  1. Build WordPress target
  2. Long press the lock screen to turn on editor mode
  3. The WordPress application shouldn't be in the selection page

Build Jetpack target for the following testings

Widget Selection (Fresh install or Logged out)

  1. The Jetpack application should be in the selection page
  2. The widget data should display placeholder data (My WordPress Site with 649 views today)

Add to the lock screen

  1. Tap the widget in the selction page
  2. The widget should be added to the rectangular place (below the time)

Logged-Out status

  1. The widget content should be LocalizableStrings.unconfiguredViewJetpackTodayTitle ("Log in to Jetpack to see today's stats.") as the same as home screen today widget

Redirection for unconfigured status

  1. Tap the widget
  2. The Jetpack app should open

No-Sites status

  1. Log in with the account without any websites
  2. The widget should change the content to LocalizableStrings.noSiteViewTodayTitle ("Create or add a site to see today's stats.") as the same as home screen today widget

Site-Selected status

  1. Switch to the account with at least one website
  2. The widget should change to success layout with stats data of the default website

Widget Selection (Logged in)

  1. Go to widget selection add one more widget
  2. The widget data should display the stats of the default website instead of placeholder

Switch Website

Given the logged-in account with more than one website

  1. Tap widget in lock screen when editor mode
  2. Select another website
  3. The widget should be in rendering mode when fetching data
  4. The widget should display the corresponding views in today

Redirection for success status

  1. Tap the widget
  2. The app should open and redirect to the Stats/Days for the widget-selected website.

Widget updated when stats data updated

Can temporarly change the LockScreenSingleStatView Text(viewModel.title) to Text(viewModel.updatedTime.mediumStringWithTime()) for easy verification of the update.

  1. Tap the widget redirect to the insights page to trigger the API refresh
  2. The widget in lock screen should update when the new data date compared to widget data date is larger than one minute
  3. The another widget with different selected website shouldn't update

Widget autorefreshed per 30 mins

Changing system time is not working from my test, and the laptop can't be in sleep mode.

  1. Wait for 30 mins (The mechanism is not very accurate, minutes of delay is acceptable)
  2. The widget should be updated automatically

Regression Notes

  1. Potential unintended areas of impact
    Home Screen Widgets

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

  • Existing Widgets
    Add today, this week, and all time widgets to the home screen, all won't be impacted after app updated
  • Adding Widgets
    After app updated, still able to add today, this week, and all time widgets to the home screen
  • Shouldn't be impacted by lock screen widget feature flag
    No matter if lockScreenWidget is enabled or disabled, the above two test cases should't be impacted
  1. What automated tests I added (or what prevented me from doing so)
  • WidgetsViewModelMapperTests test the view model is correctly converted from the stats data.
  • WidgetDataReaderTests test the widget status is correctly converted based on the account and website status.
  • WidgetUrlSourceTests test the widget URL is correct, and the source can be mapped to the right deep link source type for event tracking.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • 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.

tzef added 10 commits March 15, 2023 11:10
* Add new feature flag for widget in lock screen

* Add new widget kind to widget configuration

* Add empty lock screen widget

* Add JETPACK_STATS_WIDGETS compilation condition

To prevent lock screen widgets from displaying on WordPress target

* Move LockScreenStatsWidgetsView to views folder group

* Revert compilation condition, change to isJetpack of AppCondiguration
* Extract statsUrl from private to extension for reusable with lock screen widget

* Implement single stat view for today views widget

Add view provider for handling building view for site selected status
Add ViewModelMapper for converting viewModel from home widget data

* Update LockScreenStatsWidgetsView body to get the view from view provider

* Add mapper test to verify the viewModel converting from widget data correctly

Add mapper and viewModel to WordPress target because app extension is not able to run unitTest

* Fix getStatsURL typo
* Add views in today localizable string for footer label

* Remove dateRange and footer, only title is enough for existing feature
The root cause is the WidgetBundleBuilder body doesn't allow control flow statements, move it to supportedFamilies with feature flag to keep all control logic in the same place
* Update title of view provider from hardcoded to pass from config

* Add lock screen stats widget config and implementation to include required information

* Pass config to LockScreenStatsWidget

Replaced the hardcoded data with config properties

* Add associated type view for other status and TODO comments

* Extract app configuration and feature flag check into config
…creen (#20368)

* Add widget data and timeline entry for lock screen to separate concerns

* Add lock screen time line provider for lock screen stats widget entry

Update stats widgets service result type to consist of home widget and lock screen widget for reusable

* Update to use LockScreenSiteListProvider in LockScreenStatsWidget

Update associated type widget data to conform `LockScreenStatsWidgetData` more

Update model mapper and view provider to based on lock screen widget data

Remove unnecessary `disabled` status from `LockScreenStatsWidgetsView`

Remove unnecessary `widgetKind` parameter from `LockScreenStatsWidget`

Remove unused statsURL converter from the view model mapper

Add home widget data conform lock screen widget data extension to WordPress target for unitTest

* Extract widget load data to loader for sharing with lock screen time line provider

* Update widget reader to extract the cache read from getSnapshot

* Extract noData, noSite, loggedOut, disabled status checking logic to data reader with status callback

* Add unitTest for widget data reader

Extract cache reading to `HomeWidgetDataFileReader` for mocking the testing object

Extract app configuration is jetpack to parameter for mocking the config

* Remove multiple space lines

* Update multiple callback to Result and enum Error
* Add unconfigured view for lockscreen widget

* Add unconfigured view model to view provider and model mapper

* Add unconfigured view model unit test

* Add background to unconfigured view align with success status widget appearance

* Remove todo comments
* Add event key to configuration and pass to trackers in lockscreen widget

Expand tracks for lockscreen stats entry

Add rectangular widgets count and widgets update of the new widget

* Add lockscreen_widget source to deeplink tracked

Update statsUrl to widgetUrl for separating the url from homescreen widgets

* Update unitTests

* Remove separate widget url, move widget source from widget data extension

Add widget source type, assign the type in widgetURL in the view

* Add widget url source test to verify the converting with DeepLinkSource
@staskus staskus changed the title iOS 16 Lock Screen Widgets: Today Views iOS 16 Lock Screen Widgets: Today Views Widget Mar 30, 2023
@staskus staskus requested review from wargcm, guarani and sla8c March 30, 2023 14:21
@staskus
Copy link
Contributor Author

staskus commented Mar 30, 2023

Note for reviewers:

This is the work done by @tzef. I'm creating the PR due to limited permissions. All the PRs that went into this branch are already reviewed.

  • This is the whole functionality for Today Views widget (see description).
  • For now the feature flag is disabled, although in my opinion this could be the candidate for a release without additional functionality

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 30, 2023

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr20435-3b8e679
Version23.1
Bundle IDorg.wordpress.alpha
Commit3b8e679
App Center BuildWPiOS - One-Offs #6948
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 30, 2023

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr20435-3b8e679
Version23.1
Bundle IDcom.jetpack.alpha
Commit3b8e679
App Center Buildjetpack-installable-builds #5988
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@sla8c sla8c left a comment

Choose a reason for hiding this comment

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

All test instructions worked for me. @staskus I noticed that the test Jetpack Build for Testing still says expected and has not passed.

@guarani
Copy link
Contributor

guarani commented May 2, 2023

👋 @staskus, does this need a review?

@staskus
Copy link
Contributor Author

staskus commented May 3, 2023

👋 @staskus, does this need a review?

@guarani, thanks for checking.

Not now. Every single part of it is already reviewed. I will think if it makes sense to merge it now. It's under the disabled feature flag.

Regarding finishing the project. There's a lot of valuable functionality implemented, it could be a small project to add the missing pieces and release it.

@guarani
Copy link
Contributor

guarani commented May 4, 2023

Thanks @staskus! Let me know if I can help with anything.

@twstokes twstokes added the Widgets Anything related to Home Screen widgets label Aug 25, 2023
@peril-wordpress-mobile
Copy link

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@staskus
Copy link
Contributor Author

staskus commented Sep 4, 2023

I retested and merged with trunk. This PR is safe to merge since it has a feature flag disabled.

No site Site Logged out
Simulator Screenshot - iPhone 14 - 2023-09-04 at 12 54 26 Simulator Screenshot - iPhone 14 - 2023-09-04 at 12 14 50 Simulator Screenshot - iPhone 14 - 2023-09-04 at 12 12 13

@staskus staskus added this to the 23.3 milestone Sep 4, 2023
@staskus
Copy link
Contributor Author

staskus commented Sep 4, 2023

@guarani, I want to merge this PR but it looks like this PR requires another review, although this is already approved. Could you review it?

This functionality is behind the feature flag. I want to merge it, and build upon it to include a few more configurations before releasing.

Copy link
Contributor

@guarani guarani left a comment

Choose a reason for hiding this comment

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

Hey @staskus, if I understand correctly, I can approve this without reviewing it because it's already been reviewed. Is that correct?

I'm leaving an approval, but if you'd like me to review it (go through the code, test it, etc.) before merging, I'd be happy to do that/

@staskus
Copy link
Contributor Author

staskus commented Sep 4, 2023

@guarani thanks! Yes, I think it's appropriate. It's all been reviewed and approved. You can test it once the feature flag will be enabled.

@staskus staskus merged commit d45f864 into trunk Sep 4, 2023
@staskus staskus deleted the feature/19411-add-lock-screen-stats-widgets branch September 4, 2023 17:05
@staskus staskus mentioned this pull request Sep 8, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stats Widgets Anything related to Home Screen widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants