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

Add FXIOS-6706 [v116] Screen Time implementation #15111

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

FilippoZazzeroni
Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni commented Jun 21, 2023

Jira ticket
Github issue

Description

Added implementation of Screen Time functionalities. To test this implementation use a real device, because on simulator screen time doesn't work. In order to test it, go to Settings > Screen Time > Content & Privacy Restrictions > Content Restrictions > Web Content and select Limit Adult Websites or Allowed Websites then navigate to a restricted page and you should see that the navigation is disabled.

Pull requests checks where applicable

  • Fill in the three TODOs above (tickets number and description of your work)
  • The PR name follows our naming guidelines
  • Accessibility implemented and tested (minimum Dynamic Text and VoiceOver)
  • Unit tests written and passing
  • Documentation / comments for complex code and public methods

@FilippoZazzeroni FilippoZazzeroni requested a review from a team as a code owner June 21, 2023 16:12
@lmarceau lmarceau changed the title Add FXIOS-14975 Screen Time implementation Add FXIOS-6706 [v116] Screen Time implementation Jun 21, 2023
@mobiletest-ci-bot
Copy link

mobiletest-ci-bot commented Jun 22, 2023

Messages
📖 Project coverage: 35.97%
📖 Edited 2 files
📖 Created 0 files

Client.app: Coverage: 34.27

File Coverage
WebviewViewController.swift 54.93%
AppSettingsTableViewController.swift 12.44% ⚠️

Generated by 🚫 Danger Swift against bc6019e

@@ -35,9 +38,18 @@ class WebviewViewController: UIViewController, ContentContainable, Screenshotabl
])
}

private func setupScreenTimeController() {
addChild(screenTimeController)
screenTimeController.view.frame = webView.frame
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use constraints here as well instead of setting a frame to avoid problems with rotation or other screen size changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok perfect i'm changing it

@thatswinnie thatswinnie merged commit 792b8ef into mozilla-mobile:main Jun 23, 2023
10 checks passed
@thatswinnie
Copy link
Contributor

Thank you so much @FilippoZazzeroni for implementing screen time! This is great!

@FilippoZazzeroni
Copy link
Collaborator Author

You're welcome @thatswinnie 🚀. Thank you a lot for your reviews.

@domcorvasce
Copy link

domcorvasce commented Jun 25, 2023

@FilippoZazzeroni @thatswinnie just a heads up: the current solution is also tracking page usage in incognito mode.
STWebpageController has no concept of "incognito mode" so it's up to the browser vendor to add checks (e.g. by setting suppressUsageRecording to true).
Neither Safari nor Chrome count incognito tabs towards screen time. Shouldn't Firefox follow the same behaviour?

@FilippoZazzeroni
Copy link
Collaborator Author

@domcorvasce thank you. i see safari when you enable content restrictions it disables the incognito mode, however if you can suppress the recording when you are in incognito mode, we should just set that boolean to true if we are in private mode. what do you think @thatswinnie ?

@domcorvasce
Copy link

domcorvasce commented Jun 26, 2023

I see safari when you enable content restrictions it disables the incognito mode

@FilippoZazzeroni that's a good point. We could use WebContentSettings.blockedByFilter to block incognito mode if content restrictions are enabled but I wouldn’t do it just like Chrome doesn’t.

One last note. I think there is some misunderstanding about this PR.
The disabled navigation is built in WebKit (at least in iOS 16). Try running the current Firefox iOS build from the App Store—which doesn't include this feature. It will still disable navigation for blocked websites.

This PR is adding support for Screen Time limits on web content, and the ability of Screen Time to show a time breakdown per website.

Disabling incognito mode should be discussed as part of a separate Family Controls integration.

@FilippoZazzeroni
Copy link
Collaborator Author

FilippoZazzeroni commented Jun 26, 2023

@domcorvasce ok. I think just turn true the suppressUsageRecording is simpler than check manged settings, when we are in private mode. Because i think you need to request authorization in order to access managed settings.

@FilippoZazzeroni
Copy link
Collaborator Author

I see safari when you enable content restrictions it disables the incognito mode

@FilippoZazzeroni that's a good point. We could use WebContentSettings.blockedByFilter to block incognito mode if content restrictions are enabled but I wouldn’t do it just like Chrome doesn’t.

One last note. I think there is some misunderstanding about this PR. The disabled navigation is built in WebKit (at least in iOS 16). Try running the current Firefox iOS build from the App Store—which doesn't include this feature. It will still disable navigation for blocked websites.

This PR is adding support for Screen Time limits on web content, and the ability of Screen Time to show a time breakdown per website.

Disabling incognito mode should be discussed as part of a separate Family Controls integration.

Ok maybe a solution could be to add the screen time implementation to entire browser view controller view, in order to limit the screen time to entire app, and suppress the recording inside web view controller when incognito mode is enabled. i don't think is needed to disable the incognito mode, since parental control can work on that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants