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 when an app listed in Settings isn't installed

Țugui Dragoș037b5e1aefc7
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DecorativeSymbolTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DecorativeSymbolTests.swift
index a5588a33..c1f453f7 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DecorativeSymbolTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DecorativeSymbolTests.swift
@@ -7,6 +7,7 @@ struct DecorativeSymbolTests {
static let misleading: Set = [
"folder", "folder.fill", "questionmark.app", "doc.on.doc", "hammer", "chevron.right", "folder.badge.plus",
]
+ static let ownCovers = [".accessibilityHidden(true)", ".accessibilityLabel(", ".accessibilityRepresentation"]
static let ancestorCovers = [".hidden()", ".accessibilityElement(children: .ignore)", ".accessibilityLabel("]
@Test func aSymbolMacOSNamesByAnActionIsNeverLeftForVoiceOver() throws {
@@ -20,14 +21,9 @@ struct DecorativeSymbolTests {
let indent = Self.indent(of: line)
let before = lines[max(0, index - 3)...index].joined(separator: "\n")
if before.contains("icon:") || before.contains("label:") || before.contains("Label {") { continue }
+ let own = Self.ownModifiers(of: index, in: lines)
+ if own.contains(where: { line in Self.ownCovers.contains { line.contains($0) } }) { continue }
let following = lines[(index + 1)..<min(lines.count, index + 30)]
- let own = following.prefix { line in
- let code = line.trimmingCharacters(in: .whitespaces)
- return Self.indent(of: line) > indent && (code.hasPrefix(".") || code.hasPrefix("//"))
- }
- if own.contains(where: { $0.contains(".accessibilityHidden(true)") || $0.contains(".accessibilityLabel(") }) {
- continue
- }
let ancestors = following.filter { Self.indent(of: $0) < indent }
if ancestors.contains(where: { line in Self.ancestorCovers.contains { line.contains($0) } }) {
continue
@@ -45,6 +41,29 @@ struct DecorativeSymbolTests {
#expect(text.contains(".accessibilityHidden(systemImage != nil)"))
}
+ @Test func aMissingAppsStandInTellsVoiceOverItIsNotInstalled() throws {
+ let root = LineLengthTests.repository.path(percentEncoded: false)
+ var found: [String] = []
+ for file in try LineLengthTests.swiftFiles()
+ where file.path(percentEncoded: false).dropFirst(root.count).hasPrefix("Peel/") {
+ let lines = try String(contentsOf: file, encoding: .utf8).components(separatedBy: "\n")
+ for (index, line) in lines.enumerated() where Self.symbol(in: line) == "questionmark.app" {
+ let says = Self.ownModifiers(of: index, in: lines).contains { $0.contains(#"Text("Not installed")"#) }
+ if !says { found.append("\(file.path(percentEncoded: false).dropFirst(root.count)):\(index + 1)") }
+ }
+ }
+ #expect(found.isEmpty, "The only sign that the app isn't on this Mac says nothing to VoiceOver: \(found)")
+ }
+
+ /// The modifiers written on the image at `index` itself, each on a line of its own below it.
+ private static func ownModifiers(of index: Int, in lines: [String]) -> ArraySlice<String> {
+ let indent = indent(of: lines[index])
+ return lines[(index + 1)..<min(lines.count, index + 30)].prefix { line in
+ let code = line.trimmingCharacters(in: .whitespaces)
+ return Self.indent(of: line) > indent && (code.hasPrefix(".") || code.hasPrefix("//"))
+ }
+ }
+
private static func symbol(in line: String) -> String? {
guard let start = line.range(of: #"Image(systemName: ""#) else { return nil }
return line[start.upperBound...].split(separator: "\"", maxSplits: 1).first.map(String.init)
diff --git a/Peel/Views/Settings/ExclusionsSettingsView.swift b/Peel/Views/Settings/ExclusionsSettingsView.swift
index 689272a0..daadbb1d 100644
--- a/Peel/Views/Settings/ExclusionsSettingsView.swift
+++ b/Peel/Views/Settings/ExclusionsSettingsView.swift
@@ -112,7 +112,7 @@ struct ExclusionsSettingsView: View {
} else {
Image(systemName: "questionmark.app")
.foregroundStyle(.secondary)
- .accessibilityHidden(true)
+ .accessibilityRepresentation { Text("Not installed") }
}
Text(verbatim: identifier)
.font(.caption)
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index 47980a61..04f6b658 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -582,7 +582,7 @@ extension GeneralSettingsView {
} else {
Image(systemName: "questionmark.app")
.foregroundStyle(.secondary)
- .accessibilityHidden(true)
+ .accessibilityRepresentation { Text("Not installed") }
}
VStack(alignment: .leading, spacing: 1) {
Text(verbatim: item.name)