Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit b7217f5

Browse files
committed
update long press menu to be more concise
https://app.asana.com/0/392891325557410/1209387069429644
1 parent 8dc9d1c commit b7217f5

File tree

4 files changed

+42
-21
lines changed

4 files changed

+42
-21
lines changed

DuckDuckGo/TabSwitcherViewController+MultiSelect.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,26 @@ extension TabSwitcherViewController {
283283
}
284284
}
285285

286-
fileprivate func addSelectedPagesMultiSelectMenuItemsIfNeeded(_ selectedPagesCount: Int, _ children: inout [UIMenuElement]) {
286+
fileprivate func addSelectedPagesMultiSelectMenuItemsIfNeeded(_ children: inout [UIMenuElement]) {
287+
288+
// Only show these if there's at least one non-home page tab selected
287289
guard selectedPagesCount > 0 else { return }
290+
291+
// But use the total count for determining the text (Tab vs Tabs)
292+
let selectedTabsCount = selectedTabs.count
288293
children.append(UIMenu(title: "", options: .displayInline, children: [
289-
action(UserText.shareSelectedLink(withCount: selectedPagesCount), "Share-Apple-16", { [weak self] in
294+
action(UserText.shareSelectedTabs(withCount: selectedTabsCount), "Share-Apple-16", { [weak self] in
290295
guard let self else { return }
291296
self.selectModeShareLinks()
292297
}),
293-
action(UserText.bookmarkSelectedTabs(withCount: selectedPagesCount), "Bookmark-Add-16", { [weak self] in
298+
action(UserText.bookmarkSelectedTabs(withCount: selectedTabsCount), "Bookmark-Add-16", { [weak self] in
294299
guard let self else { return }
295300
self.selectModeBookmarkSelected()
296301
}),
297302
]))
298303
}
299304

300-
fileprivate func addBookmarkMultiSelectMenuItemIfNeeded(_ allPagesCount: Int, _ selectedPagesCount: Int, _ children: inout [UIMenuElement]) {
305+
fileprivate func addBookmarkMultiSelectMenuItemIfNeeded(_ children: inout [UIMenuElement]) {
301306
guard selectedTabs.isEmpty else { return }
302307
children.append(UIMenu(title: "", options: .displayInline, children: [
303308
action(UserText.tabSwitcherBookmarkAllTabs, "Bookmark-All-16", { [weak self] in
@@ -327,19 +332,16 @@ extension TabSwitcherViewController {
327332
}
328333

329334
func createMultiSelectionMenu() -> UIMenu {
330-
let selectedPagesCount = self.selectedPagesCount
331-
let allPagesCount = self.allPagesCount
332-
333335
var children = [UIMenuElement]()
334336

335337
addLargeInterfaceMultiSelectMenuItemsIfNeeded(&children)
336338

337339
// share
338340
// bookmark
339-
addSelectedPagesMultiSelectMenuItemsIfNeeded(selectedPagesCount, &children)
341+
addSelectedPagesMultiSelectMenuItemsIfNeeded(&children)
340342

341343
// bookmark all
342-
addBookmarkMultiSelectMenuItemIfNeeded(allPagesCount, selectedPagesCount, &children)
344+
addBookmarkMultiSelectMenuItemIfNeeded(&children)
343345

344346
// close (large UI only)
345347
// close other
@@ -377,7 +379,7 @@ extension TabSwitcherViewController {
377379

378380
let closeGroup = [
379381
// Close selected
380-
action(UserText.closeTabs(withCount: selectedTabsCount), "Close-16", destructive: true, { [weak self] in
382+
action(UserText.keyCommandClose, "Close-16", destructive: true, { [weak self] in
381383
self?.longPressMenuCloseSelectedTabs()
382384
}),
383385
]
@@ -392,13 +394,13 @@ extension TabSwitcherViewController {
392394

393395
return [
394396
// Share
395-
action(UserText.shareSelectedLink(withCount: selectedTabsCount), "Share-Apple-16", { [weak self] in
397+
action(UserText.shareLinks(withCount: selectedTabsCount), "Share-Apple-16", { [weak self] in
396398
self?.longPressMenuShareSelectedLinks()
397399
}),
398400

399401
// Bookmark
400402
selectedPagesCount > 0 ?
401-
action(UserText.bookmarkSelectedTabs(withCount: selectedTabsCount), "Bookmark-Add-16", { [weak self] in
403+
action(UserText.actionBookmark, "Bookmark-Add-16", { [weak self] in
402404
self?.longPressMenuBookmarkSelectedTabs()
403405
}) : nil,
404406

@@ -433,7 +435,7 @@ extension TabSwitcherViewController {
433435

434436
return [
435437
// Share Link
436-
tabsModel.safeGetTabAt(index)?.link != nil ? self.action(index, UserText.tabSwitcherShareLink, "Share-Apple-16", { [weak self] index in
438+
tabsModel.safeGetTabAt(index)?.link != nil ? self.action(index, UserText.shareLinks(withCount: 1), "Share-Apple-16", { [weak self] index in
437439
guard let self else { return }
438440
self.longPressMenuShareLink(index: index)
439441
}) : nil,

DuckDuckGo/TabSwitcherViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ extension TabSwitcherViewController: UICollectionViewDelegate {
421421

422422
let title = indexPaths.count == 1 ?
423423
trimMenuTitleIfNeeded(tabsModel.get(tabAt: indexPaths[0].row).link?.displayTitle ?? "", 50) :
424-
UserText.numberOfTabs(indexPaths.count)
424+
UserText.numberOfSelectedTabs(withCount: indexPaths.count)
425425

426426
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ in
427427
let menuItems = indexPaths.count == 1 ?

DuckDuckGo/UserText.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ public struct UserText {
277277
return message.format(arguments: title, address)
278278
}
279279

280-
public static let tabSwitcherShareLink = NotLocalizedString("tab.switcher.share.link", value: "Share Link", comment: "Share link menu item")
281-
282280
public static let tabSwitcherBookmarkPage = NotLocalizedString("tab.switcher.bookmark.page", value: "Bookmark This Page", comment: "Bookmark this page menu item")
283281

284282
public static let tabSwitcherBookmarkAllTabs = NotLocalizedString("tab.switcher.bookmarkAll", value: "Bookmark All Tabs", comment: "Bookmark all tabs menu item")
@@ -293,8 +291,13 @@ public struct UserText {
293291
return String.localizedStringWithFormat(format, count)
294292
}
295293

296-
public static func shareSelectedLink(withCount count: Int) -> String {
297-
let format = Bundle.main.localizedString(forKey: "tabs.share.selected.with.count", value: nil, table: nil)
294+
public static func shareLinks(withCount count: Int) -> String {
295+
let format = Bundle.main.localizedString(forKey: "shareLinks.withCount", value: nil, table: nil)
296+
return String.localizedStringWithFormat(format, count)
297+
}
298+
299+
public static func shareSelectedTabs(withCount count: Int) -> String {
300+
let format = Bundle.main.localizedString(forKey: "shareSelectedTabs.withCount", value: nil, table: nil)
298301
return String.localizedStringWithFormat(format, count)
299302
}
300303

DuckDuckGo/en.lproj/Localizable.stringsdict

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ I blocked them!
418418
<string>Close Other Tab</string>
419419
</dict>
420420
</dict>
421-
<key>tabs.share.selected.with.count</key>
421+
<key>shareLinks.withCount</key>
422422
<dict>
423423
<key>NSStringLocalizedFormatKey</key>
424424
<string>%#@tabs@</string>
@@ -429,7 +429,23 @@ I blocked them!
429429
<key>NSStringFormatValueTypeKey</key>
430430
<string>d</string>
431431
<key>other</key>
432-
<string>Share %d Selected Tabs</string>
432+
<string>Share Links</string>
433+
<key>one</key>
434+
<string>Share Link</string>
435+
</dict>
436+
</dict>
437+
<key>shareSelectedTabs.withCount</key>
438+
<dict>
439+
<key>NSStringLocalizedFormatKey</key>
440+
<string>%#@tabs@</string>
441+
<key>tabs</key>
442+
<dict>
443+
<key>NSStringFormatSpecTypeKey</key>
444+
<string>NSStringPluralRuleType</string>
445+
<key>NSStringFormatValueTypeKey</key>
446+
<string>d</string>
447+
<key>other</key>
448+
<string>Share Selected Tabs</string>
433449
<key>one</key>
434450
<string>Share Selected Tab</string>
435451
</dict>
@@ -445,7 +461,7 @@ I blocked them!
445461
<key>NSStringFormatValueTypeKey</key>
446462
<string>d</string>
447463
<key>other</key>
448-
<string>Bookmark %d Selected Tabs</string>
464+
<string>Bookmark Selected Tabs</string>
449465
<key>one</key>
450466
<string>Bookmark Selected Tab</string>
451467
</dict>

0 commit comments

Comments
 (0)