Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Re-enable screentime.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T committed Jan 3, 2024
1 parent 1c6d636 commit 7be9780
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
15 changes: 8 additions & 7 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ public class BrowserViewController: UIViewController {
}

if Preferences.Privacy.screenTimeEnabled.value {
// Enable once fixed, ref #8566
//screenTimeViewController = STWebpageController()
screenTimeViewController = STWebpageController()
}
}

Expand Down Expand Up @@ -1252,9 +1251,11 @@ public class BrowserViewController: UIViewController {
}

if let screenTimeViewController = screenTimeViewController {
webViewContainer.addSubview(screenTimeViewController.view)
addChild(screenTimeViewController)
screenTimeViewController.didMove(toParent: self)
if screenTimeViewController.parent == nil {
addChild(screenTimeViewController)
screenTimeViewController.didMove(toParent: self)
webViewContainer.addSubview(screenTimeViewController.view)
}

screenTimeViewController.view.snp.remakeConstraints {
$0.edges.equalTo(webViewContainer)
Expand Down Expand Up @@ -3321,13 +3322,13 @@ extension BrowserViewController: PreferencesObserver {
recordAdsUsageType()
case Preferences.Privacy.screenTimeEnabled.key:
if Preferences.Privacy.screenTimeEnabled.value {
// Enable once fixed, ref #8566
//screenTimeViewController = STWebpageController()
screenTimeViewController = STWebpageController()
if let tab = tabManager.selectedTab {
recordScreenTimeUsage(for: tab)
}
} else {
screenTimeViewController?.view.removeFromSuperview()
screenTimeViewController?.willMove(toParent: nil)
screenTimeViewController?.removeFromParent()
screenTimeViewController?.suppressUsageRecording = true
screenTimeViewController = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ extension BrowserViewController {
/// it will not block anything for the rest of its lifecycle. Our internal urls have to be bridged to an empty https url.
func updateScreenTimeUrl(_ url: URL?) {
guard let url = url, (url.scheme == "http" || url.scheme == "https") else {
screenTimeViewController?.url = URL(string: "https://about:blank")
screenTimeViewController?.view.removeFromSuperview()
screenTimeViewController?.willMove(toParent: nil)
screenTimeViewController?.removeFromParent()
return
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Brave/Frontend/ClientPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ extension Preferences {
/// The toggles states for clear private data screen
static let clearPrivateDataToggles = Option<[Bool]>(key: "privacy.clear-data-toggles", default: [])
/// Enables the Apple's Screen Time feature.
public static let screenTimeEnabled = Option<Bool>(key: "privacy.screentime", default: true)
public static let screenTimeEnabled = Option<Bool>(key: "privacy.screentime-toggle", default: AppConstants.buildChannel == .beta)

}
final public class NewTabPage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ struct OtherPrivacySettingsSectionView: View {
subtitle: String.localizedStringWithFormat(Strings.googleSafeBrowsingUsingWebKitDescription, URL.brave.safeBrowsingHelp.absoluteString),
option: Preferences.Shields.googleSafeBrowsing
)
// Enable once fixed, ref #8566
/*
OptionToggleView(
title: Strings.screenTimeSetting,
subtitle: String.localizedStringWithFormat(Strings.screenTimeSettingDescription, URL.brave.screenTimeHelp.absoluteString),
option: Preferences.Privacy.screenTimeEnabled
)
*/
ShieldToggleView(
title: Strings.P3A.settingTitle,
subtitle: Strings.P3A.settingSubtitle,
Expand Down

0 comments on commit 7be9780

Please sign in to comment.