Skip to content

Commit

Permalink
Support for macOS Sierra 10.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasVerhoeven committed Jan 8, 2017
1 parent d83ffee commit c376a6b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 20 deletions.
57 changes: 52 additions & 5 deletions AveNoAnimationsInMailPlugin/AveHookBootstrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ @implementation AveHookBootstrapper

static BOOL elCapitanOverrideTransactionDurationToZero = NO;

+(BOOL)isElCapitan
+(BOOL)isAtLeastElCapitan
{
static BOOL isElCapitan = NO;
static BOOL isAtLeastElCapitan = NO;

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Expand All @@ -26,11 +26,31 @@ +(BOOL)isElCapitan
NSOperatingSystemVersion version = {0};
version.majorVersion = 10;
version.minorVersion = 11; // el cap
isElCapitan = [processInfo isOperatingSystemAtLeastVersion:version];
isAtLeastElCapitan = [processInfo isOperatingSystemAtLeastVersion:version];
}
});

return isElCapitan;
return isAtLeastElCapitan;
}


+(BOOL)isAtLeastSierra
{
static BOOL isAtLeastSierra = NO;

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSProcessInfo* processInfo = [NSProcessInfo processInfo];
if([processInfo respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)])
{
NSOperatingSystemVersion version = {0};
version.majorVersion = 10;
version.minorVersion = 12; // sierra
isAtLeastSierra = [processInfo isOperatingSystemAtLeastVersion:version];
}
});

return isAtLeastSierra;
}

static IMP AveReplaceMethod(Class class, BOOL isMetaClass, SEL sel, id block) {
Expand Down Expand Up @@ -118,6 +138,22 @@ +(void)aveElCapitanSwizzleComposeWindowControllerPerformSendAnimation
});
}

// -[ComposeWindowController _performSendAnimationWithCompletion:](void * self, void * _cmd, void * arg2) {
+(void)aveSierraSwizzleComposeWindowControllerPerformSendAnimationWithCompletion
{
Class class = NSClassFromString(@"ComposeWindowController");
SEL sel = @selector(_performSendAnimationWithCompletion:);
__block IMP originalImplementation = AveReplaceInstanceMethod(class, sel, ^(id obj, id block){
elCapitanOverrideTransactionDurationToZero = YES;
if(originalImplementation != NULL)
{
((void(*)(id, SEL, id))originalImplementation)(obj, sel, block);
}

elCapitanOverrideTransactionDurationToZero = NO;
});
}

+(void)aveElCapitanSwizzlePopoutAnimationController_animateFrom_to_withCompletion
{
Class class = NSClassFromString(@"PopoutAnimationController");
Expand Down Expand Up @@ -226,6 +262,11 @@ -(void)_performSendAnimation
}
}

- (void)_performSendAnimationWithCompletion:(id)block
{
NSLog(@"Ave _performSendAnimationWithCompletion: should not be called in our class!");
}

// this will never be called, but we define it so we can call it in the swizzled
// method _performSendAnimation in this class. However, _performSendAnimation will
// only be called in the context of DocumentEditor, so -[DocumentEditor _sendAnimationCompleted]
Expand Down Expand Up @@ -276,7 +317,8 @@ +(void)aveSwizzleWindowTransformAnimation
+(void)load
{
NSLog(@"Ave: Loaded, time to start swizzling");
if([self isElCapitan])

if([self isAtLeastElCapitan])
{
[self aveElCapitanSwizzleCATransactionSetAnimationDuration];
[self aveElCapitanSwizzleNSAnimationContextSetDuration];
Expand All @@ -285,6 +327,11 @@ +(void)load
[self aveElCapitanswizzlePopoutAnimationController_internalTransitionAnimationWithDestination_fadeOut];
[self aveElCapitanSwizzleWindowTransformAnimation__animationDurationForAnimationType];
[self aveElCapitanSwizzleFullScreenWindowController_animateModalWindowClose];

if([self isAtLeastSierra])
{
[self aveSierraSwizzleComposeWindowControllerPerformSendAnimationWithCompletion];
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.2</string>
<string>1.3</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 AveApps. All rights reserved.</string>
<string>Copyright © 2017 AveApps. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>AveHookBootstrapper</string>
<key>Supported10.12PluginCompatibilityUUIDs</key>
<array>
<string># mail 10.0 (macOS Sierra 10.12)</string>
<string>36CCB8BB-2207-455E-89BC-B9D6E47ABB5B</string>
<string># mail 10.2 (macOS Sierra 10.12.2)</string>
<string>1CD3B36A-0E3B-4A26-8F7E-5BDF96AAC97E</string>
</array>
<key>SupportedPluginCompatibilityUUIDs</key>
<array>
<string># All Mail UUIDs</string>
Expand Down Expand Up @@ -76,10 +83,5 @@
<string># for macOS Sierra</string>
<string>36CCB8BB-2207-455E-89BC-B9D6E47ABB5B</string>
</array>
<key>Supported10.12PluginCompatibilityUUIDs</key>
<array>
<string># mail 10.0 (macOS Sierra 10.12)</string>
<string>36CCB8BB-2207-455E-89BC-B9D6E47ABB5B</string>
</array>
</dict>
</plist>
Binary file modified Output/AveNoAnimationsInMailPlugin.mailbundle.zip
Binary file not shown.
18 changes: 10 additions & 8 deletions Output/AveNoAnimationsInMailPlugin.mailbundle/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>15G1004</string>
<string>16C68</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
Expand All @@ -25,29 +25,31 @@
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1.2</string>
<string>1.3</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>7D1014</string>
<string>8C1002</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>15E60</string>
<string>16C58</string>
<key>DTSDKName</key>
<string>macosx10.11</string>
<string>macosx10.12</string>
<key>DTXcode</key>
<string>0731</string>
<string>0821</string>
<key>DTXcodeBuild</key>
<string>7D1014</string>
<string>8C1002</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 AveApps. All rights reserved.</string>
<string>Copyright © 2017 AveApps. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>AveHookBootstrapper</string>
<key>Supported10.12PluginCompatibilityUUIDs</key>
<array>
<string># mail 10.0 (macOS Sierra 10.12)</string>
<string>36CCB8BB-2207-455E-89BC-B9D6E47ABB5B</string>
<string># mail 10.2 (macOS Sierra 10.12.2)</string>
<string>1CD3B36A-0E3B-4A26-8F7E-5BDF96AAC97E</string>
</array>
<key>SupportedPluginCompatibilityUUIDs</key>
<array>
Expand Down
Binary file not shown.
Binary file modified Output/DisableMailAnimationsForOSX.pkg
Binary file not shown.

0 comments on commit c376a6b

Please sign in to comment.