forked from grp/tweaks
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
TWEAK_NAME = fis | ||
fis_OBJCC_FILES = Tweak.mm | ||
fis_FRAMEWORKS = UIKit QuartzCore CoreGraphics | ||
|
||
include framework/makefiles/common.mk | ||
include framework/makefiles/tweak.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
|
||
#import <SpringBoard/SpringBoard.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
#define idForKeyWithDefault(dict, key, default) ([(dict) objectForKey:(key)]?:(default)) | ||
#define floatForKeyWithDefault(dict, key, default) ({ id _result = [(dict) objectForKey:(key)]; (_result)?[_result floatValue]:(default); }) | ||
#define NSIntegerForKeyWithDefault(dict, key, default) (NSInteger)({ id _result = [(dict) objectForKey:(key)]; (_result)?[_result integerValue]:(default); }) | ||
#define BOOLForKeyWithDefault(dict, key, default) (BOOL)({ id _result = [(dict) objectForKey:(key)]; (_result)?[_result boolValue]:(default); }) | ||
|
||
#define PreferencesFilePath [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Preferences/com.chpwn.five-icon-switcher.plist"] | ||
#define PreferencesChangedNotification "com.chpwn.five-icon-switcher.prefs" | ||
|
||
#define GetPreference(name, type) type ## ForKeyWithDefault(prefsDict, @#name, (name)) | ||
|
||
@interface SBAppSwitcherBarView : UIView { } | ||
+ (unsigned)iconsPerPage:(int)page; | ||
- (CGPoint)_firstPageOffset; | ||
- (CGPoint)_firstPageOffset:(CGSize)size; | ||
- (CGRect)_frameForIndex:(unsigned)index withSize:(CGSize)size; | ||
- (CGRect)_iconFrameForIndex:(unsigned)index withSize:(CGSize)size; | ||
@end | ||
|
||
static NSDictionary *prefsDict = nil; | ||
|
||
static void preferenceChangedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { | ||
[prefsDict release]; | ||
prefsDict = [[NSDictionary alloc] initWithContentsOfFile:PreferencesFilePath]; | ||
} | ||
|
||
CGRect make_frame(SBAppSwitcherBarView *self, int index, CGSize size, CGRect orig) { | ||
CGRect r = orig; | ||
|
||
int page = index / [[self class] iconsPerPage:0]; | ||
CGFloat gap = ([self frame].size.width - (r.size.width * [[self class] iconsPerPage:0])) / ([[self class] iconsPerPage:0] + 1); | ||
r.origin.x = gap; | ||
|
||
if ([self respondsToSelector:@selector(_firstPageOffset)]) r.origin.x += [self _firstPageOffset].x; | ||
else r.origin.x += [self _firstPageOffset:[self frame].size].x; | ||
r.origin.x += (gap + size.width) * index; | ||
r.origin.x += (gap * page); | ||
r.origin.x = floorf(r.origin.x); | ||
|
||
return r; | ||
} | ||
|
||
%hook SBAppSwitcherBarView | ||
|
||
+ (unsigned int)iconsPerPage:(int)page { | ||
return [[prefsDict objectForKey:@"FISIconCount"] intValue] ?: 5; | ||
} | ||
|
||
// 4.0 and 4.1 | ||
- (CGRect)_frameForIndex:(unsigned)index withSize:(CGSize)size { | ||
return make_frame(self, index, size, %orig); | ||
} | ||
|
||
- (CGPoint)_firstPageOffset:(CGSize)offset { | ||
%log; | ||
return %orig; | ||
} | ||
|
||
// 4.2 | ||
- (CGRect)_iconFrameForIndex:(unsigned)index withSize:(CGSize)size { | ||
return make_frame(self, index, size, %orig); | ||
} | ||
|
||
|
||
%end | ||
|
||
__attribute__((constructor)) static void fis_init() { | ||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | ||
|
||
// SpringBoard only! | ||
if (![[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"]) | ||
return; | ||
|
||
prefsDict = [[NSDictionary alloc] initWithContentsOfFile:PreferencesFilePath]; | ||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, preferenceChangedCallback, CFSTR(PreferencesChangedNotification), NULL, CFNotificationSuspensionBehaviorCoalesce); | ||
|
||
[pool release]; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Package: com.chpwn.five-icon-switcher | ||
Name: Five Icon Switcher | ||
Pre-Depends: firmware (>= 4.0) | ||
Depends: mobilesubstrate | ||
Version: 1.1 | ||
Architecture: iphoneos-arm | ||
Description: Five icons in the multitasking switcher! | ||
Maintainer: chpwn | ||
Author: chpwn | ||
Section: Tweaks |
3 changes: 3 additions & 0 deletions
3
five-icon-switcher/layout/Library/MobileSubstrate/DynamicLibraries/fis.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Filter = { | ||
Bundles = (com.apple.springboard); | ||
}; |
114 changes: 114 additions & 0 deletions
114
five-icon-switcher/layout/Library/PreferenceLoader/Preferences/five-icon-switcher.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>title</key> | ||
<string>Five Icon Switcher</string> | ||
<key>entry</key> | ||
<dict> | ||
<key>cell</key> | ||
<string>PSLinkCell</string> | ||
<key>icon</key> | ||
<string>five-icon-switcher.png</string> | ||
<key>label</key> | ||
<string>Five Icon Switcher</string> | ||
</dict> | ||
<key>items</key> | ||
<array> | ||
<dict> | ||
<key>cell</key> | ||
<string>PSGroupCell</string> | ||
<key>label</key> | ||
<string>Five Icon Switcher</string> | ||
</dict> | ||
<dict> | ||
<key>cell</key> | ||
<string>PSLinkListCell</string> | ||
<key>default</key> | ||
<integer>5</integer> | ||
<key>detail</key> | ||
<string>PSListItemsController</string> | ||
<key>key</key> | ||
<string>FISIconCount</string> | ||
<key>label</key> | ||
<string>Icons per Page</string> | ||
<key>validTitles</key> | ||
<array> | ||
<string>One</string> | ||
<string>Two</string> | ||
<string>Three</string> | ||
<string>Four</string> | ||
<string>Five</string> | ||
<string>Six</string> | ||
<string>Seven</string> | ||
<string>Eight</string> | ||
<string>Nine</string> | ||
<string>Ten</string> | ||
</array> | ||
<key>validValues</key> | ||
<array> | ||
<integer>1</integer> | ||
<integer>2</integer> | ||
<integer>3</integer> | ||
<integer>4</integer> | ||
<integer>5</integer> | ||
<integer>6</integer> | ||
<integer>7</integer> | ||
<integer>8</integer> | ||
<integer>9</integer> | ||
<integer>10</integer> | ||
</array> | ||
<key>defaults</key> | ||
<string>com.chpwn.five-icon-switcher</string> | ||
<key>PostNotification</key> | ||
<string>com.chpwn.five-icon-switcher.prefs</string> | ||
</dict> | ||
|
||
<!-- Begin static text. --> | ||
<dict> | ||
<key>cell</key> | ||
<string>PSGroupCell</string> | ||
<key>footerText</key> | ||
<string>Five Icon Switcher © 2010 Grant Paul. | ||
Licensed under the BSD license at http://github.com/chpwn/five-icon-switcher. | ||
All contributions are welcome.</string> | ||
</dict> | ||
<dict> | ||
<key>cell</key> | ||
<string>PSGroupCell</string> | ||
<key>isStaticText</key> | ||
<string>true</string> | ||
<key>requiredCapabilities</key> | ||
<array> | ||
<dict> | ||
<key>wildcat</key> | ||
<false/> | ||
<key>voip</key> | ||
<false/> | ||
</dict> | ||
</array> | ||
</dict> | ||
<dict> | ||
<key>cell</key> | ||
<string>PSTitleValueCell</string> | ||
<key>label</key> | ||
<string>Five Icon Switcher © 2010 Grant Paul. | ||
Licensed under the BSD license at http://github.com/chpwn/five-icon-switcher. | ||
All contributions are welcome.</string> | ||
<key>requiredCapabilities</key> | ||
<array> | ||
<dict> | ||
<key>wildcat</key> | ||
<false/> | ||
<key>voip</key> | ||
<false/> | ||
</dict> | ||
</array> | ||
</dict> | ||
<!-- End static text. --> | ||
|
||
</array> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+8.29 KB
...con-switcher/layout/Library/PreferenceLoader/Preferences/five-icon-switcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.