Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into alex/fix-bookmarks-kb…
Browse files Browse the repository at this point in the history
…-navigation
mallexxx committed Oct 5, 2024
2 parents 82b1a11 + a599ccb commit 01236d5
Showing 67 changed files with 2,947 additions and 1,099 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_hotfix_release.yml
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ jobs:
APPLE_API_KEY_ISSUER: ${{ secrets.APPLE_API_KEY_ISSUER }}
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
SSH_PRIVATE_KEY_FASTLANE_MATCH: ${{ secrets.SSH_PRIVATE_KEY_FASTLANE_MATCH }}

update_asana:

2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 272
CURRENT_PROJECT_VERSION = 275
26 changes: 7 additions & 19 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -32,17 +32,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "cc3629fa16880e410e588a27a6b2426dcc140009",
"version" : "198.0.1"
"revision" : "b60b38bace7262e0c4a006018b7e4b060ba4b754",
"version" : "198.2.1"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "4f0d109f13beec7e8beaf0bd5c0e2c1d528677f8",
"version" : "6.16.0"
"revision" : "1ed569676555d493c9c5575eaed22aa02569aac9",
"version" : "6.19.0"
}
},
{
Original file line number Diff line number Diff line change
@@ -8,5 +8,8 @@
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Original file line number Diff line number Diff line change
@@ -8,5 +8,8 @@
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Original file line number Diff line number Diff line change
@@ -299,8 +299,13 @@ final class BookmarkManagementDetailViewController: NSViewController, NSMenuItem

switch newSortMode {
case .nameDescending:
self.sortItemsButton.title = UserText.bookmarksSortByNameTitle
self.sortItemsButton.image = .bookmarkSortDesc
default:
case .nameAscending:
self.sortItemsButton.title = UserText.bookmarksSortByNameTitle
self.sortItemsButton.image = .bookmarkSortAsc
case .manual:
self.sortItemsButton.title = UserText.bookmarksSort
self.sortItemsButton.image = .bookmarkSortAsc
}

16 changes: 8 additions & 8 deletions DuckDuckGo/BookmarksBar/View/BookmarksBar.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="JFF-Nj-8om">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="JFF-Nj-8om">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23094"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -23,13 +23,13 @@
</constraints>
</customView>
<scrollView wantsLayer="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="0.0" horizontalPageScroll="0.0" verticalLineScroll="0.0" verticalPageScroll="0.0" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" verticalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="D39-Of-BIh">
<rect key="frame" x="0.0" y="2" width="676" height="52"/>
<rect key="frame" x="12" y="2" width="664" height="52"/>
<clipView key="contentView" drawsBackground="NO" id="yvk-6W-sd0">
<rect key="frame" x="0.0" y="0.0" width="676" height="52"/>
<rect key="frame" x="0.0" y="0.0" width="664" height="52"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView selectable="YES" id="vwg-NL-UPk" customClass="ItemCachingCollectionView" customModule="DuckDuckGo_Privacy_Browser">
<rect key="frame" x="0.0" y="0.0" width="676" height="52"/>
<rect key="frame" x="0.0" y="0.0" width="664" height="52"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<collectionViewLayout key="collectionViewLayout" id="YNm-eM-CbC"/>
<color key="primaryBackgroundColor" name="NavigationBarBackgroundColor"/>
@@ -78,7 +78,7 @@
<rect key="frame" x="10" y="26" width="65" height="28"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="gwe-JW-nZ6">
<rect key="frame" x="4" y="3" width="16.5" height="24"/>
<rect key="frame" x="4" y="3" width="16" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="16" id="TNn-Xg-utS"/>
<constraint firstAttribute="height" constant="16" id="ZuD-h5-gbG"/>
@@ -140,7 +140,7 @@
<constraint firstAttribute="trailing" secondItem="Mgr-xJ-Pl5" secondAttribute="trailing" constant="8" id="UCG-Ww-dsY"/>
<constraint firstAttribute="trailing" secondItem="X6g-3K-JDi" secondAttribute="trailing" id="ZaK-nU-eHk"/>
<constraint firstItem="Mgr-xJ-Pl5" firstAttribute="centerY" secondItem="R54-3G-cms" secondAttribute="centerY" constant="-1" id="eoh-hW-GcD"/>
<constraint firstItem="D39-Of-BIh" firstAttribute="leading" secondItem="R54-3G-cms" secondAttribute="leading" id="hOd-Bz-o5j"/>
<constraint firstItem="D39-Of-BIh" firstAttribute="leading" secondItem="R54-3G-cms" secondAttribute="leading" constant="12" id="hOd-Bz-o5j"/>
<constraint firstAttribute="bottom" secondItem="X6g-3K-JDi" secondAttribute="bottom" id="iWj-iC-9gW"/>
<constraint firstItem="cjE-4p-vxI" firstAttribute="centerY" secondItem="R54-3G-cms" secondAttribute="centerY" id="s3N-bi-7Hr"/>
<constraint firstItem="YdB-zl-3Cf" firstAttribute="leading" secondItem="R54-3G-cms" secondAttribute="leading" constant="10" id="zyW-Tf-ym2"/>
@@ -168,7 +168,7 @@
</scenes>
<resources>
<image name="Chevron-Double-Right-16" width="16" height="16"/>
<image name="square.and.arrow.down" catalog="system" width="15" height="17"/>
<image name="square.and.arrow.down" catalog="system" width="16" height="17"/>
<namedColor name="AddressBarFocusedBackgroundColor">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// LeftAlignedLayout.swift
// BookmarksBarCenterAlignedLayout.swift
//
// Copyright © 2022 DuckDuckGo. All rights reserved.
//
@@ -23,15 +23,22 @@ extension NSCollectionView {

extension NSCollectionLayoutGroup {

static func leftAligned(cellSizes: [CGSize], interItemSpacing: CGFloat) -> NSCollectionLayoutGroup {
static func align(cellSizes: [CGSize], interItemSpacing: CGFloat, centered: Bool) -> NSCollectionLayoutGroup {
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .absolute(28))

return custom(layoutSize: groupSize) { environment in
let verticalPosition: CGFloat = environment.container.contentInsets.top
let totalWidth = cellSizes.map(\.width).reduce(0) { $0 == 0 ? $1 : $0 + interItemSpacing + $1 }
let maxItemHeight = cellSizes.map(\.height).max() ?? 0

var items: [NSCollectionLayoutGroupCustomItem] = []
var horizontalPosition: CGFloat = interItemSpacing
var horizontalPosition: CGFloat

if centered {
horizontalPosition = (environment.container.effectiveContentSize.width - totalWidth) / 2 + environment.container.contentInsets.leading
} else {
horizontalPosition = interItemSpacing
}

let rowItems: [NSCollectionLayoutGroupCustomItem] = cellSizes.map { size in
let origin = CGPoint(x: ceil(horizontalPosition), y: verticalPosition + (maxItemHeight - size.height) / 2)
@@ -48,9 +55,9 @@ extension NSCollectionLayoutGroup {
}
}

final class BookmarksBarLeftAlignedLayout: NSCollectionViewCompositionalLayout {
final class BookmarksBarCenterAlignedLayout: NSCollectionViewCompositionalLayout {

private static let interItemGapWidth: CGFloat = 2
private static let interItemGapWidth: CGFloat = 2.0

private var lastKnownInterItemGapIndicatorLayoutAttributes: NSCollectionViewLayoutAttributes?

8 changes: 8 additions & 0 deletions DuckDuckGo/BookmarksBar/View/BookmarksBarMenuFactory.swift
Original file line number Diff line number Diff line change
@@ -54,8 +54,16 @@ struct BookmarksBarMenuFactory {
},
BlockMenuItem(title: UserText.mainMenuBookmarksShowBookmarksBarNever, isChecked: !prefs.showBookmarksBar) {
prefs.showBookmarksBar = false
},
NSMenuItem.separator(),
BlockMenuItem(title: UserText.mainMenuBookmarksLeftAlignBookmarksBar, isChecked: !prefs.centerAlignedBookmarksBarBool) {
prefs.centerAlignedBookmarksBarBool = false
},
BlockMenuItem(title: UserText.mainMenuBookmarksCenterAlignBookmarksBar, isChecked: prefs.centerAlignedBookmarksBarBool) {
prefs.centerAlignedBookmarksBarBool = true
}
])

return item
}

27 changes: 20 additions & 7 deletions DuckDuckGo/BookmarksBar/View/BookmarksBarViewController.swift
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ final class BookmarksBarViewController: NSViewController {
private let dragDropManager: BookmarkDragDropManager
private let viewModel: BookmarksBarViewModel
private let tabCollectionViewModel: TabCollectionViewModel
private let appereancePreferences: AppearancePreferencesPersistor

private var cancellables = Set<AnyCancellable>()

@@ -59,9 +60,14 @@ final class BookmarksBarViewController: NSViewController {
}!
}

init?(coder: NSCoder, tabCollectionViewModel: TabCollectionViewModel, bookmarkManager: BookmarkManager = LocalBookmarkManager.shared, dragDropManager: BookmarkDragDropManager = BookmarkDragDropManager.shared) {
init?(coder: NSCoder, tabCollectionViewModel: TabCollectionViewModel,
bookmarkManager: BookmarkManager = LocalBookmarkManager.shared,
dragDropManager: BookmarkDragDropManager = BookmarkDragDropManager.shared,
appereancePreferences: AppearancePreferencesPersistor = AppearancePreferencesUserDefaultsPersistor()
) {
self.bookmarkManager = bookmarkManager
self.dragDropManager = dragDropManager
self.appereancePreferences = appereancePreferences

self.tabCollectionViewModel = tabCollectionViewModel
self.viewModel = BookmarksBarViewModel(bookmarkManager: bookmarkManager, dragDropManager: dragDropManager, tabCollectionViewModel: tabCollectionViewModel)
@@ -98,7 +104,6 @@ final class BookmarksBarViewController: NSViewController {

bookmarksBarCollectionView.delegate = viewModel
bookmarksBarCollectionView.dataSource = viewModel
bookmarksBarCollectionView.collectionViewLayout = createLeftAlignedCollectionViewLayout()

view.postsFrameChangedNotifications = true
bookmarksBarCollectionView.setAccessibilityIdentifier("BookmarksBarViewController.bookmarksBarCollectionView")
@@ -120,6 +125,7 @@ final class BookmarksBarViewController: NSViewController {

subscribeToEvents()
refreshFavicons()
bookmarksBarCollectionView.collectionViewLayout = createCenterAlignedCollectionViewLayout(centered: appereancePreferences.centerAlignedBookmarksBar)
}

override func viewDidAppear() {
@@ -167,6 +173,13 @@ final class BookmarksBarViewController: NSViewController {
}
.store(in: &cancellables)

NotificationCenter.default.publisher(for: AppearancePreferences.Notifications.bookmarksBarAlignmentChanged)
.compactMap { $0.userInfo?[AppearancePreferences.Constants.bookmarksBarAlignmentChangedIsCenterAlignedParameter] as? Bool }
.sink { [weak self] isCenterAligned in
self?.bookmarksBarCollectionView.collectionViewLayout = self?.createCenterAlignedCollectionViewLayout(centered: isCenterAligned)
}
.store(in: &cancellables)

viewModel.$clippedItems
.receive(on: RunLoop.main)
.sink { [weak self] _ in
@@ -228,14 +241,14 @@ final class BookmarksBarViewController: NSViewController {

// MARK: - Layout

private func createLeftAlignedLayout() -> NSCollectionLayoutSection {
let group = NSCollectionLayoutGroup.leftAligned(cellSizes: viewModel.cellSizes, interItemSpacing: BookmarksBarViewModel.Constants.buttonSpacing)
private func createAlignedLayout(centered: Bool) -> NSCollectionLayoutSection {
let group = NSCollectionLayoutGroup.align(cellSizes: viewModel.cellSizes, interItemSpacing: BookmarksBarViewModel.Constants.buttonSpacing, centered: centered)
return NSCollectionLayoutSection(group: group)
}

private func createLeftAlignedCollectionViewLayout() -> NSCollectionViewLayout {
return BookmarksBarLeftAlignedLayout { [unowned self] _, _ in
return createLeftAlignedLayout()
private func createCenterAlignedCollectionViewLayout(centered: Bool) -> NSCollectionViewLayout {
return BookmarksBarCenterAlignedLayout { [unowned self] _, _ in
return createAlignedLayout(centered: centered && viewModel.clippedItems.isEmpty)
}
}

14 changes: 7 additions & 7 deletions DuckDuckGo/Common/Extensions/NSViewControllerExtension.swift
Original file line number Diff line number Diff line change
@@ -92,13 +92,6 @@ extension NSViewController {
view.removeFromSuperview()
}

func withoutAnimation(_ closure: () -> Void) {
CATransaction.begin()
CATransaction.setDisableActions(true)
closure()
CATransaction.commit()
}

/// #Preview helper to hide Window controls on View Controller appearance
func _preview_hidingWindowControlsOnAppear() -> Self { // swiftlint:disable:this identifier_name
Preview_ViewControllerWindowObserver().attach(to: self)
@@ -107,6 +100,13 @@ extension NSViewController {

}

func withoutAnimation(_ closure: () -> Void) {
CATransaction.begin()
CATransaction.setDisableActions(true)
closure()
CATransaction.commit()
}

/// #Preview helper to hide Window controls on View Controller appearance
final class Preview_ViewControllerWindowObserver: NSObject {
func attach(to viewController: NSViewController) {
8 changes: 7 additions & 1 deletion DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
@@ -186,6 +186,11 @@ struct UserText {
static let mainMenuBookmarksShowBookmarksBarAlways = NSLocalizedString("Always Show", comment: "Preference for always showing the bookmarks bar")
static let mainMenuBookmarksShowBookmarksBarNewTabOnly = NSLocalizedString("Only Show on New Tab", comment: "Preference for only showing the bookmarks bar on new tab")
static let mainMenuBookmarksShowBookmarksBarNever = NSLocalizedString("Never Show", comment: "Preference for never showing the bookmarks bar on new tab")
static let mainMenuBookmarksLeftAlignBookmarksBar = NSLocalizedString("Align Bookmarks to Left", comment: "Preference for left aligning the bookmarks bar")
static let mainMenuBookmarksCenterAlignBookmarksBar = NSLocalizedString("Align Bookmarks to Center", comment: "Preference for center aligning the bookmarks bar")
static let preferencesBookmarksCenterAlignBookmarksBarTitle = NSLocalizedString("Align Bookmarks", comment: "Preference title aligning the bookmarks bar")
static let preferencesBookmarksCenterAlignBookmarksBar = NSLocalizedString("Center", comment: "Preference title aligning the bookmarks bar")
static let preferencesBookmarksLeftAlignBookmarksBare = NSLocalizedString("Left", comment: "Preference title aligning the bookmarks bar")

// MARK: - Main Menu -> Window
static let mainMenuWindow = NSLocalizedString("Window", comment: "Main Menu ")
@@ -990,7 +995,8 @@ struct UserText {
static let manageBookmarksTooltip = NSLocalizedString("tooltip.bookmarks.manage-bookmarks", value: "Manage bookmarks", comment: "Tooltip for the Manage Bookmarks button")
static let bookmarksManage = NSLocalizedString("bookmarks.manage", value: "Manage", comment: "Button for opening the bookmarks management interface")
static let bookmarksSearch = NSLocalizedString("tooltip.bookmarks.search", value: "Search bookmarks", comment: "Tooltip to activate the bookmark search")
static let bookmarksSort = NSLocalizedString("tooltip.bookmarks.sort", value: "Sort bookmarks", comment: "Tooltip to activate the bookmark sort")
static let bookmarksSort = NSLocalizedString("tooltip.bookmarks.sort", value: "Sort", comment: "Tooltip to activate the bookmark sort")
static let bookmarksSortByNameTitle = NSLocalizedString("tooltip.bookmarks.sort.name.title", value: "Sort by Name", comment: "Title when bookmark sort by name is enabled")
static let bookmarksSortManual = NSLocalizedString("bookmarks.sort.manual", value: "Manual", comment: "Button to sort bookmarks by manual")
static let bookmarksSortByName = NSLocalizedString("bookmarks.sort.name", value: "Name", comment: "Button to sort bookmarks by name ascending")
static let bookmarksSortByNameAscending = NSLocalizedString("bookmarks.sort.name.asc", value: "Ascending", comment: "Button to sort bookmarks by name ascending")
1 change: 1 addition & 0 deletions DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift
Original file line number Diff line number Diff line change
@@ -144,6 +144,7 @@ public struct UserDefaultsWrapper<T> {

case bookmarksBarPromptShown = "bookmarks.bar.prompt.shown"
case showBookmarksBar = "bookmarks.bar.show"
case centerAlignedBookmarksBar = "bookmarks.bar.center.aligned"
case lastBookmarksBarUsagePixelSendDate = "bookmarks.bar.last-usage-pixel-send-date"

case pinnedViews = "pinning.pinned-views"
2 changes: 1 addition & 1 deletion DuckDuckGo/Common/View/AppKit/HoverTrackingArea.swift
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ final class HoverTrackingArea: NSTrackingArea {
view?.backgroundLayer(createIfNeeded: createIfNeeded)
}

func updateLayer(animated: Bool = true) {
func updateLayer(animated: Bool = !CATransaction.disableActions()) {
let color = currentBackgroundColor ?? .clear
guard let view, let layer = layer(createIfNeeded: color != .clear) else { return }

Loading

0 comments on commit 01236d5

Please sign in to comment.