Skip to content

Commit

Permalink
Introduce long press gesture on settings button to jump to debug sett…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
jaceklyp committed Dec 15, 2023
1 parent 5a1d922 commit 59bc453
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 23 deletions.
36 changes: 18 additions & 18 deletions DuckDuckGo/Base.lproj/Settings.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,11 @@
<rect key="frame" x="20" y="1012.3333320617676" width="374" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="9RH-AW-rsk" id="s4N-yd-5mG">
<rect key="frame" x="0.0" y="0.0" width="355.66666666666669" height="43.666667938232422"/>
<rect key="frame" x="0.0" y="0.0" width="343.66666666666669" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" text="Keyboard" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="yoZ-jw-Cu3">
<rect key="frame" x="8" y="0.0" width="339.66666666666669" height="43.666667938232422"/>
<rect key="frame" x="20" y="0.0" width="315.66666666666669" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
Expand Down Expand Up @@ -759,11 +759,11 @@
<rect key="frame" x="20" y="1324.6666603088379" width="374" height="55"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="nAl-CW-4R7" id="eQZ-vi-vuJ">
<rect key="frame" x="0.0" y="0.0" width="355.66666666666669" height="55"/>
<rect key="frame" x="0.0" y="0.0" width="343.66666666666669" height="55"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" text="Email Protection" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="azf-Nc-kvW">
<rect key="frame" x="8" y="7.3333333333333339" width="118" height="19.333333333333332"/>
<rect key="frame" x="20" y="7.3333333333333339" width="118" height="19.333333333333332"/>
<autoresizingMask key="autoresizingMask"/>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="NO"/>
Expand All @@ -773,7 +773,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" text="Block email trackers and hide your address" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Y6Y-wA-n6Z">
<rect key="frame" x="8" y="29.333333333333332" width="260" height="15.666666666666666"/>
<rect key="frame" x="20" y="29.333333333333332" width="260" height="15.666666666666666"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
Expand All @@ -790,11 +790,11 @@
<rect key="frame" x="20" y="1379.6666603088379" width="374" height="55"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WpO-kq-QM6" id="jdM-R6-KZO">
<rect key="frame" x="0.0" y="0.0" width="355.66666666666669" height="55"/>
<rect key="frame" x="0.0" y="0.0" width="343.66666666666669" height="55"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" text="DuckDuckGo Mac App" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Yz9-17-qnn">
<rect key="frame" x="8" y="7.3333333333333339" width="164.33333333333334" height="19.333333333333332"/>
<rect key="frame" x="20" y="7.3333333333333339" width="164.33333333333334" height="19.333333333333332"/>
<autoresizingMask key="autoresizingMask"/>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="NO"/>
Expand All @@ -804,7 +804,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" text="Browse privately with our app for Mac " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="P0F-ts-ekd">
<rect key="frame" x="8" y="29.333333333333332" width="232" height="15.666666666666666"/>
<rect key="frame" x="20" y="29.333333333333332" width="232" height="15.666666666666666"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
Expand All @@ -821,11 +821,11 @@
<rect key="frame" x="20" y="1434.6666603088379" width="374" height="55"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ubu-Mf-iUH" id="Sm8-Lv-wFY">
<rect key="frame" x="0.0" y="0.0" width="355.66666666666669" height="55"/>
<rect key="frame" x="0.0" y="0.0" width="343.66666666666669" height="55"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" text="DuckDuckGo Windows App" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="RQ8-H1-Ez1">
<rect key="frame" x="8" y="7.3333333333333339" width="199.33333333333334" height="19.333333333333332"/>
<rect key="frame" x="20" y="7.3333333333333339" width="199.33333333333334" height="19.333333333333332"/>
<autoresizingMask key="autoresizingMask"/>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="NO"/>
Expand All @@ -835,7 +835,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" text="Browse privately with our app for Windows" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="hoT-Nu-KXP">
<rect key="frame" x="8" y="29.333333333333332" width="257.66666666666669" height="15.666666666666666"/>
<rect key="frame" x="20" y="29.333333333333332" width="257.66666666666669" height="15.666666666666666"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
Expand All @@ -852,11 +852,11 @@
<rect key="frame" x="20" y="1489.6666603088379" width="374" height="55"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="7pF-cg-5QN" id="5Yk-5T-8YE">
<rect key="frame" x="0.0" y="0.0" width="355.66666666666669" height="55"/>
<rect key="frame" x="0.0" y="0.0" width="343.66666666666669" height="55"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" text="Network Protection" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="qah-gb-udB" userLabel="Network Protection">
<rect key="frame" x="8" y="7.3333333333333339" width="140" height="19.333333333333332"/>
<rect key="frame" x="20" y="7.3333333333333339" width="140" height="19.333333333333332"/>
<autoresizingMask key="autoresizingMask"/>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="NO"/>
Expand All @@ -866,7 +866,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" text="Hide your location and conceal your online activity" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Cyw-ir-cSK">
<rect key="frame" x="8" y="29.333333333333332" width="304.66666666666669" height="15.666666666666666"/>
<rect key="frame" x="20" y="29.333333333333332" width="304.66666666666669" height="15.666666666666666"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
Expand All @@ -884,14 +884,14 @@
<tableViewSection headerTitle="About" footerTitle="" id="FpT-1C-xtx">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="oM7-1o-9oY" style="IBUITableViewCellStyleDefault" id="iy0-gV-9MR" userLabel="About Cell">
<rect key="frame" x="20" y="1611.9999923706055" width="374" height="43.666667938232422"/>
<rect key="frame" x="20" y="1495.6666628519695" width="374" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="iy0-gV-9MR" id="Msh-jY-fMD">
<rect key="frame" x="0.0" y="0.0" width="355.66666666666669" height="43.666667938232422"/>
<rect key="frame" x="0.0" y="0.0" width="343.66666666666669" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" ambiguous="YES" text="About DuckDuckGo" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="oM7-1o-9oY">
<rect key="frame" x="8" y="0.0" width="339.66666666666669" height="43.666667938232422"/>
<rect key="frame" x="20" y="0.0" width="315.66666666666669" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="NO"/>
Expand Down Expand Up @@ -2493,7 +2493,7 @@ After all, the internet shouldn’t feel so creepy, and getting the privacy you
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="secondaryLabelColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand Down
6 changes: 5 additions & 1 deletion DuckDuckGo/BlankSnapshotViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ extension BlankSnapshotViewController: OmniBarDelegate {
func onSettingsPressed() {
userInteractionDetected()
}


func onSettingsLongPressed() {
userInteractionDetected()
}

func onTextFieldDidBeginEditing(_ omniBar: OmniBar) -> Bool {
DispatchQueue.main.async {
self.viewCoordinator.omniBar.resignFirstResponder()
Expand Down
24 changes: 24 additions & 0 deletions DuckDuckGo/MainViewController+Segues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ extension MainViewController {
launchSettings()
}

func segueToDebugSettings() {
os_log(#function, log: .generalLog, type: .debug)
hideAllHighlightsIfNeeded()
launchDebugSettings()
}

func segueToSettingsCookiePopupManagement() {
os_log(#function, log: .generalLog, type: .debug)
hideAllHighlightsIfNeeded()
Expand Down Expand Up @@ -217,6 +223,24 @@ extension MainViewController {
}
}

private func launchDebugSettings(completion: ((RootDebugViewController) -> Void)? = nil) {
os_log(#function, log: .generalLog, type: .debug)

let storyboard = UIStoryboard(name: "Debug", bundle: nil)
let settings = storyboard.instantiateViewController(identifier: "DebugMenu") { coder in
RootDebugViewController(coder: coder,
sync: self.syncService,
bookmarksDatabase: self.bookmarksDatabase,
internalUserDecider: AppDependencyProvider.shared.internalUserDecider)
}

let controller = ThemableNavigationController(rootViewController: settings)
controller.modalPresentationStyle = .automatic
present(controller, animated: true) {
completion?(settings)
}
}

private func hideAllHighlightsIfNeeded() {
os_log(#function, log: .generalLog, type: .debug)
if !DaxDialogs.shared.shouldShowFireButtonPulse {
Expand Down
12 changes: 11 additions & 1 deletion DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class MainViewController: UIViewController {
private var syncUpdatesCancellable: AnyCancellable?
private var emailCancellables = Set<AnyCancellable>()

private lazy var featureFlagger = AppDependencyProvider.shared.featureFlagger

lazy var menuBookmarksViewModel: MenuBookmarksInteracting = MenuBookmarksViewModel(bookmarksDatabase: bookmarksDatabase, syncService: syncService)

weak var tabSwitcherController: TabSwitcherViewController?
Expand Down Expand Up @@ -1319,7 +1321,15 @@ extension MainViewController: OmniBarDelegate {
}
segueToSettings()
}


func onSettingsLongPressed() {
if featureFlagger.isFeatureOn(.debugMenu) || isDebugBuild {
segueToDebugSettings()
} else {
segueToSettings()
}
}

func onCancelPressed() {
dismissOmniBar()
hideSuggestionTray()
Expand Down
Loading

0 comments on commit 59bc453

Please sign in to comment.