Skip to content

Commit

Permalink
[+][u][f] Integrated preferences, added logo, made some fixes [Big Co…
Browse files Browse the repository at this point in the history
…mmit]
  • Loading branch information
MatoiDev committed May 9, 2024
1 parent 06b7415 commit d8f5059
Show file tree
Hide file tree
Showing 168 changed files with 13,069 additions and 72 deletions.
8 changes: 7 additions & 1 deletion Extensions/Extensions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
#import <rootless.h>
#include <RemoteLog.h>

#define WITCHER_PLIST_SETTINGS ROOT_PATH_NS(@"/var/mobile/Library/Preferences/dr.erast.witcherprefs.plist")
#define WITCHER_PREFERENCES_BUNDLE_PATH ROOT_PATH_NS(@"/Library/PreferenceBundles/WitcherPreferences.bundle")

@interface UIImage (Icon)
/*
Expand Down Expand Up @@ -31,4 +37,4 @@

@interface UIView (parentViewController)
-(UIViewController *)parentViewController;
@end
@end
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
### iOS 16+ is NOT supported yet !


https://github.com/MatoiDev/Witcher/assets/78802792/9b2195ae-b183-4e2c-b4de-7560d7d187ca

### Witcher - Magical iOS App Switcher
###### Work in progress...

#### TODO LIST: (Might be replenished...)
- [X] Make Logo
- [X] Preferences integration
- [ ] Add options to preferences
- [ ] Add support to iOS 16+
- [ ] Add support to hardware-button devices
- [ ] Add xmark button functional


### For testers
If you find a bug, error, or just something not working, then please let me know [here](https://github.com/MatoiDev/Witcher/issues).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ NS_ASSUME_NONNULL_BEGIN
UIImage* applicationIconImage;
}

@property(nonatomic, retain)UIImageView *snapshotImageView;
@property(nonatomic, retain)UIImageView *applicationIconImageView;
@property(nonatomic, retain)UIView *dropShadowView;
@property(nonatomic, retain)UIView *bottomViewContainer;
@property(nonatomic, retain)UILabel *applicationNameLabel;
@property(nonatomic, retain)UILabel *applicationBundleIDLabel;
@property(nonatomic, nullable, retain)WitcherApplicationLayoutStruct *layoutStruct;
@property(nonatomic, strong)UIImageView *snapshotImageView;
@property(nonatomic, strong)UIImageView *applicationIconImageView;
@property(nonatomic, strong)UIView *dropShadowView;
@property(nonatomic, strong)UIView *bottomViewContainer;
@property(nonatomic, strong)UILabel *applicationNameLabel;
@property(nonatomic, strong)UILabel *applicationBundleIDLabel;
@property(nonatomic, nullable, strong)WitcherApplicationLayoutStruct *layoutStruct;

-(instancetype)initWithLayoutStruct:(WitcherApplicationLayoutStruct *)layoutStruct_t;
-(void)updateWithLayoutStruct:(WitcherApplicationLayoutStruct *_Nullable)layoutStruct_t;
Expand Down
4 changes: 2 additions & 2 deletions UI/Router/Cell/RouterReusableCellView.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
_Bool isStackStyle;
}

@property(nonatomic, retain)UIImageView *iconImageView;
@property(nonatomic, retain)WitcherApplicationLayoutStruct *layoutStruct;
@property(nonatomic, strong)UIImageView *iconImageView;
@property(nonatomic, strong)WitcherApplicationLayoutStruct *layoutStruct;
@property(nonatomic, nullable, strong)CAShapeLayer *borderLayer;

@property(nonatomic, assign)NSUInteger applicationsCounter;
Expand Down
3 changes: 3 additions & 0 deletions UI/Router/RouterView.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ typedef void(^LayoutUpdateBlock)(WitcherApplicationLayoutStruct *_Nullable);

@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 11.0, 10.2, 10.1.1, 9.3.3, 9.0, 8.0, 7.0, 6.0
@interface AXServer : NSObject
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 11.0, 10.2, 10.1.1, 9.3.3, 9.0, 8.0, 7.0, 6.0
@interface AXSpringBoardServer : AXServer
+(id)server;
-(void)revealSpotlight;
Expand All @@ -52,6 +54,7 @@ typedef void(^LayoutUpdateBlock)(WitcherApplicationLayoutStruct *_Nullable);
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0
@interface SpringBoard (Launcher)
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2;
@end
Expand Down
33 changes: 31 additions & 2 deletions Witcher.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
#import <QuartzCore/QuartzCore.h>
#import <SpringBoard/SpringBoard.h>
#include <CoreFoundation/CoreFoundation.h>

#import <notify.h>

#import "Extensions/Extensions.h"

#import "UI/ApplicationLayoutStruct/WitcherApplicationLayoutStruct.h"
#import "UI/Router/RouterView.h"
#import "UI/ApplicationLayoutContainer/WitcherApplicationLayoutContainer.h"

#include <CoreFoundation/CoreFoundation.h>

@interface SBDeckSwitcherViewController: UIViewController
/*
HLOS - iOS versions that support these headers, according to https://developer.limneos.net/.]
*/


// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0
@interface SBDeckSwitcherViewController: UIViewController
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1
@interface SBFluidSwitcherGestureManager
-(void)fluidSwitcherGestureTransaction:(id)arg1 didBeginGesture:(id)arg2;
-(void)fluidSwitcherGestureTransaction:(id)arg1 didUpdateGesture:(id)arg2;
-(void)fluidSwitcherGestureTransaction:(id)arg1 didEndGesture:(id)arg2;
@end

// HLOS: 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0
// Doesn't support iOS 16.* 17.* etc
@interface SBMainSwitcherViewController : UIViewController
+(id)sharedInstance;
-(id)recentAppLayouts;
Expand All @@ -27,34 +38,42 @@
-(void)_deleteAppLayout:(id)arg1 forReason:(long long)arg2;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0, 8.0
@interface SBDisplayItem: NSObject
-(id)bundleIdentifier;
@end

// HLOS: 17.1, 16.3, 15.2.1
// Doesn't support ios 14.* && ios 13.*
@interface SBFluidSwitcherSpaceTitleItem
-(NSString*)subtitleText;
-(NSString*)bundleIdentifier;
-(SBDisplayItem*)displayItem;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1
@interface SBAppLayout: NSObject
@property (copy,readonly) NSString * description;
-(id)allItems;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0
@interface SBSwitcherSnapshotImageView: UIView
-(id)image;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0
@interface SBSwitcherWallpaperPageContentView: UIView
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1
@interface SBAppSwitcherReusableSnapshotView: SBSwitcherWallpaperPageContentView
-(NSString *)description;
-(NSArray<SBSwitcherSnapshotImageView*>*)_allImageViews;
-(id)appLayout; // -> SBAppLayout
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1
@interface SBReusableSnapshotItemContainer : UIView
@property (copy,readonly) NSString * description;
@property (copy,readonly) NSString * debugDescription;
Expand All @@ -66,41 +85,49 @@
-(id)_snapshotView; // -> SBAppSwitcherReusableSnapshotView
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3
@interface SBFluidSwitcherContentView: UIView
-(void)setPassesTouchesThrough:(BOOL)arg1;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1
@interface SBFluidSwitcherViewController : UIViewController
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0, 8.0
@interface SBAppSwitcherSettings
@property (assign) double spacingBetweenTrailingEdgeAndLabels;
@property (assign) double centerPoint;
@property (assign) long long switcherStyle;
-(long long)switcherStyle;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1
@interface SBFTouchPassThroughView : UIView
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0, 8.0, 7.0, 5.0, 4.0, 3.0
@interface SBApplication
-(UIImage *)imageForSnapshot:(id)arg1 interfaceOrientation:(long long)arg2;
-(NSString *)bundleIdentifier;
-(NSString *)displayName;
-(void)_didSuspend;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0
@interface SpringBoard (SpotLight)
-(void)_revealSpotlight;
-(void)quitTopApplication:(id)arg1;
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2 ;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1
@interface SBFluidSwitcherGesture : NSObject
-(NSString *)description;
-(id)gestureEvent;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3
@interface SBGestureSwitcherModifierEvent
/*
@param phase
Expand All @@ -114,11 +141,13 @@
-(double)peakSpeed;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1
@interface LSApplicationWorkspace : NSObject
+(id)defaultWorkspace;
-(BOOL)openApplicationWithBundleID:(NSString *)bundleID;
@end

// HLOS: 17.1, 16.3, 15.2.1, 14.4, 13.1.3, 12.1, 11.1.2, 11.0.1, 10.2, 10.1.1, 9.3.3, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0
@interface SBMediaController : NSObject
@property (nonatomic, weak,readonly) SBApplication * nowPlayingApplication;
+(id)sharedInstance;
Expand Down
45 changes: 29 additions & 16 deletions Witcher.x
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#import "Witcher.h"
#include <RemoteLog.h>

/* TODO
- (Not implemented) Kill aplications with quick action button: https://www.reddit.com/r/jailbreakdevelopers/comments/d6wbla/remove_app_from_app_switcher/
Expand Down Expand Up @@ -270,7 +269,7 @@ _Bool routerViewIsPresented = NO;
WitcherApplicationLayoutStruct *applicationStruct = [self performSelector:@selector(getPackedLayoutStructForApplication:) withObject:frontApp];

RLog(@"New layoutStruct! %@", applicationStruct);

if (!isEnabled) { return; }
[self performSelector:@selector(updateRouterWithFrontMostApplications:) withObject:frontApp];

handleRouterGestures = NO;
Expand Down Expand Up @@ -414,17 +413,23 @@ _Bool routerViewIsPresented = NO;
-(void)fluidSwitcherGestureTransaction:(id)arg1 didBeginGesture:(id)arg2 {
%orig;

[[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateAppLayouts" object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ShowWitcherView" object:self];

if (!isEnabled) { return; }

if (router && [router alpha] > 0 && arg2) {
CGPoint gesturePosition = [[arg2 gestureEvent] locationInContainerView];
unsigned long long gesturePhase = [[arg2 gestureEvent] phase];
[router handleGestureWithPosition:gesturePosition phase:gesturePhase interactionEnabled:handleRouterGestures];
}

[[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateAppLayouts" object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ShowWitcherView" object:self];

}

-(void)fluidSwitcherGestureTransaction:(id)arg1 didUpdateGesture:(id)arg2 {

if (!isEnabled) { %orig; return; }
double speed = [[arg2 gestureEvent] peakSpeed];

if ((speed < 2000 && router && [router alpha] > 0 && arg2) || routerViewIsPresented) {
Expand All @@ -442,7 +447,7 @@ _Bool routerViewIsPresented = NO;

-(void)fluidSwitcherGestureTransaction:(id)arg1 didEndGesture:(id)arg2 {
%orig;

if (!isEnabled) { return; }
if (router && [router alpha] > 0 && arg2) {
CGPoint gesturePosition = [[arg2 gestureEvent] locationInContainerView];
unsigned long long gesturePhase = [[arg2 gestureEvent] phase];
Expand All @@ -457,24 +462,32 @@ _Bool routerViewIsPresented = NO;

%hook SBFluidSwitcherSpaceTitleItem
-(NSString*)subtitleText {
return [[self displayItem] bundleIdentifier];
return (isEnabled ? [[self displayItem] bundleIdentifier] : %orig);
}
%end


void updateSettings(){
static void updateSettings() {
NSDictionary *prefs = [NSDictionary dictionaryWithContentsOfFile:WITCHER_PLIST_SETTINGS];
isEnabled = prefs[@"isEnabled"] ? [prefs[@"isEnabled"] boolValue] : YES;

[prefs registerDefaults:@{
@"isEnabled": @TRUE,
}];

isEnabled = [[prefs objectForKey:@"isEnabled"] boolValue];
RLog(@"Witcher %@", isEnabled ? @"is enabled now" : @"isn't enabled now");
}


static __attribute__((constructor)) void init() {
prefs = [[NSUserDefaults alloc] initWithSuiteName:@"dr.erast.witcherprefs"];


// CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL,
// (CFNotificationCallback)loadPrefs, CFSTR("dr.erast.witcherprefs/init"), NULL,
// CFNotificationSuspensionBehaviorDeliverImmediately
// );

updateSettings();
updateSettings();

if(isEnabled) { %init; }
}
int _;
notify_register_dispatch("dr.erast.witcherprefs/init", &_, dispatch_get_main_queue(), ^(int _) {
updateSettings();
});

}
18 changes: 18 additions & 0 deletions WitcherPreferences/3rdPartyLibs/Lottie/CALayer+Compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Created by Oleksii Pavlovskyi on 2/2/17.
// Copyright (c) 2017 Airbnb. All rights reserved.
//

#include <TargetConditionals.h>

#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>

@interface CALayer (Compat)

@property (nonatomic, assign) BOOL allowsEdgeAntialiasing;

@end

#endif
18 changes: 18 additions & 0 deletions WitcherPreferences/3rdPartyLibs/Lottie/CALayer+Compat.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Created by Oleksii Pavlovskyi on 2/2/17.
// Copyright (c) 2017 Airbnb. All rights reserved.
//

#include <TargetConditionals.h>

#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
#import "CALayer+Compat.h"

@implementation CALayer (Compat)

- (BOOL)allowsEdgeAntialiasing { return NO; }
- (void)setAllowsEdgeAntialiasing:(BOOL)allowsEdgeAntialiasing { }

@end

#endif
Loading

0 comments on commit d8f5059

Please sign in to comment.