Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8095f21
start of ui work
brindy Oct 30, 2017
73a5337
show dashboard modally
brindy Oct 30, 2017
357a27a
use embedded view for navigation controller
brindy Oct 30, 2017
22a19da
add transition for showing privacy protection dashboard under omni bar
brindy Oct 31, 2017
584e9f9
add more privacy protection ui and fix a bug with transitions
brindy Oct 31, 2017
2e08d63
add placeholder for toggle
brindy Oct 31, 2017
81d428f
support kerning of text
brindy Oct 31, 2017
6cb746b
Merge branch 'develop' into feature/privacy_protection_dashboard
brindy Oct 31, 2017
6fc18c4
Merge branch 'develop' into feature/privacy_protection_dashboard
brindy Oct 31, 2017
418a39d
add structure for navigating in the privacy protection screens
brindy Nov 1, 2017
51c0092
add more ui setup for privacy protection
brindy Nov 1, 2017
ac7f3b7
show privacy grade and update it when it changes
brindy Nov 2, 2017
d204970
add additional updates to the ui based on site rating
brindy Nov 2, 2017
dd66963
update trackers info on the overview screen
brindy Nov 3, 2017
80802d0
update privacy practices
brindy Nov 3, 2017
58c73b3
disable table selections
brindy Nov 3, 2017
085a802
show upgraded status of the protection
brindy Nov 4, 2017
2026072
fix broken tests and add one for blocked only
brindy Nov 4, 2017
701e04e
remove unused content blocker ui
brindy Nov 5, 2017
132f47a
Merge branch 'develop' into feature/privacy_protection_dashboard
brindy Nov 5, 2017
0a537ac
remove content blocking toggle from settings
brindy Nov 5, 2017
e589b89
address PR feedback
brindy Nov 7, 2017
1fa54b0
more pr feedback and a rename, as discussed
brindy Nov 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update trackers info on the overview screen
  • Loading branch information
brindy committed Nov 3, 2017
commit dd669639c5bfc688be24425d2b53ca3624610d5c
17 changes: 15 additions & 2 deletions Core/SiteRating.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ public class SiteRating {

return nil
}


