├── theos ├── README.md ├── CSwitcher.plist ├── .gitignore ├── control ├── Makefile ├── headers.h └── Tweak.xm /theos: -------------------------------------------------------------------------------- 1 | /opt/theos -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WIP and a complete rewrite of the original. 2 | -------------------------------------------------------------------------------- /CSwitcher.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.springboard" ); }; } 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.stamp 3 | .theos 4 | .DS_Store 5 | theos 6 | _ 7 | obj 8 | debs 9 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.twodayslate.cswitcher 2 | Name: CSwitcher 3 | Depends: mobilesubstrate 4 | Version: 0.0.1 5 | Architecture: iphoneos-arm 6 | Description: An awesome MobileSubstrate tweak! 7 | Maintainer: twodayslate 8 | Author: twodayslate 9 | Section: Tweaks 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | THEOS_DEVICE_IP = 127.0.0.1 2 | THEOS_DEVICE_PORT = 2222 3 | 4 | THEOS_PACKAGE_DIR_NAME = debs 5 | TARGET := iphone:clang 6 | ARCHS := armv7 arm64 7 | 8 | include theos/makefiles/common.mk 9 | 10 | TWEAK_NAME = CSwitcher 11 | CSwitcher_FILES = Tweak.xm 12 | CSwitcher_FRAMEWORKS = UIKit QuartzCore CoreGraphics 13 | 14 | include $(THEOS_MAKE_PATH)/tweak.mk 15 | 16 | after-install:: 17 | install.exec "killall -9 SpringBoard" 18 | -------------------------------------------------------------------------------- /headers.h: -------------------------------------------------------------------------------- 1 | @interface CSwitcherFlowLayout : UICollectionViewFlowLayout 2 | @end 3 | 4 | @interface SBControlCenterSectionViewController : UIViewController 5 | @end 6 | 7 | @interface CSwitcherController : UIViewController 8 | @property (nonatomic, strong) UICollectionView *collectionView; 9 | @property (nonatomic, strong) NSMutableArray *recentApplications; 10 | +(CSwitcherController *)sharedInstance; 11 | @end 12 | 13 | @interface SBAppSwitcherModel : NSObject 14 | +(SBAppSwitcherModel *) sharedInstance; 15 | -(id)snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary; 16 | @end 17 | 18 | @interface SBAppSwitcherController 19 | +(SBAppSwitcherController *)sharedController; 20 | @end 21 | 22 | @interface SBAppSwitcherSnapshotView : UIView 23 | -(id)initWithDisplayItem:(id)arg1 application:(id)arg2 orientation:(long long)arg3 async:(BOOL)arg4 withQueue:(id)arg5 statusBarCache:(id)arg6 ; 24 | @end 25 | 26 | @interface SBApplicationController : NSObject 27 | +(SBApplicationController *)sharedInstanceIfExists; 28 | -(id)applicationWithBundleIdentifier:(id)arg1 ; 29 | @end 30 | 31 | @interface SBApplication : NSObject 32 | @end 33 | 34 | @interface SBIcon : NSObject 35 | @end 36 | 37 | @interface SBApplicationIcon : SBIcon 38 | -(id)initWithApplication:(id)arg1 ; 39 | @end 40 | 41 | @interface SBIconView : UIView 42 | @property (assign,nonatomic) id delegate; 43 | @property (nonatomic,retain) SBIcon * icon; 44 | -(id)initWithDefaultSize; 45 | @end 46 | 47 | @interface SpringBoard 48 | -(long long)activeInterfaceOrientation; 49 | @end 50 | 51 | @interface SBControlCenterContentView 52 | -(void)_addSectionController:(id)arg1 ; 53 | @end 54 | 55 | 56 | @interface CSwitcherCell : UICollectionViewCell 57 | @property (nonatomic, strong) SBIconView *iconView; 58 | @property (nonatomic, strong) SBAppSwitcherSnapshotView *snapshot; 59 | @end 60 | 61 | -------------------------------------------------------------------------------- /Tweak.xm: -------------------------------------------------------------------------------- 1 | #import "headers.h" 2 | 3 | %hook SBAppSwitcherModel 4 | -(void)appsRemoved:(id)arg1 added:(id)arg2 { 5 | %orig; 6 | [CSwitcherController sharedInstance].recentApplications = [[[self snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary] mutableCopy] retain]; 7 | } 8 | 9 | -(void)remove:(id)arg1 { 10 | %orig; 11 | [CSwitcherController sharedInstance].recentApplications = [[[self snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary] mutableCopy] retain]; 12 | } 13 | 14 | -(void)removeDisplayItem:(id)arg1 { 15 | %orig; 16 | [CSwitcherController sharedInstance].recentApplications = [[[self snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary] mutableCopy] retain]; 17 | } 18 | 19 | -(void)addToFront:(id)arg1 { 20 | %orig; 21 | [CSwitcherController sharedInstance].recentApplications = [[[self snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary] mutableCopy] retain]; 22 | } 23 | %end 24 | 25 | 26 | 27 | 28 | @implementation CSwitcherCell 29 | -(id)initWithFrame:(CGRect)frame { 30 | self = [super initWithFrame:frame]; 31 | if(self) { 32 | // setup view with icon and snapshot 33 | } 34 | return self; 35 | } 36 | @end 37 | 38 | @implementation CSwitcherController 39 | 40 | + (id)sharedInstance{ 41 | static dispatch_once_t onceToken; 42 | static CSwitcherController *sharedInstance = nil; 43 | dispatch_once(&onceToken, ^{ 44 | sharedInstance = [CSwitcherController new]; 45 | }); 46 | return sharedInstance; 47 | } 48 | 49 | - (void)viewDidLoad { 50 | [super viewDidLoad]; 51 | self.recentApplications = [[[(SBAppSwitcherModel *)[%c(SBAppSwitcherModel) sharedInstance] snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary] mutableCopy] retain]; 52 | [self.collectionView registerClass:[CSwitcherCell class] forCellWithReuseIdentifier:@"CellView"]; 53 | UICollectionViewFlowLayout *flowLayout = [[%c(CSwitcherFlowLayout) alloc] init]; 54 | [flowLayout setItemSize:CGSizeMake(200, 200)]; 55 | [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; 56 | [self.collectionView setCollectionViewLayout:flowLayout]; 57 | } 58 | 59 | -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { 60 | return 1; 61 | } 62 | 63 | -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 64 | return [self.recentApplications count]; 65 | } 66 | 67 | -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 68 | CSwitcherCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CellView" forIndexPath:indexPath]; 69 | 70 | NSString *identifier = [self.recentApplications objectAtIndex:indexPath.section]; 71 | 72 | SBApplicationController *appController = [%c(SBApplicationController) sharedInstanceIfExists]; 73 | SBApplication *app = [appController applicationWithBundleIdentifier:identifier]; 74 | SBApplicationIcon *appIcon = [[%c(SBApplicationIcon) alloc] initWithApplication:app]; 75 | SBIconView *iconView = [[%c(SBIconView) alloc] initWithDefaultSize]; 76 | iconView.icon = appIcon; 77 | iconView.delegate = [%c(SBIconController) sharedInstance]; 78 | cell.iconView = iconView; 79 | 80 | SBAppSwitcherSnapshotView *snapshot = [[%c(SBAppSwitcherSnapshotView) alloc] initWithDisplayItem:nil application:app orientation:[(SpringBoard *)[objc_getClass("SpringBoard") sharedApplication] activeInterfaceOrientation] async:NO withQueue:MSHookIvar([%c(SBAppSwitcherController) sharedController], "_snapshotQueue") statusBarCache:nil]; 81 | cell.snapshot = snapshot; 82 | 83 | return cell; 84 | } 85 | 86 | @end 87 | 88 | 89 | %hook SBControlCenterContentView 90 | -(void)layoutSubviews { 91 | [self _addSectionController:[CSwitcherController sharedInstance]]; 92 | %orig; 93 | } 94 | -(void)_addSectionController:(id)arg1 { 95 | %log; 96 | %orig; 97 | } 98 | %end 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | --------------------------------------------------------------------------------