This commit is contained in:
Alin
2024-03-29 17:26:46 -06:00
parent 7906cd70f7
commit a65fdeb5a5
4 changed files with 65 additions and 24 deletions
+4 -4
View File
@@ -575,7 +575,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 27; CURRENT_PROJECT_VERSION = 28;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BK8443AXLU; DEVELOPMENT_TEAM = BK8443AXLU;
@@ -593,7 +593,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 13.0; MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 3.3.1; MARKETING_VERSION = 3.3.2;
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
@@ -610,7 +610,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 27; CURRENT_PROJECT_VERSION = 28;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BK8443AXLU; DEVELOPMENT_TEAM = BK8443AXLU;
@@ -628,7 +628,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 13.0; MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 3.3.1; MARKETING_VERSION = 3.3.2;
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
+2 -2
View File
@@ -84,12 +84,13 @@ struct InfoButton: View {
Button(action: { Button(action: {
self.isPopoverPresented.toggle() self.isPopoverPresented.toggle()
}) { }) {
HStack { HStack(alignment: .center, spacing: 5) {
Image(systemName: "info.circle.fill") Image(systemName: "info.circle.fill")
.resizable() .resizable()
.scaledToFit() .scaledToFit()
.frame(width: 14, height: 14) .frame(width: 14, height: 14)
.foregroundColor(color?.opacity(0.7) ?? Color("mode").opacity(0.7)) .foregroundColor(color?.opacity(0.7) ?? Color("mode").opacity(0.7))
.frame(height: 16)
if !label!.isEmpty { if !label!.isEmpty {
Text(label!) Text(label!)
.font(.callout) .font(.callout)
@@ -97,7 +98,6 @@ struct InfoButton: View {
} }
} }
} }
.buttonStyle(PlainButtonStyle()) .buttonStyle(PlainButtonStyle())
.onHover { isHovered in .onHover { isHovered in
+17
View File
@@ -388,6 +388,23 @@ func removeApp(appState: AppState, withId id: UUID) {
} }
// Check if app bundle is nested
func isNested(path: URL) -> Bool {
let applicationsPath = "/Applications"
let homeApplicationsPath = "\(home)/Applications"
guard path.path.contains("Applications") else {
return false
}
// Get the parent directory of the app
let parentDirectory = path.deletingLastPathComponent().path
// Check if the parent directory is not directly /Applications or ~/Applications
return parentDirectory != applicationsPath && parentDirectory != homeApplicationsPath
}
// --- Extend Int to convert hours to seconds --- // --- Extend Int to convert hours to seconds ---
extension Int { extension Int {
+37 -13
View File
@@ -273,17 +273,36 @@ struct FilesView: View {
appState.currentView = .empty appState.currentView = .empty
} }
} }
var selectedItemsArray = Array(appState.selectedItems) let selectedItemsArray = Array(appState.selectedItems)
if let url = URL(string: appState.appInfo.path.absoluteString) {
let appFolderURL = appState.appInfo.path.absoluteString.contains("Wrapper") ? url.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent() : url.deletingLastPathComponent() // Get the immediate parent directory of regular and wrapped apps
if appFolderURL.path == "/Applications" || appFolderURL.path == "\(home)/Applications" { // Delete all folders above app bundle between /Applications and app bundle file
// Do nothing, skip insertion
} else if appFolderURL.pathComponents.count > 2 && appFolderURL.path.contains("Applications") { // if let url = URL(string: appState.appInfo.path.absoluteString) {
// Insert into selectedItemsArray only if there is an intermediary folder // var parentURL = url.deletingLastPathComponent() // Immediate parent of the .app bundle
selectedItemsArray.insert(appFolderURL, at: 0) //
} // // Traverse up the path components until just below /Applications or ~/Applications
} // while parentURL.pathComponents.count > 2 && parentURL.path.contains("Applications") && parentURL.deletingLastPathComponent().path != "/Applications" && parentURL.deletingLastPathComponent().path != "\(home)/Applications" {
// parentURL = parentURL.deletingLastPathComponent()
// }
//
// // Now, parentURL should be the directory just below /Applications or ~/Applications
// if parentURL.path != "/Applications" && parentURL.path != "\(home)/Applications" {
// selectedItemsArray.insert(parentURL, at: 0) // Add the correct parent directory to the array
// }
// }
// Delete folder only 1 up from app bundle between /Applications and app bundle file
// if let url = URL(string: appState.appInfo.path.absoluteString) {
// let appFolderURL = appState.appInfo.path.absoluteString.contains("Wrapper") ? url.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent() : url.deletingLastPathComponent() // Get the immediate parent directory of regular and wrapped apps
//
// if appFolderURL.path == "/Applications" || appFolderURL.path == "\(home)/Applications" {
// // Do nothing, skip insertion
// } else if appFolderURL.pathComponents.count > 2 && appFolderURL.path.contains("Applications") {
// // Insert into selectedItemsArray only if there is an intermediary folder
// selectedItemsArray.insert(appFolderURL, at: 0)
// }
// }
killApp(appId: appState.appInfo.bundleIdentifier) { killApp(appId: appState.appInfo.bundleIdentifier) {
moveFilesToTrash(at: selectedItemsArray) { moveFilesToTrash(at: selectedItemsArray) {
@@ -303,8 +322,8 @@ struct FilesView: View {
caskCleanup(app: appState.appInfo.appName) caskCleanup(app: appState.appInfo.appName)
} }
// Remove app from app list if all app files were removed // Remove app from app list if main app bundle is removed
if appState.appInfo.files.count == selectedItemsArray.count { if selectedItemsArray.contains(where: { $0.absoluteString == appState.appInfo.path.absoluteString }) {
removeApp(appState: appState, withId: appState.appInfo.id) removeApp(appState: appState, withId: appState.appInfo.id)
} else { } else {
// Add deleted appInfo object to trashed array // Add deleted appInfo object to trashed array
@@ -317,7 +336,6 @@ struct FilesView: View {
appState.appInfoStore[index] = .empty appState.appInfoStore[index] = .empty
} }
} }
appState.appInfo = AppInfo.empty appState.appInfo = AppInfo.empty
} }
} }
@@ -382,11 +400,17 @@ struct FileDetailsItem: View {
} }
VStack(alignment: .leading, spacing: 5) { VStack(alignment: .leading, spacing: 5) {
HStack(alignment: .center) {
Text(path.lastPathComponent) Text(path.lastPathComponent)
.font(.title3) .font(.title3)
.lineLimit(1) .lineLimit(1)
.truncationMode(.tail) .truncationMode(.tail)
.help(path.lastPathComponent) .help(path.lastPathComponent)
if isNested(path: path) {
InfoButton(text: "Application file is nested within subdirectories. To prevent deleting incorrect folders, Pearcleaner will leave these alone. You may manually delete the remaining folders if required.", color: nil, label: "")
}
}
Text(path.path) Text(path.path)
.font(.footnote) .font(.footnote)
.lineLimit(1) .lineLimit(1)