public var majorTrackersDetected: Int {
return majorTrackers(trackers: trackersDetected)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is really a count of the unique major tracker networks detected (not a total). Maybe rename to `uniqueMajorTrackerNetworksDetected?

}

public var majorTrackersBlocked: Int {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as before, rename to uniqueMajorTrackerNetworksBlocked?

return majorTrackers(trackers: trackersBlocked)
}

public var containsMajorTracker: Bool {
return trackersDetected.contains(where: { $0.key.fromMajorNetwork } )
}
Expand All @@ -72,7 +80,7 @@ public class SiteRating {
let detectedCount = trackersDetected[tracker] ?? 0
trackersDetected[tracker] = detectedCount + 1

if blocked{
if blocked {
let blockCount = trackersBlocked[tracker] ?? 0
trackersBlocked[tracker] = blockCount + 1
}
Expand All @@ -93,4 +101,9 @@ public class SiteRating {
public var totalTrackersBlocked: Int {
return trackersBlocked.reduce(0) { $0 + $1.value }
}

private func majorTrackers(trackers: [Tracker: Int]) -> Int {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same again, rename to uniqueMajorTrackerNetworks?

return Set(trackers.keys.filter({ $0.fromMajorNetwork }).flatMap({ $0.parentDomain })).count
}

}
5 changes: 4 additions & 1 deletion DuckDuckGo/PrivacyProtection.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="f83-AN-wMW">
<rect key="frame" x="278" y="0.0" width="51" height="31"/>
<color key="onTintColor" red="0.086274509803921567" green="0.32941176470588235" blue="0.086274509803921567" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<action selector="toggleProtection" destination="7Z1-eg-OWQ" eventType="valueChanged" id="Qnb-IB-9wQ"/>
</connections>
</switch>
</subviews>
</stackView>
Expand All @@ -370,7 +373,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TRACKER NETWORK LEADERBOARD" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hB8-nL-nri">
<rect key="frame" x="84" y="22" width="209" height="14"/>
<rect key="frame" x="83.5" y="22" width="209" height="14"/>
<fontDescription key="fontDescription" name="ProximaNova-Bold" family="Proxima Nova" pointSize="12"/>
<color key="textColor" red="0.57647058823529407" green="0.57647058823529407" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
Expand Down
43 changes: 32 additions & 11 deletions DuckDuckGo/PrivacyProtectionOverviewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class PrivacyProtectionOverviewController: UITableViewController {
}
}

@IBAction func toggleProtection() {
contentBlocker.enabled = privacyProtectionSwitch.isOn
}

func updateSiteRating(_ siteRating: SiteRating) {
self.siteRating = siteRating

Expand All @@ -64,32 +68,38 @@ class PrivacyProtectionOverviewController: UITableViewController {
private func updateEncryption() {
encryptionCell.summaryLabel.text = siteRating.https ?
UserText.privacyProtectionEncryptedConnection : UserText.privacyProtectionUnencryptedConnection
encryptionCell.summaryImage.image = blocking() ? #imageLiteral(resourceName: "PP Hero OFF- Connection") : #imageLiteral(resourceName: "PP Hero ON- Connection")
encryptionCell.summaryImage.image = protecting() ? #imageLiteral(resourceName: "PP Hero ON- Connection") : #imageLiteral(resourceName: "PP Hero OFF- Connection")
}

private func updateTrackersBlocked() {
trackersCell.summaryImage.image = blocking() ? #imageLiteral(resourceName: "PP Hero OFF- Networks Blocked") : #imageLiteral(resourceName: "PP Hero ON- Networks Blocked")
trackersCell.summaryImage.image = protecting() ? #imageLiteral(resourceName: "PP Hero ON- Networks Blocked") : #imageLiteral(resourceName: "PP Hero OFF- Networks Blocked")
trackersCell.summaryLabel.text = protecting() ?
String(format: UserText.privacyProtectionTrackersBlocked, siteRating.uniqueTrackersBlocked) :
String(format: UserText.privacyProtectionTrackersFound, siteRating.uniqueTrackersDetected)
}

private func updateMajorTrackersBlocked() {
majorTrackersCell.summaryImage.image = blocking() ? #imageLiteral(resourceName: "PP Hero OFF- Major Networks") : #imageLiteral(resourceName: "PP Hero ON- Major Networks")
majorTrackersCell.summaryImage.image = protecting() ? #imageLiteral(resourceName: "PP Hero ON- Major Networks") : #imageLiteral(resourceName: "PP Hero OFF- Major Networks")
majorTrackersCell.summaryLabel.text = protecting() ?
String(format: UserText.privacyProtectionMajorTrackersBlocked, siteRating.majorTrackersBlocked) :
String(format: UserText.privacyProtectionMajorTrackersFound, siteRating.majorTrackersDetected)
}

private func updatePrivacyPractices() {
privacyPracticesCell.summaryImage.image = blocking() ? #imageLiteral(resourceName: "PP Hero OFF- Good Privacy") : #imageLiteral(resourceName: "PP Hero ON- Good Privacy")
privacyPracticesCell.summaryImage.image = protecting() ? #imageLiteral(resourceName: "PP Hero ON- Good Privacy") : #imageLiteral(resourceName: "PP Hero OFF- Good Privacy")
}

private func updateLeaderBoard() {
leaderboard.isHidden = true
}

private func updateProtectionToggle() {
privacyProtectionSwitch.isOn = !blocking()
privacyProtectionCell.backgroundColor = blocking() ? UIColor.coolGray : UIColor.green
privacyProtectionSwitch.isOn = protecting()
privacyProtectionCell.backgroundColor = protecting() ? UIColor.ppGreen : UIColor.ppGray
}

private func blocking() -> Bool {
return !contentBlocker.enabled || contentBlocker.domainWhitelist.contains(siteRating.domain)
private func protecting() -> Bool {
return contentBlocker.enabled && !contentBlocker.domainWhitelist.contains(siteRating.domain)
}

// see https://stackoverflow.com/a/41248703
Expand Down Expand Up @@ -130,7 +140,7 @@ class PrivacyGradeCell: UITableViewCell {
@IBOutlet weak var protectionDisabledLabel: UILabel!
@IBOutlet weak var protectionUpgraded: ProtectionUpgradedView!

func update(with siteRating: SiteRating, and contentBlocking: ContentBlockerConfigurationStore) {
func update(with siteRating: SiteRating, and contentprotecting: ContentBlockerConfigurationStore) {

if siteRating.finishedLoading {
gradeImage.image = PrivacyGradeCell.grades[siteRating.siteGrade]
Expand All @@ -142,9 +152,9 @@ class PrivacyGradeCell: UITableViewCell {
protectionDisabledLabel.isHidden = true
protectionUpgraded.isHidden = true

if !contentBlocking.enabled {
if !contentprotecting.enabled {
protectionDisabledLabel.isHidden = false
} else if contentBlocking.domainWhitelist.contains(siteRating.domain) {
} else if contentprotecting.domainWhitelist.contains(siteRating.domain) {
protectionPausedLabel.isHidden = false
} else {
// TODO show upgrade
Expand Down Expand Up @@ -212,4 +222,15 @@ fileprivate class InteractivePopRecognizer: NSObject, UIGestureRecognizerDelegat
}
}

fileprivate extension UIColor {

fileprivate static var ppGray: UIColor {
return UIColor(red: 149.0 / 255.0, green: 149.0 / 255.0, blue: 149.0 / 255.0, alpha: 1.0)
}

fileprivate static var ppGreen: UIColor {
return UIColor(red: 63.0 / 255.0, green: 161.0 / 255.0, blue: 64.0 / 255.0, alpha: 1.0)
}

}

4 changes: 4 additions & 0 deletions DuckDuckGo/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public struct UserText {

public static let privacyProtectionEncryptedConnection = NSLocalizedString("privacy.protection.encrypted.connection", comment: "Encrypted conection")
public static let privacyProtectionUnencryptedConnection = NSLocalizedString("privacy.protection.unencrypted.connection", comment: "Unencrypted conection")
public static let privacyProtectionTrackersBlocked = NSLocalizedString("privacy.protection.trackers.blocked", comment: "Trackers blocked")
public static let privacyProtectionTrackersFound = NSLocalizedString("privacy.protection.trackers.found", comment: "Trackers found")
public static let privacyProtectionMajorTrackersBlocked = NSLocalizedString("privacy.protection.major.trackers.blocked", comment: "Major trackers blocked")
public static let privacyProtectionMajorTrackersFound = NSLocalizedString("privacy.protection.major.trackers.found", comment: "Major trackers found")

public static func forSiteGrade(_ grade: SiteGrade) -> String {
let key = "monitoring.sitegrade.\(grade.rawValue)"
Expand Down
7 changes: 7 additions & 0 deletions DuckDuckGo/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@
"monitoring.sitegrade.b" = "B";
"monitoring.sitegrade.c" = "C";
"monitoring.sitegrade.d" = "D";

"privacy.protection.encrypted.connection" = "Encrypted Connection";
"privacy.protection.unencrypted.connection" = "Unencrypted Connection";
"privacy.protection.trackers.blocked" = "%d Tracker Networks Blocked";
"privacy.protection.trackers.found" = "%d Tracker Networks Found";
"privacy.protection.major.trackers.blocked" = "%d Major Tracker Networks Blocked";
"privacy.protection.major.trackers.found" = "%d Major Tracker Networks Found";