Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Commit

Permalink
+ switcher wallpaper blurring
Browse files Browse the repository at this point in the history
  • Loading branch information
insanj committed Feb 13, 2014
1 parent 839a250 commit 7ff452c
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 34 deletions.
39 changes: 39 additions & 0 deletions CKBlurView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// CKBlurView.h
// CKBlurView
//
// Created by Conrad Kramer on 10/25/13.
// Copyright (c) 2013 Kramer Software Productions, LLC. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>

extern NSString * const CKBlurViewQualityDefault;

extern NSString * const CKBlurViewQualityLow;

NS_CLASS_AVAILABLE_IOS(7_0) @interface CKBlurView : UIView

/**
Quality of the blur. The lower the quality, the more performant the blur. Must be one of `CKBlurViewQualityDefault` or `CKBlurViewQualityLow`. Defaults to `CKBlurViewQualityDefault`.
*/
@property (nonatomic, retain) NSString *blurQuality;

/**
Radius of the Gaussian blur. Defaults to 5.0.
*/
@property (nonatomic, readwrite) CGFloat blurRadius;

/**
Bounds to be blurred, in the receiver's coordinate system. Defaults to CGRectNull.
*/
@property (nonatomic, readwrite) CGRect blurCroppingRect;

/**
Boolean indicating whether the edge of the view should be softened. Defaults to YES.
*/
@property (nonatomic, readwrite) BOOL blurEdges;

@end
94 changes: 94 additions & 0 deletions CKBlurView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// CKBlurView.m
// CKBlurView
//
// Created by Conrad Kramer on 10/25/13.
// Copyright (c) 2013 Kramer Software Productions, LLC. All rights reserved.
//

#import "CKBlurView.h"

@interface CABackdropLayer : CALayer

@end

@interface CAFilter : NSObject

+ (instancetype)filterWithName:(NSString *)name;

@end

@interface CKBlurView ()

@property (retain, nonatomic) CAFilter *blurFilter;

@end

extern NSString * const kCAFilterGaussianBlur;

NSString * const CKBlurViewQualityDefault = @"default";

NSString * const CKBlurViewQualityLow = @"low";

static NSString * const CKBlurViewQualityKey = @"inputQuality";

static NSString * const CKBlurViewRadiusKey = @"inputRadius";

static NSString * const CKBlurViewBoundsKey = @"inputBounds";

static NSString * const CKBlurViewHardEdgesKey = @"inputHardEdges";


@implementation CKBlurView

+ (Class)layerClass {
return [CABackdropLayer class];
}

- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
CAFilter *filter = [CAFilter filterWithName:kCAFilterGaussianBlur];
self.layer.filters = @[ filter ];
self.blurFilter = filter;

self.blurQuality = CKBlurViewQualityDefault;
self.blurRadius = 5.0f;
}
return self;
}

- (void)setQuality:(NSString *)quality {
[self.blurFilter setValue:quality forKey:CKBlurViewQualityKey];
}

- (NSString *)quality {
return [self.blurFilter valueForKey:CKBlurViewQualityKey];
}

- (void)setBlurRadius:(CGFloat)radius {
[self.blurFilter setValue:@(radius) forKey:CKBlurViewRadiusKey];
}

- (CGFloat)blurRadius {
return [[self.blurFilter valueForKey:CKBlurViewRadiusKey] floatValue];
}

- (void)setBlurCroppingRect:(CGRect)croppingRect {
[self.blurFilter setValue:[NSValue valueWithCGRect:croppingRect] forKey:CKBlurViewBoundsKey];
}

- (CGRect)blurCroppingRect {
NSValue *value = [self.blurFilter valueForKey:CKBlurViewBoundsKey];
return value ? [value CGRectValue] : CGRectNull;
}

- (void)setBlurEdges:(BOOL)blurEdges {
[self.blurFilter setValue:@(!blurEdges) forKey:CKBlurViewHardEdgesKey];
}

