Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
.DS_Store
*.dmg
39 changes: 21 additions & 18 deletions FastFinder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 56;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -177,14 +177,14 @@
8ED3D89321B1B7420059AFF9 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1600;
ORGANIZATIONNAME = "Anthonin Cocagne";
TargetAttributes = {
8ED3D89A21B1B7420059AFF9 = {
CreatedOnToolsVersion = 10.1;
SystemCapabilities = {
com.apple.HardenedRuntime = {
enabled = 0;
enabled = 1;
};
com.apple.Sandbox = {
enabled = 0;
Expand All @@ -194,7 +194,7 @@
};
};
buildConfigurationList = 8ED3D89621B1B7420059AFF9 /* Build configuration list for PBXProject "FastFinder" */;
compatibilityVersion = "Xcode 9.3";
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down Expand Up @@ -247,17 +247,16 @@
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-FastFinder/Pods-FastFinder-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/MASShortcut/MASShortcut.bundle",
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-FastFinder/Pods-FastFinder-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MASShortcut.bundle",
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-FastFinder/Pods-FastFinder-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FastFinder/Pods-FastFinder-resources.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-FastFinder/Pods-FastFinder-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -296,7 +295,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
Expand All @@ -322,7 +321,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_IDENTITY = "Apple Development";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -341,7 +340,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -394,7 +393,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand All @@ -405,16 +404,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 3D09F07E1DAAECD214DAA955 /* Pods-FastFinder.debug.xcconfig */;
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = FastFinder/FastFinder.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 6A546753D6;
DEVELOPMENT_TEAM = A63B2PPG38;
INFOPLIST_FILE = FastFinder/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = com.acocagne.FastFinder;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -424,16 +425,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 04FFAE9FB767C6D853FBDCBC /* Pods-FastFinder.release.xcconfig */;
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = FastFinder/FastFinder.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 6A546753D6;
DEVELOPMENT_TEAM = A63B2PPG38;
INFOPLIST_FILE = FastFinder/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = com.acocagne.FastFinder;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
86 changes: 77 additions & 9 deletions FastFinder/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "AppDelegate.h"
#import <MASShortcut/Shortcut.h>
#import "FinderLogicHelper.h"
#import <ServiceManagement/ServiceManagement.h>

@interface AppDelegate ()

Expand All @@ -19,25 +18,94 @@ @implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
//no dock icon
[NSApp windows][0].canHide = NO;
NSWindow *mainWindow = [NSApp windows].firstObject;
if (mainWindow) {
mainWindow.canHide = NO;
}
[NSApp setActivationPolicy: NSApplicationActivationPolicyAccessory];

[[MASShortcutBinder sharedBinder]
bindShortcutWithDefaultsKey:kPreferenceGlobalShortcut
toAction:^{
[[FinderLogicHelper getInstance] processFinderLogic];
}];
[self requestAccessibilityAccess];

[self registerGlobalShortcut];
}

- (void)registerGlobalShortcut {
[[NSUserDefaults standardUserDefaults] addObserver:self
forKeyPath:kPreferenceGlobalShortcut
options:NSKeyValueObservingOptionNew
context:NULL];
[self updateGlobalShortcut];
}

- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary<NSKeyValueChangeKey,id> *)change
context:(void *)context {
if ([keyPath isEqualToString:kPreferenceGlobalShortcut]) {
[self updateGlobalShortcut];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}

- (void)updateGlobalShortcut {
id shortcutData = [[NSUserDefaults standardUserDefaults] objectForKey:kPreferenceGlobalShortcut];
NSLog(@"[AppDelegate] Stored shortcut data: %@", shortcutData);

MASShortcut *shortcut = nil;
if ([shortcutData isKindOfClass:[NSData class]]) {
@try {
NSError *error = nil;
shortcut = [NSKeyedUnarchiver unarchivedObjectOfClass:[MASShortcut class]
fromData:shortcutData
error:&error];
if (error || !shortcut) {
NSLog(@"[AppDelegate] Secure unarchiving failed: %@", error);
// Fallback to legacy unarchiving
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
shortcut = [NSKeyedUnarchiver unarchiveObjectWithData:shortcutData];
#pragma clang diagnostic pop
}
} @catch (NSException *exception) {
NSLog(@"[AppDelegate] Exception unarchiving shortcut: %@", exception);
}
}

NSLog(@"[AppDelegate] Resolved shortcut: %@", shortcut);

[[MASShortcutMonitor sharedMonitor] unregisterAllShortcuts];

if (shortcut) {
BOOL registered = [[MASShortcutMonitor sharedMonitor] registerShortcut:shortcut withAction:^{
NSLog(@"[AppDelegate] Global shortcut triggered!");
[[FinderLogicHelper getInstance] processFinderLogic];
}];
NSLog(@"[AppDelegate] MASShortcutMonitor registerShortcut result: %d", registered);
}
}

- (void)dealloc {
@try {
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:kPreferenceGlobalShortcut];
} @catch (NSException *exception) {}
}

- (void)requestAccessibilityAccess {
NSDictionary *options = @{(__bridge id)kAXTrustedCheckOptionPrompt: @YES};
AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef)options);
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}


- (void)applicationDidBecomeActive:(NSNotification *)notification {
//to reopen settings window
[[NSApp windows][0] makeKeyAndOrderFront:self];
NSWindow *window = [NSApp windows].firstObject;
if (window) {
[window makeKeyAndOrderFront:self];
}
}

@end
Loading