Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Tell VoiceOver why nothing on an app's page can move

Țugui Dragoș1c0f9d0a4b14
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ScanAnnouncementTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ScanAnnouncementTests.swift
index de46995e..41b8d02d 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ScanAnnouncementTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ScanAnnouncementTests.swift
@@ -20,4 +20,13 @@ struct ScanAnnouncementTests {
"ScanState builds its content again when the first scan ends, which loses an announcement inside it: \(found)"
)
}
+
+ @Test func anAppsPageSaysWhyNothingMovesRatherThanNothingFound() throws {
+ for name in ["Peel/Views/AppDetailView.swift", "Peel/Views/MultipleAppsView.swift"] {
+ let text = try String(contentsOf: LineLengthTests.repository.appending(path: name), encoding: .utf8)
+ let call = try #require(text.range(of: ".announcesScan(")).upperBound
+ let arguments = text[call...].prefix { $0 != ")" }
+ #expect(arguments.contains("couldNotLook:"), "\(name) lists the apps it can't move and says Nothing found.")
+ }
+ }
}
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index e4ec6e1d..6c2ad33f 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -122,7 +122,7 @@ struct AppDetailView: View {
RemovalsHeldBanner()
if plan.isExcluded {
Notice(
- title: Text("This app is excluded"),
+ title: Text(Self.excludedTitle),
detail: Text("Peel leaves it and its files alone. Change that in Settings."),
kind: .note
) {
@@ -132,7 +132,7 @@ struct AppDetailView: View {
}
if plan.removedElsewhere == .byRemovePeel {
Notice(
- title: Text("Peel removes itself in Settings"),
+ title: Text(Self.removesItselfTitle),
detail: Text("Remove Peel, in Settings > General, removes its helper and login item as well. Moved from here, Peel would leave them behind."),
kind: .note
) {
@@ -203,7 +203,12 @@ struct AppDetailView: View {
}
.scrollBarBelowSectionHeaders()
.scanState(phase, fadesInResults: false, scan: plan.scanRun)
- .announcesScan(plan.isScanning, found: plan.total.spoken, wasStopped: plan.scanRun.wasStopped)
+ .announcesScan(
+ plan.isScanning,
+ found: plan.total.spoken,
+ couldNotLook: whyNothingMoves,
+ wasStopped: plan.scanRun.wasStopped
+ )
.edgeBar(.bottom) {
if plan.scan != nil {
let selected = plan.request.total
@@ -331,6 +336,21 @@ struct AppDetailView: View {
}
}
+ private static let excludedTitle: LocalizedStringResource = "This app is excluded"
+ private static let removesItselfTitle: LocalizedStringResource = "Peel removes itself in Settings"
+
+ /// What VoiceOver hears when the scan ends with nothing here to move: the title of the page's own note, as on
+ /// every other page, since the app and its files are still listed.
+ private var whyNothingMoves: LocalizedStringResource {
+ if plan.isExcluded { return Self.excludedTitle }
+ switch plan.removedElsewhere {
+ case .byRemovePeel?: return Self.removesItselfTitle
+ case .byItsMaker(let uninstaller)?: return MakersUninstallerNotice.title(of: uninstaller)
+ case .byFinder?: return SystemExtensionNotice.title
+ case nil: return "Nothing here can be moved. Each file’s note says why."
+ }
+ }
+
private var appWarning: String? {
if let removedElsewhere = plan.removedElsewhere {
return String(localized: removedElsewhere.explanation)
diff --git a/Peel/Views/MakersUninstallerNotice.swift b/Peel/Views/MakersUninstallerNotice.swift
index 828c7c7a..8ddecae8 100644
--- a/Peel/Views/MakersUninstallerNotice.swift
+++ b/Peel/Views/MakersUninstallerNotice.swift
@@ -9,7 +9,7 @@ struct MakersUninstallerNotice: View {
let uninstaller: MakersUninstaller
var body: some View {
- Notice(title: title, detail: detail, kind: .note) {
+ Notice(title: Text(Self.title(of: uninstaller)), detail: detail, kind: .note) {
switch uninstaller.step {
case .command(let command):
CopyButton(text: command, title: "Copy Uninstall Command")
@@ -25,11 +25,11 @@ struct MakersUninstallerNotice: View {
}
}
- private var title: Text {
+ static func title(of uninstaller: MakersUninstaller) -> LocalizedStringResource {
if let product = uninstaller.removes {
- Text("\(uninstaller.maker)’s uninstaller for \(product)")
+ "\(uninstaller.maker)’s uninstaller for \(product)"
} else {
- Text("Removed with \(uninstaller.maker)’s own uninstaller")
+ "Removed with \(uninstaller.maker)’s own uninstaller"
}
}
diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swift
index 03344d63..96112231 100644
--- a/Peel/Views/MultipleAppsView.swift
+++ b/Peel/Views/MultipleAppsView.swift
@@ -110,7 +110,12 @@ struct MultipleAppsView: View {
.dimmedWhileBusy(plan.isRemoving)
.disabled(plan.isRemoving)
.scanState(phase, isRescanning: isRescanning, fadesInResults: false, scan: plan.scanRun)
- .announcesScan(plan.isScanning, found: plan.total.spoken, wasStopped: plan.scanRun.wasStopped)
+ .announcesScan(
+ plan.isScanning,
+ found: plan.total.spoken,
+ couldNotLook: "Nothing here can be moved. Each file’s note says why.",
+ wasStopped: plan.scanRun.wasStopped
+ )
.edgeBar(.bottom) {
if plan.bulk != nil {
let selected = plan.request.total
diff --git a/Peel/Views/VendorNotes.swift b/Peel/Views/VendorNotes.swift
index f86bfffe..f13ac960 100644
--- a/Peel/Views/VendorNotes.swift
+++ b/Peel/Views/VendorNotes.swift
@@ -7,9 +7,11 @@ struct SystemExtensionNotice: View {
let app: InstalledApp
let extensions: CarriedSystemExtensions
+ static let title: LocalizedStringResource = "Move It to the Trash in Finder"
+
var body: some View {
Notice(
- title: Text("Move It to the Trash in Finder"),
+ title: Text(Self.title),
detail: detail,
kind: .note
) {