- (BOOL)blurEdges {
return ![[self.blurFilter valueForKey:CKBlurViewHardEdgesKey] boolValue];
}

@end
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ARCHS = armv7 armv7s arm64
include theos/makefiles/common.mk

TWEAK_NAME = SwitcherBlur
SwitcherBlur_OBJC_FILES = SwitcherBlur.xm
SwitcherBlur_FRAMEWORKS = UIKit QuartzCore
SwitcherBlur_OBJC_FILES = SwitcherBlur.xm CKBlurView.m
SwitcherBlur_FRAMEWORKS = UIKit QuartzCore CoreGraphics

include $(THEOS_MAKE_PATH)/tweak.mk
SUBPROJECTS += switcherblurprefs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SwitcherBlur
=======================

Configurable iOS 7 snapshots blurs.
Configurable iOS 7 snapshots blurs. Uses [CKBlurView](https://github.com/conradev/CKBlurView) by conradev for the wallpaper blurring.

![Gaussian Blur your app snapshots](https://f.cloud.github.com/assets/951011/2054415/231a633a-8ab5-11e3-99d8-0d8b75842f47.PNG)

Expand Down
47 changes: 42 additions & 5 deletions SwitcherBlur.xm
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <objc/runtime.h>
#import "CKBlurView.h"

/******************** Forward-Declarations *********************/
/**************************** Forward-Declarations ****************************/

@interface CAFilter : NSObject
+(instancetype)filterWithName:(NSString *)name;
@end

@interface SpringBoard : UIApplication
-(void)_relaunchSpringBoardNow;
@end

@interface SBApplication
-(id)bundleIdentifier;
-(BOOL)isRunning;
@end

@interface SBAppSliderWindow : UIWindow
@end

@interface SBAppSliderSnapshotView {
UIImageView *_snapshotImage;
}
Expand All @@ -22,18 +30,19 @@
@end


/*********************** Global Functions **********************/
/**************************** Settings Assignments ***************************/

static NSMutableArray *switcherblur_DisabledApps; // @"All" means all are disabled, nil means everything's enabled
static NSInteger switcherblur_blurIfInactive;
static NSInteger switcherblur_blurIfInactive, switcherblur_blurWallpaper;

static void switcherBlur_reloadSettings(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo){
NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"/Library/Preferences/com.insanj.switcherblur.plist"]];
NSLog(@"[SwitcherBlur] Reloading settings: %@", settings);

if([settings objectForKey:@"enabled"] && ![[settings objectForKey:@"enabled"] boolValue]){
switcherblur_DisabledApps = @[@"All"].mutableCopy;
switcherblur_blurIfInactive = NO;
switcherblur_blurIfInactive = 1;
switcherblur_blurWallpaper = 1;
}

else{
Expand All @@ -46,10 +55,38 @@ static void switcherBlur_reloadSettings(CFNotificationCenterRef center, void *ob
switcherblur_DisabledApps = nil;

switcherblur_blurIfInactive = ([settings objectForKey:@"running"] && [[settings objectForKey:@"running"] boolValue]) + 1;

int previousWallpaper = switcherblur_blurWallpaper;
switcherblur_blurWallpaper = ([settings objectForKey:@"wallpaper"] && [[settings objectForKey:@"wallpaper"] boolValue]) + 1;
if(previousWallpaper != switcherblur_blurWallpaper)
[(SpringBoard *)[%c(SpringBoard) sharedApplication] _relaunchSpringBoardNow];
}
}

/**************************** Hooks ****************************/
/**************************** Background Blur ****************************/

%hook SBAppSliderWindow

-(id)initWithFrame:(CGRect)frame{
if(switcherblur_blurWallpaper == 0){
NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"/Library/Preferences/com.insanj.switcherblur.plist"]];
switcherblur_blurWallpaper = ([settings objectForKey:@"wallpaper"] && [[settings objectForKey:@"wallpaper"] boolValue]) + 1;
}

SBAppSliderWindow *window = %orig();

