diff --git a/CMakeLists.txt b/CMakeLists.txt index c57d94da7..d48c3e825 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ if(POLICY CMP0114) endif() # Value should follow latest stable Xcode's RECOMMENDED_MACOSX_DEPLOYMENT_TARGET -set(MACOS_SUPPORT_MINIMUM 10.13) +set(MACOS_SUPPORT_MINIMUM 10.14.6) # The value of this variable should be set prior to the first project() command invocation. # See: https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index fad7208f9..b68bb5f71 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -3907,7 +3907,7 @@ INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional"; INFOPLIST_PREFIX_HEADER = libtransmission/version.h; INFOPLIST_PREPROCESS = YES; - MACOSX_DEPLOYMENT_TARGET = 10.13; + MACOSX_DEPLOYMENT_TARGET = 10.14.6; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "$(inherited)", @@ -4114,7 +4114,7 @@ INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional"; INFOPLIST_PREFIX_HEADER = libtransmission/version.h; INFOPLIST_PREPROCESS = YES; - MACOSX_DEPLOYMENT_TARGET = 10.13; + MACOSX_DEPLOYMENT_TARGET = 10.14.6; OTHER_CFLAGS = ( "$(inherited)", "-DFMT_HEADER_ONLY", @@ -4214,7 +4214,7 @@ INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional"; INFOPLIST_PREFIX_HEADER = libtransmission/version.h; INFOPLIST_PREPROCESS = YES; - MACOSX_DEPLOYMENT_TARGET = 10.13; + MACOSX_DEPLOYMENT_TARGET = 10.14.6; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "$(inherited)", diff --git a/macosx/Controller.h b/macosx/Controller.h index a599fc4e9..627500e9f 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -26,7 +26,7 @@ typedef NS_ENUM(unsigned int, addType) { // }; @interface Controller - : NSObject + : NSObject - (void)openFiles:(NSArray*)filenames addType:(addType)type forcePath:(NSString*)path; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 45720ebe9..2ebd1b5d3 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -825,30 +825,22 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool - (void)applicationWillFinishLaunching:(NSNotification*)notification { // user notifications - if (@available(macOS 10.14, *)) - { - UNUserNotificationCenter.currentNotificationCenter.delegate = self; - UNNotificationAction* actionShow = [UNNotificationAction actionWithIdentifier:@"actionShow" - title:NSLocalizedString(@"Show", "notification button") - options:UNNotificationActionOptionForeground]; - UNNotificationCategory* categoryShow = [UNNotificationCategory categoryWithIdentifier:@"categoryShow" actions:@[ actionShow ] - intentIdentifiers:@[] - options:UNNotificationCategoryOptionNone]; - [UNUserNotificationCenter.currentNotificationCenter setNotificationCategories:[NSSet setWithObject:categoryShow]]; - [UNUserNotificationCenter.currentNotificationCenter - requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) - completionHandler:^(BOOL /*granted*/, NSError* _Nullable error) { - if (error.code > 0) - { - NSLog(@"UserNotifications not configured: %@", error.localizedDescription); - } - }]; - } - else - { - // Fallback on earlier versions - NSUserNotificationCenter.defaultUserNotificationCenter.delegate = self; - } + UNUserNotificationCenter.currentNotificationCenter.delegate = self; + UNNotificationAction* actionShow = [UNNotificationAction actionWithIdentifier:@"actionShow" + title:NSLocalizedString(@"Show", "notification button") + options:UNNotificationActionOptionForeground]; + UNNotificationCategory* categoryShow = [UNNotificationCategory categoryWithIdentifier:@"categoryShow" actions:@[ actionShow ] + intentIdentifiers:@[] + options:UNNotificationCategoryOptionNone]; + [UNUserNotificationCenter.currentNotificationCenter setNotificationCategories:[NSSet setWithObject:categoryShow]]; + [UNUserNotificationCenter.currentNotificationCenter + requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) + completionHandler:^(BOOL /*granted*/, NSError* _Nullable error) { + if (error.code > 0) + { + NSLog(@"UserNotifications not configured: %@", error.localizedDescription); + } + }]; } - (void)applicationDidFinishLaunching:(NSNotification*)notification @@ -886,24 +878,12 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool andEventID:kAEOpenContents]; //if we were opened from a user notification, do the corresponding action - if (@available(macOS 10.14, *)) + UNNotificationResponse* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey]; + if (launchNotification) { - UNNotificationResponse* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey]; - if (launchNotification) - { - [self userNotificationCenter:UNUserNotificationCenter.currentNotificationCenter - didReceiveNotificationResponse:launchNotification withCompletionHandler:^{ - }]; - } - } - else - { - NSUserNotification* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey]; - if (launchNotification) - { - [self userNotificationCenter:NSUserNotificationCenter.defaultUserNotificationCenter - didActivateNotification:launchNotification]; - } + [self userNotificationCenter:UNUserNotificationCenter.currentNotificationCenter didReceiveNotificationResponse:launchNotification + withCompletionHandler:^{ + }]; } //auto importing @@ -2385,19 +2365,14 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool - (void)userNotificationCenter:(UNUserNotificationCenter*)center willPresentNotification:(UNNotification*)notification - withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(macos(10.14)) + withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { completionHandler(-1); } -- (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center shouldPresentNotification:(NSUserNotification*)notification -{ - return YES; -} - - (void)userNotificationCenter:(UNUserNotificationCenter*)center didReceiveNotificationResponse:(UNNotificationResponse*)response - withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(macos(10.14)) + withCompletionHandler:(void (^)(void))completionHandler { if (!response.notification.request.content.userInfo.count) { @@ -2416,23 +2391,6 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool completionHandler(); } -- (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification*)notification -{ - if (!notification.userInfo) - { - return; - } - - if (notification.activationType == NSUserNotificationActivationTypeActionButtonClicked) //reveal - { - [self didActivateNotificationByActionShowWithUserInfo:notification.userInfo]; - } - else if (notification.activationType == NSUserNotificationActivationTypeContentsClicked) - { - [self didActivateNotificationByDefaultActionWithUserInfo:notification.userInfo]; - } -} - - (void)didActivateNotificationByActionShowWithUserInfo:(NSDictionary*)userInfo { Torrent* torrent = [self torrentForHash:userInfo[@"Hash"]]; @@ -2555,30 +2513,15 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool userInfo[@"Location"] = location; } - if (@available(macOS 10.14, *)) - { - NSString* identifier = [@"Download Complete " stringByAppendingString:torrent.hashString]; - UNMutableNotificationContent* content = [UNMutableNotificationContent new]; - content.title = title; - content.body = body; - content.categoryIdentifier = @"categoryShow"; - content.userInfo = userInfo; + NSString* identifier = [@"Download Complete " stringByAppendingString:torrent.hashString]; + UNMutableNotificationContent* content = [UNMutableNotificationContent new]; + content.title = title; + content.body = body; + content.categoryIdentifier = @"categoryShow"; + content.userInfo = userInfo; - UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]; - [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; - } - else - { - // Fallback on earlier versions - NSUserNotification* userNotification = [[NSUserNotification alloc] init]; - userNotification.title = title; - userNotification.informativeText = body; - userNotification.hasActionButton = YES; - userNotification.actionButtonTitle = NSLocalizedString(@"Show", "notification button"); - userNotification.userInfo = userInfo; - - [NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:userNotification]; - } + UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]; + [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; if (!self.fWindow.mainWindow) { @@ -2622,30 +2565,15 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool userInfo[@"Location"] = location; } - if (@available(macOS 10.14, *)) - { - NSString* identifier = [@"Seeding Complete " stringByAppendingString:torrent.hashString]; - UNMutableNotificationContent* content = [UNMutableNotificationContent new]; - content.title = title; - content.body = body; - content.categoryIdentifier = @"categoryShow"; - content.userInfo = userInfo; + NSString* identifier = [@"Seeding Complete " stringByAppendingString:torrent.hashString]; + UNMutableNotificationContent* content = [UNMutableNotificationContent new]; + content.title = title; + content.body = body; + content.categoryIdentifier = @"categoryShow"; + content.userInfo = userInfo; - UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]; - [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; - } - else - { - // Fallback on earlier versions - NSUserNotification* userNotification = [[NSUserNotification alloc] init]; - userNotification.title = title; - userNotification.informativeText = body; - userNotification.hasActionButton = YES; - userNotification.actionButtonTitle = NSLocalizedString(@"Show", "notification button"); - userNotification.userInfo = userInfo; - - [NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:userNotification]; - } + UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]; + [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; //removing from the list calls fullUpdateUI if (torrent.removeWhenFinishSeeding) @@ -3503,26 +3431,13 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool NSLocalizedString(@"Speed Limit Auto Disabled", "notification title"); NSString* body = NSLocalizedString(@"Bandwidth settings changed", "notification description"); - if (@available(macOS 10.14, *)) - { - NSString* identifier = @"Bandwidth settings changed"; - UNMutableNotificationContent* content = [UNMutableNotificationContent new]; - content.title = title; - content.body = body; + NSString* identifier = @"Bandwidth settings changed"; + UNMutableNotificationContent* content = [UNMutableNotificationContent new]; + content.title = title; + content.body = body; - UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]; - [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; - } - else - { - // Fallback on earlier versions - NSUserNotification* notification = [[NSUserNotification alloc] init]; - notification.title = title; - notification.informativeText = body; - notification.hasActionButton = NO; - - [NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification]; - } + UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]; + [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; } } @@ -3630,26 +3545,13 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool NSString* notificationTitle = NSLocalizedString(@"Torrent File Auto Added", "notification title"); - if (@available(macOS 10.14, *)) - { - NSString* identifier = [@"Torrent File Auto Added " stringByAppendingString:file]; - UNMutableNotificationContent* content = [UNMutableNotificationContent new]; - content.title = notificationTitle; - content.body = file; + NSString* identifier = [@"Torrent File Auto Added " stringByAppendingString:file]; + UNMutableNotificationContent* content = [UNMutableNotificationContent new]; + content.title = notificationTitle; + content.body = file; - UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]; - [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; - } - else - { - // Fallback on earlier versions - NSUserNotification* notification = [[NSUserNotification alloc] init]; - notification.title = notificationTitle; - notification.informativeText = file; - notification.hasActionButton = NO; - - [NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification]; - } + UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]; + [UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil]; } } diff --git a/macosx/NSApplicationAdditions.mm b/macosx/NSApplicationAdditions.mm index 433f8b361..eea187565 100644 --- a/macosx/NSApplicationAdditions.mm +++ b/macosx/NSApplicationAdditions.mm @@ -8,14 +8,7 @@ - (BOOL)isDarkMode { - if (@available(macOS 10.14, *)) - { - return [self.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua]; - } - else - { - return NO; - } + return [self.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua]; } @end