if(switcherblur_blurWallpaper == 2){
NSLog(@"[SwitcherBlur] Blurrig app switcher background : %@", self);
CKBlurView *blurView = [[CKBlurView alloc] initWithFrame:frame];
[window addSubview:blurView];
}

return window;
}

%end

/**************************** Snapshot Blur ****************************/

%hook SBAppSliderSnapshotView

Expand Down
4 changes: 2 additions & 2 deletions control
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Package: com.insanj.switcherblur
Name: SwitcherBlur
Pre-Depends: firmware (>= 7.0)
Depends: mobilesubstrate, applist
Version: 1.1.1
Version: 1.2
Architecture: iphoneos-arm
Description: Blur iOS 7 switcher snapshots.
Description: Blur the iOS 7 switcher.
Maintainer: Julian Weiss <me@insanj.com>
Author: Julian (insanj) Weiss
Section: Tweaks
Expand Down
19 changes: 12 additions & 7 deletions switcherblurprefs/Resources/SwitcherBlurPrefs.plist
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,23 @@
<key>label</key> <string>Inactive Blur</string>
</dict>

<dict>
<key>cell</key> <string>PSGroupCell</string>
<key>footerText</key> <string>Blurs your wallpaper behind the switcher. Will respring when toggling.</string>
</dict>

<dict>
<key>cell</key> <string>PSGroupCell</string>
<key>label</key> <string>Contact</string>
<key>footerText</key> <string>Source available online. Special thanks to Elijah Frederickson for code contributions.</string>
<key>PostNotification</key> <string>com.insanj.switcherblur/reloadSettings</string>
<key>cell</key> <string>PSSwitchCell</string>
<key>default</key> <false/>
<key>defaults</key> <string>com.insanj.switcherblur</string>
<key>key</key> <string>wallpaper</string>
<key>label</key> <string>Wallpaper Blur</string>
</dict>

<dict>
<key>cell</key> <string>PSButtonCell</string>
<key>label</key> <string>Support &amp; Feedback</string>
<key>icon</key> <string>mail.png</string>
<key>action</key> <string>mail</string>
<key>cell</key> <string>PSGroupCell</string>
<key>footerText</key> <string>Source available online. Special thanks to Elijah Frederickson for code contributions.</string>
</dict>

<dict>
Expand Down
Binary file removed switcherblurprefs/Resources/mail@2x.png
Binary file not shown.
17 changes: 0 additions & 17 deletions switcherblurprefs/SwitcherBlurPrefs.xm
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,6 @@
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://mobile.twitter.com/insanj"]];
}

-(void)mail{
NSURL *helpurl = [NSURL URLWithString:@"mailto:insanjmail%40gmail.com?subject=SwitcherBlur%20(1.1.1)%20Support"];
if([MFMailComposeViewController canSendMail]){
MFMailComposeViewController *composeViewController = [[MFMailComposeViewController alloc] initWithNibName:nil bundle:nil];
[composeViewController setMailComposeDelegate:self];
[composeViewController setToRecipients:@[@"insanjmail@gmail.com"]];
[composeViewController setSubject:@"SwitcherBlur (1.1.1) Support"];
[self presentViewController:composeViewController animated:YES completion:nil];
}//end if

else if ([[UIApplication sharedApplication] canOpenURL:helpurl])
[[UIApplication sharedApplication] openURL:helpurl];

else
[[[UIAlertView alloc] initWithTitle:@"Contact Developer" message:@"Shoot an email to insanjmail@gmail.com, or talk to me on twitter (@insanj) if you have any problems, requests, or ideas!" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil] show];
}

-(void)shareTapped:(UIBarButtonItem *)sender{
NSString *text = @"An iOS 7 switcher with style, utility, and a bit of blur. Get SwitcherBlur from @insanj today!";
NSURL *url = [NSURL URLWithString:@"https://github.com/insanj/SwitcherBlur/"];
Expand Down

0 comments on commit 7ff452c

Please sign in to comment.