From db0211fe9dfc3d120816e6202bbb64b6bc82f616 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 26 Nov 2016 23:28:41 -0600 Subject: [PATCH 01/59] Why did i think this was a good idea? --- Makefile | 4 +-- headers.h | 100 ++++++++++++++++++++++++++---------------------------- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index c1b30ff..f8b086f 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -I CFLAGS += -fobjc-arc LDFLAGS += -Wl,-segalign,4000 THEOS_PACKAGE_DIR_NAME = debs -TARGET = :8.0 +TARGET = iphone:clang:9.3:9.3 include $(THEOS)/makefiles/common.mk @@ -23,7 +23,7 @@ ReachApp_FILES = Tweak.xm $(wildcard *.xm) $(wildcard *.mm) $(wildcard *.m) \ $(wildcard DRM/*.xm) $(wildcard DRM/*.mm) $(wildcard DRM/*.m) \ $(wildcard Theming/*.xm) $(wildcard Theming/*.mm) $(wildcard Theming/*.m) \ $(wildcard Debugging/*.xm) $(wildcard Debugging/*.mm) $(wildcard Debugging/*.m) - + ReachApp_FRAMEWORKS = UIKit QuartzCore CoreGraphics CoreImage ReachApp_PRIVATE_FRAMEWORKS = GraphicsServices BackBoardServices AppSupport IOKit ReachApp_LIBRARIES = applist diff --git a/headers.h b/headers.h index 826b1ce..2935991 100644 --- a/headers.h +++ b/headers.h @@ -3,7 +3,6 @@ #import #import #import -#import #import #import #import @@ -19,6 +18,7 @@ #include #import #import +#import #define RA_BASE_PATH @"/Library/Multiplexer" @@ -113,6 +113,52 @@ extern "C" void BKSHIDServicesCancelTouchesOnMainDisplay(); - (void)_lockOrientation; @end +@interface SBIconImageView : UIView { + UIImageView *_overlayView; + //SBIconProgressView *_progressView; + _Bool _isPaused; + UIImage *_cachedSquareContentsImage; + _Bool _showsSquareCorners; + SBIcon *_icon; + double _brightness; + double _overlayAlpha; +} + ++ (id)dequeueRecycledIconImageViewOfClass:(Class)arg1; ++ (void)recycleIconImageView:(id)arg1; ++ (double)cornerRadius; +@property(nonatomic) _Bool showsSquareCorners; // @synthesize showsSquareCorners=_showsSquareCorners; +@property(nonatomic) double overlayAlpha; // @synthesize overlayAlpha=_overlayAlpha; +@property(nonatomic) double brightness; // @synthesize brightness=_brightness; +@property(retain, nonatomic) SBIcon *icon; // @synthesize icon=_icon; +- (_Bool)_shouldAnimatePropertyWithKey:(id)arg1; +- (void)iconImageDidUpdate:(id)arg1; +- (struct CGRect)visibleBounds; +- (struct CGSize)sizeThatFits:(struct CGSize)arg1; +- (id)squareDarkeningOverlayImage; +- (id)darkeningOverlayImage; +- (id)squareContentsImage; +- (UIImage*)contentsImage; +- (void)_clearCachedImages; +- (id)_generateSquareContentsImage; +- (void)_updateProgressMask; +- (void)_updateOverlayImage; +- (id)_currentOverlayImage; +- (void)updateImageAnimated:(_Bool)arg1; +- (id)snapshot; +- (void)prepareForReuse; +- (void)layoutSubviews; +- (void)setPaused:(_Bool)arg1; +- (void)setProgressAlpha:(double)arg1; +- (void)_clearProgressView; +- (void)progressViewCanBeRemoved:(id)arg1; +- (void)setProgressState:(long long)arg1 paused:(_Bool)arg2 percent:(double)arg3 animated:(_Bool)arg4; +- (void)_updateOverlayAlpha; +- (void)setIcon:(id)arg1 animated:(_Bool)arg2; +- (void)dealloc; +- (id)initWithFrame:(struct CGRect)arg1; +@end + @interface SBOrientationLockManager : NSObject { NSMutableSet *_lockOverrideReasons; @@ -916,7 +962,7 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (void)_sendDidLaunchNotification:(_Bool)arg1; - (void)notifyResumeActiveForReason:(long long)arg1; -@property(readonly, nonatomic) int pid; +@property(readwrite, nonatomic) int pid; @end @interface SBApplicationController : NSObject @@ -1017,7 +1063,7 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (unsigned int)contextID; @end -@interface UIWindow () +@interface UIWindow () +(instancetype) keyWindow; -(id) firstResponder; + (void)setAllWindowsKeepContextInBackground:(BOOL)arg1; @@ -1389,53 +1435,6 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (id)initWithDefaultSize; @end -@interface SBIconImageView () -{ - UIImageView *_overlayView; - //SBIconProgressView *_progressView; - _Bool _isPaused; - UIImage *_cachedSquareContentsImage; - _Bool _showsSquareCorners; - SBIcon *_icon; - double _brightness; - double _overlayAlpha; -} - -+ (id)dequeueRecycledIconImageViewOfClass:(Class)arg1; -+ (void)recycleIconImageView:(id)arg1; -+ (double)cornerRadius; -@property(nonatomic) _Bool showsSquareCorners; // @synthesize showsSquareCorners=_showsSquareCorners; -@property(nonatomic) double overlayAlpha; // @synthesize overlayAlpha=_overlayAlpha; -@property(nonatomic) double brightness; // @synthesize brightness=_brightness; -@property(retain, nonatomic) SBIcon *icon; // @synthesize icon=_icon; -- (_Bool)_shouldAnimatePropertyWithKey:(id)arg1; -- (void)iconImageDidUpdate:(id)arg1; -- (struct CGRect)visibleBounds; -- (struct CGSize)sizeThatFits:(struct CGSize)arg1; -- (id)squareDarkeningOverlayImage; -- (id)darkeningOverlayImage; -- (id)squareContentsImage; -- (UIImage*)contentsImage; -- (void)_clearCachedImages; -- (id)_generateSquareContentsImage; -- (void)_updateProgressMask; -- (void)_updateOverlayImage; -- (id)_currentOverlayImage; -- (void)updateImageAnimated:(_Bool)arg1; -- (id)snapshot; -- (void)prepareForReuse; -- (void)layoutSubviews; -- (void)setPaused:(_Bool)arg1; -- (void)setProgressAlpha:(double)arg1; -- (void)_clearProgressView; -- (void)progressViewCanBeRemoved:(id)arg1; -- (void)setProgressState:(long long)arg1 paused:(_Bool)arg2 percent:(double)arg3 animated:(_Bool)arg4; -- (void)_updateOverlayAlpha; -- (void)setIcon:(id)arg1 animated:(_Bool)arg2; -- (void)dealloc; -- (id)initWithFrame:(struct CGRect)arg1; -@end - @interface BBBulletin @property(copy, nonatomic) NSString *bulletinID; // @synthesize bulletinID=_bulletinID; @property(copy, nonatomic) NSString *sectionID; // @synthesize sectionID=_sectionID; @@ -1454,4 +1453,3 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (id)noticesBulletinIDsForSectionID:(id)arg1; - (id)bulletinIDsForSectionID:(id)arg1 inFeed:(unsigned long long)arg2; @end - From 76cfd691dfafd17fa607c5449b5fab2f8bfca711 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Thu, 19 Jan 2017 20:45:50 -0600 Subject: [PATCH 02/59] iOS 9 and 10 updates --- Backgrounding/IconIndicator.xm | 57 +++++++++-------- Backgrounding/Makefile | 8 ++- Backgrounding/RABackgrounder.h | 6 +- .../SpringBoard_UIAppCustomBackgroundModes.xm | 4 +- Backgrounding/UnlimitedBackgrounding.xm | 6 +- GestureSupport/Hooks_iOS9.xm | 24 +++---- GestureSupport/RAGestureManager.h | 6 +- Makefile | 12 ++-- Messaging/RAMessaging.h | 10 +-- Messaging/RAMessagingClient.h | 3 +- Messaging/RAMessagingClient.xm | 37 +++++------ Messaging/RAMessagingServer.h | 1 + Messaging/RAMessagingServer.xm | 30 ++++----- Multiplexer.xm | 18 +++--- RAFakePhoneMode.xm | 8 +-- RAHostedAppView.xm | 35 ++++++----- RASBWorkspaceFetcher.xm | 4 +- RASettings.h | 8 +-- RASettings.mm | 18 +++--- RASnapshotProvider.xm | 31 +++++---- Reachability/Reachability.xm | 63 ++++++++++++------- Reachability/UIKit.xm | 10 +-- SpringBoard.xm | 24 +++---- UIKit.xm | 14 ++--- WindowedMultitasking/LaunchToWindow.xm | 12 +--- WindowedMultitasking/RADesktopManager.xm | 8 +-- .../StartMultitaskingGesture.xm | 13 ++-- headers.h | 18 +++++- reachappassertiondhooks/Makefile | 3 +- reachappassertiondhooks/Tweak.xm | 32 +++------- reachappfakephonemode/Makefile | 3 +- reachappfsdaemon/Makefile | 3 +- reachappfsdaemon/main.mm | 4 +- widgets/Reachability/RAAllAppsWidget.xm | 23 +++++-- widgets/Reachability/RAFavoriteAppsWidget.xm | 15 +++-- widgets/Reachability/RARecentAppsWidget.xm | 17 +++-- 36 files changed, 308 insertions(+), 280 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 2981f19..14516f8 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -21,7 +21,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) if ([[%c(RASettings) sharedInstance] showNativeStateIconIndicators] && (info & RAIconIndicatorViewInfoNative)) ret = [ret stringByAppendingString:@"N"]; - + if (info & RAIconIndicatorViewInfoForced) ret = [ret stringByAppendingString:@"F"]; @@ -30,7 +30,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) if (info & RAIconIndicatorViewInfoSuspendImmediately) ret = [ret stringByAppendingString:@"ll"]; - + if (info & RAIconIndicatorViewInfoUnkillable) ret = [ret stringByAppendingString:@"U"]; @@ -49,7 +49,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) [[self viewWithTag:9962] removeFromSuperview]; [self RA_setIsIconIndicatorInhibited:YES]; if (info == RAIconIndicatorViewInfoTemporarilyInhibit) - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self RA_setIsIconIndicatorInhibited:NO showAgainImmediately:NO]; }); return; @@ -62,7 +62,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) NSString *text = stringFromIndicatorInfo(info); if ( - [self RA_isIconIndicatorInhibited] || + [self RA_isIconIndicatorInhibited] || (text == nil || text.length == 0) || // OR info == RAIconIndicatorViewInfoNone (self.icon == nil || self.icon.application == nil || self.icon.application.isRunning == NO || ![RABackgrounder.sharedInstance shouldShowIndicatorForIdentifier:self.icon.application.bundleIdentifier]) || [[%c(RASettings) sharedInstance] backgrounderEnabled] == NO) @@ -143,7 +143,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) if (!textImageView) { CGFloat padding = [objc_getClass("SBIconBadgeView") _textPadding]; - + textImageView = [[UIImageView alloc] initWithFrame:CGRectMake(padding, padding, badge.frame.size.width - (padding * 2.0), badge.frame.size.height - (padding * 2.0))]; textImageView.center = CGPointMake((badge.frame.size.width / 2.0) + [%c(SBIconBadgeView) _textOffset].x, (badge.frame.size.height / 2.0) + [%c(SBIconBadgeView) _textOffset].y); textImageView.tag = 42; @@ -274,29 +274,34 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) */ %new -(void) RA_addStatusBarIconForSelfIfOneDoesNotExist { -#if DEBUG - if ([lsbitems respondsToSelector:@selector(objectForKey:)] == NO) - { - NSLog(@"[ReachApp] ERROR: lsbitems is not NSDictionary it is %s", class_getName(lsbitems.class)); - //@throw [NSException exceptionWithName:@"OH POOP" reason:@"Expected NSDictionary" userInfo:nil]; - } -#endif - - if (objc_getClass("LSStatusBarItem") && [lsbitems objectForKey:self.bundleIdentifier] == nil && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) - { - if ([[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]) - { - RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; - BOOL native = (info & RAIconIndicatorViewInfoNative); - if ((info & RAIconIndicatorViewInfoNone) == 0 && (native == NO || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) - { + if (objc_getClass("LSStatusBarItem") && [lsbitems objectForKey:self.bundleIdentifier] == nil && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) { + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + if ([[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]) { + RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; + BOOL native = (info & RAIconIndicatorViewInfoNative); + if ((info & RAIconIndicatorViewInfoNone) == 0 && (native == NO || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; - if ([item customViewClass] == nil) - item.customViewClass = @"RAAppIconStatusBarIconView"; - item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; + if ([item customViewClass] == nil) { + item.customViewClass = @"RAAppIconStatusBarIconView"; + } + item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; lsbitems[self.bundleIdentifier] = item; } - } + } + } else { + if ([[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]) { + RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; + BOOL native = (info & RAIconIndicatorViewInfoNative); + if ((info & RAIconIndicatorViewInfoNone) == 0 && (native == NO || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { + LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; + if ([item customViewClass] == nil) { + item.customViewClass = @"RAAppIconStatusBarIconView"; + } + item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; + lsbitems[self.bundleIdentifier] = item; + } + } + } } } @@ -310,7 +315,7 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) //SET_INFO_(self.bundleIdentifier, RAIconIndicatorViewInfoNone); [lsbitems removeObjectForKey:self.bundleIdentifier]; } - else + else { if ([self respondsToSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]) [self performSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]; diff --git a/Backgrounding/Makefile b/Backgrounding/Makefile index 70ef84a..38fad7f 100644 --- a/Backgrounding/Makefile +++ b/Backgrounding/Makefile @@ -1,8 +1,7 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -CFLAGS += -fno-objc-arc -LDFLAGS += -Wl,-segalign,4000 +CFLAGS = -I../ -I../Theming/ -Wno-deprecated-declarations +CFLAGS += -fobjc-arc -O2 include $(THEOS)/makefiles/common.mk @@ -11,6 +10,9 @@ ReachAppBackgrounding_FILES = $(wildcard *.xm) $(wildcard *.mm) $(wildcard *.m) ReachAppBackgrounding_FRAMEWORKS = UIKit CoreGraphics ReachAppBackgrounding_LIBRARIES = applist +IconIndicator.xm_CFLAGS = -fno-objc-arc +SpringBoard_UIAppCustomBackgroundModes.xm_CFLAGS = -fno-objc-arc + include $(THEOS_MAKE_PATH)/tweak.mk after-install:: diff --git a/Backgrounding/RABackgrounder.h b/Backgrounding/RABackgrounder.h index 8602c15..41b3f48 100644 --- a/Backgrounding/RABackgrounder.h +++ b/Backgrounding/RABackgrounder.h @@ -1,6 +1,6 @@ #import "headers.h" -enum RABackgroundMode { +typedef NS_ENUM(NSInteger, RABackgroundMode) { RABackgroundModeNative = 1, RABackgroundModeForceNativeForOldApps = 2, RABackgroundModeForcedForeground = 3, @@ -9,7 +9,7 @@ enum RABackgroundMode { RABackgroundModeUnlimitedBackgroundingTime = 6, }; -enum RAIconIndicatorViewInfo { +typedef NS_ENUM(NSInteger, RAIconIndicatorViewInfo) { RAIconIndicatorViewInfoNone = 0, RAIconIndicatorViewInfoNative = 1, RAIconIndicatorViewInfoForced = 2, @@ -53,4 +53,4 @@ NSString *FriendlyNameForBackgroundMode(RABackgroundMode mode); -(void) updateIconIndicatorForIdentifier:(NSString*)identifier withInfo:(RAIconIndicatorViewInfo)info; -(BOOL) shouldShowIndicatorForIdentifier:(NSString*)identifier; -(BOOL) shouldShowStatusBarIconForIdentifier:(NSString*)identifier; -@end \ No newline at end of file +@end diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index 50ed74d..bf46ecf 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -25,13 +25,13 @@ if ((arg3 == kProcessAssertionReasonViewServices) == NO && // whitelist this to allow share menu to work [arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] == NO && // whitelist iCleaner to prevent crash on open [arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"] == NO && // Whitelist filza to prevent iOS hang (?!) - [NSBundle.mainBundle.bundleIdentifier isEqualToString:@"com.apple.springboard"] == NO) // FIXME: this is a hack that prevents SpringBoard from not starting + IS_SPRINGBOARD == NO) // FIXME: this is a hack that prevents SpringBoard from not starting { NSString *identifier = NSBundle.mainBundle.bundleIdentifier; if (!identifier) goto ORIGINAL; - + //NSLog(@"[ReachApp] BKSProcessAssertion initWithPID:'%d' flags:'%d' reason:'%d' name:'%@' withHandler:'%@' process identifier:'%@'", arg1, arg2, arg3, arg4, arg5, identifier); if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) diff --git a/Backgrounding/UnlimitedBackgrounding.xm b/Backgrounding/UnlimitedBackgrounding.xm index 430dd71..342dfcf 100644 --- a/Backgrounding/UnlimitedBackgrounding.xm +++ b/Backgrounding/UnlimitedBackgrounding.xm @@ -17,12 +17,12 @@ BKSProcessAssertion *keepAlive$temp; reason:kProcessAssertionReasonBackgroundUI name:@"reachapp" withHandler:^{ - NSLog(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); + HBLogInfo(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); if (keepAlive$temp.valid) processAssertions[arg1.identifier] = keepAlive$temp; else { - + } }]; } @@ -53,4 +53,4 @@ RAUnlimitedBackgroundingAppWatcher *sharedInstance$RAUnlimitedBackgroundingAppWa [processAssertions removeObjectForKey:app.bundleIdentifier]; } } -@end \ No newline at end of file +@end diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index 250d783..6b14fb6 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -38,7 +38,7 @@ struct VelocityData { VelocityData oldData; [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&oldData]; - + // this is really quite simple, it calculates a velocity based off of // (current location - last location) / (time taken to move from last location to current location) // which effectively gives you a CGPoint of where it would end if the user continued the gesture. @@ -51,7 +51,7 @@ struct VelocityData { } %new -- (CGPoint)RA_velocity +- (CGPoint)RA_velocity { VelocityData data; [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&data]; @@ -65,7 +65,7 @@ struct VelocityData { @end @implementation Hooks9$SBHandMotionExtractorReplacementByMultiplexer --(id) init +-(id) init { if (self = [super init]) { @@ -75,7 +75,7 @@ struct VelocityData { return self; } --(void) screenEdgePanRecognizerStateDidChange:(_UIScreenEdgePanRecognizer*) screenEdgePanRecognizer +-(void) screenEdgePanRecognizerStateDidChange:(_UIScreenEdgePanRecognizer*) screenEdgePanRecognizer { if (screenEdgePanRecognizer.state == UIGestureRecognizerStateBegan) { @@ -105,7 +105,7 @@ struct VelocityData { } @end -void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event) +void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event) { if (IOHIDEventGetType(event) == kIOHIDEventTypeDigitizer) { @@ -115,14 +115,14 @@ void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEvent float density = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerDensity); float x = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerX) * UIScreen.mainScreen._referenceBounds.size.width; - float y = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerY) * UIScreen.mainScreen._referenceBounds.size.height; + float y = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerY) * UIScreen.mainScreen._referenceBounds.size.height; CGPoint location = (CGPoint) { x, y }; UIInterfaceOrientation interfaceOrientation = GET_STATUSBAR_ORIENTATION; float rotatedX = x; float rotatedY = y; - + if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) { rotatedX = y; @@ -136,7 +136,7 @@ void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEvent CGPoint rotatedLocation = (CGPoint) { rotatedX, rotatedY }; - NSLog(@"[ReachApp] (%f, %d) %@ -> %@", density, isTracking, NSStringFromCGPoint(location), NSStringFromCGPoint(rotatedLocation)); + HBLogInfo(@"[ReachApp] (%f, %d) %@ -> %@", density, isTracking, NSStringFromCGPoint(location), NSStringFromCGPoint(rotatedLocation)); if (isTracking == NO) { @@ -159,7 +159,7 @@ void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEvent currentEdge9 = UIRectEdgeNone; isTracking = NO; - NSLog(@"[ReachApp] touch ended."); + HBLogInfo(@"[ReachApp] touch ended."); } else { @@ -197,7 +197,7 @@ __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; IOHIDEventSystemClientRegisterEventCallback(hidEventSystem, (IOHIDEventSystemClientEventCallback)touch_event, NULL, NULL); class_addProtocol(objc_getClass("Hooks9$SBHandMotionExtractorReplacementByMultiplexer"), @protocol(_UIScreenEdgePanRecognizerDelegate)); - + UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); gestureRecognizers = [[NSMutableSet alloc] initWithCapacity:edgeCount]; @@ -213,5 +213,5 @@ __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer = [[Hooks9$SBHandMotionExtractorReplacementByMultiplexer alloc] init]; } - -} \ No newline at end of file + +} diff --git a/GestureSupport/RAGestureManager.h b/GestureSupport/RAGestureManager.h index f5a449f..dca67cd 100644 --- a/GestureSupport/RAGestureManager.h +++ b/GestureSupport/RAGestureManager.h @@ -2,13 +2,13 @@ @class RAGestureCallback; -typedef enum { +typedef NS_ENUM(NSInteger, RAGestureCallbackResult) { RAGestureCallbackResultSuccessAndContinue, RAGestureCallbackResultFailure, RAGestureCallbackResultSuccessAndStop, RAGestureCallbackResultSuccess = RAGestureCallbackResultSuccessAndContinue, -} RAGestureCallbackResult; +}; @protocol RAGestureCallbackProtocol -(BOOL) RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity; @@ -42,4 +42,4 @@ const NSUInteger RAGesturePriorityDefault = RAGesturePriorityLow; -(void) stopIgnoringSwipesForIdentifier:(NSString*)identifier; -(void) ignoreSwipesBeginningOnSide:(UIRectEdge)side aboveYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier; -(void) ignoreSwipesBeginningOnSide:(UIRectEdge)side belowYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier; -@end \ No newline at end of file +@end diff --git a/Makefile b/Makefile index f8b086f..e0f7297 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,9 @@ DEBUG = 1 ARCHS = armv7 armv7s arm64 CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ -CFLAGS += -fobjc-arc -LDFLAGS += -Wl,-segalign,4000 +CFLAGS += -fobjc-arc -O2 THEOS_PACKAGE_DIR_NAME = debs -TARGET = iphone:clang:9.3:9.3 +TARGET = iphone:9.2 include $(THEOS)/makefiles/common.mk @@ -26,15 +25,12 @@ ReachApp_FILES = Tweak.xm $(wildcard *.xm) $(wildcard *.mm) $(wildcard *.m) \ ReachApp_FRAMEWORKS = UIKit QuartzCore CoreGraphics CoreImage ReachApp_PRIVATE_FRAMEWORKS = GraphicsServices BackBoardServices AppSupport IOKit -ReachApp_LIBRARIES = applist +ReachApp_LIBRARIES = applist rocketbootstrap include $(THEOS_MAKE_PATH)/tweak.mk after-install:: -# install.exec "killall -9 SpringBoard" -# install.exec "killall -9 Preferences" - install.exec "killall -9 backboardd" - + install.exec "killall -9 SpringBoard" SUBPROJECTS += Backgrounding SUBPROJECTS += MissionControl diff --git a/Messaging/RAMessaging.h b/Messaging/RAMessaging.h index 7ced4fa..f50d36b 100644 --- a/Messaging/RAMessaging.h +++ b/Messaging/RAMessaging.h @@ -1,6 +1,6 @@ #import -enum { +typedef NS_ENUM(NSInteger, RAMessageType) { RAMessageTypeUpdateAppData = 0, RAMessageTypeShowKeyboard, @@ -9,7 +9,7 @@ enum { RAMessageTypeRetrieveKeyboardContextId, } RAMessageType; -struct RAMessageAppData { +typedef struct { BOOL shouldForceSize; // Can't use CGSize because it uses CGFloats which aren't able to be transferred between 32/64bit processes (because its float in one and something else (double? i can't remember) in the other). // Also why we can't use CGFloat here @@ -21,15 +21,15 @@ struct RAMessageAppData { BOOL statusBarVisibility; BOOL shouldForceStatusBar; BOOL canHideStatusBarIfWanted; - + UIInterfaceOrientation forcedOrientation; BOOL shouldForceOrientation; - + BOOL shouldUseExternalKeyboard; BOOL isBeingHosted; // Only applies after the app has been restarted. BOOL forcePhoneMode; -}; +} RAMessageAppData; static NSString *RAMessagingUpdateAppInfoMessageName = @"updateAppInfo"; static NSString *RAMessagingShowKeyboardMessageName = @"showKeyboard"; diff --git a/Messaging/RAMessagingClient.h b/Messaging/RAMessagingClient.h index b1528c9..4813691 100644 --- a/Messaging/RAMessagingClient.h +++ b/Messaging/RAMessagingClient.h @@ -1,5 +1,6 @@ #import "headers.h" #import +#import #import "RAMessaging.h" @interface RAMessagingClient : NSObject { @@ -29,4 +30,4 @@ -(BOOL) shouldForceOrientation; -(BOOL) shouldUseExternalKeyboard; -(BOOL) isBeingHosted; -@end \ No newline at end of file +@end diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 6a79fe2..bfb14eb 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -20,18 +20,20 @@ extern BOOL allowClosingReachabilityNatively; @throw [NSException exceptionWithName:@"IsSpringBoardException" reason:@"Cannot use RAMessagingClient in SpringBoard" userInfo:nil]; } - SHARED_INSTANCE2(RAMessagingClient, + SHARED_INSTANCE2(RAMessagingClient, [sharedInstance loadMessagingCenter]; sharedInstance.hasRecievedData = NO; if ([NSBundle.mainBundle.executablePath hasPrefix:@"/Applications"] || + [NSBundle.mainBundle.executablePath hasPrefix:@"/var/stash/appsstash"] || + [NSBundle.mainBundle.executablePath hasPrefix:@"/var/containers/Bundle/Application"] || [NSBundle.mainBundle.executablePath hasPrefix:@"/private/var/db/stash"] || [NSBundle.mainBundle.executablePath hasPrefix:@"/var/mobile/Applications"] || [NSBundle.mainBundle.executablePath hasPrefix:@"/private/var/mobile/Applications"] || [NSBundle.mainBundle.executablePath hasPrefix:@"/var/mobile/Containers/Bundle/Application"] || [NSBundle.mainBundle.executablePath hasPrefix:@"/private/var/mobile/Containers/Bundle/Application"]) { - NSLog(@"[ReachApp] valid process for RAMessagingClient"); + HBLogDebug(@"[ReachApp] valid process for RAMessagingClient"); sharedInstance->allowedProcess = YES; } ); @@ -53,38 +55,27 @@ extern BOOL allowClosingReachabilityNatively; data.shouldForceOrientation = NO; data.shouldUseExternalKeyboard = NO; data.forcePhoneMode = NO; - data.isBeingHosted = NO; + data.isBeingHosted = NO; _currentData = data; // Initialize data - serverCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - - void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if (handle) - { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*); - rocketbootstrap_distributedmessagingcenter_apply = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(serverCenter); - dlclose(handle); - } + serverCenter = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + rocketbootstrap_distributedmessagingcenter_apply(serverCenter); } -(void) alertUser:(NSString*)description { -#if DEBUG - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"MULTIPLEXER") message:description delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; -#endif + HBLogError(@"%@", description); } -(void) _requestUpdateFromServerWithTries:(int)tries { - /*if (!NSBundle.mainBundle.bundleIdentifier || + /*if (!NSBundle.mainBundle.bundleIdentifier || IS_PROCESS("assertiond") || // Don't need to load into this anyway IS_PROCESS("searchd") || // safe-mode crash fix IS_PROCESS("gputoolsd") || // iMohkles found this crashes (no uikit) IS_PROCESS("filecoordinationd") || // ??? - IS_PROCESS("backboardd") // Backboardd uses its own messaging center for what it does. + IS_PROCESS("backboardd") // Backboardd uses its own messaging center for what it does. )*/ if (allowedProcess == NO) @@ -94,7 +85,7 @@ extern BOOL allowClosingReachabilityNatively; // 1. hang the process // 2. crash after timeout due to no UIKit (?) // 3. something else bad - // so therefore all those are simply blacklisted. simple. + // so therefore all those are simply blacklisted. simple. return; } @@ -142,7 +133,7 @@ extern BOOL allowClosingReachabilityNatively; else if (data.shouldForceSize) [UIApplication.sharedApplication RA_updateWindowsForSizeChange:CGSizeMake(data.wantedClientWidth, data.wantedClientHeight) isReverting:NO]; - if (didOrientationChange && data.shouldForceOrientation == NO) + if (didOrientationChange && data.shouldForceOrientation == NO) [UIApplication.sharedApplication RA_forceRotationToInterfaceOrientation:data.forcedOrientation isReverting:YES]; else if (data.shouldForceOrientation) [UIApplication.sharedApplication RA_forceRotationToInterfaceOrientation:data.forcedOrientation isReverting:NO]; @@ -225,10 +216,10 @@ void updateFrontmostApp(CFNotificationCenterRef center, IF_SPRINGBOARD { } - else + else { [RAMessagingClient sharedInstance]; CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadClientData, (__bridge CFStringRef)[NSString stringWithFormat:@"com.efrederickson.reachapp.clientupdate-%@",NSBundle.mainBundle.bundleIdentifier], NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &updateFrontmostApp, CFSTR("com.efrederickson.reachapp.frontmostAppDidUpdate"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); } -} \ No newline at end of file +} diff --git a/Messaging/RAMessagingServer.h b/Messaging/RAMessagingServer.h index 353d1ac..add63e3 100644 --- a/Messaging/RAMessagingServer.h +++ b/Messaging/RAMessagingServer.h @@ -1,5 +1,6 @@ #import "headers.h" #import +#import #import "RAMessaging.h" @interface RAMessagingServer : NSObject { diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index c182652..92cd545 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -23,7 +23,7 @@ extern BOOL launchNextOpenIntoWindow; @implementation RAMessagingServer +(instancetype) sharedInstance { - SHARED_INSTANCE2(RAMessagingServer, + SHARED_INSTANCE2(RAMessagingServer, [sharedInstance loadServer]; sharedInstance->dataForApps = [NSMutableDictionary dictionary]; sharedInstance->contextIds = [NSMutableDictionary dictionary]; @@ -34,16 +34,8 @@ extern BOOL launchNextOpenIntoWindow; -(void) loadServer { - messagingCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - - void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if (handle) - { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*); - rocketbootstrap_distributedmessagingcenter_apply = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); - dlclose(handle); - } + messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); [messagingCenter runServerOnCurrentThread]; @@ -96,7 +88,7 @@ extern BOOL launchNextOpenIntoWindow; callback(YES); } - // Got the message, cancel the re-sender + // Got the message, cancel the re-sender if ([asyncHandles objectForKey:identifier] != nil) { struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; @@ -306,7 +298,7 @@ extern BOOL launchNextOpenIntoWindow; } CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge CFStringRef)[NSString stringWithFormat:@"com.efrederickson.reachapp.clientupdate-%@",identifier], nil, nil, YES); - + if (tries <= 4) { if ([asyncHandles objectForKey:identifier] != nil) @@ -328,11 +320,11 @@ extern BOOL launchNextOpenIntoWindow; if (callback) waitingCompletions[identifier] = [callback copy]; } - // Reset failure checker + // Reset failure checker [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(checkIfCompletionStillExitsForIdentifierAndFailIt:) object:identifier]; [self performSelector:@selector(checkIfCompletionStillExitsForIdentifierAndFailIt:) withObject:identifier afterDelay:4]; } - + /* SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; @@ -471,10 +463,10 @@ extern BOOL launchNextOpenIntoWindow; -(void) forcePhoneMode:(BOOL)value forIdentifier:(NSString*)identifier andRelaunchApp:(BOOL)relaunch { RAMessageAppData data = [self getDataForIdentifier:identifier]; - + data.forcePhoneMode = value; [self setData:data forIdentifier:identifier]; - + if (relaunch) { [RAAppKiller killAppWithIdentifier:identifier completion:^{ @@ -495,7 +487,7 @@ extern BOOL launchNextOpenIntoWindow; -(void) setKeyboardContextId:(unsigned int)id forIdentifier:(NSString*)identifier { - NSLog(@"[ReachApp] got c id %d", id); + HBLogDebug(@"[ReachApp] got c id %d", id); contextIds[identifier] = @(id); } @@ -510,4 +502,4 @@ extern BOOL launchNextOpenIntoWindow; IF_SPRINGBOARD { [RAMessagingServer sharedInstance]; } -} \ No newline at end of file +} diff --git a/Multiplexer.xm b/Multiplexer.xm index 6e2dce5..509d41e 100644 --- a/Multiplexer.xm +++ b/Multiplexer.xm @@ -18,7 +18,7 @@ } -(NSString*) currentVersion { return @"1.0"; } --(BOOL) isOnSupportedOS { return SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0") && SYSTEM_VERSION_LESS_THAN(@"9.0"); } +-(BOOL) isOnSupportedOS { return SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0") && SYSTEM_VERSION_LESS_THAN(@"10.2"); } -(void) registerExtension:(NSString*)name forMultiplexerVersion:(NSString*)version { @@ -43,22 +43,22 @@ { // ** below code from Mirmir (https://github.com/EthanArbuckle/Mirmir/blob/lamo_no_ms/Lamo/CDTLamo.mm#L114-L138) SBWorkspaceApplicationTransitionContext *transitionContext = [[%c(SBWorkspaceApplicationTransitionContext) alloc] init]; - + //set layout role to 'side' (deactivating) SBWorkspaceDeactivatingEntity *deactivatingEntity = [%c(SBWorkspaceDeactivatingEntity) entity]; [deactivatingEntity setLayoutRole:3]; [transitionContext setEntity:deactivatingEntity forLayoutRole:3]; - + //set layout role for 'primary' (activating) SBWorkspaceHomeScreenEntity *homescreenEntity = [[%c(SBWorkspaceHomeScreenEntity) alloc] init]; [transitionContext setEntity:homescreenEntity forLayoutRole:2]; - + [transitionContext setAnimationDisabled:YES]; - + //create transititon request - SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[[UIScreen mainScreen] valueForKey:@"_fbsDisplay"]]; - [transitionRequest setValue:transitionContext forKey:@"_applicationContext"]; - + SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[UIScreen.mainScreen valueForKey:@"_fbsDisplay"]]; + [transitionRequest setApplicationContext:transitionContext]; + return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithTransitionRequest:transitionRequest]; // ** // } @@ -70,4 +70,4 @@ [[%c(SBUIController) sharedInstance] shouldShowControlCenterTabControlOnFirstSwipe]; return [[%c(SBControlCenterController) sharedInstance] _shouldShowGrabberOnFirstSwipe]; } -@end \ No newline at end of file +@end diff --git a/RAFakePhoneMode.xm b/RAFakePhoneMode.xm index b20a6ca..090900b 100644 --- a/RAFakePhoneMode.xm +++ b/RAFakePhoneMode.xm @@ -8,7 +8,7 @@ I split them apart when i was trying to find some issue with app resizing/touche */ #define RA_4S_SIZE CGSizeMake(320, 480) -#define RA_5S_SIZE CGSizeMake(320, 512) +#define RA_5S_SIZE CGSizeMake(320, 568) #define RA_6P_SIZE CGSizeMake(414, 736) CGSize forcePhoneModeSize = RA_6P_SIZE; @@ -19,8 +19,8 @@ CGSize forcePhoneModeSize = RA_6P_SIZE; // Prevent iPhone issue if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // somehow, this is needed to make sure that both force resizing and Fake Phone Mode work. Without the dispatch_after, even if fake phone mode is disabled, - // force resizing seems to render touches incorrectly ¯\_(ツ)_/¯ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // somehow, this is needed to make sure that both force resizing and Fake Phone Mode work. Without the dispatch_after, even if fake phone mode is disabled, + // force resizing seems to render touches incorrectly ¯\_(ツ)_/¯ IF_NOT_SPRINGBOARD { if ([RAFakePhoneMode shouldFakeForThisProcess]) @@ -56,7 +56,7 @@ CGSize forcePhoneModeSize = RA_6P_SIZE; IF_SPRINGBOARD { return [RAMessagingServer.sharedInstance getDataForIdentifier:identifier].forcePhoneMode; } - NSLog(@"[ReachApp] WARNING: +[RAFakePhoneMode shouldFakeForAppWithIdentifier:] called from outside SpringBoard!"); + HBLogWarn(@"[ReachApp] WARNING: +[RAFakePhoneMode shouldFakeForAppWithIdentifier:] called from outside SpringBoard!"); return NO; } diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index 6fb3f79..b474742 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -85,9 +85,14 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; if (startTries > 5) { isPreloading = NO; - NSLog(@"[ReachApp] maxed out preload attempts for app %@", app.bundleIdentifier); - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"MULTIPLEXER") message:[NSString stringWithFormat:@"Unable to start app %@", app.displayName] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + HBLogDebug(@"[ReachApp] maxed out preload attempts for app %@", app.bundleIdentifier); + UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Zypen" + message:[NSString stringWithFormat:@"Unable to start app %@", app.displayName] + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + [alert addAction:defaultAction]; + [self.inputViewController presentViewController:alert animated:YES completion:nil]; return; } @@ -104,7 +109,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; [UIApplication.sharedApplication launchApplicationWithIdentifier:self.bundleIdentifier suspended:YES]; [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:self.bundleIdentifier]; // ummm...? } - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self _preloadOrAttemptToUpdateReachabilityCounterpart]; }); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self _preloadOrAttemptToUpdateReachabilityCounterpart]; }); // this ^ runs either way. when _preloadOrAttemptToUpdateReachabilityCounterpart runs, if the app is "loaded" it will not call preloadApp again, otherwise // it will call it again. } @@ -133,7 +138,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; [self addSubview:view]; [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; - //if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) [RAHostedAppView iPad_iOS83_fixHosting]; [RARunningAppsProvider.sharedInstance addTarget:self]; @@ -192,9 +197,8 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; [self _actualLoadApp]; }, failedBlock /* stupid commas */); } - else + else IF_ASPHALEIA2 { - IF_ASPHALEIA2 { void (^failedBlock)() = ^{ [self removeLoadingIndicator]; if (!authenticationDidFailLabel) @@ -218,10 +222,9 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; ASPHALEIA2_AUTHENTICATE_APP(app.bundleIdentifier, ^{ [self _actualLoadApp]; }, failedBlock); - } - else - [self _actualLoadApp]; } + else + [self _actualLoadApp]; if (self.showSplashscreenInsteadOfSpinner) { @@ -342,7 +345,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; if (_isCurrentlyHosting == NO) return; - + _isCurrentlyHosting = NO; FBScene *scene = [app mainScene]; @@ -368,7 +371,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; if (contextHostManager) { [contextHostManager disableHostingForRequester:@"reachapp"]; - contextHostManager = nil; + contextHostManager = nil; } //if ([UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:app]) @@ -378,7 +381,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; __block BOOL didRun = NO; RAMessageCompletionCallback block = ^(BOOL success) { if (didRun || (weakSelf && [UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:weakSelf.app])) - return; + return; if (!scene) return; @@ -432,16 +435,16 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; FBWindowContextHostManager *manager = (FBWindowContextHostManager*)[RAHostManager hostManagerForApp:app_]; if (manager) { - NSLog(@"[ReachApp] rehosting for iPad: %@", bundleIdentifier); + HBLogDebug(@"[ReachApp] rehosting for iPad: %@", bundleIdentifier); [manager enableHostingForRequester:@"reachapp" priority:1]; } } } - + } // This allows for any subviews (with gestures) (e.g. the SwipeOver bar with a negative y origin) to recieve touch events. -- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event +- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { BOOL isContained = NO; for (UIView *subview in self.subviews) diff --git a/RASBWorkspaceFetcher.xm b/RASBWorkspaceFetcher.xm index 25f66fc..5ff5cc8 100644 --- a/RASBWorkspaceFetcher.xm +++ b/RASBWorkspaceFetcher.xm @@ -20,7 +20,7 @@ Class SBWorkspace_class_implementation_class = nil; { if ([SBWorkspace_class_implementation_class respondsToSelector:@selector(sharedInstance)]) return [SBWorkspace_class_implementation_class sharedInstance]; - NSLog(@"[ReachApp] \"SBWorkspace\" class '%s' does not have '+sharedInstance' method", class_getName(SBWorkspace_class_implementation_class)); + HBLogDebug(@"[ReachApp] \"SBWorkspace\" class '%s' does not have '+sharedInstance' method", class_getName(SBWorkspace_class_implementation_class)); return nil; } @end @@ -30,4 +30,4 @@ Class SBWorkspace_class_implementation_class = nil; // SBMainWorkspace: iOS 9 // SBWorkspace: iOS 8 SBWorkspace_class_implementation_class = objc_getClass("SBMainWorkspace") ?: objc_getClass("SBWorkspace"); -} \ No newline at end of file +} diff --git a/RASettings.h b/RASettings.h index 5e77277..cb010d9 100644 --- a/RASettings.h +++ b/RASettings.h @@ -1,6 +1,6 @@ #import -enum RAGrabArea { +typedef NS_ENUM(NSInteger, RAGrabArea) { RAGrabAreaBottomLeftThird = 1, RAGrabAreaBottomMiddleThird = 2, RAGrabAreaBottomRightThird = 3, @@ -78,10 +78,6 @@ enum RAGrabArea { -(BOOL) quickAccessUseGenericTabLabel; -#if DEBUG --(BOOL) debug_showIPCMessages; -#endif - -(BOOL) windowedMultitaskingEnabled; -(NSInteger) windowRotationLockMode; -(RAGrabArea) windowedMultitaskingGrabArea; @@ -89,4 +85,4 @@ enum RAGrabArea { -(BOOL) onlyShowWindowBarIconsOnOverlay; -(NSString*) currentThemeIdentifier; -@end \ No newline at end of file +@end diff --git a/RASettings.mm b/RASettings.mm index 2019066..f730953 100644 --- a/RASettings.mm +++ b/RASettings.mm @@ -4,7 +4,7 @@ #import "RAThemeManager.h" #import "RANCViewController.h" -#define BOOL(key, default) ([_settings objectForKey:key] != nil ? [_settings[key] boolValue] : default) +#define BOOL(key, default) ([_settings objectForKey:key] != nil ? [_settings[key] boolValue] : default) NSCache *backgrounderSettingsCache = [NSCache new]; @@ -35,7 +35,7 @@ +(BOOL) isActivatorInstalled } +(BOOL) isLibStatusBarInstalled -{ +{ static BOOL installed = NO; static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ @@ -81,19 +81,19 @@ -(void) reloadSettings BOOL failed = NO; - if (keyList) + if (keyList) { //_settings = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); _settings = (NSDictionary*)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)); CFRelease(keyList); - if (!_settings) + if (!_settings) { //NSLog(@"[ReachApp] failure loading from CFPreferences"); failed = YES; } } - else + else { //NSLog(@"[ReachApp] failure loading keyList"); failed = YES; @@ -131,14 +131,14 @@ -(void) resetSettings CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (keyList) + if (keyList) { CFPreferencesSetMultiple(NULL, keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); CFRelease(keyList); } else { - NSLog(@"[ReachApp] unable to get keyList to reset settings"); + HBLogError(@"[ReachApp] unable to get keyList to reset settings"); } CFPreferencesAppSynchronize(appID); CFRelease(appID); @@ -349,7 +349,7 @@ -(NSDictionary*) rawCompiledBackgrounderSettingsForIdentifier:(NSString*)identif -(BOOL) isFirstRun { NSLog(@"[ReachApp] %d", BOOL(@"isFirstRun", YES)); - return BOOL(@"isFirstRun", YES); + return BOOL(@"isFirstRun", YES); } -(void) setFirstRun:(BOOL)value @@ -383,4 +383,4 @@ -(RAGrabArea) swipeOverGrabArea { return [_settings objectForKey:@"swipeOverGrabArea"] == nil ? RAGrabAreaSideAnywhere : (RAGrabArea)[_settings[@"swipeOverGrabArea"] intValue]; } -@end \ No newline at end of file +@end diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index 5c59fdc..3011233 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -24,7 +24,7 @@ @autoreleasepool { if ([imageCache objectForKey:identifier] != nil) return [imageCache objectForKey:identifier]; - + UIImage *image = nil; SBDisplayItem *item = [%c(SBDisplayItem) displayItemWithType:@"App" displayIdentifier:identifier]; @@ -38,15 +38,22 @@ } else { - //SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; - //view = [[%c(SBAppSwitcherSnapshotView) alloc] initWithDisplayItem:item application:app orientation:orientation preferringDownscaledSnapshot:NO async:NO withQueue:nil]; + SBApplication *app = [[%c(SBApplicationController) sharedInstance] ZY_applicationWithBundleIdentifier:identifier]; + view = [[%c(SBAppSwitcherSnapshotView) alloc] initWithDisplayItem:item application:app orientation:orientation preferringDownscaledSnapshot:NO async:NO withQueue:nil]; } }); - + if (view) { - [view performSelectorOnMainThread:@selector(_loadSnapshotSync) withObject:nil waitUntilDone:YES]; - image = MSHookIvar(view, "_snapshotImageView").image; + if ([view respondsToSelector:@selector(_loadSnapshotSync)]) { + [view performSelectorOnMainThread:@selector(_loadSnapshotSync) withObject:nil waitUntilDone:YES]; + image = MSHookIvar(view, "_snapshotImageView").image; + } else { + _SBAppSwitcherSnapshotContext *snapshotContext = MSHookIvar<_SBAppSwitcherSnapshotContext*>(view, "_snapshotContext"); + SBSwitcherSnapshotImageView *snapshotImageView = snapshotContext.snapshotImageView; + image = snapshotImageView.image; + } + } if (!image) @@ -73,7 +80,7 @@ } @catch (NSException *ex) { - NSLog(@"[ReachApp] error generating snapshot: %@", ex); + HBLogError(@"[ReachApp] error generating snapshot: %@", ex); } } @@ -112,7 +119,7 @@ //CGContextRef c = UIGraphicsGetCurrentContext(); //CGContextSetAllowsAntialiasing(c, YES); //[window.layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; - + ON_MAIN_THREAD(^{ [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; }); @@ -209,13 +216,13 @@ //[[[[%c(SBUIController) sharedInstance] window] layer] performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Icons //ON_MAIN_THREAD(^{ //[MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow") drawViewHierarchyInRect:UIScreen.mainScreen.bounds afterScreenUpdates:YES]; - + [[[%c(SBUIController) sharedInstance] window] drawViewHierarchyInRect:UIScreen.mainScreen.bounds afterScreenUpdates:YES]; - + [desktop drawViewHierarchyInRect:UIScreen.mainScreen.bounds afterScreenUpdates:YES]; }); //[desktop.layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Desktop windows - + for (UIView *view in desktop.subviews) // Application views { if ([view isKindOfClass:[RAWindowBar class]]) @@ -300,4 +307,4 @@ { [imageCache removeAllObjects]; } -@end \ No newline at end of file +@end diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 4e67858..7f00eae 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -16,8 +16,6 @@ #import "RAMessagingServer.h" #import "RAAppSwitcherModelWrapper.h" -#define SPRINGBOARD ([NSBundle.mainBundle.bundleIdentifier isEqual:@"com.apple.springboard"]) - /*FBWindowContextHostWrapperView*/ UIView *view = nil; NSString *lastBundleIdentifier = @""; NSString *currentBundleIdentifier = @""; @@ -30,8 +28,8 @@ CGPoint firstLocation = CGPointZero; CGFloat grabberCenter_X = 0; BOOL showingNC = NO; BOOL overrideDisableForStatusBar = NO; -CGRect pre_topAppFrame = CGRectZero; -CGAffineTransform pre_topAppTransform = CGAffineTransformIdentity; +//CGRect pre_topAppFrame = CGRectZero; +//CGAffineTransform pre_topAppTransform = CGAffineTransformIdentity; UIView *bottomDraggerView = nil; CGFloat old_grabberCenterY = -1; @@ -42,7 +40,7 @@ BOOL wasEnabled = NO; %hook SBReachabilityManager +(BOOL)reachabilitySupported { - return YES; + return YES; } - (void)_handleReachabilityActivated @@ -89,7 +87,7 @@ BOOL wasEnabled = NO; if (wasEnabled) { wasEnabled = NO; - // Notify both top and bottom apps Reachability is closing + // Notify both top and bottom apps Reachability is closing if ([view isKindOfClass:[RAAppSliderProviderView class]]) { [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; @@ -194,7 +192,7 @@ id SBWorkspace$sharedInstance; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:currentBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:currentBundleIdentifier completion:nil]; - + if ([RASettings.sharedInstance showNCInstead]) { showingNC = NO; @@ -230,14 +228,14 @@ id SBWorkspace$sharedInstance; FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; SET_BACKGROUNDED(settings, YES); [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; - MSHookIvar([app mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; - MSHookIvar([app mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; + //MSHookIvar([app mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; + //MSHookIvar([app mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; SBApplication *currentApp = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:currentBundleIdentifier]; if ([currentApp mainScene]) { - MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; - MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; + //MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; + //MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; } FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; @@ -302,8 +300,8 @@ id SBWorkspace$sharedInstance; CGFloat knobWidth = 60; CGFloat knobHeight = 25; draggerView = [[UIView alloc] initWithFrame:CGRectMake( - (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), - [UIScreen mainScreen].bounds.size.height * .3, + (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), + [UIScreen mainScreen].bounds.size.height * .3, knobWidth, knobHeight)]; draggerView.alpha = 0.3; draggerView.layer.cornerRadius = 10; @@ -391,8 +389,8 @@ id SBWorkspace$sharedInstance; if ([RASettings.sharedInstance showBottomGrabber]) { bottomDraggerView = [[UIView alloc] initWithFrame:CGRectMake( - (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), - -(knobHeight / 2), + (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), + -(knobHeight / 2), knobWidth, knobHeight)]; bottomDraggerView.alpha = 0.3; bottomDraggerView.layer.cornerRadius = 10; @@ -409,7 +407,7 @@ id SBWorkspace$sharedInstance; { if (view) [self RA_closeCurrentView]; - + UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); //CGSize iconSize = [%c(SBIconView) defaultIconImageSize]; static CGSize fullSize = [%c(SBIconView) defaultIconSize]; @@ -428,7 +426,7 @@ id SBWorkspace$sharedInstance; UIView *widgetSelectorView = [[RAWidgetSectionManager sharedInstance] createViewForEnabledSectionsWithBaseFrame:w.frame preferredIconSize:fullSize iconsThatFitPerLine:numIconsPerLine spacing:padding]; widgetSelectorView.frame = (CGRect){ { 0, 0 }, widgetSelectorView.frame.size }; //widgetSelectorView.frame = w.frame; - + if (draggerView) [w insertSubview:widgetSelectorView belowSubview:draggerView]; else @@ -515,7 +513,26 @@ CGFloat startingY = -1; return; [self handleReachabilityModeDeactivated]; - [RADesktopManager.sharedInstance.currentDesktop createAppWindowWithIdentifier:ident animated:YES]; + SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:ident]; + RAIconIndicatorViewInfo indicatorInfo = [[%c(RABackgrounder) sharedInstance] allAggregatedIndicatorInfoForIdentifier:ident]; + + // Close app + [[%c(RABackgrounder) sharedInstance] temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:app andCloseForegroundApp:NO]; + FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; + [deactiveSets setFlag:YES forDeactivationSetting:20]; + [deactiveSets setFlag:NO forDeactivationSetting:2]; + [app _setDeactivationSettings:deactiveSets]; + + // Open in window + [RADesktopManager.sharedInstance.currentDesktop createAppWindowWithIdentifier:ident animated:YES]; + }]; + [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; + + // Pop forced foreground backgrounding + [[%c(RABackgrounder) sharedInstance] queueRemoveTemporaryOverrideForIdentifier:ident]; + [[%c(RABackgrounder) sharedInstance] removeTemporaryOverrideForIdentifier:ident]; + [[%c(RABackgrounder) sharedInstance] updateIconIndicatorForIdentifier:ident withInfo:indicatorInfo]; } %new - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer @@ -642,10 +659,10 @@ CGFloat startingY = -1; [RAMessagingServer.sharedInstance resizeApp:targetIdentifier toSize:CGSizeMake(width, height) completion:nil]; } - + /* if ([view isKindOfClass:[%c(FBWindowContextHostWrapperView) class]] == NO && [view isKindOfClass:[RAAppSliderProviderView class]] == NO) return; // only resize when the app is being shown. That way it's more like native Reachability - + */ [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:currentBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance rotateApp:lastBundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; @@ -742,7 +759,7 @@ CGFloat startingY = -1; window = MSHookIvar(self,"_reachabilityWindow"); window.frame = (CGRect) { { window.frame.origin.x, view.frame.size.width }, { window.frame.size.width, view.frame.size.width } }; - + SBApplication *currentApp = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:currentBundleIdentifier]; if ([currentApp mainScene]) // just checking... { @@ -845,9 +862,9 @@ CGFloat startingY = -1; %ctor { - if (SPRINGBOARD) + IF_SPRINGBOARD { Class c = objc_getClass("SBMainWorkspace") ?: objc_getClass("SBWorkspace"); %init(hooks, SB_WORKSPACE_CLASS=c); } -} \ No newline at end of file +} diff --git a/Reachability/UIKit.xm b/Reachability/UIKit.xm index bfe4ce1..d22e9dd 100644 --- a/Reachability/UIKit.xm +++ b/Reachability/UIKit.xm @@ -8,13 +8,13 @@ BOOL allowClosingReachabilityNatively = NO; { if (allowClosingReachabilityNatively == NO) { - NSLog(@"[ReachApp] attempting to close reachability but not allowed to."); + HBLogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); return; } - + if ([RAMessagingClient.sharedInstance isBeingHosted]) { - NSLog(@"[ReachApp] stopping reachability from closing because hosted"); + HBLogDebug(@"[ReachApp] stopping reachability from closing because hosted"); return; } %orig; @@ -71,7 +71,7 @@ BOOL allowClosingReachabilityNatively = NO; } %end -%hook UIInputWindowController +%hook UIInputWindowController - (void)moveFromPlacement:(unsafe_id)arg1 toPlacement:(unsafe_id)arg2 starting:(unsafe_id)arg3 completion:(unsafe_id)arg4 { overrideViewControllerDismissal = YES; @@ -79,4 +79,4 @@ BOOL allowClosingReachabilityNatively = NO; overrideViewControllerDismissal = NO; } %end -*/ \ No newline at end of file +*/ diff --git a/SpringBoard.xm b/SpringBoard.xm index 7ac95a4..44d4583 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -112,28 +112,28 @@ extern BOOL overrideDisableForStatusBar; %orig; } -// On iOS 8.3 and above, on the iPad, if a FBWindowContextWhatever creates a hosting context / enabled hosting, all the other hosted windows stop. -// This fixes that. +// On iOS 8.3 and above, on the iPad, if a FBWindowContextWhatever creates a hosting context / enabled hosting, all the other hosted windows stop. +// This fixes that. -(void)_didComplete { %orig; - //if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) - // can't hurt to check all devices - especially if it changes/has changed to include phones. + // can't hurt to check all devices - especially if it changes/has changed to include phones. // however this was presumably done in preparation for the iOS 9 multitasking - [RAHostedAppView iPad_iOS83_fixHosting]; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + [RAHostedAppView iPad_iOS83_fixHosting]; } %end /* %hook SBRootFolderView -- (_Bool)_hasMinusPages +- (_Bool)_hasMinusPages { - return RADesktopManager.sharedInstance.currentDesktop.hostedWindows.count > 0 ? YES : %orig; + return RADesktopManager.sharedInstance.currentDesktop.hostedWindows.count > 0 ? YES : %orig; } -- (unsigned long long)_minusPageCount +- (unsigned long long)_minusPageCount { - return RADesktopManager.sharedInstance.currentDesktop.hostedWindows.count > 0 ? 1 : %orig; + return RADesktopManager.sharedInstance.currentDesktop.hostedWindows.count > 0 ? 1 : %orig; } %end */ @@ -152,7 +152,7 @@ extern BOOL overrideDisableForStatusBar; dispatch_async(dispatch_get_main_queue(), ^{ [RASnapshotProvider.sharedInstance forceReloadOfSnapshotForIdentifier:self.bundleIdentifier]; }); - + %orig; } %end @@ -161,7 +161,7 @@ extern BOOL overrideDisableForStatusBar; - (void)_postLockCompletedNotification:(_Bool)arg1 { %orig; - + if (arg1) { if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) @@ -181,7 +181,7 @@ extern BOOL overrideDisableForStatusBar; void respring_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { - [[UIApplication sharedApplication] _relaunchSpringBoardNow]; + [[%c(FBSystemService) sharedInstance] exitAndRelaunch:YES]; } void reset_settings_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) diff --git a/UIKit.xm b/UIKit.xm index 65c9203..9b686b7 100644 --- a/UIKit.xm +++ b/UIKit.xm @@ -101,7 +101,7 @@ static Class $memorized$UITextEffectsWindow$class; arg3 = YES; } //arg1 = ((forcingRotation&&NO) || overrideDisplay) ? (isTopApp ? NO : YES) : arg1; - + %orig(arg1, arg2, arg3); } @@ -165,7 +165,7 @@ static Class $memorized$UITextEffectsWindow$class; { if (revert) { - for (UIWindow *window in [[UIApplication sharedApplication] windows]) + for (UIWindow *window in [[UIApplication sharedApplication] windows]) { CGRect frame = window.frame; if ([oldFrames objectForKey:@(window.hash)] != nil) @@ -178,7 +178,7 @@ static Class $memorized$UITextEffectsWindow$class; [window setFrame:frame]; }]; } - + if ([oldFrames objectForKey:@"statusBar"] != nil) UIApplication.sharedApplication.statusBar.frame = [oldFrames[@"statusBar"] CGRectValue]; @@ -216,10 +216,10 @@ static Class $memorized$UITextEffectsWindow$class; if ([RAMessagingClient.sharedInstance isBeingHosted]) { objc_setAssociatedObject(self, @selector(RA_networkActivity), @(arg1), OBJC_ASSOCIATION_RETAIN_NONATOMIC); - + StatusBarData *data = [UIStatusBarServer getStatusBarData]; - data->itemIsEnabled[24] = arg1; // 24 = activity indicator - [UIApplication.sharedApplication.statusBar forceUpdateToData:data animated:YES]; + data->itemIsEnabled[26] = arg1; // 24 = activity indicator + [UIApplication.sharedApplication.statusBar forceUpdateToData:data animated:YES]; } } @@ -237,7 +237,7 @@ static Class $memorized$UITextEffectsWindow$class; -(void) statusBarServer:(unsafe_id)arg1 didReceiveStatusBarData:(StatusBarData*)arg2 withActions:(int)arg3 { if ([RAMessagingClient.sharedInstance isBeingHosted]) - arg2->itemIsEnabled[24] = [UIApplication.sharedApplication isNetworkActivityIndicatorVisible]; + arg2->itemIsEnabled[26] = [UIApplication.sharedApplication isNetworkActivityIndicatorVisible]; %orig; } %end diff --git a/WindowedMultitasking/LaunchToWindow.xm b/WindowedMultitasking/LaunchToWindow.xm index 5c917c0..ea95993 100644 --- a/WindowedMultitasking/LaunchToWindow.xm +++ b/WindowedMultitasking/LaunchToWindow.xm @@ -3,18 +3,12 @@ #import "RADesktopManager.h" #import "RADesktopWindow.h" -#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) -#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) - BOOL launchNextOpenIntoWindow = NO; BOOL override = NO; BOOL allowOpenApp = NO; %hook SBIconController --(void)iconWasTapped:(__unsafe_unretained SBApplicationIcon*)arg1 +-(void)iconWasTapped:(__unsafe_unretained SBApplicationIcon*)arg1 { if ([RASettings.sharedInstance windowedMultitaskingEnabled] && [RASettings.sharedInstance launchIntoWindows] && arg1.application) { @@ -26,9 +20,9 @@ BOOL allowOpenApp = NO; -(void)_launchIcon:(unsafe_id)icon { - if (!override) + if (!override) %orig; - else + else override = NO; } %end diff --git a/WindowedMultitasking/RADesktopManager.xm b/WindowedMultitasking/RADesktopManager.xm index 4c99cbd..a5a5a9c 100644 --- a/WindowedMultitasking/RADesktopManager.xm +++ b/WindowedMultitasking/RADesktopManager.xm @@ -7,7 +7,7 @@ BOOL overrideUIWindow = NO; @implementation RADesktopManager +(instancetype) sharedInstance { - SHARED_INSTANCE2(RADesktopManager, + SHARED_INSTANCE2(RADesktopManager, sharedInstance->windows = [NSMutableArray array]; [sharedInstance addDesktop:YES]; overrideUIWindow = YES; @@ -35,7 +35,7 @@ BOOL overrideUIWindow = NO; RADesktopWindow *window = windows[index]; [window saveInfo]; [window closeAllApps]; - [windows removeObjectAtIndex:index]; + [windows removeObjectAtIndex:index]; } -(BOOL) isAppOpened:(NSString*)identifier @@ -186,6 +186,6 @@ BOOL overrideUIWindow = NO; %ctor { - if ([NSBundle.mainBundle.bundleIdentifier isEqual:@"com.apple.springboard"]) + IF_SPRINGBOARD %init; -} \ No newline at end of file +} diff --git a/WindowedMultitasking/StartMultitaskingGesture.xm b/WindowedMultitasking/StartMultitaskingGesture.xm index 1a5ea71..de12082 100644 --- a/WindowedMultitasking/StartMultitaskingGesture.xm +++ b/WindowedMultitasking/StartMultitaskingGesture.xm @@ -29,7 +29,7 @@ BOOL locationIsInValidArea(CGFloat x) %ctor { - if (!IS_SPRINGBOARD) + IF_NOT_SPRINGBOARD return; __weak __block UIView *appView = nil; __block CGFloat lastY = 0; @@ -62,7 +62,7 @@ BOOL locationIsInValidArea(CGFloat x) if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) { - scale = MIN(MAX(scale, 0.01), 1); + scale = MIN(MAX(scale, 0.01), 1); CGFloat actualScale = scale; scale = 1 - scale; RAPreservedWindowInformation info = [RAWindowStatePreservationSystemManager.sharedInstance windowInformationForAppIdentifier:topApp.bundleIdentifier]; @@ -108,7 +108,7 @@ BOOL locationIsInValidArea(CGFloat x) else { appView.transform = CGAffineTransformMakeScale(0.5, 0.5); - appView.center = originalCenter; + appView.center = originalCenter; } } completion:^(BOOL _) { RAIconIndicatorViewInfo indicatorInfo = [[%c(RABackgrounder) sharedInstance] allAggregatedIndicatorInfoForIdentifier:topApp.bundleIdentifier]; @@ -116,6 +116,11 @@ BOOL locationIsInValidArea(CGFloat x) // Close app [[%c(RABackgrounder) sharedInstance] temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:topApp andCloseForegroundApp:NO]; FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; + [deactiveSets setFlag:YES forDeactivationSetting:20]; + [deactiveSets setFlag:NO forDeactivationSetting:2]; + [topApp _setDeactivationSettings:deactiveSets]; + SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; [transaction begin]; @@ -147,4 +152,4 @@ BOOL locationIsInValidArea(CGFloat x) } withCondition:^BOOL(CGPoint location, CGPoint velocity) { return [RASettings.sharedInstance windowedMultitaskingEnabled] && (locationIsInValidArea(location.x) || appView) && ![[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && [UIApplication.sharedApplication _accessibilityFrontMostApplication] != nil && ![[%c(SBNotificationCenterController) sharedInstance] isVisible]; } forEdge:UIRectEdgeBottom identifier:@"com.efrederickson.reachapp.windowedmultitasking.systemgesture" priority:RAGesturePriorityDefault]; -} \ No newline at end of file +} diff --git a/headers.h b/headers.h index 2935991..076c8e0 100644 --- a/headers.h +++ b/headers.h @@ -75,7 +75,16 @@ extern BOOL $__IS_SPRINGBOARD; #define kBGModeBluetoothPeripheral @"bluetooth-peripheral" // newsstand-content -extern "C" CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); +#ifdef __cplusplus +extern "C" { +#endif + +CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); +void BKSHIDServicesCancelTouchesOnMainDisplay(); + +#ifdef __cplusplus +} +#endif #define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI)) #define DEGREES_TO_RADIANS(radians) ((radians) * (M_PI / 180)) @@ -99,8 +108,6 @@ return sharedInstance; #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) -extern "C" void BKSHIDServicesCancelTouchesOnMainDisplay(); - //////////////////////////////////////////////////////////////////////////////////////////////// @interface UIRemoteKeyboardWindow : UIWindow //UITextEffectsWindow @@ -1453,3 +1460,8 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (id)noticesBulletinIDsForSectionID:(id)arg1; - (id)bulletinIDsForSectionID:(id)arg1 inFeed:(unsigned long long)arg2; @end + +@interface FBSystemService : NSObject +- (id)sharedInstance; +- (void)exitAndRelaunch:(bool)arg1; +@end diff --git a/reachappassertiondhooks/Makefile b/reachappassertiondhooks/Makefile index 3f531be..54b7675 100644 --- a/reachappassertiondhooks/Makefile +++ b/reachappassertiondhooks/Makefile @@ -1,6 +1,5 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -fno-objc-arc -LDFLAGS += -Wl,-segalign,4000 +CFLAGS = -fno-objc-arc -O2 include $(THEOS)/makefiles/common.mk diff --git a/reachappassertiondhooks/Tweak.xm b/reachappassertiondhooks/Tweak.xm index a656765..b7b6ce8 100644 --- a/reachappassertiondhooks/Tweak.xm +++ b/reachappassertiondhooks/Tweak.xm @@ -1,29 +1,13 @@ #import -#import #import -extern const char *__progname; +@interface BSAuditToken : NSObject +- (int)pid; + @end -static int (*orig_BSAuditTokenTaskHasEntitlement)(id connection, NSString *entitlement); -static int hax_BSAuditTokenTaskHasEntitlement(__unsafe_unretained id connection, __unsafe_unretained NSString *entitlement) -{ - if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) - { - // We could check if the connection's pid matches SpringBoard's pid, but at this point I don't think it really matters - // I mean, what could be the worst thing a process can do by making BKSProcessAssertions? slaughtering battery? suspending/keeping apps running? - return true; - } - - return orig_BSAuditTokenTaskHasEntitlement(connection, entitlement); +%hookf(BOOL, "_BSAuditTokenTaskHasEntitlement", BSAuditToken *token, NSString *entitlement) { + if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { + return YES; + } + return %orig; } - -%ctor -{ - // We can never be too sure - if (strcmp(__progname, "assertiond") == 0) - { - dlopen("/System/Library/PrivateFrameworks/XPCObjects.framework/XPCObjects", RTLD_LAZY); - void *xpcFunction = MSFindSymbol(NULL, "_BSAuditTokenTaskHasEntitlement"); - MSHookFunction(xpcFunction, (void *)hax_BSAuditTokenTaskHasEntitlement, (void **)&orig_BSAuditTokenTaskHasEntitlement); - } -} \ No newline at end of file diff --git a/reachappfakephonemode/Makefile b/reachappfakephonemode/Makefile index 9664d58..8e0e720 100644 --- a/reachappfakephonemode/Makefile +++ b/reachappfakephonemode/Makefile @@ -1,7 +1,6 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming -LDFLAGS += -Wl,-segalign,4000 +CFLAGS = -I../ -I../Theming -O2 include $(THEOS)/makefiles/common.mk diff --git a/reachappfsdaemon/Makefile b/reachappfsdaemon/Makefile index febea2b..1e9647b 100644 --- a/reachappfsdaemon/Makefile +++ b/reachappfsdaemon/Makefile @@ -1,6 +1,5 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming -LDFLAGS += -Wl,-segalign,4000 +CFLAGS = -I../ -I../Theming -O2 include $(THEOS)/makefiles/common.mk diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index f3aa58c..d972532 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -12,7 +12,7 @@ int main(int argc, char **argv, char **envp) { NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) { - NSLog(@"[ReachApp] FS Daemon: plist does not exist"); + HBLogError(@"[ReachApp] FS Daemon: plist does not exist"); return 0; } @@ -31,4 +31,4 @@ int main(int argc, char **argv, char **envp) { [pool release]; return 0; -} \ No newline at end of file +} diff --git a/widgets/Reachability/RAAllAppsWidget.xm b/widgets/Reachability/RAAllAppsWidget.xm index e4b1228..1710b93 100644 --- a/widgets/Reachability/RAAllAppsWidget.xm +++ b/widgets/Reachability/RAAllAppsWidget.xm @@ -42,7 +42,11 @@ static NSMutableArray *allApps = nil; if (!allApps) { - allApps = [[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] mutableCopy]; + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + allApps = [[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] mutableCopy]; + } else { + allApps = [[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] mutableCopy]; + } [allApps sortUsingComparator: ^(NSString* a, NSString* b) { NSString *a_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:a].displayName; NSString *b_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:b].displayName; @@ -57,12 +61,19 @@ for (NSString *str in allApps) { app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:str]; - SBIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; - SBIconView *iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + SBApplicationIcon *icon = nil; + SBIconView *iconView = nil; + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; + iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + } else { + icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; + iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; + } if (!iconView || [icon isKindOfClass:[%c(SBApplicationIcon) class]] == NO) continue; - - if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) + + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { if (isTop) { @@ -109,4 +120,4 @@ { static id _widget = [[RAAllAppsWidget alloc] init]; [RAWidgetSectionManager.sharedInstance registerSection:_widget]; -} \ No newline at end of file +} diff --git a/widgets/Reachability/RAFavoriteAppsWidget.xm b/widgets/Reachability/RAFavoriteAppsWidget.xm index 3678f27..2be940a 100644 --- a/widgets/Reachability/RAFavoriteAppsWidget.xm +++ b/widgets/Reachability/RAFavoriteAppsWidget.xm @@ -44,11 +44,18 @@ for (NSString *str in favorites) { app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:str]; - SBIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; - SBIconView *iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + SBApplicationIcon *icon = nil; + SBIconView *iconView = nil; + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; + iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + } else { + icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; + iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; + } if (!iconView) continue; - + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { if (isTop) @@ -97,4 +104,4 @@ { static id _widget = [[RAFavoriteAppsWidget alloc] init]; [RAWidgetSectionManager.sharedInstance registerSection:_widget]; -} \ No newline at end of file +} diff --git a/widgets/Reachability/RARecentAppsWidget.xm b/widgets/Reachability/RARecentAppsWidget.xm index 19da1a3..4070b5f 100644 --- a/widgets/Reachability/RARecentAppsWidget.xm +++ b/widgets/Reachability/RARecentAppsWidget.xm @@ -53,11 +53,18 @@ for (NSString *str in recents) { app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:str]; - SBIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; - SBIconView *iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + SBApplicationIcon *icon = nil; + SBIconView *iconView = nil; + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; + iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + } else { + icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; + iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; + } if (!iconView) continue; - + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { if (isTop) @@ -98,7 +105,7 @@ { @autoreleasepool { //[[%c(SBWorkspace) sharedInstance] appViewItemTap:gesture]; - + RAAppSliderProvider *provider = [[RAAppSliderProvider alloc] init]; provider.availableIdentifiers = [[RAAppSwitcherModelWrapper appSwitcherAppIdentiferList] mutableCopy]; [((NSMutableArray*)provider.availableIdentifiers) removeObject:[[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier]; @@ -117,4 +124,4 @@ { static id _widget = [[RARecentAppsWidget alloc] init]; [RAWidgetSectionManager.sharedInstance registerSection:_widget]; -} \ No newline at end of file +} From 0a348791861e1f4a583af8df8f7cd8fc007a0941 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Thu, 19 Jan 2017 21:24:19 -0600 Subject: [PATCH 03/59] Fixed Headers --- Backgrounding/RABackgrounder.xm | 44 +++++++++++-------- Makefile | 2 +- Messaging/RAMessaging.h | 2 +- MissionControl/Makefile | 3 +- MissionControl/RAMissionControlPreviewView.h | 4 +- MissionControl/RAMissionControlPreviewView.xm | 21 ++++++--- RAAppSelectorView.xm | 23 +++++++--- RASettings.h | 4 ++ RASnapshotProvider.xm | 2 +- Reachability/Reachability.xm | 3 +- SwipeOver/Makefile | 5 +-- SwipeOver/RASwipeOverOverlay.h | 4 +- WindowedMultitasking/RAWindowBar.h | 4 +- headers.h | 34 ++++++++++++-- 14 files changed, 106 insertions(+), 49 deletions(-) diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index bc3839a..a533a35 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -32,7 +32,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; -(BOOL) shouldAutoLaunchApplication:(NSString*)identifier { if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return NO; - + NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && ([dict objectForKey:@"autoLaunch"] == nil ? NO : [dict[@"autoLaunch"] boolValue]); @@ -41,7 +41,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; -(BOOL) shouldAutoRelaunchApplication:(NSString*)identifier { if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return NO; - + NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; return [self killProcessOnExit:identifier] == NO && [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && ([dict objectForKey:@"autoRelaunch"] == nil ? NO : [dict[@"autoRelaunch"] boolValue]); @@ -71,7 +71,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; if ([temporaryShouldPop objectForKey:identifier] != nil && [[temporaryShouldPop objectForKey:identifier] boolValue]) { [temporaryShouldPop removeObjectForKey:identifier]; - [temporaryOverrides removeObjectForKey:identifier]; + [temporaryOverrides removeObjectForKey:identifier]; } } @@ -99,7 +99,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; -(BOOL) preventKillingOfIdentifier:(NSString*)identifier { if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return NO; - + NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && ([dict objectForKey:@"preventDeath"] == nil ? NO : [dict[@"preventDeath"] boolValue]); @@ -108,7 +108,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; -(BOOL) shouldRemoveFromSwitcherWhenKilledOnExit:(NSString*)identifier { if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return NO; - + NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"removeFromSwitcher"] ? [dict[@"removeFromSwitcher"] boolValue] : NO; return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && ([dict objectForKey:@"removeFromSwitcher"] == nil ? NO : [dict[@"removeFromSwitcher"] boolValue]); @@ -194,19 +194,25 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; { @autoreleasepool { SBIconView *ret = nil; - if ([[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) - { - // iOS 8.0+ - - SBIcon *icon = [[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; - ret = [[objc_getClass("SBIconViewMap") homescreenMap] mappedIconViewForIcon:icon]; - } - else - { - // iOS 7.X - SBIcon *icon = [[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; - ret = [[objc_getClass("SBIconViewMap") homescreenMap] mappedIconViewForIcon:icon]; - } + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + if ([[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) + { + // iOS 8.0+ + + SBApplicationIcon *icon = [[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; + ret = [[objc_getClass("SBIconViewMap") homescreenMap] mappedIconViewForIcon:icon]; + } + else + { + // iOS 7.X + SBApplicationIcon *icon = [[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; + ret = [[objc_getClass("SBIconViewMap") homescreenMap] mappedIconViewForIcon:icon]; + } + } else { + SBApplicationIcon *icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:identifier]; + ret = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] mappedIconViewForIcon:icon]; + } + [ret RA_updateIndicatorView:info]; } @@ -225,4 +231,4 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; BOOL globalSetting = [[%c(RASettings) sharedInstance] shouldShowStatusBarIcons]; return globalSetting ? ([dct objectForKey:@"showStatusBarIcon"] == nil ? YES : [dct[@"showStatusBarIcon"] boolValue]) : NO; } -@end \ No newline at end of file +@end diff --git a/Makefile b/Makefile index e0f7297..d650cec 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ DEBUG = 1 ARCHS = armv7 armv7s arm64 -CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ +CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ -Wno-deprecated-declarations CFLAGS += -fobjc-arc -O2 THEOS_PACKAGE_DIR_NAME = debs TARGET = iphone:9.2 diff --git a/Messaging/RAMessaging.h b/Messaging/RAMessaging.h index f50d36b..f51dea0 100644 --- a/Messaging/RAMessaging.h +++ b/Messaging/RAMessaging.h @@ -7,7 +7,7 @@ typedef NS_ENUM(NSInteger, RAMessageType) { RAMessageTypeHideKeyboard, RAMessageTypeUpdateKeyboardContextId, RAMessageTypeRetrieveKeyboardContextId, -} RAMessageType; +}; typedef struct { BOOL shouldForceSize; diff --git a/MissionControl/Makefile b/MissionControl/Makefile index 897e584..6ca74ed 100644 --- a/MissionControl/Makefile +++ b/MissionControl/Makefile @@ -1,8 +1,7 @@ ARCHS = armv7 armv7s arm64 CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -CFLAGS += -fobjc-arc -LDFLAGS += -Wl,-segalign,4000 +CFLAGS += -fobjc-arc -O2 include $(THEOS)/makefiles/common.mk diff --git a/MissionControl/RAMissionControlPreviewView.h b/MissionControl/RAMissionControlPreviewView.h index 508fb9d..0599dce 100644 --- a/MissionControl/RAMissionControlPreviewView.h +++ b/MissionControl/RAMissionControlPreviewView.h @@ -1,7 +1,7 @@ #import "headers.h" @interface RAMissionControlPreviewView : UIImageView { - SBIcon *icon; + SBApplicationIcon *icon; SBIconView *iconView; } @property (nonatomic, retain) SBApplication *application; @@ -9,4 +9,4 @@ -(void) generatePreview; -(void) generatePreviewAsync; -(void) generateDesktopPreviewAsync:(id)desktop completion:(dispatch_block_t)completionBlock; -@end \ No newline at end of file +@end diff --git a/MissionControl/RAMissionControlPreviewView.xm b/MissionControl/RAMissionControlPreviewView.xm index f2880f9..aced907 100644 --- a/MissionControl/RAMissionControlPreviewView.xm +++ b/MissionControl/RAMissionControlPreviewView.xm @@ -17,10 +17,21 @@ NSOperationQueue* targetQueue = [NSOperationQueue mainQueue]; [targetQueue addOperationWithBlock:^{ - if (!icon) - icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; - if (icon && !iconView) - iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + if (!icon) { + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; + } else { + icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; + } + } + if (icon && !iconView) { + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + } else { + iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; + } + } + }]; [targetQueue waitUntilAllOperationsAreFinished]; @@ -63,4 +74,4 @@ [self bringSubviewToFront:iconView]; iconView.frame = CGRectMake( (self.frame.size.width / 2) - (iconView.frame.size.width / 2), (self.frame.size.height / 2) - (iconView.frame.size.height / 2), iconView.frame.size.width, iconView.frame.size.height ); } -@end \ No newline at end of file +@end diff --git a/RAAppSelectorView.xm b/RAAppSelectorView.xm index 8155789..3b330ce 100644 --- a/RAAppSelectorView.xm +++ b/RAAppSelectorView.xm @@ -33,7 +33,11 @@ static NSMutableArray *allApps = nil; if (!allApps) { - allApps = [[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] mutableCopy]; + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + allApps = [[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] mutableCopy]; + } else { + allApps = [[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] mutableCopy]; + } [allApps sortUsingComparator: ^(NSString* a, NSString* b) { NSString *a_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:a].displayName; NSString *b_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:b].displayName; @@ -42,13 +46,20 @@ //[allApps removeObject:currentBundleIdentifier]; } for (NSString *str in allApps) - { + { SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:str]; - SBIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; - SBIconView *iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + SBApplicationIcon *icon = nil; + SBIconView *iconView = nil; + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; + iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + } else { + icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; + iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; + } if (!iconView || [icon isKindOfClass:[%c(SBApplicationIcon) class]] == NO) continue; - + iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); contentSize.width += iconView.frame.size.width + padding; @@ -76,4 +87,4 @@ if ([self.target respondsToSelector:@selector(appSelector:appWasSelected:)]) [self.target appSelector:self appWasSelected:recognizer.view.restorationIdentifier]; } -@end \ No newline at end of file +@end diff --git a/RASettings.h b/RASettings.h index cb010d9..36e3499 100644 --- a/RASettings.h +++ b/RASettings.h @@ -78,6 +78,10 @@ typedef NS_ENUM(NSInteger, RAGrabArea) { -(BOOL) quickAccessUseGenericTabLabel; +#if DEBUG +-(BOOL) debug_showIPCMessages; +#endif + -(BOOL) windowedMultitaskingEnabled; -(NSInteger) windowRotationLockMode; -(RAGrabArea) windowedMultitaskingGrabArea; diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index 3011233..d3bf243 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -38,7 +38,7 @@ } else { - SBApplication *app = [[%c(SBApplicationController) sharedInstance] ZY_applicationWithBundleIdentifier:identifier]; + SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; view = [[%c(SBAppSwitcherSnapshotView) alloc] initWithDisplayItem:item application:app orientation:orientation preferringDownscaledSnapshot:NO async:NO withQueue:nil]; } }); diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 7f00eae..6617715 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -11,6 +11,7 @@ #import "RAWidgetSectionManager.h" #import "RASettings.h" #import "RAAppSliderProviderView.h" +#import "RABackgrounder.h" #import "RADesktopManager.h" #import "RADesktopWindow.h" #import "RAMessagingServer.h" @@ -376,7 +377,7 @@ id SBWorkspace$sharedInstance; [draggerView addGestureRecognizer:recognizer]; UILongPressGestureRecognizer *recognizer2 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(RA_handleLongPress:)]; - recognizer2.delegate = (id)self; + recognizer2.delegate = (id)self; [draggerView addGestureRecognizer:recognizer2]; UITapGestureRecognizer *recognizer3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(RA_detachAppAndClose:)]; diff --git a/SwipeOver/Makefile b/SwipeOver/Makefile index 4ca58cf..685cf30 100644 --- a/SwipeOver/Makefile +++ b/SwipeOver/Makefile @@ -1,8 +1,7 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -I../Messaging/ -I../KeyboardSupport -I../MissionControl -CFLAGS += -fobjc-arc -LDFLAGS += -Wl,-segalign,4000 +CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -I../Messaging/ -I../KeyboardSupport -I../MissionControl -Wno-deprecated-declarations +CFLAGS += -fobjc-arc -O2 include $(THEOS)/makefiles/common.mk TWEAK_NAME = ReachAppSwipeOver diff --git a/SwipeOver/RASwipeOverOverlay.h b/SwipeOver/RASwipeOverOverlay.h index 82fc7d3..5a05f7a 100644 --- a/SwipeOver/RASwipeOverOverlay.h +++ b/SwipeOver/RASwipeOverOverlay.h @@ -1,7 +1,7 @@ #import "headers.h" #import "RAAppSelectorView.h" -@interface RASwipeOverOverlay : UIAutoRotatingWindow { +@interface RASwipeOverOverlay : UIAutoRotatingWindow { BOOL isHidingUnderlyingApp; UIView *darkenerView; @@ -17,4 +17,4 @@ -(void) showAppSelector; -(UIView*) currentView; -@end \ No newline at end of file +@end diff --git a/WindowedMultitasking/RAWindowBar.h b/WindowedMultitasking/RAWindowBar.h index de233bd..48eff43 100644 --- a/WindowedMultitasking/RAWindowBar.h +++ b/WindowedMultitasking/RAWindowBar.h @@ -3,7 +3,7 @@ @class RADesktopWindow; -@interface RAWindowBar : UIView { +@interface RAWindowBar : UIView { RAHostedAppView *attachedView; } @@ -35,4 +35,4 @@ -(void) resignForemostApp; -(void) becomeForemostApp; -@end \ No newline at end of file +@end diff --git a/headers.h b/headers.h index 076c8e0..9d65b5f 100644 --- a/headers.h +++ b/headers.h @@ -378,7 +378,7 @@ return sharedInstance; @end typedef struct { - BOOL itemIsEnabled[25]; + BOOL itemIsEnabled[29]; char timeString[64]; int gsmSignalStrengthRaw; int gsmSignalStrengthBars; @@ -405,6 +405,11 @@ typedef struct { unsigned locationIconType : 1; unsigned quietModeInactive : 1; unsigned tetheringConnectionCount; + unsigned batterySaverModeActive : 1; + unsigned deviceIsRTL : 1; + char breadcrumbTitle[256]; + char breadcrumbSecondaryTitle[256]; + char personName[100]; } StatusBarData; @interface UIStatusBar : UIView @@ -726,6 +731,7 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @interface SBMainWorkspaceTransitionRequest : NSObject - (id)initWithDisplay:(id)arg1; +- (void)setApplicationContext:(SBWorkspaceApplicationTransitionContext *)arg1 ; @end @interface SBAppToAppWorkspaceTransaction @@ -1386,9 +1392,9 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) +(Class)iconViewClassForIcon:(SBIcon *)icon location:(int)location; -(id)init; -(void)dealloc; --(SBIconView *)mappedIconViewForIcon:(SBIcon *)icon; --(SBIconView *)_iconViewForIcon:(SBIcon *)icon; --(SBIconView *)iconViewForIcon:(SBIcon *)icon; +-(SBIconView *)mappedIconViewForIcon:(SBApplicationIcon *)icon; +-(SBIconView *)_iconViewForIcon:(SBApplicationIcon *)icon; +-(SBIconView *)iconViewForIcon:(SBApplicationIcon *)icon; -(void)_addIconView:(SBIconView *)iconView forIcon:(SBIcon *)icon; -(void)purgeIconFromMap:(SBIcon *)icon; -(void)_recycleIconView:(SBIconView *)iconView; @@ -1408,6 +1414,11 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) @property (nonatomic, readonly) SBIconModel *iconModel; @end +@interface SBIconController (iOS90) +@property (nonatomic,readonly) SBIconViewMap *homescreenIconViewMap; ++ (id)sharedInstance; +@end + @interface SBApplication (iOS6) - (BOOL)isRunning; - (id)badgeNumberOrString; @@ -1465,3 +1476,18 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (id)sharedInstance; - (void)exitAndRelaunch:(bool)arg1; @end + +@interface SBSwitcherSnapshotImageView : UIView +@property (nonatomic,readonly) UIImage * image; +- (UIImage *)image; +@end + +@interface _SBAppSwitcherSnapshotContext : NSObject { + SBSwitcherSnapshotImageView* _snapshotImageView; +} +@property (nonatomic,retain) SBSwitcherSnapshotImageView * snapshotImageView; //@synthesize snapshotImageView=_snapshotImageView - In the implementation block +- (SBSwitcherSnapshotImageView *)snapshotImageView; +- (void)setSnapshotImageView:(SBSwitcherSnapshotImageView *)arg1 ; +- (CGRect)snapshotReferenceFrame; +- (void)setSnapshotReferenceFrame:(CGRect)arg1 ; +@end From d7492ed9e78b8f20a33da7d5c9a5793e000da330 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 20 Jan 2017 19:06:53 -0600 Subject: [PATCH 04/59] More Fixes --- Makefile | 1 - reachappbackboarddhooks/Makefile | 6 +-- reachappbackboarddhooks/Tweak.xm | 37 +++++++------------ .../BackgroundPerAppDetailsController.h | 3 +- reachappsettings/BackgrounderPerApp.xm | 37 ++++++++++--------- reachappsettings/BackgrounderSettings.xm | 23 +++++++----- reachappsettings/Makefile | 7 ++-- reachappsettings/MissionControlSettings.xm | 13 ++++--- reachappsettings/NCApp.xm | 27 ++++++++------ reachappsettings/RAListItemsController.xm | 21 ++++++----- reachappsettings/RASupportController.xm | 9 +++-- reachappsettings/ReachAppSettings.mm | 23 +++++++----- reachappsettings/Reachability.xm | 29 ++++++++------- reachappsettings/SwipeOver.xm | 10 +++-- reachappsettings/WindowedMultitasking.xm | 15 +++++--- 15 files changed, 139 insertions(+), 122 deletions(-) diff --git a/Makefile b/Makefile index d650cec..568cf57 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ DEBUG = 1 ARCHS = armv7 armv7s arm64 CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ -Wno-deprecated-declarations CFLAGS += -fobjc-arc -O2 -THEOS_PACKAGE_DIR_NAME = debs TARGET = iphone:9.2 include $(THEOS)/makefiles/common.mk diff --git a/reachappbackboarddhooks/Makefile b/reachappbackboarddhooks/Makefile index 96cb14f..1c7690e 100644 --- a/reachappbackboarddhooks/Makefile +++ b/reachappbackboarddhooks/Makefile @@ -1,13 +1,13 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../Messaging/ +CFLAGS = -I../Messaging/ -O2 #CFLAGS += -fno-objc-arc -LDFLAGS += -Wl,-segalign,4000 include $(THEOS)/makefiles/common.mk TWEAK_NAME = ReachAppBackboarddHooks ReachAppBackboarddHooks_FILES = Tweak.xm -ReachAppBackboarddHooks_LIBRARIES = IOKit +ReachAppBackboarddHooks_PRIVATE_FRAMEWORKS = AppSupport IOKit +ReachAppBackboarddHooks_LIBRARIES = rocketbootstrap include $(THEOS_MAKE_PATH)/tweak.mk diff --git a/reachappbackboarddhooks/Tweak.xm b/reachappbackboarddhooks/Tweak.xm index 98c4298..03cc7e0 100644 --- a/reachappbackboarddhooks/Tweak.xm +++ b/reachappbackboarddhooks/Tweak.xm @@ -1,15 +1,16 @@ #import -#import +#import #import #import "RAMessaging.h" #import +#import #define CTRL_KEY 224 -#define CMD_KEY 231 +#define CMD_KEY 231 #define CMD_KEY2 227 #define SHIFT_KEY 229 #define SHIFT_KEY2 225 -#define ALT_KEY 226 +#define ALT_KEY 226 #define ALT_KEY2 230 #define D_KEY 7 #define P_KEY 19 @@ -31,7 +32,7 @@ CPDistributedMessagingCenter *center; // TODO: Ensure all keyboard commands do not conflict with // https://support.apple.com/en-us/HT201236 -void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event) +void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event) { if (IOHIDEventGetType(event) == kIOHIDEventTypeKeyboard) { @@ -84,7 +85,7 @@ void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEven } else if (key == ARROW_DOWN_KEY) { - [center sendMessageName:RAMessagingCloseAppMessageName userInfo:nil]; + [center sendMessageName:RAMessagingCloseAppMessageName userInfo:nil]; } } } @@ -92,11 +93,9 @@ void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEven eventCallback(target, refcon, service, event); } -Boolean (*orig$IOHIDEventSystemOpen)(IOHIDEventSystemRef system, IOHIDEventSystemCallback callback, void* target, void* refcon, void* unused); -Boolean hook$IOHIDEventSystemOpen(IOHIDEventSystemRef system, IOHIDEventSystemCallback callback, void* target, void* refcon, void* unused) -{ +%hookf(Boolean, "_IOHIDEventSystemOpen", IOHIDEventSystemRef system, IOHIDEventSystemCallback callback, void* target, void* refcon, void* unused) { eventCallback = callback; - return orig$IOHIDEventSystemOpen(system, handle_event, target, refcon, unused); + return %orig; } %hook BKEventFocusManager @@ -104,7 +103,7 @@ Boolean hook$IOHIDEventSystemOpen(IOHIDEventSystemRef system, IOHIDEventSystemCa -(id ) initWithPid:(unsigned int)arg1 clientID:(NSString*)arg2; @end --(id) destinationForFocusedEventWithDisplay:(__unsafe_unretained id)arg1 +-(id) destinationForFocusedEventWithDisplay:(__unsafe_unretained id)arg1 { NSDictionary *response = [center sendMessageAndReceiveReplyName:RAMessagingGetFrontMostAppInfoMessageName userInfo:nil]; @@ -144,7 +143,7 @@ Boolean hook$IOHIDEventSystemOpen(IOHIDEventSystemRef system, IOHIDEventSystemCa UIGraphicsPopContext(); CGContextRelease(context); CGFloat alpha = pixel[0]/255.0f; - BOOL transparent = alpha < 1.f; + BOOL transparent = alpha < 1.f; if (!transparent) return cid; } @@ -156,16 +155,6 @@ Boolean hook$IOHIDEventSystemOpen(IOHIDEventSystemRef system, IOHIDEventSystemCa %ctor { - MSHookFunction(&IOHIDEventSystemOpen, hook$IOHIDEventSystemOpen, &orig$IOHIDEventSystemOpen); - - center = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - - void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if(handle) - { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*); - rocketbootstrap_distributedmessagingcenter_apply = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(center); - dlclose(handle); - } -} \ No newline at end of file + center = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + rocketbootstrap_distributedmessagingcenter_apply(center); +} diff --git a/reachappsettings/BackgroundPerAppDetailsController.h b/reachappsettings/BackgroundPerAppDetailsController.h index 84b1a22..57ca3c3 100644 --- a/reachappsettings/BackgroundPerAppDetailsController.h +++ b/reachappsettings/BackgroundPerAppDetailsController.h @@ -1,5 +1,6 @@ #import "headers.h" #import +#import @interface RABGPerAppDetailsController : SKTintedListController { @@ -7,4 +8,4 @@ NSString* _identifier; } -(id)initWithAppName:(NSString*)appName identifier:(NSString*)identifier; -@end \ No newline at end of file +@end diff --git a/reachappsettings/BackgrounderPerApp.xm b/reachappsettings/BackgrounderPerApp.xm index 3e1ffb6..8ce6e1a 100644 --- a/reachappsettings/BackgrounderPerApp.xm +++ b/reachappsettings/BackgrounderPerApp.xm @@ -1,6 +1,9 @@ -#import +#import +#import +#import +#import #import -#import +#import #import #import #import "BackgroundPerAppDetailsController.h" @@ -51,16 +54,16 @@ void RA_BGAppsControllerNeedsToReload() -(void)updateDataSource:(NSString*)searchText { NSNumber *iconSize = [NSNumber numberWithUnsignedInteger:ALApplicationIconSizeSmall]; - + NSString *enabledList = @""; CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (keyList) + if (keyList) { NSDictionary *prefs = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); CFRelease(keyList); - if (prefs) + if (prefs) { NSArray *apps = [[ALApplicationList sharedApplicationList] applications].allKeys; for (NSString* identifier in apps) @@ -74,7 +77,7 @@ void RA_BGAppsControllerNeedsToReload() } enabledList = [enabledList stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]; NSString* filter = (searchText && searchText.length > 0) ? [NSString stringWithFormat:@"displayName beginsWith[cd] '%@'", searchText] : nil; - + if (filter) { _dataSource.sectionDescriptors = [NSArray arrayWithObjects: @@ -130,27 +133,27 @@ void RA_BGAppsControllerNeedsToReload() -(id)init { if (!(self = [super init])) return nil; - + CGRect bounds = [[UIScreen mainScreen] bounds]; - + _dataSource = [[ALApplicationTableDataSource alloc] init]; - + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _tableView.delegate = self; _tableView.dataSource = _dataSource; _dataSource.tableView = _tableView; [self updateDataSource:nil]; - + return self; } -(void)viewDidLoad { ((UIViewController *)self).title = @"Applications"; - + [self.view addSubview:_tableView]; - + [super viewDidLoad]; } @@ -161,7 +164,7 @@ void RA_BGAppsControllerNeedsToReload() [self updateDataSource:nil]; reload = NO; } - + ((UIView*)self.view).tintColor = self.tintColor; self.navigationController.navigationBar.tintColor = self.tintColor; @@ -172,13 +175,13 @@ void RA_BGAppsControllerNeedsToReload() -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath]; - + // Need to mimic what PSListController does when it handles didSelectRowAtIndexPath // otherwise the child controller won't load RABGPerAppDetailsController *controller = [[RABGPerAppDetailsController alloc] initWithAppName:cell.textLabel.text identifier:[_dataSource displayIdentifierForIndexPath:indexPath]]; controller.rootController = self.rootController; controller.parentController = self; - + [self pushController:controller]; [tableView deselectRowAtIndexPath:indexPath animated:true]; } @@ -187,9 +190,9 @@ void RA_BGAppsControllerNeedsToReload() - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - + ((UIView*)self.view).tintColor = nil; self.navigationController.navigationBar.tintColor = nil; } -@end \ No newline at end of file +@end diff --git a/reachappsettings/BackgrounderSettings.xm b/reachappsettings/BackgrounderSettings.xm index 758f6ee..8675dd1 100644 --- a/reachappsettings/BackgrounderSettings.xm +++ b/reachappsettings/BackgrounderSettings.xm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import #import #import @@ -36,9 +39,9 @@ -(UIView*) headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ - (id) [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:255/255.0f green:111/255.0f blue:124/255.0f alpha:1.0f].CGColor + header.colors = @[ + (id) [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:255/255.0f green:111/255.0f blue:124/255.0f alpha:1.0f].CGColor ]; header.shouldBlend = NO; header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/BackgrounderHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(15, 33)]]; @@ -92,7 +95,7 @@ }, @{ @"label": @"Global", @"footerText": @"" }, - + @{ @"cell": @"PSLinkListCell", @"label": @"Background Mode", @@ -115,7 +118,7 @@ @"cell": @"PSLinkListCell", @"detail": @"RABackgrounderStatusbarOptionsListController", @"label": @"Status Bar Indicator Options", - }, + }, @{ @"label": @"Specific" }, @{ @"cell": @"PSLinkCell", @@ -137,7 +140,7 @@ { LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.backgrounder.togglemode"; - [self.rootController pushViewController:vc animated:YES]; + [self.rootController pushController:vc animate:YES]; } } @end @@ -148,7 +151,7 @@ @implementation RABackgrounderIconIndicatorOptionsListController -(UIColor*) navigationTintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } -(BOOL) showHeartImage { return NO; } --(NSArray*) customSpecifiers +-(NSArray*) customSpecifiers { return @[ @{ @@ -177,7 +180,7 @@ @implementation RABackgrounderStatusbarOptionsListController -(UIColor*) navigationTintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } -(BOOL) showHeartImage { return NO; } --(NSArray*) customSpecifiers +-(NSArray*) customSpecifiers { return @[ @{ @@ -195,7 +198,7 @@ @"key": @"shouldShowStatusBarNativeIcons", @"defaults": @"com.efrederickson.reachapp.settings", @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, + }, ]; } @end diff --git a/reachappsettings/Makefile b/reachappsettings/Makefile index de71efd..d414c35 100644 --- a/reachappsettings/Makefile +++ b/reachappsettings/Makefile @@ -1,13 +1,12 @@ ARCHS = armv7 armv7s arm64 -TARGET = iPhone:clang:latest:latest -CFLAGS = -fobjc-arc -I../ -I../Backgrounding/ -I../Theming/ -I../NotificationCenterApp +TARGET = iphone:9.2 +CFLAGS = -fobjc-arc -I../ -I../Backgrounding/ -I../Theming/ -I../NotificationCenterApp -Wno-deprecated-declarations LDFLAGS = -F$(THEOS)/frameworks -LDFLAGS += -Wl,-segalign,4000 include $(THEOS)/makefiles/common.mk BUNDLE_NAME = ReachAppSettings -ReachAppSettings_FILES = ReachAppSettings.mm $(shell find $(THEOS)/include/SettingsKit -name '*.m') $(wildcard *.xm) RAHeaderView.mm ../PDFImageOptions.m ../PDFImage.m ../RALocalizer.mm ../RASettings.mm $(wildcard ../Theming/*.mm) +ReachAppSettings_FILES = ReachAppSettings.mm $(shell find $(THEOS)/include/SettingsKit -name '*.m') $(wildcard *.xm) RAHeaderView.mm ../PDFImageOptions.m ../PDFImage.m ../RALocalizer.mm ../RASettings.mm $(wildcard ../Theming/*.mm) ReachAppSettings_INSTALL_PATH = /Library/PreferenceBundles ReachAppSettings_FRAMEWORKS = UIKit MessageUI Social QuartzCore CoreGraphics ReachAppSettings_LIBRARIES = applist substrate diff --git a/reachappsettings/MissionControlSettings.xm b/reachappsettings/MissionControlSettings.xm index 2a03fb4..0e57764 100644 --- a/reachappsettings/MissionControlSettings.xm +++ b/reachappsettings/MissionControlSettings.xm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import #import #import @@ -34,9 +37,9 @@ -(UIView*) headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ + header.colors = @[ (id) [UIColor colorWithRed:255/255.0f green:205/255.0f blue:2/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:255/255.0f green:227/255.0f blue:113/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:255/255.0f green:227/255.0f blue:113/255.0f alpha:1.0f].CGColor, ]; header.shouldBlend = NO; header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/MissionControlHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(32, 32)]]; @@ -129,7 +132,7 @@ { LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.missioncontrol.activatorlistener"; - [self.rootController pushViewController:vc animated:YES]; + [self.rootController pushController:vc animate:YES]; } } -@end \ No newline at end of file +@end diff --git a/reachappsettings/NCApp.xm b/reachappsettings/NCApp.xm index 5a6629a..c179433 100644 --- a/reachappsettings/NCApp.xm +++ b/reachappsettings/NCApp.xm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import #import #import @@ -33,9 +36,9 @@ -(UIView*) headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)]; - header.colors = @[ + header.colors = @[ (id) [UIColor colorWithRed:90/255.0f green:212/255.0f blue:39/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:164/255.0f green:231/255.0f blue:134/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:164/255.0f green:231/255.0f blue:134/255.0f alpha:1.0f].CGColor, ]; header.shouldBlend = NO; header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/NCAppHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(53, 32)]]; @@ -70,7 +73,7 @@ @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", }, @{ @"footerText": @"Instead of using the app's name, the tab label will simply show \"App\"." }, - @{ + @{ @"cell": @"PSSwitchCell", @"default": @NO, @"defaults": @"com.efrederickson.reachapp.settings", @@ -79,7 +82,7 @@ @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", }, @{ @"footerText": @"Instead of displaying a label, this will completely hide the Quick Access tab on the Lock Screen." }, - @{ + @{ @"cell": @"PSSwitchCell", @"default": @NO, @"defaults": @"com.efrederickson.reachapp.settings", @@ -164,18 +167,18 @@ -(id)init { if (!(self = [super init])) return nil; - + CGRect bounds = [[UIScreen mainScreen] bounds]; - + _dataSource = [[RANCApplicationTableDataSource alloc] init]; - + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _tableView.delegate = self; _tableView.dataSource = _dataSource; _dataSource.tableView = _tableView; [self updateDataSource:nil]; - + return self; } @@ -194,7 +197,7 @@ UITableViewCellAccessoryType type = [cell accessoryType]; BOOL selected = type == UITableViewCellAccessoryCheckmark; - + NSString *identifier = [_dataSource displayIdentifierForIndexPath:indexPath]; if (selected) CFPreferencesSetAppValue((__bridge CFStringRef)@"NCApp", (CFPropertyListRef)(identifier), CFSTR("com.efrederickson.reachapp.settings")); @@ -209,11 +212,11 @@ [alert show]; } -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex +- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); } } -@end \ No newline at end of file +@end diff --git a/reachappsettings/RAListItemsController.xm b/reachappsettings/RAListItemsController.xm index e3191bf..6a32d30 100644 --- a/reachappsettings/RAListItemsController.xm +++ b/reachappsettings/RAListItemsController.xm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import @interface PSListItemsController (tableView) @@ -14,7 +17,7 @@ @implementation RAListItemsController -(UIColor*) navigationTintColor { return [UIColor blackColor]; } -- (void)viewWillAppear:(BOOL)animated +- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; @@ -22,10 +25,10 @@ [[UIApplication sharedApplication] keyWindow].tintColor = self.navigationTintColor; } -- (void)viewWillDisappear:(BOOL)animated +- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - + [[UIApplication sharedApplication] keyWindow].tintColor = nil; self.navigationController.navigationBar.tintColor = nil; } @@ -40,7 +43,7 @@ detail:Nil cell:PSButtonCell edit:Nil]; - [themeSpecifier setProperty:RSIMG(@"tutorial.png") forKey:@"iconImage"]; + [themeSpecifier setProperty:SK_RSIMG(@"tutorial.png") forKey:@"iconImage"]; [themeSpecifier setProperty:@"poop" forKey:@"isTheming"]; _specifiers = [super specifiers]; [(NSMutableArray*)_specifiers addObject:[PSSpecifier emptyGroupSpecifier]]; @@ -74,7 +77,7 @@ @implementation RABackgroundingListItemsController -(UIColor*) navigationTintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } -- (void)viewWillAppear:(BOOL)animated +- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; @@ -82,11 +85,11 @@ [[UIApplication sharedApplication] keyWindow].tintColor = self.navigationTintColor; } -- (void)viewWillDisappear:(BOOL)animated +- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - + [[UIApplication sharedApplication] keyWindow].tintColor = nil; self.navigationController.navigationBar.tintColor = nil; } -@end \ No newline at end of file +@end diff --git a/reachappsettings/RASupportController.xm b/reachappsettings/RASupportController.xm index 0ed679b..5c3c97a 100644 --- a/reachappsettings/RASupportController.xm +++ b/reachappsettings/RASupportController.xm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import #import #import @@ -144,7 +147,7 @@ Crafted with love in 🇨🇦 and 🇺🇸. \n\ -(void) openElijahTwitter { [SKSharedHelper openTwitter:@"daementor"]; } -(void) openAndrewTwitter { [SKSharedHelper openTwitter:@"drewplex"]; } --(void) openAndiTwitter { [SKSharedHelper openTwitter:@"Nexuist"]; } +-(void) openAndiTwitter { [SKSharedHelper openTwitter:@"Nexuist"]; } -(void) openBetaPage { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://www.reddit.com/user/beta382"]]; } -(void) openChonTwitter { [SKSharedHelper openTwitter:@"HikoMitsuketa"]; } -(void) openDavidTwitter { [SKSharedHelper openTwitter:@"djaovx"]; } @@ -156,4 +159,4 @@ Crafted with love in 🇨🇦 and 🇺🇸. \n\ -(void) openSharedRoutineTwitter { [SKSharedHelper openTwitter:@"sharedRoutine"]; } -(void) openEthanTwitter { [SKSharedHelper openTwitter:@"its_not_herpes"]; } -(void) openSite { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com"]]; } -@end \ No newline at end of file +@end diff --git a/reachappsettings/ReachAppSettings.mm b/reachappsettings/ReachAppSettings.mm index 83ec02e..2b82721 100644 --- a/reachappsettings/ReachAppSettings.mm +++ b/reachappsettings/ReachAppSettings.mm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import #import #import @@ -39,9 +42,9 @@ @implementation ReachAppSettingsListController -(UIView*) headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 95)]; - header.colors = @[ - (id) [UIColor colorWithRed:234/255.0f green:152/255.0f blue:115/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:190/255.0f green:83/255.0f blue:184/255.0f alpha:1.0f].CGColor + header.colors = @[ + (id) [UIColor colorWithRed:234/255.0f green:152/255.0f blue:115/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:190/255.0f green:83/255.0f blue:184/255.0f alpha:1.0f].CGColor ]; #if DEBUG if (arc4random_uniform(1000000) == 11) @@ -153,7 +156,7 @@ -(NSArray*) customSpecifiers }, @{ @"footerText": [NSString stringWithFormat:@"%@%@", #if DEBUG - arc4random_uniform(10000) == 9901 ? @"2fast5me" : + arc4random_uniform(10000) == 9901 ? @"2fast5me" : #endif @"© 2015 Elijah Frederickson & Andrew Abosh.", #if DEBUG @@ -204,9 +207,9 @@ -(void) resetData [alert show]; } -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex +- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - if (buttonIndex == 1) + if (buttonIndex == 1) { CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.resetSettings"), nil, nil, YES); } @@ -243,15 +246,15 @@ -(void) showSupportDialog mailViewController = [[MFMailComposeViewController alloc] init]; mailViewController.mailComposeDelegate = self; [mailViewController setSubject:@"Multiplexer"]; - + struct utsname systemInfo; uname(&systemInfo); NSString *sysInfo = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; - + NSString *msg = [NSString stringWithFormat:@"\n\n%@ %@\nModel: %@\n", [UIDevice currentDevice].systemName, [UIDevice currentDevice].systemVersion, sysInfo]; [mailViewController setMessageBody:msg isHTML:NO]; [mailViewController setToRecipients:@[@"elijahandandrew@gmail.com"]]; - + [self.rootController presentViewController:mailViewController animated:YES completion:nil]; } } diff --git a/reachappsettings/Reachability.xm b/reachappsettings/Reachability.xm index 3319028..88fea7a 100644 --- a/reachappsettings/Reachability.xm +++ b/reachappsettings/Reachability.xm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import #import #import @@ -33,9 +36,9 @@ -(UIView*) headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ - (id) [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:82/255.0f green:191/255.0f blue:232/255.0f alpha:1.0f].CGColor + header.colors = @[ + (id) [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:82/255.0f green:191/255.0f blue:232/255.0f alpha:1.0f].CGColor ]; header.shouldBlend = NO; //header.title = @"ReachApp"; @@ -177,7 +180,7 @@ @implementation RAAppChooserOptionsListController -(BOOL) showHeartImage { return NO; } --(NSArray*) customSpecifiers +-(NSArray*) customSpecifiers { return @[ @{ @"footerText": @"If enabled, the app selector will scale to the size of available apps." }, @@ -189,7 +192,7 @@ @"label": @"Auto-size Widget Chooser", @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", }, - + @{ @"footerText": @"If enabled, a list of your recent apps will display in the app selector." }, @{ @"cell": @"PSSwitchCell", @@ -242,7 +245,7 @@ @interface RASwitchCell : PSSwitchTableCell //our class @end - + @implementation RASwitchCell -(id)initWithStyle:(int)arg1 reuseIdentifier:(id)arg2 specifier:(id)arg3 { //init method self = [super initWithStyle:arg1 reuseIdentifier:arg2 specifier:arg3]; //call the super init method @@ -318,18 +321,18 @@ -(id)init { if (!(self = [super init])) return nil; - + CGRect bounds = [[UIScreen mainScreen] bounds]; - + _dataSource = [[RAApplicationTableDataSource alloc] init]; - + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _tableView.delegate = self; _tableView.dataSource = _dataSource; _dataSource.tableView = _tableView; [self updateDataSource:nil]; - + return self; } @@ -348,7 +351,7 @@ UITableViewCellAccessoryType type = [cell accessoryType]; BOOL selected = type == UITableViewCellAccessoryCheckmark; - + NSString *identifier = [_dataSource displayIdentifierForIndexPath:indexPath]; CFPreferencesSetAppValue((__bridge CFStringRef)[NSString stringWithFormat:@"Favorites-%@", identifier], (CFPropertyListRef)(@(selected)), CFSTR("com.efrederickson.reachapp.settings")); @@ -356,4 +359,4 @@ CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); }); } -@end \ No newline at end of file +@end diff --git a/reachappsettings/SwipeOver.xm b/reachappsettings/SwipeOver.xm index 18cf1fd..81778c1 100644 --- a/reachappsettings/SwipeOver.xm +++ b/reachappsettings/SwipeOver.xm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import #import #import @@ -30,9 +33,9 @@ -(UIView*) headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ + header.colors = @[ (id) [UIColor colorWithRed:88/255.0f green:86/255.0f blue:214/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:198/255.0f green:68/255.0f blue:252/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:198/255.0f green:68/255.0f blue:252/255.0f alpha:1.0f].CGColor, ]; header.shouldBlend = NO; header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/SwipeOverHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(54, 32)]]; @@ -89,4 +92,3 @@ ]; } @end - diff --git a/reachappsettings/WindowedMultitasking.xm b/reachappsettings/WindowedMultitasking.xm index 268b539..5ccd042 100644 --- a/reachappsettings/WindowedMultitasking.xm +++ b/reachappsettings/WindowedMultitasking.xm @@ -1,4 +1,7 @@ -#import +#import +#import +#import +#import #import #import #import @@ -35,9 +38,9 @@ -(UIView*) headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ + header.colors = @[ (id) [UIColor colorWithRed:255/255.0f green:94/255.0f blue:58/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:255/255.0f green:149/255.0f blue:0/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:255/255.0f green:149/255.0f blue:0/255.0f alpha:1.0f].CGColor, ]; header.shouldBlend = NO; header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/EmpoleonHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(32, 32)]]; @@ -194,7 +197,7 @@ { LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.sortWindows"; - [self.rootController pushViewController:vc animated:YES]; + [self.rootController pushController:vc animate:YES]; } } @@ -210,7 +213,7 @@ { LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"; - [self.rootController pushViewController:vc animated:YES]; + [self.rootController pushController:vc animate:YES]; } } -@end \ No newline at end of file +@end From 74695572daa35c9b8f91daa9829c1167cdf44d1e Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 20 Jan 2017 20:28:37 -0600 Subject: [PATCH 05/59] Fixed NCApp --- NotificationCenterApp/NCHook.xm | 17 +++++++++-------- layout/DEBIAN/control | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index 5c23d49..06f9252 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -26,7 +26,7 @@ RANCViewController *ncAppViewController; %group iOS8 %hook SBNotificationCenterViewController -- (void)viewWillAppear:(BOOL)animated +- (void)viewWillAppear:(BOOL)animated { %orig; @@ -35,7 +35,7 @@ RANCViewController *ncAppViewController; if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) { SBModeViewController* modeVC = MSHookIvar(self, "_modeController"); - if (ncAppViewController == nil) + if (ncAppViewController == nil) ncAppViewController = [self _newBulletinObserverViewControllerOfClass:[RANCViewController class]]; [modeVC _addBulletinObserverViewController:ncAppViewController]; } @@ -43,14 +43,14 @@ RANCViewController *ncAppViewController; + (NSString *)_localizableTitleForBulletinViewControllerOfClass:(__unsafe_unretained Class)aClass { - if (aClass == [RANCViewController class]) + if (aClass == [RANCViewController class]) { BOOL useGenericLabel = THEMED(quickAccessUseGenericTabLabel) || [RASettings.sharedInstance quickAccessUseGenericTabLabel]; if (useGenericLabel) return LOCALIZE(@"APP"); return ncAppViewController.hostedApp.displayName ?: getAppName() ?: LOCALIZE(@"APP"); } - else + else return %orig; } %end @@ -58,7 +58,7 @@ RANCViewController *ncAppViewController; %group iOS9 %hook SBNotificationCenterLayoutViewController -- (void)_loadContentViewControllers +- (void)viewWillAppear:(BOOL)animated { %orig; @@ -67,15 +67,16 @@ RANCViewController *ncAppViewController; if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) { SBModeViewController* modeVC = MSHookIvar(self, "_modeViewController"); - if (ncAppViewController == nil) + if (ncAppViewController == nil) ncAppViewController = [[RANCViewController alloc] init]; [modeVC _addBulletinObserverViewController:ncAppViewController]; } } + %end // This is more of a hack than anything else. Note that `_localizableTitleForColumnViewController` on iOS 9 does not seem to work (I may be doing something else wrong) -// if more than one custom nc tab is added, this will not work correctly. +// if more than one custom nc tab is added, this will not work correctly. %hook SBModeViewController - (void)_layoutHeaderViewIfNecessary { @@ -111,4 +112,4 @@ RANCViewController *ncAppViewController; { %init(iOS8); } -} \ No newline at end of file +} diff --git a/layout/DEBIAN/control b/layout/DEBIAN/control index d8377d1..a982bb5 100644 --- a/layout/DEBIAN/control +++ b/layout/DEBIAN/control @@ -1,11 +1,11 @@ Package: org.thebigboss.multiplexer Name: Multiplexer -Depends: mobilesubstrate, applist, preferenceloader, com.elijahandandrew.MultiplexerTutorial, com.rpetrich.rocketbootstrap +Depends: mobilesubstrate, applist, preferenceloader, com.rpetrich.rocketbootstrap Conflicts: cc.tweak.statushud Replaces: com.efrederickson.reachapp Version: 0.1 Architecture: iphoneos-arm -Description: All sorts of multitasking. +Description: All sorts of multitasking. Depiction: http://elijahandandrew.com/repo/depictions/Multiplexer/index.html Maintainer: Elijah and Andrew Author: Elijah and Andrew From d3615e597905c213e127c4d653437f3955d780d3 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 20 Jan 2017 23:07:06 -0600 Subject: [PATCH 06/59] Working on missioncontrol --- MissionControl/ActivatorListener.xm | 4 +-- MissionControl/AppSwitcher.xm | 23 ++++++------ RAAppSelectorView.xm | 25 ++++++------- SwipeOver/RASwipeOverManager.xm | 38 ++++++++++---------- SwipeOver/RASwipeOverOverlay.xm | 18 +++++----- reachappfsdaemon/main.mm | 37 ++++++++++--------- reachappsettings/Makefile | 2 +- widgets/Reachability/RAFavoriteAppsWidget.xm | 20 +++++------ 8 files changed, 84 insertions(+), 83 deletions(-) diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index 596511e..869b102 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -14,7 +14,7 @@ static RAActivatorListener *sharedInstance; return; else if ([[%c(RASettings) sharedInstance] missionControlEnabled]) { - [RAMissionControlManager.sharedInstance toggleMissionControl:YES]; + [RAMissionControlManager.sharedInstance toggleMissionControl:YES]; [[[%c(SBUIController) sharedInstance] _appSwitcherController] forceDismissAnimated:NO]; } [event setHandled:YES]; @@ -28,4 +28,4 @@ static RAActivatorListener *sharedInstance; sharedInstance = [[RAActivatorListener alloc] init]; [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.missioncontrol.activatorlistener"]; } -} \ No newline at end of file +} diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 96443cb..01eca4e 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -90,7 +90,7 @@ BOOL willShowMissionControl = NO; { [RAMissionControlManager.sharedInstance hideMissionControl:arg1]; } - + %orig; } %end @@ -150,7 +150,7 @@ BOOL willShowMissionControl = NO; - (void)_layoutInOrientation:(long long)arg1 { %orig; - + UIView *view = MSHookIvar(self, "_contentView"); if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) @@ -163,7 +163,7 @@ BOOL willShowMissionControl = NO; } SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; grabber.center = CGPointMake(view.frame.size.width / 2, 20/2); - + grabber.backgroundColor = [UIColor clearColor]; //grabber.chevronView.vibrantSettings = [%c(_SBFVibrantSettings) vibrantSettingsWithReferenceColor:UIColor.whiteColor referenceContrast:0.5 legibilitySettings:nil]; @@ -198,12 +198,12 @@ BOOL willShowMissionControl = NO; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { width = 60; - height = 40; + height = 40; } SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; grabber.center = CGPointMake(view.frame.size.width / 2, 20/2); - - + + grabber.backgroundColor = [UIColor clearColor]; //grabber.chevronView.vibrantSettings = [%c(_SBFVibrantSettings) vibrantSettingsWithReferenceColor:UIColor.whiteColor referenceContrast:0.5 legibilitySettings:nil]; @@ -330,15 +330,15 @@ BOOL willShowMissionControl = NO; origY = fakeView.center.y; } - if (state == UIGestureRecognizerStateChanged) + if (state == UIGestureRecognizerStateChanged) fakeView.center = (CGPoint) { fakeView.center.x, origY + location.y }; - + if (state == UIGestureRecognizerStateEnded) { //NSLog(@"[ReachApp] %@ + %@ = %@ > %@", NSStringFromCGPoint(fakeView.frame.origin), NSStringFromCGPoint(velocity), @(fakeView.frame.origin.y + velocity.y), @(-(UIScreen.mainScreen.bounds.size.height / 2))); if (fakeView.frame.origin.y + velocity.y > -(UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 2)) - { + { willShowMissionControl = YES; CGFloat distance = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - (fakeView.frame.origin.y + fakeView.frame.size.height); CGFloat duration = MIN(distance / velocity.y, 0.3); @@ -386,6 +386,7 @@ BOOL willShowMissionControl = NO; %hook SBAppSwitcherPageViewController - (void)_layout { + HBLogDebug(@"Ran _layout"); %orig; UIView *view = [self view]; @@ -400,8 +401,8 @@ BOOL willShowMissionControl = NO; } SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; grabber.center = CGPointMake(view.frame.size.width / 2, 20/2); - - + + grabber.backgroundColor = [UIColor clearColor]; //grabber.chevronView.vibrantSettings = [%c(_SBFVibrantSettings) vibrantSettingsWithReferenceColor:UIColor.whiteColor referenceContrast:0.5 legibilitySettings:nil]; diff --git a/RAAppSelectorView.xm b/RAAppSelectorView.xm index 3b330ce..beaec8e 100644 --- a/RAAppSelectorView.xm +++ b/RAAppSelectorView.xm @@ -6,6 +6,7 @@ if (self = [super initWithFrame:frame]) { self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7]; + self.scrollEnabled = YES; } return self; } @@ -14,18 +15,18 @@ { [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; - static CGSize fullSize = [%c(SBIconView) defaultIconSize]; - fullSize.height = fullSize.width; - CGFloat padding = 20; + static CGSize fullSize = [%c(SBIconView) defaultIconSize]; + fullSize.height = fullSize.width; + CGFloat padding = 20; - NSInteger numIconsPerLine = 0; - CGFloat tmpWidth = 10; - while (tmpWidth + fullSize.width <= self.frame.size.width) - { - numIconsPerLine++; - tmpWidth += fullSize.width + 20; - } - padding = (self.frame.size.width - (numIconsPerLine * fullSize.width)) / (numIconsPerLine + 1); + NSInteger numIconsPerLine = 0; + CGFloat tmpWidth = 10; + while (tmpWidth + fullSize.width <= self.frame.size.width) + { + numIconsPerLine++; + tmpWidth += fullSize.width + 20; + } + padding = (self.frame.size.width - (numIconsPerLine * fullSize.width)) / (numIconsPerLine + 1); CGSize contentSize = CGSizeMake(padding, 10); int horizontal = 0; @@ -78,7 +79,7 @@ } contentSize.width = self.frame.size.width; contentSize.height += fullSize.height * 1.5; - [self setContentSize:contentSize]; + self.contentSize = contentSize; } -(void) appViewItemTap:(UITapGestureRecognizer*)recognizer diff --git a/SwipeOver/RASwipeOverManager.xm b/SwipeOver/RASwipeOverManager.xm index 4fecffd..0fdca44 100644 --- a/SwipeOver/RASwipeOverManager.xm +++ b/SwipeOver/RASwipeOverManager.xm @@ -51,7 +51,7 @@ extern int rotationDegsForOrientation(int o); if (currentAppIdentifier) { [[%c(RAMessagingServer) sharedInstance] endResizingApp:currentAppIdentifier completion:nil]; - [[%c(RAMessagingServer) sharedInstance] setShouldUseExternalKeyboard:YES forApp:currentAppIdentifier completion:nil]; + [[%c(RAMessagingServer) sharedInstance] setShouldUseExternalKeyboard:YES forApp:currentAppIdentifier completion:nil]; } [%c(RAOrientationLocker) unlockOrientation]; @@ -93,7 +93,7 @@ extern int rotationDegsForOrientation(int o); [overlayWindow showEnoughToDarkenUnderlyingApp]; [overlayWindow makeKeyAndVisible]; [overlayWindow updateForOrientation:UIApplication.sharedApplication.statusBarOrientation]; - + [self showApp:nil]; } @@ -136,13 +136,13 @@ extern int rotationDegsForOrientation(int o); RAHostedAppView *view = [[%c(RAHostedAppView) alloc] initWithBundleIdentifier:identifier]; view.autosizesApp = NO; - if (overlayWindow.isHidingUnderlyingApp == NO) - view.autosizesApp = YES; + if (overlayWindow.isHidingUnderlyingApp == NO) + view.autosizesApp = YES; view.shouldUseExternalKeyboard = YES; view.allowHidingStatusBar = NO; view.frame = UIScreen.mainScreen._referenceBounds; view.showSplashscreenInsteadOfSpinner = YES; - view.renderWallpaper = YES; + view.renderWallpaper = YES; [view rotateToOrientation:UIInterfaceOrientationPortrait]; [view loadApp]; @@ -159,14 +159,14 @@ extern int rotationDegsForOrientation(int o); if (overlayWindow.isHidingUnderlyingApp == NO) // side-by-side view.frame = CGRectMake(10, 0, view.frame.size.width, view.frame.size.height); - else // overlay - { - view.frame = CGRectMake(SCREEN_WIDTH - 50, 0, view.frame.size.width, view.frame.size.height); + else // overlay + { + view.frame = CGRectMake(SCREEN_WIDTH - 50, 0, view.frame.size.width, view.frame.size.height); - CGFloat scale = 0.1; // MIN(MAX(scale, 0.1), 0.98); - view.transform = CGAffineTransformMakeScale(scale, scale); - view.center = (CGPoint) { SCREEN_WIDTH - (view.frame.size.width / 2), view.center.y }; - } + CGFloat scale = 0.1; // MIN(MAX(scale, 0.1), 0.98); + view.transform = CGAffineTransformMakeScale(scale, scale); + view.center = (CGPoint) { SCREEN_WIDTH - (view.frame.size.width / 2), view.center.y }; + } view.tag = RASWIPEOVER_VIEW_TAG; [overlayWindow addSubview:view]; @@ -227,10 +227,10 @@ extern int rotationDegsForOrientation(int o); CGFloat underWidth = [overlayWindow isHidingUnderlyingApp] ? -1 : overlayWindow.frame.origin.x; [[%c(RAMessagingServer) sharedInstance] resizeApp:currentAppIdentifier toSize:CGSizeMake(underWidth, -1) completion:nil]; } - + if (overlayWindow.isShowingAppSelector && reloadAppSelectorSizeNow) [self showAppSelector]; - else if (overlayWindow.isHidingUnderlyingApp == NO) // Update swiped-over app in side-by-side mode. RAHostedAppView takes care of the app sizing if we resize the RAHostedAppView. + else if (overlayWindow.isHidingUnderlyingApp == NO) // Update swiped-over app in side-by-side mode. RAHostedAppView takes care of the app sizing if we resize the RAHostedAppView. { overlayWindow.currentView.frame = CGRectMake(10, 0, SCREEN_WIDTH - overlayWindow.frame.origin.x - 10, overlayWindow.currentView.frame.size.height); } @@ -244,7 +244,7 @@ extern int rotationDegsForOrientation(int o); if (start == 0) start = targetView.center.x; - + if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled || state == UIGestureRecognizerStateFailed) { lastX = -1; @@ -254,7 +254,7 @@ extern int rotationDegsForOrientation(int o); CGFloat scale = (SCREEN_WIDTH - targetView.frame.origin.x) / [overlayWindow currentView].bounds.size.width; if (scale <= 0.12 && (!CGPointEqualToPoint(translation, CGPointZero))) { - [self stopUsingSwipeOver]; + [self stopUsingSwipeOver]; return; } } @@ -272,7 +272,7 @@ extern int rotationDegsForOrientation(int o); if (lastX == -1) lastX = translation.x; CGFloat newScale = (lastX - translation.x) / SCREEN_WIDTH; - lastX = translation.x; + lastX = translation.x; newScale = newScale + sqrt(targetView.transform.a * targetView.transform.a + targetView.transform.c * targetView.transform.c); CGFloat scale = MIN(MAX(newScale, 0.1), UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation) ? (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / targetView.bounds.size.height) - 0.02 : 0.98); @@ -291,7 +291,7 @@ extern int rotationDegsForOrientation(int o); //targetView.transform = CGAffineTransformMakeScale(scale, scale); //targetView.center = (CGPoint) { SCREEN_WIDTH - (targetView.frame.size.width / 2), targetView.center.y }; } - } + } else { if (overlayOriginX == -1) @@ -303,4 +303,4 @@ extern int rotationDegsForOrientation(int o); } [self updateClientSizes:state == UIGestureRecognizerStateEnded]; } -@end \ No newline at end of file +@end diff --git a/SwipeOver/RASwipeOverOverlay.xm b/SwipeOver/RASwipeOverOverlay.xm index 3a061a0..50bd24b 100644 --- a/SwipeOver/RASwipeOverOverlay.xm +++ b/SwipeOver/RASwipeOverOverlay.xm @@ -98,19 +98,19 @@ -(void) handlePan:(UIPanGestureRecognizer*)gesture { CGPoint newPoint = [gesture translationInView:gesture.view]; - [RASwipeOverManager.sharedInstance sizeViewForTranslation:newPoint state:gesture.state]; + [RASwipeOverManager.sharedInstance sizeViewForTranslation:newPoint state:gesture.state]; } -(void) longPress:(UILongPressGestureRecognizer*)gesture { [RASwipeOverManager.sharedInstance closeCurrentView]; - if ([[self currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) - { - [(RAAppSelectorView*)[self currentView] relayoutApps]; - [self currentView].frame = CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height); - return; - } - RAAppSelectorView *appSelector = [[%c(RAAppSelectorView) alloc] initWithFrame:CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height)]; + if ([[self currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) + { + [(RAAppSelectorView*)[self currentView] relayoutApps]; + [self currentView].frame = CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height); + return; + } + RAAppSelectorView *appSelector = [[%c(RAAppSelectorView) alloc] initWithFrame:CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height)]; appSelector.tag = RASWIPEOVER_VIEW_TAG; appSelector.target = self; [appSelector relayoutApps]; @@ -133,4 +133,4 @@ return NO; return YES; } -@end \ No newline at end of file +@end diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index d972532..ff229dd 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -7,28 +7,27 @@ #import int main(int argc, char **argv, char **envp) { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; + @autoreleasepool { + NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; + if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) + { + HBLogError(@"[ReachApp] FS Daemon: plist does not exist"); + return 0; + } - NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; - if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) - { - HBLogError(@"[ReachApp] FS Daemon: plist does not exist"); - return 0; - } + NSDictionary *contents = [NSDictionary dictionaryWithContentsOfFile:filePath]; - NSDictionary *contents = [NSDictionary dictionaryWithContentsOfFile:filePath]; + LSApplicationProxy *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:contents[@"bundleIdentifier"]]; + NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; + NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; + infoPlist[@"UIApplicationExitsOnSuspend"] = contents[@"UIApplicationExitsOnSuspend"]; + BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; - LSApplicationProxy *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:contents[@"bundleIdentifier"]]; - NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; - NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; - infoPlist[@"UIApplicationExitsOnSuspend"] = contents[@"UIApplicationExitsOnSuspend"]; - BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; + if (!success) + NSLog(@"[ReachApp] FS Daemon: error writing to plist: %@", path); + else + [NSFileManager.defaultManager removeItemAtPath:filePath error:nil]; - if (!success) - NSLog(@"[ReachApp] FS Daemon: error writing to plist: %@", path); - else - [NSFileManager.defaultManager removeItemAtPath:filePath error:nil]; - - [pool release]; + } return 0; } diff --git a/reachappsettings/Makefile b/reachappsettings/Makefile index d414c35..af7cc72 100644 --- a/reachappsettings/Makefile +++ b/reachappsettings/Makefile @@ -1,6 +1,6 @@ ARCHS = armv7 armv7s arm64 TARGET = iphone:9.2 -CFLAGS = -fobjc-arc -I../ -I../Backgrounding/ -I../Theming/ -I../NotificationCenterApp -Wno-deprecated-declarations +CFLAGS = -fobjc-arc -I../ -I../Backgrounding/ -I../Theming/ -I../NotificationCenterApp -Wno-deprecated-declarations -O2 LDFLAGS = -F$(THEOS)/frameworks include $(THEOS)/makefiles/common.mk diff --git a/widgets/Reachability/RAFavoriteAppsWidget.xm b/widgets/Reachability/RAFavoriteAppsWidget.xm index 2be940a..6e44305 100644 --- a/widgets/Reachability/RAFavoriteAppsWidget.xm +++ b/widgets/Reachability/RAFavoriteAppsWidget.xm @@ -53,10 +53,10 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView) - continue; + if (!iconView) + continue; - if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { if (isTop) { @@ -73,16 +73,16 @@ isTop = !isTop; } - iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); + iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); - iconView.tag = app.pid; - iconView.restorationIdentifier = app.bundleIdentifier; - UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; - [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; + iconView.tag = app.pid; + iconView.restorationIdentifier = app.bundleIdentifier; + UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; + [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; - [favoritesView addSubview:iconView]; + [favoritesView addSubview:iconView]; - contentSize.width += iconView.frame.size.width + spacing; + contentSize.width += iconView.frame.size.width + spacing; } contentSize.width = width; contentSize.height = 10 + ((size.height + 10) * (hasSecondRow ? 2 : 1)); From 60fef402ad69761d27e9b7fb0581a6dbe78125a9 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 21 Jan 2017 11:17:37 -0600 Subject: [PATCH 07/59] Replaced NSLogs with HBLogs --- DRM/Statistics.xm | 4 ++-- Debugging/Core.xm | 16 ++++++++-------- GestureSupport/Hooks_iOS9.xm | 2 +- KeyboardSupport/RAKeyboardStateListener.xm | 16 ++++++++-------- KeyboardSupport/RARemoteKeyboardView.xm | 8 ++++---- .../RASpringBoardKeyboardActivation.xm | 6 +++--- MissionControl/ActivatorListener.xm | 2 +- NotificationCenterApp/RANCViewController.xm | 10 +++++----- RASettings.mm | 4 ++-- SwipeOver/SwipeOverGesture.xm | 16 ++++++++-------- Theming/RAThemeManager.mm | 8 ++++---- WindowedMultitasking/StartMultitaskingGesture.xm | 4 ++-- headers.h | 6 ------ reachappfsdaemon/main.mm | 2 +- widgets/Reachability/RAWidgetSectionManager.mm | 10 +++++----- 15 files changed, 54 insertions(+), 60 deletions(-) diff --git a/DRM/Statistics.xm b/DRM/Statistics.xm index 46fc040..0830219 100644 --- a/DRM/Statistics.xm +++ b/DRM/Statistics.xm @@ -4,7 +4,7 @@ { IF_SPRINGBOARD { #if DEBUG - NSLog(@"[ReachApp][DRM] Not checking statistics on debug build"); + HBLogDebug(@"[ReachApp][DRM] Not checking statistics on debug build"); #else dispatch_async(dispatch_get_main_queue(), ^(void){ NSString *statsPath = @"/var/mobile/Library/Preferences/.multiplexer.stats_checked"; @@ -29,4 +29,4 @@ }); #endif } -} \ No newline at end of file +} diff --git a/Debugging/Core.xm b/Debugging/Core.xm index 1d8a770..e3a2a7a 100644 --- a/Debugging/Core.xm +++ b/Debugging/Core.xm @@ -9,7 +9,7 @@ %hook NSObject -(void)doesNotRecognizeSelector:(SEL)selector { - NSLog(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); + HBLogDebug(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); void *array[10]; size_t size; @@ -19,16 +19,16 @@ size = backtrace (array, 10); strings = backtrace_symbols (array, size); - NSLog(@"[ReachApp] Obtained %zd stack frames:\n", size); + HBLogDebug(@"[ReachApp] Obtained %zd stack frames:\n", size); for (i = 0; i < size; i++) { - NSLog(@"[ReachApp] %s\n", strings[i]); + HBLogDebug(@"[ReachApp] %s\n", strings[i]); } free(strings); - %orig; + %orig; } %end @@ -38,7 +38,7 @@ Class hook$objc_getClass(const char *name) Class cls = orig$objc_getClass(name); if (!cls) { - NSLog(@"[ReachApp] something attempted to access nil class '%s'", name); + HBLogDebug(@"[ReachApp] something attempted to access nil class '%s'", name); } return cls; }*/ @@ -46,11 +46,11 @@ Class hook$objc_getClass(const char *name) %ctor { IF_SPRINGBOARD { - + // Causes cycript to not function //MSHookFunction((void*)objc_getClass, (void*)hook$objc_getClass, (void**)&orig$objc_getClass); - + %init; } - //NSLog(@"[ReachApp] %s", class_getImageName(orig$objc_getClass("RAMissionControlManager"))); + //HBLogDebug(@"[ReachApp] %s", class_getImageName(orig$objc_getClass("RAMissionControlManager"))); } diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index 6b14fb6..7ec87bd 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -95,7 +95,7 @@ struct VelocityData { location.y = location.x; location.x = t; } - NSLog(@"[ReachApp] _UIScreenEdgePanRecognizer location: %@", NSStringFromCGPoint(location)); + HBLogDebug(@"[ReachApp] _UIScreenEdgePanRecognizer location: %@", NSStringFromCGPoint(location)); if ([RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateBegan withPoint:location velocity:screenEdgePanRecognizer.RA_velocity forEdge:screenEdgePanRecognizer.targetEdges]) { currentEdge9 = screenEdgePanRecognizer.targetEdges; diff --git a/KeyboardSupport/RAKeyboardStateListener.xm b/KeyboardSupport/RAKeyboardStateListener.xm index a6d5387..84082c7 100644 --- a/KeyboardSupport/RAKeyboardStateListener.xm +++ b/KeyboardSupport/RAKeyboardStateListener.xm @@ -19,7 +19,7 @@ BOOL isShowing = NO; - (void)didShow:(NSNotification*)notif { - NSLog(@"[ReachApp] keyboard didShow"); + HBLogDebug(@"[ReachApp] keyboard didShow"); _visible = YES; _size = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; @@ -37,7 +37,7 @@ BOOL isShowing = NO; - (void)didHide { - NSLog(@"[ReachApp] keyboard didHide"); + HBLogDebug(@"[ReachApp] keyboard didHide"); _visible = NO; IF_NOT_SPRINGBOARD { @@ -52,7 +52,7 @@ BOOL isShowing = NO; - (id)init { - if ((self = [super init])) + if ((self = [super init])) { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(didShow:) name:UIKeyboardDidShowNotification object:nil]; @@ -66,14 +66,14 @@ BOOL isShowing = NO; -(void) _setSize:(CGSize)size { _size = size; } @end -void externalKeyboardDidShow(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) +void externalKeyboardDidShow(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { [RAKeyboardStateListener.sharedInstance _setVisible:YES]; } -void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) +void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { - //NSLog(@"[ReachApp] externalKeyboardDidHide"); + //HBLogDebug(@"[ReachApp] externalKeyboardDidHide"); [RAKeyboardStateListener.sharedInstance _setVisible:NO]; } @@ -97,7 +97,7 @@ void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFS assert(contextID == [[[UIKeyboard activeKeyboard] window] _contextId]); #endif - NSLog(@"[ReachApp] c id %d", contextID); + HBLogDebug(@"[ReachApp] c id %d", contextID); } }; @@ -120,4 +120,4 @@ void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFS CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, externalKeyboardDidShow, CFSTR("com.efrederickson.reachapp.keyboard.didShow"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, externalKeyboardDidHide, CFSTR("com.efrederickson.reachapp.keyboard.didHide"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); } -} \ No newline at end of file +} diff --git a/KeyboardSupport/RARemoteKeyboardView.xm b/KeyboardSupport/RARemoteKeyboardView.xm index 3fa92b4..5767bce 100644 --- a/KeyboardSupport/RARemoteKeyboardView.xm +++ b/KeyboardSupport/RARemoteKeyboardView.xm @@ -24,8 +24,8 @@ unsigned int value = [RAMessagingServer.sharedInstance getStoredKeyboardContextIdForApp:identifier]; self.layerHost.contextId = value; - - NSLog(@"[ReachApp] loaded keyboard view with %d", value); + + HBLogDebug(@"[ReachApp] loaded keyboard view with %d", value); if (value == 0 && cancelFetchingContextId == NO) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ @@ -37,7 +37,7 @@ -(id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; - if (self) + if (self) { self.userInteractionEnabled = YES; self.layerHost = [[CALayerHost alloc] init]; @@ -48,7 +48,7 @@ [self.layer addSublayer:self.layerHost]; update = NO; } - + return self; } diff --git a/KeyboardSupport/RASpringBoardKeyboardActivation.xm b/KeyboardSupport/RASpringBoardKeyboardActivation.xm index 2f3bd0b..590e98e 100644 --- a/KeyboardSupport/RASpringBoardKeyboardActivation.xm +++ b/KeyboardSupport/RASpringBoardKeyboardActivation.xm @@ -26,8 +26,8 @@ RAKeyboardWindow *keyboardWindow; //return; } - NSLog(@"[ReachApp] showing kb window %@", identifier); - keyboardWindow = [[RAKeyboardWindow alloc] init]; + HBLogDebug(@"[ReachApp] showing kb window %@", identifier); + keyboardWindow = [[RAKeyboardWindow alloc] init]; overrideDisableForStatusBar = YES; [keyboardWindow setupForKeyboardAndShow:identifier]; overrideDisableForStatusBar = NO; @@ -36,7 +36,7 @@ RAKeyboardWindow *keyboardWindow; -(void) hideKeyboard { - NSLog(@"[ReachApp] remove kb window (%@)", _currentIdentifier); + HBLogDebug(@"[ReachApp] remove kb window (%@)", _currentIdentifier); keyboardWindow.hidden = YES; [keyboardWindow removeKeyboard]; keyboardWindow = nil; diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index 869b102..8101950 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -17,7 +17,7 @@ static RAActivatorListener *sharedInstance; [RAMissionControlManager.sharedInstance toggleMissionControl:YES]; [[[%c(SBUIController) sharedInstance] _appSwitcherController] forceDismissAnimated:NO]; } - [event setHandled:YES]; + [event setHandled:YES]; } @end diff --git a/NotificationCenterApp/RANCViewController.xm b/NotificationCenterApp/RANCViewController.xm index 98f435e..a4be59d 100644 --- a/NotificationCenterApp/RANCViewController.xm +++ b/NotificationCenterApp/RANCViewController.xm @@ -122,7 +122,7 @@ int rotationDegsForOrientation(int o) appView.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(rotationDegsForOrientation(UIApplication.sharedApplication.statusBarOrientation))); // Explicitly, SpringBoard's status bar since the NC is shown in SpringBoard CGFloat scale = self.view.frame.size.height / UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height; appView.transform = CGAffineTransformScale(appView.transform, scale, scale); - + // Align vertically CGRect f = appView.frame; f.origin.y = 0; @@ -144,7 +144,7 @@ int rotationDegsForOrientation(int o) if (appView.isCurrentlyHosting) { appView.hideStatusBar = NO; - [appView unloadApp]; + [appView unloadApp]; } } @@ -155,7 +155,7 @@ int rotationDegsForOrientation(int o) appView.hideStatusBar = NO; if (appView.isCurrentlyHosting) { - [appView unloadApp]; + [appView unloadApp]; } } @@ -164,13 +164,13 @@ int rotationDegsForOrientation(int o) - (void)forwardInvocation:(NSInvocation *)anInvocation { // Override - NSLog(@"[ReachApp] RANCViewController: ignoring invocation: %@", anInvocation); + HBLogDebug(@"[ReachApp] RANCViewController: ignoring invocation: %@", anInvocation); } - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { NSMethodSignature *signature = [super methodSignatureForSelector:aSelector]; - if (signature == nil && class_respondsToSelector(%c(SBBulletinObserverViewController), aSelector)) + if (signature == nil && class_respondsToSelector(%c(SBBulletinObserverViewController), aSelector)) signature = [%c(SBBulletinObserverViewController) instanceMethodSignatureForSelector:aSelector]; return signature; } diff --git a/RASettings.mm b/RASettings.mm index f730953..695c9aa 100644 --- a/RASettings.mm +++ b/RASettings.mm @@ -108,7 +108,7 @@ -(void) reloadSettings if (_settings == nil) { - NSLog(@"[ReachApp] could not load settings from CFPreferences or NSDictionary"); + HBLogError(@"[ReachApp] could not load settings from CFPreferences or NSDictionary"); } if ([previousNCAppSetting isEqual:self.NCApp] == NO) @@ -348,7 +348,7 @@ -(NSDictionary*) rawCompiledBackgrounderSettingsForIdentifier:(NSString*)identif -(BOOL) isFirstRun { - NSLog(@"[ReachApp] %d", BOOL(@"isFirstRun", YES)); + HBLogDebug(@"[ReachApp] %d", BOOL(@"isFirstRun", YES)); return BOOL(@"isFirstRun", YES); } diff --git a/SwipeOver/SwipeOverGesture.xm b/SwipeOver/SwipeOverGesture.xm index 6ced5fb..0fc959e 100644 --- a/SwipeOver/SwipeOverGesture.xm +++ b/SwipeOver/SwipeOverGesture.xm @@ -27,16 +27,16 @@ CGRect adjustFrameForRotation() switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) { case UIInterfaceOrientationPortrait: - NSLog(@"[ReachApp] portrait"); + HBLogDebug(@"[ReachApp] portrait"); return (CGRect){ { width - portraitWidth + 5, (height - portraitHeight) / 2 }, { portraitWidth, portraitHeight } }; case UIInterfaceOrientationPortraitUpsideDown: - NSLog(@"[ReachApp] portrait upside down"); + HBLogDebug(@"[ReachApp] portrait upside down"); return (CGRect){ { 0, 0}, { 50, 50 } }; case UIInterfaceOrientationLandscapeLeft: - NSLog(@"[ReachApp] landscape left"); + HBLogDebug(@"[ReachApp] landscape left"); return (CGRect){ { ((width - portraitWidth) / 2), -(portraitWidth / 2) }, { portraitWidth, portraitHeight } }; case UIInterfaceOrientationLandscapeRight: - NSLog(@"[ReachApp] landscape right"); + HBLogDebug(@"[ReachApp] landscape right"); return (CGRect){ { (height - portraitHeight) / 2, width - portraitWidth - 5 }, { portraitWidth, portraitHeight } }; } return CGRectZero; @@ -62,7 +62,7 @@ CGPoint adjustCenterForOffscreenSlide(CGPoint center) } CGAffineTransform adjustTransformRotation() -{ +{ switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) { case UIInterfaceOrientationPortrait: @@ -184,7 +184,7 @@ BOOL swipeOverLocationIsInValidArea(CGFloat y) if (![RASwipeOverManager.sharedInstance isUsingSwipeOver]) [RASwipeOverManager.sharedInstance startUsingSwipeOver]; - + //if (state == UIGestureRecognizerStateChanged) [RASwipeOverManager.sharedInstance sizeViewForTranslation:translation state:state]; @@ -198,7 +198,7 @@ BOOL swipeOverLocationIsInValidArea(CGFloat y) if (CGRectContainsPoint(realKBFrame, location) || realKBFrame.size.height > 50) return NO; } - + return [[%c(RASettings) sharedInstance] swipeOverEnabled] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBNotificationCenterController) sharedInstance] isVisible] && ![[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl] && (swipeOverLocationIsInValidArea(location.y) || isShowingGrabber); } forEdge:UIRectEdgeRight identifier:@"com.efrederickson.reachapp.swipeover.systemgesture" priority:RAGesturePriorityDefault]; -} \ No newline at end of file +} diff --git a/Theming/RAThemeManager.mm b/Theming/RAThemeManager.mm index 3f69220..cdb95f5 100644 --- a/Theming/RAThemeManager.mm +++ b/Theming/RAThemeManager.mm @@ -15,7 +15,7 @@ -(NSArray*) allThemes { return allThemes.allValues; } -(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier { #if DEBUG - NSLog(@"[ReachApp] loading themes..."); + HBLogDebug(@"[ReachApp] loading themes..."); NSDate *startTime = [NSDate date]; #endif @@ -34,7 +34,7 @@ -(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier RATheme *theme = [RAThemeLoader loadFromFile:themeName]; if (theme && theme.themeIdentifier) { - //NSLog(@"[ReachApp] adding %@", theme.themeIdentifier); + //HBLogDebug(@"[ReachApp] adding %@", theme.themeIdentifier); allThemes[theme.themeIdentifier] = theme; if ([theme.themeIdentifier isEqual:currentIdentifier]) @@ -52,7 +52,7 @@ -(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier #if DEBUG NSDate *endTime = [NSDate date]; - NSLog(@"[ReachApp] loaded %ld themes in %f seconds.", (long)allThemes.count, [endTime timeIntervalSinceDate:startTime]); + HBLogDebug(@"[ReachApp] loaded %ld themes in %f seconds.", (long)allThemes.count, [endTime timeIntervalSinceDate:startTime]); #endif } -@end \ No newline at end of file +@end diff --git a/WindowedMultitasking/StartMultitaskingGesture.xm b/WindowedMultitasking/StartMultitaskingGesture.xm index de12082..c00b92b 100644 --- a/WindowedMultitasking/StartMultitaskingGesture.xm +++ b/WindowedMultitasking/StartMultitaskingGesture.xm @@ -16,7 +16,7 @@ BOOL locationIsInValidArea(CGFloat x) switch ([RASettings.sharedInstance windowedMultitaskingGrabArea]) { case RAGrabAreaBottomLeftThird: - NSLog(@"[ReachApp] StartMultitaskingGesture: %f %f", x, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width); + HBLogDebug(@"[ReachApp] StartMultitaskingGesture: %f %f", x, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width); return x <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0; case RAGrabAreaBottomMiddleThird: return x >= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0 && x <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0) * 2; @@ -120,7 +120,7 @@ BOOL locationIsInValidArea(CGFloat x) [deactiveSets setFlag:YES forDeactivationSetting:20]; [deactiveSets setFlag:NO forDeactivationSetting:2]; [topApp _setDeactivationSettings:deactiveSets]; - + SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; [transaction begin]; diff --git a/headers.h b/headers.h index 9d65b5f..37230cc 100644 --- a/headers.h +++ b/headers.h @@ -34,12 +34,6 @@ #define GET_STATUSBAR_ORIENTATION (UIApplication.sharedApplication._accessibilityFrontMostApplication == nil ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) -#if DEBUG -#define NSLog NSLog -#else -#define NSLog(...) -#endif - #if MULTIPLEXER_CORE extern BOOL $__IS_SPRINGBOARD; #define IS_SPRINGBOARD $__IS_SPRINGBOARD diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index ff229dd..37824d4 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -24,7 +24,7 @@ int main(int argc, char **argv, char **envp) { BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; if (!success) - NSLog(@"[ReachApp] FS Daemon: error writing to plist: %@", path); + HBLogError(@"[ReachApp] FS Daemon: error writing to plist: %@", path); else [NSFileManager.defaultManager removeItemAtPath:filePath error:nil]; diff --git a/widgets/Reachability/RAWidgetSectionManager.mm b/widgets/Reachability/RAWidgetSectionManager.mm index 9d8e634..3ccd599 100644 --- a/widgets/Reachability/RAWidgetSectionManager.mm +++ b/widgets/Reachability/RAWidgetSectionManager.mm @@ -48,13 +48,13 @@ -(NSArray*) enabledSections //[arr sortUsingComparator:^(RAWidgetSection *a, RAWidgetSection *b) { // return [@(a.sortOrder) compare:@(b.sortOrder)]; //}]; - + [arr sortUsingComparator:^NSComparisonResult(RAWidgetSection *a, RAWidgetSection *b) { if (a.sortOrder < b.sortOrder) return NSOrderedAscending; else if (a.sortOrder > b.sortOrder) return NSOrderedDescending; - else + else return NSOrderedSame; }]; @@ -91,7 +91,7 @@ -(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIcon [view addSubview:titleView]; currentY += titleView.frame.size.height + VERTICAL_PADDING; } - + //sectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; sectionView.backgroundColor = [UIColor clearColor]; sectionView.clipsToBounds = YES; @@ -108,7 +108,7 @@ -(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIcon } @catch (NSException *ex) { - NSLog(@"[ReachApp] an error occurred creating the view for section '%@': %@", section.identifier, ex); + HBLogError(@"[ReachApp] an error occurred creating the view for section '%@': %@", section.identifier, ex); } } @@ -119,4 +119,4 @@ -(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIcon return view; } -@end \ No newline at end of file +@end From e713b184522a48812e4eebef23ca677503278d22 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 21 Jan 2017 15:36:58 -0600 Subject: [PATCH 08/59] Mission Control Partially works now --- Makefile | 1 - MissionControl/ActivatorListener.xm | 4 +- MissionControl/AppSwitcher.xm | 62 +++++++++++++++++++----- MissionControl/RAMissionControlWindow.xm | 32 +++++++----- reachappfsdaemon/main.mm | 26 +++++----- 5 files changed, 86 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 568cf57..9f92595 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -DEBUG = 1 ARCHS = armv7 armv7s arm64 CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ -Wno-deprecated-declarations CFLAGS += -fobjc-arc -O2 diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index 8101950..62b8a73 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -15,7 +15,9 @@ static RAActivatorListener *sharedInstance; else if ([[%c(RASettings) sharedInstance] missionControlEnabled]) { [RAMissionControlManager.sharedInstance toggleMissionControl:YES]; - [[[%c(SBUIController) sharedInstance] _appSwitcherController] forceDismissAnimated:NO]; + if ([%c(SBUIController) respondsToSelector:@selector(_appSwitcherController)]) { + [[[%c(SBUIController) sharedInstance] _appSwitcherController] forceDismissAnimated:NO]; + } } [event setHandled:YES]; } diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 01eca4e..adec83b 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -22,6 +22,45 @@ BOOL willShowMissionControl = NO; %orig; } +-(BOOL)_appSwitcherSystemGestureShouldBegin:(id)arg1 +{ + statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; + willShowMissionControl = NO; + + if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) + { + if (RAMissionControlManager.sharedInstance.isShowingMissionControl == NO) + { + [RAMissionControlManager.sharedInstance showMissionControl:YES]; + } + else + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + + return YES; + } + else + { + if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) + { + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } + } + + BOOL s = %orig; + if (s && [[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999] != nil) + { + [UIView animateWithDuration:0.3 animations:^{ + [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].alpha = 1; + }]; + } + if (s) + { + [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; + //[[[%c(RADesktopManager) sharedInstance] currentDesktop] unloadApps]; + } + return s; +} + - (_Bool)_activateAppSwitcher { statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; @@ -149,6 +188,7 @@ BOOL willShowMissionControl = NO; - (void)_layoutInOrientation:(long long)arg1 { + HBLogDebug(@"Ran layout in orientation"); %orig; UIView *view = MSHookIvar(self, "_contentView"); @@ -236,8 +276,13 @@ BOOL willShowMissionControl = NO; %new -(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { - [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureFailed)]; - [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureCancelled)]; + if ([%c(SBUIController) respondsToSelector:@selector(_showNotificationsGestureFailed)]) { + [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureFailed)]; + [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureCancelled)]; + } else { + [[%c(SBNotificationCenterController) sharedInstance] performSelector:@selector(_showNotificationCenterGestureFailed)]; + [[%c(SBNotificationCenterController) sharedInstance] performSelector:@selector(_showNotificationCenterGestureCancelled)]; + } static CGFloat origY = -1; static UIView *fakeView; @@ -381,12 +426,11 @@ BOOL willShowMissionControl = NO; } %end -@interface SBAppSwitcherPageViewController : UIViewController +@interface SBDeckSwitcherViewController : UIViewController @end -%hook SBAppSwitcherPageViewController -- (void)_layout +%hook SBDeckSwitcherViewController +-(void)viewWillLayoutSubviews { - HBLogDebug(@"Ran _layout"); %orig; UIView *view = [self view]; @@ -397,7 +441,7 @@ BOOL willShowMissionControl = NO; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { width = 60; - height = 40; + height = 40; } SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; grabber.center = CGPointMake(view.frame.size.width / 2, 20/2); @@ -418,10 +462,6 @@ BOOL willShowMissionControl = NO; grabber.tag = 999; [view addSubview:grabber]; - //[grabber.chevronView setState:1 animated:YES]; - grabber.tag = 999; - [view addSubview:grabber]; - [[%c(RAGestureManager) sharedInstance] addGestureRecognizerWithTarget:(NSObject *)self forEdge:UIRectEdgeTop identifier:@"com.efrederickson.reachapp.appswitchergrabber"]; } else diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index 01dbb60..538e718 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -16,7 +16,7 @@ UIScrollView *desktopScrollView, *windowedAppScrollView, *otherRunningAppsScrollView; UILabel *desktopLabel, *windowedLabel, *otherLabel; UIButton *windowedKillAllButton, *otherKillAllButton; - + UIImageView *trashImageView; UIView *shadowView; UIImage *trashIcon; @@ -42,7 +42,7 @@ -(UIWindowLevel) windowLevel { //return UIWindowLevelStatusBar + 1; - return 1000; + return 1000; } - (BOOL)_shouldAutorotateToInterfaceOrientation:(int)arg1 checkForDismissal:(BOOL)arg2 isRotationDisabled:(BOOL*)arg3 @@ -61,7 +61,7 @@ count += 1; panePadding += width; } - panePadding = (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width - panePadding) / 5; + panePadding = (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width - panePadding) / 5; /*if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { width = (UIScreen.mainScreen.bounds.size.width / 3) * 0.9; @@ -123,7 +123,7 @@ [preview addGestureRecognizer:g]; UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(handleDoubleDesktopTap:)]; - doubleTap.numberOfTapsRequired = 2; + doubleTap.numberOfTapsRequired = 2; [preview addGestureRecognizer:doubleTap]; [g requireGestureRecognizerToFail:doubleTap]; @@ -167,9 +167,15 @@ [runningApplications sortUsingComparator:^NSComparisonResult(SBApplication *obj1, SBApplication *obj2) { return [@([switcherOrder indexOfObject:obj1.bundleIdentifier]) compare:@([switcherOrder indexOfObject:obj2.bundleIdentifier])]; }]; - + appsWithoutWindows = [runningApplications mutableCopy]; - NSArray *visibleIcons = [[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers]; + NSArray *visibleIcons = nil; + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + visibleIcons = [[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers]; + } else { + visibleIcons = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers]; + } + for (SBApplication *app in runningApplications) { if ([visibleIcons containsObject:app.bundleIdentifier] == NO)// || [RAMissionControlManager.sharedInstance.inhibitedApplications containsObject:app.bundleIdentifier]) @@ -423,7 +429,7 @@ draggedView = [gesture.view snapshotViewAfterScreenUpdates:YES]; draggedView.frame = gesture.view.frame; draggedView.center = [gesture.view.superview convertPoint:gesture.view.center toView:self]; - + [self addSubview:draggedView]; gesture.view.alpha = 0.6; @@ -497,7 +503,7 @@ SBApplication *app = ((RAMissionControlPreviewView*)gesture.view).application; [[[%c(RADesktopManager) sharedInstance] currentDesktop] removeAppWithIdentifier:app.bundleIdentifier animated:NO]; - + [desktop createAppWindowForSBApplication:app animated:NO]; [[%c(RASnapshotProvider) sharedInstance] forceReloadSnapshotOfDesktop:[[%c(RADesktopManager) sharedInstance] currentDesktop]]; @@ -511,11 +517,11 @@ } } - [UIView animateWithDuration:0.4 animations:^{ + [UIView animateWithDuration:0.4 animations:^{ if (!didKill) { draggedView.transform = CGAffineTransformIdentity; - draggedView.center = initialCenter; + draggedView.center = initialCenter; } } completion:^(BOOL _) { [draggedView removeFromSuperview]; @@ -666,7 +672,7 @@ { NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; UIView *subview; - while ((subview = [objects nextObject])) + while ((subview = [objects nextObject])) { UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; if (success) @@ -676,10 +682,10 @@ //return [super hitTest:point withEvent:event]; } -- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event +- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { if (CGRectContainsPoint(self.frame, point)) return YES; return [super pointInside:point withEvent:event]; } -@end \ No newline at end of file +@end diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index 37824d4..de50586 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -9,25 +9,25 @@ int main(int argc, char **argv, char **envp) { @autoreleasepool { NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; - if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) - { - HBLogError(@"[ReachApp] FS Daemon: plist does not exist"); - return 0; - } + if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) + { + HBLogError(@"[ReachApp] FS Daemon: plist does not exist"); + return 0; + } NSDictionary *contents = [NSDictionary dictionaryWithContentsOfFile:filePath]; - LSApplicationProxy *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:contents[@"bundleIdentifier"]]; - NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; - NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; - infoPlist[@"UIApplicationExitsOnSuspend"] = contents[@"UIApplicationExitsOnSuspend"]; - BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; + LSApplicationProxy *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:contents[@"bundleIdentifier"]]; + NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; + NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; + infoPlist[@"UIApplicationExitsOnSuspend"] = contents[@"UIApplicationExitsOnSuspend"]; + BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; - if (!success) + if (!success) { HBLogError(@"[ReachApp] FS Daemon: error writing to plist: %@", path); - else + } else { [NSFileManager.defaultManager removeItemAtPath:filePath error:nil]; - + } } return 0; } From e87529d499340dd9fedb9d4d1c46eed6869e3405 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 21 Jan 2017 16:42:08 -0600 Subject: [PATCH 09/59] Mission Control still somewhat broken --- MissionControl/AppSwitcher.xm | 8 ++------ headers.h | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index adec83b..35795d2 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -21,7 +21,7 @@ BOOL willShowMissionControl = NO; %orig; } - +/* -(BOOL)_appSwitcherSystemGestureShouldBegin:(id)arg1 { statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; @@ -60,7 +60,7 @@ BOOL willShowMissionControl = NO; } return s; } - +*/ - (_Bool)_activateAppSwitcher { statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; @@ -188,7 +188,6 @@ BOOL willShowMissionControl = NO; - (void)_layoutInOrientation:(long long)arg1 { - HBLogDebug(@"Ran layout in orientation"); %orig; UIView *view = MSHookIvar(self, "_contentView"); @@ -229,7 +228,6 @@ BOOL willShowMissionControl = NO; -(void)viewDidAppear:(BOOL)a { %orig; - UIView *view = MSHookIvar(self, "_contentView"); if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) @@ -426,8 +424,6 @@ BOOL willShowMissionControl = NO; } %end -@interface SBDeckSwitcherViewController : UIViewController -@end %hook SBDeckSwitcherViewController -(void)viewWillLayoutSubviews { diff --git a/headers.h b/headers.h index 37230cc..d833cde 100644 --- a/headers.h +++ b/headers.h @@ -1485,3 +1485,6 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (CGRect)snapshotReferenceFrame; - (void)setSnapshotReferenceFrame:(CGRect)arg1 ; @end + +@interface SBDeckSwitcherViewController : UIViewController +@end From 604c88a353be5c00a1ba12af43b25b9658e737ae Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 21 Jan 2017 21:03:14 -0600 Subject: [PATCH 10/59] Fixed assertiond hook --- MissionControl/AppSwitcher.xm | 6 ++++-- .../com.efrederickson.reachapp.fsdaemon.plist | 4 +++- reachappassertiondhooks/Tweak.xm | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 35795d2..6653ba8 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -21,7 +21,7 @@ BOOL willShowMissionControl = NO; %orig; } -/* + -(BOOL)_appSwitcherSystemGestureShouldBegin:(id)arg1 { statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; @@ -60,7 +60,7 @@ BOOL willShowMissionControl = NO; } return s; } -*/ + - (_Bool)_activateAppSwitcher { statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; @@ -425,6 +425,7 @@ BOOL willShowMissionControl = NO; %end %hook SBDeckSwitcherViewController +/* -(void)viewWillLayoutSubviews { %orig; @@ -463,4 +464,5 @@ BOOL willShowMissionControl = NO; else ((UIView*)[view viewWithTag:999]).center = CGPointMake(view.frame.size.width / 2, 20/2); } +*/ %end diff --git a/layout/Library/LaunchDaemons/com.efrederickson.reachapp.fsdaemon.plist b/layout/Library/LaunchDaemons/com.efrederickson.reachapp.fsdaemon.plist index c82ec6d..c2991a0 100644 --- a/layout/Library/LaunchDaemons/com.efrederickson.reachapp.fsdaemon.plist +++ b/layout/Library/LaunchDaemons/com.efrederickson.reachapp.fsdaemon.plist @@ -8,6 +8,8 @@ /usr/bin/ReachAppFSDaemon RunAtLoad + ExecuteAllowed + StandardErrorPath /dev/null WatchPaths @@ -19,4 +21,4 @@ group wheel - \ No newline at end of file + diff --git a/reachappassertiondhooks/Tweak.xm b/reachappassertiondhooks/Tweak.xm index b7b6ce8..797c0ec 100644 --- a/reachappassertiondhooks/Tweak.xm +++ b/reachappassertiondhooks/Tweak.xm @@ -11,3 +11,10 @@ } return %orig; } + +%hookf(BOOL, "_BSXPCConnectionHasEntitlement", id connection, NSString *entitlement) { + if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { + return YES; + } + return %orig; +} From c2664bf03be4ef2a367a0bb4fcbbd2fe734b5856 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 21 Jan 2017 21:45:58 -0600 Subject: [PATCH 11/59] Fixed HS disappearing --- MissionControl/ActivatorListener.xm | 5 +-- MissionControl/AppSwitcher.xm | 62 +++++------------------------ headers.h | 3 +- 3 files changed, 14 insertions(+), 56 deletions(-) diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index 62b8a73..c49ddee 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -10,10 +10,9 @@ static RAActivatorListener *sharedInstance; @implementation RAActivatorListener - (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event { - if ([[%c(SBLockScreenManager) sharedInstance] isUILocked]) + if ([[%c(SBLockScreenManager) sharedInstance] isUILocked]) { return; - else if ([[%c(RASettings) sharedInstance] missionControlEnabled]) - { + } else if ([[%c(RASettings) sharedInstance] missionControlEnabled]) { [RAMissionControlManager.sharedInstance toggleMissionControl:YES]; if ([%c(SBUIController) respondsToSelector:@selector(_appSwitcherController)]) { [[[%c(SBUIController) sharedInstance] _appSwitcherController] forceDismissAnimated:NO]; diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 6653ba8..3a5089e 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -22,45 +22,6 @@ BOOL willShowMissionControl = NO; %orig; } --(BOOL)_appSwitcherSystemGestureShouldBegin:(id)arg1 -{ - statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; - willShowMissionControl = NO; - - if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) - { - if (RAMissionControlManager.sharedInstance.isShowingMissionControl == NO) - { - [RAMissionControlManager.sharedInstance showMissionControl:YES]; - } - else - [RAMissionControlManager.sharedInstance hideMissionControl:YES]; - - return YES; - } - else - { - if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) - { - [RAMissionControlManager.sharedInstance hideMissionControl:YES]; - } - } - - BOOL s = %orig; - if (s && [[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999] != nil) - { - [UIView animateWithDuration:0.3 animations:^{ - [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].alpha = 1; - }]; - } - if (s) - { - [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; - //[[[%c(RADesktopManager) sharedInstance] currentDesktop] unloadApps]; - } - return s; -} - - (_Bool)_activateAppSwitcher { statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; @@ -154,6 +115,7 @@ BOOL willShowMissionControl = NO; // iOS 9 - (void)_switcherWasDismissed:(_Bool)arg1 { + HBLogDebug(@"_switcherWasDismissed"); if (willShowMissionControl == NO) { [[%c(RADesktopManager) sharedInstance] reshowDesktop]; @@ -161,7 +123,7 @@ BOOL willShowMissionControl = NO; } [UIView animateWithDuration:0.3 animations:^{ - [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].alpha = 0; + [[%c(SBMainSwitcherViewController) sharedInstance] viewWithTag:999].alpha = 0; }]; %orig; @@ -274,6 +236,7 @@ BOOL willShowMissionControl = NO; %new -(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { + HBLogDebug(@"Ran RAGestureCallback_handle"); if ([%c(SBUIController) respondsToSelector:@selector(_showNotificationsGestureFailed)]) { [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureFailed)]; [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureCancelled)]; @@ -424,24 +387,20 @@ BOOL willShowMissionControl = NO; } %end -%hook SBDeckSwitcherViewController -/* --(void)viewWillLayoutSubviews -{ +%hook SBMainSwitcherViewController +- (void)viewDidLoad { %orig; UIView *view = [self view]; - if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) - { + if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) - { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { width = 60; height = 40; } SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; - grabber.center = CGPointMake(view.frame.size.width / 2, 20/2); + grabber.center = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, 20/2); grabber.backgroundColor = [UIColor clearColor]; @@ -460,9 +419,8 @@ BOOL willShowMissionControl = NO; [view addSubview:grabber]; [[%c(RAGestureManager) sharedInstance] addGestureRecognizerWithTarget:(NSObject *)self forEdge:UIRectEdgeTop identifier:@"com.efrederickson.reachapp.appswitchergrabber"]; + } else { + ((UIView*)[view viewWithTag:999]).center = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, 20/2); } - else - ((UIView*)[view viewWithTag:999]).center = CGPointMake(view.frame.size.width / 2, 20/2); } -*/ %end diff --git a/headers.h b/headers.h index d833cde..0d58a0c 100644 --- a/headers.h +++ b/headers.h @@ -1486,5 +1486,6 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (void)setSnapshotReferenceFrame:(CGRect)arg1 ; @end -@interface SBDeckSwitcherViewController : UIViewController +@interface SBMainSwitcherViewController : UIViewController ++ (id)sharedInstance; @end From 3b2f7c0e0793e2826971330f614d15ce614cf6f0 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sun, 22 Jan 2017 11:47:28 -0600 Subject: [PATCH 12/59] Fixed assertiond hook args --- reachappassertiondhooks/Tweak.xm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reachappassertiondhooks/Tweak.xm b/reachappassertiondhooks/Tweak.xm index 797c0ec..50b762c 100644 --- a/reachappassertiondhooks/Tweak.xm +++ b/reachappassertiondhooks/Tweak.xm @@ -5,16 +5,16 @@ - (int)pid; @end -%hookf(BOOL, "_BSAuditTokenTaskHasEntitlement", BSAuditToken *token, NSString *entitlement) { +%hookf(int, "_BSAuditTokenTaskHasEntitlement", BSAuditToken *token, NSString *entitlement) { if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { - return YES; + return 1; } return %orig; } -%hookf(BOOL, "_BSXPCConnectionHasEntitlement", id connection, NSString *entitlement) { +%hookf(int, "_BSXPCConnectionHasEntitlement", id connection, NSString *entitlement) { if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { - return YES; + return 1; } return %orig; } From f70b9a7af20806753c6e26b6e392dc1ff881959e Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sun, 22 Jan 2017 13:31:32 -0600 Subject: [PATCH 13/59] Fixed MissionControl appearing --- MissionControl/AppSwitcher.xm | 67 ++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 3a5089e..73d13f6 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -95,27 +95,21 @@ BOOL willShowMissionControl = NO; } %end -%hook SBAppSwitcherController -// iOS 8 -- (void)switcherWillBeDismissed:(_Bool)arg1 -{ - if (willShowMissionControl == NO) - { - [[%c(RADesktopManager) sharedInstance] reshowDesktop]; - //[[[%c(RADesktopManager) sharedInstance] currentDesktop] loadApps]; +%hook SBNotificationCenterController +-(void)_showNotificationCenterGestureBeganWithGestureRecognizer:(id)arg1 { + CGPoint location = [arg1 locationInView:[[%c(SBMainSwitcherViewController) sharedInstance] view]]; + if ([[%c(RASettings) sharedInstance] missionControlEnabled] && [[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && CGRectContainsPoint([[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999].frame, location)) { + return; } - [UIView animateWithDuration:0.3 animations:^{ - [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].alpha = 0; - }]; - %orig; } +%end -// iOS 9 -- (void)_switcherWasDismissed:(_Bool)arg1 +%hook SBAppSwitcherController +// iOS 8 +- (void)switcherWillBeDismissed:(_Bool)arg1 { - HBLogDebug(@"_switcherWasDismissed"); if (willShowMissionControl == NO) { [[%c(RADesktopManager) sharedInstance] reshowDesktop]; @@ -123,7 +117,7 @@ BOOL willShowMissionControl = NO; } [UIView animateWithDuration:0.3 animations:^{ - [[%c(SBMainSwitcherViewController) sharedInstance] viewWithTag:999].alpha = 0; + [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].alpha = 0; }]; %orig; @@ -236,7 +230,6 @@ BOOL willShowMissionControl = NO; %new -(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { - HBLogDebug(@"Ran RAGestureCallback_handle"); if ([%c(SBUIController) respondsToSelector:@selector(_showNotificationsGestureFailed)]) { [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureFailed)]; [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureCancelled)]; @@ -423,4 +416,44 @@ BOOL willShowMissionControl = NO; ((UIView*)[view viewWithTag:999]).center = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, 20/2); } } + +- (void)viewWillDisappear:(BOOL)arg1 { + if (willShowMissionControl == NO) + { + [[%c(RADesktopManager) sharedInstance] reshowDesktop]; + //[[[%c(RADesktopManager) sharedInstance] currentDesktop] loadApps]; + } + + [UIView animateWithDuration:0.3 animations:^{ + [[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999].alpha = 0; + }]; + + %orig; +} + +-(void)viewDidAppear:(BOOL)arg1 { + statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; + willShowMissionControl = NO; + + if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) { + if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) { + [RAMissionControlManager.sharedInstance showMissionControl:YES]; + } else { + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } + } else { + if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) { + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } + } + + if ([[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999] != nil) { + [UIView animateWithDuration:0.3 animations:^{ + [[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999].alpha = 1; + }]; + } + [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; + + %orig; +} %end From 3e2bfc769e5826f0466239736dc1ada103503a8b Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sun, 22 Jan 2017 15:31:56 -0600 Subject: [PATCH 14/59] Fully Fixed MissionControls --- DRM/Statistics.xm | 2 +- MissionControl/ActivatorListener.xm | 2 + MissionControl/AppSwitcher.xm | 151 +++++++++++++++++++++++++++- RALocalizer.mm | 5 +- headers.h | 1 + 5 files changed, 158 insertions(+), 3 deletions(-) diff --git a/DRM/Statistics.xm b/DRM/Statistics.xm index 0830219..d30d4bc 100644 --- a/DRM/Statistics.xm +++ b/DRM/Statistics.xm @@ -4,7 +4,7 @@ { IF_SPRINGBOARD { #if DEBUG - HBLogDebug(@"[ReachApp][DRM] Not checking statistics on debug build"); + HBLogInfo(@"[ReachApp][DRM] Not checking statistics on debug build"); #else dispatch_async(dispatch_get_main_queue(), ^(void){ NSString *statsPath = @"/var/mobile/Library/Preferences/.multiplexer.stats_checked"; diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index c49ddee..776d4c1 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -16,6 +16,8 @@ static RAActivatorListener *sharedInstance; [RAMissionControlManager.sharedInstance toggleMissionControl:YES]; if ([%c(SBUIController) respondsToSelector:@selector(_appSwitcherController)]) { [[[%c(SBUIController) sharedInstance] _appSwitcherController] forceDismissAnimated:NO]; + } else { + [[%c(SBMainSwitcherViewController) sharedInstance] dismissSwitcherNoninteractively]; } } [event setHandled:YES]; diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 73d13f6..76ac57b 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -431,7 +431,7 @@ BOOL willShowMissionControl = NO; %orig; } --(void)viewDidAppear:(BOOL)arg1 { +- (void)viewDidAppear:(BOOL)arg1 { statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; willShowMissionControl = NO; @@ -456,4 +456,153 @@ BOOL willShowMissionControl = NO; %orig; } + +%new - (BOOL)RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity { + return allowMissionControlActivationFromSwitcher && [[%c(RASettings) sharedInstance] missionControlEnabled] && [[%c(SBUIController) sharedInstance] isAppSwitcherShowing]; +} + +%new - (RAGestureCallbackResult)RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { + if ([%c(SBUIController) respondsToSelector:@selector(_showNotificationsGestureFailed)]) { + [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureFailed)]; + [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureCancelled)]; + } else { + [[%c(SBNotificationCenterController) sharedInstance] performSelector:@selector(_showNotificationCenterGestureFailed)]; + [[%c(SBNotificationCenterController) sharedInstance] performSelector:@selector(_showNotificationCenterGestureCancelled)]; + } + + static CGFloat origY = -1; + static UIView *fakeView; + UIView *view = MSHookIvar(self, "_contentView"); + + if (!fakeView) { + UIImage *snapshot = [[%c(RASnapshotProvider) sharedInstance] storedSnapshotOfMissionControl]; + + if (snapshot) { + fakeView = [[UIImageView alloc] initWithFrame:view.frame]; + ((UIImageView*)fakeView).image = snapshot; + [view addSubview:fakeView]; + } else { + fakeView = [[UIView alloc] initWithFrame:view.frame]; + + CGFloat width = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 4.5714; + CGFloat height = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 4.36; + + _UIBackdropView *blurView = [[%c(_UIBackdropView) alloc] initWithStyle:1]; + blurView.frame = fakeView.frame; + [fakeView addSubview:blurView]; + + UILabel *desktopLabel, *windowedLabel, *otherLabel; + UIScrollView *desktopScrollView, *windowedAppScrollView, *otherRunningAppsScrollView; + + CGFloat x = 15; + CGFloat y = 25; + + desktopLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; + desktopLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + desktopLabel.textColor = UIColor.whiteColor; + desktopLabel.text = @"Desktops"; + [fakeView addSubview:desktopLabel]; + + y = y + desktopLabel.frame.size.height + 3; + + desktopScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y, fakeView.frame.size.width, height * 1.2)]; + desktopScrollView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.3]; + + [fakeView addSubview:desktopScrollView]; + + UIButton *newDesktopButton = [[UIButton alloc] init]; + newDesktopButton.frame = CGRectMake(x, 20, width, height); + newDesktopButton.backgroundColor = [UIColor darkGrayColor]; + [newDesktopButton setTitle:@"+" forState:UIControlStateNormal]; + newDesktopButton.titleLabel.font = [UIFont systemFontOfSize:36]; + [desktopScrollView addSubview:newDesktopButton]; + + x = 15; + y = desktopScrollView.frame.origin.y + desktopScrollView.frame.size.height + 5; + + windowedLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; + windowedLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + windowedLabel.textColor = UIColor.whiteColor; + windowedLabel.text = @"On This Desktop"; + [fakeView addSubview:windowedLabel]; + + windowedAppScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y + windowedLabel.frame.size.height + 3, fakeView.frame.size.width, height * 1.2)]; + windowedAppScrollView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.3]; + + [fakeView addSubview:windowedAppScrollView]; + + x = 15; + y = windowedAppScrollView.frame.origin.y + windowedAppScrollView.frame.size.height + 5; + + otherLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; + otherLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + otherLabel.textColor = UIColor.whiteColor; + otherLabel.text = @"Running Elsewhere"; + [fakeView addSubview:otherLabel]; + + otherRunningAppsScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y + otherLabel.frame.size.height + 3, fakeView.frame.size.width, height * 1.2)]; + otherRunningAppsScrollView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.3]; + + [fakeView addSubview:otherRunningAppsScrollView]; + + [view addSubview:fakeView]; + } + } + + if (origY == -1) { + CGRect f = fakeView.frame; + f.origin.y = -f.size.height; + fakeView.frame = f; + origY = fakeView.center.y; + } + + if (state == UIGestureRecognizerStateChanged) + fakeView.center = (CGPoint) { fakeView.center.x, origY + location.y }; + + if (state == UIGestureRecognizerStateEnded) { + //NSLog(@"[ReachApp] %@ + %@ = %@ > %@", NSStringFromCGPoint(fakeView.frame.origin), NSStringFromCGPoint(velocity), @(fakeView.frame.origin.y + velocity.y), @(-(UIScreen.mainScreen.bounds.size.height / 2))); + + if (fakeView.frame.origin.y + velocity.y > -(UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 2)) { + willShowMissionControl = YES; + CGFloat distance = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - (fakeView.frame.origin.y + fakeView.frame.size.height); + CGFloat duration = MIN(distance / velocity.y, 0.3); + + //NSLog(@"[ReachApp] dist %f, dur %f", distance, duration); + + [UIView animateWithDuration:duration animations:^{ + fakeView.frame = UIScreen.mainScreen.RA_interfaceOrientedBounds; + } completion:^(BOOL _) { + //((UIWindow*)[[%c(SBUIController) sharedInstance] switcherWindow]).alpha = 0; + if ([%c(SBUIController) respondsToSelector:@selector(dismissSwitcherAnimated:)]) { + [[%c(SBUIController) sharedInstance] dismissSwitcherAnimated:NO]; + } else { + [[%c(SBMainSwitcherViewController) sharedInstance] dismissSwitcherNoninteractively]; + } + [[%c(SBUIController) sharedInstance] restoreContentUpdatingStatusBar:YES]; + [RAMissionControlManager.sharedInstance showMissionControl:NO]; + [fakeView removeFromSuperview]; + fakeView = nil; + UIApplication.sharedApplication.statusBarHidden = statusBarVisibility; + // avoid status bar hiding + //dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + // ((UIWindow*)[[%c(SBUIController) sharedInstance] switcherWindow]).alpha = 1; + //}); + }]; + } else { + CGFloat distance = fakeView.frame.size.height + fakeView.frame.origin.y /* origin.y is less than 0 so the + is actually a - operation */; + CGFloat duration = MIN(distance / velocity.y, 0.3); + + //NSLog(@"[ReachApp] dist %f, dur %f", distance, duration); + + [UIView animateWithDuration:duration animations:^{ + fakeView.frame = CGRectMake(fakeView.frame.origin.x, -fakeView.frame.size.height, fakeView.frame.size.width, fakeView.frame.size.height); + } completion:^(BOOL _) { + [fakeView removeFromSuperview]; + fakeView = nil; + }]; + } + } + + return RAGestureCallbackResultSuccess; +} %end diff --git a/RALocalizer.mm b/RALocalizer.mm index 4ea386f..7804681 100644 --- a/RALocalizer.mm +++ b/RALocalizer.mm @@ -25,10 +25,13 @@ -(void) loadTranslation for (NSString *lang in langs) { + //NSDictionary *components = [NSLocale componentsFromLocaleIdentifier:lang]; + //NSString *languageDesignator = components[NSLocaleLanguageCode]; if ([self attemptLoadForLanguageCode:lang]) break; } if (!translation) + HBLogWarn(@"Failed Translation loading English"); [self attemptLoadForLanguageCode:@"en"]; } @@ -36,4 +39,4 @@ -(NSString*) localizedStringForKey:(NSString*)key { return [translation objectForKey:key] ? translation[key] : key; } -@end \ No newline at end of file +@end diff --git a/headers.h b/headers.h index 0d58a0c..0adfb36 100644 --- a/headers.h +++ b/headers.h @@ -1488,4 +1488,5 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) @interface SBMainSwitcherViewController : UIViewController + (id)sharedInstance; +- (BOOL)dismissSwitcherNoninteractively; @end From 528ee8ff64957440a19edb8cf136e067acff9bdf Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sun, 22 Jan 2017 18:37:15 -0600 Subject: [PATCH 15/59] Need to fix replaceAppSwitcherWithMC --- MissionControl/AppSwitcher.xm | 12 ++---------- RAAppSwitcherModelWrapper.xm | 2 +- update_status | 4 ++-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 76ac57b..5d7e81e 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -435,16 +435,8 @@ BOOL willShowMissionControl = NO; statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; willShowMissionControl = NO; - if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) { - if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) { - [RAMissionControlManager.sharedInstance showMissionControl:YES]; - } else { - [RAMissionControlManager.sharedInstance hideMissionControl:YES]; - } - } else { - if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) { - [RAMissionControlManager.sharedInstance hideMissionControl:YES]; - } + if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) { + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; } if ([[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999] != nil) { diff --git a/RAAppSwitcherModelWrapper.xm b/RAAppSwitcherModelWrapper.xm index 7b31d4f..1ee4406 100644 --- a/RAAppSwitcherModelWrapper.xm +++ b/RAAppSwitcherModelWrapper.xm @@ -29,7 +29,7 @@ if ([model respondsToSelector:@selector(snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary)]) return [model snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary]; - // iOS 9 most likely. + // iOS 9 most likely. NSMutableArray *ret = [NSMutableArray array]; diff --git a/update_status b/update_status index e3c4b39..8208744 100644 --- a/update_status +++ b/update_status @@ -7,9 +7,9 @@ Reachability: fixed GestureSupport: fixed Backgrounding: fixed KeyboardSupport: hackily fixed but it works now -MissionControl: initialization broken, otherwise fixed +MissionControl: working NCApp: fixed on phone, not working right on ipad (misplaced view & no title) -assertiond hooks: unknown +assertiond hooks: working backboardd hooks: unknown fake phone mode: working From 956f566db2837b3c9b04b126adb861d238bdb389 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sun, 22 Jan 2017 21:15:24 -0600 Subject: [PATCH 16/59] Better MS implementation --- MissionControl/AppSwitcher.xm | 76 +++++++++++------------ MissionControl/RAMissionControlManager.xm | 20 +++--- headers.h | 4 ++ 3 files changed, 51 insertions(+), 49 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 5d7e81e..0688372 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -380,11 +380,11 @@ BOOL willShowMissionControl = NO; } %end -%hook SBMainSwitcherViewController -- (void)viewDidLoad { +%hook SBSwitcherContainerView +- (void)layoutSubviews { %orig; - UIView *view = [self view]; + UIView *view = self; if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; @@ -417,38 +417,6 @@ BOOL willShowMissionControl = NO; } } -- (void)viewWillDisappear:(BOOL)arg1 { - if (willShowMissionControl == NO) - { - [[%c(RADesktopManager) sharedInstance] reshowDesktop]; - //[[[%c(RADesktopManager) sharedInstance] currentDesktop] loadApps]; - } - - [UIView animateWithDuration:0.3 animations:^{ - [[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999].alpha = 0; - }]; - - %orig; -} - -- (void)viewDidAppear:(BOOL)arg1 { - statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; - willShowMissionControl = NO; - - if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) { - [RAMissionControlManager.sharedInstance hideMissionControl:YES]; - } - - if ([[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999] != nil) { - [UIView animateWithDuration:0.3 animations:^{ - [[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999].alpha = 1; - }]; - } - [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; - - %orig; -} - %new - (BOOL)RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity { return allowMissionControlActivationFromSwitcher && [[%c(RASettings) sharedInstance] missionControlEnabled] && [[%c(SBUIController) sharedInstance] isAppSwitcherShowing]; } @@ -464,7 +432,7 @@ BOOL willShowMissionControl = NO; static CGFloat origY = -1; static UIView *fakeView; - UIView *view = MSHookIvar(self, "_contentView"); + UIView *view = self; if (!fakeView) { UIImage *snapshot = [[%c(RASnapshotProvider) sharedInstance] storedSnapshotOfMissionControl]; @@ -490,7 +458,7 @@ BOOL willShowMissionControl = NO; CGFloat y = 25; desktopLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; - desktopLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + desktopLabel.font = [UIFont fontWithName:@"SFUIText-Medium" size:14]; desktopLabel.textColor = UIColor.whiteColor; desktopLabel.text = @"Desktops"; [fakeView addSubview:desktopLabel]; @@ -513,7 +481,7 @@ BOOL willShowMissionControl = NO; y = desktopScrollView.frame.origin.y + desktopScrollView.frame.size.height + 5; windowedLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; - windowedLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + windowedLabel.font = [UIFont fontWithName:@"SFUIText-Medium" size:14]; windowedLabel.textColor = UIColor.whiteColor; windowedLabel.text = @"On This Desktop"; [fakeView addSubview:windowedLabel]; @@ -527,7 +495,7 @@ BOOL willShowMissionControl = NO; y = windowedAppScrollView.frame.origin.y + windowedAppScrollView.frame.size.height + 5; otherLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; - otherLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + otherLabel.font = [UIFont fontWithName:@"SFUIText-Medium" size:14]; otherLabel.textColor = UIColor.whiteColor; otherLabel.text = @"Running Elsewhere"; [fakeView addSubview:otherLabel]; @@ -598,3 +566,33 @@ BOOL willShowMissionControl = NO; return RAGestureCallbackResultSuccess; } %end + +%hook SBMainSwitcherViewController +- (void)viewDidAppear:(BOOL)arg1 { + %orig; + statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; + willShowMissionControl = NO; + + if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) { + if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) { + [RAMissionControlManager.sharedInstance showMissionControl:YES]; + } else { + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } + } else { + if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) { + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } + } + + [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; +} + +- (void)viewWillDisappear:(BOOL)arg1 { + if (!willShowMissionControl) { + [[%c(RADesktopManager) sharedInstance] reshowDesktop]; + //[[[%c(RADesktopManager) sharedInstance] currentDesktop] loadApps]; + } + %orig; +} +%end diff --git a/MissionControl/RAMissionControlManager.xm b/MissionControl/RAMissionControlManager.xm index bb2353c..cbb36b4 100644 --- a/MissionControl/RAMissionControlManager.xm +++ b/MissionControl/RAMissionControlManager.xm @@ -68,7 +68,7 @@ CGRect swappedForOrientation2(CGRect in) @implementation RAMissionControlManager +(instancetype) sharedInstance { - SHARED_INSTANCE2(RAMissionControlManager, + SHARED_INSTANCE2(RAMissionControlManager, sharedInstance->originalAppView = nil; sharedInstance.inhibitDismissalGesture = NO; sharedInstance->hasMoved = NO; @@ -82,7 +82,7 @@ CGRect swappedForOrientation2(CGRect in) dispatch_sync(dispatch_get_main_queue(), ^{ [self showMissionControl:animated]; }); return; } - + _isShowingMissionControl = YES; SBApplication *app = UIApplication.sharedApplication._accessibilityFrontMostApplication; @@ -94,7 +94,7 @@ CGRect swappedForOrientation2(CGRect in) if (animated) //window.alpha = 0; window.frame = swappedForOrientation(CGRectMake(0, -window.frame.size.height, window.frame.size.width, window.frame.size.height)); - + [window makeKeyAndVisible]; if (lastOpenedApp && lastOpenedApp.isRunning) @@ -106,8 +106,8 @@ CGRect swappedForOrientation2(CGRect in) if (animated) { //[UIView animateWithDuration:0.5 animations:^{ window.alpha = 1; }]; - [UIView animateWithDuration:0.5 animations:^{ - window.frame = CGRectMake(0, 0, window.frame.size.width, window.frame.size.height); + [UIView animateWithDuration:0.5 animations:^{ + window.frame = CGRectMake(0, 0, window.frame.size.width, window.frame.size.height); if (originalAppView) originalAppView.frame = swappedForOrientation2(CGRectMake(originalAppFrame.origin.x, originalAppView.frame.size.height, originalAppFrame.size.width, originalAppFrame.size.height)); @@ -123,7 +123,7 @@ CGRect swappedForOrientation2(CGRect in) [[%c(RAGestureManager) sharedInstance] ignoreSwipesBeginningInRect:UIScreen.mainScreen.bounds forIdentifier:@"com.efrederickson.reachapp.windowedmultitasking.systemgesture"]; [[%c(RARunningAppsProvider) sharedInstance] addTarget:window]; [%c(RAOrientationLocker) lockOrientation]; - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAMissionControlManager"]; + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAMissionControlManager"]; self.inhibitDismissalGesture = NO; [%c(RAControlCenterInhibitor) setInhibited:YES]; @@ -205,7 +205,7 @@ CGRect swappedForOrientation2(CGRect in) if (animated) { [UIView animateWithDuration:0.5 animations:^{ - window.frame = swappedForOrientation(CGRectMake(0, -window.frame.size.height, window.frame.size.width, window.frame.size.height)); + window.frame = swappedForOrientation(CGRectMake(0, -window.frame.size.height, window.frame.size.width, window.frame.size.height)); if (originalAppView) originalAppView.frame = originalAppFrame; @@ -280,7 +280,7 @@ CGRect swappedForOrientation2(CGRect in) [UIView animateWithDuration:duration animations:^{ if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortrait) window.center = CGPointMake(window.center.x, -initialCenter.y); - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { CGRect f = window.frame; f.origin.x = UIScreen.mainScreen.bounds.size.width; @@ -360,9 +360,9 @@ CGRect swappedForOrientation2(CGRect in) -(void) _updateLockState { %orig; - + if ([self hasAnyLockState]) if (RAMissionControlManager.sharedInstance.isShowingMissionControl) [RAMissionControlManager.sharedInstance hideMissionControl:NO]; } -%end \ No newline at end of file +%end diff --git a/headers.h b/headers.h index 0adfb36..f1f726f 100644 --- a/headers.h +++ b/headers.h @@ -1490,3 +1490,7 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) + (id)sharedInstance; - (BOOL)dismissSwitcherNoninteractively; @end + +@interface SBSwitcherContainerView : UIView +-(void)layoutSubviews; +@end From edb033117e444aafad55d6d383b0746a371749b8 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 23 Jan 2017 21:09:46 -0600 Subject: [PATCH 17/59] Updated Asphaleia support --- Asphaleia2.h | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Asphaleia2.h b/Asphaleia2.h index 3b69d4f..cc43229 100644 --- a/Asphaleia2.h +++ b/Asphaleia2.h @@ -1,28 +1,33 @@ #import -// https://gist.github.com/evilGoldfish/49753c4aa247b727453e - typedef NS_ENUM(NSInteger, ASAuthenticationAlertType) { - ASAuthenticationAlertAppArranging, - ASAuthenticationAlertSwitcher, - ASAuthenticationAlertSpotlight, - ASAuthenticationAlertPowerDown, - ASAuthenticationAlertControlCentre, - ASAuthenticationAlertControlPanel, - ASAuthenticationAlertPhotos, - ASAuthenticationAlertSettingsPanel, - ASAuthenticationAlertFlipswitch + ASAuthenticationAlertAppArranging, + ASAuthenticationAlertSwitcher, + ASAuthenticationAlertSpotlight, + ASAuthenticationAlertPowerDown, + ASAuthenticationAlertControlCentre, + ASAuthenticationAlertControlPanel, + ASAuthenticationAlertDynamicSelection, + ASAuthenticationAlertPhotos, + ASAuthenticationAlertSettingsPanel, + ASAuthenticationAlertFlipswitch +}; + +typedef NS_ENUM(NSInteger, ASAuthenticationType) { + ASAuthenticationItem, + ASAuthenticationFunction, + ASAuthenticationSecurityMod }; typedef void (^ASCommonAuthenticationHandler) (BOOL wasCancelled); @interface ASCommon : NSObject { - ASCommonAuthenticationHandler authHandler; + ASCommonAuthenticationHandler authHandler; } -+(instancetype)sharedInstance; --(UIAlertView *)currentAuthAlert; --(BOOL)authenticateAppWithDisplayIdentifier:(NSString *)appIdentifier customMessage:(NSString *)customMessage dismissedHandler:(ASCommonAuthenticationHandler)handler; --(BOOL)authenticateFunction:(ASAuthenticationAlertType)alertType dismissedHandler:(ASCommonAuthenticationHandler)handler; ++ (instancetype)sharedInstance; +- (BOOL)displayingAuthAlert; +- (BOOL)authenticateAppWithDisplayIdentifier:(NSString *)appIdentifier customMessage:(NSString *)customMessage dismissedHandler:(ASCommonAuthenticationHandler)handler; +- (BOOL)authenticateFunction:(ASAuthenticationAlertType)alertType dismissedHandler:(ASCommonAuthenticationHandler)handler; @end @@ -40,4 +45,4 @@ typedef void (^ASCommonAuthenticationHandler) (BOOL wasCancelled); }]; \ if (!isAppProtected) { \ success(); \ - } \ No newline at end of file + } From 37141803f3f5726ffec00930f5fd3f915900cc0f Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 28 Jan 2017 12:56:17 -0600 Subject: [PATCH 18/59] Reverted to MSHookFunction --- SpringBoard.xm | 2 +- reachappassertiondhooks/Tweak.xm | 46 +++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/SpringBoard.xm b/SpringBoard.xm index 44d4583..828985f 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -191,7 +191,7 @@ void reset_settings_notification(CFNotificationCenterRef center, void *observer, %ctor { - if (IS_SPRINGBOARD) + IF_SPRINGBOARD { %init; LOAD_ASPHALEIA; diff --git a/reachappassertiondhooks/Tweak.xm b/reachappassertiondhooks/Tweak.xm index 50b762c..56e3a29 100644 --- a/reachappassertiondhooks/Tweak.xm +++ b/reachappassertiondhooks/Tweak.xm @@ -1,20 +1,40 @@ #import +#import #import -@interface BSAuditToken : NSObject -- (int)pid; - @end +#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) -%hookf(int, "_BSAuditTokenTaskHasEntitlement", BSAuditToken *token, NSString *entitlement) { - if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { - return 1; - } - return %orig; +extern const char *__progname; + +static int (*orig_BSAuditTokenTaskHasEntitlement)(id connection, NSString *entitlement); +static int hax_BSAuditTokenTaskHasEntitlement(__unsafe_unretained id connection, __unsafe_unretained NSString *entitlement) { + if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { + return true; + } + + return orig_BSAuditTokenTaskHasEntitlement(connection, entitlement); +} + +static int (*orig_BSXPCConnectionHasEntitlement)(id connection, NSString *entitlement); +static int hax_BSXPCConnectionHasEntitlement(__unsafe_unretained id connection, __unsafe_unretained NSString *entitlement) { + if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { + return true; + } + + return orig_BSXPCConnectionHasEntitlement(connection, entitlement); } -%hookf(int, "_BSXPCConnectionHasEntitlement", id connection, NSString *entitlement) { - if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { - return 1; - } - return %orig; +%ctor { + // We can never be too sure + if (strcmp(__progname, "assertiond") == 0) { + HBLogDebug(@"Is assertiond"); + dlopen("/System/Library/PrivateFrameworks/XPCObjects.framework/XPCObjects", RTLD_LAZY); + if (SYSTEM_VERSION_LESS_THAN(@"9.0")) { + void *xpcFunction = MSFindSymbol(NULL, "_BSAuditTokenTaskHasEntitlement"); + MSHookFunction(xpcFunction, (void *)hax_BSAuditTokenTaskHasEntitlement, (void **)&orig_BSAuditTokenTaskHasEntitlement); + } else { + void *xpcFunction = MSFindSymbol(NULL, "_BSXPCConnectionHasEntitlement"); + MSHookFunction(xpcFunction, (void *)hax_BSXPCConnectionHasEntitlement, (void **)&orig_BSXPCConnectionHasEntitlement); + } + } } From 730dd28fdb1f61e7425b810de88441ff9f4ad6b0 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Wed, 1 Feb 2017 19:44:45 -0600 Subject: [PATCH 19/59] some 10.X support --- GestureSupport/Hooks_iOS9.xm | 6 +++--- NotificationCenterApp/NCHook.xm | 4 ++++ README.md | 14 +++++++------- Reachability/Reachability.xm | 21 ++++++++++++++++++--- SpringBoard.xm | 24 ++++++++++++++++++++++++ headers.h | 3 +-- update_status | 8 ++++---- 7 files changed, 61 insertions(+), 19 deletions(-) diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index 7ec87bd..56ac920 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -23,11 +23,11 @@ static BOOL isTracking = NO; static NSMutableSet *gestureRecognizers; UIRectEdge currentEdge9; -struct VelocityData { +typedef struct { CGPoint velocity; double timestamp; CGPoint location; -}; +} VelocityData; %hook _UIScreenEdgePanRecognizer - (void)incorporateTouchSampleAtLocation:(CGPoint)location timestamp:(double)timestamp modifier:(NSInteger)modifier interfaceOrientation:(UIInterfaceOrientation)orientation forceState:(int)arg5 @@ -205,7 +205,7 @@ __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; { _UIScreenEdgePanRecognizer *recognizer = [[_UIScreenEdgePanRecognizer alloc] initWithType:2]; recognizer.targetEdges = edgesToWatch[i]; - recognizer.screenBounds = UIScreen.mainScreen.bounds; + recognizer.screenBounds = UIScreen.mainScreen._referenceBounds; [gestureRecognizers addObject:recognizer]; } diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index 06f9252..99bd796 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -73,6 +73,10 @@ RANCViewController *ncAppViewController; } } +- (id)_localizableTitleForColumnViewController:(id)arg1 { + HBLogDebug(@"Ran _localizableTitleForColumnViewController"); + return %orig; +} %end // This is more of a hack than anything else. Note that `_localizableTitleForColumnViewController` on iOS 9 does not seem to work (I may be doing something else wrong) diff --git a/README.md b/README.md index fd4fe15..ee6f1e0 100644 --- a/README.md +++ b/README.md @@ -18,22 +18,22 @@ See /wiki for some code tutorials. - Empoleon: working - fs daemon: working - SwipeOver: fixed -- Reachability: fixed +- Reachability: working - GestureSupport: fixed -- Backgrounding: fixed +- Backgrounding: working - KeyboardSupport: hackily fixed but it works now -- MissionControl: initialization broken, otherwise fixed +- MissionControl: fixed - NCApp: fixed -- assertiond hooks: unknown +- assertiond hooks: working - backboardd hooks: unknown -- fake phone mode: unknown +- fake phone mode: fixed see the update_status file for more info on the iOS 9 changes. ### API -There is a full public API (as opposed to the private/interval api and headers) that allows anyone to create addons, widgets, and tweaks (Tweakception!) for Multiplexer. +There is a full public API (as opposed to the private/interval api and headers) that allows anyone to create addons, widgets, and tweaks (Tweakception!) for Multiplexer. The public api can be found in public_api. This api is less likely to change or be removed as opposed to the other headers and stuff. For the end user's ease of use, please register your extensions with -[Multiplexer registerExtension:forMultiplexerVersion:]. I hope to also move the core functions into extensions, provide api requirements, etc at some point. Currently it is only compatible with iOS 8, however some measures have been taken to ease the process of making it compatible with other iOS editions (whether future or past). -There are some "options" or features that are in here but are disabled or otherwise removed because either they don't work or there's no point having them. +There are some "options" or features that are in here but are disabled or otherwise removed because either they don't work or there's no point having them. diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 6617715..2c62d10 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -36,7 +36,7 @@ CGFloat old_grabberCenterY = -1; BOOL wasEnabled = NO; -%group hooks +%group SBReachability %hook SBReachabilityManager +(BOOL)reachabilitySupported @@ -145,6 +145,10 @@ BOOL wasEnabled = NO; %end +%end + +%group SBWorkspace + id SBWorkspace$sharedInstance; %hook SB_WORKSPACE_CLASS %new +(id) sharedInstance @@ -852,11 +856,22 @@ CGFloat startingY = -1; } %end +%end + +%group SpringBoard + %hook SpringBoard - (UIInterfaceOrientation)activeInterfaceOrientation { return overrideOrientation ? UIInterfaceOrientationPortrait : %orig; } + +- (void)applicationDidFinishLaunching:(id)arg1 +{ + Class c = objc_getClass("SBMainWorkspace") ?: objc_getClass("SBWorkspace"); + %init(SBWorkspace, SB_WORKSPACE_CLASS=c); + %orig; +} %end %end @@ -865,7 +880,7 @@ CGFloat startingY = -1; { IF_SPRINGBOARD { - Class c = objc_getClass("SBMainWorkspace") ?: objc_getClass("SBWorkspace"); - %init(hooks, SB_WORKSPACE_CLASS=c); + %init(SBReachability); + %init(SpringBoard); } } diff --git a/SpringBoard.xm b/SpringBoard.xm index 828985f..9f60e93 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -45,6 +45,30 @@ extern BOOL overrideDisableForStatusBar; return %orig; } +- (BOOL)handleHomeButtonSinglePressUp +{ + if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) + { + [[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver]; + return YES; + } + + if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) + { + overrideDisableForStatusBar = NO; + [[%c(SBReachabilityManager) sharedInstance] _handleReachabilityDeactivated]; + return YES; + } + + if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) + { + [[%c(RAMissionControlManager) sharedInstance] hideMissionControl:YES]; + return YES; + } + + return %orig; +} + /*- (_Bool)handleMenuDoubleTap { if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) diff --git a/headers.h b/headers.h index f1f726f..b6fb2e3 100644 --- a/headers.h +++ b/headers.h @@ -266,7 +266,6 @@ return sharedInstance; @interface BKSProcess : NSObject { //BSBaseXPCClient { int _pid; NSString *_bundlePath; - NSObject *_clientQueue; bool _workspaceLocked; bool _connectedToExternalAccessories; bool _nowPlayingWithAudio; @@ -1491,6 +1490,6 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (BOOL)dismissSwitcherNoninteractively; @end -@interface SBSwitcherContainerView : UIView +@interface SBSwitcherContainerView : UIView -(void)layoutSubviews; @end diff --git a/update_status b/update_status index 8208744..5b72398 100644 --- a/update_status +++ b/update_status @@ -3,12 +3,12 @@ update status: Windowed: working fs daemon: working SwipeOver: working (replace with native slide over(?)) -Reachability: fixed +Reachability: working GestureSupport: fixed -Backgrounding: fixed +Backgrounding: working KeyboardSupport: hackily fixed but it works now -MissionControl: working -NCApp: fixed on phone, not working right on ipad (misplaced view & no title) +MissionControl: fixed +NCApp: fixed on phone, not working right on ipad (misplaced view & no title) needs major overhaul for 10.X assertiond hooks: working backboardd hooks: unknown fake phone mode: working From 72be58bc273fe22069fb90cf07e9c11d55159aa4 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Wed, 1 Feb 2017 21:20:04 -0600 Subject: [PATCH 20/59] Working on MS grabber --- MissionControl/AppSwitcher.xm | 34 ++++++++++++++++++++++------------ headers.h | 10 ++++++++++ update_status | 2 +- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 0688372..6dc0769 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -392,25 +392,35 @@ BOOL willShowMissionControl = NO; width = 60; height = 40; } - SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; - grabber.center = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, 20/2); + if ([%c(SBControlCenterGrabberView) class]) { + SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; - grabber.backgroundColor = [UIColor clearColor]; - //grabber.chevronView.vibrantSettings = [%c(_SBFVibrantSettings) vibrantSettingsWithReferenceColor:UIColor.whiteColor referenceContrast:0.5 legibilitySettings:nil]; + grabber.center = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, 20/2); - _UIBackdropView *blurView = [[%c(_UIBackdropView) alloc] initWithStyle:2060]; - blurView.frame = grabber.frame; - [grabber insertSubview:blurView atIndex:0]; - [grabber.chevronView setState:1 animated:NO]; + grabber.backgroundColor = [UIColor clearColor]; + //grabber.chevronView.vibrantSettings = [%c(_SBFVibrantSettings) vibrantSettingsWithReferenceColor:UIColor.whiteColor referenceContrast:0.5 legibilitySettings:nil]; - grabber.layer.cornerRadius = 5; + _UIBackdropView *blurView = [[%c(_UIBackdropView) alloc] initWithStyle:2060]; + blurView.frame = grabber.frame; + [grabber insertSubview:blurView atIndex:0]; - //[grabber.chevronView setState:1 animated:YES]; - grabber.tag = 999; - [view addSubview:grabber]; + [grabber.chevronView setState:1 animated:NO]; + + grabber.layer.cornerRadius = 5; + + //[grabber.chevronView setState:1 animated:YES]; + grabber.tag = 999; + [view addSubview:grabber]; + } else { + NCNotificationGrabberView *grabber = [[NCNotificationGrabberView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; + + grabber.tag = 999; + [view addSubview:grabber]; + + } [[%c(RAGestureManager) sharedInstance] addGestureRecognizerWithTarget:(NSObject *)self forEdge:UIRectEdgeTop identifier:@"com.efrederickson.reachapp.appswitchergrabber"]; } else { ((UIView*)[view viewWithTag:999]).center = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, 20/2); diff --git a/headers.h b/headers.h index b6fb2e3..966c701 100644 --- a/headers.h +++ b/headers.h @@ -1493,3 +1493,13 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) @interface SBSwitcherContainerView : UIView -(void)layoutSubviews; @end + +@interface SBUIChevronView : UIView +-(id)initWithFrame:(CGRect)arg1; +-(void)setState:(long long)arg1 animated:(BOOL)arg2; +-(void)setBackgroundView:(id)arg1; +@end + +@interface NCNotificationGrabberView : UIView +-(id)initWithFrame:(CGRect)arg1; +@end diff --git a/update_status b/update_status index 5b72398..fbdc2d9 100644 --- a/update_status +++ b/update_status @@ -7,7 +7,7 @@ Reachability: working GestureSupport: fixed Backgrounding: working KeyboardSupport: hackily fixed but it works now -MissionControl: fixed +MissionControl: broken in app and grabber disappears? NCApp: fixed on phone, not working right on ipad (misplaced view & no title) needs major overhaul for 10.X assertiond hooks: working backboardd hooks: unknown From d474902d6c6e45719ccd158dd15e484f7a6a9212 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Wed, 1 Feb 2017 22:06:12 -0600 Subject: [PATCH 21/59] Updated backgrounding --- Backgrounding/SpringBoard.xm | 25 ++++++++++++++++++++----- MissionControl/AppSwitcher.xm | 2 +- headers.h | 3 +++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Backgrounding/SpringBoard.xm b/Backgrounding/SpringBoard.xm index 5f26350..a268927 100644 --- a/Backgrounding/SpringBoard.xm +++ b/Backgrounding/SpringBoard.xm @@ -62,12 +62,27 @@ } return %orig(arg1, arg2, arg3, arg4, arg5, arg6); } + +- (id)_initWithQueue:(id)arg1 callOutQueue:(id)arg2 identifier:(id)arg3 specification:(id)arg4 display:(id)arg5 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg6 clientSettings:(id)arg7 +{ + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg3]) + { + // what? + if (!arg6) + { + UIMutableApplicationSceneSettings *fakeSettings = [[%c(UIMutableApplicationSceneSettings) alloc] init]; + arg6 = fakeSettings; + } + SET_BACKGROUNDED(arg6, NO); + } + return %orig(arg1, arg2, arg3, arg4, arg5, arg6, arg7); +} %end %hook FBUIApplicationWorkspaceScene -(void) host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 { - [RABackgrounder.sharedInstance removeTemporaryOverrideForIdentifier:arg1.identifier]; + [RABackgrounder.sharedInstance removeTemporaryOverrideForIdentifier:arg1.identifier]; if (arg1 && arg1.identifier && arg2 && arg1.clientProcess) // FIX: sanity check to prevent NC App crash. untested/not working. { if (arg2.backgrounded) @@ -86,24 +101,24 @@ [%c(RAAppSwitcherModelWrapper) removeItemWithIdentifier:arg1.identifier]; } } - [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; + [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; } if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.identifier]) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; - [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; + [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; return; } else if ([RABackgrounder.sharedInstance backgroundModeForIdentifier:arg1.identifier] == RABackgroundModeNative) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; - [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; + [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; } else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; - [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; + [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; } } else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 6dc0769..fef70a7 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -415,7 +415,7 @@ BOOL willShowMissionControl = NO; [view addSubview:grabber]; } else { - NCNotificationGrabberView *grabber = [[NCNotificationGrabberView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; + NCNotificationGrabberView *grabber = [[%c(NCNotificationGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; grabber.tag = 999; [view addSubview:grabber]; diff --git a/headers.h b/headers.h index 966c701..49d9038 100644 --- a/headers.h +++ b/headers.h @@ -1503,3 +1503,6 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) @interface NCNotificationGrabberView : UIView -(id)initWithFrame:(CGRect)arg1; @end + +@interface SBDashBoardPageViewController : UIViewController +@end From 743c80b37988befa3f3faa7eab3b5e67c9700772 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 17 Feb 2017 21:57:24 -0600 Subject: [PATCH 22/59] Fixed ControlCenter Inhibitor --- Backgrounding/SpringBoard.xm | 12 ++++++------ Multiplexer.xm | 2 +- RAControlCenterInhibitor.xm | 8 ++++++++ Tweak.xm | 14 ++++++++------ update_status | 2 +- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Backgrounding/SpringBoard.xm b/Backgrounding/SpringBoard.xm index a268927..32d43c3 100644 --- a/Backgrounding/SpringBoard.xm +++ b/Backgrounding/SpringBoard.xm @@ -63,19 +63,19 @@ return %orig(arg1, arg2, arg3, arg4, arg5, arg6); } -- (id)_initWithQueue:(id)arg1 callOutQueue:(id)arg2 identifier:(id)arg3 specification:(id)arg4 display:(id)arg5 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg6 clientSettings:(id)arg7 +- (id)initWithQueue:(id)arg1 identifier:(id)arg2 display:(id)arg3 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg4 clientSettings:(id)arg5 { - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg3]) + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2]) { // what? - if (!arg6) + if (!arg4) { UIMutableApplicationSceneSettings *fakeSettings = [[%c(UIMutableApplicationSceneSettings) alloc] init]; - arg6 = fakeSettings; + arg4 = fakeSettings; } - SET_BACKGROUNDED(arg6, NO); + SET_BACKGROUNDED(arg4, NO); } - return %orig(arg1, arg2, arg3, arg4, arg5, arg6, arg7); + return %orig(arg1, arg2, arg3, arg4, arg5); } %end diff --git a/Multiplexer.xm b/Multiplexer.xm index 509d41e..67f866d 100644 --- a/Multiplexer.xm +++ b/Multiplexer.xm @@ -57,7 +57,7 @@ //create transititon request SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[UIScreen.mainScreen valueForKey:@"_fbsDisplay"]]; - [transitionRequest setApplicationContext:transitionContext]; + [transitionRequest setValue:transitionContext forKey:@"_applicationContext"]; return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithTransitionRequest:transitionRequest]; // ** // diff --git a/RAControlCenterInhibitor.xm b/RAControlCenterInhibitor.xm index ab16c45..ad31bd9 100644 --- a/RAControlCenterInhibitor.xm +++ b/RAControlCenterInhibitor.xm @@ -28,3 +28,11 @@ BOOL overrideCC = NO; %orig; } %end + +%hook SBControlCenterController +- (void)presentAnimated:(BOOL)arg1 completion:(id)arg2 +{ + if (!overrideCC) + %orig; +} +%end diff --git a/Tweak.xm b/Tweak.xm index cc91ecb..756ee04 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -3,7 +3,7 @@ #include /* -This project thanks: +This project thanks: ForceReach: https://github.com/PoomSmart/ForceReach/ Reference: https://github.com/fewjative/Reference MessageBox: https://github.com/b3ll/MessageBox @@ -14,13 +14,13 @@ Various concepts / help / ideas: Ethan Arbuckle (@its_not_herpes) Many concepts and ideas have been used from them. Unlike shinvou's claims, however, there was no copyright violation. Nor did I use any of his code. Or Auxo 3's for that matter. See here for context: https://www.reddit.com/r/jailbreak/comments/3esp30/question_how_come_we_all_desperately_waited_for/cti3eck -Any code based off of or using parts of the above projects is documented. +Any code based off of or using parts of the above projects is documented. */ // IS_SPRINGBOARD macro optimized from always comparing NSBundle - because it won't change in-process BOOL $__IS_SPRINGBOARD = NO; -%ctor +%ctor { $__IS_SPRINGBOARD = [NSBundle.mainBundle.bundleIdentifier isEqual:@"com.apple.springboard"]; } @@ -29,9 +29,11 @@ void SET_BACKGROUNDED(id settings, BOOL value) { #if __has_feature(objc_arc) // stupid ARC... - ptrdiff_t bgOffset = ivar_getOffset(class_getInstanceVariable([settings class], "_backgrounded")); - char *bgPtr = ((char *)(__bridge void *)settings) + bgOffset; - memcpy(bgPtr, &value, sizeof(value)); + ptrdiff_t bgOffset = ivar_getOffset(class_getInstanceVariable([settings class], "_backgrounded")); + CFTypeRef settingsRef = CFBridgingRetain(settings); + uint8_t *bgPtr = ((uint8_t *)(__bridge void *)settings) + bgOffset; + memcpy(bgPtr, &value, sizeof(value)); + CFBridgingRelease(settingsRef); #else // ARC is off, easy way if (value) diff --git a/update_status b/update_status index fbdc2d9..66a391c 100644 --- a/update_status +++ b/update_status @@ -1,6 +1,6 @@ update status: -Windowed: working +Windowed: working (asphaleia breaks for some reason?) fs daemon: working SwipeOver: working (replace with native slide over(?)) Reachability: working From 512df6840c3da421abc60e627d96c7c530fffd8f Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 17 Feb 2017 22:43:25 -0600 Subject: [PATCH 23/59] MC grabber partially fixed --- MissionControl/AppSwitcher.xm | 8 ++++---- headers.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index fef70a7..909541c 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -384,7 +384,7 @@ BOOL willShowMissionControl = NO; - (void)layoutSubviews { %orig; - UIView *view = self; + UIView *view = self.contentView; if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; @@ -396,7 +396,7 @@ BOOL willShowMissionControl = NO; if ([%c(SBControlCenterGrabberView) class]) { SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; - grabber.center = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, 20/2); + grabber.center = CGPointMake(UIScreen.mainScreen.bounds.size.width / 2, 20/2); grabber.backgroundColor = [UIColor clearColor]; @@ -423,7 +423,7 @@ BOOL willShowMissionControl = NO; } [[%c(RAGestureManager) sharedInstance] addGestureRecognizerWithTarget:(NSObject *)self forEdge:UIRectEdgeTop identifier:@"com.efrederickson.reachapp.appswitchergrabber"]; } else { - ((UIView*)[view viewWithTag:999]).center = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, 20/2); + ((UIView*)[view viewWithTag:999]).center = CGPointMake(UIScreen.mainScreen.bounds.size.width / 2, 20/2); } } @@ -442,7 +442,7 @@ BOOL willShowMissionControl = NO; static CGFloat origY = -1; static UIView *fakeView; - UIView *view = self; + UIView *view = self.contentView; if (!fakeView) { UIImage *snapshot = [[%c(RASnapshotProvider) sharedInstance] storedSnapshotOfMissionControl]; diff --git a/headers.h b/headers.h index 49d9038..fe08598 100644 --- a/headers.h +++ b/headers.h @@ -1491,6 +1491,7 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) @end @interface SBSwitcherContainerView : UIView +@property (nonatomic,retain) UIView * contentView; -(void)layoutSubviews; @end From b048d255dce6ff63ee1c9d3d94d7089e2d816e7c Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 18 Feb 2017 21:17:04 -0600 Subject: [PATCH 24/59] Fixed Grabber --- MissionControl/AppSwitcher.xm | 22 ++++++++++++++++++++-- headers.h | 18 +++++++++++++----- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 909541c..53ec4de 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -98,7 +98,8 @@ BOOL willShowMissionControl = NO; %hook SBNotificationCenterController -(void)_showNotificationCenterGestureBeganWithGestureRecognizer:(id)arg1 { CGPoint location = [arg1 locationInView:[[%c(SBMainSwitcherViewController) sharedInstance] view]]; - if ([[%c(RASettings) sharedInstance] missionControlEnabled] && [[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && CGRectContainsPoint([[[%c(SBMainSwitcherViewController) sharedInstance] view] viewWithTag:999].frame, location)) { + if ([[%c(RASettings) sharedInstance] missionControlEnabled] && [[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && CGRectContainsPoint([[[[%c(SBMainSwitcherViewController) sharedInstance] valueForKey:@"_contentView"] contentView] viewWithTag:999].frame, location)) { + HBLogDebug(@"contains rect"); return; } @@ -415,7 +416,24 @@ BOOL willShowMissionControl = NO; [view addSubview:grabber]; } else { - NCNotificationGrabberView *grabber = [[%c(NCNotificationGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; + UIView *grabber = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; + + grabber.center = CGPointMake(UIScreen.mainScreen.bounds.size.width / 2, 20/2); + + _UIBackdropView *blurView = [[%c(_UIBackdropView) alloc] initWithStyle:2060]; + blurView.frame = grabber.frame; + blurView._blurRadius = 30; + [blurView _setCornerRadius:6]; + [blurView _applyCornerRadiusToSubviews]; + [grabber addSubview:blurView]; + + SBUIChevronView *chevronView = [[%c(SBUIChevronView) alloc] initWithColor:[UIColor blackColor]]; + chevronView.frame = CGRectMake((width - 36) / 2, (height - 14) / 2, 36, 14); + [chevronView setState:1 animated:YES]; + chevronView.alpha = 0.6499; + [grabber addSubview:chevronView]; + + grabber.layer.cornerRadius = 6; grabber.tag = 999; [view addSubview:grabber]; diff --git a/headers.h b/headers.h index fe08598..cd46dc4 100644 --- a/headers.h +++ b/headers.h @@ -638,12 +638,15 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @interface _UIBackdropView : UIView @property (retain, nonatomic) _UIBackdropViewSettings *outputSettings; @property (retain, nonatomic) _UIBackdropViewSettings *inputSettings; +@property (assign,nonatomic) double _blurRadius; @property (nonatomic) int blurHardEdges; +- (void)_applyCornerRadiusToSubviews; +- (void)_setCornerRadius:(double)arg1 ; - (void) setBlursWithHardEdges:(BOOL)arg1; - (void)setBlurQuality:(id)arg1; --(void) setBlurRadius:(CGFloat)radius; --(void) setBlurRadiusSetOnce:(BOOL)v; --(id) initWithStyle:(NSInteger)style; +- (void)setBlurRadius:(CGFloat)radius; +- (void)setBlurRadiusSetOnce:(BOOL)v; +- (id)initWithStyle:(NSInteger)style; @property (nonatomic) BOOL autosizesToFitSuperview; @property (nonatomic) BOOL blursBackground; - (void)_setBlursBackground:(BOOL)arg1; @@ -1485,18 +1488,23 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (void)setSnapshotReferenceFrame:(CGRect)arg1 ; @end -@interface SBMainSwitcherViewController : UIViewController +@interface SBMainSwitcherViewController : UIViewController + (id)sharedInstance; - (BOOL)dismissSwitcherNoninteractively; @end @interface SBSwitcherContainerView : UIView @property (nonatomic,retain) UIView * contentView; --(void)layoutSubviews; +- (void)layoutSubviews; +- (UIView *)contentView; @end @interface SBUIChevronView : UIView +@property (assign,nonatomic) long long state; +@property (nonatomic,retain) UIColor * color; -(id)initWithFrame:(CGRect)arg1; +-(id)initWithColor:(id)arg1 ; +-(void)setColor:(UIColor *)arg1 ; -(void)setState:(long long)arg1 animated:(BOOL)arg2; -(void)setBackgroundView:(id)arg1; @end From 1947dd43561243f82eed56fc5a441c4a94525da9 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 18 Feb 2017 21:42:45 -0600 Subject: [PATCH 25/59] Updating status --- MissionControl/AppSwitcher.xm | 2 +- update_status | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 53ec4de..1e3ea26 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -429,7 +429,7 @@ BOOL willShowMissionControl = NO; SBUIChevronView *chevronView = [[%c(SBUIChevronView) alloc] initWithColor:[UIColor blackColor]]; chevronView.frame = CGRectMake((width - 36) / 2, (height - 14) / 2, 36, 14); - [chevronView setState:1 animated:YES]; + [chevronView setState:1 animated:NO]; chevronView.alpha = 0.6499; [grabber addSubview:chevronView]; diff --git a/update_status b/update_status index 66a391c..5b121d7 100644 --- a/update_status +++ b/update_status @@ -1,13 +1,13 @@ update status: -Windowed: working (asphaleia breaks for some reason?) +Windowed: working fs daemon: working SwipeOver: working (replace with native slide over(?)) Reachability: working GestureSupport: fixed Backgrounding: working KeyboardSupport: hackily fixed but it works now -MissionControl: broken in app and grabber disappears? +MissionControl: working (MC presents even when not dragging grabber) NCApp: fixed on phone, not working right on ipad (misplaced view & no title) needs major overhaul for 10.X assertiond hooks: working backboardd hooks: unknown From 190128db8ff031b265d2aa44a7780d3feb5c7183 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 20 Feb 2017 15:45:27 -0600 Subject: [PATCH 26/59] proper respring --- NotificationCenterApp/NCHook.xm | 5 ----- SpringBoard.xm | 14 ++++++++++---- headers.h | 12 ++++++------ .../BackgroundPerAppDetailsController.xm | 10 +++++----- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index 99bd796..f918c5a 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -72,11 +72,6 @@ RANCViewController *ncAppViewController; [modeVC _addBulletinObserverViewController:ncAppViewController]; } } - -- (id)_localizableTitleForColumnViewController:(id)arg1 { - HBLogDebug(@"Ran _localizableTitleForColumnViewController"); - return %orig; -} %end // This is more of a hack than anything else. Note that `_localizableTitleForColumnViewController` on iOS 9 does not seem to work (I may be doing something else wrong) diff --git a/SpringBoard.xm b/SpringBoard.xm index 9f60e93..f929665 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -45,7 +45,7 @@ extern BOOL overrideDisableForStatusBar; return %orig; } -- (BOOL)handleHomeButtonSinglePressUp +- (BOOL)handleHomeButtonSinglePressUp { if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) { @@ -205,7 +205,13 @@ extern BOOL overrideDisableForStatusBar; void respring_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { - [[%c(FBSystemService) sharedInstance] exitAndRelaunch:YES]; + SpringBoard *springBoard = (SpringBoard*)[UIApplication sharedApplication]; + if ([springBoard respondsToSelector:@selector(_relaunchSpringBoardNow)]) { + [springBoard _relaunchSpringBoardNow]; + } else { + SBSRestartRenderServerAction *restartAction = [%c(SBSRestartRenderServerAction) restartActionWithTargetRelaunchURL:nil]; + [[%c(FBSSystemService) sharedService] sendActions:[NSSet setWithObject:restartAction] withResult:nil]; + } } void reset_settings_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) @@ -220,7 +226,7 @@ void reset_settings_notification(CFNotificationCenterRef center, void *observer, %init; LOAD_ASPHALEIA; - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, respring_notification, CFSTR("com.efrederickson.reachapp.respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, reset_settings_notification, CFSTR("com.efrederickson.reachapp.resetSettings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &respring_notification, CFSTR("com.efrederickson.reachapp.respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reset_settings_notification, CFSTR("com.efrederickson.reachapp.resetSettings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); } } diff --git a/headers.h b/headers.h index cd46dc4..7ace09c 100644 --- a/headers.h +++ b/headers.h @@ -19,6 +19,8 @@ #import #import #import +#import +#import #define RA_BASE_PATH @"/Library/Multiplexer" @@ -1488,7 +1490,7 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (void)setSnapshotReferenceFrame:(CGRect)arg1 ; @end -@interface SBMainSwitcherViewController : UIViewController +@interface SBMainSwitcherViewController : UIViewController + (id)sharedInstance; - (BOOL)dismissSwitcherNoninteractively; @end @@ -1509,9 +1511,7 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) -(void)setBackgroundView:(id)arg1; @end -@interface NCNotificationGrabberView : UIView --(id)initWithFrame:(CGRect)arg1; -@end - -@interface SBDashBoardPageViewController : UIViewController +@interface SBPagedScrollView : UIScrollView +- (NSArray *)pageViews; +- (void)setPageViews:(NSArray *)arg1; @end diff --git a/reachappsettings/BackgroundPerAppDetailsController.xm b/reachappsettings/BackgroundPerAppDetailsController.xm index 64d6214..c48f825 100644 --- a/reachappsettings/BackgroundPerAppDetailsController.xm +++ b/reachappsettings/BackgroundPerAppDetailsController.xm @@ -52,7 +52,7 @@ extern void RA_BGAppsControllerNeedsToReload(); }, @{ @"cell": @"PSSwitchCell", - @"label": @"Auto Launch", + @"label": @"Auto Launch (On Boot)", @"key": @"autoLaunch", @"default": @NO, }, @@ -62,7 +62,7 @@ extern void RA_BGAppsControllerNeedsToReload(); @"key": @"autoRelaunch", @"default": @NO, }, - + @{ @"footerText": @"If the app's background mode is Disabled, this will remove the app from the switcher in addition to killing it." }, @{ @"cell": @"PSSwitchCell", @@ -89,9 +89,9 @@ extern void RA_BGAppsControllerNeedsToReload(); @"enabled": @(!preventDeath), @"reloadSpecifiersXX": @YES, }, - @{ + @{ @"cell": @"PSGroupCell", - @"label": @"Native Backgrounding Modes", + @"label": @"Native Backgrounding Modes", @"footerText": @"A respring is required to apply changes to these values. Just because a mode has been enabled does not necessarily mean it will be used by the app.", }, @{ @@ -256,4 +256,4 @@ The status bar icon is simply the app icon.", }, NSString *key = [specifier propertyForKey:@"prefix"] ? [NSString stringWithFormat:@"backgrounder-%@-%@-%@",_identifier,[specifier propertyForKey:@"prefix"],[specifier propertyForKey:@"key"]] : [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,[specifier propertyForKey:@"key"]]; return [_settings objectForKey:key] == nil ? [specifier propertyForKey:@"default"] : _settings[key]; } -@end \ No newline at end of file +@end From 6d9e19ff5439e6ec0a62d397d107b5305ae300e6 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 20 Feb 2017 17:36:22 -0600 Subject: [PATCH 27/59] Fixed NCApps (thanks logandev22!) --- NotificationCenterApp/NCHook.xm | 58 +++++++++++++++++++--- NotificationCenterApp/RANCViewController.h | 2 +- reachappsettings/NCApp.xm | 2 +- update_status | 2 +- 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index f918c5a..367c975 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -101,14 +101,58 @@ RANCViewController *ncAppViewController; %end %end -%ctor +%group iOS10 +%hook SBPagedScrollView +static BOOL hasEnteredPages = NO; + +- (void)layoutSubviews { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) - { - %init(iOS9); - } - else + %orig; + + if (!hasEnteredPages && [self.superview isKindOfClass:[%c(SBSearchEtceteraLayoutView) class]]) { - %init(iOS8); + if (ncAppViewController == nil) + ncAppViewController = [[RANCViewController alloc] init]; + + NSMutableArray *newArray = [[self pageViews] mutableCopy]; + [newArray addObject:ncAppViewController.view]; + [self setPageViews:newArray]; + + hasEnteredPages = YES; } } +%end + +%hook SBNotificationCenterController +- (void)_handleDismissGesture:(id)arg1 +{ + %orig; + [ncAppViewController viewDidDisappear:YES]; +} +%end + +%hook SBNotificationCenterViewController +- (UIPageControl*)pageControl +{ + UIPageControl *original = %orig; + original.numberOfPages = 3; + return original; +} +%end +%end + +%ctor +{ + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) + { + %init(iOS10); + } + else if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) + { + %init(iOS9); + } + else + { + %init(iOS8); + } +} diff --git a/NotificationCenterApp/RANCViewController.h b/NotificationCenterApp/RANCViewController.h index 4845fdc..5e9a522 100644 --- a/NotificationCenterApp/RANCViewController.h +++ b/NotificationCenterApp/RANCViewController.h @@ -10,4 +10,4 @@ -(RAHostedAppView*) hostedApp; -(void) forceReloadAppLikelyBecauseTheSettingChanged; -@end \ No newline at end of file +@end diff --git a/reachappsettings/NCApp.xm b/reachappsettings/NCApp.xm index c179433..a7a0b41 100644 --- a/reachappsettings/NCApp.xm +++ b/reachappsettings/NCApp.xm @@ -72,7 +72,7 @@ @"label": @"Enabled", @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", }, - @{ @"footerText": @"Instead of using the app's name, the tab label will simply show \"App\"." }, + @{ @"footerText": @"Instead of using the app's name, the tab label will simply show \"App\". Only Works on iOS 9 and below" }, @{ @"cell": @"PSSwitchCell", @"default": @NO, diff --git a/update_status b/update_status index 5b121d7..f1ec48c 100644 --- a/update_status +++ b/update_status @@ -8,7 +8,7 @@ GestureSupport: fixed Backgrounding: working KeyboardSupport: hackily fixed but it works now MissionControl: working (MC presents even when not dragging grabber) -NCApp: fixed on phone, not working right on ipad (misplaced view & no title) needs major overhaul for 10.X +NCApp: working (not tested on ipad / needs to freeze app when NC not visible); assertiond hooks: working backboardd hooks: unknown fake phone mode: working From 40cbe2c69adc8a43b1fce78c510d5edb72492f8b Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 20 Feb 2017 21:53:08 -0600 Subject: [PATCH 28/59] Properly unloads NCApp --- DRM/Statistics.xm | 10 ++++----- MissionControl/AppSwitcher.xm | 14 +++++++++++- NotificationCenterApp/NCHook.xm | 38 +++++++++++++++++---------------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/DRM/Statistics.xm b/DRM/Statistics.xm index d30d4bc..6d5c6de 100644 --- a/DRM/Statistics.xm +++ b/DRM/Statistics.xm @@ -8,17 +8,17 @@ #else dispatch_async(dispatch_get_main_queue(), ^(void){ NSString *statsPath = @"/var/mobile/Library/Preferences/.multiplexer.stats_checked"; - if ([NSFileManager.defaultManager fileExistsAtPath:statsPath] == NO) + if (![NSFileManager.defaultManager fileExistsAtPath:statsPath]) { - CFStringRef (*$MGCopyAnswer)(CFStringRef); + CFStringRef (*$MGCopyAnswer)(CFStringRef); - void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); - $MGCopyAnswer = (CFStringRef (*)(CFStringRef))dlsym(gestalt, "MGCopyAnswer"); + void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); + $MGCopyAnswer = (CFStringRef (*)(CFStringRef))dlsym(gestalt, "MGCopyAnswer"); NSString *udid = (__bridge NSString*)$MGCopyAnswer(CFSTR("UniqueDeviceID")); NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://elijahandandrew.com/multiplexer/stats.php?udid=%@", udid]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]; [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; int code = [httpResponse statusCode]; if (error == nil && (code == 0 || code == 200)) { diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 1e3ea26..a2df90f 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -9,6 +9,7 @@ BOOL allowMissionControlActivationFromSwitcher = YES; BOOL statusBarVisibility; BOOL willShowMissionControl = NO; +BOOL toggleOrActivate = NO; %hook SBUIController - (void)_showNotificationsGestureBeganWithLocation:(CGPoint)arg1 @@ -597,7 +598,6 @@ BOOL willShowMissionControl = NO; %hook SBMainSwitcherViewController - (void)viewDidAppear:(BOOL)arg1 { - %orig; statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; willShowMissionControl = NO; @@ -613,6 +613,8 @@ BOOL willShowMissionControl = NO; } } + %orig; + [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; } @@ -623,4 +625,14 @@ BOOL willShowMissionControl = NO; } %orig; } + +- (BOOL)toggleSwitcherNoninteractively { + HBLogDebug(@"toggleSwitcherNoninteractively"); + return %orig; +} + +- (BOOL)activateSwitcherNoninteractively { + HBLogDebug(@"activateSwitcherNoninteractively"); + return %orig; +} %end diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index 367c975..9749d30 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -109,7 +109,7 @@ static BOOL hasEnteredPages = NO; { %orig; - if (!hasEnteredPages && [self.superview isKindOfClass:[%c(SBSearchEtceteraLayoutView) class]]) + if (!hasEnteredPages && [self.superview isKindOfClass:[%c(SBSearchEtceteraLayoutView) class]] && [[%c(SBNotificationCenterController) sharedInstance] isVisible]) { if (ncAppViewController == nil) ncAppViewController = [[RANCViewController alloc] init]; @@ -123,15 +123,17 @@ static BOOL hasEnteredPages = NO; } %end -%hook SBNotificationCenterController -- (void)_handleDismissGesture:(id)arg1 +%hook SBNotificationCenterViewController +- (void)viewDidDisappear:(BOOL)arg1 { %orig; - [ncAppViewController viewDidDisappear:YES]; + [ncAppViewController hostedApp].hideStatusBar = YES; + if ([ncAppViewController hostedApp].isCurrentlyHosting) + { + [[ncAppViewController hostedApp] unloadApp]; + } } -%end -%hook SBNotificationCenterViewController - (UIPageControl*)pageControl { UIPageControl *original = %orig; @@ -143,16 +145,16 @@ static BOOL hasEnteredPages = NO; %ctor { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) - { - %init(iOS10); - } - else if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) - { - %init(iOS9); - } - else - { - %init(iOS8); - } + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) + { + %init(iOS10); + } + else if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) + { + %init(iOS9); + } + else + { + %init(iOS8); + } } From b8794eafd3bbfee21d11d696f846e5ca05f6855c Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Thu, 23 Feb 2017 19:23:42 -0600 Subject: [PATCH 29/59] using built in theos macros --- Asphaleia2.h => Asphaleia.h | 6 ++--- GestureSupport/Hooks_iOS8.xm | 24 +++++++++---------- GestureSupport/Hooks_iOS9.xm | 2 +- KeyboardSupport/RAKeyboardStateListener.xm | 2 +- KeyboardSupport/RARemoteKeyboardView.xm | 2 +- Multiplexer.xm | 8 +------ NotificationCenterApp/NCHook.xm | 14 +++++++---- NotificationCenterApp/RANCViewController.xm | 2 +- RAHostedAppView.xm | 8 +++---- Reachability/Reachability.xm | 20 +++++++++------- SpringBoard.xm | 11 ++++----- SwipeOver/RASwipeOverManager.xm | 2 +- Tweak.xm | 7 ------ UIKit.xm | 2 +- .../StartMultitaskingGesture.xm | 2 +- headers.h | 23 +++++++----------- .../Multiplexer/Localizations/en.strings | 4 ++-- reachappassertiondhooks/Tweak.xm | 6 ++--- reachappsettings/RASupportController.xm | 8 +++++++ update_status | 11 +++++++-- widgets/Reachability/RAFavoriteAppsWidget.xm | 6 ++--- 21 files changed, 85 insertions(+), 85 deletions(-) rename Asphaleia2.h => Asphaleia.h (90%) diff --git a/Asphaleia2.h b/Asphaleia.h similarity index 90% rename from Asphaleia2.h rename to Asphaleia.h index cc43229..ac77054 100644 --- a/Asphaleia2.h +++ b/Asphaleia.h @@ -33,10 +33,10 @@ typedef void (^ASCommonAuthenticationHandler) (BOOL wasCancelled); #define LOAD_ASPHALEIA if ([NSFileManager.defaultManager fileExistsAtPath:@"/usr/lib/libasphaleiaui.dylib"]) dlopen("/usr/lib/libasphaleiaui.dylib", RTLD_LAZY); -#define HAS_ASPHALEIA2 (objc_getClass("ASCommon") != nil) -#define IF_ASPHALEIA2 if (HAS_ASPHALEIA2) +#define HAS_ASPHALEIA (objc_getClass("ASCommon") != nil) +#define IF_ASPHALEIA if (HAS_ASPHALEIA) -#define ASPHALEIA2_AUTHENTICATE_APP(ident, success, failure_) \ +#define ASPHALEIA_AUTHENTICATE_APP(ident, success, failure_) \ BOOL isAppProtected = [[objc_getClass("ASCommon") sharedInstance] authenticateAppWithDisplayIdentifier:ident customMessage:nil dismissedHandler:^(BOOL wasCancelled) { \ if (!wasCancelled) \ success(); \ diff --git a/GestureSupport/Hooks_iOS8.xm b/GestureSupport/Hooks_iOS8.xm index 1cef3e7..399b6ab 100644 --- a/GestureSupport/Hooks_iOS8.xm +++ b/GestureSupport/Hooks_iOS8.xm @@ -2,7 +2,7 @@ #import "RAGestureManager.h" /* -Some code modified/adapted/based off of MultitaskingGestures by HamzaSood. +Some code modified/adapted/based off of MultitaskingGestures by HamzaSood. MultitaskingGestures source code: https://github.com/hamzasood/MultitaskingGestures/ License (GPL): https://github.com/hamzasood/MultitaskingGestures/blob/master/License.md */ @@ -22,7 +22,7 @@ struct VelocityData { }; %hook _UIScreenEdgePanRecognizer -- (void)incorporateTouchSampleAtLocation:(CGPoint)location timestamp:(double)timestamp modifier:(NSInteger)modifier interfaceOrientation:(UIInterfaceOrientation)orientation +- (void)incorporateTouchSampleAtLocation:(CGPoint)location timestamp:(double)timestamp modifier:(NSInteger)modifier interfaceOrientation:(UIInterfaceOrientation)orientation { %orig; @@ -30,7 +30,7 @@ struct VelocityData { VelocityData oldData; [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&oldData]; - + // this is really quite simple, it calculates a velocity based off of // (current location - last location) / (time taken to move from last location to current location) // which effectively gives you a CGPoint of where it would end if the user continued the gesture. @@ -43,7 +43,7 @@ struct VelocityData { } %new -- (CGPoint)RA_velocity +- (CGPoint)RA_velocity { VelocityData data; [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&data]; @@ -53,7 +53,7 @@ struct VelocityData { %end %hook SBHandMotionExtractor --(id) init +-(id) init { if ((self = %orig)) { @@ -63,7 +63,7 @@ struct VelocityData { return self; } --(void) extractHandMotionForActiveTouches:(SBActiveTouch*) activeTouches count:(NSUInteger)count centroid:(CGPoint)centroid +-(void) extractHandMotionForActiveTouches:(SBActiveTouch*) activeTouches count:(NSUInteger)count centroid:(CGPoint)centroid { %orig; dispatch_async(dispatch_get_main_queue(), ^{ @@ -92,7 +92,7 @@ struct VelocityData { }); } -%new -(void) screenEdgePanRecognizerStateDidChange:(_UIScreenEdgePanRecognizer*) screenEdgePanRecognizer +%new -(void) screenEdgePanRecognizerStateDidChange:(_UIScreenEdgePanRecognizer*) screenEdgePanRecognizer { if (screenEdgePanRecognizer.state == UIGestureRecognizerStateBegan) { @@ -145,15 +145,15 @@ struct VelocityData { } %end -%ctor +%ctor { IF_SPRINGBOARD { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) + if (IS_IOS_OR_NEWER(iOS_9_0)) return; class_addProtocol(objc_getClass("SBHandMotionExtractor"), @protocol(_UIScreenEdgePanRecognizerDelegate)); - + UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); gestureRecognizers = [[NSMutableSet alloc] initWithCapacity:edgeCount]; @@ -167,5 +167,5 @@ struct VelocityData { %init; } - -} \ No newline at end of file + +} diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index 56ac920..afe1e6e 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -186,7 +186,7 @@ __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; IF_SPRINGBOARD { - if (SYSTEM_VERSION_LESS_THAN(@"9.0")) + if (IS_IOS_OR_OLDER(iOS_8_4)) return; clientCreatePointer clientCreate; diff --git a/KeyboardSupport/RAKeyboardStateListener.xm b/KeyboardSupport/RAKeyboardStateListener.xm index 84082c7..77caffd 100644 --- a/KeyboardSupport/RAKeyboardStateListener.xm +++ b/KeyboardSupport/RAKeyboardStateListener.xm @@ -101,7 +101,7 @@ void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFS } }; - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) + if (IS_IOS_OR_NEWER(iOS_9_0)) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), block); else block(); diff --git a/KeyboardSupport/RARemoteKeyboardView.xm b/KeyboardSupport/RARemoteKeyboardView.xm index 5767bce..4e20e88 100644 --- a/KeyboardSupport/RARemoteKeyboardView.xm +++ b/KeyboardSupport/RARemoteKeyboardView.xm @@ -42,7 +42,7 @@ self.userInteractionEnabled = YES; self.layerHost = [[CALayerHost alloc] init]; self.layerHost.anchorPoint = CGPointMake(0, 0); - if (SYSTEM_VERSION_LESS_THAN(@"9.0")) + if (IS_IOS_OR_OLDER(iOS_8_4)) self.layerHost.transform = CATransform3DMakeScale(1/[UIScreen mainScreen].scale, 1/[UIScreen mainScreen].scale, 1); self.layerHost.bounds = self.bounds; [self.layer addSublayer:self.layerHost]; diff --git a/Multiplexer.xm b/Multiplexer.xm index 67f866d..bf4c4a4 100644 --- a/Multiplexer.xm +++ b/Multiplexer.xm @@ -2,12 +2,6 @@ #import "RACompatibilitySystem.h" #import "headers.h" -#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) -#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) - @implementation MultiplexerExtension @end @@ -18,7 +12,7 @@ } -(NSString*) currentVersion { return @"1.0"; } --(BOOL) isOnSupportedOS { return SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0") && SYSTEM_VERSION_LESS_THAN(@"10.2"); } +-(BOOL) isOnSupportedOS { return IS_IOS_BETWEEN(iOS_8_0, iOS_10_2); } -(void) registerExtension:(NSString*)name forMultiplexerVersion:(NSString*)version { diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index 9749d30..dd39a94 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -3,7 +3,7 @@ #import "RASettings.h" #import "headers.h" -@interface SBNotificationCenterViewController +@interface SBNotificationCenterViewController () -(id)_newBulletinObserverViewControllerOfClass:(Class)aClass; @end @@ -109,15 +109,19 @@ static BOOL hasEnteredPages = NO; { %orig; - if (!hasEnteredPages && [self.superview isKindOfClass:[%c(SBSearchEtceteraLayoutView) class]] && [[%c(SBNotificationCenterController) sharedInstance] isVisible]) + if (!hasEnteredPages && [RASettings.sharedInstance NCAppEnabled] && [self.superview isKindOfClass:[%c(SBSearchEtceteraLayoutView) class]] && [[%c(SBNotificationCenterController) sharedInstance] isVisible]) { - if (ncAppViewController == nil) + if (ncAppViewController == nil) { ncAppViewController = [[RANCViewController alloc] init]; + HBLogDebug(@"created ncAppViewController"); + } NSMutableArray *newArray = [[self pageViews] mutableCopy]; [newArray addObject:ncAppViewController.view]; [self setPageViews:newArray]; + HBLogDebug(@"added custom page") + hasEnteredPages = YES; } } @@ -145,11 +149,11 @@ static BOOL hasEnteredPages = NO; %ctor { - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) + if (IS_IOS_OR_NEWER(iOS_10_0)) { %init(iOS10); } - else if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) + else if (IS_IOS_BETWEEN(iOS_8_4, iOS_9_3)) { %init(iOS9); } diff --git a/NotificationCenterApp/RANCViewController.xm b/NotificationCenterApp/RANCViewController.xm index a4be59d..4a24fe7 100644 --- a/NotificationCenterApp/RANCViewController.xm +++ b/NotificationCenterApp/RANCViewController.xm @@ -131,7 +131,7 @@ int rotationDegsForOrientation(int o) } //[appView rotateToOrientation:UIApplication.sharedApplication.statusBarOrientation]; - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) // Must manually place view controller :( + if (IS_IOS_OR_NEWER(iOS_9_0)) // Must manually place view controller :( { CGRect frame = self.view.frame; frame.origin.x = UIScreen.mainScreen.bounds.size.width * 2.0; diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index b474742..126442a 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -4,7 +4,7 @@ #import "RAMessagingServer.h" #import "RASnapshotProvider.h" #import "RASpringBoardKeyboardActivation.h" -#import "Asphaleia2.h" +#import "Asphaleia.h" #import "dispatch_after_cancel.h" NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; @@ -197,7 +197,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; [self _actualLoadApp]; }, failedBlock /* stupid commas */); } - else IF_ASPHALEIA2 + else IF_ASPHALEIA { void (^failedBlock)() = ^{ [self removeLoadingIndicator]; @@ -210,7 +210,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; authenticationDidFailLabel.font = [UIFont systemFontOfSize:36]; authenticationDidFailLabel.numberOfLines = 0; authenticationDidFailLabel.lineBreakMode = NSLineBreakByWordWrapping; - authenticationDidFailLabel.text = [NSString stringWithFormat:LOCALIZE(@"ASPHALEIA2_AUTH_FAILED"),self.app.displayName]; + authenticationDidFailLabel.text = [NSString stringWithFormat:LOCALIZE(@"ASPHALEIA_AUTH_FAILED"),self.app.displayName]; [self addSubview:authenticationDidFailLabel]; authenticationFailedRetryTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loadApp)]; @@ -219,7 +219,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; } }; - ASPHALEIA2_AUTHENTICATE_APP(app.bundleIdentifier, ^{ + ASPHALEIA_AUTHENTICATE_APP(app.bundleIdentifier, ^{ [self _actualLoadApp]; }, failedBlock); } diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 2c62d10..8394f64 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -20,7 +20,7 @@ /*FBWindowContextHostWrapperView*/ UIView *view = nil; NSString *lastBundleIdentifier = @""; NSString *currentBundleIdentifier = @""; -UIViewController *ncViewController = nil; +SBNotificationCenterViewController *ncViewController = nil; UIView *draggerView = nil; BOOL overrideOrientation = NO; @@ -204,9 +204,11 @@ id SBWorkspace$sharedInstance; UIWindow *window = MSHookIvar(self, "_reachabilityEffectWindow"); [window _setRotatableViewOrientation:UIInterfaceOrientationPortrait updateStatusBar:YES duration:0.0 force:YES]; window.rootViewController = nil; - UIViewController *viewController = [[%c(SBNotificationCenterController) performSelector:@selector(sharedInstance)] performSelector:@selector(viewController)]; - [viewController performSelector:@selector(hostWillDismiss)]; - [viewController performSelector:@selector(hostDidDismiss)]; + SBNotificationCenterViewController *viewController = [[%c(SBNotificationCenterController) performSelector:@selector(sharedInstance)] performSelector:@selector(viewController)]; + if ([viewController respondsToSelector:@selector(hostWillDismiss)]) { + [viewController performSelector:@selector(hostWillDismiss)]; + [viewController performSelector:@selector(hostDidDismiss)]; + } //[viewController.view removeFromSuperview]; } else @@ -317,15 +319,17 @@ id SBWorkspace$sharedInstance; { showingNC = YES; - if (ncViewController == nil) + if (!ncViewController) ncViewController = [[%c(SBNotificationCenterViewController) alloc] init]; ncViewController.view.frame = (CGRect) { { 0, 0 }, w.frame.size }; w.rootViewController = ncViewController; [w addSubview:ncViewController.view]; //[[%c(SBNotificationCenterController) performSelector:@selector(sharedInstance)] performSelector:@selector(_setupForViewPresentation)]; - [ncViewController performSelector:@selector(hostWillPresent)]; - [ncViewController performSelector:@selector(hostDidPresent)]; + if ([ncViewController respondsToSelector:@selector(hostWillPresent)]) { + [ncViewController performSelector:@selector(hostWillPresent)]; + [ncViewController performSelector:@selector(hostDidPresent)]; + } if ([RASettings.sharedInstance enableRotation]) { @@ -604,7 +608,7 @@ CGFloat startingY = -1; if ([RASettings.sharedInstance showNCInstead]) { if (ncViewController) - ncViewController.view.frame = (CGRect) { { 0, 0 }, topFrame.size }; + ncViewController.view.frame = CGRectMake(0, 0, topFrame.size.width, topFrame.size.height); } else if (lastBundleIdentifier != nil || [view isKindOfClass:[RAAppSliderProviderView class]]) { diff --git a/SpringBoard.xm b/SpringBoard.xm index f929665..ff4bdfe 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -15,7 +15,7 @@ #import "RAMissionControlManager.h" #import "RADesktopManager.h" #import "RADesktopWindow.h" -#import "Asphaleia2.h" +#import "Asphaleia.h" #import "RASnapshotProvider.h" extern BOOL overrideDisableForStatusBar; @@ -205,12 +205,11 @@ extern BOOL overrideDisableForStatusBar; void respring_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { - SpringBoard *springBoard = (SpringBoard*)[UIApplication sharedApplication]; - if ([springBoard respondsToSelector:@selector(_relaunchSpringBoardNow)]) { - [springBoard _relaunchSpringBoardNow]; + if (IS_IOS_OR_NEWER(iOS_9_3)) { + SBSRestartRenderServerAction *restartAction = [%c(SBSRestartRenderServerAction) restartActionWithTargetRelaunchURL:nil]; + [[%c(FBSSystemService) sharedService] sendActions:[NSSet setWithObject:restartAction] withResult:nil]; } else { - SBSRestartRenderServerAction *restartAction = [%c(SBSRestartRenderServerAction) restartActionWithTargetRelaunchURL:nil]; - [[%c(FBSSystemService) sharedService] sendActions:[NSSet setWithObject:restartAction] withResult:nil]; + [[UIApplication sharedApplication] _relaunchSpringBoardNow]; } } diff --git a/SwipeOver/RASwipeOverManager.xm b/SwipeOver/RASwipeOverManager.xm index 0fdca44..8c3a213 100644 --- a/SwipeOver/RASwipeOverManager.xm +++ b/SwipeOver/RASwipeOverManager.xm @@ -88,7 +88,7 @@ extern int rotationDegsForOrientation(int o); -(void) createEdgeView { overlayWindow = [[RASwipeOverOverlay alloc] initWithFrame:UIScreen.mainScreen.RA_interfaceOrientedBounds]; - if (SYSTEM_VERSION_LESS_THAN(@"9.0")) + if (IS_IOS_OR_OLDER(iOS_8_4)) [overlayWindow _rotateWindowToOrientation:UIApplication.sharedApplication.statusBarOrientation updateStatusBar:YES duration:0.001 skipCallbacks:NO]; [overlayWindow showEnoughToDarkenUnderlyingApp]; [overlayWindow makeKeyAndVisible]; diff --git a/Tweak.xm b/Tweak.xm index 756ee04..20a0499 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -18,13 +18,6 @@ Any code based off of or using parts of the above projects is documented. */ -// IS_SPRINGBOARD macro optimized from always comparing NSBundle - because it won't change in-process -BOOL $__IS_SPRINGBOARD = NO; -%ctor -{ - $__IS_SPRINGBOARD = [NSBundle.mainBundle.bundleIdentifier isEqual:@"com.apple.springboard"]; -} - void SET_BACKGROUNDED(id settings, BOOL value) { #if __has_feature(objc_arc) diff --git a/UIKit.xm b/UIKit.xm index 9b686b7..e215498 100644 --- a/UIKit.xm +++ b/UIKit.xm @@ -218,7 +218,7 @@ static Class $memorized$UITextEffectsWindow$class; objc_setAssociatedObject(self, @selector(RA_networkActivity), @(arg1), OBJC_ASSOCIATION_RETAIN_NONATOMIC); StatusBarData *data = [UIStatusBarServer getStatusBarData]; - data->itemIsEnabled[26] = arg1; // 24 = activity indicator + data->itemIsEnabled[26] = arg1; // 26 = activity indicator [UIApplication.sharedApplication.statusBar forceUpdateToData:data animated:YES]; } } diff --git a/WindowedMultitasking/StartMultitaskingGesture.xm b/WindowedMultitasking/StartMultitaskingGesture.xm index c00b92b..fd4983a 100644 --- a/WindowedMultitasking/StartMultitaskingGesture.xm +++ b/WindowedMultitasking/StartMultitaskingGesture.xm @@ -51,7 +51,7 @@ BOOL locationIsInValidArea(CGFloat x) // Assign view appView = [RAHostManager systemHostViewForApplication:topApp].superview; - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) + if (IS_IOS_OR_NEWER(iOS_9_0)) appView = appView.superview; originalCenter = appView.center; } diff --git a/headers.h b/headers.h index 7ace09c..f0080fa 100644 --- a/headers.h +++ b/headers.h @@ -21,6 +21,7 @@ #import #import #import +#import #define RA_BASE_PATH @"/Library/Multiplexer" @@ -36,13 +37,6 @@ #define GET_STATUSBAR_ORIENTATION (UIApplication.sharedApplication._accessibilityFrontMostApplication == nil ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) -#if MULTIPLEXER_CORE -extern BOOL $__IS_SPRINGBOARD; -#define IS_SPRINGBOARD $__IS_SPRINGBOARD -#else -#define IS_SPRINGBOARD [NSBundle.mainBundle.bundleIdentifier isEqual:@"com.apple.springboard"] -#endif - #define ON_MAIN_THREAD(block) \ { \ dispatch_block_t _blk = block; \ @@ -52,8 +46,8 @@ extern BOOL $__IS_SPRINGBOARD; dispatch_sync(dispatch_get_main_queue(), _blk); \ } -#define IF_SPRINGBOARD if (IS_SPRINGBOARD) -#define IF_NOT_SPRINGBOARD if (!IS_SPRINGBOARD) +#define IF_SPRINGBOARD if (IN_SPRINGBOARD) +#define IF_NOT_SPRINGBOARD if (!IN_SPRINGBOARD) #define IF_THIS_PROCESS(x) if ([[x objectForKey:@"bundleIdentifier"] isEqual:NSBundle.mainBundle.bundleIdentifier]) // ugh, i got so tired of typing this in by hand, plus it expands method declarations by a LOT. @@ -98,12 +92,6 @@ return sharedInstance; #define SHARED_INSTANCE(cls) SHARED_INSTANCE2(cls, ); -#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) -#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) - //////////////////////////////////////////////////////////////////////////////////////////////// @interface UIRemoteKeyboardWindow : UIWindow //UITextEffectsWindow @@ -418,8 +406,13 @@ typedef struct { +(StatusBarData*) getStatusBarData; @end +@interface SBNotificationCenterViewController : UIViewController +-(void)_setContainerFrame:(CGRect)arg1 ; +@end + @interface SBNotificationCenterController : NSObject +(id) sharedInstance; +-(SBNotificationCenterViewController *)viewController; -(BOOL) isVisible; @end diff --git a/layout/Library/Multiplexer/Localizations/en.strings b/layout/Library/Multiplexer/Localizations/en.strings index 732efd9..8157433 100644 --- a/layout/Library/Multiplexer/Localizations/en.strings +++ b/layout/Library/Multiplexer/Localizations/en.strings @@ -19,6 +19,6 @@ "FAVORITES" = "Favorites"; "RECENTS" = "Recent"; "ACTIVE_APP_WARNING" = "%@\n is currently open"; -"ASPHALEIA2_AUTH_FAILED" = "Asphaleia 2\n authentication failed for\n %@.\nTap to try again."; +"ASPHALEIA_AUTH_FAILED" = "Asphaleia \n authentication failed for\n %@.\nTap to try again."; "UNLIMITED_BACKGROUNDING_TIME" = "Unlimited Backgrounding Time"; -"KILL_ALL" = "Kill All"; \ No newline at end of file +"KILL_ALL" = "Kill All"; diff --git a/reachappassertiondhooks/Tweak.xm b/reachappassertiondhooks/Tweak.xm index 56e3a29..892f11d 100644 --- a/reachappassertiondhooks/Tweak.xm +++ b/reachappassertiondhooks/Tweak.xm @@ -1,8 +1,7 @@ #import #import #import - -#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) +#import extern const char *__progname; @@ -27,9 +26,8 @@ static int hax_BSXPCConnectionHasEntitlement(__unsafe_unretained id connection, %ctor { // We can never be too sure if (strcmp(__progname, "assertiond") == 0) { - HBLogDebug(@"Is assertiond"); dlopen("/System/Library/PrivateFrameworks/XPCObjects.framework/XPCObjects", RTLD_LAZY); - if (SYSTEM_VERSION_LESS_THAN(@"9.0")) { + if (IS_IOS_OR_OLDER(iOS_8_4)) { void *xpcFunction = MSFindSymbol(NULL, "_BSAuditTokenTaskHasEntitlement"); MSHookFunction(xpcFunction, (void *)hax_BSAuditTokenTaskHasEntitlement, (void **)&orig_BSAuditTokenTaskHasEntitlement); } else { diff --git a/reachappsettings/RASupportController.xm b/reachappsettings/RASupportController.xm index 5c3c97a..d58b95e 100644 --- a/reachappsettings/RASupportController.xm +++ b/reachappsettings/RASupportController.xm @@ -38,6 +38,13 @@ @"label": @"Andrew Abosh", @"icon": @"andrew" }, + @{ + @"cell": @"PSLinkCell", + @"height": @45, + @"action": @"openShadeTwitter", + @"label": @"Shade Zepheri", + @"icon": @"shade" + }, @{ @"label": @"Beta tested by" }, @{ @@ -147,6 +154,7 @@ Crafted with love in 🇨🇦 and 🇺🇸. \n\ -(void) openElijahTwitter { [SKSharedHelper openTwitter:@"daementor"]; } -(void) openAndrewTwitter { [SKSharedHelper openTwitter:@"drewplex"]; } +-(void) openShadeTwitter { [SKSharedHelper openTwitter:@"ShadeZepheri"]; } -(void) openAndiTwitter { [SKSharedHelper openTwitter:@"Nexuist"]; } -(void) openBetaPage { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://www.reddit.com/user/beta382"]]; } -(void) openChonTwitter { [SKSharedHelper openTwitter:@"HikoMitsuketa"]; } diff --git a/update_status b/update_status index f1ec48c..b1c3e4d 100644 --- a/update_status +++ b/update_status @@ -3,12 +3,12 @@ update status: Windowed: working fs daemon: working SwipeOver: working (replace with native slide over(?)) -Reachability: working +Reachability: working (show NC broken in 10.x) GestureSupport: fixed Backgrounding: working KeyboardSupport: hackily fixed but it works now MissionControl: working (MC presents even when not dragging grabber) -NCApp: working (not tested on ipad / needs to freeze app when NC not visible); +NCApp: working (not tested on ipad / app should be frozen but doesn't appear to be); assertiond hooks: working backboardd hooks: unknown fake phone mode: working @@ -19,5 +19,12 @@ fake phone mode: working - icons and apps do not show up in RASnapshotProvider - GestureSupport: LandscapeLeft is, once again, broken +Bugs: +- Individual app force foregrounding is broken when used in conjunction with auto (re)launch; +- MC view invokes regardless if grabbing the grabber or not +- Replace AppSwitcher with MC is broken +- Invoking keyboard in reachapp closes view + + notes: use _referenceBounds instead of bounds on UIScreen to get physical bounds. Makes landscape support easier? diff --git a/widgets/Reachability/RAFavoriteAppsWidget.xm b/widgets/Reachability/RAFavoriteAppsWidget.xm index 6e44305..93dde21 100644 --- a/widgets/Reachability/RAFavoriteAppsWidget.xm +++ b/widgets/Reachability/RAFavoriteAppsWidget.xm @@ -20,12 +20,12 @@ -(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size_ iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing { CGSize size = [%c(SBIconView) defaultIconSize]; - spacing = (frame.size.width - (iconsPerLine * size.width)) / iconsPerLine; + spacing = (frame.size.width - (iconsPerLine * size.width)) / (iconsPerLine + 0); NSString *currentBundleIdentifier = [[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; if (!currentBundleIdentifier) return nil; - CGSize contentSize = CGSizeMake(spacing / 2.0, 10); - CGFloat interval = (size.width + spacing) * iconsPerLine; + CGSize contentSize = CGSizeMake((spacing / 2.0), 10); + CGFloat interval = ((size.width + spacing) * iconsPerLine); NSInteger intervalCount = 1; BOOL isTop = YES; BOOL hasSecondRow = NO; From 90273513efe1deb68a505324d892fc3d5a05070f Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Thu, 23 Feb 2017 21:27:50 -0600 Subject: [PATCH 30/59] Proper respring method + better debugging --- Debugging/Core.xm | 20 +++++--------------- SpringBoard.xm | 2 +- update_status | 2 ++ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Debugging/Core.xm b/Debugging/Core.xm index e3a2a7a..7fb1d89 100644 --- a/Debugging/Core.xm +++ b/Debugging/Core.xm @@ -7,27 +7,17 @@ #import "headers.h" %hook NSObject --(void)doesNotRecognizeSelector:(SEL)selector +- (void)doesNotRecognizeSelector:(SEL)selector { HBLogDebug(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); - void *array[10]; - size_t size; - char **strings; - size_t i; - - size = backtrace (array, 10); - strings = backtrace_symbols (array, size); - - HBLogDebug(@"[ReachApp] Obtained %zd stack frames:\n", size); - - for (i = 0; i < size; i++) + NSArray * symbols = [NSThread callStackSymbols]; + HBLogDebug(@"[ReachApp] Obtained %zd stack frames:\n", symbols.count); + for (NSString * symbol in symbols) { - HBLogDebug(@"[ReachApp] %s\n", strings[i]); + HBLogDebug(@"[ReachApp] %@\n", symbol); } - free(strings); - %orig; } %end diff --git a/SpringBoard.xm b/SpringBoard.xm index ff4bdfe..dd5e0f9 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -206,7 +206,7 @@ extern BOOL overrideDisableForStatusBar; void respring_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { if (IS_IOS_OR_NEWER(iOS_9_3)) { - SBSRestartRenderServerAction *restartAction = [%c(SBSRestartRenderServerAction) restartActionWithTargetRelaunchURL:nil]; + SBSRelaunchAction *restartAction = [%c(SBSRelaunchAction) actionWithReason:@"RestartRenderServer" options:SBSRelaunchOptionsFadeToBlack targetURL:nil]; [[%c(FBSSystemService) sharedService] sendActions:[NSSet setWithObject:restartAction] withResult:nil]; } else { [[UIApplication sharedApplication] _relaunchSpringBoardNow]; diff --git a/update_status b/update_status index b1c3e4d..1532886 100644 --- a/update_status +++ b/update_status @@ -24,6 +24,8 @@ Bugs: - MC view invokes regardless if grabbing the grabber or not - Replace AppSwitcher with MC is broken - Invoking keyboard in reachapp closes view +- NCApp doesnt properly unload +- Showing NC with reachapp doesnt properly resize notes: From 97fb9afac66006909182f633b97de5479f71fe73 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 25 Feb 2017 23:24:11 -0600 Subject: [PATCH 31/59] Fixed nonexistent falcon incompatibilty --- MissionControl/AppSwitcher.xm | 15 --------------- NotificationCenterApp/NCHook.xm | 14 +++----------- NotificationCenterApp/RANCViewController.xm | 3 ++- layout/DEBIAN/control | 6 +++--- update_status | 1 + 5 files changed, 9 insertions(+), 30 deletions(-) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index a2df90f..43859b6 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -562,11 +562,6 @@ BOOL toggleOrActivate = NO; fakeView.frame = UIScreen.mainScreen.RA_interfaceOrientedBounds; } completion:^(BOOL _) { //((UIWindow*)[[%c(SBUIController) sharedInstance] switcherWindow]).alpha = 0; - if ([%c(SBUIController) respondsToSelector:@selector(dismissSwitcherAnimated:)]) { - [[%c(SBUIController) sharedInstance] dismissSwitcherAnimated:NO]; - } else { - [[%c(SBMainSwitcherViewController) sharedInstance] dismissSwitcherNoninteractively]; - } [[%c(SBUIController) sharedInstance] restoreContentUpdatingStatusBar:YES]; [RAMissionControlManager.sharedInstance showMissionControl:NO]; [fakeView removeFromSuperview]; @@ -625,14 +620,4 @@ BOOL toggleOrActivate = NO; } %orig; } - -- (BOOL)toggleSwitcherNoninteractively { - HBLogDebug(@"toggleSwitcherNoninteractively"); - return %orig; -} - -- (BOOL)activateSwitcherNoninteractively { - HBLogDebug(@"activateSwitcherNoninteractively"); - return %orig; -} %end diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index dd39a94..28bb1a1 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -111,17 +111,13 @@ static BOOL hasEnteredPages = NO; if (!hasEnteredPages && [RASettings.sharedInstance NCAppEnabled] && [self.superview isKindOfClass:[%c(SBSearchEtceteraLayoutView) class]] && [[%c(SBNotificationCenterController) sharedInstance] isVisible]) { - if (ncAppViewController == nil) { + if (!ncAppViewController) { ncAppViewController = [[RANCViewController alloc] init]; - HBLogDebug(@"created ncAppViewController"); } NSMutableArray *newArray = [[self pageViews] mutableCopy]; [newArray addObject:ncAppViewController.view]; [self setPageViews:newArray]; - - HBLogDebug(@"added custom page") - hasEnteredPages = YES; } } @@ -131,11 +127,7 @@ static BOOL hasEnteredPages = NO; - (void)viewDidDisappear:(BOOL)arg1 { %orig; - [ncAppViewController hostedApp].hideStatusBar = YES; - if ([ncAppViewController hostedApp].isCurrentlyHosting) - { - [[ncAppViewController hostedApp] unloadApp]; - } + [ncAppViewController viewDidDisappear:YES]; } - (UIPageControl*)pageControl @@ -153,7 +145,7 @@ static BOOL hasEnteredPages = NO; { %init(iOS10); } - else if (IS_IOS_BETWEEN(iOS_8_4, iOS_9_3)) + else if (IS_IOS_BETWEEN(iOS_9_0, iOS_9_3)) { %init(iOS9); } diff --git a/NotificationCenterApp/RANCViewController.xm b/NotificationCenterApp/RANCViewController.xm index 4a24fe7..d6025d7 100644 --- a/NotificationCenterApp/RANCViewController.xm +++ b/NotificationCenterApp/RANCViewController.xm @@ -131,7 +131,8 @@ int rotationDegsForOrientation(int o) } //[appView rotateToOrientation:UIApplication.sharedApplication.statusBarOrientation]; - if (IS_IOS_OR_NEWER(iOS_9_0)) // Must manually place view controller :( + + if (IS_IOS_BETWEEN(iOS_9_0, iOS_9_3)) // Must manually place view controller :( { CGRect frame = self.view.frame; frame.origin.x = UIScreen.mainScreen.bounds.size.width * 2.0; diff --git a/layout/DEBIAN/control b/layout/DEBIAN/control index a982bb5..0f4264c 100644 --- a/layout/DEBIAN/control +++ b/layout/DEBIAN/control @@ -6,7 +6,7 @@ Replaces: com.efrederickson.reachapp Version: 0.1 Architecture: iphoneos-arm Description: All sorts of multitasking. -Depiction: http://elijahandandrew.com/repo/depictions/Multiplexer/index.html -Maintainer: Elijah and Andrew -Author: Elijah and Andrew +Depiction: http://shade-zepheri.github.io/depic/index.html?p=org.bigboss.multiplexer +Maintainer: Shade Zepheri +Author: Shade Zepheri Section: Tweaks diff --git a/update_status b/update_status index 1532886..c073d6c 100644 --- a/update_status +++ b/update_status @@ -23,6 +23,7 @@ Bugs: - Individual app force foregrounding is broken when used in conjunction with auto (re)launch; - MC view invokes regardless if grabbing the grabber or not - Replace AppSwitcher with MC is broken +- Invoking MC shows appswitcher dismissing - Invoking keyboard in reachapp closes view - NCApp doesnt properly unload - Showing NC with reachapp doesnt properly resize From bda8248beb59fb278a45e46f046b2be1585e74ec Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Tue, 28 Feb 2017 21:21:24 -0600 Subject: [PATCH 32/59] NCApp should properly unload? --- Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm | 2 +- Debugging/Core.xm | 4 +++- NotificationCenterApp/NCHook.xm | 3 ++- layout/DEBIAN/control | 2 +- update_status | 6 +++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index bf46ecf..01de77d 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -25,7 +25,7 @@ if ((arg3 == kProcessAssertionReasonViewServices) == NO && // whitelist this to allow share menu to work [arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] == NO && // whitelist iCleaner to prevent crash on open [arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"] == NO && // Whitelist filza to prevent iOS hang (?!) - IS_SPRINGBOARD == NO) // FIXME: this is a hack that prevents SpringBoard from not starting + !IN_SPRINGBOARD) // FIXME: this is a hack that prevents SpringBoard from not starting { NSString *identifier = NSBundle.mainBundle.bundleIdentifier; diff --git a/Debugging/Core.xm b/Debugging/Core.xm index 7fb1d89..809c600 100644 --- a/Debugging/Core.xm +++ b/Debugging/Core.xm @@ -9,14 +9,16 @@ %hook NSObject - (void)doesNotRecognizeSelector:(SEL)selector { +#if DEBUG HBLogDebug(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); NSArray * symbols = [NSThread callStackSymbols]; HBLogDebug(@"[ReachApp] Obtained %zd stack frames:\n", symbols.count); - for (NSString * symbol in symbols) + for (NSString *symbol in symbols) { HBLogDebug(@"[ReachApp] %@\n", symbol); } +#endif %orig; } diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index 28bb1a1..e068d6e 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -127,7 +127,8 @@ static BOOL hasEnteredPages = NO; - (void)viewDidDisappear:(BOOL)arg1 { %orig; - [ncAppViewController viewDidDisappear:YES]; + NSNumber *passedValue = [NSNumber numberWithBool:YES]; + [ncAppViewController performSelector:@selector(viewDidDisappear:) withObject:passedValue afterDelay:2.0]; } - (UIPageControl*)pageControl diff --git a/layout/DEBIAN/control b/layout/DEBIAN/control index 0f4264c..b58d9d1 100644 --- a/layout/DEBIAN/control +++ b/layout/DEBIAN/control @@ -6,7 +6,7 @@ Replaces: com.efrederickson.reachapp Version: 0.1 Architecture: iphoneos-arm Description: All sorts of multitasking. -Depiction: http://shade-zepheri.github.io/depic/index.html?p=org.bigboss.multiplexer +Depiction: https://shade-zepheri.github.io/depic/index.html?p=com.shade.multiplexer Maintainer: Shade Zepheri Author: Shade Zepheri Section: Tweaks diff --git a/update_status b/update_status index c073d6c..d973d1d 100644 --- a/update_status +++ b/update_status @@ -25,8 +25,12 @@ Bugs: - Replace AppSwitcher with MC is broken - Invoking MC shows appswitcher dismissing - Invoking keyboard in reachapp closes view -- NCApp doesnt properly unload +- NCApp doesnt properly unload (Should now after hacky fix?) - Showing NC with reachapp doesnt properly resize +- Startup bug still isnt fixed +- Some say it causes serios lag? +- Launching MC from activator gesture black screen +- Empoleon frozen upon homebutton press notes: From 4aab37e43d1f9603fb63f32a464712d4c60c6f1e Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 4 Mar 2017 23:37:00 -0600 Subject: [PATCH 33/59] Too many changes --- .../BackgroundModeTogglerActivator.xm | 4 +- Backgrounding/Makefile | 2 +- Backgrounding/RABackgrounder.h | 2 +- Backgrounding/RABackgrounder.xm | 23 +++++---- .../SpringBoard_UIAppCustomBackgroundModes.xm | 2 +- GestureSupport/Hooks_iOS8.xm | 4 +- Messaging/RAMessagingClient.xm | 11 +++- Messaging/RAMessagingServer.xm | 28 +++++++---- MissionControl/ActivatorListener.xm | 2 +- MissionControl/AppSwitcher.xm | 11 ++-- Multiplexer.xm | 35 +++++++------ NotificationCenterApp/NCHook.xm | 9 ++-- NotificationCenterApp/RANCViewController.xm | 7 ++- RAControlCenterInhibitor.xm | 5 ++ RAFakePhoneMode.xm | 2 +- RAHostManager.xm | 5 +- RAHostedAppView.h | 4 +- RAHostedAppView.xm | 30 +++++------ Reachability/UIKit.xm | 2 +- SpringBoard.xm | 2 +- WindowedMultitasking/RADesktopWindow.mm | 18 +++---- WindowedMultitasking/RAWindowBar.h | 2 +- WindowedMultitasking/RAWindowBar.xm | 50 +++++++++---------- .../StartMultitaskingGesture.xm | 2 +- headers.h | 2 + reachappbackboarddhooks/Tweak.xm | 11 +++- reachappfsdaemon/main.mm | 30 +++++------ update_status | 6 +-- 28 files changed, 174 insertions(+), 137 deletions(-) diff --git a/Backgrounding/BackgroundModeTogglerActivator.xm b/Backgrounding/BackgroundModeTogglerActivator.xm index 44e5c24..cabf8a2 100644 --- a/Backgrounding/BackgroundModeTogglerActivator.xm +++ b/Backgrounding/BackgroundModeTogglerActivator.xm @@ -57,9 +57,9 @@ static RAActivatorBackgrounderToggleModeListener *sharedInstance$RAActivatorBack %ctor { - if ([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"]) + if (IN_SPRINGBOARD) { sharedInstance$RAActivatorBackgrounderToggleModeListener = [[RAActivatorBackgrounderToggleModeListener alloc] init]; [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorBackgrounderToggleModeListener forName:@"com.efrederickson.reachapp.backgrounder.togglemode"]; } -} \ No newline at end of file +} diff --git a/Backgrounding/Makefile b/Backgrounding/Makefile index 38fad7f..cc51bbd 100644 --- a/Backgrounding/Makefile +++ b/Backgrounding/Makefile @@ -1,6 +1,6 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -Wno-deprecated-declarations +CFLAGS = -I../ -I../Theming/ -I../WindowedMultitasking/ -Wno-deprecated-declarations CFLAGS += -fobjc-arc -O2 include $(THEOS)/makefiles/common.mk diff --git a/Backgrounding/RABackgrounder.h b/Backgrounding/RABackgrounder.h index 41b3f48..12870df 100644 --- a/Backgrounding/RABackgrounder.h +++ b/Backgrounding/RABackgrounder.h @@ -29,7 +29,7 @@ typedef NS_ENUM(NSInteger, RAIconIndicatorViewInfo) { NSString *FriendlyNameForBackgroundMode(RABackgroundMode mode); @interface RABackgrounder : NSObject -+(id) sharedInstance; ++(instancetype) sharedInstance; -(BOOL) shouldAutoLaunchApplication:(NSString*)identifier; -(BOOL) shouldAutoRelaunchApplication:(NSString*)identifier; diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index a533a35..80f0a81 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -1,5 +1,6 @@ #import "RABackgrounder.h" #import "RASettings.h" +#import "Multiplexer.h" NSString *FriendlyNameForBackgroundMode(RABackgroundMode mode) { @@ -24,7 +25,7 @@ NSMutableDictionary *temporaryOverrides = [NSMutableDictionary dictionary]; NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; @implementation RABackgrounder -+(id) sharedInstance ++(instancetype) sharedInstance { SHARED_INSTANCE(RABackgrounder); } @@ -68,7 +69,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; { if (!identifier) return; - if ([temporaryShouldPop objectForKey:identifier] != nil && [[temporaryShouldPop objectForKey:identifier] boolValue]) + if ([temporaryShouldPop objectForKey:identifier] && [[temporaryShouldPop objectForKey:identifier] boolValue]) { [temporaryShouldPop removeObjectForKey:identifier]; [temporaryOverrides removeObjectForKey:identifier]; @@ -117,7 +118,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; -(NSInteger) backgroundModeForIdentifier:(NSString*)identifier { @autoreleasepool { - if (!identifier || [[%c(RASettings) sharedInstance] backgrounderEnabled] == NO) + if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return RABackgroundModeNative; NSInteger temporaryOverride = [self popTemporaryOverrideForApplication:identifier]; @@ -152,11 +153,11 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; if (close) { - FBWorkspaceEvent *event = [objc_getClass("FBWorkspaceEvent") eventWithName:@"ActivateSpringBoard" handler:^{ - SBAppToAppWorkspaceTransaction *transaction = [[objc_getClass("SBAppExitedWorkspaceTransaction") alloc] initWithAlertManager:nil exitedApp:app]; + FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBAppToAppWorkspaceTransaction *transaction = [%c(Multiplexer) createSBAppToAppWorkspaceTransactionForExitingApp:app]; [transaction begin]; }]; - [(FBWorkspaceEventQueue*)[objc_getClass("FBWorkspaceEventQueue") sharedInstance] executeOrAppendEvent:event]; + [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; } } @@ -195,18 +196,18 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; @autoreleasepool { SBIconView *ret = nil; if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { - if ([[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) + if ([[[%c(SBIconViewMap) homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) { // iOS 8.0+ - SBApplicationIcon *icon = [[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; - ret = [[objc_getClass("SBIconViewMap") homescreenMap] mappedIconViewForIcon:icon]; + SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; + ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; } else { // iOS 7.X - SBApplicationIcon *icon = [[[objc_getClass("SBIconViewMap") homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; - ret = [[objc_getClass("SBIconViewMap") homescreenMap] mappedIconViewForIcon:icon]; + SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; + ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; } } else { SBApplicationIcon *icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:identifier]; diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index 01de77d..ad75ee4 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -27,7 +27,7 @@ [arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"] == NO && // Whitelist filza to prevent iOS hang (?!) !IN_SPRINGBOARD) // FIXME: this is a hack that prevents SpringBoard from not starting { - NSString *identifier = NSBundle.mainBundle.bundleIdentifier; + NSString *identifier = [NSBundle mainBundle].bundleIdentifier; if (!identifier) goto ORIGINAL; diff --git a/GestureSupport/Hooks_iOS8.xm b/GestureSupport/Hooks_iOS8.xm index 399b6ab..d2e1cad 100644 --- a/GestureSupport/Hooks_iOS8.xm +++ b/GestureSupport/Hooks_iOS8.xm @@ -15,11 +15,11 @@ static BOOL isTracking = NO; static NSMutableSet *gestureRecognizers; UIRectEdge currentEdge; -struct VelocityData { +typedef struct { CGPoint velocity; double timestamp; CGPoint location; -}; +} VelocityData; %hook _UIScreenEdgePanRecognizer - (void)incorporateTouchSampleAtLocation:(CGPoint)location timestamp:(double)timestamp modifier:(NSInteger)modifier interfaceOrientation:(UIInterfaceOrientation)orientation diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index bfb14eb..793e4d4 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -59,8 +59,15 @@ extern BOOL allowClosingReachabilityNatively; _currentData = data; // Initialize data - serverCenter = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - rocketbootstrap_distributedmessagingcenter_apply(serverCenter); + serverCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + + void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); + if (handle) + { + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(serverCenter); + dlclose(handle); + } } -(void) alertUser:(NSString*)description diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index 92cd545..c5cb072 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -12,6 +12,7 @@ #import "RADesktopManager.h" #import "RAWindowSnapDataProvider.h" #import "RAHostManager.h" +#import "Multiplexer.h" extern BOOL launchNextOpenIntoWindow; @@ -34,8 +35,15 @@ extern BOOL launchNextOpenIntoWindow; -(void) loadServer { - messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); + messagingCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + + void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); + if (handle) + { + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); + dlclose(handle); + } [messagingCenter runServerOnCurrentThread]; @@ -143,27 +151,27 @@ extern BOOL launchNextOpenIntoWindow; { if ([identifier isEqual:RAMessagingDetachCurrentAppMessageName]) { - SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; + SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; - if (topApp) - { - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; - [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; + if (topApp) + { + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; + [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; - UIView *appView = [RAHostManager systemHostViewForApplication:topApp].superview; + UIView *appView = [RAHostManager systemHostViewForApplication:topApp].superview; [UIView animateWithDuration:0.2 animations:^{ appView.transform = CGAffineTransformMakeScale(0.5, 0.5); } completion:^(BOOL _) { [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ - SBAppToAppWorkspaceTransaction *transaction = [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithAlertManager:nil exitedApp:UIApplication.sharedApplication._accessibilityFrontMostApplication]; + SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; [transaction begin]; }]; [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; }]; - } + } } else if ([identifier isEqual:RAMessagingGoToDesktopOnTheLeftMessageName]) { diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index 776d4c1..88212d1 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -26,7 +26,7 @@ static RAActivatorListener *sharedInstance; %ctor { - if ([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"]) + if (IN_SPRINGBOARD) { sharedInstance = [[RAActivatorListener alloc] init]; [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.missioncontrol.activatorlistener"]; diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 43859b6..43a6585 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -153,7 +153,7 @@ BOOL toggleOrActivate = NO; if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (IS_IPAD) { width = 60; height = 40; @@ -191,7 +191,7 @@ BOOL toggleOrActivate = NO; if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (IS_IPAD) { width = 60; height = 40; @@ -390,7 +390,7 @@ BOOL toggleOrActivate = NO; if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + if (IS_IPAD) { width = 60; height = 40; } @@ -562,6 +562,11 @@ BOOL toggleOrActivate = NO; fakeView.frame = UIScreen.mainScreen.RA_interfaceOrientedBounds; } completion:^(BOOL _) { //((UIWindow*)[[%c(SBUIController) sharedInstance] switcherWindow]).alpha = 0; + if ([%c(SBUIController) respondsToSelector:@selector(dismissSwitcherAnimated:)]) { + [[%c(SBUIController) sharedInstance] dismissSwitcherAnimated:NO]; + } else { + [[%c(SBMainSwitcherViewController) sharedInstance] dismissSwitcherNoninteractively]; + } [[%c(SBUIController) sharedInstance] restoreContentUpdatingStatusBar:YES]; [RAMissionControlManager.sharedInstance showMissionControl:NO]; [fakeView removeFromSuperview]; diff --git a/Multiplexer.xm b/Multiplexer.xm index bf4c4a4..88a505d 100644 --- a/Multiplexer.xm +++ b/Multiplexer.xm @@ -27,35 +27,34 @@ [activeExtensions addObject:ext]; } -+(id) createSBAppToAppWorkspaceTransactionForExitingApp:(SBApplication*)app ++ (SBAppToAppWorkspaceTransaction*)createSBAppToAppWorkspaceTransactionForExitingApp:(SBApplication*)app { if ([%c(SBAppToAppWorkspaceTransaction) respondsToSelector:@selector(initWithAlertManager:exitedApp:)]) { return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithAlertManager:nil exitedApp:app]; } else - { - // ** below code from Mirmir (https://github.com/EthanArbuckle/Mirmir/blob/lamo_no_ms/Lamo/CDTLamo.mm#L114-L138) - SBWorkspaceApplicationTransitionContext *transitionContext = [[%c(SBWorkspaceApplicationTransitionContext) alloc] init]; + { + // ** below code from Mirmir (https://github.com/EthanArbuckle/Mirmir/blob/lamo_no_ms/Lamo/CDTLamo.mm#L114-L138) + SBWorkspaceApplicationTransitionContext *transitionContext = [[%c(SBWorkspaceApplicationTransitionContext) alloc] init]; - //set layout role to 'side' (deactivating) - SBWorkspaceDeactivatingEntity *deactivatingEntity = [%c(SBWorkspaceDeactivatingEntity) entity]; - [deactivatingEntity setLayoutRole:3]; - [transitionContext setEntity:deactivatingEntity forLayoutRole:3]; + //set layout role to 'side' (deactivating) + SBWorkspaceDeactivatingEntity *deactivatingEntity = [%c(SBWorkspaceDeactivatingEntity) entity]; + [deactivatingEntity setLayoutRole:3]; + [transitionContext setEntity:deactivatingEntity forLayoutRole:3]; - //set layout role for 'primary' (activating) - SBWorkspaceHomeScreenEntity *homescreenEntity = [[%c(SBWorkspaceHomeScreenEntity) alloc] init]; - [transitionContext setEntity:homescreenEntity forLayoutRole:2]; + //set layout role for 'primary' (activating) + SBWorkspaceHomeScreenEntity *homescreenEntity = [[%c(SBWorkspaceHomeScreenEntity) alloc] init]; + [transitionContext setEntity:homescreenEntity forLayoutRole:2]; - [transitionContext setAnimationDisabled:YES]; + [transitionContext setAnimationDisabled:YES]; - //create transititon request - SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[UIScreen.mainScreen valueForKey:@"_fbsDisplay"]]; - [transitionRequest setValue:transitionContext forKey:@"_applicationContext"]; + //create transititon request + SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[UIScreen.mainScreen valueForKey:@"_fbsDisplay"]]; + [transitionRequest setApplicationContext:transitionContext]; - return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithTransitionRequest:transitionRequest]; - // ** // - } + return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithTransitionRequest:transitionRequest]; + } } +(BOOL) shouldShowControlCenterGrabberOnFirstSwipe diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index e068d6e..3a35c18 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -127,15 +127,14 @@ static BOOL hasEnteredPages = NO; - (void)viewDidDisappear:(BOOL)arg1 { %orig; - NSNumber *passedValue = [NSNumber numberWithBool:YES]; - [ncAppViewController performSelector:@selector(viewDidDisappear:) withObject:passedValue afterDelay:2.0]; + [ncAppViewController.hostedApp unloadApp]; } - (UIPageControl*)pageControl { - UIPageControl *original = %orig; - original.numberOfPages = 3; - return original; + UIPageControl *original = %orig; + original.numberOfPages = 3; + return original; } %end %end diff --git a/NotificationCenterApp/RANCViewController.xm b/NotificationCenterApp/RANCViewController.xm index d6025d7..6c77650 100644 --- a/NotificationCenterApp/RANCViewController.xm +++ b/NotificationCenterApp/RANCViewController.xm @@ -67,6 +67,11 @@ int rotationDegsForOrientation(int o) { [super viewDidAppear:animated]; + if (![[%c(SBNotificationCenterController) sharedInstance] isVisible] && ![[%c(SBNotificationCenterController) sharedInstance] isTransitioning]) + { + return; + } + if ([[%c(SBLockScreenManager) sharedInstance] isUILocked]) { if (isLockedLabel == nil) @@ -75,7 +80,7 @@ int rotationDegsForOrientation(int o) isLockedLabel.numberOfLines = 2; isLockedLabel.textAlignment = NSTextAlignmentCenter; isLockedLabel.textColor = [UIColor whiteColor]; - isLockedLabel.font = [UIFont systemFontOfSize:UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 36 : 30]; + isLockedLabel.font = [UIFont systemFontOfSize:IS_IPAD ? 36 : 30]; [self.view addSubview:isLockedLabel]; } diff --git a/RAControlCenterInhibitor.xm b/RAControlCenterInhibitor.xm index ad31bd9..c2f4038 100644 --- a/RAControlCenterInhibitor.xm +++ b/RAControlCenterInhibitor.xm @@ -35,4 +35,9 @@ BOOL overrideCC = NO; if (!overrideCC) %orig; } + +- (BOOL)inGrabberOnlyMode +{ + return overrideCC || %orig; +} %end diff --git a/RAFakePhoneMode.xm b/RAFakePhoneMode.xm index 090900b..1644471 100644 --- a/RAFakePhoneMode.xm +++ b/RAFakePhoneMode.xm @@ -17,7 +17,7 @@ CGSize forcePhoneModeSize = RA_6P_SIZE; +(void) load { // Prevent iPhone issue - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (IS_IPAD) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // somehow, this is needed to make sure that both force resizing and Fake Phone Mode work. Without the dispatch_after, even if fake phone mode is disabled, // force resizing seems to render touches incorrectly ¯\_(ツ)_/¯ diff --git a/RAHostManager.xm b/RAHostManager.xm index a6fc12e..14cf6ed 100644 --- a/RAHostManager.xm +++ b/RAHostManager.xm @@ -29,6 +29,7 @@ if (!settings) return nil; + [[UIApplication sharedApplication] launchApplicationWithIdentifier:app.bundleIdentifier suspended:YES]; SET_BACKGROUNDED(settings, NO); [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; @@ -44,7 +45,7 @@ { if (!app) return nil; - + if ([app respondsToSelector:@selector(mainScene)]) { FBScene *scene = [app mainScene]; @@ -54,4 +55,4 @@ [RACompatibilitySystem showWarning:@"Unable to find valid method for accessing context host view managers"]; return nil; } -@end \ No newline at end of file +@end diff --git a/RAHostedAppView.h b/RAHostedAppView.h index a42179e..f360959 100644 --- a/RAHostedAppView.h +++ b/RAHostedAppView.h @@ -10,7 +10,7 @@ +(void) iPad_iOS83_fixHosting; --(id) initWithBundleIdentifier:(NSString*)bundleIdentifier; +-(instancetype) initWithBundleIdentifier:(NSString*)bundleIdentifier; @property (nonatomic) BOOL showSplashscreenInsteadOfSpinner; @property (nonatomic) BOOL renderWallpaper; @@ -36,4 +36,4 @@ -(void) unloadApp; -(void) unloadApp:(BOOL)forceImmediate; -@end \ No newline at end of file +@end diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index 126442a..df8488c 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -30,18 +30,18 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; @end @implementation RAHostedAppView --(id) initWithBundleIdentifier:(NSString*)bundleIdentifier +-(instancetype) initWithBundleIdentifier:(NSString*)bundleIdentifier { if (self = [super init]) { self.bundleIdentifier = bundleIdentifier; - self.autosizesApp = NO; - self.allowHidingStatusBar = YES; - self.showSplashscreenInsteadOfSpinner = NO; - startTries = 0; - disablePreload = NO; - self.renderWallpaper = NO; - self.backgroundColor = [UIColor clearColor]; + self.autosizesApp = NO; + self.allowHidingStatusBar = YES; + self.showSplashscreenInsteadOfSpinner = NO; + startTries = 0; + disablePreload = NO; + self.renderWallpaper = NO; + self.backgroundColor = [UIColor clearColor]; } return self; } @@ -96,15 +96,15 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; return; } - if (app == nil) + if (!app) return; if (_isCurrentlyHosting) return; isPreloading = YES; - FBScene *scene = [app mainScene]; - if (![app pid] || scene == nil) + FBScene *scene = [app mainScene]; + if (![app pid] || !scene) { [UIApplication.sharedApplication launchApplicationWithIdentifier:self.bundleIdentifier suspended:YES]; [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:self.bundleIdentifier]; // ummm...? @@ -138,7 +138,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; [self addSubview:view]; [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (IS_IPAD) [RAHostedAppView iPad_iOS83_fixHosting]; [RARunningAppsProvider.sharedInstance addTarget:self]; @@ -151,7 +151,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; { startTries = 0; disablePreload = NO; - [self preloadApp]; + [self preloadApp]; if (!app) return; @@ -255,7 +255,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; -(void) verifyHostingAndRehostIfNecessary { - if (!isPreloading && _isCurrentlyHosting && (app.isRunning == NO || view.contextHosted == NO)) // && (app.pid == 0 || view == nil || view.manager == nil)) // || view._isReallyHosting == NO)) + if (!isPreloading && _isCurrentlyHosting && (!app.isRunning || !view.contextHosted)) // && (app.pid == 0 || view == nil || view.manager == nil)) // || view._isReallyHosting == NO)) { //[activityView startAnimating]; [self unloadApp]; @@ -343,7 +343,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; disablePreload = YES; - if (_isCurrentlyHosting == NO) + if (!_isCurrentlyHosting) return; _isCurrentlyHosting = NO; diff --git a/Reachability/UIKit.xm b/Reachability/UIKit.xm index d22e9dd..c9db3ae 100644 --- a/Reachability/UIKit.xm +++ b/Reachability/UIKit.xm @@ -6,7 +6,7 @@ BOOL allowClosingReachabilityNatively = NO; %hook UIApplication - (void)_deactivateReachability { - if (allowClosingReachabilityNatively == NO) + if (!allowClosingReachabilityNatively) { HBLogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); return; diff --git a/SpringBoard.xm b/SpringBoard.xm index dd5e0f9..e32878f 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -144,7 +144,7 @@ extern BOOL overrideDisableForStatusBar; // can't hurt to check all devices - especially if it changes/has changed to include phones. // however this was presumably done in preparation for the iOS 9 multitasking - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (IS_IPAD) [RAHostedAppView iPad_iOS83_fixHosting]; } %end diff --git a/WindowedMultitasking/RADesktopWindow.mm b/WindowedMultitasking/RADesktopWindow.mm index 941942e..3869ece 100644 --- a/WindowedMultitasking/RADesktopWindow.mm +++ b/WindowedMultitasking/RADesktopWindow.mm @@ -44,7 +44,7 @@ -(RAWindowBar*) addAppWithView:(RAHostedAppView*)view animated:(BOOL)animated if (animated) [UIView animateWithDuration:0.5 animations:^{ windowBar.alpha = 1; }]; - if (self.hidden == NO) + if (!self.hidden) [view loadApp]; view.hideStatusBar = YES; windowBar.transform = CGAffineTransformMakeScale(0.5, 0.5); @@ -66,7 +66,7 @@ -(RAWindowBar*) addAppWithView:(RAHostedAppView*)view animated:(BOOL)animated windowBar.center = info.center; windowBar.transform = info.transform; } completion:^(BOOL _) { - [windowBar updateClientRotation]; + [windowBar updateClientRotation]; RADesktopManager.sharedInstance.lastUsedWindow = windowBar; }]; } @@ -117,7 +117,7 @@ -(void) removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated fo [appViews removeObject:view]; [self saveInfo]; - if (dontClearForcedPhoneState == NO && [RAFakePhoneMode shouldFakeForAppWithIdentifier:identifier]) + if (!dontClearForcedPhoneState && [RAFakePhoneMode shouldFakeForAppWithIdentifier:identifier]) [RAMessagingServer.sharedInstance forcePhoneMode:NO forIdentifier:identifier andRelaunchApp:YES]; }; if (animated) @@ -126,7 +126,7 @@ -(void) removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated fo view.superview.layer.position = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, UIScreen.mainScreen._referenceBounds.size.height); view.superview.layer.opacity = 0.0f; [RADesktopManager.sharedInstance findNewForemostApp]; - //view.superview.alpha = 0; + //view.superview.alpha = 0; } completion:^(BOOL _) { destructor(); }]; else destructor(); @@ -186,7 +186,7 @@ -(void) closeAllApps while (i --> 0) // Always wanted to use that 😍 { [self removeAppWithIdentifier:((RAHostedAppView*)appViews[i]).bundleIdentifier animated:YES]; - } + } } -(void) updateRotationOnClients:(UIInterfaceOrientation)orientation @@ -195,7 +195,7 @@ -(void) updateRotationOnClients:(UIInterfaceOrientation)orientation for (RAWindowBar *app in self.subviews) if ([app isKindOfClass:[RAWindowBar class]]) // could be a diferent kind of UIView actually - [app updateClientRotation:orientation]; + [app updateClientRotation:orientation]; } -(BOOL) isAppOpened:(NSString*)identifier @@ -325,7 +325,7 @@ -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; UIView *subview; - while ((subview = [objects nextObject])) + while ((subview = [objects nextObject])) { if (self.rootViewController && [self.rootViewController.view isEqual:subview]) continue; @@ -338,7 +338,7 @@ -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event return [super hitTest:point withEvent:event]; } -- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event +- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { BOOL isContained = NO; for (UIView *view in self.subviews) @@ -352,4 +352,4 @@ - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event } return isContained; } -@end \ No newline at end of file +@end diff --git a/WindowedMultitasking/RAWindowBar.h b/WindowedMultitasking/RAWindowBar.h index 48eff43..14cb4a8 100644 --- a/WindowedMultitasking/RAWindowBar.h +++ b/WindowedMultitasking/RAWindowBar.h @@ -3,7 +3,7 @@ @class RADesktopWindow; -@interface RAWindowBar : UIView { +@interface RAWindowBar : UIView { RAHostedAppView *attachedView; } diff --git a/WindowedMultitasking/RAWindowBar.xm b/WindowedMultitasking/RAWindowBar.xm index c0a0791..3d00d98 100644 --- a/WindowedMultitasking/RAWindowBar.xm +++ b/WindowedMultitasking/RAWindowBar.xm @@ -47,7 +47,7 @@ extern BOOL allowOpenApp; -(void) attachView:(RAHostedAppView*)view { height = 40; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (IS_IPAD) { height = 45; } @@ -64,9 +64,9 @@ extern BOOL allowOpenApp; view.hideStatusBar = YES; [self addSubview:view]; - panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; - panGesture.delegate = self; - [self addGestureRecognizer:panGesture]; + panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; + panGesture.delegate = self; + [self addGestureRecognizer:panGesture]; scaleGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)]; scaleGesture.delegate = self; @@ -87,12 +87,12 @@ extern BOOL allowOpenApp; [self addGestureRecognizer:tapGesture]; doubleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; - doubleTapGesture.numberOfTapsRequired = 2; + doubleTapGesture.numberOfTapsRequired = 2; doubleTapGesture.delegate = self; [self addGestureRecognizer:doubleTapGesture]; tripleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTripleTap:)]; - tripleTapGesture.numberOfTapsRequired = 3; + tripleTapGesture.numberOfTapsRequired = 3; tripleTapGesture.delegate = self; [self addGestureRecognizer:tripleTapGesture]; @@ -155,18 +155,18 @@ extern BOOL allowOpenApp; tmpItem.item = closeItemIdentifier; [infos addObject:tmpItem]; - tmpItem = [[RAWindowBarIconInfo alloc] init]; + tmpItem = [[RAWindowBarIconInfo alloc] init]; tmpItem.alignment = maxAlignment; tmpItem.priority = maxPriority; tmpItem.item = maxItemIdentifier; [infos addObject:tmpItem]; - + tmpItem = [[RAWindowBarIconInfo alloc] init]; tmpItem.alignment = minAlignment; tmpItem.priority = minPriority; tmpItem.item = minItemIdentifier; [infos addObject:tmpItem]; - + tmpItem = [[RAWindowBarIconInfo alloc] init]; tmpItem.alignment = rotationAlignment; tmpItem.priority = rotationPriority; @@ -303,8 +303,8 @@ extern BOOL allowOpenApp; self.layer.mask = maskLayer; } --(void) drawRect:(CGRect)rect -{ +-(void) drawRect:(CGRect)rect +{ CGRect topRect = CGRectMake(0, 0, rect.size.width, height); // Fill the rectangle with grey [barBackgroundColor setFill]; @@ -404,14 +404,14 @@ extern BOOL allowOpenApp; CGFloat rotation = atan2(self.transform.b, self.transform.a); CGAffineTransform transform = CGAffineTransformMakeScale(scale, scale); - if (derotate == NO) + if (!derotate) transform = CGAffineTransformRotate(transform, rotation); if (animate) [UIView animateWithDuration:0.2 animations:^{ [self setTransform:transform]; }]; - else + else [self setTransform:transform]; [self saveWindowInfo]; @@ -421,7 +421,7 @@ extern BOOL allowOpenApp; { if (sizingLocked) return; - + if (rads != 0) self.transform = CGAffineTransformRotate(self.transform, rads); @@ -430,7 +430,7 @@ extern BOOL allowOpenApp; CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); CGFloat rotateSnapDegrees = 0; - if (currentRotation < 0) + if (currentRotation < 0) currentRotation = 360 + currentRotation; if (currentRotation >= 315 || currentRotation <= 45) @@ -497,7 +497,7 @@ extern BOOL allowOpenApp; - (void)handleRotate:(UIRotationGestureRecognizer *)gesture { - if ([RASettings.sharedInstance alwaysEnableGestures] == NO && self.isOverlayShowing == NO) + if (![RASettings.sharedInstance alwaysEnableGestures] && !self.isOverlayShowing) return; if (gesture.state == UIGestureRecognizerStateChanged) @@ -569,7 +569,7 @@ extern BOOL allowOpenApp; -(void) handleTripleTap:(UITapGestureRecognizer*)tap { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + if (IS_IPAD) [RAMessagingServer.sharedInstance forcePhoneMode:![RAFakePhoneMode shouldFakeForAppWithIdentifier:attachedView.app.bundleIdentifier] forIdentifier:attachedView.app.bundleIdentifier andRelaunchApp:YES]; } @@ -624,7 +624,7 @@ extern BOOL allowOpenApp; - (void)handlePinch:(UIPinchGestureRecognizer *)gesture { - if ([RASettings.sharedInstance alwaysEnableGestures] == NO && self.isOverlayShowing == NO) + if (![RASettings.sharedInstance alwaysEnableGestures] && !self.isOverlayShowing) return; switch (gesture.state) { @@ -639,7 +639,7 @@ extern BOOL allowOpenApp; break; case UIGestureRecognizerStateEnded: enableDrag = YES; enableLongPress = YES; - + if ([RAWindowSnapDataProvider shouldSnapWindow:self]) { [RAWindowSnapDataProvider snapWindow:self toLocation:[RAWindowSnapDataProvider snapLocationForWindow:self] animated:YES]; @@ -667,7 +667,7 @@ extern BOOL allowOpenApp; [super setTransform:trans]; - if (isBeingTouched == NO) + if (!isBeingTouched) { if ([RAWindowSnapDataProvider shouldSnapWindow:self]) [RAWindowSnapDataProvider snapWindow:self toLocation:[RAWindowSnapDataProvider snapLocationForWindow:self] animated:YES]; @@ -698,7 +698,7 @@ extern BOOL allowOpenApp; if (![RASettings.sharedInstance showSnapHelper]) return; - + if (!snapShadowView) { snapShadowView = [[UIView alloc] initWithFrame:self.bounds]; @@ -768,7 +768,7 @@ extern BOOL allowOpenApp; return [super hitTest:point withEvent:event]; } -- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event +- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { BOOL isContained = NO; for (UIView *view in self.subviews) @@ -779,11 +779,11 @@ extern BOOL allowOpenApp; return isContained || [super pointInside:point withEvent:event]; } -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) return NO; - return YES; + return YES; } -(RAHostedAppView*) attachedView { return attachedView; } -@end \ No newline at end of file +@end diff --git a/WindowedMultitasking/StartMultitaskingGesture.xm b/WindowedMultitasking/StartMultitaskingGesture.xm index fd4983a..6d6adef 100644 --- a/WindowedMultitasking/StartMultitaskingGesture.xm +++ b/WindowedMultitasking/StartMultitaskingGesture.xm @@ -150,6 +150,6 @@ BOOL locationIsInValidArea(CGFloat x) return RAGestureCallbackResultSuccess; } withCondition:^BOOL(CGPoint location, CGPoint velocity) { - return [RASettings.sharedInstance windowedMultitaskingEnabled] && (locationIsInValidArea(location.x) || appView) && ![[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && [UIApplication.sharedApplication _accessibilityFrontMostApplication] != nil && ![[%c(SBNotificationCenterController) sharedInstance] isVisible]; + return [RASettings.sharedInstance windowedMultitaskingEnabled] && (locationIsInValidArea(location.x) || appView) && ![[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && [UIApplication.sharedApplication _accessibilityFrontMostApplication] && ![[%c(SBNotificationCenterController) sharedInstance] isVisible]; } forEdge:UIRectEdgeBottom identifier:@"com.efrederickson.reachapp.windowedmultitasking.systemgesture" priority:RAGesturePriorityDefault]; } diff --git a/headers.h b/headers.h index f0080fa..a61926c 100644 --- a/headers.h +++ b/headers.h @@ -414,6 +414,8 @@ typedef struct { +(id) sharedInstance; -(SBNotificationCenterViewController *)viewController; -(BOOL) isVisible; +-(BOOL)isTransitioning; +-(BOOL)isPresentingControllerTransitioning; @end @interface UIStatusBarItem : NSObject diff --git a/reachappbackboarddhooks/Tweak.xm b/reachappbackboarddhooks/Tweak.xm index 03cc7e0..71d94ff 100644 --- a/reachappbackboarddhooks/Tweak.xm +++ b/reachappbackboarddhooks/Tweak.xm @@ -155,6 +155,13 @@ void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEven %ctor { - center = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - rocketbootstrap_distributedmessagingcenter_apply(center); + center = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + + void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); + if(handle) + { + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(center); + dlclose(handle); + } } diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index de50586..866a783 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -9,25 +9,25 @@ int main(int argc, char **argv, char **envp) { @autoreleasepool { NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; - if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) - { - HBLogError(@"[ReachApp] FS Daemon: plist does not exist"); - return 0; - } + if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) + { + HBLogError(@"[ReachApp] FS Daemon: plist does not exist"); + return 0; + } NSDictionary *contents = [NSDictionary dictionaryWithContentsOfFile:filePath]; - LSApplicationProxy *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:contents[@"bundleIdentifier"]]; - NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; - NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; - infoPlist[@"UIApplicationExitsOnSuspend"] = contents[@"UIApplicationExitsOnSuspend"]; - BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; + LSApplicationProxy *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:contents[@"bundleIdentifier"]]; + NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; + NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; + infoPlist[@"UIApplicationExitsOnSuspend"] = contents[@"UIApplicationExitsOnSuspend"]; + BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; - if (!success) { - HBLogError(@"[ReachApp] FS Daemon: error writing to plist: %@", path); - } else { - [NSFileManager.defaultManager removeItemAtPath:filePath error:nil]; - } + if (!success) { + HBLogError(@"[ReachApp] FS Daemon: error writing to plist: %@", path); + } else { + [NSFileManager.defaultManager removeItemAtPath:filePath error:nil]; + } } return 0; } diff --git a/update_status b/update_status index d973d1d..a713d57 100644 --- a/update_status +++ b/update_status @@ -23,15 +23,13 @@ Bugs: - Individual app force foregrounding is broken when used in conjunction with auto (re)launch; - MC view invokes regardless if grabbing the grabber or not - Replace AppSwitcher with MC is broken -- Invoking MC shows appswitcher dismissing +- Invoking MC shows appswitcher dismissing (dont know if can fix) - Invoking keyboard in reachapp closes view -- NCApp doesnt properly unload (Should now after hacky fix?) +- viewDidAppear is called when NC disappeared causing NCapp to not unload - Showing NC with reachapp doesnt properly resize - Startup bug still isnt fixed - Some say it causes serios lag? - Launching MC from activator gesture black screen -- Empoleon frozen upon homebutton press - notes: use _referenceBounds instead of bounds on UIScreen to get physical bounds. Makes landscape support easier? From 5447023dedf5dd754774ae3cc65845225b1b188e Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sun, 5 Mar 2017 21:53:19 -0600 Subject: [PATCH 34/59] Fixed NCApp? --- NotificationCenterApp/NCHook.xm | 13 ++++- NotificationCenterApp/RANCViewController.xm | 3 +- headers.h | 1 + reachappassertiondhooks/Tweak.xm | 56 +++++++++++---------- update_status | 8 ++- 5 files changed, 51 insertions(+), 30 deletions(-) diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index 3a35c18..c370a60 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -23,6 +23,7 @@ NSString *getAppName() } RANCViewController *ncAppViewController; +BOOL shouldLoadView = NO; %group iOS8 %hook SBNotificationCenterViewController @@ -124,10 +125,20 @@ static BOOL hasEnteredPages = NO; %end %hook SBNotificationCenterViewController +- (void)viewWillAppear:(BOOL)arg1 +{ + %orig; + + shouldLoadView = YES; + [ncAppViewController viewDidAppear:arg1]; +} + - (void)viewDidDisappear:(BOOL)arg1 { %orig; - [ncAppViewController.hostedApp unloadApp]; + + shouldLoadView = NO; + [ncAppViewController viewDidDisappear:arg1]; } - (UIPageControl*)pageControl diff --git a/NotificationCenterApp/RANCViewController.xm b/NotificationCenterApp/RANCViewController.xm index 6c77650..b36e757 100644 --- a/NotificationCenterApp/RANCViewController.xm +++ b/NotificationCenterApp/RANCViewController.xm @@ -12,6 +12,7 @@ @end extern RANCViewController *ncAppViewController; +extern BOOL shouldLoadView; @implementation RANCViewController +(instancetype) sharedViewController @@ -67,7 +68,7 @@ int rotationDegsForOrientation(int o) { [super viewDidAppear:animated]; - if (![[%c(SBNotificationCenterController) sharedInstance] isVisible] && ![[%c(SBNotificationCenterController) sharedInstance] isTransitioning]) + if (IS_IOS_OR_NEWER(iOS_10_0) && !shouldLoadView) { return; } diff --git a/headers.h b/headers.h index a61926c..47a4778 100644 --- a/headers.h +++ b/headers.h @@ -414,6 +414,7 @@ typedef struct { +(id) sharedInstance; -(SBNotificationCenterViewController *)viewController; -(BOOL) isVisible; +-(double)percentComplete; -(BOOL)isTransitioning; -(BOOL)isPresentingControllerTransitioning; @end diff --git a/reachappassertiondhooks/Tweak.xm b/reachappassertiondhooks/Tweak.xm index 892f11d..eb2ada7 100644 --- a/reachappassertiondhooks/Tweak.xm +++ b/reachappassertiondhooks/Tweak.xm @@ -1,38 +1,42 @@ #import -#import #import #import -extern const char *__progname; +%group iOS8 +%hookf(int, BSAuditTokenTaskHasEntitlement, id connection, NSString *entitlement) +{ + if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) + { + return true; + } -static int (*orig_BSAuditTokenTaskHasEntitlement)(id connection, NSString *entitlement); -static int hax_BSAuditTokenTaskHasEntitlement(__unsafe_unretained id connection, __unsafe_unretained NSString *entitlement) { - if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { - return true; - } - - return orig_BSAuditTokenTaskHasEntitlement(connection, entitlement); + return %orig; } +%end -static int (*orig_BSXPCConnectionHasEntitlement)(id connection, NSString *entitlement); -static int hax_BSXPCConnectionHasEntitlement(__unsafe_unretained id connection, __unsafe_unretained NSString *entitlement) { - if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { - return true; - } +%group iOS9andUp +%hookf(int, BSXPCConnectionHasEntitlement, id connection, NSString *entitlement) +{ + if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) + { + return true; + } - return orig_BSXPCConnectionHasEntitlement(connection, entitlement); + return %orig; } +%end %ctor { - // We can never be too sure - if (strcmp(__progname, "assertiond") == 0) { - dlopen("/System/Library/PrivateFrameworks/XPCObjects.framework/XPCObjects", RTLD_LAZY); - if (IS_IOS_OR_OLDER(iOS_8_4)) { - void *xpcFunction = MSFindSymbol(NULL, "_BSAuditTokenTaskHasEntitlement"); - MSHookFunction(xpcFunction, (void *)hax_BSAuditTokenTaskHasEntitlement, (void **)&orig_BSAuditTokenTaskHasEntitlement); - } else { - void *xpcFunction = MSFindSymbol(NULL, "_BSXPCConnectionHasEntitlement"); - MSHookFunction(xpcFunction, (void *)hax_BSXPCConnectionHasEntitlement, (void **)&orig_BSXPCConnectionHasEntitlement); - } - } + // We can never be too sure (im pretty sure we can) + dlopen("/System/Library/PrivateFrameworks/XPCObjects.framework/XPCObjects", RTLD_LAZY); + if (IS_IOS_OR_NEWER(iOS_9_0)) + { + void *BSXPCConnectionHasEntitlement = MSFindSymbol(NULL, "_BSXPCConnectionHasEntitlement"); + %init(iOS9andUp); + } + else + { + void *BSAuditTokenTaskHasEntitlement = MSFindSymbol(NULL, "_BSAuditTokenTaskHasEntitlement"); + %init(iOS8); + } } diff --git a/update_status b/update_status index a713d57..882f6e0 100644 --- a/update_status +++ b/update_status @@ -25,11 +25,15 @@ Bugs: - Replace AppSwitcher with MC is broken - Invoking MC shows appswitcher dismissing (dont know if can fix) - Invoking keyboard in reachapp closes view -- viewDidAppear is called when NC disappeared causing NCapp to not unload - Showing NC with reachapp doesnt properly resize - Startup bug still isnt fixed -- Some say it causes serios lag? +- Some say it causes serious lag? - Launching MC from activator gesture black screen +- Foregrounding through activator broken? +- CC inhibitor still broken? + +Features Intended: +- Activator Gesture to launch window notes: use _referenceBounds instead of bounds on UIScreen to get physical bounds. Makes landscape support easier? From 517f5975b69ffc2f1f91314c736691a589a6d6f8 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 6 Mar 2017 17:50:57 -0600 Subject: [PATCH 35/59] Macros + MC + Empoleon + random fixes --- .../BackgroundModeTogglerActivator.xm | 2 +- Backgrounding/SpringBoard.xm | 1 + .../SpringBoard_UIAppCustomBackgroundModes.xm | 2 +- Backgrounding/UnlimitedBackgrounding.xm | 2 +- DRM/Statistics.xm | 2 +- Debugging/Core.xm | 10 +-- GestureSupport/Hooks_iOS9.xm | 6 +- KeyboardSupport/RAKeyboardStateListener.xm | 8 +-- KeyboardSupport/RARemoteKeyboardView.xm | 2 +- .../RASpringBoardKeyboardActivation.xm | 4 +- Messaging/RAMessagingClient.xm | 4 +- Messaging/RAMessagingServer.xm | 2 +- MissionControl/ActivatorListener.xm | 4 +- MissionControl/AppSwitcher.xm | 63 ++++++++++++++++++- NotificationCenterApp/RANCViewController.xm | 2 +- RAFakePhoneMode.xm | 2 +- RAHostedAppView.xm | 4 +- RALocalizer.mm | 2 +- RASBWorkspaceFetcher.xm | 2 +- RASettings.mm | 6 +- RASnapshotProvider.xm | 2 +- Reachability/Reachability.xm | 14 ++++- Reachability/UIKit.xm | 4 +- SwipeOver/SwipeOverGesture.xm | 8 +-- Theming/RAThemeManager.mm | 6 +- Tweak.xm | 9 ++- .../StartMultitaskingGesture.xm | 2 +- headers.h | 29 ++++++++- reachappfsdaemon/main.mm | 4 +- update_status | 18 +++--- .../Reachability/RAWidgetSectionManager.mm | 2 +- 31 files changed, 165 insertions(+), 63 deletions(-) diff --git a/Backgrounding/BackgroundModeTogglerActivator.xm b/Backgrounding/BackgroundModeTogglerActivator.xm index cabf8a2..b77d61a 100644 --- a/Backgrounding/BackgroundModeTogglerActivator.xm +++ b/Backgrounding/BackgroundModeTogglerActivator.xm @@ -57,7 +57,7 @@ static RAActivatorBackgrounderToggleModeListener *sharedInstance$RAActivatorBack %ctor { - if (IN_SPRINGBOARD) + IF_SPRINGBOARD { sharedInstance$RAActivatorBackgrounderToggleModeListener = [[RAActivatorBackgrounderToggleModeListener alloc] init]; [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorBackgrounderToggleModeListener forName:@"com.efrederickson.reachapp.backgrounder.togglemode"]; diff --git a/Backgrounding/SpringBoard.xm b/Backgrounding/SpringBoard.xm index 32d43c3..dc01fb8 100644 --- a/Backgrounding/SpringBoard.xm +++ b/Backgrounding/SpringBoard.xm @@ -82,6 +82,7 @@ %hook FBUIApplicationWorkspaceScene -(void) host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 { + LogDebug(@"running host thing for: %@", arg1.identifier); [RABackgrounder.sharedInstance removeTemporaryOverrideForIdentifier:arg1.identifier]; if (arg1 && arg1.identifier && arg2 && arg1.clientProcess) // FIX: sanity check to prevent NC App crash. untested/not working. { diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index ad75ee4..32537d3 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -25,7 +25,7 @@ if ((arg3 == kProcessAssertionReasonViewServices) == NO && // whitelist this to allow share menu to work [arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] == NO && // whitelist iCleaner to prevent crash on open [arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"] == NO && // Whitelist filza to prevent iOS hang (?!) - !IN_SPRINGBOARD) // FIXME: this is a hack that prevents SpringBoard from not starting + !IS_SPRINGBOARD) // FIXME: this is a hack that prevents SpringBoard from not starting { NSString *identifier = [NSBundle mainBundle].bundleIdentifier; diff --git a/Backgrounding/UnlimitedBackgrounding.xm b/Backgrounding/UnlimitedBackgrounding.xm index 342dfcf..6dd27bc 100644 --- a/Backgrounding/UnlimitedBackgrounding.xm +++ b/Backgrounding/UnlimitedBackgrounding.xm @@ -17,7 +17,7 @@ BKSProcessAssertion *keepAlive$temp; reason:kProcessAssertionReasonBackgroundUI name:@"reachapp" withHandler:^{ - HBLogInfo(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); + LogInfo(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); if (keepAlive$temp.valid) processAssertions[arg1.identifier] = keepAlive$temp; else diff --git a/DRM/Statistics.xm b/DRM/Statistics.xm index 6d5c6de..925577c 100644 --- a/DRM/Statistics.xm +++ b/DRM/Statistics.xm @@ -4,7 +4,7 @@ { IF_SPRINGBOARD { #if DEBUG - HBLogInfo(@"[ReachApp][DRM] Not checking statistics on debug build"); + LogInfo(@"[ReachApp][DRM] Not checking statistics on debug build"); #else dispatch_async(dispatch_get_main_queue(), ^(void){ NSString *statsPath = @"/var/mobile/Library/Preferences/.multiplexer.stats_checked"; diff --git a/Debugging/Core.xm b/Debugging/Core.xm index 809c600..8d78ea2 100644 --- a/Debugging/Core.xm +++ b/Debugging/Core.xm @@ -10,13 +10,13 @@ - (void)doesNotRecognizeSelector:(SEL)selector { #if DEBUG - HBLogDebug(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); + LogDebug(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); NSArray * symbols = [NSThread callStackSymbols]; - HBLogDebug(@"[ReachApp] Obtained %zd stack frames:\n", symbols.count); + LogDebug(@"[ReachApp] Obtained %zd stack frames:\n", symbols.count); for (NSString *symbol in symbols) { - HBLogDebug(@"[ReachApp] %@\n", symbol); + LogDebug(@"[ReachApp] %@\n", symbol); } #endif @@ -30,7 +30,7 @@ Class hook$objc_getClass(const char *name) Class cls = orig$objc_getClass(name); if (!cls) { - HBLogDebug(@"[ReachApp] something attempted to access nil class '%s'", name); + LogDebug(@"[ReachApp] something attempted to access nil class '%s'", name); } return cls; }*/ @@ -44,5 +44,5 @@ Class hook$objc_getClass(const char *name) %init; } - //HBLogDebug(@"[ReachApp] %s", class_getImageName(orig$objc_getClass("RAMissionControlManager"))); + //LogDebug(@"[ReachApp] %s", class_getImageName(orig$objc_getClass("RAMissionControlManager"))); } diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index afe1e6e..095d518 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -95,7 +95,7 @@ typedef struct { location.y = location.x; location.x = t; } - HBLogDebug(@"[ReachApp] _UIScreenEdgePanRecognizer location: %@", NSStringFromCGPoint(location)); + LogDebug(@"[ReachApp] _UIScreenEdgePanRecognizer location: %@", NSStringFromCGPoint(location)); if ([RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateBegan withPoint:location velocity:screenEdgePanRecognizer.RA_velocity forEdge:screenEdgePanRecognizer.targetEdges]) { currentEdge9 = screenEdgePanRecognizer.targetEdges; @@ -136,7 +136,7 @@ void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEvent CGPoint rotatedLocation = (CGPoint) { rotatedX, rotatedY }; - HBLogInfo(@"[ReachApp] (%f, %d) %@ -> %@", density, isTracking, NSStringFromCGPoint(location), NSStringFromCGPoint(rotatedLocation)); + LogInfo(@"[ReachApp] (%f, %d) %@ -> %@", density, isTracking, NSStringFromCGPoint(location), NSStringFromCGPoint(rotatedLocation)); if (isTracking == NO) { @@ -159,7 +159,7 @@ void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEvent currentEdge9 = UIRectEdgeNone; isTracking = NO; - HBLogInfo(@"[ReachApp] touch ended."); + LogInfo(@"[ReachApp] touch ended."); } else { diff --git a/KeyboardSupport/RAKeyboardStateListener.xm b/KeyboardSupport/RAKeyboardStateListener.xm index 77caffd..8e400bd 100644 --- a/KeyboardSupport/RAKeyboardStateListener.xm +++ b/KeyboardSupport/RAKeyboardStateListener.xm @@ -19,7 +19,7 @@ BOOL isShowing = NO; - (void)didShow:(NSNotification*)notif { - HBLogDebug(@"[ReachApp] keyboard didShow"); + LogDebug(@"[ReachApp] keyboard didShow"); _visible = YES; _size = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; @@ -37,7 +37,7 @@ BOOL isShowing = NO; - (void)didHide { - HBLogDebug(@"[ReachApp] keyboard didHide"); + LogDebug(@"[ReachApp] keyboard didHide"); _visible = NO; IF_NOT_SPRINGBOARD { @@ -73,7 +73,7 @@ void externalKeyboardDidShow(CFNotificationCenterRef center, void *observer, CFS void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { - //HBLogDebug(@"[ReachApp] externalKeyboardDidHide"); + //LogDebug(@"[ReachApp] externalKeyboardDidHide"); [RAKeyboardStateListener.sharedInstance _setVisible:NO]; } @@ -97,7 +97,7 @@ void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFS assert(contextID == [[[UIKeyboard activeKeyboard] window] _contextId]); #endif - HBLogDebug(@"[ReachApp] c id %d", contextID); + LogDebug(@"[ReachApp] c id %d", contextID); } }; diff --git a/KeyboardSupport/RARemoteKeyboardView.xm b/KeyboardSupport/RARemoteKeyboardView.xm index 4e20e88..1a67711 100644 --- a/KeyboardSupport/RARemoteKeyboardView.xm +++ b/KeyboardSupport/RARemoteKeyboardView.xm @@ -25,7 +25,7 @@ unsigned int value = [RAMessagingServer.sharedInstance getStoredKeyboardContextIdForApp:identifier]; self.layerHost.contextId = value; - HBLogDebug(@"[ReachApp] loaded keyboard view with %d", value); + LogDebug(@"[ReachApp] loaded keyboard view with %d", value); if (value == 0 && cancelFetchingContextId == NO) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ diff --git a/KeyboardSupport/RASpringBoardKeyboardActivation.xm b/KeyboardSupport/RASpringBoardKeyboardActivation.xm index 590e98e..6794038 100644 --- a/KeyboardSupport/RASpringBoardKeyboardActivation.xm +++ b/KeyboardSupport/RASpringBoardKeyboardActivation.xm @@ -26,7 +26,7 @@ RAKeyboardWindow *keyboardWindow; //return; } - HBLogDebug(@"[ReachApp] showing kb window %@", identifier); + LogDebug(@"[ReachApp] showing kb window %@", identifier); keyboardWindow = [[RAKeyboardWindow alloc] init]; overrideDisableForStatusBar = YES; [keyboardWindow setupForKeyboardAndShow:identifier]; @@ -36,7 +36,7 @@ RAKeyboardWindow *keyboardWindow; -(void) hideKeyboard { - HBLogDebug(@"[ReachApp] remove kb window (%@)", _currentIdentifier); + LogDebug(@"[ReachApp] remove kb window (%@)", _currentIdentifier); keyboardWindow.hidden = YES; [keyboardWindow removeKeyboard]; keyboardWindow = nil; diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 793e4d4..530e6c3 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -33,7 +33,7 @@ extern BOOL allowClosingReachabilityNatively; [NSBundle.mainBundle.executablePath hasPrefix:@"/var/mobile/Containers/Bundle/Application"] || [NSBundle.mainBundle.executablePath hasPrefix:@"/private/var/mobile/Containers/Bundle/Application"]) { - HBLogDebug(@"[ReachApp] valid process for RAMessagingClient"); + LogDebug(@"[ReachApp] valid process for RAMessagingClient"); sharedInstance->allowedProcess = YES; } ); @@ -72,7 +72,7 @@ extern BOOL allowClosingReachabilityNatively; -(void) alertUser:(NSString*)description { - HBLogError(@"%@", description); + LogError(@"%@", description); } -(void) _requestUpdateFromServerWithTries:(int)tries diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index c5cb072..2c1a799 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -495,7 +495,7 @@ extern BOOL launchNextOpenIntoWindow; -(void) setKeyboardContextId:(unsigned int)id forIdentifier:(NSString*)identifier { - HBLogDebug(@"[ReachApp] got c id %d", id); + LogDebug(@"[ReachApp] got c id %d", id); contextIds[identifier] = @(id); } diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index 88212d1..c29027b 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -17,7 +17,7 @@ static RAActivatorListener *sharedInstance; if ([%c(SBUIController) respondsToSelector:@selector(_appSwitcherController)]) { [[[%c(SBUIController) sharedInstance] _appSwitcherController] forceDismissAnimated:NO]; } else { - [[%c(SBMainSwitcherViewController) sharedInstance] dismissSwitcherNoninteractively]; + [[%c(SBMainSwitcherViewController) sharedInstance] RA_dismissSwitcherUnanimated]; } } [event setHandled:YES]; @@ -26,7 +26,7 @@ static RAActivatorListener *sharedInstance; %ctor { - if (IN_SPRINGBOARD) + IF_SPRINGBOARD { sharedInstance = [[RAActivatorListener alloc] init]; [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.missioncontrol.activatorlistener"]; diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 43a6585..dda5882 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -100,7 +100,7 @@ BOOL toggleOrActivate = NO; -(void)_showNotificationCenterGestureBeganWithGestureRecognizer:(id)arg1 { CGPoint location = [arg1 locationInView:[[%c(SBMainSwitcherViewController) sharedInstance] view]]; if ([[%c(RASettings) sharedInstance] missionControlEnabled] && [[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && CGRectContainsPoint([[[[%c(SBMainSwitcherViewController) sharedInstance] valueForKey:@"_contentView"] contentView] viewWithTag:999].frame, location)) { - HBLogDebug(@"contains rect"); + LogDebug(@"contains rect"); return; } @@ -565,7 +565,7 @@ BOOL toggleOrActivate = NO; if ([%c(SBUIController) respondsToSelector:@selector(dismissSwitcherAnimated:)]) { [[%c(SBUIController) sharedInstance] dismissSwitcherAnimated:NO]; } else { - [[%c(SBMainSwitcherViewController) sharedInstance] dismissSwitcherNoninteractively]; + [[%c(SBMainSwitcherViewController) sharedInstance] RA_dismissSwitcherUnanimated]; } [[%c(SBUIController) sharedInstance] restoreContentUpdatingStatusBar:YES]; [RAMissionControlManager.sharedInstance showMissionControl:NO]; @@ -625,4 +625,63 @@ BOOL toggleOrActivate = NO; } %orig; } + +%new - (void)RA_dismissSwitcherUnanimated { + FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBWorkspaceApplicationTransitionContext *transitionContext = [[%c(SBWorkspaceApplicationTransitionContext) alloc] init]; + [transitionContext setAnimationDisabled:YES]; + + //set layout role to 'side' (deactivating) + SBWorkspaceDeactivatingEntity *deactivatingEntity = [%c(SBWorkspaceDeactivatingEntity) entity]; + [deactivatingEntity setLayoutRole:3]; + [transitionContext setEntity:deactivatingEntity forLayoutRole:3]; + + //set layout role for 'primary' (activating) + SBWorkspaceHomeScreenEntity *homescreenEntity = [[%c(SBWorkspaceHomeScreenEntity) alloc] init]; + [transitionContext setEntity:homescreenEntity forLayoutRole:2]; + + //create transititon request + SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[[UIScreen mainScreen] valueForKey:@"_fbsDisplay"]]; + [transitionRequest setApplicationContext:transitionContext]; + + //create apptoapp transaction + SBAppToAppWorkspaceTransaction *transaction = [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithTransitionRequest:transitionRequest]; + + //start closing + [transaction begin]; + }]; + [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; +} + +//Because I cant think of a better solution +- (BOOL)toggleSwitcherNoninteractively { + if (![self isVisible]) { + return [self activateSwitcherNoninteractively]; + } else { + return [self dismissSwitcherNoninteractively]; + } +} + +- (BOOL)activateSwitcherNoninteractively { + if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) + { + if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) + { + [RAMissionControlManager.sharedInstance showMissionControl:YES]; + } + else + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + + return YES; + } + else + { + if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) + { + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } + } + + return %orig; +} %end diff --git a/NotificationCenterApp/RANCViewController.xm b/NotificationCenterApp/RANCViewController.xm index b36e757..f96e59e 100644 --- a/NotificationCenterApp/RANCViewController.xm +++ b/NotificationCenterApp/RANCViewController.xm @@ -171,7 +171,7 @@ int rotationDegsForOrientation(int o) - (void)forwardInvocation:(NSInvocation *)anInvocation { // Override - HBLogDebug(@"[ReachApp] RANCViewController: ignoring invocation: %@", anInvocation); + LogDebug(@"[ReachApp] RANCViewController: ignoring invocation: %@", anInvocation); } - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector diff --git a/RAFakePhoneMode.xm b/RAFakePhoneMode.xm index 1644471..276e023 100644 --- a/RAFakePhoneMode.xm +++ b/RAFakePhoneMode.xm @@ -56,7 +56,7 @@ CGSize forcePhoneModeSize = RA_6P_SIZE; IF_SPRINGBOARD { return [RAMessagingServer.sharedInstance getDataForIdentifier:identifier].forcePhoneMode; } - HBLogWarn(@"[ReachApp] WARNING: +[RAFakePhoneMode shouldFakeForAppWithIdentifier:] called from outside SpringBoard!"); + LogWarn(@"[ReachApp] WARNING: +[RAFakePhoneMode shouldFakeForAppWithIdentifier:] called from outside SpringBoard!"); return NO; } diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index df8488c..757a838 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -85,7 +85,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; if (startTries > 5) { isPreloading = NO; - HBLogDebug(@"[ReachApp] maxed out preload attempts for app %@", app.bundleIdentifier); + LogDebug(@"[ReachApp] maxed out preload attempts for app %@", app.bundleIdentifier); UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Zypen" message:[NSString stringWithFormat:@"Unable to start app %@", app.displayName] preferredStyle:UIAlertControllerStyleAlert]; @@ -435,7 +435,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; FBWindowContextHostManager *manager = (FBWindowContextHostManager*)[RAHostManager hostManagerForApp:app_]; if (manager) { - HBLogDebug(@"[ReachApp] rehosting for iPad: %@", bundleIdentifier); + LogDebug(@"[ReachApp] rehosting for iPad: %@", bundleIdentifier); [manager enableHostingForRequester:@"reachapp" priority:1]; } } diff --git a/RALocalizer.mm b/RALocalizer.mm index 7804681..df0cde9 100644 --- a/RALocalizer.mm +++ b/RALocalizer.mm @@ -31,7 +31,7 @@ -(void) loadTranslation break; } if (!translation) - HBLogWarn(@"Failed Translation loading English"); + LogWarn(@"Failed Translation loading English"); [self attemptLoadForLanguageCode:@"en"]; } diff --git a/RASBWorkspaceFetcher.xm b/RASBWorkspaceFetcher.xm index 5ff5cc8..3788415 100644 --- a/RASBWorkspaceFetcher.xm +++ b/RASBWorkspaceFetcher.xm @@ -20,7 +20,7 @@ Class SBWorkspace_class_implementation_class = nil; { if ([SBWorkspace_class_implementation_class respondsToSelector:@selector(sharedInstance)]) return [SBWorkspace_class_implementation_class sharedInstance]; - HBLogDebug(@"[ReachApp] \"SBWorkspace\" class '%s' does not have '+sharedInstance' method", class_getName(SBWorkspace_class_implementation_class)); + HBLogError(@"[ReachApp] \"SBWorkspace\" class '%s' does not have '+sharedInstance' method", class_getName(SBWorkspace_class_implementation_class)); return nil; } @end diff --git a/RASettings.mm b/RASettings.mm index 695c9aa..f373d31 100644 --- a/RASettings.mm +++ b/RASettings.mm @@ -108,7 +108,7 @@ -(void) reloadSettings if (_settings == nil) { - HBLogError(@"[ReachApp] could not load settings from CFPreferences or NSDictionary"); + LogError(@"[ReachApp] could not load settings from CFPreferences or NSDictionary"); } if ([previousNCAppSetting isEqual:self.NCApp] == NO) @@ -138,7 +138,7 @@ -(void) resetSettings } else { - HBLogError(@"[ReachApp] unable to get keyList to reset settings"); + LogError(@"[ReachApp] unable to get keyList to reset settings"); } CFPreferencesAppSynchronize(appID); CFRelease(appID); @@ -348,7 +348,7 @@ -(NSDictionary*) rawCompiledBackgrounderSettingsForIdentifier:(NSString*)identif -(BOOL) isFirstRun { - HBLogDebug(@"[ReachApp] %d", BOOL(@"isFirstRun", YES)); + LogDebug(@"[ReachApp] %d", BOOL(@"isFirstRun", YES)); return BOOL(@"isFirstRun", YES); } diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index d3bf243..be0b366 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -80,7 +80,7 @@ } @catch (NSException *ex) { - HBLogError(@"[ReachApp] error generating snapshot: %@", ex); + LogError(@"[ReachApp] error generating snapshot: %@", ex); } } diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 8394f64..56a20da 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -151,7 +151,7 @@ BOOL wasEnabled = NO; id SBWorkspace$sharedInstance; %hook SB_WORKSPACE_CLASS -%new +(id) sharedInstance +%new +(instancetype) sharedInstance { return SBWorkspace$sharedInstance; } @@ -208,6 +208,8 @@ id SBWorkspace$sharedInstance; if ([viewController respondsToSelector:@selector(hostWillDismiss)]) { [viewController performSelector:@selector(hostWillDismiss)]; [viewController performSelector:@selector(hostDidDismiss)]; + } else { + [viewController performSelector:@selector(_loadContainerView)]; } //[viewController.view removeFromSuperview]; } @@ -329,6 +331,8 @@ id SBWorkspace$sharedInstance; if ([ncViewController respondsToSelector:@selector(hostWillPresent)]) { [ncViewController performSelector:@selector(hostWillPresent)]; [ncViewController performSelector:@selector(hostDidPresent)]; + } else { + [ncViewController _loadContainerView]; } if ([RASettings.sharedInstance enableRotation]) @@ -607,8 +611,10 @@ CGFloat startingY = -1; if ([RASettings.sharedInstance showNCInstead]) { - if (ncViewController) - ncViewController.view.frame = CGRectMake(0, 0, topFrame.size.width, topFrame.size.height); + if (ncViewController) { + ncViewController.view.frame = (CGRect) { { 0, 0 }, topFrame.size }; + [ncViewController viewDidLoad]; + } } else if (lastBundleIdentifier != nil || [view isKindOfClass:[RAAppSliderProviderView class]]) { @@ -737,6 +743,8 @@ CGFloat startingY = -1; SET_BACKGROUNDED(settings, NO); [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; + [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; + [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; view = [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES]; diff --git a/Reachability/UIKit.xm b/Reachability/UIKit.xm index c9db3ae..3cd2f93 100644 --- a/Reachability/UIKit.xm +++ b/Reachability/UIKit.xm @@ -8,13 +8,13 @@ BOOL allowClosingReachabilityNatively = NO; { if (!allowClosingReachabilityNatively) { - HBLogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); + LogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); return; } if ([RAMessagingClient.sharedInstance isBeingHosted]) { - HBLogDebug(@"[ReachApp] stopping reachability from closing because hosted"); + LogDebug(@"[ReachApp] stopping reachability from closing because hosted"); return; } %orig; diff --git a/SwipeOver/SwipeOverGesture.xm b/SwipeOver/SwipeOverGesture.xm index 0fc959e..40524cb 100644 --- a/SwipeOver/SwipeOverGesture.xm +++ b/SwipeOver/SwipeOverGesture.xm @@ -27,16 +27,16 @@ CGRect adjustFrameForRotation() switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) { case UIInterfaceOrientationPortrait: - HBLogDebug(@"[ReachApp] portrait"); + LogDebug(@"[ReachApp] portrait"); return (CGRect){ { width - portraitWidth + 5, (height - portraitHeight) / 2 }, { portraitWidth, portraitHeight } }; case UIInterfaceOrientationPortraitUpsideDown: - HBLogDebug(@"[ReachApp] portrait upside down"); + LogDebug(@"[ReachApp] portrait upside down"); return (CGRect){ { 0, 0}, { 50, 50 } }; case UIInterfaceOrientationLandscapeLeft: - HBLogDebug(@"[ReachApp] landscape left"); + LogDebug(@"[ReachApp] landscape left"); return (CGRect){ { ((width - portraitWidth) / 2), -(portraitWidth / 2) }, { portraitWidth, portraitHeight } }; case UIInterfaceOrientationLandscapeRight: - HBLogDebug(@"[ReachApp] landscape right"); + LogDebug(@"[ReachApp] landscape right"); return (CGRect){ { (height - portraitHeight) / 2, width - portraitWidth - 5 }, { portraitWidth, portraitHeight } }; } return CGRectZero; diff --git a/Theming/RAThemeManager.mm b/Theming/RAThemeManager.mm index cdb95f5..b11afc8 100644 --- a/Theming/RAThemeManager.mm +++ b/Theming/RAThemeManager.mm @@ -15,7 +15,7 @@ -(NSArray*) allThemes { return allThemes.allValues; } -(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier { #if DEBUG - HBLogDebug(@"[ReachApp] loading themes..."); + LogDebug(@"[ReachApp] loading themes..."); NSDate *startTime = [NSDate date]; #endif @@ -34,7 +34,7 @@ -(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier RATheme *theme = [RAThemeLoader loadFromFile:themeName]; if (theme && theme.themeIdentifier) { - //HBLogDebug(@"[ReachApp] adding %@", theme.themeIdentifier); + //LogDebug(@"[ReachApp] adding %@", theme.themeIdentifier); allThemes[theme.themeIdentifier] = theme; if ([theme.themeIdentifier isEqual:currentIdentifier]) @@ -52,7 +52,7 @@ -(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier #if DEBUG NSDate *endTime = [NSDate date]; - HBLogDebug(@"[ReachApp] loaded %ld themes in %f seconds.", (long)allThemes.count, [endTime timeIntervalSinceDate:startTime]); + LogDebug(@"[ReachApp] loaded %ld themes in %f seconds.", (long)allThemes.count, [endTime timeIntervalSinceDate:startTime]); #endif } @end diff --git a/Tweak.xm b/Tweak.xm index 20a0499..bd13901 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -18,13 +18,20 @@ Any code based off of or using parts of the above projects is documented. */ +// IS_SPRINGBOARD macro optimized from always comparing NSBundle - because it won't change in-process +BOOL $__IS_SPRINGBOARD = NO; +%ctor +{ + $__IS_SPRINGBOARD = [[NSBundle mainBundle].bundleIdentifier isEqual:@"com.apple.springboard"]; +} + void SET_BACKGROUNDED(id settings, BOOL value) { #if __has_feature(objc_arc) // stupid ARC... ptrdiff_t bgOffset = ivar_getOffset(class_getInstanceVariable([settings class], "_backgrounded")); CFTypeRef settingsRef = CFBridgingRetain(settings); - uint8_t *bgPtr = ((uint8_t *)(__bridge void *)settings) + bgOffset; + uint8_t *bgPtr = (uint8_t *)settingsRef + bgOffset; memcpy(bgPtr, &value, sizeof(value)); CFBridgingRelease(settingsRef); #else diff --git a/WindowedMultitasking/StartMultitaskingGesture.xm b/WindowedMultitasking/StartMultitaskingGesture.xm index 6d6adef..c623f44 100644 --- a/WindowedMultitasking/StartMultitaskingGesture.xm +++ b/WindowedMultitasking/StartMultitaskingGesture.xm @@ -16,7 +16,7 @@ BOOL locationIsInValidArea(CGFloat x) switch ([RASettings.sharedInstance windowedMultitaskingGrabArea]) { case RAGrabAreaBottomLeftThird: - HBLogDebug(@"[ReachApp] StartMultitaskingGesture: %f %f", x, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width); + LogDebug(@"[ReachApp] StartMultitaskingGesture: %f %f", x, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width); return x <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0; case RAGrabAreaBottomMiddleThird: return x >= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0 && x <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0) * 2; diff --git a/headers.h b/headers.h index 47a4778..f0189f8 100644 --- a/headers.h +++ b/headers.h @@ -37,6 +37,25 @@ #define GET_STATUSBAR_ORIENTATION (UIApplication.sharedApplication._accessibilityFrontMostApplication == nil ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) +#if DEBUG +#define LogDebug HBLogDebug +#define LogInfo HBLogInfo +#define LogWarn HBLogWarn +#define LogError HBLogError +#else +#define LogDebug(...) +#define LogInfo(...) +#define LogWarn(...) +#define LogError(...) +#endif + +#if MULTIPLEXER_CORE +extern BOOL $__IS_SPRINGBOARD; +#define IS_SPRINGBOARD $__IS_SPRINGBOARD +#else +#define IS_SPRINGBOARD IN_SPRINGBOARD +#endif + #define ON_MAIN_THREAD(block) \ { \ dispatch_block_t _blk = block; \ @@ -46,8 +65,8 @@ dispatch_sync(dispatch_get_main_queue(), _blk); \ } -#define IF_SPRINGBOARD if (IN_SPRINGBOARD) -#define IF_NOT_SPRINGBOARD if (!IN_SPRINGBOARD) +#define IF_SPRINGBOARD if (IS_SPRINGBOARD) +#define IF_NOT_SPRINGBOARD if (!IS_SPRINGBOARD) #define IF_THIS_PROCESS(x) if ([[x objectForKey:@"bundleIdentifier"] isEqual:NSBundle.mainBundle.bundleIdentifier]) // ugh, i got so tired of typing this in by hand, plus it expands method declarations by a LOT. @@ -408,6 +427,9 @@ typedef struct { @interface SBNotificationCenterViewController : UIViewController -(void)_setContainerFrame:(CGRect)arg1 ; +-(void)prepareLayoutForDefaultPresentation; +-(void)_loadContainerView; +-(void)_loadContentView; @end @interface SBNotificationCenterController : NSObject @@ -1489,6 +1511,9 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) @interface SBMainSwitcherViewController : UIViewController + (id)sharedInstance; - (BOOL)dismissSwitcherNoninteractively; +- (BOOL)isVisible; +- (BOOL)activateSwitcherNoninteractively; +- (void)RA_dismissSwitcherUnanimated; @end @interface SBSwitcherContainerView : UIView diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index 866a783..cbe8383 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -11,7 +11,7 @@ int main(int argc, char **argv, char **envp) { NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) { - HBLogError(@"[ReachApp] FS Daemon: plist does not exist"); + LogError(@"[ReachApp] FS Daemon: plist does not exist"); return 0; } @@ -24,7 +24,7 @@ int main(int argc, char **argv, char **envp) { BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; if (!success) { - HBLogError(@"[ReachApp] FS Daemon: error writing to plist: %@", path); + LogError(@"[ReachApp] FS Daemon: error writing to plist: %@", path); } else { [NSFileManager.defaultManager removeItemAtPath:filePath error:nil]; } diff --git a/update_status b/update_status index 882f6e0..34dd4d5 100644 --- a/update_status +++ b/update_status @@ -8,7 +8,7 @@ GestureSupport: fixed Backgrounding: working KeyboardSupport: hackily fixed but it works now MissionControl: working (MC presents even when not dragging grabber) -NCApp: working (not tested on ipad / app should be frozen but doesn't appear to be); +NCApp: working (not tested on ipad); assertiond hooks: working backboardd hooks: unknown fake phone mode: working @@ -22,16 +22,18 @@ fake phone mode: working Bugs: - Individual app force foregrounding is broken when used in conjunction with auto (re)launch; - MC view invokes regardless if grabbing the grabber or not -- Replace AppSwitcher with MC is broken -- Invoking MC shows appswitcher dismissing (dont know if can fix) -- Invoking keyboard in reachapp closes view +- Invoking keyboard in reachapp closes view (I think reachability dismisses when using KB) - Showing NC with reachapp doesnt properly resize -- Startup bug still isnt fixed -- Some say it causes serious lag? -- Launching MC from activator gesture black screen -- Foregrounding through activator broken? +- Launching MC from activator gesture in app black screen +- Foregrounding through activator broken (override gets removed when launching another app) - CC inhibitor still broken? +Minor Things to note: +- MC works but causes jittery animations; +- NCApp disappears on first load +- Some say it causes serious lag (probably because logs werent disabled)? +- Startup bug still isnt fixed (find cause / better fix); + Features Intended: - Activator Gesture to launch window diff --git a/widgets/Reachability/RAWidgetSectionManager.mm b/widgets/Reachability/RAWidgetSectionManager.mm index 3ccd599..8cf1f1c 100644 --- a/widgets/Reachability/RAWidgetSectionManager.mm +++ b/widgets/Reachability/RAWidgetSectionManager.mm @@ -108,7 +108,7 @@ -(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIcon } @catch (NSException *ex) { - HBLogError(@"[ReachApp] an error occurred creating the view for section '%@': %@", section.identifier, ex); + LogError(@"[ReachApp] an error occurred creating the view for section '%@': %@", section.identifier, ex); } } From dfc798750ab4e75231f50214e6ab0438c6e5c640 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 6 Mar 2017 17:56:23 -0600 Subject: [PATCH 36/59] if it ain't broke don't fix it --- Tweak.xm | 6 ++---- update_status | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Tweak.xm b/Tweak.xm index bd13901..0f8e72b 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -30,10 +30,8 @@ void SET_BACKGROUNDED(id settings, BOOL value) #if __has_feature(objc_arc) // stupid ARC... ptrdiff_t bgOffset = ivar_getOffset(class_getInstanceVariable([settings class], "_backgrounded")); - CFTypeRef settingsRef = CFBridgingRetain(settings); - uint8_t *bgPtr = (uint8_t *)settingsRef + bgOffset; - memcpy(bgPtr, &value, sizeof(value)); - CFBridgingRelease(settingsRef); + char *bgPtr = ((char *)(__bridge void *)settings) + bgOffset; + memcpy(bgPtr, &value, sizeof(value)); #else // ARC is off, easy way if (value) diff --git a/update_status b/update_status index 34dd4d5..d57a0b1 100644 --- a/update_status +++ b/update_status @@ -32,7 +32,8 @@ Minor Things to note: - MC works but causes jittery animations; - NCApp disappears on first load - Some say it causes serious lag (probably because logs werent disabled)? -- Startup bug still isnt fixed (find cause / better fix); +- Startup bug still isnt fixed (find cause / better fix) +- General Code Cleanup, feels to messy RN Features Intended: - Activator Gesture to launch window From 97198ca0af5f9ca5ccf1cd75abb1279d39015add Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 6 Mar 2017 20:42:17 -0600 Subject: [PATCH 37/59] Added gesture to create appwindow --- Reachability/Reachability.xm | 4 +- .../ActivatorCreateAppWindow.xm | 53 ++++++++++++++++++ .../ActivatorToggleEditModeListener.xm | 4 +- .../StartMultitaskingGesture.xm | 2 +- WindowedMultitasking/WindowSorterActivator.xm | 4 +- headers.h | 16 ++++++ .../Info.plist | 16 ++++++ .../icon-small.png | Bin 0 -> 920 bytes .../icon-small@2x.png | Bin 0 -> 1837 bytes .../icon-small@3x.png | Bin 0 -> 2928 bytes reachappsettings/WindowedMultitasking.xm | 22 ++++++++ update_status | 12 ++-- 12 files changed, 117 insertions(+), 16 deletions(-) create mode 100644 WindowedMultitasking/ActivatorCreateAppWindow.xm create mode 100644 layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/Info.plist create mode 100644 layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/icon-small.png create mode 100644 layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/icon-small@2x.png create mode 100644 layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/icon-small@3x.png diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 56a20da..3f00802 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -611,10 +611,8 @@ CGFloat startingY = -1; if ([RASettings.sharedInstance showNCInstead]) { - if (ncViewController) { + if (ncViewController) ncViewController.view.frame = (CGRect) { { 0, 0 }, topFrame.size }; - [ncViewController viewDidLoad]; - } } else if (lastBundleIdentifier != nil || [view isKindOfClass:[RAAppSliderProviderView class]]) { diff --git a/WindowedMultitasking/ActivatorCreateAppWindow.xm b/WindowedMultitasking/ActivatorCreateAppWindow.xm new file mode 100644 index 0000000..ec62375 --- /dev/null +++ b/WindowedMultitasking/ActivatorCreateAppWindow.xm @@ -0,0 +1,53 @@ +#import +#import "RABackgrounder.h" +#import "RADesktopManager.h" +#import "RADesktopWindow.h" +#import "RAHostedAppView.h" +#import "RAWindowBar.h" +#import "RAWindowSorter.h" +#import "Multiplexer.h" + +@interface RAActivatorCreateWindowListener : NSObject +@end + +static RAActivatorCreateWindowListener *sharedInstance$RAActivatorCreateWindowListener; + +@implementation RAActivatorCreateWindowListener +- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)levent +{ + SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; + RAIconIndicatorViewInfo indicatorInfo = [[%c(RABackgrounder) sharedInstance] allAggregatedIndicatorInfoForIdentifier:topApp.bundleIdentifier]; + + // Close app + [[%c(RABackgrounder) sharedInstance] temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:topApp andCloseForegroundApp:NO]; + FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; + [deactiveSets setFlag:YES forDeactivationSetting:20]; + [deactiveSets setFlag:NO forDeactivationSetting:2]; + [topApp _setDeactivationSettings:deactiveSets]; + + SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; + [transaction begin]; + + // Open in window + RAWindowBar *windowBar = [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; + if (!RADesktopManager.sharedInstance.lastUsedWindow) + RADesktopManager.sharedInstance.lastUsedWindow = windowBar; + }]; + [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; + + // Pop forced foreground backgrounding + [[%c(RABackgrounder) sharedInstance] queueRemoveTemporaryOverrideForIdentifier:topApp.bundleIdentifier]; + [[%c(RABackgrounder) sharedInstance] removeTemporaryOverrideForIdentifier:topApp.bundleIdentifier]; + [[%c(RABackgrounder) sharedInstance] updateIconIndicatorForIdentifier:topApp.bundleIdentifier withInfo:indicatorInfo]; +} +@end + +%ctor +{ + IF_SPRINGBOARD + { + sharedInstance$RAActivatorCreateWindowListener = [[RAActivatorCreateWindowListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorCreateWindowListener forName:@"com.efrederickson.reachapp.windowedmultitasking.createWindow"]; + } +} diff --git a/WindowedMultitasking/ActivatorToggleEditModeListener.xm b/WindowedMultitasking/ActivatorToggleEditModeListener.xm index b4a68e6..99c688d 100644 --- a/WindowedMultitasking/ActivatorToggleEditModeListener.xm +++ b/WindowedMultitasking/ActivatorToggleEditModeListener.xm @@ -29,9 +29,9 @@ static RAActivatorToggleEditModeListener *sharedInstance; %ctor { - if([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"]) + IF_SPRINGBOARD { sharedInstance = [[RAActivatorToggleEditModeListener alloc] init]; [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"]; } -} \ No newline at end of file +} diff --git a/WindowedMultitasking/StartMultitaskingGesture.xm b/WindowedMultitasking/StartMultitaskingGesture.xm index c623f44..269a78a 100644 --- a/WindowedMultitasking/StartMultitaskingGesture.xm +++ b/WindowedMultitasking/StartMultitaskingGesture.xm @@ -126,7 +126,7 @@ BOOL locationIsInValidArea(CGFloat x) // Open in window RAWindowBar *windowBar = [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; - if (RADesktopManager.sharedInstance.lastUsedWindow == nil) + if (!RADesktopManager.sharedInstance.lastUsedWindow) RADesktopManager.sharedInstance.lastUsedWindow = windowBar; }]; [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; diff --git a/WindowedMultitasking/WindowSorterActivator.xm b/WindowedMultitasking/WindowSorterActivator.xm index 17d5a52..7e3c804 100644 --- a/WindowedMultitasking/WindowSorterActivator.xm +++ b/WindowedMultitasking/WindowSorterActivator.xm @@ -21,11 +21,9 @@ static RAActivatorSortWindowsListener *sharedInstance$RAActivatorSortWindowsList %ctor { - if([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"]) + IF_SPRINGBOARD { sharedInstance$RAActivatorSortWindowsListener = [[RAActivatorSortWindowsListener alloc] init]; [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorSortWindowsListener forName:@"com.efrederickson.reachapp.windowedmultitasking.sortWindows"]; } } - - diff --git a/headers.h b/headers.h index f0189f8..9111c32 100644 --- a/headers.h +++ b/headers.h @@ -426,12 +426,22 @@ typedef struct { @end @interface SBNotificationCenterViewController : UIViewController +@property (nonatomic,readonly) CGRect contentFrame; +-(CGRect)_containerFrame; -(void)_setContainerFrame:(CGRect)arg1 ; -(void)prepareLayoutForDefaultPresentation; -(void)_loadContainerView; -(void)_loadContentView; @end +@interface SBSearchEtceteraLayoutContentView : UIView +@end + +@interface SBSearchEtceteraLayoutView : UIView +@property (getter=_visibleView,nonatomic,retain,readonly) SBSearchEtceteraLayoutContentView * visibleView; +-(id)_visibleView; +@end + @interface SBNotificationCenterController : NSObject +(id) sharedInstance; -(SBNotificationCenterViewController *)viewController; @@ -441,6 +451,12 @@ typedef struct { -(BOOL)isPresentingControllerTransitioning; @end +@interface SBSearchEtceteraIsolatedViewController : UIViewController +@property (nonatomic,retain,readonly) SBSearchEtceteraLayoutView * contentView; +-(SBSearchEtceteraLayoutView *)contentView; ++(id)sharedInstance; +@end + @interface UIStatusBarItem : NSObject -(NSString*)indicatorName; @end diff --git a/layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/Info.plist b/layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/Info.plist new file mode 100644 index 0000000..7d88b9b --- /dev/null +++ b/layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/Info.plist @@ -0,0 +1,16 @@ + + + + + compatible-modes + + springboard + application + lockscreen + + description + Create window for currently open app. + title + Create Window + + diff --git a/layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/icon-small.png b/layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/icon-small.png new file mode 100644 index 0000000000000000000000000000000000000000..1c8a8255ec9b5f8a14fc666ce1b11f357c8e231a GIT binary patch literal 920 zcmV;J184k+P)Px&Qb|NXR7efIR^Lk$Q561WoK;sdf+Q0%DzeD%biTO^v+Ulx&LVc$<<6aZ&iCDO z&pCIFg)H&T9XW>5SPz`o4%l`amSq9_af~RQ=K=i5=(;H^r@vw;-DCAXeh?t|V4_lj zuJ#d>R~#scAV67ZI)0W$G1;>p zXlVuN8X-2Jh3f*7pMjBK;Qd(m-t;6@;j9=-denIVXxOcX;Rfn=s{fY{z`#v)0(xz~ z{KTR_36k*aH8Wu@FgHeh+8M=yUC>i{SiRY3u3ex$?Mx!clogyDEymDvq&cd2Q`*tq zAZF5*HoXZG=glkN>7W`p*9nu(AbL`kMO{O_2?=grSA@TRs*!UYF|(XF8gVr5R2^oQ zMWFO9A$2(oToj_Ra^UYGaHAU-9|iU`2U=>RJ?mLh!+KI?-{OM&Qz4KO17;?H?Yk5q zS4hnH^n{B4ayry6j~laCPs*ES>^U%eCj{A04IJ)JaioWVr{6xR_kCA^U$dcp>uF=X z>PdOE)ocj?_(Z^1sVX5JDLo`1OC%>0w%^O-f(G-u{Qwg}M;z#6kJO`=v@?l($Stq? zlncu?-};PC$9Z7tJMiKmkV@vm#Vdh>M}gXUV6e}awZ5U}3hCvJ4D1r~F$WZkanm75 zBB@2zE0csb4zrZmn|N06NCOzS8Q1bIot&5MLADxER@*r&r<0D~mpZY%5h<02hEj-x zA$_pTMz~-yMM8?G#BPv{H`TrW-1n*klFnPQGO=bJ(?jBuN5m%;cQfp~*$B(mWnAK% uWR^kFyXcLOfOfPe4)Fxn@9c$#r2haK6g~UOUCOcm0000Px*=Sf6CRA>d|TWf3-RTTbax@8L#XrWk?hf%?xK%|l=5m960As`wpA`%iYlGrF< zH1NY;Xrlh`hX$jVVARA!#aH43tdAHBVl)9MqEdmV6u}@0EmUc{-5t+2w?n(H**!D6 zp{ysFo!$F7=ey_LbI(2Zu7w=r+<)U}*aPoHd1Nl^vT?BODtRhk*|t=*U|FUG%lnd} zL2b6?JW5~p9bUi{*)U(-EOrWbJTgM zel?=eCR9|6OD%X#{qE>!L1*VwYs2Ofp4^;gy;KSyiH3?ImOgX_sIzk6mUCW{eSi^* zI|X~vT%fMu88moq-*P4KUF?jDO~4q9(z^C{%NnHTiHX>REO(t8R(q%l*sjN8l1leeyt;_%))f>Xg|moy|k1r=HG?rzIjdskevdd6{3R8KBi zI|f*?65zWKbo6)NjpqQq!%`xVAiyMlH&C0GT?sTiRydFpf*r;-*>-rcY%#y#nz?2U zuxltD>)kBDxambyBCPu~W1eFgm6ZfXyz1nRB@W-kH; zD3>P6uw$!A3LQ{7==5DRbof``_4UBVZHf^-_K9;s+rigLIT2mv*$ zOV-*YlYq%r0UIQpWmuMuLB7OopMrE69irIL(b#ZKl4j0J25C}F8uLgjt1(bYgQx?l zY5bp)y@tncUVC|*v#gUZX=IT$bwigz#N)uB1ODQSsP)hH%jJGF)o`VjA3HuZCFgG) zPzpg8?4>6R;B3ubw*Z*47~m2@O)+}FIhl!=M`GE*LxILOfo+>jTBc9V_s3r`VVF$$ zS<-Yvmy133=)-epjKZ@V*Gba0EdZC9RAL(QNOdz!9S^ukP5&Hzo+-ypSCCGlCytq> zYeoUbj$~(Z+WLVE`zOuA?;c2&VcAVmCl`@7gK3mSK{}xH zM5u`=)6MYlW7KwB1b-eFc>%EcDPYE2GY`EwoRdsr-bm3B%bt`ve#Gf8!?9WeRT6^-O5n}9DNqV51 zAB?-+vBGSEcWlj%B?09NDpQNxaMSUBcVnOcw{DJl0x-DDcq`Y+p~Jn@;=Rd(yvUQh z15hxajG!~P%w5DiYxMg`jiB7Ck_UN_XTa#a?VcZM7<*;eyR?*}#sW)M2MTX^O=W#E zWWu(|gS>)9?d6O#m_|Lx=nQ=Hnz6tQ>&%InmlyWUZ5Z36r6mvY3PC)3Nr;&jlNN%w z+%WFSQ!p+Sd%g|Pm{jFjdFygBN~p<@AZ7dK6!4HqhS!n@O&F9u>?fN5uA>^F_Goly zT{%n(c*s=TW5d?JjW(KhiQtDM`qw6#>$rh#mjOeDNykVBO{_CcNYx0lP8Q|Z@R9mc zV$mu!9iOvowu4|=Om5pqbOF7nd$A9KV_oeL_m-qMR)%|lJ~>zENbvEF_8D(tD8`En z(8J-jk2|7bAMMLcPys4eL4h#^f|%Y6o$p*eaeA%7rU*vcz3*DsX8T`ja;MkkrQX0! zL;r)6E)g$O2}aw!xy(zwrAmU07>#EnH)CR1x#X0}+t@u<&y!p~ z=b_sVmdu@9xrJ>#``(3~@{*l;xt~X!=c;*M7)cuSGD`l>10GPm{}+D;NdjCV bfAIMa#&v*s<|_QQ00000NkvXXu0mjfWmRzs literal 0 HcmV?d00001 diff --git a/layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/icon-small@3x.png b/layout/Library/Activator/Listeners/com.efrederickson.reachapp.windowedmultitasking.createWindow/icon-small@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..42b36d2c02e107a98c3edfe1774388a7ab397be7 GIT binary patch literal 2928 zcmV-$3y<`PP)Px=DoI2^RCodHU2BjP#TEYM?q!$P0)hgrfEz>u8Xp)_1eMZFbb}BdREf`sWhEu# zN0Krz`H>%q`Jbv(Dlhd<3W>4QRK=)3iKf89h@?m;5}$~IfCxSiSYEq(_fF0?eS7cR z**kYC@lzobGeFd)h&r1taidXD&(S33wdJ6YBe^~wgV6qPil>5DJuEeOZ_sDBM zXxzav`@gwgl-hja=ql$o&)-|COre0eOXrWmv?*KAGWx<=3{LBN-N)a=-UC-SPj5O= z4Tq}Wy7za^#@KP2(cC<)TB0n>hd@uy5ga`-&v|s++rCimbO5+sjh%kZ{tVb4R5h*% z@SYE+25WF`KoY8gti}$2rDg!}B5nby0M~20G94R$DB`8y=Hcgy-mezC?pAB-j;vSU zLnrPjdl6k-vuro5Tyxov&AMB0;jD~L{D@1=r=1=OFOI1*1G11^098R;QV!qf4*TWu4&P75cD9(=Vq(b==_U~8`AHtg>; z)J~P%jf4Q*t>TW&NsaA@lpu=~4*|iIPVE`-Ql%WbxdmvS4a_(nnA`@OITaWqE{>Lw zzzDh5+YNF10mqI2pY8`f-UsY{7uY4HeUIE5E+n|-y%B^)3)C_SxLDfMxmN?{UH~*T zg-gV^{Ea&UIQ!gkyuLo*gYCf9SAhR+mIqMPQB{tg_L+>#IPMQ`J=`!~!pPCUwKoA* zenVbBW z>z@HOy$JLb(#xkB=R$9{r@5skH>~4kVA+p`7FgoL2g!Vy|4@flKG7ol`h} zj_P;b227a_{N)j#&>J3C=MLu=q>Sy@@xZ+g0@G&dh@6xQAMm6pz{+0&M-M0E7M@;k zExR1Uqt$1*q(qYO4AHa@sQ+`F#1(!~kG<^k%1s}kQa#Maq(gT-nKzg@MWup8nhZ5;& zar$F5-G;V+`}Y`!3mxOfyX4JiH4b#P@KeQ<)g;Q#a%|b4!c`AkI=VH9qYG>PY#iX# z_`dL@ajY-8TShHrRf|zy7|Wpqu8vyZ&LyT$zsPHAtyEI%q1x~`?bfZ1*0iPX+SCk7cmwu(BrR8NQ z?%0+;zU9*+Q=Z=Zx8)e^$Twj6d1lH~v=lXC>43|rLj?CNDGVoJ#G&u}6gcl9W767m zd_e4OMNtim=YOEKG1|QYc=C6aW3=PfWReQO21f(f zkBvgXc$UwHJENqoj5Dd!>#^mjyc_#U2VC2TSmEM`!AWx@I$``KG+X_RYs|f{|Bb6F z4GE^V&YW$V!cv8Y+sa|f6CN|t9UX8vjgw@BGgs06S;K7YrBUD?9-`I7`2~FS{lsgA z`;7*sqtQX4?*Hfma~|ja%(G2wTb?*+tHjmOxinizW28|UKM^>5&|F9Te|{CP{Ab2= zB|!8QSYi$4kBtp`1#GS%Vo)Kp8IxENd*|Gacz4YmJY>Tt)x4(*RfwmPdhfz~zi?7Myh1 zmF5`tpSAV%f0|STYQ@hhb#OI))UhibDg#UX?N=4m(u9RsxmgaS8R|M}fdX?z_sls! zTRU)88}La<4~G>d7|z%EiQgJ$%vB4GiXgyIMC_&<0qI$*!ARd%Cpp24kgk9 zm$ioD|Fmu{UjT5VATAZ%n=KYZ^SrhC`XL}P8<`y(qO*- zmN8m(yk1`(HWk-aP+k({S6oY>2QG!<8icQOm{xb;oxoGSXK4LI;F5wjSnfB7oHV~V z#h>ykl1_tW1>)ikYyQr?YVZchrfbxZ4dP`YCy8<^FHX?~mqK!J2iG8wQksKhm?!+V zbK1y;@=|VP(g&BTX1KV6t$$m4>T_W0#$)LUBOm3YyeX{q(Fd2MrA77P)27_)KXNU? za3acMjRwj|c~hXA)G&E;DbV`A0oHlKNp4qMn?fdau%sMzvLNN7oN18YnoiBN!gAG& zb;>OHw&|wXdyP16gYT+HgUEf!m(GnRK&Y)qw%%5^l z9?F&Saw*6C$sNViKO7WXhjw5u@c6Ieo5+#T^hKm8e)kV#{n<1VNL4Tt>(Jy&O$4`3 zz)iOX+p<#EaSZ}JS@b^r>t*2Ye>E1DjiYs>Mfde3z?ZKvQ?1yvu<=Su#|Gst7K@Ev z`%8QNwU>aGpEKW32nreZnj^>5tzW&aJf*ckYkwQKYF+Gk)?_;qy;u~tyU8(@kp@v zFj^;=k6G|Yof;fo8aCfscwos+nX2Ai^C_f#lQUeRekmkOmf`lLknR(^^4`bKWkzb4 z%tI1RH{X^G=ErUm=lgP6YQ;BhlgD^KG&a-J_3Skj{6`8!0GrG^hG{3I1*36HRo+G!F>=i z(nCP-B(BCX;|3EM=^;?U(|{{GcYxo0%_unn#F2OkdEk0mqHyPqjFKZDINB{{$_^XZ z5=HvFS?x^%FYzOeCF%#)`-r)0iDGYL$2t(;mNLFQd&KuwN$vx;ype4gQ;A8WE7?lM z`PDNQ`Q!H2-2On>YX;o0BctdD5HI2upaI}|TcF5ZGa0}Eq{1!fwP1N< zyGmIkY8>m?Rm#sU+Yil;M(Lcrf+YK)`B`Q=`B_kvck-(MIopF$e-BDO!1g@bJ=G!+ ae*7PN!N_ylpgcDK0000 Date: Thu, 9 Mar 2017 22:54:18 -0600 Subject: [PATCH 38/59] coding style changes + fbdisplaymanager --- Backgrounding/IconIndicator.xm | 14 +++++------ Backgrounding/RABackgrounder.xm | 12 +++++----- .../SpringBoard_UIAppCustomBackgroundModes.xm | 6 ++--- Backgrounding/UnlimitedBackgrounding.xm | 2 +- DRM/Statistics.xm | 2 +- Debugging/Core.xm | 2 -- GestureSupport/Hooks_iOS9.xm | 2 +- GestureSupport/RAGestureManager.h | 2 +- GestureSupport/RAGestureManager.xm | 12 +++++----- KeyboardSupport/RAKeyboardStateListener.xm | 4 ++-- KeyboardSupport/RARemoteKeyboardView.xm | 4 ++-- .../RASpringBoardKeyboardActivation.xm | 2 +- Makefile | 4 ++-- Messaging/RAMessagingClient.xm | 16 ++++++------- Messaging/RAMessagingServer.xm | 23 +++++++++++-------- MissionControl/AppSwitcher.xm | 2 +- MissionControl/RAMissionControlWindow.xm | 4 ++-- Multiplexer.xm | 2 +- NotificationCenterApp/NCHook.xm | 4 ++-- RAAppKiller.xm | 6 ++--- RAAppSelectorView.xm | 2 +- RAAppSliderProvider.mm | 8 +++---- RALocalizer.h | 4 ++-- RALocalizer.mm | 2 +- RARunningAppsProvider.xm | 10 ++++---- RASettings.mm | 4 ++-- RASnapshotProvider.h | 4 ++-- RASnapshotProvider.xm | 4 ++-- Reachability/RAReachabilityManager.h | 4 ++-- Reachability/RAReachabilityManager.mm | 4 ++-- Reachability/Reachability.xm | 14 +++++------ SwipeOver/RASwipeOverManager.h | 2 +- SwipeOver/RASwipeOverManager.xm | 14 +++++------ SwipeOver/RASwipeOverOverlay.xm | 2 +- SwipeOver/SwipeOverGesture.xm | 2 +- UIKit.xm | 12 +++++----- WindowedMultitasking/RADesktopManager.xm | 2 +- WindowedMultitasking/RADesktopWindow.mm | 4 ++-- .../RAWindowSnapDataProvider.h | 4 ++-- .../RAWindowStatePreservationSystemManager.h | 12 +++++----- .../RAWindowStatePreservationSystemManager.xm | 4 ++-- headers.h | 7 +++++- reachappfsdaemon/main.mm | 2 +- update_status | 3 +++ widgets/Core/RAWidgetHostManager.h | 4 ++-- widgets/Core/RAWidgetHostManager.xm | 4 ++-- .../Reachability/RAWidgetSectionManager.mm | 4 ++-- 47 files changed, 139 insertions(+), 128 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 14516f8..1156ca9 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -63,8 +63,8 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) if ( [self RA_isIconIndicatorInhibited] || - (text == nil || text.length == 0) || // OR info == RAIconIndicatorViewInfoNone - (self.icon == nil || self.icon.application == nil || self.icon.application.isRunning == NO || ![RABackgrounder.sharedInstance shouldShowIndicatorForIdentifier:self.icon.application.bundleIdentifier]) || + (!text || text.length == 0) || // OR info == RAIconIndicatorViewInfoNone + (!self.icon || !self.icon.application || !self.icon.application.isRunning || ![RABackgrounder.sharedInstance shouldShowIndicatorForIdentifier:self.icon.application.bundleIdentifier]) || [[%c(RASettings) sharedInstance] backgrounderEnabled] == NO) { [[self viewWithTag:9962] removeFromSuperview]; @@ -174,7 +174,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) %new -(void) RA_setIsIconIndicatorInhibited:(BOOL)value showAgainImmediately:(BOOL)value2 { objc_setAssociatedObject(self, @selector(RA_isIconIndicatorInhibited), value ? (id)kCFBooleanTrue : (id)kCFBooleanFalse, OBJC_ASSOCIATION_ASSIGN); - if (value2 || value == YES) + if (value2 || value) [self RA_updateIndicatorViewWithExistingInfo]; } @@ -274,12 +274,12 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) */ %new -(void) RA_addStatusBarIconForSelfIfOneDoesNotExist { - if (objc_getClass("LSStatusBarItem") && [lsbitems objectForKey:self.bundleIdentifier] == nil && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) { + if (objc_getClass("LSStatusBarItem") && ![lsbitems objectForKey:self.bundleIdentifier] && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) { if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { if ([[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]) { RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; BOOL native = (info & RAIconIndicatorViewInfoNative); - if ((info & RAIconIndicatorViewInfoNone) == 0 && (native == NO || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { + if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; if ([item customViewClass] == nil) { item.customViewClass = @"RAAppIconStatusBarIconView"; @@ -292,7 +292,7 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) if ([[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]) { RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; BOOL native = (info & RAIconIndicatorViewInfoNative); - if ((info & RAIconIndicatorViewInfoNone) == 0 && (native == NO || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { + if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; if ([item customViewClass] == nil) { item.customViewClass = @"RAAppIconStatusBarIconView"; @@ -309,7 +309,7 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) { %orig; - if (self.isRunning == NO) + if (!self.isRunning) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:RAIconIndicatorViewInfoNone]; //SET_INFO_(self.bundleIdentifier, RAIconIndicatorViewInfoNone); diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index 80f0a81..19be29f 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -36,7 +36,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; - return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && ([dict objectForKey:@"autoLaunch"] == nil ? NO : [dict[@"autoLaunch"] boolValue]); + return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && (![dict objectForKey:@"autoLaunch"] ? NO : [dict[@"autoLaunch"] boolValue]); } -(BOOL) shouldAutoRelaunchApplication:(NSString*)identifier @@ -45,7 +45,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; - return [self killProcessOnExit:identifier] == NO && [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && ([dict objectForKey:@"autoRelaunch"] == nil ? NO : [dict[@"autoRelaunch"] boolValue]); + return ![self killProcessOnExit:identifier] && [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && (![dict objectForKey:@"autoRelaunch"] ? NO : [dict[@"autoRelaunch"] boolValue]); } -(NSInteger) popTemporaryOverrideForApplication:(NSString*)identifier @@ -103,7 +103,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; - return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && ([dict objectForKey:@"preventDeath"] == nil ? NO : [dict[@"preventDeath"] boolValue]); + return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && (![dict objectForKey:@"preventDeath"] ? NO : [dict[@"preventDeath"] boolValue]); } -(BOOL) shouldRemoveFromSwitcherWhenKilledOnExit:(NSString*)identifier @@ -112,7 +112,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"removeFromSwitcher"] ? [dict[@"removeFromSwitcher"] boolValue] : NO; - return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && ([dict objectForKey:@"removeFromSwitcher"] == nil ? NO : [dict[@"removeFromSwitcher"] boolValue]); + return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && (![dict objectForKey:@"removeFromSwitcher"] ? NO : [dict[@"removeFromSwitcher"] boolValue]); } -(NSInteger) backgroundModeForIdentifier:(NSString*)identifier @@ -223,13 +223,13 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; { NSDictionary *dct = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL globalSetting = [[%c(RASettings) sharedInstance] shouldShowIconIndicatorsGlobally]; - return globalSetting ? ([dct objectForKey:@"showIndicatorOnIcon"] == nil ? YES : [dct[@"showIndicatorOnIcon"] boolValue]) : NO; + return globalSetting ? (![dct objectForKey:@"showIndicatorOnIcon"] ? YES : [dct[@"showIndicatorOnIcon"] boolValue]) : NO; } -(BOOL) shouldShowStatusBarIconForIdentifier:(NSString*)identifier { NSDictionary *dct = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL globalSetting = [[%c(RASettings) sharedInstance] shouldShowStatusBarIcons]; - return globalSetting ? ([dct objectForKey:@"showStatusBarIcon"] == nil ? YES : [dct[@"showStatusBarIcon"] boolValue]) : NO; + return globalSetting ? (![dct objectForKey:@"showStatusBarIcon"] ? YES : [dct[@"showStatusBarIcon"] boolValue]) : NO; } @end diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index 32537d3..c75ded9 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -22,9 +22,9 @@ %hook BKSProcessAssertion - (id)initWithPID:(int)arg1 flags:(unsigned int)arg2 reason:(unsigned int)arg3 name:(unsafe_id)arg4 withHandler:(unsafe_id)arg5 { - if ((arg3 == kProcessAssertionReasonViewServices) == NO && // whitelist this to allow share menu to work - [arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] == NO && // whitelist iCleaner to prevent crash on open - [arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"] == NO && // Whitelist filza to prevent iOS hang (?!) + if (!(arg3 == kProcessAssertionReasonViewServices) && // whitelist this to allow share menu to work + ![arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] && // whitelist iCleaner to prevent crash on open + ![arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"] && // Whitelist filza to prevent iOS hang (?!) !IS_SPRINGBOARD) // FIXME: this is a hack that prevents SpringBoard from not starting { NSString *identifier = [NSBundle mainBundle].bundleIdentifier; diff --git a/Backgrounding/UnlimitedBackgrounding.xm b/Backgrounding/UnlimitedBackgrounding.xm index 6dd27bc..4037033 100644 --- a/Backgrounding/UnlimitedBackgrounding.xm +++ b/Backgrounding/UnlimitedBackgrounding.xm @@ -8,7 +8,7 @@ BKSProcessAssertion *keepAlive$temp; %hook FBUIApplicationWorkspaceScene -(void) host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 { - if ([RABackgrounder.sharedInstance hasUnlimitedBackgroundTime:arg1.identifier] && arg2.backgrounded == YES && [processAssertions objectForKey:arg1.identifier] == nil) + if ([RABackgrounder.sharedInstance hasUnlimitedBackgroundTime:arg1.identifier] && arg2.backgrounded && ![processAssertions objectForKey:arg1.identifier]) { SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:arg1.identifier]; diff --git a/DRM/Statistics.xm b/DRM/Statistics.xm index 925577c..cb2fe9e 100644 --- a/DRM/Statistics.xm +++ b/DRM/Statistics.xm @@ -20,7 +20,7 @@ [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; int code = [httpResponse statusCode]; - if (error == nil && (code == 0 || code == 200)) + if (!error && (code == 0 || code == 200)) { [NSFileManager.defaultManager createFileAtPath:statsPath contents:[NSData new] attributes:nil]; } diff --git a/Debugging/Core.xm b/Debugging/Core.xm index 8d78ea2..317844e 100644 --- a/Debugging/Core.xm +++ b/Debugging/Core.xm @@ -9,7 +9,6 @@ %hook NSObject - (void)doesNotRecognizeSelector:(SEL)selector { -#if DEBUG LogDebug(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); NSArray * symbols = [NSThread callStackSymbols]; @@ -18,7 +17,6 @@ { LogDebug(@"[ReachApp] %@\n", symbol); } -#endif %orig; } diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index 095d518..bc39adc 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -65,7 +65,7 @@ typedef struct { @end @implementation Hooks9$SBHandMotionExtractorReplacementByMultiplexer --(id) init +-(instancetype) init { if (self = [super init]) { diff --git a/GestureSupport/RAGestureManager.h b/GestureSupport/RAGestureManager.h index dca67cd..52db0cd 100644 --- a/GestureSupport/RAGestureManager.h +++ b/GestureSupport/RAGestureManager.h @@ -26,7 +26,7 @@ const NSUInteger RAGesturePriorityDefault = RAGesturePriorityLow; NSMutableArray *gestures; NSMutableDictionary *ignoredAreas; } -+(id) sharedInstance; ++(instancetype) sharedInstance; -(void) addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority; -(void) addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier; diff --git a/GestureSupport/RAGestureManager.xm b/GestureSupport/RAGestureManager.xm index 5744a71..af6c9ad 100644 --- a/GestureSupport/RAGestureManager.xm +++ b/GestureSupport/RAGestureManager.xm @@ -4,10 +4,10 @@ #import "RAGestureCallback.h" @implementation RAGestureManager -+(id) sharedInstance ++(instancetype) sharedInstance { - SHARED_INSTANCE2(RAGestureManager, - sharedInstance->gestures = [NSMutableArray array]; + SHARED_INSTANCE2(RAGestureManager, + sharedInstance->gestures = [NSMutableArray array]; sharedInstance->ignoredAreas = [NSMutableDictionary dictionary]; ); } @@ -41,7 +41,7 @@ if (!found) { [gestures addObject:callback]; - [self sortGestureRecognizers]; + [self sortGestureRecognizers]; } } @@ -119,7 +119,7 @@ -(BOOL) handleMovementOrStateUpdate:(UIGestureRecognizerState)state withPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { // If we don't do this check here, but in canHandleMovementWithPoint:forEdge:, the recognizer hooks will not begin tracking the swipe - // This is an issue if someone calls stopIgnoringSwipesForIdentifier: while a swipe is going on. + // This is an issue if someone calls stopIgnoringSwipesForIdentifier: while a swipe is going on. /*for (NSString *key in ignoredAreas.allKeys) { NSValue *value = ignoredAreas[key]; @@ -154,7 +154,7 @@ isThisCallbackCapable = YES; if (isThisCallbackCapable) - { + { if (callback.callbackBlock) { RAGestureCallbackResult result = callback.callbackBlock(state, point, velocity); diff --git a/KeyboardSupport/RAKeyboardStateListener.xm b/KeyboardSupport/RAKeyboardStateListener.xm index 8e400bd..97bf499 100644 --- a/KeyboardSupport/RAKeyboardStateListener.xm +++ b/KeyboardSupport/RAKeyboardStateListener.xm @@ -50,7 +50,7 @@ BOOL isShowing = NO; } } -- (id)init +- (instancetype)init { if ((self = [super init])) { @@ -85,7 +85,7 @@ void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFS void (^block)() = ^{ IF_NOT_SPRINGBOARD { unsigned int contextID = 0; - if (objc_getClass("UIRemoteKeyboardWindow") != nil && [UIKeyboard activeKeyboard] && [[UIKeyboard activeKeyboard] window]) + if (%c(UIRemoteKeyboardWindow) && [UIKeyboard activeKeyboard] && [[UIKeyboard activeKeyboard] window]) contextID = [[[UIKeyboard activeKeyboard] window] _contextId]; // ((UITextEffectsWindow*)[%c(UIRemoteKeyboardWindow) remoteKeyboardWindowForScreen:UIScreen.mainScreen create:NO])._contextId; else contextID = UITextEffectsWindow.sharedTextEffectsWindow._contextId; diff --git a/KeyboardSupport/RARemoteKeyboardView.xm b/KeyboardSupport/RARemoteKeyboardView.xm index 1a67711..5c28a6c 100644 --- a/KeyboardSupport/RARemoteKeyboardView.xm +++ b/KeyboardSupport/RARemoteKeyboardView.xm @@ -26,7 +26,7 @@ self.layerHost.contextId = value; LogDebug(@"[ReachApp] loaded keyboard view with %d", value); - if (value == 0 && cancelFetchingContextId == NO) + if (value == 0 && !cancelFetchingContextId) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self connectToKeyboardWindowForApp:identifier]; @@ -34,7 +34,7 @@ } } --(id)initWithFrame:(CGRect)frame +-(instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) diff --git a/KeyboardSupport/RASpringBoardKeyboardActivation.xm b/KeyboardSupport/RASpringBoardKeyboardActivation.xm index 6794038..31746d7 100644 --- a/KeyboardSupport/RASpringBoardKeyboardActivation.xm +++ b/KeyboardSupport/RASpringBoardKeyboardActivation.xm @@ -10,7 +10,7 @@ extern BOOL overrideDisableForStatusBar; RAKeyboardWindow *keyboardWindow; @implementation RASpringBoardKeyboardActivation -+(id) sharedInstance ++(instancetype) sharedInstance { SHARED_INSTANCE2(RASpringBoardKeyboardActivation, [RARunningAppsProvider.sharedInstance addTarget:self] diff --git a/Makefile b/Makefile index 9f92595..b84b910 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ -Wno-deprecated-declarations -CFLAGS += -fobjc-arc -O2 +CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ -Wno-deprecated-declarations -O2 +CFLAGS += -fobjc-arc TARGET = iphone:9.2 include $(THEOS)/makefiles/common.mk diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 530e6c3..636809d 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -85,7 +85,7 @@ extern BOOL allowClosingReachabilityNatively; IS_PROCESS("backboardd") // Backboardd uses its own messaging center for what it does. )*/ - if (allowedProcess == NO) + if (!allowedProcess) { // Anything that's not a UIApp (system app or user app) doesn't need this messaging client // Attempting to reach out will either: @@ -98,7 +98,7 @@ extern BOOL allowClosingReachabilityNatively; NSDictionary *dict = @{ @"bundleIdentifier": NSBundle.mainBundle.bundleIdentifier }; NSDictionary *data = [serverCenter sendMessageAndReceiveReplyName:RAMessagingUpdateAppInfoMessageName userInfo:dict]; - if (data && [data objectForKey:@"data"] != nil) + if (data && [data objectForKey:@"data"]) { RAMessageAppData actualData; [data[@"data"] getBytes:&actualData length:sizeof(actualData)]; @@ -130,17 +130,17 @@ extern BOOL allowClosingReachabilityNatively; /* THE REAL IMPORTANT BIT */ _currentData = data; - if (didStatusBarVisibilityChange && data.shouldForceStatusBar == NO) + if (didStatusBarVisibilityChange && !data.shouldForceStatusBar) [UIApplication.sharedApplication RA_forceStatusBarVisibility:_currentData.statusBarVisibility orRevert:YES]; else if (data.shouldForceStatusBar) [UIApplication.sharedApplication RA_forceStatusBarVisibility:_currentData.statusBarVisibility orRevert:NO]; - if (didSizingChange && data.shouldForceSize == NO) + if (didSizingChange && !data.shouldForceSize) [UIApplication.sharedApplication RA_updateWindowsForSizeChange:CGSizeMake(data.wantedClientWidth, data.wantedClientHeight) isReverting:YES]; else if (data.shouldForceSize) [UIApplication.sharedApplication RA_updateWindowsForSizeChange:CGSizeMake(data.wantedClientWidth, data.wantedClientHeight) isReverting:NO]; - if (didOrientationChange && data.shouldForceOrientation == NO) + if (didOrientationChange && !data.shouldForceOrientation) [UIApplication.sharedApplication RA_forceRotationToInterfaceOrientation:data.forcedOrientation isReverting:YES]; else if (data.shouldForceOrientation) [UIApplication.sharedApplication RA_forceRotationToInterfaceOrientation:data.forcedOrientation isReverting:NO]; @@ -186,15 +186,15 @@ extern BOOL allowClosingReachabilityNatively; if (!ident) return; - if ([self isBeingHosted] && (self.knownFrontmostApp == nil || [self.knownFrontmostApp isEqual:ident] == NO)) + if ([self isBeingHosted] && (!self.knownFrontmostApp || ![self.knownFrontmostApp isEqual:ident])) [serverCenter sendMessageName:RAMessagingChangeFrontMostAppMessageName userInfo:@{ @"bundleIdentifier": ident }]; } -(BOOL) shouldUseExternalKeyboard { return _currentData.shouldUseExternalKeyboard; } -(BOOL) shouldResize { return _currentData.shouldForceSize; } -(CGSize) resizeSize { return CGSizeMake(_currentData.wantedClientWidth, _currentData.wantedClientHeight); } --(BOOL) shouldHideStatusBar { return _currentData.shouldForceStatusBar && _currentData.statusBarVisibility == NO; } --(BOOL) shouldShowStatusBar { return _currentData.shouldForceStatusBar && _currentData.statusBarVisibility == YES; } +-(BOOL) shouldHideStatusBar { return _currentData.shouldForceStatusBar && !_currentData.statusBarVisibility; } +-(BOOL) shouldShowStatusBar { return _currentData.shouldForceStatusBar && _currentData.statusBarVisibility; } -(UIInterfaceOrientation) forcedOrientation { return _currentData.forcedOrientation; } -(BOOL) shouldForceOrientation { return _currentData.shouldForceOrientation; } -(BOOL) isBeingHosted { return _currentData.isBeingHosted; } diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index 2c1a799..1ed4050 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -89,7 +89,7 @@ extern BOOL launchNextOpenIntoWindow; NSString *identifier = info[@"bundleIdentifier"]; RAMessageAppData data = [self getDataForIdentifier:identifier]; - if ([waitingCompletions objectForKey:identifier] != nil) + if ([waitingCompletions objectForKey:identifier]) { RAMessageCompletionCallback callback = (RAMessageCompletionCallback)waitingCompletions[identifier]; [waitingCompletions removeObjectForKey:identifier]; @@ -97,7 +97,7 @@ extern BOOL launchNextOpenIntoWindow; } // Got the message, cancel the re-sender - if ([asyncHandles objectForKey:identifier] != nil) + if ([asyncHandles objectForKey:identifier]) { struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; dispatch_after_cancel(handle); @@ -165,6 +165,11 @@ extern BOOL launchNextOpenIntoWindow; } completion:^(BOOL _) { [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; + [deactiveSets setFlag:YES forDeactivationSetting:20]; + [deactiveSets setFlag:NO forDeactivationSetting:2]; + [topApp _setDeactivationSettings:deactiveSets]; + SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; [transaction begin]; }]; @@ -259,10 +264,10 @@ extern BOOL launchNextOpenIntoWindow; -(void) checkIfCompletionStillExitsForIdentifierAndFailIt:(NSString*)identifier { - if ([waitingCompletions objectForKey:identifier] != nil) + if ([waitingCompletions objectForKey:identifier]) { // We timed out, remove the re-sender - if ([asyncHandles objectForKey:identifier] != nil) + if ([asyncHandles objectForKey:identifier]) { struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; dispatch_after_cancel(handle); @@ -281,7 +286,7 @@ extern BOOL launchNextOpenIntoWindow; -(void) sendDataWithCurrentTries:(int)tries toAppWithBundleIdentifier:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; - if (!app.isRunning || [app mainScene] == nil) + if (!app.isRunning || ![app mainScene]) { if (tries > 4) { @@ -291,7 +296,7 @@ extern BOOL launchNextOpenIntoWindow; return; } - if ([asyncHandles objectForKey:identifier] != nil) + if ([asyncHandles objectForKey:identifier]) { struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; dispatch_after_cancel(handle); @@ -309,7 +314,7 @@ extern BOOL launchNextOpenIntoWindow; if (tries <= 4) { - if ([asyncHandles objectForKey:identifier] != nil) + if ([asyncHandles objectForKey:identifier]) { struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; dispatch_after_cancel(handle); @@ -321,7 +326,7 @@ extern BOOL launchNextOpenIntoWindow; }); asyncHandles[identifier] = [NSValue valueWithPointer:handle]; - if ([waitingCompletions objectForKey:identifier] == nil) + if (![waitingCompletions objectForKey:identifier]) { //if (callback == nil) // callback = ^(BOOL _) { }; @@ -501,7 +506,7 @@ extern BOOL launchNextOpenIntoWindow; -(unsigned int) getStoredKeyboardContextIdForApp:(NSString*)identifier { - return [contextIds objectForKey:identifier] != nil ? [contextIds[identifier] unsignedIntValue] : 0; + return [contextIds objectForKey:identifier] ? [contextIds[identifier] unsignedIntValue] : 0; } @end diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index dda5882..a9280f7 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -641,7 +641,7 @@ BOOL toggleOrActivate = NO; [transitionContext setEntity:homescreenEntity forLayoutRole:2]; //create transititon request - SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[[UIScreen mainScreen] valueForKey:@"_fbsDisplay"]]; + SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[%c(FBDisplayManager) mainDisplay]]; [transitionRequest setApplicationContext:transitionContext]; //create apptoapp transaction diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index 538e718..6ecfa00 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -30,7 +30,7 @@ @end @implementation RAMissionControlWindow --(id) initWithFrame:(CGRect)frame +-(instancetype) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { @@ -178,7 +178,7 @@ for (SBApplication *app in runningApplications) { - if ([visibleIcons containsObject:app.bundleIdentifier] == NO)// || [RAMissionControlManager.sharedInstance.inhibitedApplications containsObject:app.bundleIdentifier]) + if (![visibleIcons containsObject:app.bundleIdentifier])// || [RAMissionControlManager.sharedInstance.inhibitedApplications containsObject:app.bundleIdentifier]) [appsWithoutWindows removeObject:app]; } diff --git a/Multiplexer.xm b/Multiplexer.xm index 88a505d..9fef4ba 100644 --- a/Multiplexer.xm +++ b/Multiplexer.xm @@ -50,7 +50,7 @@ [transitionContext setAnimationDisabled:YES]; //create transititon request - SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[UIScreen.mainScreen valueForKey:@"_fbsDisplay"]]; + SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[%c(FBDisplayManager) mainDisplay]]; [transitionRequest setApplicationContext:transitionContext]; return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithTransitionRequest:transitionRequest]; diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index c370a60..ac7719b 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -36,7 +36,7 @@ BOOL shouldLoadView = NO; if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) { SBModeViewController* modeVC = MSHookIvar(self, "_modeController"); - if (ncAppViewController == nil) + if (!ncAppViewController) ncAppViewController = [self _newBulletinObserverViewControllerOfClass:[RANCViewController class]]; [modeVC _addBulletinObserverViewController:ncAppViewController]; } @@ -68,7 +68,7 @@ BOOL shouldLoadView = NO; if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) { SBModeViewController* modeVC = MSHookIvar(self, "_modeViewController"); - if (ncAppViewController == nil) + if (!ncAppViewController) ncAppViewController = [[RANCViewController alloc] init]; [modeVC _addBulletinObserverViewController:ncAppViewController]; } diff --git a/RAAppKiller.xm b/RAAppKiller.xm index 10ec13c..89333a9 100644 --- a/RAAppKiller.xm +++ b/RAAppKiller.xm @@ -11,7 +11,7 @@ extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSStrin @implementation RAAppKiller : NSObject +(instancetype) sharedInstance { - SHARED_INSTANCE2(RAAppKiller, + SHARED_INSTANCE2(RAAppKiller, [sharedInstance initialize]; ); } @@ -47,7 +47,7 @@ extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSStrin handler(); } } - else + else { if (tries == 0) { @@ -86,7 +86,7 @@ extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSStrin -(void) appDidDie:(__unsafe_unretained SBApplication*)app { - if (completionDictionary && [completionDictionary objectForKey:app.bundleIdentifier] != nil) + if (completionDictionary && [completionDictionary objectForKey:app.bundleIdentifier]) { dispatch_block_t block = completionDictionary[app.bundleIdentifier]; block(); diff --git a/RAAppSelectorView.xm b/RAAppSelectorView.xm index beaec8e..53fd6e9 100644 --- a/RAAppSelectorView.xm +++ b/RAAppSelectorView.xm @@ -1,7 +1,7 @@ #import "RAAppSelectorView.h" @implementation RAAppSelectorView --(id) initWithFrame:(CGRect)frame +-(instancetype) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { diff --git a/RAAppSliderProvider.mm b/RAAppSliderProvider.mm index efd9dfc..07d2f14 100644 --- a/RAAppSliderProvider.mm +++ b/RAAppSliderProvider.mm @@ -9,7 +9,7 @@ @interface RAAppSliderProvider () { @implementation RAAppSliderProvider @synthesize currentIndex, availableIdentifiers; --(id) init +-(instancetype) init { if (self = [super init]) { @@ -33,7 +33,7 @@ -(RAHostedAppView*) viewToTheLeft if (self.canGoLeft) { NSString *ident = [availableIdentifiers objectAtIndex:currentIndex - 1]; - + if (!ident) return nil; if ([cachedViews objectForKey:ident]) return cachedViews[ident]; @@ -50,7 +50,7 @@ -(RAHostedAppView*) viewToTheRight if (self.canGoRight) { NSString *ident = [availableIdentifiers objectAtIndex:currentIndex + 1]; - + if (!ident) return nil; if ([cachedViews objectForKey:ident]) return cachedViews[ident]; @@ -65,7 +65,7 @@ -(RAHostedAppView*) viewToTheRight -(RAHostedAppView*) viewAtCurrentIndex { NSString *ident = [availableIdentifiers objectAtIndex:currentIndex]; - + if (!ident) return nil; if ([cachedViews objectForKey:ident]) return cachedViews[ident]; diff --git a/RALocalizer.h b/RALocalizer.h index 989bbd8..0dd0d74 100644 --- a/RALocalizer.h +++ b/RALocalizer.h @@ -1,7 +1,7 @@ @interface RALocalizer : NSObject { NSDictionary *translation; } -+(id) sharedInstance; ++(instancetype) sharedInstance; -(NSString*) localizedStringForKey:(NSString*)key; -@end \ No newline at end of file +@end diff --git a/RALocalizer.mm b/RALocalizer.mm index df0cde9..40f92fa 100644 --- a/RALocalizer.mm +++ b/RALocalizer.mm @@ -2,7 +2,7 @@ #import "headers.h" @implementation RALocalizer -+(id) sharedInstance ++(instancetype) sharedInstance { SHARED_INSTANCE2(RALocalizer, [sharedInstance loadTranslation]); } diff --git a/RARunningAppsProvider.xm b/RARunningAppsProvider.xm index 362a53d..a891e27 100644 --- a/RARunningAppsProvider.xm +++ b/RARunningAppsProvider.xm @@ -3,8 +3,8 @@ @implementation RARunningAppsProvider +(instancetype) sharedInstance { - SHARED_INSTANCE2(RARunningAppsProvider, - sharedInstance->apps = [NSMutableArray array]; + SHARED_INSTANCE2(RARunningAppsProvider, + sharedInstance->apps = [NSMutableArray array]; sharedInstance->targets = [NSMutableArray array]; sharedInstance->lock = [[NSLock alloc] init]; ); @@ -43,7 +43,7 @@ { [lock lock]; - if ([targets containsObject:target] == NO) + if (![targets containsObject:target]) [targets addObject:target]; [lock unlock]; @@ -67,9 +67,9 @@ { %orig; - if (self.isRunning && [RARunningAppsProvider.sharedInstance.mutableRunningApplications containsObject:self] == NO) + if (self.isRunning && ![RARunningAppsProvider.sharedInstance.mutableRunningApplications containsObject:self]) [RARunningAppsProvider.sharedInstance addRunningApp:self]; else if (!self.isRunning && [RARunningAppsProvider.sharedInstance.mutableRunningApplications containsObject:self]) [RARunningAppsProvider.sharedInstance removeRunningApp:self]; } -%end \ No newline at end of file +%end diff --git a/RASettings.mm b/RASettings.mm index f373d31..fcf8e79 100644 --- a/RASettings.mm +++ b/RASettings.mm @@ -53,7 +53,7 @@ +(instancetype) sharedInstance SHARED_INSTANCE(RASettings); } --(id) init +-(instancetype) init { if (self = [super init]) { @@ -106,7 +106,7 @@ -(void) reloadSettings //NSLog(@"[ReachApp] settings sandbox load: %@", _settings == nil ? @"failed" : @"succeed"); } - if (_settings == nil) + if (!_settings) { LogError(@"[ReachApp] could not load settings from CFPreferences or NSDictionary"); } diff --git a/RASnapshotProvider.h b/RASnapshotProvider.h index a54aaa6..fd5b7fb 100644 --- a/RASnapshotProvider.h +++ b/RASnapshotProvider.h @@ -3,7 +3,7 @@ @interface RASnapshotProvider : NSObject { NSCache *imageCache; } -+(id) sharedInstance; ++(instancetype) sharedInstance; -(UIImage*) snapshotForDesktop:(RADesktopWindow*)desktop; -(void) forceReloadSnapshotOfDesktop:(RADesktopWindow*)desktop; @@ -17,4 +17,4 @@ -(UIImage*) wallpaperImage; -(void) forceReloadEverything; -@end \ No newline at end of file +@end diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index be0b366..fd9699a 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -3,7 +3,7 @@ #import "RAWindowBar.h" @implementation RASnapshotProvider -+(id) sharedInstance ++(instancetype) sharedInstance { SHARED_INSTANCE2(RASnapshotProvider, sharedInstance->imageCache = [NSCache new]); } @@ -23,7 +23,7 @@ @autoreleasepool { - if ([imageCache objectForKey:identifier] != nil) return [imageCache objectForKey:identifier]; + if ([imageCache objectForKey:identifier]) return [imageCache objectForKey:identifier]; UIImage *image = nil; diff --git a/Reachability/RAReachabilityManager.h b/Reachability/RAReachabilityManager.h index 73e2940..4642c8e 100644 --- a/Reachability/RAReachabilityManager.h +++ b/Reachability/RAReachabilityManager.h @@ -3,11 +3,11 @@ @class RAAppSliderProviderView; @interface RAReachabilityManager : NSObject -+(id) sharedInstance; ++(instancetype) sharedInstance; -(void) launchTopAppWithIdentifier:(NSString*)identifier; -(void) launchWidget:(RAWidget*)widget; -(void) showAppWithSliderProvider:(__weak RAAppSliderProviderView*)view; -(void) showWidgetSelector; -@end \ No newline at end of file +@end diff --git a/Reachability/RAReachabilityManager.mm b/Reachability/RAReachabilityManager.mm index 0b06ef4..412d090 100644 --- a/Reachability/RAReachabilityManager.mm +++ b/Reachability/RAReachabilityManager.mm @@ -5,7 +5,7 @@ #import "RAMessagingServer.h" @implementation RAReachabilityManager -+(id) sharedInstance ++(instancetype) sharedInstance { SHARED_INSTANCE(RAReachabilityManager); } @@ -35,4 +35,4 @@ -(void) showAppWithSliderProvider:(__weak RAAppSliderProviderView*)view [view load]; [GET_SBWORKSPACE RA_setView:view preferredHeight:view.frame.size.height]; } -@end \ No newline at end of file +@end diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 3f00802..1e47632 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -225,7 +225,7 @@ id SBWorkspace$sharedInstance; // Give them a little time to receive the notifications... if (view) { - if ([view superview] != nil) + if ([view superview]) [view removeFromSuperview]; } dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ @@ -264,7 +264,7 @@ id SBWorkspace$sharedInstance; %orig; - if (![RASettings.sharedInstance reachabilityEnabled] && wasEnabled == NO) + if (![RASettings.sharedInstance reachabilityEnabled] && !wasEnabled) { return; } @@ -355,7 +355,7 @@ id SBWorkspace$sharedInstance; SBApplication *app = nil; FBScene *scene = nil; NSMutableArray *bundleIdentifiers = [[RAAppSwitcherModelWrapper appSwitcherAppIdentiferList] mutableCopy]; - while (scene == nil && bundleIdentifiers.count > 0) + while (!scene && bundleIdentifiers.count > 0) { lastBundleIdentifier = bundleIdentifiers[0]; @@ -371,7 +371,7 @@ id SBWorkspace$sharedInstance; if (bundleIdentifiers.count > 0) [bundleIdentifiers removeObjectAtIndex:0]; } - if (lastBundleIdentifier == nil || lastBundleIdentifier.length == 0) + if (!lastBundleIdentifier || lastBundleIdentifier.length == 0) return; [self RA_launchTopAppWithIdentifier:lastBundleIdentifier]; @@ -614,7 +614,7 @@ CGFloat startingY = -1; if (ncViewController) ncViewController.view.frame = (CGRect) { { 0, 0 }, topFrame.size }; } - else if (lastBundleIdentifier != nil || [view isKindOfClass:[RAAppSliderProviderView class]]) + else if (lastBundleIdentifier || [view isKindOfClass:[RAAppSliderProviderView class]]) { // Notify clients @@ -712,7 +712,7 @@ CGFloat startingY = -1; UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; FBScene *scene = [app mainScene]; - if (app == nil) + if (!app) return; [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; @@ -720,7 +720,7 @@ CGFloat startingY = -1; [RAMessagingServer.sharedInstance rotateApp:app.bundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; [RAMessagingServer.sharedInstance forceStatusBarVisibility:YES forApp:app.bundleIdentifier completion:nil]; - if (![app pid] || [app mainScene] == nil) + if (![app pid] || ![app mainScene]) { overrideDisableForStatusBar = YES; [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; diff --git a/SwipeOver/RASwipeOverManager.h b/SwipeOver/RASwipeOverManager.h index eb5a95a..0524fe0 100644 --- a/SwipeOver/RASwipeOverManager.h +++ b/SwipeOver/RASwipeOverManager.h @@ -4,7 +4,7 @@ NSString *currentAppIdentifier; BOOL isUsingSwipeOver; } -+(id) sharedInstance; ++(instancetype) sharedInstance; -(void) startUsingSwipeOver; -(void) stopUsingSwipeOver; diff --git a/SwipeOver/RASwipeOverManager.xm b/SwipeOver/RASwipeOverManager.xm index 8c3a213..c1871b5 100644 --- a/SwipeOver/RASwipeOverManager.xm +++ b/SwipeOver/RASwipeOverManager.xm @@ -25,7 +25,7 @@ extern int rotationDegsForOrientation(int o); @end @implementation RASwipeOverManager -+(id) sharedInstance ++(instancetype) sharedInstance { SHARED_INSTANCE(RASwipeOverManager); } @@ -131,7 +131,7 @@ extern int rotationDegsForOrientation(int o); [[%c(SBAppSwitcherModel) sharedInstance] addToFront:layout]; } - if (identifier == nil || identifier.length == 0) + if (!identifier || identifier.length == 0) return; RAHostedAppView *view = [[%c(RAHostedAppView) alloc] initWithBundleIdentifier:identifier]; @@ -157,7 +157,7 @@ extern int rotationDegsForOrientation(int o); detachView.tag = 9903553; [view addSubview:detachView]; - if (overlayWindow.isHidingUnderlyingApp == NO) // side-by-side + if (!overlayWindow.isHidingUnderlyingApp) // side-by-side view.frame = CGRectMake(10, 0, view.frame.size.width, view.frame.size.height); else // overlay { @@ -186,7 +186,7 @@ extern int rotationDegsForOrientation(int o); -(void) convertSwipeOverViewToSideBySide { - if (currentAppIdentifier == nil || [[%c(SBReachabilityManager) sharedInstance] reachabilityModeActive]) + if (!currentAppIdentifier || [[%c(SBReachabilityManager) sharedInstance] reachabilityModeActive]) { [self stopUsingSwipeOver]; return; @@ -222,7 +222,7 @@ extern int rotationDegsForOrientation(int o); -(void) updateClientSizes:(BOOL)reloadAppSelectorSizeNow { - if (currentAppIdentifier && overlayWindow.isHidingUnderlyingApp == NO) + if (currentAppIdentifier && !overlayWindow.isHidingUnderlyingApp) { CGFloat underWidth = [overlayWindow isHidingUnderlyingApp] ? -1 : overlayWindow.frame.origin.x; [[%c(RAMessagingServer) sharedInstance] resizeApp:currentAppIdentifier toSize:CGSizeMake(underWidth, -1) completion:nil]; @@ -230,7 +230,7 @@ extern int rotationDegsForOrientation(int o); if (overlayWindow.isShowingAppSelector && reloadAppSelectorSizeNow) [self showAppSelector]; - else if (overlayWindow.isHidingUnderlyingApp == NO) // Update swiped-over app in side-by-side mode. RAHostedAppView takes care of the app sizing if we resize the RAHostedAppView. + else if (!overlayWindow.isHidingUnderlyingApp) // Update swiped-over app in side-by-side mode. RAHostedAppView takes care of the app sizing if we resize the RAHostedAppView. { overlayWindow.currentView.frame = CGRectMake(10, 0, SCREEN_WIDTH - overlayWindow.frame.origin.x - 10, overlayWindow.currentView.frame.size.height); } @@ -267,7 +267,7 @@ extern int rotationDegsForOrientation(int o); if (overlayWindow.isHidingUnderlyingApp) { - if ([[overlayWindow currentView] isKindOfClass:[%c(RAAppSelectorView) class]] == NO) + if (![[overlayWindow currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) { if (lastX == -1) lastX = translation.x; diff --git a/SwipeOver/RASwipeOverOverlay.xm b/SwipeOver/RASwipeOverOverlay.xm index 50bd24b..a934c63 100644 --- a/SwipeOver/RASwipeOverOverlay.xm +++ b/SwipeOver/RASwipeOverOverlay.xm @@ -4,7 +4,7 @@ @implementation RASwipeOverOverlay @synthesize grabberView; --(id) initWithFrame:(CGRect)frame +-(instancetype) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { diff --git a/SwipeOver/SwipeOverGesture.xm b/SwipeOver/SwipeOverGesture.xm index 40524cb..78ccb19 100644 --- a/SwipeOver/SwipeOverGesture.xm +++ b/SwipeOver/SwipeOverGesture.xm @@ -103,7 +103,7 @@ BOOL swipeOverLocationIsInValidArea(CGFloat y) if ([%c(Multiplexer) shouldShowControlCenterGrabberOnFirstSwipe] || [[%c(RASettings) sharedInstance] alwaysShowSOGrabber]) { - if (isShowingGrabber == NO && isPastGrabber == NO) + if (!isShowingGrabber && !isPastGrabber) { firstSwipe = YES; isShowingGrabber = YES; diff --git a/UIKit.xm b/UIKit.xm index e215498..aadaab8 100644 --- a/UIKit.xm +++ b/UIKit.xm @@ -18,9 +18,9 @@ static Class $memorized$UITextEffectsWindow$class; %hook UIWindow -(void) setFrame:(CGRect)frame { - if ([self.class isEqual:$memorized$UITextEffectsWindow$class] == NO && [RAMessagingClient.sharedInstance shouldResize]) + if (![self.class isEqual:$memorized$UITextEffectsWindow$class] && [RAMessagingClient.sharedInstance shouldResize]) { - if ([oldFrames objectForKey:@(self.hash)] == nil) + if (![oldFrames objectForKey:@(self.hash)]) [oldFrames setObject:[NSValue valueWithCGRect:frame] forKey:@(self.hash)]; frame.origin.x = RAMessagingClient.sharedInstance.currentData.wantedClientOriginX == -1 ? 0 : RAMessagingClient.sharedInstance.currentData.wantedClientOriginX; @@ -118,7 +118,7 @@ static Class $memorized$UITextEffectsWindow$class; { if (!reverting) { - if (setPreviousOrientation == NO) + if (!setPreviousOrientation) { setPreviousOrientation = YES; prevousOrientation = UIApplication.sharedApplication.statusBarOrientation; @@ -168,7 +168,7 @@ static Class $memorized$UITextEffectsWindow$class; for (UIWindow *window in [[UIApplication sharedApplication] windows]) { CGRect frame = window.frame; - if ([oldFrames objectForKey:@(window.hash)] != nil) + if ([oldFrames objectForKey:@(window.hash)]) { frame = [[oldFrames objectForKey:@(window.hash)] CGRectValue]; [oldFrames removeObjectForKey:@(window.hash)]; @@ -179,7 +179,7 @@ static Class $memorized$UITextEffectsWindow$class; }]; } - if ([oldFrames objectForKey:@"statusBar"] != nil) + if ([oldFrames objectForKey:@"statusBar"]) UIApplication.sharedApplication.statusBar.frame = [oldFrames[@"statusBar"] CGRectValue]; return; @@ -187,7 +187,7 @@ static Class $memorized$UITextEffectsWindow$class; if (size.width != -1) { - if ([oldFrames objectForKey:@"statusBar"] == nil) + if (![oldFrames objectForKey:@"statusBar"]) [oldFrames setObject:[NSValue valueWithCGRect:UIApplication.sharedApplication.statusBar.frame] forKey:@"statusBar"]; UIApplication.sharedApplication.statusBar.frame = CGRectMake(0, 0, size.width, UIApplication.sharedApplication.statusBar.frame.size.height); } diff --git a/WindowedMultitasking/RADesktopManager.xm b/WindowedMultitasking/RADesktopManager.xm index a5a5a9c..768a469 100644 --- a/WindowedMultitasking/RADesktopManager.xm +++ b/WindowedMultitasking/RADesktopManager.xm @@ -65,7 +65,7 @@ BOOL overrideUIWindow = NO; [currentDesktop unloadApps]; [newDesktop loadApps]; - if (show == NO) + if (!show) newDesktop.hidden = YES; overrideUIWindow = NO; [newDesktop makeKeyAndVisible]; diff --git a/WindowedMultitasking/RADesktopWindow.mm b/WindowedMultitasking/RADesktopWindow.mm index 3869ece..065ace2 100644 --- a/WindowedMultitasking/RADesktopWindow.mm +++ b/WindowedMultitasking/RADesktopWindow.mm @@ -7,7 +7,7 @@ #import "RAFakePhoneMode.h" @implementation RADesktopWindow --(id) initWithFrame:(CGRect)frame +-(instancetype) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { @@ -314,7 +314,7 @@ -(UIInterfaceOrientation) appOrientationRelativeToThisOrientation:(CGFloat)curre -(void) loadInfo:(NSInteger)index { - if ([RAWindowStatePreservationSystemManager.sharedInstance hasDesktopInformationAtIndex:index] == NO) + if (![RAWindowStatePreservationSystemManager.sharedInstance hasDesktopInformationAtIndex:index]) return; RAPreservedDesktopInformation info = [RAWindowStatePreservationSystemManager.sharedInstance desktopInformationForIndex:index]; for (NSString *bundleIdentifier in info.openApps) diff --git a/WindowedMultitasking/RAWindowSnapDataProvider.h b/WindowedMultitasking/RAWindowSnapDataProvider.h index f06bb1a..111e2cc 100644 --- a/WindowedMultitasking/RAWindowSnapDataProvider.h +++ b/WindowedMultitasking/RAWindowSnapDataProvider.h @@ -1,13 +1,13 @@ #import "RAWindowBar.h" #import "RADesktopWindow.h" -enum RAWindowSnapLocation { +typedef NS_ENUM(NSInteger, RAWindowSnapLocation) { RAWindowSnapLocationInvalid = 0, RAWindowSnapLocationLeftTop, RAWindowSnapLocationLeftMiddle, RAWindowSnapLocationLeftBottom, - + RAWindowSnapLocationRightTop, RAWindowSnapLocationRightMiddle, RAWindowSnapLocationRightBottom, diff --git a/WindowedMultitasking/RAWindowStatePreservationSystemManager.h b/WindowedMultitasking/RAWindowStatePreservationSystemManager.h index 7ec4429..d15c155 100644 --- a/WindowedMultitasking/RAWindowStatePreservationSystemManager.h +++ b/WindowedMultitasking/RAWindowStatePreservationSystemManager.h @@ -2,20 +2,20 @@ #import "RADesktopWindow.h" #import "RAWindowBar.h" -struct RAPreservedWindowInformation { +typedef struct { CGPoint center; CGAffineTransform transform; -}; +} RAPreservedWindowInformation; -struct RAPreservedDesktopInformation { +typedef struct { NSUInteger index; NSArray *openApps; //NSArray -}; +} RAPreservedDesktopInformation; @interface RAWindowStatePreservationSystemManager : NSObject { NSMutableDictionary *dict; } -+(id) sharedInstance; ++(instancetype) sharedInstance; -(void) loadInfo; -(void) saveInfo; @@ -30,4 +30,4 @@ struct RAPreservedDesktopInformation { -(BOOL) hasWindowInformationForIdentifier:(NSString*)appIdentifier; -(RAPreservedWindowInformation) windowInformationForAppIdentifier:(NSString*)identifier; -(void) removeWindowInformationForIdentifier:(NSString*)appIdentifier; -@end \ No newline at end of file +@end diff --git a/WindowedMultitasking/RAWindowStatePreservationSystemManager.xm b/WindowedMultitasking/RAWindowStatePreservationSystemManager.xm index e3d56d0..6b0c038 100644 --- a/WindowedMultitasking/RAWindowStatePreservationSystemManager.xm +++ b/WindowedMultitasking/RAWindowStatePreservationSystemManager.xm @@ -5,7 +5,7 @@ #define FILE_PATH @"/User/Library/Preferences/com.efrederickson.empoleon.windowstates.plist" @implementation RAWindowStatePreservationSystemManager -+(id) sharedInstance ++(instancetype) sharedInstance { SHARED_INSTANCE2(RAWindowStatePreservationSystemManager, [sharedInstance loadInfo]); } @@ -95,4 +95,4 @@ [dict removeObjectForKey:appIdentifier]; [self saveInfo]; } -@end \ No newline at end of file +@end diff --git a/headers.h b/headers.h index 9111c32..8e968bd 100644 --- a/headers.h +++ b/headers.h @@ -102,7 +102,7 @@ void SET_BACKGROUNDED(id settings, BOOL val); #define SHARED_INSTANCE2(cls, extracode) \ static cls *sharedInstance = nil; \ -static dispatch_once_t onceToken = 0; \ +static dispatch_once_t onceToken; \ dispatch_once(&onceToken, ^{ \ sharedInstance = [[cls alloc] init]; \ extracode; \ @@ -748,6 +748,11 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @interface FBSceneManager : NSObject @end +@interface FBDisplayManager : NSObject ++(id)sharedInstance; ++(id)mainDisplay; +@end + @interface SBWorkspaceApplicationTransitionContext : NSObject @property(nonatomic) _Bool animationDisabled; // @synthesize animationDisabled=_animationDisabled; - (void)setEntity:(id)arg1 forLayoutRole:(int)arg2; diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index cbe8383..fb2cc05 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -9,7 +9,7 @@ int main(int argc, char **argv, char **envp) { @autoreleasepool { NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; - if ([NSFileManager.defaultManager fileExistsAtPath:filePath] == NO) + if (![NSFileManager.defaultManager fileExistsAtPath:filePath]) { LogError(@"[ReachApp] FS Daemon: plist does not exist"); return 0; diff --git a/update_status b/update_status index d807d96..3a69250 100644 --- a/update_status +++ b/update_status @@ -36,5 +36,8 @@ Minor Things/Bugs to note: - Startup bug still isnt fixed (find cause / better fix) - General Code Cleanup, feels to messy RN +Features to Add: +- 3D Touch actions? + notes: use _referenceBounds instead of bounds on UIScreen to get physical bounds. Makes landscape support easier? diff --git a/widgets/Core/RAWidgetHostManager.h b/widgets/Core/RAWidgetHostManager.h index 07bcb73..37363eb 100644 --- a/widgets/Core/RAWidgetHostManager.h +++ b/widgets/Core/RAWidgetHostManager.h @@ -4,10 +4,10 @@ @interface RAWidgetHostManager : NSObject { NSMutableArray *widgets; } -+(id) sharedInstance; ++(instancetype) sharedInstance; -(void) addWidget:(RAWidgetBase*)widget; -(void) removeWidget:(RAWidgetBase*)widget; -(void) removeWidgetWithIdentifier:(NSString*)identifier; -(RAWidgetBase*) widgetForIdentifier:(NSString*)identifier; -@end \ No newline at end of file +@end diff --git a/widgets/Core/RAWidgetHostManager.xm b/widgets/Core/RAWidgetHostManager.xm index 3f3bcbf..5c3fabf 100644 --- a/widgets/Core/RAWidgetHostManager.xm +++ b/widgets/Core/RAWidgetHostManager.xm @@ -1,7 +1,7 @@ #import "RAWidgetHostManager.h" @implementation RAWidgetHostManager -+(id) sharedInstance ++(instancetype) sharedInstance { SHARED_INSTANCE2(RAWidgetHostManager, sharedInstance->widgets = [NSMutableArray array]); } @@ -40,4 +40,4 @@ } return nil; } -@end \ No newline at end of file +@end diff --git a/widgets/Reachability/RAWidgetSectionManager.mm b/widgets/Reachability/RAWidgetSectionManager.mm index 8cf1f1c..3fdc949 100644 --- a/widgets/Reachability/RAWidgetSectionManager.mm +++ b/widgets/Reachability/RAWidgetSectionManager.mm @@ -11,7 +11,7 @@ +(instancetype) sharedInstance SHARED_INSTANCE(RAWidgetSectionManager); } --(id) init +-(instancetype) init { if (self = [super init]) { @@ -73,7 +73,7 @@ -(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIcon for (RAWidgetSection* section in [self enabledSections]) { - if (section.enabled == NO) + if (!section.enabled) continue; @try { From 1c6971f1ee846f153fb188aad25eb9d3d9ed753c Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 10 Mar 2017 14:30:09 -0600 Subject: [PATCH 39/59] using %c when viable --- Backgrounding/IconIndicator.xm | 4 ++-- Backgrounding/Makefile | 4 ++-- GestureSupport/Hooks_iOS8.xm | 2 +- GestureSupport/Hooks_iOS9.xm | 2 +- Messaging/RAMessagingClient.xm | 2 +- Messaging/RAMessagingServer.xm | 2 +- MissionControl/Makefile | 4 ++-- RASBWorkspaceFetcher.xm | 2 +- RASettings.mm | 14 +++++++------- Reachability/Reachability.xm | 2 +- SwipeOver/Makefile | 4 ++-- UIKit.xm | 2 +- reachappbackboarddhooks/Tweak.xm | 4 ++-- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 1156ca9..d55b17d 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -142,7 +142,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) UIImageView *textImageView = (UIImageView*)[badge viewWithTag:42]; if (!textImageView) { - CGFloat padding = [objc_getClass("SBIconBadgeView") _textPadding]; + CGFloat padding = [%c(SBIconBadgeView) _textPadding]; textImageView = [[UIImageView alloc] initWithFrame:CGRectMake(padding, padding, badge.frame.size.width - (padding * 2.0), badge.frame.size.height - (padding * 2.0))]; textImageView.center = CGPointMake((badge.frame.size.width / 2.0) + [%c(SBIconBadgeView) _textOffset].x, (badge.frame.size.height / 2.0) + [%c(SBIconBadgeView) _textOffset].y); @@ -274,7 +274,7 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) */ %new -(void) RA_addStatusBarIconForSelfIfOneDoesNotExist { - if (objc_getClass("LSStatusBarItem") && ![lsbitems objectForKey:self.bundleIdentifier] && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) { + if (%c(LSStatusBarItem) && ![lsbitems objectForKey:self.bundleIdentifier] && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) { if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { if ([[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]) { RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; diff --git a/Backgrounding/Makefile b/Backgrounding/Makefile index cc51bbd..09b4244 100644 --- a/Backgrounding/Makefile +++ b/Backgrounding/Makefile @@ -1,7 +1,7 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -I../WindowedMultitasking/ -Wno-deprecated-declarations -CFLAGS += -fobjc-arc -O2 +CFLAGS = -I../ -I../Theming/ -I../WindowedMultitasking/ -Wno-deprecated-declarations -O2 +CFLAGS += -fobjc-arc include $(THEOS)/makefiles/common.mk diff --git a/GestureSupport/Hooks_iOS8.xm b/GestureSupport/Hooks_iOS8.xm index d2e1cad..f95cda1 100644 --- a/GestureSupport/Hooks_iOS8.xm +++ b/GestureSupport/Hooks_iOS8.xm @@ -152,7 +152,7 @@ typedef struct { if (IS_IOS_OR_NEWER(iOS_9_0)) return; - class_addProtocol(objc_getClass("SBHandMotionExtractor"), @protocol(_UIScreenEdgePanRecognizerDelegate)); + class_addProtocol(%c(SBHandMotionExtractor), @protocol(_UIScreenEdgePanRecognizerDelegate)); UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index bc39adc..230c625 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -196,7 +196,7 @@ __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; IOHIDEventSystemClientScheduleWithRunLoop(hidEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); IOHIDEventSystemClientRegisterEventCallback(hidEventSystem, (IOHIDEventSystemClientEventCallback)touch_event, NULL, NULL); - class_addProtocol(objc_getClass("Hooks9$SBHandMotionExtractorReplacementByMultiplexer"), @protocol(_UIScreenEdgePanRecognizerDelegate)); + class_addProtocol(%c(Hooks9$SBHandMotionExtractorReplacementByMultiplexer), @protocol(_UIScreenEdgePanRecognizerDelegate)); UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 636809d..8d87326 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -59,7 +59,7 @@ extern BOOL allowClosingReachabilityNatively; _currentData = data; // Initialize data - serverCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + serverCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); if (handle) diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index 1ed4050..edb6b54 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -35,7 +35,7 @@ extern BOOL launchNextOpenIntoWindow; -(void) loadServer { - messagingCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + messagingCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); if (handle) diff --git a/MissionControl/Makefile b/MissionControl/Makefile index 6ca74ed..a2769a3 100644 --- a/MissionControl/Makefile +++ b/MissionControl/Makefile @@ -1,7 +1,7 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -CFLAGS += -fobjc-arc -O2 +CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -O2 +CFLAGS += -fobjc-arc include $(THEOS)/makefiles/common.mk diff --git a/RASBWorkspaceFetcher.xm b/RASBWorkspaceFetcher.xm index 3788415..1615430 100644 --- a/RASBWorkspaceFetcher.xm +++ b/RASBWorkspaceFetcher.xm @@ -29,5 +29,5 @@ Class SBWorkspace_class_implementation_class = nil; { // SBMainWorkspace: iOS 9 // SBWorkspace: iOS 8 - SBWorkspace_class_implementation_class = objc_getClass("SBMainWorkspace") ?: objc_getClass("SBWorkspace"); + SBWorkspace_class_implementation_class = %c(SBMainWorkspace) ?: %c(SBWorkspace); } diff --git a/RASettings.mm b/RASettings.mm index fcf8e79..2f586a6 100644 --- a/RASettings.mm +++ b/RASettings.mm @@ -111,10 +111,10 @@ -(void) reloadSettings LogError(@"[ReachApp] could not load settings from CFPreferences or NSDictionary"); } - if ([previousNCAppSetting isEqual:self.NCApp] == NO) + if (![previousNCAppSetting isEqual:self.NCApp]) [[objc_getClass("RANCViewController") sharedViewController] forceReloadAppLikelyBecauseTheSettingChanged]; // using objc_getClass allows RASettings to be used in reachappsettings and other places - if ([self shouldShowStatusBarIcons] == NO && [objc_getClass("SBApplication") respondsToSelector:@selector(RA_clearAllStatusBarIcons)]) + if (![self shouldShowStatusBarIcons] && [objc_getClass("SBApplication") respondsToSelector:@selector(RA_clearAllStatusBarIcons)]) [objc_getClass("SBApplication") performSelector:@selector(RA_clearAllStatusBarIcons)]; [RAThemeManager.sharedInstance invalidateCurrentThemeAndReload:[self currentThemeIdentifier]]; @@ -246,7 +246,7 @@ -(BOOL) flipTopAndBottom -(NSString*) NCApp { - return [_settings objectForKey:@"NCApp"] == nil ? @"com.apple.Preferences" : _settings[@"NCApp"]; + return ![_settings objectForKey:@"NCApp"] ? @"com.apple.Preferences" : _settings[@"NCApp"]; } -(BOOL) alwaysEnableGestures @@ -300,12 +300,12 @@ -(BOOL) snapRotation -(NSInteger) globalBackgroundMode { - return [_settings objectForKey:@"globalBackgroundMode"] == nil ? RABackgroundModeNative : [_settings[@"globalBackgroundMode"] intValue]; + return ![_settings objectForKey:@"globalBackgroundMode"] ? RABackgroundModeNative : [_settings[@"globalBackgroundMode"] intValue]; } -(NSInteger) windowRotationLockMode { - return [_settings objectForKey:@"windowRotationLockMode"] == nil ? 0 : [_settings[@"windowRotationLockMode"] intValue]; + return ![_settings objectForKey:@"windowRotationLockMode"] ? 0 : [_settings[@"windowRotationLockMode"] intValue]; } -(BOOL) shouldShowStatusBarIcons { return BOOL(@"shouldShowStatusBarIcons", YES); } @@ -376,11 +376,11 @@ -(BOOL) showSnapHelper { return BOOL(@"showSnapHelper", NO); } -(RAGrabArea) windowedMultitaskingGrabArea { - return [_settings objectForKey:@"windowedMultitaskingGrabArea"] == nil ? RAGrabAreaBottomLeftThird : (RAGrabArea)[_settings[@"windowedMultitaskingGrabArea"] intValue]; + return ![_settings objectForKey:@"windowedMultitaskingGrabArea"] ? RAGrabAreaBottomLeftThird : (RAGrabArea)[_settings[@"windowedMultitaskingGrabArea"] intValue]; } -(RAGrabArea) swipeOverGrabArea { - return [_settings objectForKey:@"swipeOverGrabArea"] == nil ? RAGrabAreaSideAnywhere : (RAGrabArea)[_settings[@"swipeOverGrabArea"] intValue]; + return ![_settings objectForKey:@"swipeOverGrabArea"] ? RAGrabAreaSideAnywhere : (RAGrabArea)[_settings[@"swipeOverGrabArea"] intValue]; } @end diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 1e47632..fe7b854 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -878,7 +878,7 @@ CGFloat startingY = -1; - (void)applicationDidFinishLaunching:(id)arg1 { - Class c = objc_getClass("SBMainWorkspace") ?: objc_getClass("SBWorkspace"); + Class c = %c(SBMainWorkspace) ?: %c(SBWorkspace); %init(SBWorkspace, SB_WORKSPACE_CLASS=c); %orig; } diff --git a/SwipeOver/Makefile b/SwipeOver/Makefile index 685cf30..7a23b47 100644 --- a/SwipeOver/Makefile +++ b/SwipeOver/Makefile @@ -1,7 +1,7 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -I../Messaging/ -I../KeyboardSupport -I../MissionControl -Wno-deprecated-declarations -CFLAGS += -fobjc-arc -O2 +CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -I../Messaging/ -I../KeyboardSupport -I../MissionControl -Wno-deprecated-declarations -O2 +CFLAGS += -fobjc-arc include $(THEOS)/makefiles/common.mk TWEAK_NAME = ReachAppSwipeOver diff --git a/UIKit.xm b/UIKit.xm index aadaab8..8621c02 100644 --- a/UIKit.xm +++ b/UIKit.xm @@ -255,7 +255,7 @@ void reloadSettings(CFNotificationCenterRef center, { IF_NOT_SPRINGBOARD { %init; - $memorized$UITextEffectsWindow$class = objc_getClass("UITextEffectsWindow"); + $memorized$UITextEffectsWindow$class = %c(UITextEffectsWindow); } CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadSettings, CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), NULL, 0); diff --git a/reachappbackboarddhooks/Tweak.xm b/reachappbackboarddhooks/Tweak.xm index 71d94ff..04576c0 100644 --- a/reachappbackboarddhooks/Tweak.xm +++ b/reachappbackboarddhooks/Tweak.xm @@ -113,7 +113,7 @@ void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEven NSString *clientId = response[@"bundleIdentifier"]; if (pid && clientId) - return [[[objc_getClass("BKEventDestination") alloc] initWithPid:pid clientID:clientId] autorelease]; + return [[[%c(BKEventDestination) alloc] initWithPid:pid clientID:clientId] autorelease]; } return %orig; } @@ -155,7 +155,7 @@ void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEven %ctor { - center = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + center = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); if(handle) From 529d30ea899638655ef6f992bda387f1f24e8c40 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 10 Mar 2017 20:57:37 -0600 Subject: [PATCH 40/59] Not sure what i fixed? --- RAHostManager.xm | 2 +- RAHostedAppView.h | 2 +- RAHostedAppView.xm | 1 + Reachability/Reachability.xm | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RAHostManager.xm b/RAHostManager.xm index 14cf6ed..44bc820 100644 --- a/RAHostManager.xm +++ b/RAHostManager.xm @@ -30,7 +30,7 @@ return nil; [[UIApplication sharedApplication] launchApplicationWithIdentifier:app.bundleIdentifier suspended:YES]; - SET_BACKGROUNDED(settings, NO); + SET_BACKGROUNDED(settings, NO); [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; diff --git a/RAHostedAppView.h b/RAHostedAppView.h index f360959..16de588 100644 --- a/RAHostedAppView.h +++ b/RAHostedAppView.h @@ -15,7 +15,7 @@ @property (nonatomic) BOOL showSplashscreenInsteadOfSpinner; @property (nonatomic) BOOL renderWallpaper; -@property (nonatomic, retain) NSString *bundleIdentifier; +@property (nonatomic, copy) NSString *bundleIdentifier; @property (nonatomic) BOOL autosizesApp; @property (nonatomic) BOOL allowHidingStatusBar; diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index 757a838..812ab43 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -106,6 +106,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; FBScene *scene = [app mainScene]; if (![app pid] || !scene) { + LogDebug(@"has no pid or scene, createApplicationProcessForBundleID"); [UIApplication.sharedApplication launchApplicationWithIdentifier:self.bundleIdentifier suspended:YES]; [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:self.bundleIdentifier]; // ummm...? } diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index fe7b854..feaf2f2 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -746,6 +746,8 @@ CGFloat startingY = -1; [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; view = [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES]; + view.accessibilityHint = bundleIdentifier; + if (draggerView && draggerView.superview == w) [w insertSubview:view belowSubview:draggerView]; else From 022aa0257f2dfe475f09abd1457225ba4905c1c2 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 10 Mar 2017 22:17:26 -0600 Subject: [PATCH 41/59] Changed retain to copy on NSString properties --- GestureSupport/RAGestureCallback.h | 4 ++-- .../RASpringBoardKeyboardActivation.h | 2 +- Messaging/RAMessagingClient.h | 2 +- Messaging/RAMessagingClient.xm | 11 ++------- Messaging/RAMessagingServer.xm | 11 ++------- Multiplexer.h | 4 ++-- RAHostManager.xm | 5 ++-- Reachability/Reachability.xm | 1 + Reachability/UIKit.xm | 8 +++++++ Theming/RATheme.h | 6 ++--- reachappsettings/Reachability.xm | 23 +++++++++---------- update_status | 2 ++ widgets/Reachability/RADefaultWidgetSection.h | 4 ++-- .../Reachability/RADefaultWidgetSection.mm | 10 ++++---- widgets/Reachability/RAFavoriteAppsWidget.xm | 4 ++-- 15 files changed, 47 insertions(+), 50 deletions(-) diff --git a/GestureSupport/RAGestureCallback.h b/GestureSupport/RAGestureCallback.h index 507d679..0b23d7f 100644 --- a/GestureSupport/RAGestureCallback.h +++ b/GestureSupport/RAGestureCallback.h @@ -9,6 +9,6 @@ @property (nonatomic) UIRectEdge screenEdge; @property (nonatomic) NSUInteger priority; -@property (nonatomic, retain) NSString *identifier; +@property (nonatomic, copy) NSString *identifier; -@end \ No newline at end of file +@end diff --git a/KeyboardSupport/RASpringBoardKeyboardActivation.h b/KeyboardSupport/RASpringBoardKeyboardActivation.h index 9a6dd03..fc5e541 100644 --- a/KeyboardSupport/RASpringBoardKeyboardActivation.h +++ b/KeyboardSupport/RASpringBoardKeyboardActivation.h @@ -4,7 +4,7 @@ @interface RASpringBoardKeyboardActivation : NSObject +(instancetype) sharedInstance; -@property (nonatomic, readonly, retain) NSString *currentIdentifier; +@property (nonatomic, readonly, copy) NSString *currentIdentifier; -(void) showKeyboardForAppWithIdentifier:(NSString*)identifier; -(void) hideKeyboard; diff --git a/Messaging/RAMessagingClient.h b/Messaging/RAMessagingClient.h index 4813691..199c1a3 100644 --- a/Messaging/RAMessagingClient.h +++ b/Messaging/RAMessagingClient.h @@ -10,7 +10,7 @@ @property (nonatomic, readonly) RAMessageAppData currentData; @property (nonatomic) BOOL hasRecievedData; -@property (nonatomic, retain) NSString *knownFrontmostApp; +@property (nonatomic, copy) NSString *knownFrontmostApp; -(void) requestUpdateFromServer; diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 8d87326..70f5bbe 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -59,15 +59,8 @@ extern BOOL allowClosingReachabilityNatively; _currentData = data; // Initialize data - serverCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - - void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if (handle) - { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(serverCenter); - dlclose(handle); - } + serverCenter = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + rocketbootstrap_distributedmessagingcenter_apply(serverCenter); } -(void) alertUser:(NSString*)description diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index edb6b54..655f7db 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -35,15 +35,8 @@ extern BOOL launchNextOpenIntoWindow; -(void) loadServer { - messagingCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - - void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if (handle) - { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); - dlclose(handle); - } + messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); [messagingCenter runServerOnCurrentThread]; diff --git a/Multiplexer.h b/Multiplexer.h index 77ec554..1d17cab 100644 --- a/Multiplexer.h +++ b/Multiplexer.h @@ -1,8 +1,8 @@ @class SBApplication; @interface MultiplexerExtension : NSObject -@property (nonatomic, retain) NSString *name; -@property (nonatomic, retain) NSString *multiplexerVersion; +@property (nonatomic, copy) NSString *name; +@property (nonatomic, copy) NSString *multiplexerVersion; @end @interface Multiplexer : NSObject { diff --git a/RAHostManager.xm b/RAHostManager.xm index 44bc820..7df7b17 100644 --- a/RAHostManager.xm +++ b/RAHostManager.xm @@ -22,6 +22,8 @@ if ([app respondsToSelector:@selector(mainScene)]) { + [[UIApplication sharedApplication] launchApplicationWithIdentifier:app.bundleIdentifier suspended:YES]; + FBScene *scene = [app mainScene]; FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; @@ -29,8 +31,7 @@ if (!settings) return nil; - [[UIApplication sharedApplication] launchApplicationWithIdentifier:app.bundleIdentifier suspended:YES]; - SET_BACKGROUNDED(settings, NO); + [settings setBackgrounded:NO]; [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index feaf2f2..6b76e4b 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -722,6 +722,7 @@ CGFloat startingY = -1; if (![app pid] || ![app mainScene]) { + LogDebug(@"no pid or scene; trying again"); overrideDisableForStatusBar = YES; [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:bundleIdentifier]; diff --git a/Reachability/UIKit.xm b/Reachability/UIKit.xm index 3cd2f93..6f5b1d8 100644 --- a/Reachability/UIKit.xm +++ b/Reachability/UIKit.xm @@ -1,11 +1,19 @@ #import "headers.h" #import "RAMessagingClient.h" +#import "RAKeyboardStateListener.h" BOOL allowClosingReachabilityNatively = NO; %hook UIApplication - (void)_deactivateReachability { + LogDebug(@"_deactivateReachability"); + + if ([RAKeyboardStateListener sharedInstance].visible) { + LogDebug(@"stopping reachability from closing due to keyboard"); + return; + } + if (!allowClosingReachabilityNatively) { LogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); diff --git a/Theming/RATheme.h b/Theming/RATheme.h index 0259708..4cdd506 100644 --- a/Theming/RATheme.h +++ b/Theming/RATheme.h @@ -2,8 +2,8 @@ @interface RATheme : NSObject -@property (nonatomic, retain) NSString *themeIdentifier; -@property (nonatomic, retain) NSString *themeName; +@property (nonatomic, copy) NSString *themeIdentifier; +@property (nonatomic, copy) NSString *themeName; // Backgrounder @property (nonatomic, retain) UIColor *backgroundingIndicatorBackgroundColor; @@ -56,4 +56,4 @@ @property (nonatomic, retain) UIColor *swipeOverDetachBarColor; @property (nonatomic, retain) UIColor *swipeOverDetachImageColor; -@end \ No newline at end of file +@end diff --git a/reachappsettings/Reachability.xm b/reachappsettings/Reachability.xm index 88fea7a..007fb6b 100644 --- a/reachappsettings/Reachability.xm +++ b/reachappsettings/Reachability.xm @@ -318,21 +318,20 @@ [_tableView reloadData]; } --(id)init +-(instancetype)init { - if (!(self = [super init])) return nil; + if (self = [super init]) { + CGRect bounds = [[UIScreen mainScreen] bounds]; - CGRect bounds = [[UIScreen mainScreen] bounds]; - - _dataSource = [[RAApplicationTableDataSource alloc] init]; - - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; - _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - _tableView.delegate = self; - _tableView.dataSource = _dataSource; - _dataSource.tableView = _tableView; - [self updateDataSource:nil]; + _dataSource = [[RAApplicationTableDataSource alloc] init]; + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; + _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _tableView.delegate = self; + _tableView.dataSource = _dataSource; + _dataSource.tableView = _tableView; + [self updateDataSource:nil]; + } return self; } diff --git a/update_status b/update_status index 3a69250..e1f2b74 100644 --- a/update_status +++ b/update_status @@ -35,6 +35,8 @@ Minor Things/Bugs to note: - Some say it causes serious lag (probably because logs werent disabled)? - Startup bug still isnt fixed (find cause / better fix) - General Code Cleanup, feels to messy RN +- Calling launchapplication:suspended in host manager fixes issues with multiple windows but causes ReachApp and NCApp to not properly load apps when they are suspended + (although doesnt happen always) Features to Add: - 3D Touch actions? diff --git a/widgets/Reachability/RADefaultWidgetSection.h b/widgets/Reachability/RADefaultWidgetSection.h index cac3d36..421a1bd 100644 --- a/widgets/Reachability/RADefaultWidgetSection.h +++ b/widgets/Reachability/RADefaultWidgetSection.h @@ -2,5 +2,5 @@ #import "RAWidget.h" @interface RADefaultWidgetSection : RAWidgetSection -+(id) sharedDefaultWidgetSection; -@end \ No newline at end of file ++(instancetype) sharedDefaultWidgetSection; +@end diff --git a/widgets/Reachability/RADefaultWidgetSection.mm b/widgets/Reachability/RADefaultWidgetSection.mm index 1a686db..a3aeb21 100644 --- a/widgets/Reachability/RADefaultWidgetSection.mm +++ b/widgets/Reachability/RADefaultWidgetSection.mm @@ -4,18 +4,18 @@ #import "headers.h" @implementation RADefaultWidgetSection -+(id) sharedDefaultWidgetSection ++(instancetype) sharedDefaultWidgetSection { SHARED_INSTANCE2(RADefaultWidgetSection, [[RAWidgetSectionManager sharedInstance] registerSection:sharedInstance]); } --(NSString*) displayName +-(NSString*) displayName { return LOCALIZE(@"WIDGETS"); } --(NSString*) identifier -{ +-(NSString*) identifier +{ return @"com.efrederickson.reachapp.widgets.sections.default"; } @end @@ -24,4 +24,4 @@ static __attribute__((constructor)) void cant_believe_i_forgot_this_before() { static id _widget = [RADefaultWidgetSection sharedDefaultWidgetSection]; [RAWidgetSectionManager.sharedInstance registerSection:_widget]; -} \ No newline at end of file +} diff --git a/widgets/Reachability/RAFavoriteAppsWidget.xm b/widgets/Reachability/RAFavoriteAppsWidget.xm index 93dde21..2326650 100644 --- a/widgets/Reachability/RAFavoriteAppsWidget.xm +++ b/widgets/Reachability/RAFavoriteAppsWidget.xm @@ -20,12 +20,12 @@ -(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size_ iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing { CGSize size = [%c(SBIconView) defaultIconSize]; - spacing = (frame.size.width - (iconsPerLine * size.width)) / (iconsPerLine + 0); + spacing = (frame.size.width - (iconsPerLine * size.width)) / iconsPerLine; NSString *currentBundleIdentifier = [[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; if (!currentBundleIdentifier) return nil; CGSize contentSize = CGSizeMake((spacing / 2.0), 10); - CGFloat interval = ((size.width + spacing) * iconsPerLine); + CGFloat interval = (size.width + spacing) * iconsPerLine; NSInteger intervalCount = 1; BOOL isTop = YES; BOOL hasSecondRow = NO; From cd0556604504d7c4a5f416011349374116a1eadd Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 10 Mar 2017 23:17:44 -0600 Subject: [PATCH 42/59] annoying launchApp:suspended bug --- Messaging/RAMessagingClient.xm | 11 +++++++++-- Messaging/RAMessagingServer.xm | 11 +++++++++-- RAHostManager.xm | 5 +++-- RAHostedAppView.xm | 5 ++++- Reachability/UIKit.xm | 7 ------- update_status | 3 +-- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 70f5bbe..636809d 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -59,8 +59,15 @@ extern BOOL allowClosingReachabilityNatively; _currentData = data; // Initialize data - serverCenter = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - rocketbootstrap_distributedmessagingcenter_apply(serverCenter); + serverCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + + void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); + if (handle) + { + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(serverCenter); + dlclose(handle); + } } -(void) alertUser:(NSString*)description diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index 655f7db..1ed4050 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -35,8 +35,15 @@ extern BOOL launchNextOpenIntoWindow; -(void) loadServer { - messagingCenter = [CPDistributedMessagingCenter centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); + messagingCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + + void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); + if (handle) + { + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); + dlclose(handle); + } [messagingCenter runServerOnCurrentThread]; diff --git a/RAHostManager.xm b/RAHostManager.xm index 7df7b17..b8c3ab3 100644 --- a/RAHostManager.xm +++ b/RAHostManager.xm @@ -31,11 +31,12 @@ if (!settings) return nil; - [settings setBackgrounded:NO]; + SET_BACKGROUNDED(settings, NO); [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; - return [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES]; + UIView *hostView = [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES]; + return hostView; } [RACompatibilitySystem showWarning:@"Unable to find valid method for accessing context host views"]; diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index 812ab43..d3f682e 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -125,6 +125,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; if (_isCurrentlyHosting) return; + _isCurrentlyHosting = YES; appsBeingHosted[app.bundleIdentifier] = [appsBeingHosted objectForKey:app.bundleIdentifier] ? @([appsBeingHosted[app.bundleIdentifier] intValue] + 1) : @1; @@ -225,7 +226,9 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; }, failedBlock); } else - [self _actualLoadApp]; + { + [self _actualLoadApp]; + } if (self.showSplashscreenInsteadOfSpinner) { diff --git a/Reachability/UIKit.xm b/Reachability/UIKit.xm index 6f5b1d8..eee650b 100644 --- a/Reachability/UIKit.xm +++ b/Reachability/UIKit.xm @@ -7,13 +7,6 @@ BOOL allowClosingReachabilityNatively = NO; %hook UIApplication - (void)_deactivateReachability { - LogDebug(@"_deactivateReachability"); - - if ([RAKeyboardStateListener sharedInstance].visible) { - LogDebug(@"stopping reachability from closing due to keyboard"); - return; - } - if (!allowClosingReachabilityNatively) { LogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); diff --git a/update_status b/update_status index e1f2b74..b658499 100644 --- a/update_status +++ b/update_status @@ -23,7 +23,6 @@ Bugs: - Individual app force foregrounding is broken when used in conjunction with auto (re)launch; - Invoking keyboard in reachapp closes view (I think reachability dismisses when using KB) - Showing NC with reachapp doesnt properly resize (not even sure if possible) -- Launching MC from activator gesture in app black screen - Foregrounding through activator broken (override gets removed when launching another app) - CC inhibitor still broken? @@ -31,7 +30,7 @@ Minor Things/Bugs to note: - RA favorites layout messed up - MC view invokes regardless if grabbing the grabber or not (was always like that?) - MC works but causes jittery animations; -- NCApp disappears on first load +- NCApp disappears on first load (see last issue) - Some say it causes serious lag (probably because logs werent disabled)? - Startup bug still isnt fixed (find cause / better fix) - General Code Cleanup, feels to messy RN From 57cfda8236a40b5a7c4422fd39b0ff74b5bbfcf6 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 13 Mar 2017 11:48:13 -0500 Subject: [PATCH 43/59] Fixed reachability resizing + more imports --- Backgrounding/IconIndicator.xm | 2 +- Backgrounding/Makefile | 2 +- Backgrounding/SpringBoard.xm | 3 +- .../SpringBoard_UIAppCustomBackgroundModes.xm | 4 +- Backgrounding/UnlimitedBackgrounding.xm | 4 +- GestureSupport/Hooks_iOS9.xm | 12 ++- Messaging/RAMessagingClient.xm | 2 +- Messaging/RAMessagingServer.xm | 2 +- MissionControl/AppSwitcher.xm | 2 +- RAControlCenterInhibitor.xm | 5 -- Reachability/Reachability.xm | 43 ++++------ Reachability/UIKit.xm | 1 - TutorialApp/multiplexertutorial/Tweak.xm | 4 +- headers.h | 84 ++----------------- update_status | 7 +- 15 files changed, 52 insertions(+), 125 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index d55b17d..0e80e9c 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -65,7 +65,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) [self RA_isIconIndicatorInhibited] || (!text || text.length == 0) || // OR info == RAIconIndicatorViewInfoNone (!self.icon || !self.icon.application || !self.icon.application.isRunning || ![RABackgrounder.sharedInstance shouldShowIndicatorForIdentifier:self.icon.application.bundleIdentifier]) || - [[%c(RASettings) sharedInstance] backgrounderEnabled] == NO) + ![[%c(RASettings) sharedInstance] backgrounderEnabled]) { [[self viewWithTag:9962] removeFromSuperview]; return; diff --git a/Backgrounding/Makefile b/Backgrounding/Makefile index 09b4244..7c3405e 100644 --- a/Backgrounding/Makefile +++ b/Backgrounding/Makefile @@ -1,6 +1,6 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -I../WindowedMultitasking/ -Wno-deprecated-declarations -O2 +CFLAGS = -I../ -I../Theming/ -Wno-deprecated-declarations -O2 CFLAGS += -fobjc-arc include $(THEOS)/makefiles/common.mk diff --git a/Backgrounding/SpringBoard.xm b/Backgrounding/SpringBoard.xm index dc01fb8..e7af68d 100644 --- a/Backgrounding/SpringBoard.xm +++ b/Backgrounding/SpringBoard.xm @@ -82,8 +82,9 @@ %hook FBUIApplicationWorkspaceScene -(void) host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 { - LogDebug(@"running host thing for: %@", arg1.identifier); [RABackgrounder.sharedInstance removeTemporaryOverrideForIdentifier:arg1.identifier]; + LogDebug(@"removeTemporaryOverrideForIdentifier: %@", arg1.identifier); + if (arg1 && arg1.identifier && arg2 && arg1.clientProcess) // FIX: sanity check to prevent NC App crash. untested/not working. { if (arg2.backgrounded) diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index c75ded9..baedc78 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -22,7 +22,7 @@ %hook BKSProcessAssertion - (id)initWithPID:(int)arg1 flags:(unsigned int)arg2 reason:(unsigned int)arg3 name:(unsafe_id)arg4 withHandler:(unsafe_id)arg5 { - if (!(arg3 == kProcessAssertionReasonViewServices) && // whitelist this to allow share menu to work + if (!(arg3 == BKSProcessAssertionReasonViewServices) && // whitelist this to allow share menu to work ![arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] && // whitelist iCleaner to prevent crash on open ![arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"] && // Whitelist filza to prevent iOS hang (?!) !IS_SPRINGBOARD) // FIXME: this is a hack that prevents SpringBoard from not starting @@ -36,7 +36,7 @@ if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) { - if ((arg3 >= kProcessAssertionReasonAudio && arg3 <= kProcessAssertionReasonVOiP)) // In most cases arg3 == 4 (finish task) + if ((arg3 >= BKSProcessAssertionReasonAudio && arg3 <= BKSProcessAssertionReasonVOiP)) // In most cases arg3 == 4 (finish task) { //NSLog(@"[ReachApp] blocking BKSProcessAssertion"); diff --git a/Backgrounding/UnlimitedBackgrounding.xm b/Backgrounding/UnlimitedBackgrounding.xm index 4037033..f77770d 100644 --- a/Backgrounding/UnlimitedBackgrounding.xm +++ b/Backgrounding/UnlimitedBackgrounding.xm @@ -13,8 +13,8 @@ BKSProcessAssertion *keepAlive$temp; SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:arg1.identifier]; keepAlive$temp = [[%c(BKSProcessAssertion) alloc] initWithPID:[app pid] - flags:(ProcessAssertionFlagPreventSuspend | ProcessAssertionFlagAllowIdleSleep | ProcessAssertionFlagPreventThrottleDownCPU | ProcessAssertionFlagWantsForegroundResourcePriority) - reason:kProcessAssertionReasonBackgroundUI + flags:(BKSProcessAssertionFlagPreventSuspend | BKSProcessAssertionFlagAllowIdleSleep | BKSProcessAssertionFlagPreventThrottleDownCPU | BKSProcessAssertionFlagWantsForegroundResourcePriority) + reason:BKSProcessAssertionReasonBackgroundUI name:@"reachapp" withHandler:^{ LogInfo(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index 230c625..4d8826a 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -138,7 +138,7 @@ void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEvent LogInfo(@"[ReachApp] (%f, %d) %@ -> %@", density, isTracking, NSStringFromCGPoint(location), NSStringFromCGPoint(rotatedLocation)); - if (isTracking == NO) + if (!isTracking) { for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) [recognizer incorporateTouchSampleAtLocation:location timestamp:CACurrentMediaTime() modifier:1 interfaceOrientation:interfaceOrientation forceState:0]; @@ -189,6 +189,8 @@ __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; if (IS_IOS_OR_OLDER(iOS_8_4)) return; + LogDebug(@"start of ctor"); + clientCreatePointer clientCreate; void *handle = dlopen(0, 9); *(void**)(&clientCreate) = dlsym(handle,"IOHIDEventSystemClientCreate"); @@ -196,8 +198,12 @@ __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; IOHIDEventSystemClientScheduleWithRunLoop(hidEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); IOHIDEventSystemClientRegisterEventCallback(hidEventSystem, (IOHIDEventSystemClientEventCallback)touch_event, NULL, NULL); + LogDebug(@"did iokit stuff") + class_addProtocol(%c(Hooks9$SBHandMotionExtractorReplacementByMultiplexer), @protocol(_UIScreenEdgePanRecognizerDelegate)); + LogDebug(@"added protocol"); + UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); gestureRecognizers = [[NSMutableSet alloc] initWithCapacity:edgeCount]; @@ -209,8 +215,12 @@ __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; [gestureRecognizers addObject:recognizer]; } + LogDebug(@"added gestureRecognizers") + %init; + LogDebug(@"inited ctor"); + __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer = [[Hooks9$SBHandMotionExtractorReplacementByMultiplexer alloc] init]; } diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 636809d..8d87326 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -59,7 +59,7 @@ extern BOOL allowClosingReachabilityNatively; _currentData = data; // Initialize data - serverCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + serverCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); if (handle) diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index 1ed4050..edb6b54 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -35,7 +35,7 @@ extern BOOL launchNextOpenIntoWindow; -(void) loadServer { - messagingCenter = [objc_getClass("CPDistributedMessagingCenter") centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + messagingCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); if (handle) diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index a9280f7..10340fb 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -546,7 +546,7 @@ BOOL toggleOrActivate = NO; } if (state == UIGestureRecognizerStateChanged) - fakeView.center = (CGPoint) { fakeView.center.x, origY + location.y }; + fakeView.center = CGPointMake(fakeView.center.x, origY + location.y); if (state == UIGestureRecognizerStateEnded) { //NSLog(@"[ReachApp] %@ + %@ = %@ > %@", NSStringFromCGPoint(fakeView.frame.origin), NSStringFromCGPoint(velocity), @(fakeView.frame.origin.y + velocity.y), @(-(UIScreen.mainScreen.bounds.size.height / 2))); diff --git a/RAControlCenterInhibitor.xm b/RAControlCenterInhibitor.xm index c2f4038..ad31bd9 100644 --- a/RAControlCenterInhibitor.xm +++ b/RAControlCenterInhibitor.xm @@ -35,9 +35,4 @@ BOOL overrideCC = NO; if (!overrideCC) %orig; } - -- (BOOL)inGrabberOnlyMode -{ - return overrideCC || %orig; -} %end diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 6b76e4b..69cbcb3 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -16,6 +16,7 @@ #import "RADesktopWindow.h" #import "RAMessagingServer.h" #import "RAAppSwitcherModelWrapper.h" +#import "RAKeyboardStateListener.h" /*FBWindowContextHostWrapperView*/ UIView *view = nil; NSString *lastBundleIdentifier = @""; @@ -36,7 +37,7 @@ CGFloat old_grabberCenterY = -1; BOOL wasEnabled = NO; -%group SBReachability +%group hooks %hook SBReachabilityManager +(BOOL)reachabilitySupported @@ -81,7 +82,7 @@ BOOL wasEnabled = NO; - (void)deactivateReachabilityModeForObserver:(unsafe_id)arg1 { - if (overrideDisableForStatusBar) + if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) return; %orig; @@ -114,7 +115,7 @@ BOOL wasEnabled = NO; - (void)_handleReachabilityDeactivated { - if (overrideDisableForStatusBar) + if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) return; %orig; @@ -122,7 +123,7 @@ BOOL wasEnabled = NO; - (void)_updateReachabilityModeActive:(_Bool)arg1 withRequestingObserver:(unsafe_id)arg2 { - if (overrideDisableForStatusBar) + if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) return; %orig; } @@ -145,10 +146,6 @@ BOOL wasEnabled = NO; %end -%end - -%group SBWorkspace - id SBWorkspace$sharedInstance; %hook SB_WORKSPACE_CLASS %new +(instancetype) sharedInstance @@ -169,7 +166,7 @@ id SBWorkspace$sharedInstance; - (void)_exitReachabilityModeWithCompletion:(unsafe_id)arg1 { - if (overrideDisableForStatusBar) + if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) return; %orig; @@ -177,7 +174,7 @@ id SBWorkspace$sharedInstance; - (void)handleReachabilityModeDeactivated { - if (overrideDisableForStatusBar) + if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) return; %orig; @@ -259,7 +256,7 @@ id SBWorkspace$sharedInstance; - (void)_disableReachabilityImmediately:(_Bool)arg1 { - if (overrideDisableForStatusBar) + if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) return; %orig; @@ -672,10 +669,13 @@ CGFloat startingY = -1; [RAMessagingServer.sharedInstance resizeApp:targetIdentifier toSize:CGSizeMake(width, height) completion:nil]; } - /* - if ([view isKindOfClass:[%c(FBWindowContextHostWrapperView) class]] == NO && [view isKindOfClass:[RAAppSliderProviderView class]] == NO) + + if (![view isKindOfClass:[%c(FBWindowContextHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_OLDER(iOS_8_4)) return; // only resize when the app is being shown. That way it's more like native Reachability - */ + + if (![view isKindOfClass:[%c(FBSceneHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_NEWER(iOS_9_0)) + return; // iOS 9 + [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:currentBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance rotateApp:lastBundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; @@ -869,22 +869,11 @@ CGFloat startingY = -1; } %end -%end - -%group SpringBoard - %hook SpringBoard - (UIInterfaceOrientation)activeInterfaceOrientation { return overrideOrientation ? UIInterfaceOrientationPortrait : %orig; } - -- (void)applicationDidFinishLaunching:(id)arg1 -{ - Class c = %c(SBMainWorkspace) ?: %c(SBWorkspace); - %init(SBWorkspace, SB_WORKSPACE_CLASS=c); - %orig; -} %end %end @@ -893,7 +882,7 @@ CGFloat startingY = -1; { IF_SPRINGBOARD { - %init(SBReachability); - %init(SpringBoard); + Class c = %c(SBMainWorkspace) ?: %c(SBWorkspace); + %init(hooks, SB_WORKSPACE_CLASS=c); } } diff --git a/Reachability/UIKit.xm b/Reachability/UIKit.xm index eee650b..3cd2f93 100644 --- a/Reachability/UIKit.xm +++ b/Reachability/UIKit.xm @@ -1,6 +1,5 @@ #import "headers.h" #import "RAMessagingClient.h" -#import "RAKeyboardStateListener.h" BOOL allowClosingReachabilityNatively = NO; diff --git a/TutorialApp/multiplexertutorial/Tweak.xm b/TutorialApp/multiplexertutorial/Tweak.xm index 41d6677..90d0bae 100644 --- a/TutorialApp/multiplexertutorial/Tweak.xm +++ b/TutorialApp/multiplexertutorial/Tweak.xm @@ -15,8 +15,8 @@ void open_settings(CFNotificationCenterRef a, void *b, CFStringRef c, const void %ctor { - if ([NSBundle.mainBundle.bundleIdentifier isEqual:@"com.apple.springboard"]) + if (IN_SPRINGBOARD) CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, open_settings, CFSTR("com.elijahandandrew.multiplexer.tutorial.open_settings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); else %init; -} \ No newline at end of file +} diff --git a/headers.h b/headers.h index 8e968bd..82a4757 100644 --- a/headers.h +++ b/headers.h @@ -18,8 +18,13 @@ #include #import #import +#import #import #import +#import +#import +#import +#import #import #import @@ -35,7 +40,7 @@ #import "RASBWorkspaceFetcher.h" #define GET_SBWORKSPACE [RASBWorkspaceFetcher getCurrentSBWorkspaceImplementationInstanceForThisOS] -#define GET_STATUSBAR_ORIENTATION (UIApplication.sharedApplication._accessibilityFrontMostApplication == nil ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) +#define GET_STATUSBAR_ORIENTATION (!UIApplication.sharedApplication._accessibilityFrontMostApplications ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) #if DEBUG #define LogDebug HBLogDebug @@ -72,18 +77,6 @@ extern BOOL $__IS_SPRINGBOARD; // ugh, i got so tired of typing this in by hand, plus it expands method declarations by a LOT. #define unsafe_id __unsafe_unretained id -#define kBGModeUnboundedTaskCompletion @"unboundedTaskCompletion" -#define kBGModeContinuous @"continuous" -#define kBGModeFetch @"fetch" -#define kBGModeRemoteNotification @"remote-notification" -#define kBGModeExternalAccessory @"external-accessory" -#define kBGModeVoIP @"voip" -#define kBGModeLocation @"location" -#define kBGModeAudio @"audio" -#define kBGModeBluetoothCentral @"bluetooth-central" -#define kBGModeBluetoothPeripheral @"bluetooth-peripheral" -// newsstand-content - #ifdef __cplusplus extern "C" { #endif @@ -745,9 +738,6 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { + (instancetype)eventWithName:(NSString *)label handler:(id)handler; @end -@interface FBSceneManager : NSObject -@end - @interface FBDisplayManager : NSObject +(id)sharedInstance; +(id)mainDisplay; @@ -835,8 +825,7 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { -(id)initWithLayoutSize:(int)layoutSize displayItems:(id)items; @end -@interface FBProcessManager : NSObject -+ (id)sharedInstance; +@interface FBProcessManager () - (void)_updateWorkspaceLockedState; - (void)applicationProcessWillLaunch:(id)arg1; - (void)noteProcess:(id)arg1 didUpdateState:(id)arg2; @@ -848,7 +837,6 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { - (id)createApplicationProcessForBundleID:(id)arg1 withExecutionContext:(id)arg2; - (id)createApplicationProcessForBundleID:(id)arg1; - (id)applicationProcessForPID:(int)arg1; -- (id)processForPID:(int)arg1; - (id)applicationProcessesForBundleIdentifier:(id)arg1; - (id)processesForBundleIdentifier:(id)arg1; - (id)allApplicationProcesses; @@ -860,51 +848,6 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { } @end -typedef NS_ENUM(NSUInteger, BKSProcessAssertionReason) -{ - kProcessAssertionReasonNone = 0, - kProcessAssertionReasonAudio = 1, - kProcessAssertionReasonLocation = 2, - kProcessAssertionReasonExternalAccessory = 3, - kProcessAssertionReasonFinishTask = 4, - kProcessAssertionReasonBluetooth = 5, - kProcessAssertionReasonNetworkAuthentication = 6, - kProcessAssertionReasonBackgroundUI = 7, - kProcessAssertionReasonInterAppAudioStreaming = 8, - kProcessAssertionReasonViewServices = 9, - kProcessAssertionReasonNewsstandDownload = 10, - kProcessAssertionReasonBackgroundDownload = 11, - kProcessAssertionReasonVOiP = 12, - kProcessAssertionReasonExtension = 13, - kProcessAssertionReasonContinuityStreams = 14, - // 15-9999 unknown - kProcessAssertionReasonActivation = 10000, - kProcessAssertionReasonSuspend = 10001, - kProcessAssertionReasonTransientWakeup = 10002, - kProcessAssertionReasonVOiP_PreiOS8 = 10003, - kProcessAssertionReasonPeriodicTask_iOS8 = kProcessAssertionReasonVOiP_PreiOS8, - kProcessAssertionReasonFinishTaskUnbounded = 10004, - kProcessAssertionReasonContinuous = 10005, - kProcessAssertionReasonBackgroundContentFetching = 10006, - kProcessAssertionReasonNotificationAction = 10007, - // 10008-49999 unknown - kProcessAssertionReasonFinishTaskAfterBackgroundContentFetching = 50000, - kProcessAssertionReasonFinishTaskAfterBackgroundDownload = 50001, - kProcessAssertionReasonFinishTaskAfterPeriodicTask = 50002, - kProcessAssertionReasonAFterNoficationAction = 50003, - // 50004+ unknown -}; - -typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) -{ - ProcessAssertionFlagNone = 0, - ProcessAssertionFlagPreventSuspend = 1 << 0, - ProcessAssertionFlagPreventThrottleDownCPU = 1 << 1, - ProcessAssertionFlagAllowIdleSleep = 1 << 2, - ProcessAssertionFlagWantsForegroundResourcePriority = 1 << 3 -}; - - @interface FBWindowContextHostManager - (id)hostViewForRequester:(id)arg1 enableAndOrderFront:(BOOL)arg2; - (void)resumeContextHosting; @@ -984,17 +927,9 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) @interface UIMutableApplicationSceneSettings : FBSMutableSceneSettings @end - -@interface FBProcess : NSObject -@end - -@interface FBScene +@interface FBScene () -(FBWindowContextHostManager*) contextHostManager; -@property(readonly, retain, nonatomic) FBSMutableSceneSettings *mutableSettings; // @synthesize mutableSettings=_mutableSettings; - (void)updateSettings:(id)arg1 withTransitionContext:(id)arg2; -- (void)_applyMutableSettings:(id)arg1 withTransitionContext:(id)arg2 completion:(id)arg3; -@property (nonatomic, readonly) NSString *identifier; -@property (nonatomic, readonly, retain) FBProcess *clientProcess; @end @interface SBApplication () @@ -1052,8 +987,7 @@ typedef NS_ENUM(NSUInteger, ProcessAssertionFlags) - (void)minimize; @end -@interface BKSProcessAssertion -- (id)initWithPID:(int)arg1 flags:(unsigned int)arg2 reason:(unsigned int)arg3 name:(id)arg4 withHandler:(id)arg5; +@interface BKSProcessAssertion () - (id)initWithBundleIdentifier:(id)arg1 flags:(unsigned int)arg2 reason:(unsigned int)arg3 name:(id)arg4 withHandler:(id)arg5; - (void)invalidate; @property(readonly, nonatomic) BOOL valid; diff --git a/update_status b/update_status index b658499..d6a7c1c 100644 --- a/update_status +++ b/update_status @@ -24,18 +24,17 @@ Bugs: - Invoking keyboard in reachapp closes view (I think reachability dismisses when using KB) - Showing NC with reachapp doesnt properly resize (not even sure if possible) - Foregrounding through activator broken (override gets removed when launching another app) -- CC inhibitor still broken? +- CC inhibitor not reliable on 9.x+? Minor Things/Bugs to note: -- RA favorites layout messed up - MC view invokes regardless if grabbing the grabber or not (was always like that?) - MC works but causes jittery animations; - NCApp disappears on first load (see last issue) - Some say it causes serious lag (probably because logs werent disabled)? -- Startup bug still isnt fixed (find cause / better fix) +- Startup bug still isnt fixed (apparently caused by gesture support?) - General Code Cleanup, feels to messy RN - Calling launchapplication:suspended in host manager fixes issues with multiple windows but causes ReachApp and NCApp to not properly load apps when they are suspended - (although doesnt happen always) + (doesnt seem to be an issue anymore) Features to Add: - 3D Touch actions? From c4a3947440cfc24048931175af42e3fc9cea77eb Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 13 Mar 2017 12:07:58 -0500 Subject: [PATCH 44/59] Using built in Anemone header --- Anemone.h | 22 ---------------------- Backgrounding/IconIndicator.xm | 6 +++--- 2 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 Anemone.h diff --git a/Anemone.h b/Anemone.h deleted file mode 100644 index 1a781b5..0000000 --- a/Anemone.h +++ /dev/null @@ -1,22 +0,0 @@ -// From: slack logs -// Usage to get icon badge: -// -// @interface SBIconBadgeView -// + (SBIconAccessoryImage *)_checkoutBackgroundImage; -// @end -// -// [UIImage imageNamed:@"SBBadgeBG.png"] -// -// Notes: -// Can convert to UIColor with +[UIColor colorWithPatternImage:] -// Needs tested. Heard bad reports about colorWithPatternImage: and memory usage -// - -@interface ANEMSettingsManager : NSObject { - NSArray *_themeSettings; -} -+ (instancetype)sharedManager; -- (NSArray *)themeSettings; -@end - -#define HAS_ANEMONE (objc_getClass("ANEMSettingsManager") != nil) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 0e80e9c..5833c85 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -3,7 +3,7 @@ #import #import #import "ColorBadges.h" -#import "Anemone.h" +#import NSMutableDictionary *indicatorStateDict = [[[NSMutableDictionary alloc] init] retain]; #define SET_INFO_(x, y) indicatorStateDict[x] = [NSNumber numberWithInt:y] @@ -124,7 +124,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) badge.textColor = THEMED(backgroundingIndicatorTextColor); } UIImage *bgImage = [%c(SBIconBadgeView) _checkoutBackgroundImage]; - if (HAS_ANEMONE && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) + if (%c(ANEMSettingsManager) && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) { badge.backgroundColor = [UIColor colorWithPatternImage:bgImage]; } @@ -137,7 +137,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) badge.layer.cornerRadius = MAX(badge.frame.size.width, badge.frame.size.height) / 2.0; } - if (HAS_ANEMONE && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) + if (%c(ANEMSettingsManager) && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) { UIImageView *textImageView = (UIImageView*)[badge viewWithTag:42]; if (!textImageView) From 56f99b963013009c99bc41cce4a0132c5a3c0921 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 13 Mar 2017 16:13:22 -0500 Subject: [PATCH 45/59] changed objc_getAssociatedObject with %property --- Backgrounding/IconIndicator.xm | 12 ++++-------- BioLockdown.h | 2 +- RAHostedAppView.xm | 1 + UIKit.xm | 5 +++-- headers.h | 7 ++++++- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 5833c85..3f9ccaf 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -41,6 +41,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) } %hook SBIconView +%property (nonatomic, assign) BOOL RA_isIconIndicatorInhibited; %new -(void) RA_updateIndicatorView:(RAIconIndicatorViewInfo)info { @autoreleasepool { @@ -173,7 +174,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) %new -(void) RA_setIsIconIndicatorInhibited:(BOOL)value showAgainImmediately:(BOOL)value2 { - objc_setAssociatedObject(self, @selector(RA_isIconIndicatorInhibited), value ? (id)kCFBooleanTrue : (id)kCFBooleanFalse, OBJC_ASSOCIATION_ASSIGN); + self.RA_isIconIndicatorInhibited = value; if (value2 || value) [self RA_updateIndicatorViewWithExistingInfo]; } @@ -192,11 +193,6 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) %orig; } -%new -(BOOL) RA_isIconIndicatorInhibited -{ - return [objc_getAssociatedObject(self, @selector(RA_isIconIndicatorInhibited)) boolValue]; -} - -(void) layoutSubviews { %orig; @@ -281,7 +277,7 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) BOOL native = (info & RAIconIndicatorViewInfoNative); if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; - if ([item customViewClass] == nil) { + if (![item customViewClass] { item.customViewClass = @"RAAppIconStatusBarIconView"; } item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; @@ -294,7 +290,7 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) BOOL native = (info & RAIconIndicatorViewInfoNative); if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; - if ([item customViewClass] == nil) { + if (![item customViewClass]) { item.customViewClass = @"RAAppIconStatusBarIconView"; } item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; diff --git a/BioLockdown.h b/BioLockdown.h index 5b0c0ff..78198c3 100644 --- a/BioLockdown.h +++ b/BioLockdown.h @@ -29,4 +29,4 @@ __attribute__((visibility("hidden"))) [[objc_getClass("BioLockdownController") sharedController] authenticateForIdentifier:ident actionDescription:LOCALIZE(@"BIOLOCKDOWN_AUTH_DESCRIPTION") completion:success failure:failure_]; \ } \ else \ - success() \ No newline at end of file + success() diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index d3f682e..f72ad80 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -43,6 +43,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; self.renderWallpaper = NO; self.backgroundColor = [UIColor clearColor]; } + return self; } diff --git a/UIKit.xm b/UIKit.xm index 8621c02..c3d130e 100644 --- a/UIKit.xm +++ b/UIKit.xm @@ -73,6 +73,7 @@ static Class $memorized$UITextEffectsWindow$class; %end %hook UIApplication +%property (nonatomic, assign) BOOL RA_networkActivity; -(void) applicationDidResume { %orig; @@ -205,7 +206,7 @@ static Class $memorized$UITextEffectsWindow$class; -(BOOL) isNetworkActivityIndicatorVisible { if ([RAMessagingClient.sharedInstance isBeingHosted]) - return [objc_getAssociatedObject(self, @selector(RA_networkActivity)) boolValue]; + return self.RA_networkActivity; else return %orig; } @@ -215,7 +216,7 @@ static Class $memorized$UITextEffectsWindow$class; %orig(arg1); if ([RAMessagingClient.sharedInstance isBeingHosted]) { - objc_setAssociatedObject(self, @selector(RA_networkActivity), @(arg1), OBJC_ASSOCIATION_RETAIN_NONATOMIC); + self.RA_networkActivity = arg1; StatusBarData *data = [UIStatusBarServer getStatusBarData]; data->itemIsEnabled[26] = arg1; // 26 = activity indicator diff --git a/headers.h b/headers.h index 82a4757..eaef78d 100644 --- a/headers.h +++ b/headers.h @@ -40,7 +40,7 @@ #import "RASBWorkspaceFetcher.h" #define GET_SBWORKSPACE [RASBWorkspaceFetcher getCurrentSBWorkspaceImplementationInstanceForThisOS] -#define GET_STATUSBAR_ORIENTATION (!UIApplication.sharedApplication._accessibilityFrontMostApplications ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) +#define GET_STATUSBAR_ORIENTATION (UIApplication.sharedApplication._accessibilityFrontMostApplication == nil ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) #if DEBUG #define LogDebug HBLogDebug @@ -1059,6 +1059,7 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @end @interface UIApplication () +@property (nonatomic) BOOL RA_networkActivity; - (void)_handleKeyUIEvent:(id)arg1; -(UIStatusBar*) statusBar; - (id)_mainScene; @@ -1349,6 +1350,10 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @end +@interface SBIconView () +@property (nonatomic, assign) BOOL RA_isIconIndicatorInhibited; +@end + @class NSMapTable; @interface SBIconViewMap : NSObject { From 7c05f82285bb9c69171ac08fcdf1142def2a5c93 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 13 Mar 2017 20:37:29 -0500 Subject: [PATCH 46/59] Somehow reduced lag by the fonts? --- Backgrounding/IconIndicator.xm | 2 +- MissionControl/RAMissionControlManager.xm | 4 ++-- MissionControl/RAMissionControlWindow.xm | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 3f9ccaf..05680d0 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -277,7 +277,7 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) BOOL native = (info & RAIconIndicatorViewInfoNative); if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; - if (![item customViewClass] { + if (![item customViewClass]) { item.customViewClass = @"RAAppIconStatusBarIconView"; } item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; diff --git a/MissionControl/RAMissionControlManager.xm b/MissionControl/RAMissionControlManager.xm index cbb36b4..bc1925e 100644 --- a/MissionControl/RAMissionControlManager.xm +++ b/MissionControl/RAMissionControlManager.xm @@ -139,8 +139,8 @@ CGRect swappedForOrientation2(CGRect in) { if (originalAppView) originalAppView.frame = originalAppFrame; - window.hidden = YES; - window = nil; + window.hidden = YES; + window = nil; } window = [[RAMissionControlWindow alloc] initWithFrame:UIScreen.mainScreen.RA_interfaceOrientedBounds]; diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index 6ecfa00..8e410e4 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -78,7 +78,7 @@ else { desktopLabel = [[UILabel alloc] initWithFrame:CGRectMake(panePadding, y, self.frame.size.width - 20, 25)]; - desktopLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + desktopLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; desktopLabel.textColor = UIColor.whiteColor; desktopLabel.text = LOCALIZE(@"DESKTOPS"); [self addSubview:desktopLabel]; @@ -192,7 +192,7 @@ else { windowedLabel = [[UILabel alloc] initWithFrame:CGRectMake(panePadding, y, self.frame.size.width - 20, 25)]; - windowedLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + windowedLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; windowedLabel.textColor = UIColor.whiteColor; windowedLabel.text = LOCALIZE(@"ON_THIS_DESKTOP"); [self addSubview:windowedLabel]; @@ -232,7 +232,7 @@ { UILabel *emptyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (windowedAppScrollView.frame.size.height - 30) / 2, windowedAppScrollView.frame.size.width, 30)]; emptyLabel.textAlignment = NSTextAlignmentCenter; - emptyLabel.font = [UIFont fontWithName:@"Helvetica" size:25]; + emptyLabel.font = [UIFont systemFontOfSize:25]; emptyLabel.text = LOCALIZE(@"NO_APPS"); emptyLabel.textColor = [UIColor whiteColor]; emptyLabel.alpha = 0.7; @@ -250,7 +250,7 @@ { windowedKillAllButton = [UIButton buttonWithType:UIButtonTypeCustom]; [windowedKillAllButton setTitle:LOCALIZE(@"KILL_ALL") forState:UIControlStateNormal]; - windowedKillAllButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + windowedKillAllButton.titleLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; windowedKillAllButton.titleLabel.textColor = [UIColor whiteColor]; [windowedKillAllButton sizeToFit]; windowedKillAllButton.frame = CGRectMake(self.frame.size.width - panePadding - windowedKillAllButton.frame.size.width, y, windowedKillAllButton.frame.size.width, windowedKillAllButton.frame.size.height); @@ -273,7 +273,7 @@ else { otherLabel = [[UILabel alloc] initWithFrame:CGRectMake(panePadding, y, self.frame.size.width - 20, 25)]; - otherLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + otherLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; otherLabel.textColor = UIColor.whiteColor; otherLabel.text = LOCALIZE(@"RUNNING_ELSEWHERE"); [self addSubview:otherLabel]; @@ -311,7 +311,7 @@ { UILabel *emptyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (windowedAppScrollView.frame.size.height - 30) / 2, windowedAppScrollView.frame.size.width, 30)]; emptyLabel.textAlignment = NSTextAlignmentCenter; - emptyLabel.font = [UIFont fontWithName:@"Helvetica" size:25]; + emptyLabel.font = [UIFont systemFontOfSize:25]; emptyLabel.text = LOCALIZE(@"NO_APPS"); emptyLabel.textColor = [UIColor whiteColor]; emptyLabel.alpha = 0.7; @@ -329,7 +329,7 @@ { otherKillAllButton = [UIButton buttonWithType:UIButtonTypeCustom]; [otherKillAllButton setTitle:LOCALIZE(@"KILL_ALL") forState:UIControlStateNormal]; - otherKillAllButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14]; + otherKillAllButton.titleLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; otherKillAllButton.titleLabel.textColor = [UIColor whiteColor]; [otherKillAllButton sizeToFit]; otherKillAllButton.frame = CGRectMake(self.frame.size.width - panePadding - otherKillAllButton.frame.size.width, y, otherKillAllButton.frame.size.width, otherKillAllButton.frame.size.height); @@ -458,9 +458,9 @@ //CGPoint center = [gesture translationInView:draggedView]; //center.x += initialCenter.x; //center.y += initialCenter.y; - CGPoint center = draggedView.center; - center.x += point.x - lastPoint.x; - center.y += point.y - lastPoint.y; + CGPoint center = draggedView.center; + center.x += point.x - lastPoint.x; + center.y += point.y - lastPoint.y; BOOL didKill = NO; From 0d5377147c0807bdc3649a3407d366c044891e62 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Mon, 13 Mar 2017 21:51:13 -0500 Subject: [PATCH 47/59] Replaced alertviews with alertController in prefs --- Backgrounding/IconIndicator.xm | 1 + Debugging/Core.xm | 2 +- RASettings.mm | 22 ++++----- SwipeOver/RASwipeOverManager.xm | 4 +- .../BackgroundPerAppDetailsController.xm | 44 ++++++++--------- reachappsettings/BackgrounderPerApp.xm | 2 +- reachappsettings/BackgrounderSettings.xm | 20 +++++--- reachappsettings/MissionControlSettings.xm | 16 +++++-- reachappsettings/NCApp.xm | 27 ++++++----- reachappsettings/RAHeaderView.mm | 4 +- reachappsettings/RAListItemsController.xm | 2 +- reachappsettings/ReachAppSettings.mm | 26 +++++----- reachappsettings/Reachability.xm | 4 +- reachappsettings/WindowedMultitasking.xm | 48 ++++++++++++++----- update_status | 8 +--- 15 files changed, 138 insertions(+), 92 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 05680d0..b914f9f 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -268,6 +268,7 @@ Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): *** Terminating a FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) */ +//really need to optimize %new -(void) RA_addStatusBarIconForSelfIfOneDoesNotExist { if (%c(LSStatusBarItem) && ![lsbitems objectForKey:self.bundleIdentifier] && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) { diff --git a/Debugging/Core.xm b/Debugging/Core.xm index 317844e..994d0be 100644 --- a/Debugging/Core.xm +++ b/Debugging/Core.xm @@ -11,7 +11,7 @@ { LogDebug(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); - NSArray * symbols = [NSThread callStackSymbols]; + NSArray *symbols = [NSThread callStackSymbols]; LogDebug(@"[ReachApp] Obtained %zd stack frames:\n", symbols.count); for (NSString *symbol in symbols) { diff --git a/RASettings.mm b/RASettings.mm index 2f586a6..f7aaeef 100644 --- a/RASettings.mm +++ b/RASettings.mm @@ -4,7 +4,7 @@ #import "RAThemeManager.h" #import "RANCViewController.h" -#define BOOL(key, default) ([_settings objectForKey:key] != nil ? [_settings[key] boolValue] : default) +#define BOOL(key, default) ([_settings objectForKey:key] ? [_settings[key] boolValue] : default) NSCache *backgrounderSettingsCache = [NSCache new]; @@ -325,16 +325,16 @@ -(NSDictionary*) _createAndCacheBackgrounderSettingsForIdentifier:(NSString*)ide ret[@"showStatusBarIcon"] = _settings[[NSString stringWithFormat:@"backgrounder-%@-showStatusBarIcon",identifier]] ?: @YES; ret[@"backgroundModes"] = [NSMutableDictionary dictionary]; - ret[@"backgroundModes"][kBGModeUnboundedTaskCompletion] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeUnboundedTaskCompletion]] ?: @NO; - ret[@"backgroundModes"][kBGModeContinuous] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeContinuous]] ?: @NO; - ret[@"backgroundModes"][kBGModeFetch] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeFetch]] ?: @NO; - ret[@"backgroundModes"][kBGModeRemoteNotification] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeRemoteNotification]] ?: @NO; - ret[@"backgroundModes"][kBGModeExternalAccessory] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeExternalAccessory]] ?: @NO; - ret[@"backgroundModes"][kBGModeVoIP] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeVoIP]] ?: @NO; - ret[@"backgroundModes"][kBGModeLocation] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeLocation]] ?: @NO; - ret[@"backgroundModes"][kBGModeAudio] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeAudio]] ?: @NO; - ret[@"backgroundModes"][kBGModeBluetoothCentral] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeBluetoothCentral]] ?: @NO; - ret[@"backgroundModes"][kBGModeBluetoothPeripheral] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBGModeBluetoothPeripheral]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeUnboundedTaskCompletion] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeUnboundedTaskCompletion]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeContinuous] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeContinuous]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeFetch] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeFetch]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeRemoteNotification] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeRemoteNotification]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeExternalAccessory] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeExternalAccessory]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeVoIP] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeVoIP]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeLocation] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeLocation]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeAudio] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeAudio]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeBluetoothCentral] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeBluetoothCentral]] ?: @NO; + ret[@"backgroundModes"][kBKSBackgroundModeBluetoothPeripheral] = _settings[[NSString stringWithFormat:@"backgrounder-%@-backgroundmodes-%@",identifier,kBKSBackgroundModeBluetoothPeripheral]] ?: @NO; [backgrounderSettingsCache setObject:ret forKey:identifier]; diff --git a/SwipeOver/RASwipeOverManager.xm b/SwipeOver/RASwipeOverManager.xm index c1871b5..02429bc 100644 --- a/SwipeOver/RASwipeOverManager.xm +++ b/SwipeOver/RASwipeOverManager.xm @@ -109,7 +109,7 @@ extern int rotationDegsForOrientation(int o); else { NSMutableArray *bundleIdentifiers = [[%c(RAAppSwitcherModelWrapper) appSwitcherAppIdentiferList] mutableCopy]; - while (scene == nil && bundleIdentifiers.count > 0) + while (!scene && bundleIdentifiers.count > 0) { identifier = bundleIdentifiers[0]; @@ -136,7 +136,7 @@ extern int rotationDegsForOrientation(int o); RAHostedAppView *view = [[%c(RAHostedAppView) alloc] initWithBundleIdentifier:identifier]; view.autosizesApp = NO; - if (overlayWindow.isHidingUnderlyingApp == NO) + if (!overlayWindow.isHidingUnderlyingApp) view.autosizesApp = YES; view.shouldUseExternalKeyboard = YES; view.allowHidingStatusBar = NO; diff --git a/reachappsettings/BackgroundPerAppDetailsController.xm b/reachappsettings/BackgroundPerAppDetailsController.xm index c48f825..b44c8cb 100644 --- a/reachappsettings/BackgroundPerAppDetailsController.xm +++ b/reachappsettings/BackgroundPerAppDetailsController.xm @@ -6,7 +6,7 @@ extern void RA_BGAppsControllerNeedsToReload(); @implementation RABGPerAppDetailsController --(id)initWithAppName:(NSString*)appName identifier:(NSString*)identifier +-(instancetype)initWithAppName:(NSString*)appName identifier:(NSString*)identifier { _appName = appName; _identifier = identifier; @@ -97,72 +97,72 @@ extern void RA_BGAppsControllerNeedsToReload(); @{ @"cell": @"PSSwitchCell", @"label": @"Unbounded Task Completion", - @"key": kBGModeUnboundedTaskCompletion, + @"key": kBKSBackgroundModeUnboundedTaskCompletion, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeUnboundedTaskCompletion withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeUnboundedTaskCompletion withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"Continuous", - @"key": kBGModeContinuous, + @"key": kBKSBackgroundModeContinuous, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeContinuous withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeContinuous withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"Fetch", - @"key": kBGModeFetch, + @"key": kBKSBackgroundModeFetch, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeFetch withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeFetch withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"Remote Notification", - @"key": kBGModeRemoteNotification, + @"key": kBKSBackgroundModeRemoteNotification, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeRemoteNotification withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeRemoteNotification withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"External Accessory", - @"key": kBGModeExternalAccessory, + @"key": kBKSBackgroundModeExternalAccessory, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeExternalAccessory withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeExternalAccessory withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"VoIP", - @"key": kBGModeVoIP, + @"key": kBKSBackgroundModeVoIP, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeVoIP withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeVoIP withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"Location", - @"key": kBGModeLocation, + @"key": kBKSBackgroundModeLocation, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeLocation withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeLocation withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"Audio", - @"key": kBGModeAudio, + @"key": kBKSBackgroundModeAudio, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeAudio withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeAudio withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"Bluetooth (Central)", - @"key": kBGModeBluetoothCentral, + @"key": kBKSBackgroundModeBluetoothCentral, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeBluetoothCentral withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeBluetoothCentral withAppInfo:bgModes], }, @{ @"cell": @"PSSwitchCell", @"label": @"Bluetooth (Peripheral)", - @"key": kBGModeBluetoothPeripheral, + @"key": kBKSBackgroundModeBluetoothPeripheral, @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBGModeBluetoothPeripheral withAppInfo:bgModes], + @"default": [self isBackgroundModeActive:kBKSBackgroundModeBluetoothPeripheral withAppInfo:bgModes], }, @{ @"footerText": @"Description of icon letters: \n\ @@ -254,6 +254,6 @@ The status bar icon is simply the app icon.", }, } NSString *key = [specifier propertyForKey:@"prefix"] ? [NSString stringWithFormat:@"backgrounder-%@-%@-%@",_identifier,[specifier propertyForKey:@"prefix"],[specifier propertyForKey:@"key"]] : [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,[specifier propertyForKey:@"key"]]; - return [_settings objectForKey:key] == nil ? [specifier propertyForKey:@"default"] : _settings[key]; + return ![_settings objectForKey:key] ? [specifier propertyForKey:@"default"] : _settings[key]; } @end diff --git a/reachappsettings/BackgrounderPerApp.xm b/reachappsettings/BackgrounderPerApp.xm index 8ce6e1a..6a8dec6 100644 --- a/reachappsettings/BackgrounderPerApp.xm +++ b/reachappsettings/BackgrounderPerApp.xm @@ -130,7 +130,7 @@ void RA_BGAppsControllerNeedsToReload() [_tableView reloadData]; } --(id)init +-(instancetype)init { if (!(self = [super init])) return nil; diff --git a/reachappsettings/BackgrounderSettings.xm b/reachappsettings/BackgrounderSettings.xm index 8675dd1..f0837fa 100644 --- a/reachappsettings/BackgrounderSettings.xm +++ b/reachappsettings/BackgrounderSettings.xm @@ -130,22 +130,30 @@ -(void) showActivatorAction { - id activator = objc_getClass("LAListenerSettingsViewController"); + id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") + message:@"Activator must be installed to use this feature." + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + }]; + + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } else { - LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.backgrounder.togglemode"; [self.rootController pushController:vc animate:YES]; } } @end -@interface RABackgrounderIconIndicatorOptionsListController : SKTintedListController +@interface RABackgrounderIconIndicatorOptionsListController : SKTintedListController @end @implementation RABackgrounderIconIndicatorOptionsListController @@ -174,7 +182,7 @@ } @end -@interface RABackgrounderStatusbarOptionsListController : SKTintedListController +@interface RABackgrounderStatusbarOptionsListController : SKTintedListController @end @implementation RABackgrounderStatusbarOptionsListController diff --git a/reachappsettings/MissionControlSettings.xm b/reachappsettings/MissionControlSettings.xm index 0e57764..ecbe386 100644 --- a/reachappsettings/MissionControlSettings.xm +++ b/reachappsettings/MissionControlSettings.xm @@ -122,15 +122,23 @@ } -(void) showActivatorAction { - id activator = objc_getClass("LAListenerSettingsViewController"); + id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") + message:@"Activator must be installed to use this feature." + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + }]; + + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } else { - LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.missioncontrol.activatorlistener"; [self.rootController pushController:vc animate:YES]; } diff --git a/reachappsettings/NCApp.xm b/reachappsettings/NCApp.xm index a7a0b41..0c47c27 100644 --- a/reachappsettings/NCApp.xm +++ b/reachappsettings/NCApp.xm @@ -29,7 +29,7 @@ - (void)sectionRequestedSectionReload:(id)section animated:(BOOL)animated; @end -@interface ReachAppNCAppSettingsListController: SKTintedListController +@interface ReachAppNCAppSettingsListController: SKTintedListController @end @implementation ReachAppNCAppSettingsListController @@ -164,7 +164,7 @@ [_tableView reloadData]; } --(id)init +-(instancetype)init { if (!(self = [super init])) return nil; @@ -208,15 +208,20 @@ CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); }); - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Quick Access" message:@"A respring is required to apply changes. Would you like to respring now?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes",nil]; - [alert show]; -} - -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex -{ - if (buttonIndex == 1) - { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Quick Access" + message:@"A respring is required to apply changes. Would you like to respring now?" + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *respringAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); - } + }]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action) { + }]; + + [alert addAction:respringAction]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } @end diff --git a/reachappsettings/RAHeaderView.mm b/reachappsettings/RAHeaderView.mm index be2d78a..0427582 100644 --- a/reachappsettings/RAHeaderView.mm +++ b/reachappsettings/RAHeaderView.mm @@ -20,12 +20,12 @@ - (UIImage *)tintedImageWithColor:(UIColor *)tintColor blendingMode:(CGBlendMode @end @implementation RAHeaderView -+ (Class)layerClass ++ (Class)layerClass { return [CAGradientLayer class]; } --(id) initWithFrame:(CGRect)frame +-(instancetype) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { diff --git a/reachappsettings/RAListItemsController.xm b/reachappsettings/RAListItemsController.xm index 6a32d30..43d9368 100644 --- a/reachappsettings/RAListItemsController.xm +++ b/reachappsettings/RAListItemsController.xm @@ -62,7 +62,7 @@ [super tableView:arg1 didSelectRowAtIndexPath:arg2]; PSTableCell *cell = [self tableView:arg1 cellForRowAtIndexPath:arg2]; - if ([cell.specifier propertyForKey:@"isTheming"] != nil) + if ([cell.specifier propertyForKey:@"isTheming"]) { [self openThemingDocumentation]; } diff --git a/reachappsettings/ReachAppSettings.mm b/reachappsettings/ReachAppSettings.mm index 2b82721..89535dc 100644 --- a/reachappsettings/ReachAppSettings.mm +++ b/reachappsettings/ReachAppSettings.mm @@ -202,17 +202,21 @@ -(NSArray*) customSpecifiers -(void) resetData { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Multiplexer" message:@"Please confirm your choice to reset all settings & respring." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; - [alert addButtonWithTitle:@"Yes"]; - [alert show]; -} - -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex -{ - if (buttonIndex == 1) - { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") + message:@"Please confirm your choice to reset all settings & respring.." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.resetSettings"), nil, nil, YES); - } + }]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action) { + }]; + + [alert addAction:resetAction]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } -(void) openThemingDocumentation @@ -278,7 +282,7 @@ -(BOOL) getEnabled return YES; } - return [_settings objectForKey:@"enabled"] == nil ? YES : [_settings[@"enabled"] boolValue]; + return ![_settings objectForKey:@"enabled"] ? YES : [_settings[@"enabled"] boolValue]; } -(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{ diff --git a/reachappsettings/Reachability.xm b/reachappsettings/Reachability.xm index 007fb6b..2795da5 100644 --- a/reachappsettings/Reachability.xm +++ b/reachappsettings/Reachability.xm @@ -175,7 +175,7 @@ } @end -@interface RAAppChooserOptionsListController : SKTintedListController +@interface RAAppChooserOptionsListController : SKTintedListController @end @implementation RAAppChooserOptionsListController @@ -247,7 +247,7 @@ @end @implementation RASwitchCell --(id)initWithStyle:(int)arg1 reuseIdentifier:(id)arg2 specifier:(id)arg3 { //init method +-(instancetype)initWithStyle:(int)arg1 reuseIdentifier:(id)arg2 specifier:(id)arg3 { //init method self = [super initWithStyle:arg1 reuseIdentifier:arg2 specifier:arg3]; //call the super init method if (self) { [((UISwitch *)[self control]) setOnTintColor:[UIColor redColor]]; //change the switch color diff --git a/reachappsettings/WindowedMultitasking.xm b/reachappsettings/WindowedMultitasking.xm index 6d57d77..d6510e1 100644 --- a/reachappsettings/WindowedMultitasking.xm +++ b/reachappsettings/WindowedMultitasking.xm @@ -193,15 +193,23 @@ -(void) showActivatorAction { - id activator = objc_getClass("LAListenerSettingsViewController"); + id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") + message:@"Activator must be installed to use this feature." + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + }]; + + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } else { - LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.sortWindows"; [self.rootController pushController:vc animate:YES]; } @@ -209,15 +217,23 @@ -(void) showActivatorAction2 { - id activator = objc_getClass("LAListenerSettingsViewController"); + id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") + message:@"Activator must be installed to use this feature." + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + }]; + + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } else { - LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"; [self.rootController pushController:vc animate:YES]; } @@ -225,15 +241,23 @@ -(void) showActivatorAction3 { - id activator = objc_getClass("LAListenerSettingsViewController"); + id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") + message:@"Activator must be installed to use this feature." + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + }]; + + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } else { - LAListenerSettingsViewController *vc = [[objc_getClass("LAListenerSettingsViewController") alloc] init]; + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.createWindow"; [self.rootController pushController:vc animate:YES]; } diff --git a/update_status b/update_status index d6a7c1c..adc2533 100644 --- a/update_status +++ b/update_status @@ -27,14 +27,10 @@ Bugs: - CC inhibitor not reliable on 9.x+? Minor Things/Bugs to note: -- MC view invokes regardless if grabbing the grabber or not (was always like that?) -- MC works but causes jittery animations; -- NCApp disappears on first load (see last issue) -- Some say it causes serious lag (probably because logs werent disabled)? +- MC works but causes jittery animations (not as much as before) +- Some say it causes serious lag (probably because logs werent disabled/due to MC)? - Startup bug still isnt fixed (apparently caused by gesture support?) - General Code Cleanup, feels to messy RN -- Calling launchapplication:suspended in host manager fixes issues with multiple windows but causes ReachApp and NCApp to not properly load apps when they are suspended - (doesnt seem to be an issue anymore) Features to Add: - 3D Touch actions? From 5fe9891c1a26899041e0d498980db19b18de4bb4 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Tue, 14 Mar 2017 14:58:27 -0500 Subject: [PATCH 48/59] More style changes --- Backgrounding/IconIndicator.xm | 49 +++++++++---------- Backgrounding/RABackgrounder.xm | 36 +++++++------- .../SpringBoard_UIAppCustomBackgroundModes.xm | 9 ++-- MissionControl/AppSwitcher.xm | 32 ++++++------ MissionControl/RAMissionControlManager.xm | 2 +- MissionControl/RAMissionControlWindow.xm | 4 +- NotificationCenterApp/RANCViewController.xm | 4 +- RAAppSelectorView.xm | 2 +- RARunningAppsProvider.h | 5 +- RARunningAppsProvider.xm | 33 ++++++++----- RASnapshotProvider.xm | 2 +- Reachability/Reachability.xm | 13 ++--- SwipeOver/SwipeOverGesture.xm | 2 +- Theming/RAThemeLoader.mm | 4 +- Theming/RAThemeManager.mm | 2 +- UIKit.xm | 2 +- WindowedMultitasking/LaunchToWindow.xm | 4 +- WindowedMultitasking/RADesktopManager.xm | 2 +- WindowedMultitasking/RADesktopWindow.mm | 2 +- headers.h | 1 + reachappsettings/BackgrounderSettings.xm | 10 +--- reachappsettings/MissionControlSettings.xm | 10 +--- reachappsettings/NCApp.xm | 16 ++---- reachappsettings/ReachAppSettings.mm | 16 ++---- reachappsettings/WindowedMultitasking.xm | 30 +++--------- update_status | 4 +- widgets/Core/RAWidgetHostManager.xm | 2 +- widgets/Reachability/RAAllAppsWidget.xm | 2 +- widgets/Reachability/RAWidgetSection.mm | 14 +++--- 29 files changed, 142 insertions(+), 172 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index b914f9f..a29a21b 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -268,37 +268,34 @@ Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): *** Terminating a FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) */ -//really need to optimize %new -(void) RA_addStatusBarIconForSelfIfOneDoesNotExist { - if (%c(LSStatusBarItem) && ![lsbitems objectForKey:self.bundleIdentifier] && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) { - if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { - if ([[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]) { - RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; - BOOL native = (info & RAIconIndicatorViewInfoNative); - if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { +#if DEBUG + if (![lsbitems respondsToSelector:@selector(objectForKey:)]) + { + LogError(@"ERROR: lsbitems is not NSDictionary it is %s", class_getName(lsbitems.class)); + //@throw [NSException exceptionWithName:@"OH POOP" reason:@"Expected NSDictionary" userInfo:nil]; + } +#endif + + BOOL homescreenMapCheck = [%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)] && [[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]; + BOOL homescreenIconViewMapCheck = [[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]; + + if (%c(LSStatusBarItem) && ![lsbitems objectForKey:self.bundleIdentifier] && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) + { + if (homescreenMapCheck || homescreenIconViewMapCheck) + { + RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; + BOOL native = (info & RAIconIndicatorViewInfoNative); + if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) + { LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; - if (![item customViewClass]) { - item.customViewClass = @"RAAppIconStatusBarIconView"; - } - item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; + if (![item customViewClass]) + item.customViewClass = @"RAAppIconStatusBarIconView"; + item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; lsbitems[self.bundleIdentifier] = item; } - } - } else { - if ([[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]) { - RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; - BOOL native = (info & RAIconIndicatorViewInfoNative); - if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { - LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; - if (![item customViewClass]) { - item.customViewClass = @"RAAppIconStatusBarIconView"; - } - item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; - lsbitems[self.bundleIdentifier] = item; - } - } - } + } } } diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index 19be29f..14a8550 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -195,27 +195,27 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; { @autoreleasepool { SBIconView *ret = nil; - if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { - if ([[[%c(SBIconViewMap) homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) - { - // iOS 8.0+ - - SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; - ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; - } - else - { - // iOS 7.X - SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; - ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; - } - } else { - SBApplicationIcon *icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:identifier]; - ret = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] mappedIconViewForIcon:icon]; + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + if ([[[%c(SBIconViewMap) homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) + { + // iOS 8.0+ + + SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; + ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; + } + else + { + // iOS 7.X + SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; + ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; } + } else { + SBApplicationIcon *icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:identifier]; + ret = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] mappedIconViewForIcon:icon]; + } - [ret RA_updateIndicatorView:info]; + [ret RA_updateIndicatorView:info]; } } diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index baedc78..9d59c85 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -20,19 +20,18 @@ %end %hook BKSProcessAssertion -- (id)initWithPID:(int)arg1 flags:(unsigned int)arg2 reason:(unsigned int)arg3 name:(unsafe_id)arg4 withHandler:(unsafe_id)arg5 +- (id)initWithPID:(NSInteger)arg1 flags:(NSUInteger)arg2 reason:(NSUInteger)arg3 name:(NSString *)arg4 withHandler:(unsafe_id)arg5 { - if (!(arg3 == BKSProcessAssertionReasonViewServices) && // whitelist this to allow share menu to work + if (arg3 != BKSProcessAssertionReasonViewServices && // whitelist this to allow share menu to work ![arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] && // whitelist iCleaner to prevent crash on open - ![arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"] && // Whitelist filza to prevent iOS hang (?!) - !IS_SPRINGBOARD) // FIXME: this is a hack that prevents SpringBoard from not starting + ![arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"]) // Whitelist filza to prevent iOS hang (?!) Not sure if the springboard hack is still required { NSString *identifier = [NSBundle mainBundle].bundleIdentifier; if (!identifier) goto ORIGINAL; - //NSLog(@"[ReachApp] BKSProcessAssertion initWithPID:'%d' flags:'%d' reason:'%d' name:'%@' withHandler:'%@' process identifier:'%@'", arg1, arg2, arg3, arg4, arg5, identifier); + LogDebug(@"BKSProcessAssertion initWithPID:'%zd' flags:'%tu' reason:'%tu' name:'%@' withHandler:'%@' process identifier:'%@'", arg1, arg2, arg3, arg4, arg5, identifier); if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) { diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 10340fb..40064b9 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -30,7 +30,7 @@ BOOL toggleOrActivate = NO; if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) { - if (RAMissionControlManager.sharedInstance.isShowingMissionControl == NO) + if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) { [RAMissionControlManager.sharedInstance showMissionControl:YES]; } @@ -48,7 +48,7 @@ BOOL toggleOrActivate = NO; } BOOL s = %orig; - if (s && [[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999] != nil) + if (s && [[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999]) { [UIView animateWithDuration:0.3 animations:^{ [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].alpha = 1; @@ -112,7 +112,7 @@ BOOL toggleOrActivate = NO; // iOS 8 - (void)switcherWillBeDismissed:(_Bool)arg1 { - if (willShowMissionControl == NO) + if (!willShowMissionControl) { [[%c(RADesktopManager) sharedInstance] reshowDesktop]; //[[[%c(RADesktopManager) sharedInstance] currentDesktop] loadApps]; @@ -150,7 +150,7 @@ BOOL toggleOrActivate = NO; UIView *view = MSHookIvar(self, "_contentView"); - if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) + if (![view viewWithTag:999] && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; if (IS_IPAD) @@ -188,7 +188,7 @@ BOOL toggleOrActivate = NO; %orig; UIView *view = MSHookIvar(self, "_contentView"); - if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) + if (![view viewWithTag:999] && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; if (IS_IPAD) @@ -388,7 +388,7 @@ BOOL toggleOrActivate = NO; UIView *view = self.contentView; - if ([view viewWithTag:999] == nil && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { + if (![view viewWithTag:999] && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; if (IS_IPAD) { width = 60; @@ -484,17 +484,17 @@ BOOL toggleOrActivate = NO; UIScrollView *desktopScrollView, *windowedAppScrollView, *otherRunningAppsScrollView; CGFloat x = 15; - CGFloat y = 25; + CGFloat y = 20; - desktopLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; + desktopLabel = [[UILabel alloc] initWithFrame:CGRectMake(9.37, y, fakeView.frame.size.width - 20, 25)]; desktopLabel.font = [UIFont fontWithName:@"SFUIText-Medium" size:14]; desktopLabel.textColor = UIColor.whiteColor; desktopLabel.text = @"Desktops"; [fakeView addSubview:desktopLabel]; - y = y + desktopLabel.frame.size.height + 3; + y = y + desktopLabel.frame.size.height; - desktopScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y, fakeView.frame.size.width, height * 1.2)]; + desktopScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y, fakeView.frame.size.width, height * 1.15)]; desktopScrollView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.3]; [fakeView addSubview:desktopScrollView]; @@ -507,29 +507,29 @@ BOOL toggleOrActivate = NO; [desktopScrollView addSubview:newDesktopButton]; x = 15; - y = desktopScrollView.frame.origin.y + desktopScrollView.frame.size.height + 5; + y = desktopScrollView.frame.origin.y + desktopScrollView.frame.size.height + 7; - windowedLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; + windowedLabel = [[UILabel alloc] initWithFrame:CGRectMake(9.37, y, fakeView.frame.size.width - 20, 25)]; windowedLabel.font = [UIFont fontWithName:@"SFUIText-Medium" size:14]; windowedLabel.textColor = UIColor.whiteColor; windowedLabel.text = @"On This Desktop"; [fakeView addSubview:windowedLabel]; - windowedAppScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y + windowedLabel.frame.size.height + 3, fakeView.frame.size.width, height * 1.2)]; + windowedAppScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y + windowedLabel.frame.size.height, fakeView.frame.size.width, height * 1.15)]; windowedAppScrollView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.3]; [fakeView addSubview:windowedAppScrollView]; x = 15; - y = windowedAppScrollView.frame.origin.y + windowedAppScrollView.frame.size.height + 5; + y = windowedAppScrollView.frame.origin.y + windowedAppScrollView.frame.size.height + 7; - otherLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, y, fakeView.frame.size.width - 20, 20)]; + otherLabel = [[UILabel alloc] initWithFrame:CGRectMake(9.37, y, fakeView.frame.size.width - 20, 25)]; otherLabel.font = [UIFont fontWithName:@"SFUIText-Medium" size:14]; otherLabel.textColor = UIColor.whiteColor; otherLabel.text = @"Running Elsewhere"; [fakeView addSubview:otherLabel]; - otherRunningAppsScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y + otherLabel.frame.size.height + 3, fakeView.frame.size.width, height * 1.2)]; + otherRunningAppsScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, y + otherLabel.frame.size.height, fakeView.frame.size.width, height * 1.15)]; otherRunningAppsScrollView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.3]; [fakeView addSubview:otherRunningAppsScrollView]; diff --git a/MissionControl/RAMissionControlManager.xm b/MissionControl/RAMissionControlManager.xm index bc1925e..b81ab30 100644 --- a/MissionControl/RAMissionControlManager.xm +++ b/MissionControl/RAMissionControlManager.xm @@ -246,7 +246,7 @@ CGRect swappedForOrientation2(CGRect in) -(BOOL) RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity { - return self.isShowingMissionControl && self.inhibitDismissalGesture == NO; + return self.isShowingMissionControl && !self.inhibitDismissalGesture; } -(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index 8e410e4..ee950f1 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -403,7 +403,7 @@ if (gesture.state == UIGestureRecognizerStateBegan) { - if (!trashImageView || trashImageView.superview == nil /* new window perhaps */) + if (!trashImageView || !trashImageView.superview /* new window perhaps */) { trashImageView = [[UIImageView alloc] initWithFrame:CGRectMake((UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2) - (75/2), UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height + 75, 75, 75)]; trashImageView.image = trashIcon; @@ -424,7 +424,7 @@ trashImageView.frame = CGRectMake((UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2) - (75/2), UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - (75+45), 75, 75); }]; - if (draggedView == nil) + if (!draggedView) { draggedView = [gesture.view snapshotViewAfterScreenUpdates:YES]; draggedView.frame = gesture.view.frame; diff --git a/NotificationCenterApp/RANCViewController.xm b/NotificationCenterApp/RANCViewController.xm index f96e59e..43d0462 100644 --- a/NotificationCenterApp/RANCViewController.xm +++ b/NotificationCenterApp/RANCViewController.xm @@ -75,7 +75,7 @@ int rotationDegsForOrientation(int o) if ([[%c(SBLockScreenManager) sharedInstance] isUILocked]) { - if (isLockedLabel == nil) + if (!isLockedLabel) { isLockedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 400)]; isLockedLabel.numberOfLines = 2; @@ -177,7 +177,7 @@ int rotationDegsForOrientation(int o) - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { NSMethodSignature *signature = [super methodSignatureForSelector:aSelector]; - if (signature == nil && class_respondsToSelector(%c(SBBulletinObserverViewController), aSelector)) + if (!signature && class_respondsToSelector(%c(SBBulletinObserverViewController), aSelector)) signature = [%c(SBBulletinObserverViewController) instanceMethodSignatureForSelector:aSelector]; return signature; } diff --git a/RAAppSelectorView.xm b/RAAppSelectorView.xm index 53fd6e9..f5ccf5a 100644 --- a/RAAppSelectorView.xm +++ b/RAAppSelectorView.xm @@ -58,7 +58,7 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView || [icon isKindOfClass:[%c(SBApplicationIcon) class]] == NO) + if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) continue; iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); diff --git a/RARunningAppsProvider.h b/RARunningAppsProvider.h index 99d52e6..724ca6f 100644 --- a/RARunningAppsProvider.h +++ b/RARunningAppsProvider.h @@ -1,4 +1,5 @@ #import "headers.h" +#import @protocol RARunningAppsProviderDelegate @optional @@ -9,7 +10,7 @@ @interface RARunningAppsProvider : NSObject { NSMutableArray *apps; NSMutableArray *targets; - NSLock *lock; + pthread_mutex_t mutex; } +(instancetype) sharedInstance; @@ -20,4 +21,4 @@ -(void) removeTarget:(__weak NSObject*)target; -(NSArray*) runningApplications; -@end \ No newline at end of file +@end diff --git a/RARunningAppsProvider.xm b/RARunningAppsProvider.xm index a891e27..205a6d0 100644 --- a/RARunningAppsProvider.xm +++ b/RARunningAppsProvider.xm @@ -6,56 +6,67 @@ SHARED_INSTANCE2(RARunningAppsProvider, sharedInstance->apps = [NSMutableArray array]; sharedInstance->targets = [NSMutableArray array]; - sharedInstance->lock = [[NSLock alloc] init]; ); } +- (instancetype)init { + self = [super init]; + if (self) { + pthread_mutex_init(&mutex, NULL); + } + return self; +} + -(void) addRunningApp:(__unsafe_unretained SBApplication*)app { - [lock lock]; + pthread_mutex_lock(&mutex); [apps addObject:app]; for (NSObject* target in targets) if ([target respondsToSelector:@selector(appDidStart:)]) - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_main_queue(), ^{ [target appDidStart:app]; }); - [lock unlock]; + pthread_mutex_unlock(&mutex); } -(void) removeRunningApp:(__unsafe_unretained SBApplication*)app { - [lock lock]; + pthread_mutex_lock(&mutex); [apps removeObject:app]; for (NSObject* target in targets) if ([target respondsToSelector:@selector(appDidDie:)]) - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_main_queue(), ^{ [target appDidDie:app]; }); - [lock unlock]; + pthread_mutex_unlock(&mutex); } -(void) addTarget:(__weak NSObject*)target { - [lock lock]; + pthread_mutex_lock(&mutex); if (![targets containsObject:target]) [targets addObject:target]; - [lock unlock]; + pthread_mutex_unlock(&mutex); } -(void) removeTarget:(__weak NSObject*)target { - [lock lock]; + pthread_mutex_lock(&mutex); [targets removeObject:target]; - [lock unlock]; + pthread_mutex_unlock(&mutex); +} + +- (void)dealloc { + pthread_mutex_destroy(&mutex); } -(NSArray*) runningApplications { return apps; } diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index fd9699a..31eda15 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -142,7 +142,7 @@ -(UIImage*) snapshotForDesktop:(RADesktopWindow*)desktop { NSString *key = [self createKeyForDesktop:desktop]; - if ([imageCache objectForKey:key] != nil) return [imageCache objectForKey:key]; + if ([imageCache objectForKey:key]) return [imageCache objectForKey:key]; UIImage *img = [self renderPreviewForDesktop:desktop]; if (img) diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 69cbcb3..4334db7 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -82,7 +82,8 @@ BOOL wasEnabled = NO; - (void)deactivateReachabilityModeForObserver:(unsafe_id)arg1 { - if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) + //Disable for keyboard here + if (overrideDisableForStatusBar) return; %orig; @@ -115,7 +116,7 @@ BOOL wasEnabled = NO; - (void)_handleReachabilityDeactivated { - if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) + if (overrideDisableForStatusBar) return; %orig; @@ -123,7 +124,7 @@ BOOL wasEnabled = NO; - (void)_updateReachabilityModeActive:(_Bool)arg1 withRequestingObserver:(unsafe_id)arg2 { - if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) + if (overrideDisableForStatusBar) return; %orig; } @@ -166,7 +167,7 @@ id SBWorkspace$sharedInstance; - (void)_exitReachabilityModeWithCompletion:(unsafe_id)arg1 { - if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) + if (overrideDisableForStatusBar) return; %orig; @@ -174,7 +175,7 @@ id SBWorkspace$sharedInstance; - (void)handleReachabilityModeDeactivated { - if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) + if (overrideDisableForStatusBar) return; %orig; @@ -256,6 +257,7 @@ id SBWorkspace$sharedInstance; - (void)_disableReachabilityImmediately:(_Bool)arg1 { + //Disable for keyboard here if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) return; @@ -722,7 +724,6 @@ CGFloat startingY = -1; if (![app pid] || ![app mainScene]) { - LogDebug(@"no pid or scene; trying again"); overrideDisableForStatusBar = YES; [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:bundleIdentifier]; diff --git a/SwipeOver/SwipeOverGesture.xm b/SwipeOver/SwipeOverGesture.xm index 78ccb19..b2f2057 100644 --- a/SwipeOver/SwipeOverGesture.xm +++ b/SwipeOver/SwipeOverGesture.xm @@ -158,7 +158,7 @@ BOOL swipeOverLocationIsInValidArea(CGFloat y) isShowingGrabber = NO; isPastGrabber = YES; } - else if (isPastGrabber == NO) + else if (!isPastGrabber) { if (state == UIGestureRecognizerStateEnded) firstSwipe = NO; diff --git a/Theming/RAThemeLoader.mm b/Theming/RAThemeLoader.mm index cb405d3..8dadd52 100644 --- a/Theming/RAThemeLoader.mm +++ b/Theming/RAThemeLoader.mm @@ -64,7 +64,7 @@ +(RATheme*) themeFromDictionary:(NSDictionary*)dict ret.swipeOverDetachBarColor = COLOR(@"swipeOverDetachBarColor"); ret.swipeOverDetachImageColor = COLOR(@"swipeOverDetachImageColor") ?: [UIColor RA_colorWithHexString:@"737273"]; - ret.quickAccessUseGenericTabLabel = [dict objectForKey:@"quickAccessUseGenericTabLabel"] == nil ? NO : [dict[@"quickAccessUseGenericTabLabel"] boolValue]; + ret.quickAccessUseGenericTabLabel = ![dict objectForKey:@"quickAccessUseGenericTabLabel"] ? NO : [dict[@"quickAccessUseGenericTabLabel"] boolValue]; return ret; } @@ -112,4 +112,4 @@ +(UIColor*) tryGetColorFromThemeImageName:(NSString*)name return [UIColor colorWithPatternImage:image]; return nil; } -@end \ No newline at end of file +@end diff --git a/Theming/RAThemeManager.mm b/Theming/RAThemeManager.mm index b11afc8..7146e38 100644 --- a/Theming/RAThemeManager.mm +++ b/Theming/RAThemeManager.mm @@ -28,7 +28,7 @@ -(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier for (NSString *themeName in themeFileNames) { - if ([themeName hasSuffix:@"plist"] == NO) + if (![themeName hasSuffix:@"plist"]) continue; RATheme *theme = [RAThemeLoader loadFromFile:themeName]; diff --git a/UIKit.xm b/UIKit.xm index c3d130e..a956c17 100644 --- a/UIKit.xm +++ b/UIKit.xm @@ -194,7 +194,7 @@ static Class $memorized$UITextEffectsWindow$class; } for (UIWindow *window in [[UIApplication sharedApplication] windows]) { - if ([oldFrames objectForKey:@(window.hash)] == nil) + if (![oldFrames objectForKey:@(window.hash)]) [oldFrames setObject:[NSValue valueWithCGRect:window.frame] forKey:@(window.hash)]; [UIView animateWithDuration:0.3 animations:^{ diff --git a/WindowedMultitasking/LaunchToWindow.xm b/WindowedMultitasking/LaunchToWindow.xm index ea95993..2bee37d 100644 --- a/WindowedMultitasking/LaunchToWindow.xm +++ b/WindowedMultitasking/LaunchToWindow.xm @@ -33,7 +33,7 @@ BOOL allowOpenApp = NO; // Broken //if (launchNextOpenIntoWindow) - if ([RASettings.sharedInstance windowedMultitaskingEnabled] &&[RASettings.sharedInstance launchIntoWindows] && allowOpenApp != YES) + if ([RASettings.sharedInstance windowedMultitaskingEnabled] &&[RASettings.sharedInstance launchIntoWindows] && !allowOpenApp) { [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:arg1 animated:YES]; //launchNextOpenIntoWindow = NO; @@ -51,7 +51,7 @@ BOOL allowOpenApp = NO; // Broken //if (launchNextOpenIntoWindow) - if ([RASettings.sharedInstance windowedMultitaskingEnabled] &&[RASettings.sharedInstance launchIntoWindows] && allowOpenApp != YES) + if ([RASettings.sharedInstance windowedMultitaskingEnabled] &&[RASettings.sharedInstance launchIntoWindows] && !allowOpenApp) { [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:arg1 animated:YES]; //launchNextOpenIntoWindow = NO; diff --git a/WindowedMultitasking/RADesktopManager.xm b/WindowedMultitasking/RADesktopManager.xm index 768a469..70b0afd 100644 --- a/WindowedMultitasking/RADesktopManager.xm +++ b/WindowedMultitasking/RADesktopManager.xm @@ -70,7 +70,7 @@ BOOL overrideUIWindow = NO; overrideUIWindow = NO; [newDesktop makeKeyAndVisible]; overrideUIWindow = YES; - if (show == NO) + if (!show) newDesktop.hidden = YES; currentDesktopIndex = index; diff --git a/WindowedMultitasking/RADesktopWindow.mm b/WindowedMultitasking/RADesktopWindow.mm index 065ace2..69fd77d 100644 --- a/WindowedMultitasking/RADesktopWindow.mm +++ b/WindowedMultitasking/RADesktopWindow.mm @@ -227,7 +227,7 @@ -(void) saveInfo -(void) loadInfo { NSInteger index = [RADesktopManager.sharedInstance.availableDesktops indexOfObject:self]; - if ([RAWindowStatePreservationSystemManager.sharedInstance hasDesktopInformationAtIndex:index] == NO) + if (![RAWindowStatePreservationSystemManager.sharedInstance hasDesktopInformationAtIndex:index]) return; RAPreservedDesktopInformation info = [RAWindowStatePreservationSystemManager.sharedInstance desktopInformationForIndex:index]; for (NSString *bundleIdentifier in info.openApps) diff --git a/headers.h b/headers.h index eaef78d..9ef0859 100644 --- a/headers.h +++ b/headers.h @@ -455,6 +455,7 @@ typedef struct { @end @interface UIScreen (ohBoy) +- (CGRect)_gkBounds; -(CGRect) _referenceBounds; - (CGPoint)convertPoint:(CGPoint)arg1 toCoordinateSpace:(id)arg2; + (CGPoint)convertPoint:(CGPoint)arg1 toView:(id)arg2; diff --git a/reachappsettings/BackgrounderSettings.xm b/reachappsettings/BackgrounderSettings.xm index f0837fa..733a192 100644 --- a/reachappsettings/BackgrounderSettings.xm +++ b/reachappsettings/BackgrounderSettings.xm @@ -133,14 +133,8 @@ id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") - message:@"Activator must be installed to use this feature." - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - }]; - + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; } diff --git a/reachappsettings/MissionControlSettings.xm b/reachappsettings/MissionControlSettings.xm index ecbe386..b311aa8 100644 --- a/reachappsettings/MissionControlSettings.xm +++ b/reachappsettings/MissionControlSettings.xm @@ -125,14 +125,8 @@ id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") - message:@"Activator must be installed to use this feature." - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - }]; - + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; } diff --git a/reachappsettings/NCApp.xm b/reachappsettings/NCApp.xm index 0c47c27..93d35de 100644 --- a/reachappsettings/NCApp.xm +++ b/reachappsettings/NCApp.xm @@ -208,18 +208,12 @@ CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); }); - UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Quick Access" - message:@"A respring is required to apply changes. Would you like to respring now?" - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *respringAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Quick Access" message:@"A respring is required to apply changes. Would you like to respring now?" preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *respringAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); }]; - - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel - handler:^(UIAlertAction *action) { - }]; - + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:nil]; + [alert addAction:respringAction]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; diff --git a/reachappsettings/ReachAppSettings.mm b/reachappsettings/ReachAppSettings.mm index 89535dc..35f2489 100644 --- a/reachappsettings/ReachAppSettings.mm +++ b/reachappsettings/ReachAppSettings.mm @@ -202,18 +202,12 @@ -(NSArray*) customSpecifiers -(void) resetData { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") - message:@"Please confirm your choice to reset all settings & respring.." - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.resetSettings"), nil, nil, YES); + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Please confirm your choice to reset all settings & respring.." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.resetSettings"), nil, nil, YES); }]; - - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel - handler:^(UIAlertAction *action) { - }]; - + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; + [alert addAction:resetAction]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; diff --git a/reachappsettings/WindowedMultitasking.xm b/reachappsettings/WindowedMultitasking.xm index d6510e1..5a5ee33 100644 --- a/reachappsettings/WindowedMultitasking.xm +++ b/reachappsettings/WindowedMultitasking.xm @@ -196,14 +196,8 @@ id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") - message:@"Activator must be installed to use this feature." - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - }]; - + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; } @@ -220,14 +214,8 @@ id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") - message:@"Activator must be installed to use this feature." - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - }]; - + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; } @@ -244,14 +232,8 @@ id activator = %c(LAListenerSettingsViewController); if (!activator) { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") - message:@"Activator must be installed to use this feature." - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - }]; - + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; } diff --git a/update_status b/update_status index adc2533..749f20b 100644 --- a/update_status +++ b/update_status @@ -32,8 +32,10 @@ Minor Things/Bugs to note: - Startup bug still isnt fixed (apparently caused by gesture support?) - General Code Cleanup, feels to messy RN -Features to Add: +Things to do/Features to add: +- Remove as many deprecations as can (subclassing UIAlertController?) - 3D Touch actions? +- (Real distant future) split all 6 features into seperate tweaks notes: use _referenceBounds instead of bounds on UIScreen to get physical bounds. Makes landscape support easier? diff --git a/widgets/Core/RAWidgetHostManager.xm b/widgets/Core/RAWidgetHostManager.xm index 5c3fabf..0b6f035 100644 --- a/widgets/Core/RAWidgetHostManager.xm +++ b/widgets/Core/RAWidgetHostManager.xm @@ -8,7 +8,7 @@ -(void) addWidget:(RAWidgetBase*)widget { - if ([widgets containsObject:widget] == NO) + if (![widgets containsObject:widget]) [widgets addObject:widget]; } diff --git a/widgets/Reachability/RAAllAppsWidget.xm b/widgets/Reachability/RAAllAppsWidget.xm index 1710b93..7e46ad6 100644 --- a/widgets/Reachability/RAAllAppsWidget.xm +++ b/widgets/Reachability/RAAllAppsWidget.xm @@ -70,7 +70,7 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView || [icon isKindOfClass:[%c(SBApplicationIcon) class]] == NO) + if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) continue; if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) diff --git a/widgets/Reachability/RAWidgetSection.mm b/widgets/Reachability/RAWidgetSection.mm index 0fa7bef..bc8d881 100644 --- a/widgets/Reachability/RAWidgetSection.mm +++ b/widgets/Reachability/RAWidgetSection.mm @@ -3,7 +3,7 @@ @implementation RAWidgetSection --(id) init +-(instancetype) init { if (self = [super init]) { @@ -17,13 +17,13 @@ -(BOOL) showTitle { return YES; } -(NSInteger) sortOrder { return 10; } --(NSString*) displayName +-(NSString*) displayName { - @throw @"This is an abstract method and should be overriden."; + @throw @"This is an abstract method and should be overriden."; } --(NSString*) identifier -{ +-(NSString*) identifier +{ @throw @"This is an abstract method and should be overriden."; } @@ -33,7 +33,7 @@ -(void) addWidget:(RAWidget*)widget } -(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing -{ +{ UIView *view = [[UIView alloc] initWithFrame:frame]; view.userInteractionEnabled = YES; CGPoint origin = CGPointMake(10, 10); @@ -71,4 +71,4 @@ -(CGFloat) titleOffset { return 10; } -@end \ No newline at end of file +@end From b260920236d76d1f91660f901ee526fd42652507 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Tue, 14 Mar 2017 15:52:55 -0500 Subject: [PATCH 49/59] Completely removed UIAlertView --- .../BackgroundModeTogglerActivator.xm | 52 +++++++----------- Backgrounding/Makefile | 2 +- Backgrounding/RABackgrounder.xm | 4 ++ BioLockdown.h | 4 +- Makefile | 2 +- Messaging/RAMessagingServer.xm | 8 +-- RACompatibilitySystem.mm | 15 +++--- SwipeOver/Makefile | 2 +- SwipeOver/RASwipeOverManager.xm | 6 ++- UIAlertController+Window.h | 16 ++++++ UIAlertController+Window.m | 54 +++++++++++++++++++ update_status | 1 - 12 files changed, 118 insertions(+), 48 deletions(-) create mode 100644 UIAlertController+Window.h create mode 100644 UIAlertController+Window.m diff --git a/Backgrounding/BackgroundModeTogglerActivator.xm b/Backgrounding/BackgroundModeTogglerActivator.xm index b77d61a..b2f9b5a 100644 --- a/Backgrounding/BackgroundModeTogglerActivator.xm +++ b/Backgrounding/BackgroundModeTogglerActivator.xm @@ -1,8 +1,9 @@ #import +#import "UIAlertController+Window.h" #import "RABackgrounder.h" #import "RASettings.h" -@interface RAActivatorBackgrounderToggleModeListener : NSObject +@interface RAActivatorBackgrounderToggleModeListener : NSObject @end static RAActivatorBackgrounderToggleModeListener *sharedInstance$RAActivatorBackgrounderToggleModeListener; @@ -15,43 +16,30 @@ static RAActivatorBackgrounderToggleModeListener *sharedInstance$RAActivatorBack if (!app) return; + BOOL dismissApp = [[%c(RASettings) sharedInstance] exitAppAfterUsingActivatorAction]; + NSString *friendlyCurrentBackgroundMode = FriendlyNameForBackgroundMode((RABackgroundMode)[RABackgrounder.sharedInstance backgroundModeForIdentifier:app.bundleIdentifier]); - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"MULTIPLEXER") message:[NSString stringWithFormat:LOCALIZE(@"BACKGROUNDER_POPUP_SWITCHER_TEXT"),app.displayName,friendlyCurrentBackgroundMode] delegate:self cancelButtonTitle:LOCALIZE(@"CANCEL") otherButtonTitles:LOCALIZE(@"FORCE_FOREGROUND"), LOCALIZE(@"NATIVE"), LOCALIZE(@"SUSPEND_IMMEDIATELY"), LOCALIZE(@"DISABLE"), nil]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:[NSString stringWithFormat:LOCALIZE(@"BACKGROUNDER_POPUP_SWITCHER_TEXT"),app.displayName,friendlyCurrentBackgroundMode] preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"FORCE_FOREGROUND") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:app andCloseForegroundApp:dismissApp]; + }]]; - [alert show]; -} + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"NATIVE") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeNative forApplication:app andCloseForegroundApp:dismissApp]; + }]]; -- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex -{ - SBApplication *app = UIApplication.sharedApplication._accessibilityFrontMostApplication; - if (!app) - return; + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"SUSPEND_IMMEDIATELY") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeSuspendImmediately forApplication:app andCloseForegroundApp:dismissApp]; + }]]; - BOOL dismissApp = [[%c(RASettings) sharedInstance] exitAppAfterUsingActivatorAction]; + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"DISABLE") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeForceNone forApplication:app andCloseForegroundApp:dismissApp]; + }]]; - if (buttonIndex == [alertView cancelButtonIndex]) - { - return; - } - if (buttonIndex == 1) - { - // Force foreground - [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:app andCloseForegroundApp:dismissApp]; - } - else if (buttonIndex == 2) - { - // Native - [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeNative forApplication:app andCloseForegroundApp:dismissApp]; - } - else if (buttonIndex == 3) - { - [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeSuspendImmediately forApplication:app andCloseForegroundApp:dismissApp]; - } - else// if (buttonIndex == 3) - { - [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeForceNone forApplication:app andCloseForegroundApp:dismissApp]; - } + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"CANCEL") style:UIAlertActionStyleDefault handler:nil]]; + + [alert show]; } @end diff --git a/Backgrounding/Makefile b/Backgrounding/Makefile index 7c3405e..d16212c 100644 --- a/Backgrounding/Makefile +++ b/Backgrounding/Makefile @@ -1,6 +1,6 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -Wno-deprecated-declarations -O2 +CFLAGS = -I../ -I../Theming/ -O2 CFLAGS += -fobjc-arc include $(THEOS)/makefiles/common.mk diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index 14a8550..51a1ff3 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -191,6 +191,8 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; return (RAIconIndicatorViewInfo)info; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -(void) updateIconIndicatorForIdentifier:(NSString*)identifier withInfo:(RAIconIndicatorViewInfo)info { @autoreleasepool { @@ -218,6 +220,8 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; [ret RA_updateIndicatorView:info]; } } +#pragma GCC diagnostic pop + -(BOOL) shouldShowIndicatorForIdentifier:(NSString*)identifier { diff --git a/BioLockdown.h b/BioLockdown.h index 78198c3..b2b16ab 100644 --- a/BioLockdown.h +++ b/BioLockdown.h @@ -3,6 +3,8 @@ @class SBApplication; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" __attribute__((visibility("hidden"))) @interface BioLockdownController : NSObject @@ -18,7 +20,7 @@ __attribute__((visibility("hidden"))) - (BOOL)authenticateForRecord:(ABRecordRef)record actionText:(NSString *)actionText completion:(dispatch_block_t)completion failure:(dispatch_block_t)failure; @end - +#pragma GCC diagnostic pop #define HAS_BIOLOCKDOWN (objc_getClass("BioLockdownController") != nil) #define IF_BIOLOCKDOWN if (HAS_BIOLOCKDOWN) diff --git a/Makefile b/Makefile index b84b910..a8c1bb1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ -Wno-deprecated-declarations -O2 +CFLAGS = -I./ -Iwidgets/ -Iwidgets/Core/ -Iwidgets/Reachability/ -ISwipeOver/ -IReachability/ -IGestureSupport/ -IKeyboardSupport/ -IMissionControl/ -IWindowedMultitasking/ -INotificationCenterApp/ -IBackgrounding/ -IIntroTutorial/ -IMessaging/ -ITheming/ -O2 CFLAGS += -fobjc-arc TARGET = iphone:9.2 diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index edb6b54..7862c10 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -13,6 +13,7 @@ #import "RAWindowSnapDataProvider.h" #import "RAHostManager.h" #import "Multiplexer.h" +#import "UIAlertController+Window.h" extern BOOL launchNextOpenIntoWindow; @@ -223,9 +224,10 @@ extern BOOL launchNextOpenIntoWindow; #if DEBUG if ([RASettings.sharedInstance debug_showIPCMessages]) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"MULTIPLEXER") message:description delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; - } + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:description preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; + [alert show]; + } #endif } diff --git a/RACompatibilitySystem.mm b/RACompatibilitySystem.mm index 1479b0e..d192ae3 100644 --- a/RACompatibilitySystem.mm +++ b/RACompatibilitySystem.mm @@ -3,6 +3,7 @@ #include #import #import "headers.h" +#import "UIAlertController+Window.h" @implementation RACompatibilitySystem +(NSString*) aggregateSystemInfo @@ -12,7 +13,7 @@ +(NSString*) aggregateSystemInfo struct utsname systemInfo; uname(&systemInfo); NSString *sysInfo = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; - + [ret appendString:[NSString stringWithFormat:@"%@, %@ %@\n", sysInfo, UIDevice.currentDevice.systemName, UIDevice.currentDevice.systemVersion]]; return ret; @@ -22,15 +23,17 @@ +(void) showWarning:(NSString*)info { NSString *message = [NSString stringWithFormat:@"System info: %@\n\nWARNING: POTENTIAL INCOMPATIBILITY DETECTED\n%@", [self aggregateSystemInfo], info]; - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Multiplexer Compatibility" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Multiplexer Compatibility" message:message preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; + [alert show]; } +(void) showError:(NSString*)info { NSString *message = [NSString stringWithFormat:@"System info: %@\n\n***ERROR***: POTENTIAL INCOMPATIBILITY DETECTED\n%@", [self aggregateSystemInfo], info]; - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Multiplexer Compatibility" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Multiplexer Compatibility" message:message preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; + [alert show]; } -@end \ No newline at end of file +@end diff --git a/SwipeOver/Makefile b/SwipeOver/Makefile index 7a23b47..814ab49 100644 --- a/SwipeOver/Makefile +++ b/SwipeOver/Makefile @@ -1,6 +1,6 @@ ARCHS = armv7 armv7s arm64 -CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -I../Messaging/ -I../KeyboardSupport -I../MissionControl -Wno-deprecated-declarations -O2 +CFLAGS = -I../ -I../Theming/ -I../GestureSupport/ -I../WindowedMultitasking/ -I../Messaging/ -I../KeyboardSupport -I../MissionControl -O2 CFLAGS += -fobjc-arc include $(THEOS)/makefiles/common.mk diff --git a/SwipeOver/RASwipeOverManager.xm b/SwipeOver/RASwipeOverManager.xm index 02429bc..cbfe14d 100644 --- a/SwipeOver/RASwipeOverManager.xm +++ b/SwipeOver/RASwipeOverManager.xm @@ -9,6 +9,7 @@ #import "RAAppSelectorView.h" #import "RAAppSwitcherModelWrapper.h" #import "RAOrientationLocker.h" +#import "UIAlertController+Window.h" extern int rotationDegsForOrientation(int o); @@ -194,8 +195,9 @@ extern int rotationDegsForOrientation(int o); if (UIApplication.sharedApplication.statusBarOrientation != UIInterfaceOrientationPortrait) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LOCALIZE(@"MULTIPLEXER") message:@"Sorry, SwipeOver's side-by-side mode is not currently compatible with landscape." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:@"Sorry, SwipeOver's side-by-side mode is not currently compatible with landscape." preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; + [alert show]; return; } diff --git a/UIAlertController+Window.h b/UIAlertController+Window.h new file mode 100644 index 0000000..748c4f5 --- /dev/null +++ b/UIAlertController+Window.h @@ -0,0 +1,16 @@ +// +// UIAlertController+Window.h +// FFM +// +// Created by Eric Larson on 6/17/15. +// Copyright (c) 2015 ForeFlight, LLC. All rights reserved. +// + +#import + +@interface UIAlertController (Window) + +- (void)show; +- (void)show:(BOOL)animated; + +@end diff --git a/UIAlertController+Window.m b/UIAlertController+Window.m new file mode 100644 index 0000000..8db2d6c --- /dev/null +++ b/UIAlertController+Window.m @@ -0,0 +1,54 @@ +// +// UIAlertController+Window.m +// FFM +// +// Created by Eric Larson on 6/17/15. +// Copyright (c) 2015 ForeFlight, LLC. All rights reserved. +// + +#import "UIAlertController+Window.h" +#import + +@interface UIAlertController (Private) + +@property (nonatomic, strong) UIWindow *alertWindow; + +@end + +@implementation UIAlertController (Private) + +@dynamic alertWindow; + +- (void)setAlertWindow:(UIWindow *)alertWindow { + objc_setAssociatedObject(self, @selector(alertWindow), alertWindow, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (UIWindow *)alertWindow { + return objc_getAssociatedObject(self, @selector(alertWindow)); +} + +@end + +@implementation UIAlertController (Window) + +- (void)show { + [self show:YES]; +} + +- (void)show:(BOOL)animated { + self.alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + self.alertWindow.rootViewController = [[UIViewController alloc] init]; + self.alertWindow.windowLevel = UIWindowLevelAlert + 1; + [self.alertWindow makeKeyAndVisible]; + [self.alertWindow.rootViewController presentViewController:self animated:animated completion:nil]; +} + +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; + + // precaution to insure window gets destroyed + self.alertWindow.hidden = YES; + self.alertWindow = nil; +} + +@end diff --git a/update_status b/update_status index 749f20b..ffdd362 100644 --- a/update_status +++ b/update_status @@ -33,7 +33,6 @@ Minor Things/Bugs to note: - General Code Cleanup, feels to messy RN Things to do/Features to add: -- Remove as many deprecations as can (subclassing UIAlertController?) - 3D Touch actions? - (Real distant future) split all 6 features into seperate tweaks From 5a223435f3cbdd213701933d2b2795ef40bc0dc3 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Tue, 14 Mar 2017 21:55:46 -0500 Subject: [PATCH 50/59] Fixed indents? (thanks linter) --- Backgrounding/IconIndicator.xm | 46 +- Backgrounding/RABackgrounder.h | 32 +- Backgrounding/RABackgrounder.xm | 13 +- .../SpringBoard_UIAppCustomBackgroundModes.xm | 69 +- Backgrounding/UnlimitedBackgrounding.xm | 56 +- DRM/Statistics.xm | 32 +- KeyboardSupport/RARemoteKeyboardView.xm | 66 +- Messaging/RAMessagingClient.xm | 38 +- Messaging/RAMessagingServer.xm | 106 +- MissionControl/ActivatorListener.xm | 12 +- MissionControl/AppSwitcher.xm | 8 +- MissionControl/RAMissionControlManager.xm | 8 +- MissionControl/RAMissionControlPreviewView.xm | 83 +- MissionControl/RAMissionControlWindow.xm | 36 +- Multiplexer.xm | 28 +- NotificationCenterApp/NCHook.xm | 16 +- RAAppKiller.xm | 2 +- RAAppSelectorView.xm | 56 +- RAAppSliderProviderView.mm | 28 +- RAAppSwitcherModelWrapper.xm | 12 +- RACompatibilitySystem.mm | 18 +- RAControlCenterInhibitor.xm | 12 +- RAFakePhoneMode.xm | 66 +- RAHostManager.xm | 26 +- RAHostedAppView.xm | 653 +++++---- RAResourceImageProvider.mm | 102 +- RARunningAppsProvider.xm | 4 +- RASettings.mm | 8 +- RASnapshotProvider.xm | 4 +- README.md | 2 +- Reachability/Reachability.xm | 1254 ++++++++--------- Reachability/UIKit.xm | 22 +- SpringBoard.xm | 170 +-- SwipeOver/RASwipeOverManager.xm | 146 +- SwipeOver/RASwipeOverOverlay.xm | 28 +- SwipeOver/SwipeOverGesture.xm | 330 ++--- Tweak.xm | 4 +- UIKit.xm | 290 ++-- .../ActivatorCreateAppWindow.xm | 34 +- .../ActivatorToggleEditModeListener.xm | 18 +- WindowedMultitasking/RADesktopWindow.mm | 66 +- WindowedMultitasking/RAWindowBar.xm | 303 ++-- .../StartMultitaskingGesture.xm | 272 ++-- WindowedMultitasking/WindowSorterActivator.xm | 14 +- headers.h | 106 +- reachappbackboarddhooks/Tweak.xm | 6 +- reachappfakephonemode/Tweak.xm | 52 +- reachappfsdaemon/main.mm | 22 +- .../BackgroundPerAppDetailsController.xm | 402 +++--- reachappsettings/BackgrounderPerApp.xm | 148 +- reachappsettings/BackgrounderSettings.xm | 244 ++-- reachappsettings/MissionControlSettings.xm | 54 +- reachappsettings/NCApp.xm | 250 ++-- reachappsettings/RAHeaderView.mm | 86 +- reachappsettings/RAListItemsController.xm | 68 +- reachappsettings/RASupportController.xm | 220 +-- reachappsettings/ReachAppSettings.mm | 366 ++--- reachappsettings/Reachability.xm | 479 ++++--- update_status | 1 + widgets/Reachability/RAAllAppsWidget.xm | 20 +- widgets/Reachability/RAFavoriteAppsWidget.xm | 20 +- widgets/Reachability/RARecentAppsWidget.xm | 20 +- 62 files changed, 3568 insertions(+), 3589 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index a29a21b..3d1f2c3 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -174,9 +174,9 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) %new -(void) RA_setIsIconIndicatorInhibited:(BOOL)value showAgainImmediately:(BOOL)value2 { - self.RA_isIconIndicatorInhibited = value; - if (value2 || value) - [self RA_updateIndicatorViewWithExistingInfo]; + self.RA_isIconIndicatorInhibited = value; + if (value2 || value) + [self RA_updateIndicatorViewWithExistingInfo]; } -(void) dealloc @@ -195,10 +195,10 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) -(void) layoutSubviews { - %orig; + %orig; - //if ([self viewWithTag:9962] == nil) - // this is back in, again, to try to fix "Smartclose badges show randomly in the app switcher for random applications even though I only have one app smart closed" + //if ([self viewWithTag:9962] == nil) + // this is back in, again, to try to fix "Smartclose badges show randomly in the app switcher for random applications even though I only have one app smart closed" // [self RA_updateIndicatorView:GET_INFO]; } @@ -295,28 +295,28 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; lsbitems[self.bundleIdentifier] = item; } - } + } } } - (void)setApplicationState:(unsigned int)arg1 { - %orig; - - if (!self.isRunning) - { - [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:RAIconIndicatorViewInfoNone]; - //SET_INFO_(self.bundleIdentifier, RAIconIndicatorViewInfoNone); - [lsbitems removeObjectForKey:self.bundleIdentifier]; - } - else - { - if ([self respondsToSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]) + %orig; + + if (!self.isRunning) + { + [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:RAIconIndicatorViewInfoNone]; + //SET_INFO_(self.bundleIdentifier, RAIconIndicatorViewInfoNone); + [lsbitems removeObjectForKey:self.bundleIdentifier]; + } + else + { + if ([self respondsToSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]) [self performSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]; [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]]; SET_INFO_(self.bundleIdentifier, [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]); - } + } } %new +(void) RA_clearAllStatusBarIcons @@ -341,10 +341,10 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) %hook SBIconViewMap - (id) _iconViewForIcon:(unsafe_id)arg1 { - SBIconView *iconView = %orig; + SBIconView *iconView = %orig; - [iconView RA_updateIndicatorViewWithExistingInfo]; - return iconView; + [iconView RA_updateIndicatorViewWithExistingInfo]; + return iconView; } %end @@ -365,7 +365,7 @@ inline NSString *getAppNameFromIndicatorName(NSString *indicatorName) -(id) contentsImage { UIImage *img = [ALApplicationList.sharedApplicationList iconOfSize:15 forDisplayIdentifier:getAppNameFromIndicatorName(self.item.indicatorName)]; - return [_UILegibilityImageSet imageFromImage:img withShadowImage:img]; + return [_UILegibilityImageSet imageFromImage:img withShadowImage:img]; } -(CGFloat) standardPadding { return 4; } %end diff --git a/Backgrounding/RABackgrounder.h b/Backgrounding/RABackgrounder.h index 12870df..3d63e12 100644 --- a/Backgrounding/RABackgrounder.h +++ b/Backgrounding/RABackgrounder.h @@ -1,29 +1,29 @@ #import "headers.h" typedef NS_ENUM(NSInteger, RABackgroundMode) { - RABackgroundModeNative = 1, - RABackgroundModeForceNativeForOldApps = 2, - RABackgroundModeForcedForeground = 3, - RABackgroundModeForceNone = 4, - RABackgroundModeSuspendImmediately = 5, - RABackgroundModeUnlimitedBackgroundingTime = 6, + RABackgroundModeNative = 1, + RABackgroundModeForceNativeForOldApps = 2, + RABackgroundModeForcedForeground = 3, + RABackgroundModeForceNone = 4, + RABackgroundModeSuspendImmediately = 5, + RABackgroundModeUnlimitedBackgroundingTime = 6, }; typedef NS_ENUM(NSInteger, RAIconIndicatorViewInfo) { - RAIconIndicatorViewInfoNone = 0, - RAIconIndicatorViewInfoNative = 1, - RAIconIndicatorViewInfoForced = 2, - RAIconIndicatorViewInfoSuspendImmediately = 4, + RAIconIndicatorViewInfoNone = 0, + RAIconIndicatorViewInfoNative = 1, + RAIconIndicatorViewInfoForced = 2, + RAIconIndicatorViewInfoSuspendImmediately = 4, - RAIconIndicatorViewInfoUnkillable = 8, - RAIconIndicatorViewInfoForceDeath = 16, + RAIconIndicatorViewInfoUnkillable = 8, + RAIconIndicatorViewInfoForceDeath = 16, - RAIconIndicatorViewInfoUnlimitedBackgroundTime = 32, + RAIconIndicatorViewInfoUnlimitedBackgroundTime = 32, - RAIconIndicatorViewInfoTemporarilyInhibit = 1024, - RAIconIndicatorViewInfoInhibit = 2048, - RAIconIndicatorViewInfoUninhibit = 4096, + RAIconIndicatorViewInfoTemporarilyInhibit = 1024, + RAIconIndicatorViewInfoInhibit = 2048, + RAIconIndicatorViewInfoUninhibit = 4096, }; NSString *FriendlyNameForBackgroundMode(RABackgroundMode mode); diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index 51a1ff3..1f22a5c 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -153,11 +153,11 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; if (close) { - FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ - SBAppToAppWorkspaceTransaction *transaction = [%c(Multiplexer) createSBAppToAppWorkspaceTransactionForExitingApp:app]; - [transaction begin]; - }]; - [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; + FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBAppToAppWorkspaceTransaction *transaction = [%c(Multiplexer) createSBAppToAppWorkspaceTransactionForExitingApp:app]; + [transaction begin]; + }]; + [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; } } @@ -216,8 +216,7 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; ret = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] mappedIconViewForIcon:icon]; } - - [ret RA_updateIndicatorView:info]; + [ret RA_updateIndicatorView:info]; } } #pragma GCC diagnostic pop diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index 9d59c85..f193d34 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -13,8 +13,9 @@ - (BOOL)supportsBackgroundMode:(__unsafe_unretained NSString *)mode { int override = [RABackgrounder.sharedInstance application:self.bundleIdentifier overrideBackgroundMode:mode]; - if (override == -1) - return %orig; + if (override == -1) + return %orig; + return override; } %end @@ -22,38 +23,38 @@ %hook BKSProcessAssertion - (id)initWithPID:(NSInteger)arg1 flags:(NSUInteger)arg2 reason:(NSUInteger)arg3 name:(NSString *)arg4 withHandler:(unsafe_id)arg5 { - if (arg3 != BKSProcessAssertionReasonViewServices && // whitelist this to allow share menu to work - ![arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] && // whitelist iCleaner to prevent crash on open - ![arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"]) // Whitelist filza to prevent iOS hang (?!) Not sure if the springboard hack is still required - { - NSString *identifier = [NSBundle mainBundle].bundleIdentifier; - - if (!identifier) - goto ORIGINAL; - - LogDebug(@"BKSProcessAssertion initWithPID:'%zd' flags:'%tu' reason:'%tu' name:'%@' withHandler:'%@' process identifier:'%@'", arg1, arg2, arg3, arg4, arg5, identifier); - - if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) - { - if ((arg3 >= BKSProcessAssertionReasonAudio && arg3 <= BKSProcessAssertionReasonVOiP)) // In most cases arg3 == 4 (finish task) - { - //NSLog(@"[ReachApp] blocking BKSProcessAssertion"); - - //if (arg5) - //{ - //void (^arg5fix)() = arg5; - //arg5fix(); - // ^^ causes crashes with share menu - //} - return nil; - } - //else if (arg3 == kProcessAssertionReasonActivation) - //{ - // arg2 = ProcessAssertionFlagAllowIdleSleep; - //} - } - } + if (arg3 != BKSProcessAssertionReasonViewServices && // whitelist this to allow share menu to work + ![arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] && // whitelist iCleaner to prevent crash on open + ![arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"]) // Whitelist filza to prevent iOS hang (?!) Not sure if the springboard hack is still required + { + NSString *identifier = [NSBundle mainBundle].bundleIdentifier; + + if (!identifier) + goto ORIGINAL; + + LogDebug(@"BKSProcessAssertion initWithPID:'%zd' flags:'%tu' reason:'%tu' name:'%@' withHandler:'%@' process identifier:'%@'", arg1, arg2, arg3, arg4, arg5, identifier); + + if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) + { + if ((arg3 >= BKSProcessAssertionReasonAudio && arg3 <= BKSProcessAssertionReasonVOiP)) // In most cases arg3 == 4 (finish task) + { + //NSLog(@"[ReachApp] blocking BKSProcessAssertion"); + + //if (arg5) + //{ + //void (^arg5fix)() = arg5; + //arg5fix(); + // ^^ causes crashes with share menu + //} + return nil; + } + //else if (arg3 == kProcessAssertionReasonActivation) + //{ + // arg2 = ProcessAssertionFlagAllowIdleSleep; + //} + } + } ORIGINAL: - return %orig(arg1, arg2, arg3, arg4, arg5); + return %orig(arg1, arg2, arg3, arg4, arg5); } %end diff --git a/Backgrounding/UnlimitedBackgrounding.xm b/Backgrounding/UnlimitedBackgrounding.xm index f77770d..49c4ea1 100644 --- a/Backgrounding/UnlimitedBackgrounding.xm +++ b/Backgrounding/UnlimitedBackgrounding.xm @@ -8,25 +8,25 @@ BKSProcessAssertion *keepAlive$temp; %hook FBUIApplicationWorkspaceScene -(void) host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 { - if ([RABackgrounder.sharedInstance hasUnlimitedBackgroundTime:arg1.identifier] && arg2.backgrounded && ![processAssertions objectForKey:arg1.identifier]) - { - SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:arg1.identifier]; - - keepAlive$temp = [[%c(BKSProcessAssertion) alloc] initWithPID:[app pid] - flags:(BKSProcessAssertionFlagPreventSuspend | BKSProcessAssertionFlagAllowIdleSleep | BKSProcessAssertionFlagPreventThrottleDownCPU | BKSProcessAssertionFlagWantsForegroundResourcePriority) - reason:BKSProcessAssertionReasonBackgroundUI - name:@"reachapp" - withHandler:^{ - LogInfo(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); - if (keepAlive$temp.valid) - processAssertions[arg1.identifier] = keepAlive$temp; - else - { - - } - }]; - } - %orig(arg1, arg2, arg3, arg4, arg5); + if ([RABackgrounder.sharedInstance hasUnlimitedBackgroundTime:arg1.identifier] && arg2.backgrounded && ![processAssertions objectForKey:arg1.identifier]) + { + SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:arg1.identifier]; + + keepAlive$temp = [[%c(BKSProcessAssertion) alloc] initWithPID:[app pid] + flags:(BKSProcessAssertionFlagPreventSuspend | BKSProcessAssertionFlagAllowIdleSleep | BKSProcessAssertionFlagPreventThrottleDownCPU | BKSProcessAssertionFlagWantsForegroundResourcePriority) + reason:BKSProcessAssertionReasonBackgroundUI + name:@"reachapp" + withHandler:^{ + LogInfo(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); + if (keepAlive$temp.valid) + processAssertions[arg1.identifier] = keepAlive$temp; + else + { + + } + }]; + } + %orig(arg1, arg2, arg3, arg4, arg5); } %end @@ -39,18 +39,18 @@ RAUnlimitedBackgroundingAppWatcher *sharedInstance$RAUnlimitedBackgroundingAppWa @implementation RAUnlimitedBackgroundingAppWatcher +(void) load { - IF_SPRINGBOARD { - sharedInstance$RAUnlimitedBackgroundingAppWatcher = [[RAUnlimitedBackgroundingAppWatcher alloc] init]; - [[%c(RARunningAppsProvider) sharedInstance] addTarget:sharedInstance$RAUnlimitedBackgroundingAppWatcher]; - } + IF_SPRINGBOARD { + sharedInstance$RAUnlimitedBackgroundingAppWatcher = [[RAUnlimitedBackgroundingAppWatcher alloc] init]; + [[%c(RARunningAppsProvider) sharedInstance] addTarget:sharedInstance$RAUnlimitedBackgroundingAppWatcher]; + } } -(void) appDidDie:(__unsafe_unretained SBApplication*)app { - if (/*W[RABackgrounder.sharedInstance preventKillingOfIdentifier:app.bundleIdentifier] == NO && */[processAssertions objectForKey:app.bundleIdentifier]) - { - [processAssertions[app.bundleIdentifier] invalidate]; - [processAssertions removeObjectForKey:app.bundleIdentifier]; - } + if (/*W[RABackgrounder.sharedInstance preventKillingOfIdentifier:app.bundleIdentifier] == NO && */[processAssertions objectForKey:app.bundleIdentifier]) + { + [processAssertions[app.bundleIdentifier] invalidate]; + [processAssertions removeObjectForKey:app.bundleIdentifier]; + } } @end diff --git a/DRM/Statistics.xm b/DRM/Statistics.xm index cb2fe9e..55f36bd 100644 --- a/DRM/Statistics.xm +++ b/DRM/Statistics.xm @@ -6,25 +6,25 @@ #if DEBUG LogInfo(@"[ReachApp][DRM] Not checking statistics on debug build"); #else - dispatch_async(dispatch_get_main_queue(), ^(void){ - NSString *statsPath = @"/var/mobile/Library/Preferences/.multiplexer.stats_checked"; - if (![NSFileManager.defaultManager fileExistsAtPath:statsPath]) - { - CFStringRef (*$MGCopyAnswer)(CFStringRef); + dispatch_async(dispatch_get_main_queue(), ^(void){ + NSString *statsPath = @"/var/mobile/Library/Preferences/.multiplexer.stats_checked"; + if (![NSFileManager.defaultManager fileExistsAtPath:statsPath]) + { + CFStringRef (*$MGCopyAnswer)(CFStringRef); - void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); - $MGCopyAnswer = (CFStringRef (*)(CFStringRef))dlsym(gestalt, "MGCopyAnswer"); + void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); + $MGCopyAnswer = (CFStringRef (*)(CFStringRef))dlsym(gestalt, "MGCopyAnswer"); - NSString *udid = (__bridge NSString*)$MGCopyAnswer(CFSTR("UniqueDeviceID")); - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://elijahandandrew.com/multiplexer/stats.php?udid=%@", udid]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]; - [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; + NSString *udid = (__bridge NSString*)$MGCopyAnswer(CFSTR("UniqueDeviceID")); + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://elijahandandrew.com/multiplexer/stats.php?udid=%@", udid]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]; + [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; int code = [httpResponse statusCode]; - if (!error && (code == 0 || code == 200)) - { - [NSFileManager.defaultManager createFileAtPath:statsPath contents:[NSData new] attributes:nil]; - } - }]; + if (!error && (code == 0 || code == 200)) + { + [NSFileManager.defaultManager createFileAtPath:statsPath contents:[NSData new] attributes:nil]; + } + }]; } }); #endif diff --git a/KeyboardSupport/RARemoteKeyboardView.xm b/KeyboardSupport/RARemoteKeyboardView.xm index 5c28a6c..6f6b1f7 100644 --- a/KeyboardSupport/RARemoteKeyboardView.xm +++ b/KeyboardSupport/RARemoteKeyboardView.xm @@ -14,46 +14,46 @@ -(void) connectToKeyboardWindowForApp:(NSString*)identifier { - if (!identifier) - { - self.layerHost.contextId = 0; - cancelFetchingContextId = YES; - return; - } - _identifier = identifier; - - unsigned int value = [RAMessagingServer.sharedInstance getStoredKeyboardContextIdForApp:identifier]; - self.layerHost.contextId = value; - - LogDebug(@"[ReachApp] loaded keyboard view with %d", value); - if (value == 0 && !cancelFetchingContextId) - { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - [self connectToKeyboardWindowForApp:identifier]; - }); - } + if (!identifier) + { + self.layerHost.contextId = 0; + cancelFetchingContextId = YES; + return; + } + _identifier = identifier; + + unsigned int value = [RAMessagingServer.sharedInstance getStoredKeyboardContextIdForApp:identifier]; + self.layerHost.contextId = value; + + LogDebug(@"[ReachApp] loaded keyboard view with %d", value); + if (value == 0 && !cancelFetchingContextId) + { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + [self connectToKeyboardWindowForApp:identifier]; + }); + } } -(instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) - { - self.userInteractionEnabled = YES; - self.layerHost = [[CALayerHost alloc] init]; - self.layerHost.anchorPoint = CGPointMake(0, 0); - if (IS_IOS_OR_OLDER(iOS_8_4)) - self.layerHost.transform = CATransform3DMakeScale(1/[UIScreen mainScreen].scale, 1/[UIScreen mainScreen].scale, 1); - self.layerHost.bounds = self.bounds; - [self.layer addSublayer:self.layerHost]; - update = NO; - } - - return self; + self = [super initWithFrame:frame]; + if (self) + { + self.userInteractionEnabled = YES; + self.layerHost = [[CALayerHost alloc] init]; + self.layerHost.anchorPoint = CGPointMake(0, 0); + if (IS_IOS_OR_OLDER(iOS_8_4)) + self.layerHost.transform = CATransform3DMakeScale(1/[UIScreen mainScreen].scale, 1/[UIScreen mainScreen].scale, 1); + self.layerHost.bounds = self.bounds; + [self.layer addSublayer:self.layerHost]; + update = NO; + } + + return self; } -(void)dealloc { - self.layerHost = nil; + self.layerHost = nil; } @end diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 8d87326..26aef6f 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -61,18 +61,18 @@ extern BOOL allowClosingReachabilityNatively; serverCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if (handle) - { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(serverCenter); - dlclose(handle); - } + void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); + if (handle) + { + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(serverCenter); + dlclose(handle); + } } -(void) alertUser:(NSString*)description { - LogError(@"%@", description); + LogError(@"%@", description); } -(void) _requestUpdateFromServerWithTries:(int)tries @@ -131,9 +131,9 @@ extern BOOL allowClosingReachabilityNatively; _currentData = data; if (didStatusBarVisibilityChange && !data.shouldForceStatusBar) - [UIApplication.sharedApplication RA_forceStatusBarVisibility:_currentData.statusBarVisibility orRevert:YES]; - else if (data.shouldForceStatusBar) - [UIApplication.sharedApplication RA_forceStatusBarVisibility:_currentData.statusBarVisibility orRevert:NO]; + [UIApplication.sharedApplication RA_forceStatusBarVisibility:_currentData.statusBarVisibility orRevert:YES]; + else if (data.shouldForceStatusBar) + [UIApplication.sharedApplication RA_forceStatusBarVisibility:_currentData.statusBarVisibility orRevert:NO]; if (didSizingChange && !data.shouldForceSize) [UIApplication.sharedApplication RA_updateWindowsForSizeChange:CGSizeMake(data.wantedClientWidth, data.wantedClientHeight) isReverting:YES]; @@ -200,20 +200,12 @@ extern BOOL allowClosingReachabilityNatively; -(BOOL) isBeingHosted { return _currentData.isBeingHosted; } @end -void reloadClientData(CFNotificationCenterRef center, - void *observer, - CFStringRef name, - const void *object, - CFDictionaryRef userInfo) +void reloadClientData(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { [[RAMessagingClient sharedInstance] requestUpdateFromServer]; } -void updateFrontmostApp(CFNotificationCenterRef center, - void *observer, - CFStringRef name, - const void *object, - CFDictionaryRef userInfo) +void updateFrontmostApp(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { RAMessagingClient.sharedInstance.knownFrontmostApp = ((__bridge NSDictionary*)userInfo)[@"bundleIdentifier"]; } @@ -226,7 +218,7 @@ void updateFrontmostApp(CFNotificationCenterRef center, else { [RAMessagingClient sharedInstance]; - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadClientData, (__bridge CFStringRef)[NSString stringWithFormat:@"com.efrederickson.reachapp.clientupdate-%@",NSBundle.mainBundle.bundleIdentifier], NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &updateFrontmostApp, CFSTR("com.efrederickson.reachapp.frontmostAppDidUpdate"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadClientData, (__bridge CFStringRef)[NSString stringWithFormat:@"com.efrederickson.reachapp.clientupdate-%@",NSBundle.mainBundle.bundleIdentifier], NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &updateFrontmostApp, CFSTR("com.efrederickson.reachapp.frontmostAppDidUpdate"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); } } diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index 7862c10..aae46bf 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -36,38 +36,38 @@ extern BOOL launchNextOpenIntoWindow; -(void) loadServer { - messagingCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; + messagingCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; - void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if (handle) - { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); - dlclose(handle); - } + void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); + if (handle) + { + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); + dlclose(handle); + } - [messagingCenter runServerOnCurrentThread]; + [messagingCenter runServerOnCurrentThread]; - [messagingCenter registerForMessageName:RAMessagingShowKeyboardMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingHideKeyboardMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingUpdateKeyboardContextIdMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingRetrieveKeyboardContextIdMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingUpdateAppInfoMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingShowKeyboardMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingHideKeyboardMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingUpdateKeyboardContextIdMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingRetrieveKeyboardContextIdMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingUpdateAppInfoMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingUpdateKeyboardSizeMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingOpenURLKMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingUpdateKeyboardSizeMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingOpenURLKMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingGetFrontMostAppInfoMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingChangeFrontMostAppMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingGetFrontMostAppInfoMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingChangeFrontMostAppMessageName target:self selector:@selector(handleMessageNamed:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingSnapFrontMostWindowLeftMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingSnapFrontMostWindowRightMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingGoToDesktopOnTheLeftMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingGoToDesktopOnTheRightMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingMaximizeAppMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingAddNewDesktopMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingCloseAppMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; - [messagingCenter registerForMessageName:RAMessagingDetachCurrentAppMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingSnapFrontMostWindowLeftMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingSnapFrontMostWindowRightMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingGoToDesktopOnTheLeftMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingGoToDesktopOnTheRightMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingMaximizeAppMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingAddNewDesktopMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingCloseAppMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; + [messagingCenter registerForMessageName:RAMessagingDetachCurrentAppMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; } -(NSDictionary*) handleMessageNamed:(NSString*)identifier userInfo:(NSDictionary*)info @@ -152,32 +152,32 @@ extern BOOL launchNextOpenIntoWindow; { if ([identifier isEqual:RAMessagingDetachCurrentAppMessageName]) { - SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; - - if (topApp) - { - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; - [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; - - UIView *appView = [RAHostManager systemHostViewForApplication:topApp].superview; - - [UIView animateWithDuration:0.2 animations:^{ - appView.transform = CGAffineTransformMakeScale(0.5, 0.5); - } completion:^(BOOL _) { - [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; - FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ - SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; - [deactiveSets setFlag:YES forDeactivationSetting:20]; - [deactiveSets setFlag:NO forDeactivationSetting:2]; - [topApp _setDeactivationSettings:deactiveSets]; - - SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; - [transaction begin]; - }]; - [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; - [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; - }]; - } + SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; + + if (topApp) + { + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; + [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; + + UIView *appView = [RAHostManager systemHostViewForApplication:topApp].superview; + + [UIView animateWithDuration:0.2 animations:^{ + appView.transform = CGAffineTransformMakeScale(0.5, 0.5); + } completion:^(BOOL _) { + [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; + FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; + [deactiveSets setFlag:YES forDeactivationSetting:20]; + [deactiveSets setFlag:NO forDeactivationSetting:2]; + [topApp _setDeactivationSettings:deactiveSets]; + + SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; + [transaction begin]; + }]; + [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; + [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; + }]; + } } else if ([identifier isEqual:RAMessagingGoToDesktopOnTheLeftMessageName]) { @@ -227,7 +227,7 @@ extern BOOL launchNextOpenIntoWindow; UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:description preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; [alert show]; - } + } #endif } diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index c29027b..a1a7f68 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -20,15 +20,15 @@ static RAActivatorListener *sharedInstance; [[%c(SBMainSwitcherViewController) sharedInstance] RA_dismissSwitcherUnanimated]; } } - [event setHandled:YES]; + [event setHandled:YES]; } @end %ctor { - IF_SPRINGBOARD - { - sharedInstance = [[RAActivatorListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.missioncontrol.activatorlistener"]; - } + IF_SPRINGBOARD + { + sharedInstance = [[RAActivatorListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.missioncontrol.activatorlistener"]; + } } diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 40064b9..17780fa 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -563,10 +563,10 @@ BOOL toggleOrActivate = NO; } completion:^(BOOL _) { //((UIWindow*)[[%c(SBUIController) sharedInstance] switcherWindow]).alpha = 0; if ([%c(SBUIController) respondsToSelector:@selector(dismissSwitcherAnimated:)]) { - [[%c(SBUIController) sharedInstance] dismissSwitcherAnimated:NO]; - } else { - [[%c(SBMainSwitcherViewController) sharedInstance] RA_dismissSwitcherUnanimated]; - } + [[%c(SBUIController) sharedInstance] dismissSwitcherAnimated:NO]; + } else { + [[%c(SBMainSwitcherViewController) sharedInstance] RA_dismissSwitcherUnanimated]; + } [[%c(SBUIController) sharedInstance] restoreContentUpdatingStatusBar:YES]; [RAMissionControlManager.sharedInstance showMissionControl:NO]; [fakeView removeFromSuperview]; diff --git a/MissionControl/RAMissionControlManager.xm b/MissionControl/RAMissionControlManager.xm index b81ab30..0581bd7 100644 --- a/MissionControl/RAMissionControlManager.xm +++ b/MissionControl/RAMissionControlManager.xm @@ -123,7 +123,7 @@ CGRect swappedForOrientation2(CGRect in) [[%c(RAGestureManager) sharedInstance] ignoreSwipesBeginningInRect:UIScreen.mainScreen.bounds forIdentifier:@"com.efrederickson.reachapp.windowedmultitasking.systemgesture"]; [[%c(RARunningAppsProvider) sharedInstance] addTarget:window]; [%c(RAOrientationLocker) lockOrientation]; - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAMissionControlManager"]; + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAMissionControlManager"]; self.inhibitDismissalGesture = NO; [%c(RAControlCenterInhibitor) setInhibited:YES]; @@ -224,7 +224,7 @@ CGRect swappedForOrientation2(CGRect in) [[%c(RAGestureManager) sharedInstance] removeGestureWithIdentifier:@"com.efrederickson.reachapp.missioncontrol.dismissgesture"]; [[%c(RAGestureManager) sharedInstance] stopIgnoringSwipesForIdentifier:@"com.efrederickson.reachapp.windowedmultitasking.systemgesture"]; [%c(RAOrientationLocker) unlockOrientation]; - [%c(RAControlCenterInhibitor) setInhibited:NO]; + [%c(RAControlCenterInhibitor) setInhibited:NO]; //if (lastOpenedApp && lastOpenedApp.isRunning && UIApplication.sharedApplication._accessibilityFrontMostApplication != lastOpenedApp) //{ @@ -359,9 +359,9 @@ CGRect swappedForOrientation2(CGRect in) %hook SBLockStateAggregator -(void) _updateLockState { - %orig; + %orig; - if ([self hasAnyLockState]) + if ([self hasAnyLockState]) if (RAMissionControlManager.sharedInstance.isShowingMissionControl) [RAMissionControlManager.sharedInstance hideMissionControl:NO]; } diff --git a/MissionControl/RAMissionControlPreviewView.xm b/MissionControl/RAMissionControlPreviewView.xm index aced907..bb152e0 100644 --- a/MissionControl/RAMissionControlPreviewView.xm +++ b/MissionControl/RAMissionControlPreviewView.xm @@ -5,48 +5,47 @@ @implementation RAMissionControlPreviewView -(void) generatePreview { - [self performSelectorOnMainThread:@selector(setBackgroundColor:) withObject:[[UIColor blackColor] colorWithAlphaComponent:0.5] waitUntilDone:NO]; - //self.image = [[%c(RASnapshotProvider) sharedInstance] snapshotForIdentifier:self.application.bundleIdentifier]; - UIImage *img = [[%c(RASnapshotProvider) sharedInstance] snapshotForIdentifier:self.application.bundleIdentifier]; - [self performSelectorOnMainThread:@selector(setImage:) withObject:img waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(setBackgroundColor:) withObject:[[UIColor blackColor] colorWithAlphaComponent:0.5] waitUntilDone:NO]; + //self.image = [[%c(RASnapshotProvider) sharedInstance] snapshotForIdentifier:self.application.bundleIdentifier]; + UIImage *img = [[%c(RASnapshotProvider) sharedInstance] snapshotForIdentifier:self.application.bundleIdentifier]; + [self performSelectorOnMainThread:@selector(setImage:) withObject:img waitUntilDone:NO]; - //if (!icon) - // icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; - //if (icon && !iconView) - // iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + //if (!icon) + // icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; + //if (icon && !iconView) + // iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; - NSOperationQueue* targetQueue = [NSOperationQueue mainQueue]; - [targetQueue addOperationWithBlock:^{ - if (!icon) { - if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { - icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; - } else { - icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; - } - } - if (icon && !iconView) { - if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { - iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; - } else { - iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; - } - } + NSOperationQueue* targetQueue = [NSOperationQueue mainQueue]; + [targetQueue addOperationWithBlock:^{ + if (!icon) { + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; + } else { + icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:self.application.bundleIdentifier]; + } + } + if (icon && !iconView) { + if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { + iconView = [[%c(SBIconViewMap) homescreenMap] _iconViewForIcon:icon]; + } else { + iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; + } + } + }]; + [targetQueue waitUntilAllOperationsAreFinished]; - }]; - [targetQueue waitUntilAllOperationsAreFinished]; + iconView.layer.shadowRadius = THEMED(missionControlIconPreviewShadowRadius); // iconView.layer.cornerRadius; + iconView.layer.shadowOpacity = 0.8; + iconView.layer.shadowOffset = CGSizeMake(0, 0); + //iconView.layer.shouldRasterize = YES; + //iconView.layer.rasterizationScale = UIScreen.mainScreen.scale; + iconView.userInteractionEnabled = NO; + iconView.iconLabelAlpha = 0; + CGFloat scale = (iconView.frame.size.width - 3.0) / iconView.frame.size.width; + iconView.transform = CGAffineTransformMakeScale(scale, scale); - iconView.layer.shadowRadius = THEMED(missionControlIconPreviewShadowRadius); // iconView.layer.cornerRadius; - iconView.layer.shadowOpacity = 0.8; - iconView.layer.shadowOffset = CGSizeMake(0, 0); - //iconView.layer.shouldRasterize = YES; - //iconView.layer.rasterizationScale = UIScreen.mainScreen.scale; - iconView.userInteractionEnabled = NO; - iconView.iconLabelAlpha = 0; - CGFloat scale = (iconView.frame.size.width - 3.0) / iconView.frame.size.width; - iconView.transform = CGAffineTransformMakeScale(scale, scale); - - [self performSelectorOnMainThread:@selector(addSubview:) withObject:iconView waitUntilDone:NO]; - [self performSelectorOnMainThread:@selector(updateIconViewFrame) withObject:nil waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(addSubview:) withObject:iconView waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(updateIconViewFrame) withObject:nil waitUntilDone:NO]; } -(void) generatePreviewAsync @@ -69,9 +68,9 @@ -(void) updateIconViewFrame { - if (!iconView) - return; - [self bringSubviewToFront:iconView]; - iconView.frame = CGRectMake( (self.frame.size.width / 2) - (iconView.frame.size.width / 2), (self.frame.size.height / 2) - (iconView.frame.size.height / 2), iconView.frame.size.width, iconView.frame.size.height ); + if (!iconView) + return; + [self bringSubviewToFront:iconView]; + iconView.frame = CGRectMake( (self.frame.size.width / 2) - (iconView.frame.size.width / 2), (self.frame.size.height / 2) - (iconView.frame.size.height / 2), iconView.frame.size.width, iconView.frame.size.height ); } @end diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index ee950f1..df34de2 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -165,7 +165,7 @@ NSArray *switcherOrder = [[%c(RAAppSwitcherModelWrapper) appSwitcherAppIdentiferList] copy]; [runningApplications sortUsingComparator:^NSComparisonResult(SBApplication *obj1, SBApplication *obj2) { - return [@([switcherOrder indexOfObject:obj1.bundleIdentifier]) compare:@([switcherOrder indexOfObject:obj2.bundleIdentifier])]; + return [@([switcherOrder indexOfObject:obj1.bundleIdentifier]) compare:@([switcherOrder indexOfObject:obj2.bundleIdentifier])]; }]; appsWithoutWindows = [runningApplications mutableCopy]; @@ -446,10 +446,10 @@ //newCenter.y += initialCenter.y; //draggedView.center = newCenter; - CGPoint center = draggedView.center; - center.x += point.x - lastPoint.x; - center.y += point.y - lastPoint.y; - draggedView.center = center; + CGPoint center = draggedView.center; + center.x += point.x - lastPoint.x; + center.y += point.y - lastPoint.y; + draggedView.center = center; } else { @@ -458,9 +458,9 @@ //CGPoint center = [gesture translationInView:draggedView]; //center.x += initialCenter.x; //center.y += initialCenter.y; - CGPoint center = draggedView.center; - center.x += point.x - lastPoint.x; - center.y += point.y - lastPoint.y; + CGPoint center = draggedView.center; + center.x += point.x - lastPoint.x; + center.y += point.y - lastPoint.y; BOOL didKill = NO; @@ -670,16 +670,16 @@ -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { - NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; - UIView *subview; - while ((subview = [objects nextObject])) - { - UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; - if (success) - return success; - } - return self; - //return [super hitTest:point withEvent:event]; + NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; + UIView *subview; + while ((subview = [objects nextObject])) + { + UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; + if (success) + return success; + } + return self; + //return [super hitTest:point withEvent:event]; } - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event diff --git a/Multiplexer.xm b/Multiplexer.xm index 9fef4ba..7384fd8 100644 --- a/Multiplexer.xm +++ b/Multiplexer.xm @@ -36,25 +36,25 @@ else { // ** below code from Mirmir (https://github.com/EthanArbuckle/Mirmir/blob/lamo_no_ms/Lamo/CDTLamo.mm#L114-L138) - SBWorkspaceApplicationTransitionContext *transitionContext = [[%c(SBWorkspaceApplicationTransitionContext) alloc] init]; + SBWorkspaceApplicationTransitionContext *transitionContext = [[%c(SBWorkspaceApplicationTransitionContext) alloc] init]; - //set layout role to 'side' (deactivating) - SBWorkspaceDeactivatingEntity *deactivatingEntity = [%c(SBWorkspaceDeactivatingEntity) entity]; - [deactivatingEntity setLayoutRole:3]; - [transitionContext setEntity:deactivatingEntity forLayoutRole:3]; + //set layout role to 'side' (deactivating) + SBWorkspaceDeactivatingEntity *deactivatingEntity = [%c(SBWorkspaceDeactivatingEntity) entity]; + [deactivatingEntity setLayoutRole:3]; + [transitionContext setEntity:deactivatingEntity forLayoutRole:3]; - //set layout role for 'primary' (activating) - SBWorkspaceHomeScreenEntity *homescreenEntity = [[%c(SBWorkspaceHomeScreenEntity) alloc] init]; - [transitionContext setEntity:homescreenEntity forLayoutRole:2]; + //set layout role for 'primary' (activating) + SBWorkspaceHomeScreenEntity *homescreenEntity = [[%c(SBWorkspaceHomeScreenEntity) alloc] init]; + [transitionContext setEntity:homescreenEntity forLayoutRole:2]; - [transitionContext setAnimationDisabled:YES]; + [transitionContext setAnimationDisabled:YES]; - //create transititon request - SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[%c(FBDisplayManager) mainDisplay]]; - [transitionRequest setApplicationContext:transitionContext]; + //create transititon request + SBMainWorkspaceTransitionRequest *transitionRequest = [[%c(SBMainWorkspaceTransitionRequest) alloc] initWithDisplay:[%c(FBDisplayManager) mainDisplay]]; + [transitionRequest setApplicationContext:transitionContext]; - return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithTransitionRequest:transitionRequest]; - } + return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithTransitionRequest:transitionRequest]; + } } +(BOOL) shouldShowControlCenterGrabberOnFirstSwipe diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index ac7719b..f578270 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -29,12 +29,12 @@ BOOL shouldLoadView = NO; %hook SBNotificationCenterViewController - (void)viewWillAppear:(BOOL)animated { - %orig; + %orig; - BOOL hideBecauseLS = [[%c(SBLockScreenManager) sharedInstance] isUILocked] ? [RASettings.sharedInstance ncAppHideOnLS] : NO; + BOOL hideBecauseLS = [[%c(SBLockScreenManager) sharedInstance] isUILocked] ? [RASettings.sharedInstance ncAppHideOnLS] : NO; - if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) - { + if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) + { SBModeViewController* modeVC = MSHookIvar(self, "_modeController"); if (!ncAppViewController) ncAppViewController = [self _newBulletinObserverViewControllerOfClass:[RANCViewController class]]; @@ -61,12 +61,12 @@ BOOL shouldLoadView = NO; %hook SBNotificationCenterLayoutViewController - (void)viewWillAppear:(BOOL)animated { - %orig; + %orig; - BOOL hideBecauseLS = [[%c(SBLockScreenManager) sharedInstance] isUILocked] ? [RASettings.sharedInstance ncAppHideOnLS] : NO; + BOOL hideBecauseLS = [[%c(SBLockScreenManager) sharedInstance] isUILocked] ? [RASettings.sharedInstance ncAppHideOnLS] : NO; - if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) - { + if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) + { SBModeViewController* modeVC = MSHookIvar(self, "_modeViewController"); if (!ncAppViewController) ncAppViewController = [[RANCViewController alloc] init]; diff --git a/RAAppKiller.xm b/RAAppKiller.xm index 89333a9..27e6d84 100644 --- a/RAAppKiller.xm +++ b/RAAppKiller.xm @@ -53,7 +53,7 @@ extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSStrin { // Try nicely FBApplicationProcess *process = [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:app.bundleIdentifier]; - [process killForReason:1 andReport:NO withDescription:@"PSY SLAYED" completion:nil]; + [process killForReason:1 andReport:NO withDescription:@"PSY SLAYED" completion:nil]; } /*else if (tries == 1) { diff --git a/RAAppSelectorView.xm b/RAAppSelectorView.xm index f5ccf5a..0bd37b7 100644 --- a/RAAppSelectorView.xm +++ b/RAAppSelectorView.xm @@ -5,8 +5,8 @@ { if (self = [super initWithFrame:frame]) { - self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7]; - self.scrollEnabled = YES; + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7]; + self.scrollEnabled = YES; } return self; } @@ -15,18 +15,18 @@ { [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; - static CGSize fullSize = [%c(SBIconView) defaultIconSize]; - fullSize.height = fullSize.width; - CGFloat padding = 20; + static CGSize fullSize = [%c(SBIconView) defaultIconSize]; + fullSize.height = fullSize.width; + CGFloat padding = 20; - NSInteger numIconsPerLine = 0; - CGFloat tmpWidth = 10; - while (tmpWidth + fullSize.width <= self.frame.size.width) - { - numIconsPerLine++; - tmpWidth += fullSize.width + 20; - } - padding = (self.frame.size.width - (numIconsPerLine * fullSize.width)) / (numIconsPerLine + 1); + NSInteger numIconsPerLine = 0; + CGFloat tmpWidth = 10; + while (tmpWidth + fullSize.width <= self.frame.size.width) + { + numIconsPerLine++; + tmpWidth += fullSize.width + 20; + } + padding = (self.frame.size.width - (numIconsPerLine * fullSize.width)) / (numIconsPerLine + 1); CGSize contentSize = CGSizeMake(padding, 10); int horizontal = 0; @@ -58,24 +58,24 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) - continue; + if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) + continue; - iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); - contentSize.width += iconView.frame.size.width + padding; + iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); + contentSize.width += iconView.frame.size.width + padding; - horizontal++; - if (horizontal >= numIconsPerLine) - { - horizontal = 0; - contentSize.width = padding; - contentSize.height += iconView.frame.size.height + 10; - } + horizontal++; + if (horizontal >= numIconsPerLine) + { + horizontal = 0; + contentSize.width = padding; + contentSize.height += iconView.frame.size.height + 10; + } - iconView.restorationIdentifier = app.bundleIdentifier; - UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; - [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; - [self addSubview:iconView]; + iconView.restorationIdentifier = app.bundleIdentifier; + UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; + [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; + [self addSubview:iconView]; } contentSize.width = self.frame.size.width; contentSize.height += fullSize.height * 1.5; diff --git a/RAAppSliderProviderView.mm b/RAAppSliderProviderView.mm index d5d6155..0365d3b 100644 --- a/RAAppSliderProviderView.mm +++ b/RAAppSliderProviderView.mm @@ -41,19 +41,19 @@ -(void) updateCurrentView currentView = [swipeProvider viewAtCurrentIndex]; if (self.isSwipeable && self.swipeProvider) - { - self.backgroundColor = [UIColor clearColor]; // redColor]; - self.userInteractionEnabled = YES; - - [RAGestureManager.sharedInstance addGestureRecognizerWithTarget:self forEdge:UIRectEdgeLeft | UIRectEdgeRight identifier:currentView.bundleIdentifier priority:RAGesturePriorityHigh]; - //[RAGestureManager.sharedInstance addGestureRecognizerWithTarget:self forEdge:UIRectEdgeRight identifier:currentView.bundleIdentifier priority:RAGesturePriorityHigh]; - - currentView.frame = CGRectMake(0, 0, self.frame.size.width - 0, self.frame.size.height); - } - else - currentView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); - [self addSubview:currentView]; - [self load]; + { + self.backgroundColor = [UIColor clearColor]; // redColor]; + self.userInteractionEnabled = YES; + + [RAGestureManager.sharedInstance addGestureRecognizerWithTarget:self forEdge:UIRectEdgeLeft | UIRectEdgeRight identifier:currentView.bundleIdentifier priority:RAGesturePriorityHigh]; + //[RAGestureManager.sharedInstance addGestureRecognizerWithTarget:self forEdge:UIRectEdgeRight identifier:currentView.bundleIdentifier priority:RAGesturePriorityHigh]; + + currentView.frame = CGRectMake(0, 0, self.frame.size.width - 0, self.frame.size.height); + } + else + currentView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); + [self addSubview:currentView]; + [self load]; } -(CGRect) clientFrame @@ -107,4 +107,4 @@ -(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)st } return RAGestureCallbackResultFailure; } -@end \ No newline at end of file +@end diff --git a/RAAppSwitcherModelWrapper.xm b/RAAppSwitcherModelWrapper.xm index 1ee4406..7c43835 100644 --- a/RAAppSwitcherModelWrapper.xm +++ b/RAAppSwitcherModelWrapper.xm @@ -44,11 +44,11 @@ +(void) removeItemWithIdentifier:(NSString*)ident { - SBDisplayItem *item = [%c(SBDisplayItem) displayItemWithType:@"App" displayIdentifier:ident]; - id appSwitcherModel = [%c(SBAppSwitcherModel) sharedInstance]; - if ([appSwitcherModel respondsToSelector:@selector(removeDisplayItem:)]) - [[%c(SBAppSwitcherModel) sharedInstance] removeDisplayItem:item]; - else - [[%c(SBAppSwitcherModel) sharedInstance] remove:item]; + SBDisplayItem *item = [%c(SBDisplayItem) displayItemWithType:@"App" displayIdentifier:ident]; + id appSwitcherModel = [%c(SBAppSwitcherModel) sharedInstance]; + if ([appSwitcherModel respondsToSelector:@selector(removeDisplayItem:)]) + [[%c(SBAppSwitcherModel) sharedInstance] removeDisplayItem:item]; + else + [[%c(SBAppSwitcherModel) sharedInstance] remove:item]; } @end diff --git a/RACompatibilitySystem.mm b/RACompatibilitySystem.mm index d192ae3..e027585 100644 --- a/RACompatibilitySystem.mm +++ b/RACompatibilitySystem.mm @@ -10,13 +10,13 @@ +(NSString*) aggregateSystemInfo { NSMutableString *ret = [[NSMutableString alloc] init]; - struct utsname systemInfo; - uname(&systemInfo); - NSString *sysInfo = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; + struct utsname systemInfo; + uname(&systemInfo); + NSString *sysInfo = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; - [ret appendString:[NSString stringWithFormat:@"%@, %@ %@\n", sysInfo, UIDevice.currentDevice.systemName, UIDevice.currentDevice.systemVersion]]; + [ret appendString:[NSString stringWithFormat:@"%@, %@ %@\n", sysInfo, UIDevice.currentDevice.systemName, UIDevice.currentDevice.systemVersion]]; - return ret; + return ret; } +(void) showWarning:(NSString*)info @@ -24,8 +24,8 @@ +(void) showWarning:(NSString*)info NSString *message = [NSString stringWithFormat:@"System info: %@\n\nWARNING: POTENTIAL INCOMPATIBILITY DETECTED\n%@", [self aggregateSystemInfo], info]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Multiplexer Compatibility" message:message preferredStyle:UIAlertControllerStyleAlert]; - [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; - [alert show]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; + [alert show]; } +(void) showError:(NSString*)info @@ -33,7 +33,7 @@ +(void) showError:(NSString*)info NSString *message = [NSString stringWithFormat:@"System info: %@\n\n***ERROR***: POTENTIAL INCOMPATIBILITY DETECTED\n%@", [self aggregateSystemInfo], info]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Multiplexer Compatibility" message:message preferredStyle:UIAlertControllerStyleAlert]; - [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; - [alert show]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; + [alert show]; } @end diff --git a/RAControlCenterInhibitor.xm b/RAControlCenterInhibitor.xm index ad31bd9..8a0bf3f 100644 --- a/RAControlCenterInhibitor.xm +++ b/RAControlCenterInhibitor.xm @@ -18,21 +18,21 @@ BOOL overrideCC = NO; %hook SBUIController - (void)_showControlCenterGestureBeganWithLocation:(CGPoint)arg1 { - if (!overrideCC) - %orig; + if (!overrideCC) + %orig; } - (void)handleShowControlCenterSystemGesture:(__unsafe_unretained id)arg1 { - if (!overrideCC) - %orig; + if (!overrideCC) + %orig; } %end %hook SBControlCenterController - (void)presentAnimated:(BOOL)arg1 completion:(id)arg2 { - if (!overrideCC) - %orig; + if (!overrideCC) + %orig; } %end diff --git a/RAFakePhoneMode.xm b/RAFakePhoneMode.xm index 276e023..a75db63 100644 --- a/RAFakePhoneMode.xm +++ b/RAFakePhoneMode.xm @@ -16,32 +16,32 @@ CGSize forcePhoneModeSize = RA_6P_SIZE; @implementation RAFakePhoneMode +(void) load { - // Prevent iPhone issue - if (IS_IPAD) - { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // somehow, this is needed to make sure that both force resizing and Fake Phone Mode work. Without the dispatch_after, even if fake phone mode is disabled, - // force resizing seems to render touches incorrectly ¯\_(ツ)_/¯ - IF_NOT_SPRINGBOARD - { - if ([RAFakePhoneMode shouldFakeForThisProcess]) - { - dlopen("/Library/MobileSubstrate/DynamicLibraries/ReachAppFakePhoneMode.dylib", RTLD_NOW); - } - } - }); - } + // Prevent iPhone issue + if (IS_IPAD) + { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // somehow, this is needed to make sure that both force resizing and Fake Phone Mode work. Without the dispatch_after, even if fake phone mode is disabled, + // force resizing seems to render touches incorrectly ¯\_(ツ)_/¯ + IF_NOT_SPRINGBOARD + { + if ([RAFakePhoneMode shouldFakeForThisProcess]) + { + dlopen("/Library/MobileSubstrate/DynamicLibraries/ReachAppFakePhoneMode.dylib", RTLD_NOW); + } + } + }); + } } +(CGSize) fakedSize { - if (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)) - return CGSizeMake(forcePhoneModeSize.height, forcePhoneModeSize.width); - return forcePhoneModeSize; + if (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)) + return CGSizeMake(forcePhoneModeSize.height, forcePhoneModeSize.width); + return forcePhoneModeSize; } +(CGSize) fakeSizeForAppWithIdentifier:(NSString*)identifier { - return forcePhoneModeSize; + return forcePhoneModeSize; } +(void) updateAppSizing @@ -53,27 +53,27 @@ CGSize forcePhoneModeSize = RA_6P_SIZE; +(BOOL) shouldFakeForAppWithIdentifier:(NSString*)identifier { - IF_SPRINGBOARD { - return [RAMessagingServer.sharedInstance getDataForIdentifier:identifier].forcePhoneMode; - } - LogWarn(@"[ReachApp] WARNING: +[RAFakePhoneMode shouldFakeForAppWithIdentifier:] called from outside SpringBoard!"); - return NO; + IF_SPRINGBOARD { + return [RAMessagingServer.sharedInstance getDataForIdentifier:identifier].forcePhoneMode; + } + LogWarn(@"[ReachApp] WARNING: +[RAFakePhoneMode shouldFakeForAppWithIdentifier:] called from outside SpringBoard!"); + return NO; } +(BOOL) shouldFakeForThisProcess { - static char fakeFlag = 0; - static dispatch_once_t onceToken = 0; - dispatch_once(&onceToken, ^{ - if (!RAMessagingClient.sharedInstance.hasRecievedData) - { - [RAMessagingClient.sharedInstance requestUpdateFromServer]; - } + static char fakeFlag = 0; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + if (!RAMessagingClient.sharedInstance.hasRecievedData) + { + [RAMessagingClient.sharedInstance requestUpdateFromServer]; + } - fakeFlag = RAMessagingClient.sharedInstance.currentData.forcePhoneMode; - }); + fakeFlag = RAMessagingClient.sharedInstance.currentData.forcePhoneMode; + }); - return fakeFlag; + return fakeFlag; } @end diff --git a/RAHostManager.xm b/RAHostManager.xm index b8c3ab3..e735cfb 100644 --- a/RAHostManager.xm +++ b/RAHostManager.xm @@ -22,21 +22,21 @@ if ([app respondsToSelector:@selector(mainScene)]) { - [[UIApplication sharedApplication] launchApplicationWithIdentifier:app.bundleIdentifier suspended:YES]; + [[UIApplication sharedApplication] launchApplicationWithIdentifier:app.bundleIdentifier suspended:YES]; - FBScene *scene = [app mainScene]; - FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; + FBScene *scene = [app mainScene]; + FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; - FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; - if (!settings) - return nil; + FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; + if (!settings) + return nil; - SET_BACKGROUNDED(settings, NO); - [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; + SET_BACKGROUNDED(settings, NO); + [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; - [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; - UIView *hostView = [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES]; - return hostView; + [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; + UIView *hostView = [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES]; + return hostView; } [RACompatibilitySystem showWarning:@"Unable to find valid method for accessing context host views"]; @@ -50,8 +50,8 @@ if ([app respondsToSelector:@selector(mainScene)]) { - FBScene *scene = [app mainScene]; - return (NSObject*)[scene contextHostManager]; + FBScene *scene = [app mainScene]; + return (NSObject*)[scene contextHostManager]; } [RACompatibilitySystem showWarning:@"Unable to find valid method for accessing context host view managers"]; diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index f72ad80..357d161 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -32,9 +32,9 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; @implementation RAHostedAppView -(instancetype) initWithBundleIdentifier:(NSString*)bundleIdentifier { - if (self = [super init]) - { - self.bundleIdentifier = bundleIdentifier; + if (self = [super init]) + { + self.bundleIdentifier = bundleIdentifier; self.autosizesApp = NO; self.allowHidingStatusBar = YES; self.showSplashscreenInsteadOfSpinner = NO; @@ -42,422 +42,421 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; disablePreload = NO; self.renderWallpaper = NO; self.backgroundColor = [UIColor clearColor]; - } - - return self; + } + + return self; } -(void) _preloadOrAttemptToUpdateReachabilityCounterpart { - if (app) + if (app) + { + if ([app mainScene]) + { + isPreloading = NO; + if (((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive && [GET_SBWORKSPACE respondsToSelector:@selector(RA_updateViewSizes)]) + [GET_SBWORKSPACE performSelector:@selector(RA_updateViewSizes) withObject:nil afterDelay:0.5]; // App is launched using ReachApp - animations commence. We have to wait for those animations to finish or this won't work. + } + else if (![app mainScene]) { - if ([app mainScene]) - { - isPreloading = NO; - if (((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive && [GET_SBWORKSPACE respondsToSelector:@selector(RA_updateViewSizes)]) - [GET_SBWORKSPACE performSelector:@selector(RA_updateViewSizes) withObject:nil afterDelay:0.5]; // App is launched using ReachApp - animations commence. We have to wait for those animations to finish or this won't work. - } - else if (![app mainScene]) - { - if (disablePreload) - disablePreload = NO; - else - [self preloadApp]; - } + if (disablePreload) + disablePreload = NO; + else + [self preloadApp]; } + } } -(void) setBundleIdentifier:(NSString*)value { - _orientation = UIInterfaceOrientationPortrait; - _bundleIdentifier = value; - app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:value]; + _orientation = UIInterfaceOrientationPortrait; + _bundleIdentifier = value; + app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:value]; } -(void) setShouldUseExternalKeyboard:(BOOL)value { - _shouldUseExternalKeyboard = value; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:value forApp:self.bundleIdentifier completion:nil]; + _shouldUseExternalKeyboard = value; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:value forApp:self.bundleIdentifier completion:nil]; } -(void) preloadApp { - startTries++; - if (startTries > 5) - { - isPreloading = NO; - LogDebug(@"[ReachApp] maxed out preload attempts for app %@", app.bundleIdentifier); - UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Zypen" - message:[NSString stringWithFormat:@"Unable to start app %@", app.displayName] - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) {}]; - [alert addAction:defaultAction]; - [self.inputViewController presentViewController:alert animated:YES completion:nil]; - return; - } - - if (!app) - return; - - if (_isCurrentlyHosting) - return; - - isPreloading = YES; - FBScene *scene = [app mainScene]; - if (![app pid] || !scene) - { - LogDebug(@"has no pid or scene, createApplicationProcessForBundleID"); - [UIApplication.sharedApplication launchApplicationWithIdentifier:self.bundleIdentifier suspended:YES]; - [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:self.bundleIdentifier]; // ummm...? - } - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self _preloadOrAttemptToUpdateReachabilityCounterpart]; }); - // this ^ runs either way. when _preloadOrAttemptToUpdateReachabilityCounterpart runs, if the app is "loaded" it will not call preloadApp again, otherwise - // it will call it again. + startTries++; + if (startTries > 5) + { + isPreloading = NO; + LogDebug(@"[ReachApp] maxed out preload attempts for app %@", app.bundleIdentifier); + UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Zypen" + message:[NSString stringWithFormat:@"Unable to start app %@", app.displayName] + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + [alert addAction:defaultAction]; + [self.inputViewController presentViewController:alert animated:YES completion:nil]; + return; + } + + if (!app) + return; + + if (_isCurrentlyHosting) + return; + + isPreloading = YES; + FBScene *scene = [app mainScene]; + if (![app pid] || !scene) + { + LogDebug(@"has no pid or scene, createApplicationProcessForBundleID"); + [UIApplication.sharedApplication launchApplicationWithIdentifier:self.bundleIdentifier suspended:YES]; + [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:self.bundleIdentifier]; // ummm...? + } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self _preloadOrAttemptToUpdateReachabilityCounterpart]; }); + // this ^ runs either way. when _preloadOrAttemptToUpdateReachabilityCounterpart runs, if the app is "loaded" it will not call preloadApp again, otherwise + // it will call it again. } -(void) _actualLoadApp { - if (isPreloading) - { - [self performSelector:@selector(_actualLoadApp) withObject:nil afterDelay:0.3]; - return; - } + if (isPreloading) + { + [self performSelector:@selector(_actualLoadApp) withObject:nil afterDelay:0.3]; + return; + } - if (_isCurrentlyHosting) - return; + if (_isCurrentlyHosting) + return; - _isCurrentlyHosting = YES; + _isCurrentlyHosting = YES; - appsBeingHosted[app.bundleIdentifier] = [appsBeingHosted objectForKey:app.bundleIdentifier] ? @([appsBeingHosted[app.bundleIdentifier] intValue] + 1) : @1; - view = (FBWindowContextHostWrapperView*)[RAHostManager enabledHostViewForApplication:app]; - contextHostManager = (FBWindowContextHostManager*)[RAHostManager hostManagerForApp:app]; - view.backgroundColorWhileNotHosting = [UIColor clearColor]; - view.backgroundColorWhileHosting = [UIColor clearColor]; + appsBeingHosted[app.bundleIdentifier] = [appsBeingHosted objectForKey:app.bundleIdentifier] ? @([appsBeingHosted[app.bundleIdentifier] intValue] + 1) : @1; + view = (FBWindowContextHostWrapperView*)[RAHostManager enabledHostViewForApplication:app]; + contextHostManager = (FBWindowContextHostManager*)[RAHostManager hostManagerForApp:app]; + view.backgroundColorWhileNotHosting = [UIColor clearColor]; + view.backgroundColorWhileHosting = [UIColor clearColor]; - view.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); - //view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + view.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); + //view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - [self addSubview:view]; + [self addSubview:view]; - [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; - if (IS_IPAD) - [RAHostedAppView iPad_iOS83_fixHosting]; + [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; + if (IS_IPAD) + [RAHostedAppView iPad_iOS83_fixHosting]; - [RARunningAppsProvider.sharedInstance addTarget:self]; + [RARunningAppsProvider.sharedInstance addTarget:self]; - loadedTimer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(verifyHostingAndRehostIfNecessary) userInfo:nil repeats:YES]; - [[NSRunLoop currentRunLoop] addTimer:loadedTimer forMode:NSRunLoopCommonModes]; + loadedTimer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(verifyHostingAndRehostIfNecessary) userInfo:nil repeats:YES]; + [[NSRunLoop currentRunLoop] addTimer:loadedTimer forMode:NSRunLoopCommonModes]; } -(void) loadApp { - startTries = 0; - disablePreload = NO; - [self preloadApp]; - if (!app) - return; - - if (_isCurrentlyHosting) - return; - - if ([UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:app]) - { - isForemostAppLabel = [[UILabel alloc] initWithFrame:self.bounds]; - isForemostAppLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; - isForemostAppLabel.textColor = [UIColor whiteColor]; - isForemostAppLabel.textAlignment = NSTextAlignmentCenter; - isForemostAppLabel.font = [UIFont systemFontOfSize:36]; - isForemostAppLabel.numberOfLines = 0; - isForemostAppLabel.lineBreakMode = NSLineBreakByWordWrapping; - isForemostAppLabel.text = [NSString stringWithFormat:LOCALIZE(@"ACTIVE_APP_WARNING"),self.app.displayName]; - [self addSubview:isForemostAppLabel]; - return; - } + startTries = 0; + disablePreload = NO; + [self preloadApp]; + if (!app) + return; + + if (_isCurrentlyHosting) + return; + + if ([UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:app]) + { + isForemostAppLabel = [[UILabel alloc] initWithFrame:self.bounds]; + isForemostAppLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; + isForemostAppLabel.textColor = [UIColor whiteColor]; + isForemostAppLabel.textAlignment = NSTextAlignmentCenter; + isForemostAppLabel.font = [UIFont systemFontOfSize:36]; + isForemostAppLabel.numberOfLines = 0; + isForemostAppLabel.lineBreakMode = NSLineBreakByWordWrapping; + isForemostAppLabel.text = [NSString stringWithFormat:LOCALIZE(@"ACTIVE_APP_WARNING"),self.app.displayName]; + [self addSubview:isForemostAppLabel]; + return; + } + + IF_BIOLOCKDOWN { + id failedBlock = ^{ + [self removeLoadingIndicator]; + if (!authenticationDidFailLabel) + { + authenticationDidFailLabel = [[UILabel alloc] initWithFrame:self.bounds]; + authenticationDidFailLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; + authenticationDidFailLabel.textColor = [UIColor whiteColor]; + authenticationDidFailLabel.textAlignment = NSTextAlignmentCenter; + authenticationDidFailLabel.font = [UIFont systemFontOfSize:36]; + authenticationDidFailLabel.numberOfLines = 0; + authenticationDidFailLabel.lineBreakMode = NSLineBreakByWordWrapping; + authenticationDidFailLabel.text = [NSString stringWithFormat:LOCALIZE(@"BIOLOCKDOWN_AUTH_FAILED"),self.app.displayName]; + [self addSubview:authenticationDidFailLabel]; + + authenticationFailedRetryTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loadApp)]; + [self addGestureRecognizer:authenticationFailedRetryTapGesture]; + self.userInteractionEnabled = YES; + } + }; - IF_BIOLOCKDOWN { - id failedBlock = ^{ - [self removeLoadingIndicator]; - if (!authenticationDidFailLabel) - { - authenticationDidFailLabel = [[UILabel alloc] initWithFrame:self.bounds]; - authenticationDidFailLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; - authenticationDidFailLabel.textColor = [UIColor whiteColor]; - authenticationDidFailLabel.textAlignment = NSTextAlignmentCenter; - authenticationDidFailLabel.font = [UIFont systemFontOfSize:36]; - authenticationDidFailLabel.numberOfLines = 0; - authenticationDidFailLabel.lineBreakMode = NSLineBreakByWordWrapping; - authenticationDidFailLabel.text = [NSString stringWithFormat:LOCALIZE(@"BIOLOCKDOWN_AUTH_FAILED"),self.app.displayName]; - [self addSubview:authenticationDidFailLabel]; - - authenticationFailedRetryTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loadApp)]; - [self addGestureRecognizer:authenticationFailedRetryTapGesture]; - self.userInteractionEnabled = YES; - } - }; - - BIOLOCKDOWN_AUTHENTICATE_APP(app.bundleIdentifier, ^{ - [self _actualLoadApp]; - }, failedBlock /* stupid commas */); - } - else IF_ASPHALEIA - { - void (^failedBlock)() = ^{ - [self removeLoadingIndicator]; - if (!authenticationDidFailLabel) - { - authenticationDidFailLabel = [[UILabel alloc] initWithFrame:self.bounds]; - authenticationDidFailLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; - authenticationDidFailLabel.textColor = [UIColor whiteColor]; - authenticationDidFailLabel.textAlignment = NSTextAlignmentCenter; - authenticationDidFailLabel.font = [UIFont systemFontOfSize:36]; - authenticationDidFailLabel.numberOfLines = 0; - authenticationDidFailLabel.lineBreakMode = NSLineBreakByWordWrapping; - authenticationDidFailLabel.text = [NSString stringWithFormat:LOCALIZE(@"ASPHALEIA_AUTH_FAILED"),self.app.displayName]; - [self addSubview:authenticationDidFailLabel]; - - authenticationFailedRetryTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loadApp)]; - [self addGestureRecognizer:authenticationFailedRetryTapGesture]; - self.userInteractionEnabled = YES; - } - }; - - ASPHALEIA_AUTHENTICATE_APP(app.bundleIdentifier, ^{ - [self _actualLoadApp]; - }, failedBlock); - } - else - { + BIOLOCKDOWN_AUTHENTICATE_APP(app.bundleIdentifier, ^{ [self _actualLoadApp]; - } + }, failedBlock /* stupid commas */); + } + else IF_ASPHALEIA + { + void (^failedBlock)() = ^{ + [self removeLoadingIndicator]; + if (!authenticationDidFailLabel) + { + authenticationDidFailLabel = [[UILabel alloc] initWithFrame:self.bounds]; + authenticationDidFailLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; + authenticationDidFailLabel.textColor = [UIColor whiteColor]; + authenticationDidFailLabel.textAlignment = NSTextAlignmentCenter; + authenticationDidFailLabel.font = [UIFont systemFontOfSize:36]; + authenticationDidFailLabel.numberOfLines = 0; + authenticationDidFailLabel.lineBreakMode = NSLineBreakByWordWrapping; + authenticationDidFailLabel.text = [NSString stringWithFormat:LOCALIZE(@"ASPHALEIA_AUTH_FAILED"),self.app.displayName]; + [self addSubview:authenticationDidFailLabel]; + + authenticationFailedRetryTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loadApp)]; + [self addGestureRecognizer:authenticationFailedRetryTapGesture]; + self.userInteractionEnabled = YES; + } + }; - if (self.showSplashscreenInsteadOfSpinner) + ASPHALEIA_AUTHENTICATE_APP(app.bundleIdentifier, ^{ + [self _actualLoadApp]; + }, failedBlock); + } + else + { + [self _actualLoadApp]; + } + + if (self.showSplashscreenInsteadOfSpinner) + { + if (splashScreenImageView) { - if (splashScreenImageView) - { - [splashScreenImageView removeFromSuperview]; - splashScreenImageView = nil; - } - UIImage *img = [RASnapshotProvider.sharedInstance snapshotForIdentifier:self.bundleIdentifier]; - splashScreenImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; - splashScreenImageView.image = img; - [self insertSubview:splashScreenImageView atIndex:0]; + [splashScreenImageView removeFromSuperview]; + splashScreenImageView = nil; } - else + UIImage *img = [RASnapshotProvider.sharedInstance snapshotForIdentifier:self.bundleIdentifier]; + splashScreenImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; + splashScreenImageView.image = img; + [self insertSubview:splashScreenImageView atIndex:0]; + } + else + { + if (!activityView) { - if (!activityView) - { - activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; - [self addSubview:activityView]; - } + activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + [self addSubview:activityView]; + } - CGFloat size = 50; - activityView.frame = CGRectMake((self.bounds.size.width - size) / 2, (self.bounds.size.height - size) / 2, size, size); + CGFloat size = 50; + activityView.frame = CGRectMake((self.bounds.size.width - size) / 2, (self.bounds.size.height - size) / 2, size, size); - [activityView startAnimating]; - } + [activityView startAnimating]; + } } -(void) verifyHostingAndRehostIfNecessary { - if (!isPreloading && _isCurrentlyHosting && (!app.isRunning || !view.contextHosted)) // && (app.pid == 0 || view == nil || view.manager == nil)) // || view._isReallyHosting == NO)) - { - //[activityView startAnimating]; - [self unloadApp]; - [self loadApp]; - } - else - { - [self removeLoadingIndicator]; - [loadedTimer invalidate]; - loadedTimer = nil; - } + if (!isPreloading && _isCurrentlyHosting && (!app.isRunning || !view.contextHosted)) // && (app.pid == 0 || view == nil || view.manager == nil)) // || view._isReallyHosting == NO)) + { + //[activityView startAnimating]; + [self unloadApp]; + [self loadApp]; + } + else + { + [self removeLoadingIndicator]; + [loadedTimer invalidate]; + loadedTimer = nil; + } } -(void) appDidDie:(SBApplication*)app_ { - if (app_ == self.app) - { - [self verifyHostingAndRehostIfNecessary]; - } + if (app_ == self.app) + { + [self verifyHostingAndRehostIfNecessary]; + } } -(void) removeLoadingIndicator { - if (self.showSplashscreenInsteadOfSpinner) - { - [splashScreenImageView removeFromSuperview]; - splashScreenImageView = nil; - } - else if (activityView) - [activityView stopAnimating]; + if (self.showSplashscreenInsteadOfSpinner) + { + [splashScreenImageView removeFromSuperview]; + splashScreenImageView = nil; + } + else if (activityView) + [activityView stopAnimating]; } -(void) drawRect:(CGRect)rect { - if (_renderWallpaper) - [[RASnapshotProvider.sharedInstance wallpaperImage] drawInRect:rect]; + if (_renderWallpaper) + [[RASnapshotProvider.sharedInstance wallpaperImage] drawInRect:rect]; } -(void) setFrame:(CGRect)frame { - [super setFrame:frame]; - [view setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; - - if (self.autosizesApp) - { - RAMessageAppData data = [RAMessagingServer.sharedInstance getDataForIdentifier:self.bundleIdentifier]; - data.canHideStatusBarIfWanted = self.allowHidingStatusBar; - [RAMessagingServer.sharedInstance setData:data forIdentifier:self.bundleIdentifier]; - [RAMessagingServer.sharedInstance resizeApp:self.bundleIdentifier toSize:CGSizeMake(frame.size.width, frame.size.height) completion:nil]; - - } - else if (self.bundleIdentifier) - { - [RAMessagingServer.sharedInstance endResizingApp:self.bundleIdentifier completion:nil]; - } + [super setFrame:frame]; + [view setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; + + if (self.autosizesApp) + { + RAMessageAppData data = [RAMessagingServer.sharedInstance getDataForIdentifier:self.bundleIdentifier]; + data.canHideStatusBarIfWanted = self.allowHidingStatusBar; + [RAMessagingServer.sharedInstance setData:data forIdentifier:self.bundleIdentifier]; + [RAMessagingServer.sharedInstance resizeApp:self.bundleIdentifier toSize:CGSizeMake(frame.size.width, frame.size.height) completion:nil]; + + } + else if (self.bundleIdentifier) + { + [RAMessagingServer.sharedInstance endResizingApp:self.bundleIdentifier completion:nil]; + } } -(void) setHideStatusBar:(BOOL)value { - _hideStatusBar = value; + _hideStatusBar = value; - if (!self.bundleIdentifier) - return; + if (!self.bundleIdentifier) + return; - if (value) - [RAMessagingServer.sharedInstance forceStatusBarVisibility:!value forApp:self.bundleIdentifier completion:nil]; - else - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:self.bundleIdentifier completion:nil]; + if (value) + [RAMessagingServer.sharedInstance forceStatusBarVisibility:!value forApp:self.bundleIdentifier completion:nil]; + else + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:self.bundleIdentifier completion:nil]; } -(void) unloadApp { - [self unloadApp:NO]; + [self unloadApp:NO]; } -(void) unloadApp:(BOOL)forceImmediate { - //if (activityView) - // [activityView stopAnimating]; - [self removeLoadingIndicator]; - [loadedTimer invalidate]; - loadedTimer = nil; - - [RARunningAppsProvider.sharedInstance removeTarget:self]; - - disablePreload = YES; - - if (!_isCurrentlyHosting) - return; - - _isCurrentlyHosting = NO; - - FBScene *scene = [app mainScene]; - - if (authenticationDidFailLabel) - { - [authenticationDidFailLabel removeFromSuperview]; - authenticationDidFailLabel = nil; - - [self removeGestureRecognizer:authenticationFailedRetryTapGesture]; - self.userInteractionEnabled = NO; - } - - if (isForemostAppLabel) - { - [isForemostAppLabel removeFromSuperview]; - isForemostAppLabel = nil; - } - - if ([RASpringBoardKeyboardActivation.sharedInstance.currentIdentifier isEqual:self.bundleIdentifier]) - [RASpringBoardKeyboardActivation.sharedInstance hideKeyboard]; - - if (contextHostManager) - { - [contextHostManager disableHostingForRequester:@"reachapp"]; - contextHostManager = nil; - } - - //if ([UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:app]) - // return; - - __weak RAHostedAppView *weakSelf = self; - __block BOOL didRun = NO; - RAMessageCompletionCallback block = ^(BOOL success) { - if (didRun || (weakSelf && [UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:weakSelf.app])) - return; - if (!scene) - return; - - appsBeingHosted[app.bundleIdentifier] = [appsBeingHosted objectForKey:app.bundleIdentifier] ? @([appsBeingHosted[app.bundleIdentifier] intValue] - 1) : @0; - - if ([appsBeingHosted[app.bundleIdentifier] intValue] > 0) - return; - - FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; - SET_BACKGROUNDED(settings, YES); - [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; - //FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; - didRun = YES; - }; - - [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:app.bundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:self.bundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance unRotateApp:self.bundleIdentifier completion:nil]; - if (forceImmediate) - { - [RAMessagingServer.sharedInstance endResizingApp:self.bundleIdentifier completion:nil]; - block(YES); - } - else - { - // >Somewhere in the messaging server, the block is being removed from the waitingCompletions dictionary without being called. - // >This is a large issue (probably to do with asynchronous code) TODO: FIXME - // lol im retarded, it's the default empty callback the messaging server made - //[RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:self.bundleIdentifier completion:block]; - //[RAMessagingServer.sharedInstance unRotateApp:self.bundleIdentifier completion:block]; - - [RAMessagingServer.sharedInstance endResizingApp:self.bundleIdentifier completion:block]; - } + //if (activityView) + // [activityView stopAnimating]; + [self removeLoadingIndicator]; + [loadedTimer invalidate]; + loadedTimer = nil; + + [RARunningAppsProvider.sharedInstance removeTarget:self]; + + disablePreload = YES; + + if (!_isCurrentlyHosting) + return; + + _isCurrentlyHosting = NO; + + FBScene *scene = [app mainScene]; + + if (authenticationDidFailLabel) + { + [authenticationDidFailLabel removeFromSuperview]; + authenticationDidFailLabel = nil; + + [self removeGestureRecognizer:authenticationFailedRetryTapGesture]; + self.userInteractionEnabled = NO; + } + + if (isForemostAppLabel) + { + [isForemostAppLabel removeFromSuperview]; + isForemostAppLabel = nil; + } + + if ([RASpringBoardKeyboardActivation.sharedInstance.currentIdentifier isEqual:self.bundleIdentifier]) + [RASpringBoardKeyboardActivation.sharedInstance hideKeyboard]; + + if (contextHostManager) + { + [contextHostManager disableHostingForRequester:@"reachapp"]; + contextHostManager = nil; + } + + //if ([UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:app]) + // return; + + __weak RAHostedAppView *weakSelf = self; + __block BOOL didRun = NO; + RAMessageCompletionCallback block = ^(BOOL success) { + if (didRun || (weakSelf && [UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:weakSelf.app])) + return; + if (!scene) + return; + + appsBeingHosted[app.bundleIdentifier] = [appsBeingHosted objectForKey:app.bundleIdentifier] ? @([appsBeingHosted[app.bundleIdentifier] intValue] - 1) : @0; + + if ([appsBeingHosted[app.bundleIdentifier] intValue] > 0) + return; + + FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; + SET_BACKGROUNDED(settings, YES); + [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; + //FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; + didRun = YES; + }; + + [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:app.bundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:self.bundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance unRotateApp:self.bundleIdentifier completion:nil]; + if (forceImmediate) + { + [RAMessagingServer.sharedInstance endResizingApp:self.bundleIdentifier completion:nil]; + block(YES); + } + else + { + // >Somewhere in the messaging server, the block is being removed from the waitingCompletions dictionary without being called. + // >This is a large issue (probably to do with asynchronous code) TODO: FIXME + // lol im retarded, it's the default empty callback the messaging server made + //[RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:self.bundleIdentifier completion:block]; + //[RAMessagingServer.sharedInstance unRotateApp:self.bundleIdentifier completion:block]; + + [RAMessagingServer.sharedInstance endResizingApp:self.bundleIdentifier completion:block]; + } } -(void) rotateToOrientation:(UIInterfaceOrientation)o { - _orientation = o; + _orientation = o; - [RAMessagingServer.sharedInstance rotateApp:self.bundleIdentifier toOrientation:o completion:nil]; + [RAMessagingServer.sharedInstance rotateApp:self.bundleIdentifier toOrientation:o completion:nil]; } +(void) iPad_iOS83_fixHosting { - for (NSString *bundleIdentifier in appsBeingHosted.allKeys) + for (NSString *bundleIdentifier in appsBeingHosted.allKeys) + { + NSNumber *num = appsBeingHosted[bundleIdentifier]; + if (num.intValue > 0) { - NSNumber *num = appsBeingHosted[bundleIdentifier]; - if (num.intValue > 0) - { - SBApplication *app_ = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:bundleIdentifier]; - FBWindowContextHostManager *manager = (FBWindowContextHostManager*)[RAHostManager hostManagerForApp:app_]; - if (manager) - { - LogDebug(@"[ReachApp] rehosting for iPad: %@", bundleIdentifier); - [manager enableHostingForRequester:@"reachapp" priority:1]; - } - } + SBApplication *app_ = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:bundleIdentifier]; + FBWindowContextHostManager *manager = (FBWindowContextHostManager*)[RAHostManager hostManagerForApp:app_]; + if (manager) + { + LogDebug(@"[ReachApp] rehosting for iPad: %@", bundleIdentifier); + [manager enableHostingForRequester:@"reachapp" priority:1]; + } } - + } } // This allows for any subviews (with gestures) (e.g. the SwipeOver bar with a negative y origin) to recieve touch events. - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { - BOOL isContained = NO; - for (UIView *subview in self.subviews) - { - if (CGRectContainsPoint(subview.frame, point)) // [self convertPoint:point toView:view])) - isContained = YES; - } - return isContained; + BOOL isContained = NO; + for (UIView *subview in self.subviews) + { + if (CGRectContainsPoint(subview.frame, point)) // [self convertPoint:point toView:view])) + isContained = YES; + } + return isContained; } -(SBApplication*) app { return app; } diff --git a/RAResourceImageProvider.mm b/RAResourceImageProvider.mm index 1867f48..41b02de 100644 --- a/RAResourceImageProvider.mm +++ b/RAResourceImageProvider.mm @@ -5,86 +5,86 @@ NSCache *_rsImgCache = [NSCache new]; @implementation RAResourceImageProvider -+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize -{ - // from: https://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage - // In next line, pass 0.0 to use the current device's pixel scaling factor (and thus account for Retina resolution). - // Pass 1.0 to force exact pixel size. - UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0); - [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; - UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return newImage; ++ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize +{ + // from: https://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage + // In next line, pass 0.0 to use the current device's pixel scaling factor (and thus account for Retina resolution). + // Pass 1.0 to force exact pixel size. + UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0); + [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; + UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return newImage; } +(id) loadAndCacheImageWithStrippedPath:(NSString*)stripped { - NSString *pdfPath = [NSString stringWithFormat:@"%@/Resources/%@.pdf",resourcePath,stripped]; - NSString *pngPath = [NSString stringWithFormat:@"%@/Resources/%@.png",resourcePath,stripped]; + NSString *pdfPath = [NSString stringWithFormat:@"%@/Resources/%@.pdf",resourcePath,stripped]; + NSString *pngPath = [NSString stringWithFormat:@"%@/Resources/%@.png",resourcePath,stripped]; - if ([NSFileManager.defaultManager fileExistsAtPath:pdfPath]) - { - RAPDFImage *pdf = [RAPDFImage imageWithContentsOfFile:pdfPath]; + if ([NSFileManager.defaultManager fileExistsAtPath:pdfPath]) + { + RAPDFImage *pdf = [RAPDFImage imageWithContentsOfFile:pdfPath]; - if (pdf) - [_rsImgCache setObject:pdf forKey:stripped]; + if (pdf) + [_rsImgCache setObject:pdf forKey:stripped]; - return pdf; - } - else if ([NSFileManager.defaultManager fileExistsAtPath:pngPath]) - { - UIImage *img = [UIImage imageWithContentsOfFile:pngPath]; - if (img) - [_rsImgCache setObject:img forKey:stripped]; + return pdf; + } + else if ([NSFileManager.defaultManager fileExistsAtPath:pngPath]) + { + UIImage *img = [UIImage imageWithContentsOfFile:pngPath]; + if (img) + [_rsImgCache setObject:img forKey:stripped]; - return img; - } + return img; + } - return nil; + return nil; } +(id) getOrCacheImageWithFilename:(NSString*)strippedPath { - return [_rsImgCache objectForKey:strippedPath] ?: [self loadAndCacheImageWithStrippedPath:strippedPath]; + return [_rsImgCache objectForKey:strippedPath] ?: [self loadAndCacheImageWithStrippedPath:strippedPath]; } +(UIImage*) convertToUIImageIfNeeded:(id)arg sizeIfNeeded:(CGSize)size forceSizing:(BOOL)force { - if ([arg isKindOfClass:UIImage.class]) - { - if (force) - return [self imageWithImage:arg scaledToSize:size]; - else - return (UIImage*)arg; - } - - if ([arg isKindOfClass:[RAPDFImage class]]) - { - UIImage *image = [arg imageWithOptions:[RAPDFImageOptions optionsWithSize:size]]; - return image; - } - - return nil; + if ([arg isKindOfClass:UIImage.class]) + { + if (force) + return [self imageWithImage:arg scaledToSize:size]; + else + return (UIImage*)arg; + } + + if ([arg isKindOfClass:[RAPDFImage class]]) + { + UIImage *image = [arg imageWithOptions:[RAPDFImageOptions optionsWithSize:size]]; + return image; + } + + return nil; } +(UIImage*) imageForFilename:(NSString*)filename { - NSString *strippedPath = [[filename lastPathComponent] stringByDeletingPathExtension]; - id img = [self getOrCacheImageWithFilename:strippedPath]; + NSString *strippedPath = [[filename lastPathComponent] stringByDeletingPathExtension]; + id img = [self getOrCacheImageWithFilename:strippedPath]; - return [self convertToUIImageIfNeeded:img sizeIfNeeded:CGSizeMake(200, 200) forceSizing:NO]; + return [self convertToUIImageIfNeeded:img sizeIfNeeded:CGSizeMake(200, 200) forceSizing:NO]; } +(UIImage*) imageForFilename:(NSString*)filename size:(CGSize)size tintedTo:(UIColor*)tint { - return [[self imageForFilename:filename constrainedToSize:size] _flatImageWithColor:tint]; + return [[self imageForFilename:filename constrainedToSize:size] _flatImageWithColor:tint]; } +(UIImage*) imageForFilename:(NSString*)filename constrainedToSize:(CGSize)size { - NSString *strippedPath = [[filename lastPathComponent] stringByDeletingPathExtension]; - id img = [self getOrCacheImageWithFilename:strippedPath]; + NSString *strippedPath = [[filename lastPathComponent] stringByDeletingPathExtension]; + id img = [self getOrCacheImageWithFilename:strippedPath]; - return [self convertToUIImageIfNeeded:img sizeIfNeeded:size forceSizing:YES]; + return [self convertToUIImageIfNeeded:img sizeIfNeeded:size forceSizing:YES]; } -@end \ No newline at end of file +@end diff --git a/RARunningAppsProvider.xm b/RARunningAppsProvider.xm index 205a6d0..f518b59 100644 --- a/RARunningAppsProvider.xm +++ b/RARunningAppsProvider.xm @@ -24,7 +24,7 @@ [apps addObject:app]; for (NSObject* target in targets) if ([target respondsToSelector:@selector(appDidStart:)]) - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_main_queue(), ^{ [target appDidStart:app]; }); @@ -39,7 +39,7 @@ for (NSObject* target in targets) if ([target respondsToSelector:@selector(appDidDie:)]) - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_main_queue(), ^{ [target appDidDie:app]; }); diff --git a/RASettings.mm b/RASettings.mm index f7aaeef..8ef1703 100644 --- a/RASettings.mm +++ b/RASettings.mm @@ -13,7 +13,7 @@ @implementation RASettings +(BOOL) isParagonInstalled { static BOOL installed = NO; - static dispatch_once_t onceToken = 0; + static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ installed = [NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/ParagonPlus.dylib"]; }); @@ -23,7 +23,7 @@ +(BOOL) isParagonInstalled +(BOOL) isActivatorInstalled { static BOOL installed = NO; - static dispatch_once_t onceToken = 0; + static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ if ([NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/libactivator.dylib"]) { @@ -37,7 +37,7 @@ +(BOOL) isActivatorInstalled +(BOOL) isLibStatusBarInstalled { static BOOL installed = NO; - static dispatch_once_t onceToken = 0; + static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ if ([NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib"]) { @@ -143,7 +143,7 @@ -(void) resetSettings CFPreferencesAppSynchronize(appID); CFRelease(appID); - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); } -(BOOL) enabled diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index 31eda15..2540399 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -270,9 +270,9 @@ UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen.bounds.size, YES, UIScreen.mainScreen.scale); CGContextRef c = UIGraphicsGetCurrentContext(); - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAWallpaperSnapshot"]; + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAWallpaperSnapshot"]; - [MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow").layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Wallpaper + [MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow").layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Wallpaper UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); diff --git a/README.md b/README.md index ee6f1e0..94deb16 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ http://moreinfo.thebigboss.org/moreinfo/depiction.php?file=multiplexerDp - iOS 9-like "slide over" (Swipe Over) - Mission Control with multiple desktops (Mission Control) - Windowed multitasking (Empoleon) -- An app in a Notication Center tab (Quick Access) +- An app in a Notification Center tab (Quick Access) - Backgrounding features (Aura) ### Wiki diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 4334db7..91efb32 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -42,107 +42,105 @@ BOOL wasEnabled = NO; %hook SBReachabilityManager +(BOOL)reachabilitySupported { - return YES; + return YES; } - (void)_handleReachabilityActivated { - overrideOrientation = YES; - %orig; - overrideOrientation = NO; + overrideOrientation = YES; + %orig; + overrideOrientation = NO; } - (void)enableExpirationTimerForEndedInteraction { - if ([RASettings.sharedInstance disableAutoDismiss]) - return; - %orig; + if ([RASettings.sharedInstance disableAutoDismiss]) + return; + %orig; } - (void)_handleSignificantTimeChanged { - if ([RASettings.sharedInstance disableAutoDismiss]) - return; - %orig; + if ([RASettings.sharedInstance disableAutoDismiss]) + return; + %orig; } - (void)_keepAliveTimerFired:(unsafe_id)arg1 { - if ([RASettings.sharedInstance disableAutoDismiss]) - return; - %orig; + if ([RASettings.sharedInstance disableAutoDismiss]) + return; + %orig; } - (void)_setKeepAliveTimerForDuration:(double)arg1 { - if ([RASettings.sharedInstance disableAutoDismiss]) - return; - %orig; + if ([RASettings.sharedInstance disableAutoDismiss]) + return; + %orig; } - (void)deactivateReachabilityModeForObserver:(unsafe_id)arg1 { - //Disable for keyboard here - if (overrideDisableForStatusBar) - return; - %orig; + //Disable for keyboard here + if (overrideDisableForStatusBar) + return; + %orig; - if (wasEnabled) + if (wasEnabled) + { + wasEnabled = NO; + // Notify both top and bottom apps Reachability is closing + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { - wasEnabled = NO; - // Notify both top and bottom apps Reachability is closing - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { - [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [(RAAppSliderProviderView*)view unload]; - [view removeFromSuperview]; - view = nil; - } - if (lastBundleIdentifier && lastBundleIdentifier.length > 0) - { - [RAMessagingServer.sharedInstance endResizingApp:lastBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:lastBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:lastBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:lastBundleIdentifier completion:nil]; - } - if (currentBundleIdentifier) - [RAMessagingServer.sharedInstance endResizingApp:currentBundleIdentifier completion:nil]; - [GET_SBWORKSPACE RA_closeCurrentView]; + [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [(RAAppSliderProviderView*)view unload]; + [view removeFromSuperview]; + view = nil; } - + if (lastBundleIdentifier && lastBundleIdentifier.length > 0) + { + [RAMessagingServer.sharedInstance endResizingApp:lastBundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:lastBundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:lastBundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:lastBundleIdentifier completion:nil]; + } + if (currentBundleIdentifier) + [RAMessagingServer.sharedInstance endResizingApp:currentBundleIdentifier completion:nil]; + [GET_SBWORKSPACE RA_closeCurrentView]; + } } - (void)_handleReachabilityDeactivated { - if (overrideDisableForStatusBar) - return; - - %orig; + if (overrideDisableForStatusBar) + return; + %orig; } - (void)_updateReachabilityModeActive:(_Bool)arg1 withRequestingObserver:(unsafe_id)arg2 { - if (overrideDisableForStatusBar) - return; - %orig; + if (overrideDisableForStatusBar) + return; + %orig; } %end %hook SBReachabilitySettings -(CGFloat) reachabilityDefaultKeepAlive { - if ([RASettings.sharedInstance disableAutoDismiss]) - return 9999999999; - return %orig; + if ([RASettings.sharedInstance disableAutoDismiss]) + return 9999999999; + return %orig; } -(CGFloat) reachabilityInteractiveKeepAlive { - if ([RASettings.sharedInstance disableAutoDismiss]) - return 9999999999; - return %orig; + if ([RASettings.sharedInstance disableAutoDismiss]) + return 9999999999; + return %orig; } %end @@ -151,729 +149,727 @@ id SBWorkspace$sharedInstance; %hook SB_WORKSPACE_CLASS %new +(instancetype) sharedInstance { - return SBWorkspace$sharedInstance; + return SBWorkspace$sharedInstance; } -(id) init { - SBWorkspace$sharedInstance = %orig; - return SBWorkspace$sharedInstance; + SBWorkspace$sharedInstance = %orig; + return SBWorkspace$sharedInstance; } %new -(BOOL) isUsingReachApp { - return (view || showingNC); + return (view || showingNC); } - (void)_exitReachabilityModeWithCompletion:(unsafe_id)arg1 { - if (overrideDisableForStatusBar) - return; - - %orig; + if (overrideDisableForStatusBar) + return; + %orig; } - (void)handleReachabilityModeDeactivated { - if (overrideDisableForStatusBar) - return; - - %orig; + if (overrideDisableForStatusBar) + return; + %orig; } %new -(void) RA_closeCurrentView { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) + { + [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [(RAAppSliderProviderView*)view unload]; + [view removeFromSuperview]; + view = nil; + } + + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:currentBundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:currentBundleIdentifier completion:nil]; + + if ([RASettings.sharedInstance showNCInstead]) + { + showingNC = NO; + UIWindow *window = MSHookIvar(self, "_reachabilityEffectWindow"); + [window _setRotatableViewOrientation:UIInterfaceOrientationPortrait updateStatusBar:YES duration:0.0 force:YES]; + window.rootViewController = nil; + SBNotificationCenterViewController *viewController = [[%c(SBNotificationCenterController) performSelector:@selector(sharedInstance)] performSelector:@selector(viewController)]; + if ([viewController respondsToSelector:@selector(hostWillDismiss)]) { + [viewController performSelector:@selector(hostWillDismiss)]; + [viewController performSelector:@selector(hostDidDismiss)]; + } else { + [viewController performSelector:@selector(_loadContainerView)]; + } + //[viewController.view removeFromSuperview]; + } + else + { + SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { - [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [(RAAppSliderProviderView*)view unload]; - [view removeFromSuperview]; - view = nil; + [((RAAppSliderProviderView*)view) unload]; } - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:currentBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:currentBundleIdentifier completion:nil]; - - if ([RASettings.sharedInstance showNCInstead]) + // Give them a little time to receive the notifications... + if (view) { - showingNC = NO; - UIWindow *window = MSHookIvar(self, "_reachabilityEffectWindow"); - [window _setRotatableViewOrientation:UIInterfaceOrientationPortrait updateStatusBar:YES duration:0.0 force:YES]; - window.rootViewController = nil; - SBNotificationCenterViewController *viewController = [[%c(SBNotificationCenterController) performSelector:@selector(sharedInstance)] performSelector:@selector(viewController)]; - if ([viewController respondsToSelector:@selector(hostWillDismiss)]) { - [viewController performSelector:@selector(hostWillDismiss)]; - [viewController performSelector:@selector(hostDidDismiss)]; - } else { - [viewController performSelector:@selector(_loadContainerView)]; - } - //[viewController.view removeFromSuperview]; + if ([view superview]) + [view removeFromSuperview]; } - else - { - SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; - - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { - [((RAAppSliderProviderView*)view) unload]; - } - - // Give them a little time to receive the notifications... - if (view) + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + if (lastBundleIdentifier && lastBundleIdentifier.length > 0) + { + if (app && [app pid] && [app mainScene]) { - if ([view superview]) - [view removeFromSuperview]; + FBScene *scene = [app mainScene]; + FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; + SET_BACKGROUNDED(settings, YES); + [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; + //MSHookIvar([app mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; + //MSHookIvar([app mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; + + SBApplication *currentApp = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:currentBundleIdentifier]; + if ([currentApp mainScene]) + { + //MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; + //MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; + } + + FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; + [contextHostManager disableHostingForRequester:@"reachapp"]; } - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - if (lastBundleIdentifier && lastBundleIdentifier.length > 0) - { - if (app && [app pid] && [app mainScene]) - { - FBScene *scene = [app mainScene]; - FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; - SET_BACKGROUNDED(settings, YES); - [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; - //MSHookIvar([app mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; - //MSHookIvar([app mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; - - SBApplication *currentApp = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:currentBundleIdentifier]; - if ([currentApp mainScene]) - { - //MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; - //MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; - } - - FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; - [contextHostManager disableHostingForRequester:@"reachapp"]; - } - } - view = nil; - lastBundleIdentifier = nil; - }); - } + } + view = nil; + lastBundleIdentifier = nil; + }); + } } - (void)_disableReachabilityImmediately:(_Bool)arg1 { - //Disable for keyboard here - if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) - return; + //Disable for keyboard here + if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) + return; + + %orig; - %orig; + if (![RASettings.sharedInstance reachabilityEnabled] && !wasEnabled) + { + return; + } - if (![RASettings.sharedInstance reachabilityEnabled] && !wasEnabled) + if (arg1 && wasEnabled) + { + wasEnabled = NO; + + // Notify both top and bottom apps Reachability is closing + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { - return; + [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [(RAAppSliderProviderView*)view unload]; + [view removeFromSuperview]; + view = nil; } - - if (arg1 && wasEnabled) + if (lastBundleIdentifier && lastBundleIdentifier.length > 0) { - wasEnabled = NO; - - // Notify both top and bottom apps Reachability is closing - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { - [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [(RAAppSliderProviderView*)view unload]; - [view removeFromSuperview]; - view = nil; - } - if (lastBundleIdentifier && lastBundleIdentifier.length > 0) - { - [RAMessagingServer.sharedInstance endResizingApp:lastBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:lastBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:lastBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:lastBundleIdentifier completion:nil]; - } - if (currentBundleIdentifier) - [RAMessagingServer.sharedInstance endResizingApp:currentBundleIdentifier completion:nil]; - - [self RA_closeCurrentView]; - if (draggerView) - draggerView = nil; + [RAMessagingServer.sharedInstance endResizingApp:lastBundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:lastBundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:lastBundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:lastBundleIdentifier completion:nil]; } + if (currentBundleIdentifier) + [RAMessagingServer.sharedInstance endResizingApp:currentBundleIdentifier completion:nil]; + + [self RA_closeCurrentView]; + if (draggerView) + draggerView = nil; + } } - (void) handleReachabilityModeActivated { - %orig; - if (![RASettings.sharedInstance reachabilityEnabled]) - return; - wasEnabled = YES; + %orig; + if (![RASettings.sharedInstance reachabilityEnabled]) + return; + wasEnabled = YES; - CGFloat knobWidth = 60; - CGFloat knobHeight = 25; - draggerView = [[UIView alloc] initWithFrame:CGRectMake( - (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), - [UIScreen mainScreen].bounds.size.height * .3, - knobWidth, knobHeight)]; - draggerView.alpha = 0.3; - draggerView.layer.cornerRadius = 10; - grabberCenter_X = draggerView.center.x; + CGFloat knobWidth = 60; + CGFloat knobHeight = 25; + draggerView = [[UIView alloc] initWithFrame:CGRectMake( + (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), + [UIScreen mainScreen].bounds.size.height * .3, + knobWidth, knobHeight)]; + draggerView.alpha = 0.3; + draggerView.layer.cornerRadius = 10; + grabberCenter_X = draggerView.center.x; + + UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); + if ([RASettings.sharedInstance showNCInstead]) + { + showingNC = YES; + + if (!ncViewController) + ncViewController = [[%c(SBNotificationCenterViewController) alloc] init]; + ncViewController.view.frame = (CGRect) { { 0, 0 }, w.frame.size }; + w.rootViewController = ncViewController; + [w addSubview:ncViewController.view]; - UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); - if ([RASettings.sharedInstance showNCInstead]) + //[[%c(SBNotificationCenterController) performSelector:@selector(sharedInstance)] performSelector:@selector(_setupForViewPresentation)]; + if ([ncViewController respondsToSelector:@selector(hostWillPresent)]) { + [ncViewController performSelector:@selector(hostWillPresent)]; + [ncViewController performSelector:@selector(hostDidPresent)]; + } else { + [ncViewController _loadContainerView]; + } + + if ([RASettings.sharedInstance enableRotation]) { - showingNC = YES; - - if (!ncViewController) - ncViewController = [[%c(SBNotificationCenterViewController) alloc] init]; - ncViewController.view.frame = (CGRect) { { 0, 0 }, w.frame.size }; - w.rootViewController = ncViewController; - [w addSubview:ncViewController.view]; - - //[[%c(SBNotificationCenterController) performSelector:@selector(sharedInstance)] performSelector:@selector(_setupForViewPresentation)]; - if ([ncViewController respondsToSelector:@selector(hostWillPresent)]) { - [ncViewController performSelector:@selector(hostWillPresent)]; - [ncViewController performSelector:@selector(hostDidPresent)]; - } else { - [ncViewController _loadContainerView]; - } + [w _setRotatableViewOrientation:[UIApplication sharedApplication].statusBarOrientation updateStatusBar:YES duration:0.0 force:YES]; + } + } + else + { + currentBundleIdentifier = [[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; + if (!currentBundleIdentifier) + return; - if ([RASettings.sharedInstance enableRotation]) - { - [w _setRotatableViewOrientation:[UIApplication sharedApplication].statusBarOrientation updateStatusBar:YES duration:0.0 force:YES]; - } + if ([RASettings.sharedInstance showWidgetSelector]) + { + [self RA_showWidgetSelector]; } else { - currentBundleIdentifier = [[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; - if (!currentBundleIdentifier) - return; + SBApplication *app = nil; + FBScene *scene = nil; + NSMutableArray *bundleIdentifiers = [[RAAppSwitcherModelWrapper appSwitcherAppIdentiferList] mutableCopy]; + while (!scene && bundleIdentifiers.count > 0) + { + lastBundleIdentifier = bundleIdentifiers[0]; - if ([RASettings.sharedInstance showWidgetSelector]) + if ([lastBundleIdentifier isEqual:currentBundleIdentifier]) { - [self RA_showWidgetSelector]; - } - else - { - SBApplication *app = nil; - FBScene *scene = nil; - NSMutableArray *bundleIdentifiers = [[RAAppSwitcherModelWrapper appSwitcherAppIdentiferList] mutableCopy]; - while (!scene && bundleIdentifiers.count > 0) - { - lastBundleIdentifier = bundleIdentifiers[0]; - - if ([lastBundleIdentifier isEqual:currentBundleIdentifier]) - { - [bundleIdentifiers removeObjectAtIndex:0]; - continue; - } - - app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; - scene = [app mainScene]; - if (!scene) - if (bundleIdentifiers.count > 0) - [bundleIdentifiers removeObjectAtIndex:0]; - } - if (!lastBundleIdentifier || lastBundleIdentifier.length == 0) - return; - - [self RA_launchTopAppWithIdentifier:lastBundleIdentifier]; + [bundleIdentifiers removeObjectAtIndex:0]; + continue; } + + app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; + scene = [app mainScene]; + if (!scene) + if (bundleIdentifiers.count > 0) + [bundleIdentifiers removeObjectAtIndex:0]; + } + if (!lastBundleIdentifier || lastBundleIdentifier.length == 0) + return; + + [self RA_launchTopAppWithIdentifier:lastBundleIdentifier]; } + } - draggerView.backgroundColor = UIColor.lightGrayColor; - UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; - if (grabberCenter_Y == -1) - grabberCenter_Y = w.frame.size.height - (knobHeight / 2); - if (grabberCenter_Y < 0) - grabberCenter_Y = UIScreen.mainScreen.bounds.size.height * 0.3; - draggerView.center = CGPointMake(grabberCenter_X, grabberCenter_Y); - recognizer.delegate = (id)self; - [draggerView addGestureRecognizer:recognizer]; + draggerView.backgroundColor = UIColor.lightGrayColor; + UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; + if (grabberCenter_Y == -1) + grabberCenter_Y = w.frame.size.height - (knobHeight / 2); + if (grabberCenter_Y < 0) + grabberCenter_Y = UIScreen.mainScreen.bounds.size.height * 0.3; + draggerView.center = CGPointMake(grabberCenter_X, grabberCenter_Y); + recognizer.delegate = (id)self; + [draggerView addGestureRecognizer:recognizer]; - UILongPressGestureRecognizer *recognizer2 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(RA_handleLongPress:)]; - recognizer2.delegate = (id)self; - [draggerView addGestureRecognizer:recognizer2]; + UILongPressGestureRecognizer *recognizer2 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(RA_handleLongPress:)]; + recognizer2.delegate = (id)self; + [draggerView addGestureRecognizer:recognizer2]; - UITapGestureRecognizer *recognizer3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(RA_detachAppAndClose:)]; - recognizer3.numberOfTapsRequired = 2; - recognizer3.delegate = (id)self; - [draggerView addGestureRecognizer:recognizer3]; + UITapGestureRecognizer *recognizer3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(RA_detachAppAndClose:)]; + recognizer3.numberOfTapsRequired = 2; + recognizer3.delegate = (id)self; + [draggerView addGestureRecognizer:recognizer3]; - [w addSubview:draggerView]; + [w addSubview:draggerView]; - if ([RASettings.sharedInstance showBottomGrabber]) - { - bottomDraggerView = [[UIView alloc] initWithFrame:CGRectMake( - (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), - -(knobHeight / 2), - knobWidth, knobHeight)]; - bottomDraggerView.alpha = 0.3; - bottomDraggerView.layer.cornerRadius = 10; - bottomDraggerView.backgroundColor = UIColor.lightGrayColor; - [bottomDraggerView addGestureRecognizer:recognizer]; - [MSHookIvar(self,"_reachabilityWindow") addSubview:bottomDraggerView]; - } + if ([RASettings.sharedInstance showBottomGrabber]) + { + bottomDraggerView = [[UIView alloc] initWithFrame:CGRectMake( + (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), + -(knobHeight / 2), + knobWidth, knobHeight)]; + bottomDraggerView.alpha = 0.3; + bottomDraggerView.layer.cornerRadius = 10; + bottomDraggerView.backgroundColor = UIColor.lightGrayColor; + [bottomDraggerView addGestureRecognizer:recognizer]; + [MSHookIvar(self,"_reachabilityWindow") addSubview:bottomDraggerView]; + } - // Update sizes of reachability (and their contained apps) and the location of the dragger view - [self updateViewSizes:draggerView.center animate:NO]; + // Update sizes of reachability (and their contained apps) and the location of the dragger view + [self updateViewSizes:draggerView.center animate:NO]; } %new -(void)RA_showWidgetSelector { - if (view) - [self RA_closeCurrentView]; - - UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); - //CGSize iconSize = [%c(SBIconView) defaultIconImageSize]; - static CGSize fullSize = [%c(SBIconView) defaultIconSize]; - fullSize.height = fullSize.width; // otherwise it often looks like {60,74} - CGFloat padding = 20; - - NSInteger numIconsPerLine = 0; - CGFloat tmpWidth = 10; - while (tmpWidth + fullSize.width <= w.frame.size.width) - { - numIconsPerLine++; - tmpWidth += fullSize.width + 20; - } - padding = (w.frame.size.width - (numIconsPerLine * fullSize.width)) / numIconsPerLine; - - UIView *widgetSelectorView = [[RAWidgetSectionManager sharedInstance] createViewForEnabledSectionsWithBaseFrame:w.frame preferredIconSize:fullSize iconsThatFitPerLine:numIconsPerLine spacing:padding]; - widgetSelectorView.frame = (CGRect){ { 0, 0 }, widgetSelectorView.frame.size }; - //widgetSelectorView.frame = w.frame; - - if (draggerView) - [w insertSubview:widgetSelectorView belowSubview:draggerView]; - else - [w addSubview:widgetSelectorView]; - view = widgetSelectorView; - - if ([RASettings.sharedInstance autoSizeWidgetSelector]) - { - CGFloat moddedHeight = widgetSelectorView.frame.size.height; - if (old_grabberCenterY == -1) - old_grabberCenterY = UIScreen.mainScreen.bounds.size.height * 0.3; - old_grabberCenterY = grabberCenter_Y; - grabberCenter_Y = moddedHeight; - } - CGPoint newCenter = CGPointMake(draggerView.center.x, grabberCenter_Y); - draggerView.center = newCenter; - draggerView.hidden = YES; - [self updateViewSizes:newCenter animate:YES]; + if (view) + [self RA_closeCurrentView]; + + UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); + //CGSize iconSize = [%c(SBIconView) defaultIconImageSize]; + static CGSize fullSize = [%c(SBIconView) defaultIconSize]; + fullSize.height = fullSize.width; // otherwise it often looks like {60,74} + CGFloat padding = 20; + + NSInteger numIconsPerLine = 0; + CGFloat tmpWidth = 10; + while (tmpWidth + fullSize.width <= w.frame.size.width) + { + numIconsPerLine++; + tmpWidth += fullSize.width + 20; + } + padding = (w.frame.size.width - (numIconsPerLine * fullSize.width)) / numIconsPerLine; + + UIView *widgetSelectorView = [[RAWidgetSectionManager sharedInstance] createViewForEnabledSectionsWithBaseFrame:w.frame preferredIconSize:fullSize iconsThatFitPerLine:numIconsPerLine spacing:padding]; + widgetSelectorView.frame = (CGRect){ { 0, 0 }, widgetSelectorView.frame.size }; + //widgetSelectorView.frame = w.frame; + + if (draggerView) + [w insertSubview:widgetSelectorView belowSubview:draggerView]; + else + [w addSubview:widgetSelectorView]; + view = widgetSelectorView; + + if ([RASettings.sharedInstance autoSizeWidgetSelector]) + { + CGFloat moddedHeight = widgetSelectorView.frame.size.height; + if (old_grabberCenterY == -1) + old_grabberCenterY = UIScreen.mainScreen.bounds.size.height * 0.3; + old_grabberCenterY = grabberCenter_Y; + grabberCenter_Y = moddedHeight; + } + CGPoint newCenter = CGPointMake(draggerView.center.x, grabberCenter_Y); + draggerView.center = newCenter; + draggerView.hidden = YES; + [self updateViewSizes:newCenter animate:YES]; } CGFloat startingY = -1; %new -(void)handlePan:(UIPanGestureRecognizer*)sender { - UIView *view = draggerView; //sender.view; + UIView *view = draggerView; //sender.view; - if (sender.state == UIGestureRecognizerStateBegan) + if (sender.state == UIGestureRecognizerStateBegan) + { + startingY = grabberCenter_Y; + grabberCenter_X = view.center.x; + firstLocation = view.center; + grabberCenter_Y = [sender locationInView:view.superview].y; + draggerView.alpha = 0.8; + bottomDraggerView.alpha = 0; + } + else if (sender.state == UIGestureRecognizerStateChanged) + { + CGPoint translation = [sender translationInView:view]; + + if (firstLocation.y + translation.y < 50) { - startingY = grabberCenter_Y; - grabberCenter_X = view.center.x; - firstLocation = view.center; - grabberCenter_Y = [sender locationInView:view.superview].y; - draggerView.alpha = 0.8; - bottomDraggerView.alpha = 0; + view.center = CGPointMake(grabberCenter_X, 50); + grabberCenter_Y = 50; } - else if (sender.state == UIGestureRecognizerStateChanged) + else if (firstLocation.y + translation.y > UIScreen.mainScreen.bounds.size.height - 30) { - CGPoint translation = [sender translationInView:view]; - - if (firstLocation.y + translation.y < 50) - { - view.center = CGPointMake(grabberCenter_X, 50); - grabberCenter_Y = 50; - } - else if (firstLocation.y + translation.y > UIScreen.mainScreen.bounds.size.height - 30) - { - view.center = CGPointMake(grabberCenter_X, UIScreen.mainScreen.bounds.size.height - 30); - grabberCenter_Y = UIScreen.mainScreen.bounds.size.height - 30; - } - else - { - view.center = CGPointMake(grabberCenter_X, firstLocation.y + translation.y); - grabberCenter_Y = [sender locationInView:view.superview].y; - } - - [self updateViewSizes:view.center animate:YES]; + view.center = CGPointMake(grabberCenter_X, UIScreen.mainScreen.bounds.size.height - 30); + grabberCenter_Y = UIScreen.mainScreen.bounds.size.height - 30; } - else if (sender.state == UIGestureRecognizerStateEnded) + else { - draggerView.alpha = 0.3; - bottomDraggerView.alpha = 0.3; - if (startingY != -1 && fabs(grabberCenter_Y - startingY) < 3) - [self RA_handleLongPress:nil]; - startingY = -1; - [self updateViewSizes:view.center animate:YES]; + view.center = CGPointMake(grabberCenter_X, firstLocation.y + translation.y); + grabberCenter_Y = [sender locationInView:view.superview].y; } + + [self updateViewSizes:view.center animate:YES]; + } + else if (sender.state == UIGestureRecognizerStateEnded) + { + draggerView.alpha = 0.3; + bottomDraggerView.alpha = 0.3; + if (startingY != -1 && fabs(grabberCenter_Y - startingY) < 3) + [self RA_handleLongPress:nil]; + startingY = -1; + [self updateViewSizes:view.center animate:YES]; + } } %new -(void) RA_handleLongPress:(UILongPressGestureRecognizer*)gesture { - [self RA_showWidgetSelector]; + [self RA_showWidgetSelector]; } %new -(void) RA_detachAppAndClose:(UITapGestureRecognizer*)gesture { - NSString *ident = lastBundleIdentifier; - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { - RAAppSliderProviderView *temp = (RAAppSliderProviderView*)view; - ident = temp.currentBundleIdentifier; - [temp unload]; - } + NSString *ident = lastBundleIdentifier; + if ([view isKindOfClass:[RAAppSliderProviderView class]]) + { + RAAppSliderProviderView *temp = (RAAppSliderProviderView*)view; + ident = temp.currentBundleIdentifier; + [temp unload]; + } - if (!ident || ident.length == 0) - return; + if (!ident || ident.length == 0) + return; - [self handleReachabilityModeDeactivated]; - SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:ident]; - RAIconIndicatorViewInfo indicatorInfo = [[%c(RABackgrounder) sharedInstance] allAggregatedIndicatorInfoForIdentifier:ident]; + [self handleReachabilityModeDeactivated]; + SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:ident]; + RAIconIndicatorViewInfo indicatorInfo = [[%c(RABackgrounder) sharedInstance] allAggregatedIndicatorInfoForIdentifier:ident]; - // Close app - [[%c(RABackgrounder) sharedInstance] temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:app andCloseForegroundApp:NO]; - FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ - SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; - [deactiveSets setFlag:YES forDeactivationSetting:20]; - [deactiveSets setFlag:NO forDeactivationSetting:2]; - [app _setDeactivationSettings:deactiveSets]; + // Close app + [[%c(RABackgrounder) sharedInstance] temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:app andCloseForegroundApp:NO]; + FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; + [deactiveSets setFlag:YES forDeactivationSetting:20]; + [deactiveSets setFlag:NO forDeactivationSetting:2]; + [app _setDeactivationSettings:deactiveSets]; - // Open in window - [RADesktopManager.sharedInstance.currentDesktop createAppWindowWithIdentifier:ident animated:YES]; - }]; - [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; + // Open in window + [RADesktopManager.sharedInstance.currentDesktop createAppWindowWithIdentifier:ident animated:YES]; + }]; + [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; - // Pop forced foreground backgrounding - [[%c(RABackgrounder) sharedInstance] queueRemoveTemporaryOverrideForIdentifier:ident]; - [[%c(RABackgrounder) sharedInstance] removeTemporaryOverrideForIdentifier:ident]; - [[%c(RABackgrounder) sharedInstance] updateIconIndicatorForIdentifier:ident withInfo:indicatorInfo]; + // Pop forced foreground backgrounding + [[%c(RABackgrounder) sharedInstance] queueRemoveTemporaryOverrideForIdentifier:ident]; + [[%c(RABackgrounder) sharedInstance] removeTemporaryOverrideForIdentifier:ident]; + [[%c(RABackgrounder) sharedInstance] updateIconIndicatorForIdentifier:ident withInfo:indicatorInfo]; } %new - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { - if ([view isKindOfClass:[UIScrollView class]]) - return NO; - return YES; + if ([view isKindOfClass:[UIScrollView class]]) + return NO; + return YES; } %new -(void) RA_updateViewSizes { - [self updateViewSizes:draggerView.center animate:YES]; + [self updateViewSizes:draggerView.center animate:YES]; } %new -(void) updateViewSizes:(CGPoint) center animate:(BOOL)animate { - // Resizing - UIWindow *topWindow = MSHookIvar(self, "_reachabilityEffectWindow"); - UIWindow *bottomWindow = MSHookIvar(self, "_reachabilityWindow"); - - CGRect topFrame = CGRectMake(topWindow.frame.origin.x, topWindow.frame.origin.y, topWindow.frame.size.width, center.y); - CGRect bottomFrame = CGRectMake(bottomWindow.frame.origin.x, center.y, bottomWindow.frame.size.width, UIScreen.mainScreen._referenceBounds.size.height - center.y); - - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { - topFrame = CGRectMake(topWindow.frame.origin.x, 0, topWindow.frame.size.width, center.y); - bottomFrame = CGRectMake(bottomWindow.frame.origin.x, center.y, bottomWindow.frame.size.width, UIScreen.mainScreen._referenceBounds.size.height - center.y); - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) - { - - } + // Resizing + UIWindow *topWindow = MSHookIvar(self, "_reachabilityEffectWindow"); + UIWindow *bottomWindow = MSHookIvar(self, "_reachabilityWindow"); + + CGRect topFrame = CGRectMake(topWindow.frame.origin.x, topWindow.frame.origin.y, topWindow.frame.size.width, center.y); + CGRect bottomFrame = CGRectMake(bottomWindow.frame.origin.x, center.y, bottomWindow.frame.size.width, UIScreen.mainScreen._referenceBounds.size.height - center.y); + + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) + { + topFrame = CGRectMake(topWindow.frame.origin.x, 0, topWindow.frame.size.width, center.y); + bottomFrame = CGRectMake(bottomWindow.frame.origin.x, center.y, bottomWindow.frame.size.width, UIScreen.mainScreen._referenceBounds.size.height - center.y); + } + else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) + { + + } + + if ([view isKindOfClass:[RAAppSliderProviderView class]]) + { + RAAppSliderProviderView *sliderView = (RAAppSliderProviderView*)view; + sliderView.frame = topFrame; + } + + /*if ([RASettings.sharedInstance flipTopAndBottom]) + { + CGRect tmp = topFrame; + topFrame = bottomFrame; + bottomFrame = tmp; + }*/ + + if (animate) + { + [UIView animateWithDuration:0.3 animations:^{ + bottomWindow.frame = bottomFrame; + topWindow.frame = topFrame; + if (view && [view isKindOfClass:[UIScrollView class]]) + view.frame = topFrame; + }]; + } + else + { + bottomWindow.frame = bottomFrame; + topWindow.frame = topFrame; + if (view && [view isKindOfClass:[UIScrollView class]]) + view.frame = topFrame; + } + + if ([RASettings.sharedInstance showNCInstead]) + { + if (ncViewController) + ncViewController.view.frame = (CGRect) { { 0, 0 }, topFrame.size }; + } + else if (lastBundleIdentifier || [view isKindOfClass:[RAAppSliderProviderView class]]) + { + // Notify clients + + CGFloat width = - 1, height = -1; if ([view isKindOfClass:[RAAppSliderProviderView class]]) { - RAAppSliderProviderView *sliderView = (RAAppSliderProviderView*)view; - sliderView.frame = topFrame; - } - - /*if ([RASettings.sharedInstance flipTopAndBottom]) - { - CGRect tmp = topFrame; - topFrame = bottomFrame; - bottomFrame = tmp; - }*/ - - if (animate) - { - [UIView animateWithDuration:0.3 animations:^{ - bottomWindow.frame = bottomFrame; - topWindow.frame = topFrame; - if (view && [view isKindOfClass:[UIScrollView class]]) - view.frame = topFrame; - }]; + RAAppSliderProviderView *sliderView = (RAAppSliderProviderView*)view; + //width = sliderView.clientFrame.size.width; + //height = sliderView.clientFrame.size.height; + + + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) + { + width = center.y; + height = topWindow.frame.size.width; + } + else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) + { + //width = topWindow.frame.size.height; + width = bottomWindow.frame.origin.y; + height = topWindow.frame.size.width; + } + else + { + width = sliderView.clientFrame.size.width; + height = sliderView.clientFrame.size.height; + } } else { - bottomWindow.frame = bottomFrame; - topWindow.frame = topFrame; - if (view && [view isKindOfClass:[UIScrollView class]]) - view.frame = topFrame; - } + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) + { + width = center.y; + height = topWindow.frame.size.width; + } + else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) + { + width = bottomWindow.frame.origin.y; + height = topWindow.frame.size.width; + } + else + { + width = topWindow.frame.size.width; + height = topWindow.frame.size.height; + } + } + + NSString *targetIdentifier = lastBundleIdentifier; + if ([view isKindOfClass:[RAAppSliderProviderView class]]) + targetIdentifier = [((RAAppSliderProviderView*)view) currentBundleIdentifier]; - if ([RASettings.sharedInstance showNCInstead]) - { - if (ncViewController) - ncViewController.view.frame = (CGRect) { { 0, 0 }, topFrame.size }; - } - else if (lastBundleIdentifier || [view isKindOfClass:[RAAppSliderProviderView class]]) - { - // Notify clients + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) + [RAMessagingServer.sharedInstance moveApp:targetIdentifier toOrigin:CGPointMake(bottomWindow.frame.size.height, 0) completion:nil]; - CGFloat width = - 1, height = -1; + [RAMessagingServer.sharedInstance resizeApp:targetIdentifier toSize:CGSizeMake(width, height) completion:nil]; + } - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { - RAAppSliderProviderView *sliderView = (RAAppSliderProviderView*)view; - //width = sliderView.clientFrame.size.width; - //height = sliderView.clientFrame.size.height; - - - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { - width = center.y; - height = topWindow.frame.size.width; - } - else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { - //width = topWindow.frame.size.height; - width = bottomWindow.frame.origin.y; - height = topWindow.frame.size.width; - } - else - { - width = sliderView.clientFrame.size.width; - height = sliderView.clientFrame.size.height; - } - } - else - { - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { - width = center.y; - height = topWindow.frame.size.width; - } - else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { - width = bottomWindow.frame.origin.y; - height = topWindow.frame.size.width; - } - else - { - width = topWindow.frame.size.width; - height = topWindow.frame.size.height; - } - } + if (![view isKindOfClass:[%c(FBWindowContextHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_OLDER(iOS_8_4)) + return; // only resize when the app is being shown. That way it's more like native Reachability - NSString *targetIdentifier = lastBundleIdentifier; - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - targetIdentifier = [((RAAppSliderProviderView*)view) currentBundleIdentifier]; + if (![view isKindOfClass:[%c(FBSceneHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_NEWER(iOS_9_0)) + return; // iOS 9 - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - [RAMessagingServer.sharedInstance moveApp:targetIdentifier toOrigin:CGPointMake(bottomWindow.frame.size.height, 0) completion:nil]; + [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:currentBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance resizeApp:targetIdentifier toSize:CGSizeMake(width, height) completion:nil]; - } + [RAMessagingServer.sharedInstance rotateApp:lastBundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; - if (![view isKindOfClass:[%c(FBWindowContextHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_OLDER(iOS_8_4)) - return; // only resize when the app is being shown. That way it's more like native Reachability + CGFloat width = -1, height = -1; - if (![view isKindOfClass:[%c(FBSceneHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_NEWER(iOS_9_0)) - return; // iOS 9 + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) + { + width = bottomWindow.frame.size.height; + height = bottomWindow.frame.size.width; + } + else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) + { + //width = center.y; + width = bottomWindow.frame.size.height; + height = bottomWindow.frame.size.width; - [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:currentBundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance moveApp:currentBundleIdentifier toOrigin:CGPointMake(bottomWindow.frame.origin.y, 0) completion:nil]; + } + else + { + width = bottomWindow.frame.size.width; + height = bottomWindow.frame.size.height; + } + [RAMessagingServer.sharedInstance resizeApp:currentBundleIdentifier toSize:CGSizeMake(width, height) completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:currentBundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance rotateApp:lastBundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; + if ([RASettings.sharedInstance unifyStatusBar]) + [RAMessagingServer.sharedInstance forceStatusBarVisibility:NO forApp:currentBundleIdentifier completion:nil]; +} + +%new -(void) RA_launchTopAppWithIdentifier:(NSString*) bundleIdentifier +{ + UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); + SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; + FBScene *scene = [app mainScene]; + if (!app) + return; - CGFloat width = -1, height = -1; + [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:app.bundleIdentifier completion:nil]; + [RAMessagingServer.sharedInstance rotateApp:app.bundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; + [RAMessagingServer.sharedInstance forceStatusBarVisibility:YES forApp:app.bundleIdentifier completion:nil]; - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { - width = bottomWindow.frame.size.height; - height = bottomWindow.frame.size.width; - } - else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { - //width = center.y; - width = bottomWindow.frame.size.height; - height = bottomWindow.frame.size.width; + if (![app pid] || ![app mainScene]) + { + overrideDisableForStatusBar = YES; + [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; + [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:bundleIdentifier]; - [RAMessagingServer.sharedInstance moveApp:currentBundleIdentifier toOrigin:CGPointMake(bottomWindow.frame.origin.y, 0) completion:nil]; - } - else - { - width = bottomWindow.frame.size.width; - height = bottomWindow.frame.size.height; - } - [RAMessagingServer.sharedInstance resizeApp:currentBundleIdentifier toSize:CGSizeMake(width, height) completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:currentBundleIdentifier completion:nil]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + [self RA_launchTopAppWithIdentifier:bundleIdentifier]; + [self updateViewSizes:draggerView.center animate:YES]; + }); + return; + } - if ([RASettings.sharedInstance unifyStatusBar]) - [RAMessagingServer.sharedInstance forceStatusBarVisibility:NO forApp:currentBundleIdentifier completion:nil]; -} + [RAAppSwitcherModelWrapper addIdentifierToFront:bundleIdentifier]; -%new -(void) RA_launchTopAppWithIdentifier:(NSString*) bundleIdentifier -{ - UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); - SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; - FBScene *scene = [app mainScene]; - if (!app) - return; + FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; - [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:app.bundleIdentifier completion:nil]; - [RAMessagingServer.sharedInstance rotateApp:app.bundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; - [RAMessagingServer.sharedInstance forceStatusBarVisibility:YES forApp:app.bundleIdentifier completion:nil]; + FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; + SET_BACKGROUNDED(settings, NO); + [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; - if (![app pid] || ![app mainScene]) - { - overrideDisableForStatusBar = YES; - [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; - [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:bundleIdentifier]; - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - [self RA_launchTopAppWithIdentifier:bundleIdentifier]; - [self updateViewSizes:draggerView.center animate:YES]; - }); - return; - } + [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; - [RAAppSwitcherModelWrapper addIdentifierToFront:bundleIdentifier]; + [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; + view = [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES]; - FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; + view.accessibilityHint = bundleIdentifier; - FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; - SET_BACKGROUNDED(settings, NO); - [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; + if (draggerView && draggerView.superview == w) + [w insertSubview:view belowSubview:draggerView]; + else + [w addSubview:view]; - [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; + //if ([RASettings.sharedInstance enableRotation] && ![RASettings.sharedInstance scalingRotationMode]) + { + [RAMessagingServer.sharedInstance rotateApp:lastBundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; + } + /*else if ([RASettings.sharedInstance scalingRotationMode] && [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) + { + overrideDisableForStatusBar = YES; - [contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES]; - view = [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES]; + // Force portrait + [RAMessagingServer.sharedInstance rotateApp:lastBundleIdentifier toOrientation:UIInterfaceOrientationPortrait completion:nil]; + [RAMessagingServer.sharedInstance rotateApp:currentBundleIdentifier toOrientation:UIInterfaceOrientationPortrait completion:nil]; - view.accessibilityHint = bundleIdentifier; + // Scale app + CGFloat scale = view.frame.size.width / UIScreen.mainScreen.bounds.size.height; + pre_topAppTransform = MSHookIvar([app mainScene].contextHostManager, "_hostView").transform; + MSHookIvar([app mainScene].contextHostManager, "_hostView").transform = CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale), CGAffineTransformMakeRotation(M_PI_2)); + pre_topAppFrame = MSHookIvar([app mainScene].contextHostManager, "_hostView").frame; + MSHookIvar([app mainScene].contextHostManager, "_hostView").frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height); + UIWindow *window = MSHookIvar(self,"_reachabilityEffectWindow"); + window.frame = (CGRect) { window.frame.origin, { window.frame.size.width, view.frame.size.width } }; - if (draggerView && draggerView.superview == w) - [w insertSubview:view belowSubview:draggerView]; - else - [w addSubview:view]; + window = MSHookIvar(self,"_reachabilityWindow"); + window.frame = (CGRect) { { window.frame.origin.x, view.frame.size.width }, { window.frame.size.width, view.frame.size.width } }; - //if ([RASettings.sharedInstance enableRotation] && ![RASettings.sharedInstance scalingRotationMode]) + SBApplication *currentApp = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:currentBundleIdentifier]; + if ([currentApp mainScene]) // just checking... { - [RAMessagingServer.sharedInstance rotateApp:lastBundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; + MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").transform = CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale), CGAffineTransformMakeRotation(M_PI_2)); + MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").frame = CGRectMake(0, 0, window.frame.size.width, window.frame.size.height); } - /*else if ([RASettings.sharedInstance scalingRotationMode] && [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { - overrideDisableForStatusBar = YES; - - // Force portrait - [RAMessagingServer.sharedInstance rotateApp:lastBundleIdentifier toOrientation:UIInterfaceOrientationPortrait completion:nil]; - [RAMessagingServer.sharedInstance rotateApp:currentBundleIdentifier toOrientation:UIInterfaceOrientationPortrait completion:nil]; - - // Scale app - CGFloat scale = view.frame.size.width / UIScreen.mainScreen.bounds.size.height; - pre_topAppTransform = MSHookIvar([app mainScene].contextHostManager, "_hostView").transform; - MSHookIvar([app mainScene].contextHostManager, "_hostView").transform = CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale), CGAffineTransformMakeRotation(M_PI_2)); - pre_topAppFrame = MSHookIvar([app mainScene].contextHostManager, "_hostView").frame; - MSHookIvar([app mainScene].contextHostManager, "_hostView").frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height); - UIWindow *window = MSHookIvar(self,"_reachabilityEffectWindow"); - window.frame = (CGRect) { window.frame.origin, { window.frame.size.width, view.frame.size.width } }; - - window = MSHookIvar(self,"_reachabilityWindow"); - window.frame = (CGRect) { { window.frame.origin.x, view.frame.size.width }, { window.frame.size.width, view.frame.size.width } }; - - SBApplication *currentApp = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:currentBundleIdentifier]; - if ([currentApp mainScene]) // just checking... - { - MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").transform = CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale), CGAffineTransformMakeRotation(M_PI_2)); - MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").frame = CGRectMake(0, 0, window.frame.size.width, window.frame.size.height); - } - // Gotta for the animations to finish... ;_; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - overrideDisableForStatusBar = NO; - }); - }*/ - draggerView.hidden = NO; - overrideDisableForStatusBar = NO; + // Gotta for the animations to finish... ;_; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + overrideDisableForStatusBar = NO; + }); + }*/ + draggerView.hidden = NO; + overrideDisableForStatusBar = NO; } %new -(void) RA_setView:(UIView*)view_ preferredHeight:(CGFloat)pHeight { - view_.hidden = NO; - UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); - if (view) - { - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { - [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; - [(RAAppSliderProviderView*)view unload]; - } - [view removeFromSuperview]; - view = nil; - } - view = view_; - [w addSubview:view]; - if (draggerView && draggerView.superview) - [draggerView.superview bringSubviewToFront:draggerView]; - - CGPoint center = (CGPoint){ draggerView.center.x, pHeight <= 0 ? draggerView.center.y : pHeight }; - [self updateViewSizes:center animate:YES]; - draggerView.hidden = NO; - draggerView.center = center; - + view_.hidden = NO; + UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); + if (view) + { if ([view isKindOfClass:[RAAppSliderProviderView class]]) { - NSString *targetIdentifier = ((RAAppSliderProviderView*)view).currentBundleIdentifier; - [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:targetIdentifier completion:nil]; - [RAMessagingServer.sharedInstance rotateApp:targetIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; - [RAMessagingServer.sharedInstance forceStatusBarVisibility:YES forApp:targetIdentifier completion:nil]; - } + [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; + [(RAAppSliderProviderView*)view unload]; + } + [view removeFromSuperview]; + view = nil; + } + view = view_; + [w addSubview:view]; + if (draggerView && draggerView.superview) + [draggerView.superview bringSubviewToFront:draggerView]; + + CGPoint center = (CGPoint){ draggerView.center.x, pHeight <= 0 ? draggerView.center.y : pHeight }; + [self updateViewSizes:center animate:YES]; + draggerView.hidden = NO; + draggerView.center = center; + + if ([view isKindOfClass:[RAAppSliderProviderView class]]) + { + NSString *targetIdentifier = ((RAAppSliderProviderView*)view).currentBundleIdentifier; + [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:targetIdentifier completion:nil]; + [RAMessagingServer.sharedInstance rotateApp:targetIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; + [RAMessagingServer.sharedInstance forceStatusBarVisibility:YES forApp:targetIdentifier completion:nil]; + } } %new -(void) RA_animateWidgetSelectorOut:(id)completion { - [UIView animateWithDuration:0.3 - animations:^{ - view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.01, 0.01); - view.alpha = 0; - } - completion:completion]; + [UIView animateWithDuration:0.3 + animations:^{ + view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.01, 0.01); + view.alpha = 0; + } + completion:completion]; } %new -(void) appViewItemTap:(UITapGestureRecognizer*)sender { - int pid = [sender.view tag]; - SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithPid:pid]; - if (!app) - app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:sender.view.restorationIdentifier]; + int pid = [sender.view tag]; + SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithPid:pid]; + if (!app) + app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:sender.view.restorationIdentifier]; - if (app) - { - // before we re-assign view... - [self RA_animateWidgetSelectorOut:^(BOOL a){ - [view removeFromSuperview]; - view = nil; - - lastBundleIdentifier = app.bundleIdentifier; - [self RA_launchTopAppWithIdentifier:app.bundleIdentifier]; - - if ([RASettings.sharedInstance autoSizeWidgetSelector]) - { - if (old_grabberCenterY == -1) - old_grabberCenterY = UIScreen.mainScreen.bounds.size.height * 0.3; - grabberCenter_Y = old_grabberCenterY; - draggerView.center = CGPointMake(grabberCenter_X, grabberCenter_Y); - } - [self updateViewSizes:draggerView.center animate:YES]; - }]; - } + if (app) + { + // before we re-assign view... + [self RA_animateWidgetSelectorOut:^(BOOL a){ + [view removeFromSuperview]; + view = nil; + + lastBundleIdentifier = app.bundleIdentifier; + [self RA_launchTopAppWithIdentifier:app.bundleIdentifier]; + + if ([RASettings.sharedInstance autoSizeWidgetSelector]) + { + if (old_grabberCenterY == -1) + old_grabberCenterY = UIScreen.mainScreen.bounds.size.height * 0.3; + grabberCenter_Y = old_grabberCenterY; + draggerView.center = CGPointMake(grabberCenter_X, grabberCenter_Y); + } + [self updateViewSizes:draggerView.center animate:YES]; + }]; + } } %end %hook SpringBoard - (UIInterfaceOrientation)activeInterfaceOrientation { - return overrideOrientation ? UIInterfaceOrientationPortrait : %orig; + return overrideOrientation ? UIInterfaceOrientationPortrait : %orig; } %end @@ -881,9 +877,9 @@ CGFloat startingY = -1; %ctor { - IF_SPRINGBOARD - { - Class c = %c(SBMainWorkspace) ?: %c(SBWorkspace); - %init(hooks, SB_WORKSPACE_CLASS=c); - } + IF_SPRINGBOARD + { + Class c = %c(SBMainWorkspace) ?: %c(SBWorkspace); + %init(hooks, SB_WORKSPACE_CLASS=c); + } } diff --git a/Reachability/UIKit.xm b/Reachability/UIKit.xm index 3cd2f93..b0fa171 100644 --- a/Reachability/UIKit.xm +++ b/Reachability/UIKit.xm @@ -6,18 +6,18 @@ BOOL allowClosingReachabilityNatively = NO; %hook UIApplication - (void)_deactivateReachability { - if (!allowClosingReachabilityNatively) - { - LogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); - return; - } + if (!allowClosingReachabilityNatively) + { + LogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); + return; + } - if ([RAMessagingClient.sharedInstance isBeingHosted]) - { - LogDebug(@"[ReachApp] stopping reachability from closing because hosted"); - return; - } - %orig; + if ([RAMessagingClient.sharedInstance isBeingHosted]) + { + LogDebug(@"[ReachApp] stopping reachability from closing because hosted"); + return; + } + %orig; } %end diff --git a/SpringBoard.xm b/SpringBoard.xm index e32878f..df52c12 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -29,20 +29,20 @@ extern BOOL overrideDisableForStatusBar; return YES; } - if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) - { - overrideDisableForStatusBar = NO; - [[%c(SBReachabilityManager) sharedInstance] _handleReachabilityDeactivated]; - return YES; - } + if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) + { + overrideDisableForStatusBar = NO; + [[%c(SBReachabilityManager) sharedInstance] _handleReachabilityDeactivated]; + return YES; + } - if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) - { - [[%c(RAMissionControlManager) sharedInstance] hideMissionControl:YES]; - return YES; - } + if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) + { + [[%c(RAMissionControlManager) sharedInstance] hideMissionControl:YES]; + return YES; + } - return %orig; + return %orig; } - (BOOL)handleHomeButtonSinglePressUp @@ -53,20 +53,20 @@ extern BOOL overrideDisableForStatusBar; return YES; } - if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) - { - overrideDisableForStatusBar = NO; - [[%c(SBReachabilityManager) sharedInstance] _handleReachabilityDeactivated]; - return YES; - } + if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) + { + overrideDisableForStatusBar = NO; + [[%c(SBReachabilityManager) sharedInstance] _handleReachabilityDeactivated]; + return YES; + } - if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) - { - [[%c(RAMissionControlManager) sharedInstance] hideMissionControl:YES]; - return YES; - } + if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) + { + [[%c(RAMissionControlManager) sharedInstance] hideMissionControl:YES]; + return YES; + } - return %orig; + return %orig; } /*- (_Bool)handleMenuDoubleTap @@ -87,65 +87,65 @@ extern BOOL overrideDisableForStatusBar; // This should help fix the problems where closing an app with Tage or the iPad Gesture would cause the app to suspend(?) and lock up the device. - (void)_suspendGestureBegan { - %orig; - [UIApplication.sharedApplication._accessibilityFrontMostApplication clearDeactivationSettings]; + %orig; + [UIApplication.sharedApplication._accessibilityFrontMostApplication clearDeactivationSettings]; } %end %hook SpringBoard -(void) _performDeferredLaunchWork { - %orig; - [RADesktopManager sharedInstance]; // load desktop (and previous windows!) + %orig; + [RADesktopManager sharedInstance]; // load desktop (and previous windows!) - // No applications show in the mission control until they have been launched by the user. - // This prevents always-running apps like Mail or Pebble from perpetually showing in Mission Control. - //[[%c(RAMissionControlManager) sharedInstance] setInhibitedApplications:[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers]]; + // No applications show in the mission control until they have been launched by the user. + // This prevents always-running apps like Mail or Pebble from perpetually showing in Mission Control. + //[[%c(RAMissionControlManager) sharedInstance] setInhibitedApplications:[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers]]; } %end %hook SBApplicationController %new -(SBApplication*) RA_applicationWithBundleIdentifier:(__unsafe_unretained NSString*)bundleIdentifier { - if ([self respondsToSelector:@selector(applicationWithBundleIdentifier:)]) - return [self applicationWithBundleIdentifier:bundleIdentifier]; - else if ([self respondsToSelector:@selector(applicationWithDisplayIdentifier:)]) - return [self applicationWithDisplayIdentifier:bundleIdentifier]; + if ([self respondsToSelector:@selector(applicationWithBundleIdentifier:)]) + return [self applicationWithBundleIdentifier:bundleIdentifier]; + else if ([self respondsToSelector:@selector(applicationWithDisplayIdentifier:)]) + return [self applicationWithDisplayIdentifier:bundleIdentifier]; - [RACompatibilitySystem showWarning:@"Unable to find valid -[SBApplicationController applicationWithBundleIdentifier:] replacement"]; - return nil; + [RACompatibilitySystem showWarning:@"Unable to find valid -[SBApplicationController applicationWithBundleIdentifier:] replacement"]; + return nil; } %end %hook SBToAppsWorkspaceTransaction - (void)_willBegin { - @autoreleasepool { - NSArray *apps = nil; - if ([self respondsToSelector:@selector(toApplications)]) - apps = [self toApplications]; - else - apps = [MSHookIvar(self, "_toApplications") copy]; - for (SBApplication *app in apps) - { - dispatch_async(dispatch_get_main_queue(), ^{ - [RADesktopManager.sharedInstance removeAppWithIdentifier:app.bundleIdentifier animated:NO forceImmediateUnload:YES]; - }); - } - } - %orig; + @autoreleasepool { + NSArray *apps = nil; + if ([self respondsToSelector:@selector(toApplications)]) + apps = [self toApplications]; + else + apps = [MSHookIvar(self, "_toApplications") copy]; + for (SBApplication *app in apps) + { + dispatch_async(dispatch_get_main_queue(), ^{ + [RADesktopManager.sharedInstance removeAppWithIdentifier:app.bundleIdentifier animated:NO forceImmediateUnload:YES]; + }); + } + } + %orig; } // On iOS 8.3 and above, on the iPad, if a FBWindowContextWhatever creates a hosting context / enabled hosting, all the other hosted windows stop. // This fixes that. -(void)_didComplete { - %orig; + %orig; - // can't hurt to check all devices - especially if it changes/has changed to include phones. - // however this was presumably done in preparation for the iOS 9 multitasking - if (IS_IPAD) - [RAHostedAppView iPad_iOS83_fixHosting]; + // can't hurt to check all devices - especially if it changes/has changed to include phones. + // however this was presumably done in preparation for the iOS 9 multitasking + if (IS_IPAD) + [RAHostedAppView iPad_iOS83_fixHosting]; } %end @@ -165,67 +165,67 @@ extern BOOL overrideDisableForStatusBar; %hook SpringBoard -(void)noteInterfaceOrientationChanged:(int)arg1 duration:(float)arg2 { - %orig; - [RASnapshotProvider.sharedInstance forceReloadEverything]; + %orig; + [RASnapshotProvider.sharedInstance forceReloadEverything]; } %end %hook SBApplication - (void)didActivateWithTransactionID:(unsigned long long)arg1 { - dispatch_async(dispatch_get_main_queue(), ^{ - [RASnapshotProvider.sharedInstance forceReloadOfSnapshotForIdentifier:self.bundleIdentifier]; - }); + dispatch_async(dispatch_get_main_queue(), ^{ + [RASnapshotProvider.sharedInstance forceReloadOfSnapshotForIdentifier:self.bundleIdentifier]; + }); - %orig; + %orig; } %end %hook SBLockScreenManager - (void)_postLockCompletedNotification:(_Bool)arg1 { - %orig; + %orig; - if (arg1) - { - if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) - [[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver]; - } + if (arg1) + { + if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) + [[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver]; + } } %end %hook UIScreen %new -(CGRect) RA_interfaceOrientedBounds { - if ([self respondsToSelector:@selector(_interfaceOrientedBounds)]) - return [self _interfaceOrientedBounds]; - return [self bounds]; + if ([self respondsToSelector:@selector(_interfaceOrientedBounds)]) + return [self _interfaceOrientedBounds]; + return [self bounds]; } %end void respring_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { - if (IS_IOS_OR_NEWER(iOS_9_3)) { - SBSRelaunchAction *restartAction = [%c(SBSRelaunchAction) actionWithReason:@"RestartRenderServer" options:SBSRelaunchOptionsFadeToBlack targetURL:nil]; - [[%c(FBSSystemService) sharedService] sendActions:[NSSet setWithObject:restartAction] withResult:nil]; - } else { - [[UIApplication sharedApplication] _relaunchSpringBoardNow]; - } + if (IS_IOS_OR_NEWER(iOS_9_3)) { + SBSRelaunchAction *restartAction = [%c(SBSRelaunchAction) actionWithReason:@"RestartRenderServer" options:SBSRelaunchOptionsFadeToBlack targetURL:nil]; + [[%c(FBSSystemService) sharedService] sendActions:[NSSet setWithObject:restartAction] withResult:nil]; + } else { + [[UIApplication sharedApplication] _relaunchSpringBoardNow]; + } } void reset_settings_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { - [RASettings.sharedInstance resetSettings]; + [RASettings.sharedInstance resetSettings]; } %ctor { - IF_SPRINGBOARD - { - %init; - LOAD_ASPHALEIA; + IF_SPRINGBOARD + { + %init; + LOAD_ASPHALEIA; - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &respring_notification, CFSTR("com.efrederickson.reachapp.respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reset_settings_notification, CFSTR("com.efrederickson.reachapp.resetSettings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - } + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &respring_notification, CFSTR("com.efrederickson.reachapp.respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reset_settings_notification, CFSTR("com.efrederickson.reachapp.resetSettings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + } } diff --git a/SwipeOver/RASwipeOverManager.xm b/SwipeOver/RASwipeOverManager.xm index cbfe14d..18f7d37 100644 --- a/SwipeOver/RASwipeOverManager.xm +++ b/SwipeOver/RASwipeOverManager.xm @@ -63,14 +63,14 @@ extern int rotationDegsForOrientation(int o); CGRect newFrame = overlayWindow.frame; switch ([UIApplication.sharedApplication statusBarOrientation]) { - case UIInterfaceOrientationPortrait: - newFrame = (CGRect) { { newFrame.origin.x + newFrame.size.height, newFrame.origin.y }, newFrame.size }; - case UIInterfaceOrientationPortraitUpsideDown: - newFrame = (CGRect) { { newFrame.origin.x - newFrame.size.height, newFrame.origin.y }, newFrame.size }; - case UIInterfaceOrientationLandscapeLeft: - newFrame = (CGRect) { { newFrame.origin.x, newFrame.origin.y - newFrame.size.height }, newFrame.size }; - case UIInterfaceOrientationLandscapeRight: - newFrame = (CGRect) { { newFrame.origin.x, newFrame.origin.y + newFrame.size.height }, newFrame.size }; + case UIInterfaceOrientationPortrait: + newFrame = (CGRect) { { newFrame.origin.x + newFrame.size.height, newFrame.origin.y }, newFrame.size }; + case UIInterfaceOrientationPortraitUpsideDown: + newFrame = (CGRect) { { newFrame.origin.x - newFrame.size.height, newFrame.origin.y }, newFrame.size }; + case UIInterfaceOrientationLandscapeLeft: + newFrame = (CGRect) { { newFrame.origin.x, newFrame.origin.y - newFrame.size.height }, newFrame.size }; + case UIInterfaceOrientationLandscapeRight: + newFrame = (CGRect) { { newFrame.origin.x, newFrame.origin.y + newFrame.size.height }, newFrame.size }; } [UIView animateWithDuration:0.3 animations:^{ @@ -103,74 +103,74 @@ extern int rotationDegsForOrientation(int o); [self closeCurrentView]; SBApplication *app = nil; - FBScene *scene = nil; - - if (identifier) - app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:identifier]; - else - { - NSMutableArray *bundleIdentifiers = [[%c(RAAppSwitcherModelWrapper) appSwitcherAppIdentiferList] mutableCopy]; - while (!scene && bundleIdentifiers.count > 0) - { - identifier = bundleIdentifiers[0]; + FBScene *scene = nil; - if ([identifier isEqual:currentAppIdentifier]) - { - [bundleIdentifiers removeObjectAtIndex:0]; - continue; - } + if (identifier) + app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:identifier]; + else + { + NSMutableArray *bundleIdentifiers = [[%c(RAAppSwitcherModelWrapper) appSwitcherAppIdentiferList] mutableCopy]; + while (!scene && bundleIdentifiers.count > 0) + { + identifier = bundleIdentifiers[0]; - app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:identifier]; - break; + if ([identifier isEqual:currentAppIdentifier]) + { + [bundleIdentifiers removeObjectAtIndex:0]; + continue; } - } - - if (app) - { - SBDisplayLayout *layout = [%c(SBDisplayLayout) fullScreenDisplayLayoutForApplication:app]; - if (layout) - [[%c(SBAppSwitcherModel) sharedInstance] addToFront:layout]; - } - - if (!identifier || identifier.length == 0) - return; - - RAHostedAppView *view = [[%c(RAHostedAppView) alloc] initWithBundleIdentifier:identifier]; - view.autosizesApp = NO; - if (!overlayWindow.isHidingUnderlyingApp) - view.autosizesApp = YES; - view.shouldUseExternalKeyboard = YES; - view.allowHidingStatusBar = NO; - view.frame = UIScreen.mainScreen._referenceBounds; - view.showSplashscreenInsteadOfSpinner = YES; - view.renderWallpaper = YES; - [view rotateToOrientation:UIInterfaceOrientationPortrait]; - [view loadApp]; - - UIImageView *detachView = [[UIImageView alloc] initWithFrame:CGRectMake(0, -20, view.frame.size.width, 20)]; - detachView.image = [[%c(RAResourceImageProvider) imageForFilename:@"SwipeOverDetachImage" constrainedToSize:CGSizeMake(97, 28)] _flatImageWithColor:THEMED(swipeOverDetachImageColor)]; - detachView.contentMode = UIViewContentModeScaleAspectFit; - UITapGestureRecognizer *detachGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(detachViewAndCloseSwipeOver)]; - [detachView addGestureRecognizer:detachGesture]; - detachView.backgroundColor = THEMED(swipeOverDetachBarColor); - detachView.userInteractionEnabled = YES; - detachGesture.delegate = overlayWindow; - detachView.tag = 9903553; - [view addSubview:detachView]; - - if (!overlayWindow.isHidingUnderlyingApp) // side-by-side - view.frame = CGRectMake(10, 0, view.frame.size.width, view.frame.size.height); - else // overlay - { - view.frame = CGRectMake(SCREEN_WIDTH - 50, 0, view.frame.size.width, view.frame.size.height); - CGFloat scale = 0.1; // MIN(MAX(scale, 0.1), 0.98); - view.transform = CGAffineTransformMakeScale(scale, scale); - view.center = (CGPoint) { SCREEN_WIDTH - (view.frame.size.width / 2), view.center.y }; - } + app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:identifier]; + break; + } + } + + if (app) + { + SBDisplayLayout *layout = [%c(SBDisplayLayout) fullScreenDisplayLayoutForApplication:app]; + if (layout) + [[%c(SBAppSwitcherModel) sharedInstance] addToFront:layout]; + } + + if (!identifier || identifier.length == 0) + return; + + RAHostedAppView *view = [[%c(RAHostedAppView) alloc] initWithBundleIdentifier:identifier]; + view.autosizesApp = NO; + if (!overlayWindow.isHidingUnderlyingApp) + view.autosizesApp = YES; + view.shouldUseExternalKeyboard = YES; + view.allowHidingStatusBar = NO; + view.frame = UIScreen.mainScreen._referenceBounds; + view.showSplashscreenInsteadOfSpinner = YES; + view.renderWallpaper = YES; + [view rotateToOrientation:UIInterfaceOrientationPortrait]; + [view loadApp]; + + UIImageView *detachView = [[UIImageView alloc] initWithFrame:CGRectMake(0, -20, view.frame.size.width, 20)]; + detachView.image = [[%c(RAResourceImageProvider) imageForFilename:@"SwipeOverDetachImage" constrainedToSize:CGSizeMake(97, 28)] _flatImageWithColor:THEMED(swipeOverDetachImageColor)]; + detachView.contentMode = UIViewContentModeScaleAspectFit; + UITapGestureRecognizer *detachGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(detachViewAndCloseSwipeOver)]; + [detachView addGestureRecognizer:detachGesture]; + detachView.backgroundColor = THEMED(swipeOverDetachBarColor); + detachView.userInteractionEnabled = YES; + detachGesture.delegate = overlayWindow; + detachView.tag = 9903553; + [view addSubview:detachView]; + + if (!overlayWindow.isHidingUnderlyingApp) // side-by-side + view.frame = CGRectMake(10, 0, view.frame.size.width, view.frame.size.height); + else // overlay + { + view.frame = CGRectMake(SCREEN_WIDTH - 50, 0, view.frame.size.width, view.frame.size.height); + + CGFloat scale = 0.1; // MIN(MAX(scale, 0.1), 0.98); + view.transform = CGAffineTransformMakeScale(scale, scale); + view.center = (CGPoint) { SCREEN_WIDTH - (view.frame.size.width / 2), view.center.y }; + } - view.tag = RASWIPEOVER_VIEW_TAG; - [overlayWindow addSubview:view]; + view.tag = RASWIPEOVER_VIEW_TAG; + [overlayWindow addSubview:view]; [self updateClientSizes:YES]; } @@ -196,8 +196,8 @@ extern int rotationDegsForOrientation(int o); if (UIApplication.sharedApplication.statusBarOrientation != UIInterfaceOrientationPortrait) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:@"Sorry, SwipeOver's side-by-side mode is not currently compatible with landscape." preferredStyle:UIAlertControllerStyleAlert]; - [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; - [alert show]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; + [alert show]; return; } diff --git a/SwipeOver/RASwipeOverOverlay.xm b/SwipeOver/RASwipeOverOverlay.xm index a934c63..f07ff18 100644 --- a/SwipeOver/RASwipeOverOverlay.xm +++ b/SwipeOver/RASwipeOverOverlay.xm @@ -21,12 +21,12 @@ [self addGestureRecognizer:g2]; CGFloat knobWidth = 10; - CGFloat knobHeight = 30; - grabberView = [[UIView alloc] initWithFrame:CGRectMake(2, (self.frame.size.height / 2) - (knobHeight / 2), knobWidth - 4, knobHeight)]; - grabberView.alpha = 0.5; - grabberView.layer.cornerRadius = knobWidth / 2; - grabberView.backgroundColor = [UIColor whiteColor]; - [self addSubview:grabberView]; + CGFloat knobHeight = 30; + grabberView = [[UIView alloc] initWithFrame:CGRectMake(2, (self.frame.size.height / 2) - (knobHeight / 2), knobWidth - 4, knobHeight)]; + grabberView.alpha = 0.5; + grabberView.layer.cornerRadius = knobWidth / 2; + grabberView.backgroundColor = [UIColor whiteColor]; + [self addSubview:grabberView]; } return self; } @@ -98,19 +98,19 @@ -(void) handlePan:(UIPanGestureRecognizer*)gesture { CGPoint newPoint = [gesture translationInView:gesture.view]; - [RASwipeOverManager.sharedInstance sizeViewForTranslation:newPoint state:gesture.state]; + [RASwipeOverManager.sharedInstance sizeViewForTranslation:newPoint state:gesture.state]; } -(void) longPress:(UILongPressGestureRecognizer*)gesture { [RASwipeOverManager.sharedInstance closeCurrentView]; - if ([[self currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) - { - [(RAAppSelectorView*)[self currentView] relayoutApps]; - [self currentView].frame = CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height); - return; - } - RAAppSelectorView *appSelector = [[%c(RAAppSelectorView) alloc] initWithFrame:CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height)]; + if ([[self currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) + { + [(RAAppSelectorView*)[self currentView] relayoutApps]; + [self currentView].frame = CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height); + return; + } + RAAppSelectorView *appSelector = [[%c(RAAppSelectorView) alloc] initWithFrame:CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height)]; appSelector.tag = RASWIPEOVER_VIEW_TAG; appSelector.target = self; [appSelector relayoutApps]; diff --git a/SwipeOver/SwipeOverGesture.xm b/SwipeOver/SwipeOverGesture.xm index b2f2057..ae78cf1 100644 --- a/SwipeOver/SwipeOverGesture.xm +++ b/SwipeOver/SwipeOverGesture.xm @@ -18,187 +18,187 @@ BOOL firstSwipe = NO; CGRect adjustFrameForRotation() { - CGFloat portraitWidth = 30; - CGFloat portraitHeight = 50; - - CGFloat width = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width; - CGFloat height = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height; - - switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) - { - case UIInterfaceOrientationPortrait: - LogDebug(@"[ReachApp] portrait"); - return (CGRect){ { width - portraitWidth + 5, (height - portraitHeight) / 2 }, { portraitWidth, portraitHeight } }; - case UIInterfaceOrientationPortraitUpsideDown: - LogDebug(@"[ReachApp] portrait upside down"); - return (CGRect){ { 0, 0}, { 50, 50 } }; - case UIInterfaceOrientationLandscapeLeft: - LogDebug(@"[ReachApp] landscape left"); - return (CGRect){ { ((width - portraitWidth) / 2), -(portraitWidth / 2) }, { portraitWidth, portraitHeight } }; - case UIInterfaceOrientationLandscapeRight: - LogDebug(@"[ReachApp] landscape right"); - return (CGRect){ { (height - portraitHeight) / 2, width - portraitWidth - 5 }, { portraitWidth, portraitHeight } }; - } - return CGRectZero; + CGFloat portraitWidth = 30; + CGFloat portraitHeight = 50; + + CGFloat width = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width; + CGFloat height = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height; + + switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) + { + case UIInterfaceOrientationPortrait: + LogDebug(@"[ReachApp] portrait"); + return (CGRect){ { width - portraitWidth + 5, (height - portraitHeight) / 2 }, { portraitWidth, portraitHeight } }; + case UIInterfaceOrientationPortraitUpsideDown: + LogDebug(@"[ReachApp] portrait upside down"); + return (CGRect){ { 0, 0}, { 50, 50 } }; + case UIInterfaceOrientationLandscapeLeft: + LogDebug(@"[ReachApp] landscape left"); + return (CGRect){ { ((width - portraitWidth) / 2), -(portraitWidth / 2) }, { portraitWidth, portraitHeight } }; + case UIInterfaceOrientationLandscapeRight: + LogDebug(@"[ReachApp] landscape right"); + return (CGRect){ { (height - portraitHeight) / 2, width - portraitWidth - 5 }, { portraitWidth, portraitHeight } }; + } + return CGRectZero; } CGPoint adjustCenterForOffscreenSlide(CGPoint center) { - CGFloat portraitWidth = 30; - //CGFloat portraitHeight = 50; - - switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) - { - case UIInterfaceOrientationPortrait: - return (CGPoint) { center.x + portraitWidth, center.y }; - case UIInterfaceOrientationPortraitUpsideDown: - return (CGPoint) { center.x - portraitWidth, center.y }; - case UIInterfaceOrientationLandscapeLeft: - return (CGPoint) { center.x, center.y - portraitWidth }; - case UIInterfaceOrientationLandscapeRight: - return (CGPoint) { center.x, center.y + portraitWidth }; - } - return CGPointZero; + CGFloat portraitWidth = 30; + //CGFloat portraitHeight = 50; + + switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) + { + case UIInterfaceOrientationPortrait: + return (CGPoint) { center.x + portraitWidth, center.y }; + case UIInterfaceOrientationPortraitUpsideDown: + return (CGPoint) { center.x - portraitWidth, center.y }; + case UIInterfaceOrientationLandscapeLeft: + return (CGPoint) { center.x, center.y - portraitWidth }; + case UIInterfaceOrientationLandscapeRight: + return (CGPoint) { center.x, center.y + portraitWidth }; + } + return CGPointZero; } CGAffineTransform adjustTransformRotation() { - switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) - { - case UIInterfaceOrientationPortrait: - return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0)); - case UIInterfaceOrientationPortraitUpsideDown: - return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180)); - case UIInterfaceOrientationLandscapeLeft: - return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90)); - case UIInterfaceOrientationLandscapeRight: - return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90)); - } - return CGAffineTransformIdentity; + switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) + { + case UIInterfaceOrientationPortrait: + return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0)); + case UIInterfaceOrientationPortraitUpsideDown: + return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180)); + case UIInterfaceOrientationLandscapeLeft: + return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90)); + case UIInterfaceOrientationLandscapeRight: + return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90)); + } + return CGAffineTransformIdentity; } BOOL swipeOverLocationIsInValidArea(CGFloat y) { - if (y == 0) return YES; // more than likely, UIGestureRecognizerStateEnded - - switch ([[%c(RASettings) sharedInstance] swipeOverGrabArea]) - { - case RAGrabAreaSideAnywhere: - return YES; - case RAGrabAreaSideTopThird: - return y <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0; - case RAGrabAreaSideMiddleThird: - return y >= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0 && y <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0) * 2; - case RAGrabAreaSideBottomThird: - return y >= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0) * 2; - default: - return NO; - } + if (y == 0) return YES; // more than likely, UIGestureRecognizerStateEnded + + switch ([[%c(RASettings) sharedInstance] swipeOverGrabArea]) + { + case RAGrabAreaSideAnywhere: + return YES; + case RAGrabAreaSideTopThird: + return y <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0; + case RAGrabAreaSideMiddleThird: + return y >= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0 && y <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0) * 2; + case RAGrabAreaSideBottomThird: + return y >= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0) * 2; + default: + return NO; + } } %ctor { - [[%c(RAGestureManager) sharedInstance] addGestureRecognizer:^RAGestureCallbackResult(UIGestureRecognizerState state, CGPoint location, CGPoint velocity) { - lastTouch = [NSDate date]; - - if ([%c(Multiplexer) shouldShowControlCenterGrabberOnFirstSwipe] || [[%c(RASettings) sharedInstance] alwaysShowSOGrabber]) - { - if (!isShowingGrabber && !isPastGrabber) - { - firstSwipe = YES; - isShowingGrabber = YES; - - grabberView = [[UIView alloc] init]; - - _UIBackdropView *bgView = [[%c(_UIBackdropView) alloc] initWithStyle:1]; - bgView.frame = CGRectMake(0, 0, grabberView.frame.size.width, grabberView.frame.size.height); - [grabberView addSubview:bgView]; - - //grabberView.backgroundColor = UIColor.redColor; - grabberView.frame = adjustFrameForRotation(); - - UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, grabberView.frame.size.width - 20, grabberView.frame.size.height - 20)]; - imgView.image = [%c(RAResourceImageProvider) imageForFilename:@"Grabber" constrainedToSize:CGSizeMake(grabberView.frame.size.width - 20, grabberView.frame.size.height - 20)]; - [grabberView addSubview:imgView]; - grabberView.layer.cornerRadius = 5; - grabberView.clipsToBounds = YES; - - grabberView.transform = adjustTransformRotation(); - //[UIWindow.keyWindow addSubview:grabberView]; // The desktop view most likely - [[[%c(RAHostManager) systemHostViewForApplication:UIApplication.sharedApplication._accessibilityFrontMostApplication] superview] addSubview:grabberView]; - - static void (^dismisser)() = ^{ // top kek, needs "static" so it's not a local, self-retaining block - if ([[NSDate date] timeIntervalSinceDate:lastTouch] > 2) - { - [UIView animateWithDuration:0.2 animations:^{ - //grabberView.frame = CGRectOffset(grabberView.frame, 40, 0); - grabberView.center = adjustCenterForOffscreenSlide(grabberView.center); - } completion:^(BOOL _) { - [grabberView removeFromSuperview]; - grabberView = nil; - isShowingGrabber = NO; - isPastGrabber = NO; - }]; - } - else if (grabberView) // left there - { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - dismisser(); - }); - } - }; - dismisser(); - - return RAGestureCallbackResultSuccess; - } - else if (CGRectContainsPoint(grabberView.frame, location) || (isShowingGrabber && !firstSwipe && [[%c(RASettings) sharedInstance] swipeOverGrabArea] != RAGrabAreaSideAnywhere && [[%c(RASettings) sharedInstance] swipeOverGrabArea] != RAGrabAreaSideMiddleThird)) - { - [grabberView removeFromSuperview]; - grabberView = nil; - isShowingGrabber = NO; - isPastGrabber = YES; - } - else if (!isPastGrabber) - { - if (state == UIGestureRecognizerStateEnded) - firstSwipe = NO; - startingPoint = CGPointZero; - isPastGrabber = NO; - return RAGestureCallbackResultSuccess; - } - } - - CGPoint translation; - switch (state) { - case UIGestureRecognizerStateBegan: - startingPoint = location; - break; - case UIGestureRecognizerStateChanged: - translation = CGPointMake(location.x - startingPoint.x, location.y - startingPoint.y); - break; - case UIGestureRecognizerStateEnded: - startingPoint = CGPointZero; - isPastGrabber = NO; - break; - } - - if (![RASwipeOverManager.sharedInstance isUsingSwipeOver]) - [RASwipeOverManager.sharedInstance startUsingSwipeOver]; - - //if (state == UIGestureRecognizerStateChanged) - [RASwipeOverManager.sharedInstance sizeViewForTranslation:translation state:state]; + [[%c(RAGestureManager) sharedInstance] addGestureRecognizer:^RAGestureCallbackResult(UIGestureRecognizerState state, CGPoint location, CGPoint velocity) { + lastTouch = [NSDate date]; + if ([%c(Multiplexer) shouldShowControlCenterGrabberOnFirstSwipe] || [[%c(RASettings) sharedInstance] alwaysShowSOGrabber]) + { + if (!isShowingGrabber && !isPastGrabber) + { + firstSwipe = YES; + isShowingGrabber = YES; + + grabberView = [[UIView alloc] init]; + + _UIBackdropView *bgView = [[%c(_UIBackdropView) alloc] initWithStyle:1]; + bgView.frame = CGRectMake(0, 0, grabberView.frame.size.width, grabberView.frame.size.height); + [grabberView addSubview:bgView]; + + //grabberView.backgroundColor = UIColor.redColor; + grabberView.frame = adjustFrameForRotation(); + + UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, grabberView.frame.size.width - 20, grabberView.frame.size.height - 20)]; + imgView.image = [%c(RAResourceImageProvider) imageForFilename:@"Grabber" constrainedToSize:CGSizeMake(grabberView.frame.size.width - 20, grabberView.frame.size.height - 20)]; + [grabberView addSubview:imgView]; + grabberView.layer.cornerRadius = 5; + grabberView.clipsToBounds = YES; + + grabberView.transform = adjustTransformRotation(); + //[UIWindow.keyWindow addSubview:grabberView]; // The desktop view most likely + [[[%c(RAHostManager) systemHostViewForApplication:UIApplication.sharedApplication._accessibilityFrontMostApplication] superview] addSubview:grabberView]; + + static void (^dismisser)() = ^{ // top kek, needs "static" so it's not a local, self-retaining block + if ([[NSDate date] timeIntervalSinceDate:lastTouch] > 2) + { + [UIView animateWithDuration:0.2 animations:^{ + //grabberView.frame = CGRectOffset(grabberView.frame, 40, 0); + grabberView.center = adjustCenterForOffscreenSlide(grabberView.center); + } completion:^(BOOL _) { + [grabberView removeFromSuperview]; + grabberView = nil; + isShowingGrabber = NO; + isPastGrabber = NO; + }]; + } + else if (grabberView) // left there + { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + dismisser(); + }); + } + }; + dismisser(); + + return RAGestureCallbackResultSuccess; + } + else if (CGRectContainsPoint(grabberView.frame, location) || (isShowingGrabber && !firstSwipe && [[%c(RASettings) sharedInstance] swipeOverGrabArea] != RAGrabAreaSideAnywhere && [[%c(RASettings) sharedInstance] swipeOverGrabArea] != RAGrabAreaSideMiddleThird)) + { + [grabberView removeFromSuperview]; + grabberView = nil; + isShowingGrabber = NO; + isPastGrabber = YES; + } + else if (!isPastGrabber) + { + if (state == UIGestureRecognizerStateEnded) + firstSwipe = NO; + startingPoint = CGPointZero; + isPastGrabber = NO; return RAGestureCallbackResultSuccess; - } withCondition:^BOOL(CGPoint location, CGPoint velocity) { - if ([[%c(RAKeyboardStateListener) sharedInstance] visible] && ![RASwipeOverManager.sharedInstance isUsingSwipeOver]) - { - CGRect realKBFrame = CGRectMake(0, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height, [[%c(RAKeyboardStateListener) sharedInstance] size].width, [[%c(RAKeyboardStateListener) sharedInstance] size].height); - realKBFrame = CGRectOffset(realKBFrame, 0, -realKBFrame.size.height); - - if (CGRectContainsPoint(realKBFrame, location) || realKBFrame.size.height > 50) - return NO; - } - - return [[%c(RASettings) sharedInstance] swipeOverEnabled] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBNotificationCenterController) sharedInstance] isVisible] && ![[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl] && (swipeOverLocationIsInValidArea(location.y) || isShowingGrabber); - } forEdge:UIRectEdgeRight identifier:@"com.efrederickson.reachapp.swipeover.systemgesture" priority:RAGesturePriorityDefault]; + } + } + + CGPoint translation; + switch (state) { + case UIGestureRecognizerStateBegan: + startingPoint = location; + break; + case UIGestureRecognizerStateChanged: + translation = CGPointMake(location.x - startingPoint.x, location.y - startingPoint.y); + break; + case UIGestureRecognizerStateEnded: + startingPoint = CGPointZero; + isPastGrabber = NO; + break; + } + + if (![RASwipeOverManager.sharedInstance isUsingSwipeOver]) + [RASwipeOverManager.sharedInstance startUsingSwipeOver]; + + //if (state == UIGestureRecognizerStateChanged) + [RASwipeOverManager.sharedInstance sizeViewForTranslation:translation state:state]; + + return RAGestureCallbackResultSuccess; + } withCondition:^BOOL(CGPoint location, CGPoint velocity) { + if ([[%c(RAKeyboardStateListener) sharedInstance] visible] && ![RASwipeOverManager.sharedInstance isUsingSwipeOver]) + { + CGRect realKBFrame = CGRectMake(0, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height, [[%c(RAKeyboardStateListener) sharedInstance] size].width, [[%c(RAKeyboardStateListener) sharedInstance] size].height); + realKBFrame = CGRectOffset(realKBFrame, 0, -realKBFrame.size.height); + + if (CGRectContainsPoint(realKBFrame, location) || realKBFrame.size.height > 50) + return NO; + } + + return [[%c(RASettings) sharedInstance] swipeOverEnabled] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBNotificationCenterController) sharedInstance] isVisible] && ![[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl] && (swipeOverLocationIsInValidArea(location.y) || isShowingGrabber); + } forEdge:UIRectEdgeRight identifier:@"com.efrederickson.reachapp.swipeover.systemgesture" priority:RAGesturePriorityDefault]; } diff --git a/Tweak.xm b/Tweak.xm index 0f8e72b..3e35cf3 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -30,8 +30,8 @@ void SET_BACKGROUNDED(id settings, BOOL value) #if __has_feature(objc_arc) // stupid ARC... ptrdiff_t bgOffset = ivar_getOffset(class_getInstanceVariable([settings class], "_backgrounded")); - char *bgPtr = ((char *)(__bridge void *)settings) + bgOffset; - memcpy(bgPtr, &value, sizeof(value)); + char *bgPtr = ((char *)(__bridge void *)settings) + bgOffset; + memcpy(bgPtr, &value, sizeof(value)); #else // ARC is off, easy way if (value) diff --git a/UIKit.xm b/UIKit.xm index a956c17..16f4d13 100644 --- a/UIKit.xm +++ b/UIKit.xm @@ -18,57 +18,57 @@ static Class $memorized$UITextEffectsWindow$class; %hook UIWindow -(void) setFrame:(CGRect)frame { - if (![self.class isEqual:$memorized$UITextEffectsWindow$class] && [RAMessagingClient.sharedInstance shouldResize]) + if (![self.class isEqual:$memorized$UITextEffectsWindow$class] && [RAMessagingClient.sharedInstance shouldResize]) + { + if (![oldFrames objectForKey:@(self.hash)]) + [oldFrames setObject:[NSValue valueWithCGRect:frame] forKey:@(self.hash)]; + + frame.origin.x = RAMessagingClient.sharedInstance.currentData.wantedClientOriginX == -1 ? 0 : RAMessagingClient.sharedInstance.currentData.wantedClientOriginX; + frame.origin.y = RAMessagingClient.sharedInstance.currentData.wantedClientOriginY == -1 ? 0 : RAMessagingClient.sharedInstance.currentData.wantedClientOriginY; + CGFloat overrideWidth = [RAMessagingClient.sharedInstance resizeSize].width; + CGFloat overrideHeight = [RAMessagingClient.sharedInstance resizeSize].height; + if (overrideWidth != -1 && overrideWidth != 0) + frame.size.width = overrideWidth; + if (overrideHeight != -1 && overrideHeight != 0) + frame.size.height = overrideHeight; + + if (self.subviews.count > 0) { - if (![oldFrames objectForKey:@(self.hash)]) - [oldFrames setObject:[NSValue valueWithCGRect:frame] forKey:@(self.hash)]; - - frame.origin.x = RAMessagingClient.sharedInstance.currentData.wantedClientOriginX == -1 ? 0 : RAMessagingClient.sharedInstance.currentData.wantedClientOriginX; - frame.origin.y = RAMessagingClient.sharedInstance.currentData.wantedClientOriginY == -1 ? 0 : RAMessagingClient.sharedInstance.currentData.wantedClientOriginY; - CGFloat overrideWidth = [RAMessagingClient.sharedInstance resizeSize].width; - CGFloat overrideHeight = [RAMessagingClient.sharedInstance resizeSize].height; - if (overrideWidth != -1 && overrideWidth != 0) - frame.size.width = overrideWidth; - if (overrideHeight != -1 && overrideHeight != 0) - frame.size.height = overrideHeight; - - if (self.subviews.count > 0) - { - ((UIView*)self.subviews[0]).frame = frame; - } + ((UIView*)self.subviews[0]).frame = frame; } + } - %orig(frame); + %orig(frame); } - (void)_rotateWindowToOrientation:(UIInterfaceOrientation)arg1 updateStatusBar:(BOOL)arg2 duration:(double)arg3 skipCallbacks:(BOOL)arg4 { - if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) - return; - %orig; + if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) + return; + %orig; } - (BOOL)_shouldAutorotateToInterfaceOrientation:(int)arg1 checkForDismissal:(BOOL)arg2 isRotationDisabled:(BOOL*)arg3 { - if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) - return NO; - return %orig; + if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) + return NO; + return %orig; } - (void)_setWindowInterfaceOrientation:(int)arg1 { - if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) - return; - %orig([RAMessagingClient.sharedInstance shouldForceOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:[RAMessagingClient.sharedInstance forcedOrientation]] ? [RAMessagingClient.sharedInstance forcedOrientation] : arg1); + if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) + return; + %orig([RAMessagingClient.sharedInstance shouldForceOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:[RAMessagingClient.sharedInstance forcedOrientation]] ? [RAMessagingClient.sharedInstance forcedOrientation] : arg1); } - (void)_sendTouchesForEvent:(unsafe_id)arg1 { - %orig; + %orig; - dispatch_async(dispatch_get_main_queue(), ^{ - [RAMessagingClient.sharedInstance notifySpringBoardOfFrontAppChangeToSelf]; - }); + dispatch_async(dispatch_get_main_queue(), ^{ + [RAMessagingClient.sharedInstance notifySpringBoardOfFrontAppChangeToSelf]; + }); } %end @@ -76,9 +76,9 @@ static Class $memorized$UITextEffectsWindow$class; %property (nonatomic, assign) BOOL RA_networkActivity; -(void) applicationDidResume { - %orig; - [RAMessagingClient.sharedInstance requestUpdateFromServer]; - //[RAFakePhoneMode updateAppSizing]; + %orig; + [RAMessagingClient.sharedInstance requestUpdateFromServer]; + //[RAFakePhoneMode updateAppSizing]; } /* +(void) _startWindowServerIfNecessary @@ -90,20 +90,20 @@ static Class $memorized$UITextEffectsWindow$class; */ -(void) _setStatusBarHidden:(BOOL)arg1 animationParameters:(unsafe_id)arg2 changeApplicationFlag:(BOOL)arg3 { - //if ([RASettings.sharedInstance unifyStatusBar]) - if ([RAMessagingClient.sharedInstance shouldHideStatusBar]) - { - arg1 = YES; - arg3 = YES; - } - else if ([RAMessagingClient.sharedInstance shouldShowStatusBar]) - { - arg1 = NO; - arg3 = YES; - } - //arg1 = ((forcingRotation&&NO) || overrideDisplay) ? (isTopApp ? NO : YES) : arg1; - - %orig(arg1, arg2, arg3); + //if ([RASettings.sharedInstance unifyStatusBar]) + if ([RAMessagingClient.sharedInstance shouldHideStatusBar]) + { + arg1 = YES; + arg3 = YES; + } + else if ([RAMessagingClient.sharedInstance shouldShowStatusBar]) + { + arg1 = NO; + arg3 = YES; + } + //arg1 = ((forcingRotation&&NO) || overrideDisplay) ? (isTopApp ? NO : YES) : arg1; + + %orig(arg1, arg2, arg3); } /* @@ -117,148 +117,144 @@ static Class $memorized$UITextEffectsWindow$class; %new -(void) RA_forceRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation isReverting:(BOOL)reverting { - if (!reverting) + if (!reverting) + { + if (!setPreviousOrientation) { - if (!setPreviousOrientation) - { - setPreviousOrientation = YES; - prevousOrientation = UIApplication.sharedApplication.statusBarOrientation; - if (wasStatusBarHidden == -1) - wasStatusBarHidden = UIApplication.sharedApplication.statusBarHidden; - } - } - else if (setPreviousOrientation) - { - orientation = prevousOrientation; - - setPreviousOrientation = NO; - } - - if (![UIApplication.sharedApplication _isSupportedOrientation:orientation]) - { - return; - } - - for (UIWindow *window in [[UIApplication sharedApplication] windows]) - { - [window _setRotatableViewOrientation:orientation updateStatusBar:YES duration:0.25 force:YES]; + setPreviousOrientation = YES; + prevousOrientation = UIApplication.sharedApplication.statusBarOrientation; + if (wasStatusBarHidden == -1) + wasStatusBarHidden = UIApplication.sharedApplication.statusBarHidden; } + } + else if (setPreviousOrientation) + { + orientation = prevousOrientation; + + setPreviousOrientation = NO; + } + + if (![UIApplication.sharedApplication _isSupportedOrientation:orientation]) + { + return; + } + + for (UIWindow *window in [[UIApplication sharedApplication] windows]) + { + [window _setRotatableViewOrientation:orientation updateStatusBar:YES duration:0.25 force:YES]; + } } %new -(void) RA_forceStatusBarVisibility:(BOOL)visible orRevert:(BOOL)revert { - if (revert) - { - if (wasStatusBarHidden != -1) - { - [UIApplication.sharedApplication _setStatusBarHidden:wasStatusBarHidden animationParameters:nil changeApplicationFlag:YES]; - } - } - else + if (revert) + { + if (wasStatusBarHidden != -1) { - if (wasStatusBarHidden == -1) - wasStatusBarHidden = UIApplication.sharedApplication.statusBarHidden; - [UIApplication.sharedApplication _setStatusBarHidden:visible animationParameters:nil changeApplicationFlag:YES]; + [UIApplication.sharedApplication _setStatusBarHidden:wasStatusBarHidden animationParameters:nil changeApplicationFlag:YES]; } + } + else + { + if (wasStatusBarHidden == -1) + wasStatusBarHidden = UIApplication.sharedApplication.statusBarHidden; + [UIApplication.sharedApplication _setStatusBarHidden:visible animationParameters:nil changeApplicationFlag:YES]; + } } %new -(void) RA_updateWindowsForSizeChange:(CGSize)size isReverting:(BOOL)revert { - if (revert) + if (revert) + { + for (UIWindow *window in [[UIApplication sharedApplication] windows]) { - for (UIWindow *window in [[UIApplication sharedApplication] windows]) - { - CGRect frame = window.frame; - if ([oldFrames objectForKey:@(window.hash)]) - { - frame = [[oldFrames objectForKey:@(window.hash)] CGRectValue]; - [oldFrames removeObjectForKey:@(window.hash)]; - } - - [UIView animateWithDuration:0.4 animations:^{ - [window setFrame:frame]; - }]; - } - - if ([oldFrames objectForKey:@"statusBar"]) - UIApplication.sharedApplication.statusBar.frame = [oldFrames[@"statusBar"] CGRectValue]; - - return; + CGRect frame = window.frame; + if ([oldFrames objectForKey:@(window.hash)]) + { + frame = [[oldFrames objectForKey:@(window.hash)] CGRectValue]; + [oldFrames removeObjectForKey:@(window.hash)]; + } + + [UIView animateWithDuration:0.4 animations:^{ + [window setFrame:frame]; + }]; } - if (size.width != -1) - { - if (![oldFrames objectForKey:@"statusBar"]) - [oldFrames setObject:[NSValue valueWithCGRect:UIApplication.sharedApplication.statusBar.frame] forKey:@"statusBar"]; - UIApplication.sharedApplication.statusBar.frame = CGRectMake(0, 0, size.width, UIApplication.sharedApplication.statusBar.frame.size.height); - } + if ([oldFrames objectForKey:@"statusBar"]) + UIApplication.sharedApplication.statusBar.frame = [oldFrames[@"statusBar"] CGRectValue]; - for (UIWindow *window in [[UIApplication sharedApplication] windows]) { - if (![oldFrames objectForKey:@(window.hash)]) - [oldFrames setObject:[NSValue valueWithCGRect:window.frame] forKey:@(window.hash)]; + return; + } - [UIView animateWithDuration:0.3 animations:^{ - [window setFrame:window.frame]; // updates with client message app data in the setFrame: hook - }]; - } + if (size.width != -1) + { + if (![oldFrames objectForKey:@"statusBar"]) + [oldFrames setObject:[NSValue valueWithCGRect:UIApplication.sharedApplication.statusBar.frame] forKey:@"statusBar"]; + UIApplication.sharedApplication.statusBar.frame = CGRectMake(0, 0, size.width, UIApplication.sharedApplication.statusBar.frame.size.height); + } + + for (UIWindow *window in [[UIApplication sharedApplication] windows]) { + if (![oldFrames objectForKey:@(window.hash)]) + [oldFrames setObject:[NSValue valueWithCGRect:window.frame] forKey:@(window.hash)]; + + [UIView animateWithDuration:0.3 animations:^{ + [window setFrame:window.frame]; // updates with client message app data in the setFrame: hook + }]; + } } -(BOOL) isNetworkActivityIndicatorVisible { - if ([RAMessagingClient.sharedInstance isBeingHosted]) - return self.RA_networkActivity; - else - return %orig; + if ([RAMessagingClient.sharedInstance isBeingHosted]) + return self.RA_networkActivity; + else + return %orig; } -(void) setNetworkActivityIndicatorVisible:(BOOL)arg1 { - %orig(arg1); - if ([RAMessagingClient.sharedInstance isBeingHosted]) - { - self.RA_networkActivity = arg1; - - StatusBarData *data = [UIStatusBarServer getStatusBarData]; - data->itemIsEnabled[26] = arg1; // 26 = activity indicator - [UIApplication.sharedApplication.statusBar forceUpdateToData:data animated:YES]; - } + %orig(arg1); + if ([RAMessagingClient.sharedInstance isBeingHosted]) + { + self.RA_networkActivity = arg1; + + StatusBarData *data = [UIStatusBarServer getStatusBarData]; + data->itemIsEnabled[26] = arg1; // 26 = activity indicator + [UIApplication.sharedApplication.statusBar forceUpdateToData:data animated:YES]; + } } -(BOOL) openURL:(__unsafe_unretained NSURL*)url { - if ([RAMessagingClient.sharedInstance isBeingHosted])// || [RASettings.sharedInstance openLinksInWindows]) - { - return [RAMessagingClient.sharedInstance notifyServerToOpenURL:url openInWindow:[RASettings.sharedInstance openLinksInWindows]]; - } - return %orig; + if ([RAMessagingClient.sharedInstance isBeingHosted])// || [RASettings.sharedInstance openLinksInWindows]) + { + return [RAMessagingClient.sharedInstance notifyServerToOpenURL:url openInWindow:[RASettings.sharedInstance openLinksInWindows]]; + } + return %orig; } %end %hook UIStatusBar -(void) statusBarServer:(unsafe_id)arg1 didReceiveStatusBarData:(StatusBarData*)arg2 withActions:(int)arg3 { - if ([RAMessagingClient.sharedInstance isBeingHosted]) - arg2->itemIsEnabled[26] = [UIApplication.sharedApplication isNetworkActivityIndicatorVisible]; - %orig; + if ([RAMessagingClient.sharedInstance isBeingHosted]) + arg2->itemIsEnabled[26] = [UIApplication.sharedApplication isNetworkActivityIndicatorVisible]; + %orig; } %end -void reloadSettings(CFNotificationCenterRef center, - void *observer, - CFStringRef name, - const void *object, - CFDictionaryRef userInfo) +void reloadSettings(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { [RASettings.sharedInstance reloadSettings]; } %ctor { - IF_NOT_SPRINGBOARD { - %init; - $memorized$UITextEffectsWindow$class = %c(UITextEffectsWindow); - } + IF_NOT_SPRINGBOARD { + %init; + $memorized$UITextEffectsWindow$class = %c(UITextEffectsWindow); + } - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadSettings, CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), NULL, 0); - [RASettings sharedInstance]; + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadSettings, CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), NULL, 0); + [RASettings sharedInstance]; } diff --git a/WindowedMultitasking/ActivatorCreateAppWindow.xm b/WindowedMultitasking/ActivatorCreateAppWindow.xm index ec62375..948d3e0 100644 --- a/WindowedMultitasking/ActivatorCreateAppWindow.xm +++ b/WindowedMultitasking/ActivatorCreateAppWindow.xm @@ -21,18 +21,18 @@ static RAActivatorCreateWindowListener *sharedInstance$RAActivatorCreateWindowLi // Close app [[%c(RABackgrounder) sharedInstance] temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:topApp andCloseForegroundApp:NO]; FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ - SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; - [deactiveSets setFlag:YES forDeactivationSetting:20]; - [deactiveSets setFlag:NO forDeactivationSetting:2]; - [topApp _setDeactivationSettings:deactiveSets]; - - SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; - [transaction begin]; - - // Open in window - RAWindowBar *windowBar = [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; - if (!RADesktopManager.sharedInstance.lastUsedWindow) - RADesktopManager.sharedInstance.lastUsedWindow = windowBar; + SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; + [deactiveSets setFlag:YES forDeactivationSetting:20]; + [deactiveSets setFlag:NO forDeactivationSetting:2]; + [topApp _setDeactivationSettings:deactiveSets]; + + SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; + [transaction begin]; + + // Open in window + RAWindowBar *windowBar = [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; + if (!RADesktopManager.sharedInstance.lastUsedWindow) + RADesktopManager.sharedInstance.lastUsedWindow = windowBar; }]; [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; @@ -45,9 +45,9 @@ static RAActivatorCreateWindowListener *sharedInstance$RAActivatorCreateWindowLi %ctor { - IF_SPRINGBOARD - { - sharedInstance$RAActivatorCreateWindowListener = [[RAActivatorCreateWindowListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorCreateWindowListener forName:@"com.efrederickson.reachapp.windowedmultitasking.createWindow"]; - } + IF_SPRINGBOARD + { + sharedInstance$RAActivatorCreateWindowListener = [[RAActivatorCreateWindowListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorCreateWindowListener forName:@"com.efrederickson.reachapp.windowedmultitasking.createWindow"]; + } } diff --git a/WindowedMultitasking/ActivatorToggleEditModeListener.xm b/WindowedMultitasking/ActivatorToggleEditModeListener.xm index 99c688d..3ec7728 100644 --- a/WindowedMultitasking/ActivatorToggleEditModeListener.xm +++ b/WindowedMultitasking/ActivatorToggleEditModeListener.xm @@ -18,10 +18,10 @@ static RAActivatorToggleEditModeListener *sharedInstance; { if ([view isKindOfClass:[RAWindowBar class]]) { - if (view.isOverlayShowing) - [view hideOverlay]; - else - [view showOverlay]; + if (view.isOverlayShowing) + [view hideOverlay]; + else + [view showOverlay]; } } } @@ -29,9 +29,9 @@ static RAActivatorToggleEditModeListener *sharedInstance; %ctor { - IF_SPRINGBOARD - { - sharedInstance = [[RAActivatorToggleEditModeListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"]; - } + IF_SPRINGBOARD + { + sharedInstance = [[RAActivatorToggleEditModeListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"]; + } } diff --git a/WindowedMultitasking/RADesktopWindow.mm b/WindowedMultitasking/RADesktopWindow.mm index 69fd77d..6406e7b 100644 --- a/WindowedMultitasking/RADesktopWindow.mm +++ b/WindowedMultitasking/RADesktopWindow.mm @@ -260,24 +260,24 @@ -(UIInterfaceOrientation) appOrientationRelativeToThisOrientation:(CGFloat)curre switch (base) { case UIInterfaceOrientationLandscapeLeft: - if (currentRotation >= 315 || currentRotation <= 45) - return UIInterfaceOrientationLandscapeLeft; - else if (currentRotation > 45 && currentRotation <= 135) - return UIInterfaceOrientationPortraitUpsideDown; - else if (currentRotation > 135 && currentRotation <= 215) - return UIInterfaceOrientationLandscapeRight; - else - return UIInterfaceOrientationPortrait; + if (currentRotation >= 315 || currentRotation <= 45) + return UIInterfaceOrientationLandscapeLeft; + else if (currentRotation > 45 && currentRotation <= 135) + return UIInterfaceOrientationPortraitUpsideDown; + else if (currentRotation > 135 && currentRotation <= 215) + return UIInterfaceOrientationLandscapeRight; + else + return UIInterfaceOrientationPortrait; case UIInterfaceOrientationLandscapeRight: - if (currentRotation >= 315 || currentRotation <= 45) - return UIInterfaceOrientationLandscapeRight; - else if (currentRotation > 45 && currentRotation <= 135) - return UIInterfaceOrientationPortrait; - else if (currentRotation > 135 && currentRotation <= 215) - return UIInterfaceOrientationLandscapeLeft; - else - return UIInterfaceOrientationPortraitUpsideDown; + if (currentRotation >= 315 || currentRotation <= 45) + return UIInterfaceOrientationLandscapeRight; + else if (currentRotation > 45 && currentRotation <= 135) + return UIInterfaceOrientationPortrait; + else if (currentRotation > 135 && currentRotation <= 215) + return UIInterfaceOrientationLandscapeLeft; + else + return UIInterfaceOrientationPortraitUpsideDown; case UIInterfaceOrientationPortraitUpsideDown: if (currentRotation >= 315 || currentRotation <= 45) @@ -323,19 +323,19 @@ -(void) loadInfo:(NSInteger)index -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { - NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; - UIView *subview; - while ((subview = [objects nextObject])) - { - if (self.rootViewController && [self.rootViewController.view isEqual:subview]) - continue; - if (subview.hidden) - continue; - UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; - if (success) - return success; - } - return [super hitTest:point withEvent:event]; + NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; + UIView *subview; + while ((subview = [objects nextObject])) + { + if (self.rootViewController && [self.rootViewController.view isEqual:subview]) + continue; + if (subview.hidden) + continue; + UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; + if (success) + return success; + } + return [super hitTest:point withEvent:event]; } - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event @@ -343,10 +343,10 @@ - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event BOOL isContained = NO; for (UIView *view in self.subviews) { - if (self.rootViewController && [self.rootViewController.view isEqual:view]) - continue; - if (view.hidden) - continue; + if (self.rootViewController && [self.rootViewController.view isEqual:view]) + continue; + if (view.hidden) + continue; if (CGRectContainsPoint(view.frame, point) || CGRectContainsPoint(view.frame, [view convertPoint:point fromView:self])) // [self convertPoint:point toView:view])) isContained = YES; } diff --git a/WindowedMultitasking/RAWindowBar.xm b/WindowedMultitasking/RAWindowBar.xm index 3d00d98..0fa95f8 100644 --- a/WindowedMultitasking/RAWindowBar.xm +++ b/WindowedMultitasking/RAWindowBar.xm @@ -64,9 +64,9 @@ extern BOOL allowOpenApp; view.hideStatusBar = YES; [self addSubview:view]; - panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; - panGesture.delegate = self; - [self addGestureRecognizer:panGesture]; + panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; + panGesture.delegate = self; + [self addGestureRecognizer:panGesture]; scaleGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)]; scaleGesture.delegate = self; @@ -104,79 +104,79 @@ extern BOOL allowOpenApp; [doubleTapGesture requireGestureRecognizerToFail:tripleTapGesture]; - self.userInteractionEnabled = YES; - enableDrag = YES; - enableLongPress = YES; - - titleLabel = [[RAInsetLabel alloc] initWithFrame:CGRectMake(0, 0, myFrame.size.width, height)]; - titleLabel.textInset = UIEdgeInsetsMake(0, THEMED(windowedMultitaskingBarTitleTextInset) ?: 5, 0, THEMED(windowedMultitaskingBarTitleTextInset) ?: 5); - titleLabel.textAlignment = THEMED(windowedMultaskingBarTitleTextAlignment); - titleLabel.font = [UIFont systemFontOfSize:18]; - titleLabel.textColor = THEMED(windowedMultitaskingBarTitleColor); - titleLabel.text = [view displayName]; - [self addSubview:titleLabel]; - - CGFloat tmp = 16; - while (tmp + 16 < height) - tmp += 16; - buttonSize = tmp; - spacing = (height - buttonSize) / 2.0; - - if (![RASettings.sharedInstance onlyShowWindowBarIconsOnOverlay]) - { - /* - alignment: - 0 = left - 1 = right - */ - - // This is terribly inefficient.... plz send help - - static id closeItemIdentifier = [[NSObject alloc] init], - maxItemIdentifier = [[NSObject alloc] init], - minItemIdentifier = [[NSObject alloc] init], - rotationItemIdentifier = [[NSObject alloc] init]; - - NSMutableArray *infos = [NSMutableArray array]; - - NSInteger closeAlignment = THEMED(windowedMultitaskingCloseButtonAlignment); - NSInteger maxAlignment = THEMED(windowedMultitaskingMaxButtonAlignment); - NSInteger minAlignment = THEMED(windowedMultitaskingMinButtonAlignment); - NSInteger rotationAlignment = THEMED(windowedMultitaskingRotationAlignment); - - NSInteger closePriority = THEMED(windowedMultitaskingCloseButtonPriority); - NSInteger maxPriority = THEMED(windowedMultitaskingMaxButtonPriority); - NSInteger minPriority = THEMED(windowedMultitaskingMinButtonPriority); - NSInteger rotationPriority = THEMED(windowedMultitaskingRotationPriority); - - RAWindowBarIconInfo *tmpItem = [[RAWindowBarIconInfo alloc] init]; - tmpItem.alignment = closeAlignment; - tmpItem.priority = closePriority; - tmpItem.item = closeItemIdentifier; - [infos addObject:tmpItem]; - - tmpItem = [[RAWindowBarIconInfo alloc] init]; - tmpItem.alignment = maxAlignment; - tmpItem.priority = maxPriority; - tmpItem.item = maxItemIdentifier; - [infos addObject:tmpItem]; - - tmpItem = [[RAWindowBarIconInfo alloc] init]; - tmpItem.alignment = minAlignment; - tmpItem.priority = minPriority; - tmpItem.item = minItemIdentifier; - [infos addObject:tmpItem]; - - tmpItem = [[RAWindowBarIconInfo alloc] init]; - tmpItem.alignment = rotationAlignment; - tmpItem.priority = rotationPriority; - tmpItem.item = rotationItemIdentifier; - [infos addObject:tmpItem]; - - NSMutableArray *leftIconOrder = [NSMutableArray array]; - NSMutableArray *rightIconOrder = [NSMutableArray array]; - - for (int i = 0; i < infos.count; i++) + self.userInteractionEnabled = YES; + enableDrag = YES; + enableLongPress = YES; + + titleLabel = [[RAInsetLabel alloc] initWithFrame:CGRectMake(0, 0, myFrame.size.width, height)]; + titleLabel.textInset = UIEdgeInsetsMake(0, THEMED(windowedMultitaskingBarTitleTextInset) ?: 5, 0, THEMED(windowedMultitaskingBarTitleTextInset) ?: 5); + titleLabel.textAlignment = THEMED(windowedMultaskingBarTitleTextAlignment); + titleLabel.font = [UIFont systemFontOfSize:18]; + titleLabel.textColor = THEMED(windowedMultitaskingBarTitleColor); + titleLabel.text = [view displayName]; + [self addSubview:titleLabel]; + + CGFloat tmp = 16; + while (tmp + 16 < height) + tmp += 16; + buttonSize = tmp; + spacing = (height - buttonSize) / 2.0; + + if (![RASettings.sharedInstance onlyShowWindowBarIconsOnOverlay]) + { + /* + alignment: + 0 = left + 1 = right + */ + + // This is terribly inefficient.... plz send help + + static id closeItemIdentifier = [[NSObject alloc] init], + maxItemIdentifier = [[NSObject alloc] init], + minItemIdentifier = [[NSObject alloc] init], + rotationItemIdentifier = [[NSObject alloc] init]; + + NSMutableArray *infos = [NSMutableArray array]; + + NSInteger closeAlignment = THEMED(windowedMultitaskingCloseButtonAlignment); + NSInteger maxAlignment = THEMED(windowedMultitaskingMaxButtonAlignment); + NSInteger minAlignment = THEMED(windowedMultitaskingMinButtonAlignment); + NSInteger rotationAlignment = THEMED(windowedMultitaskingRotationAlignment); + + NSInteger closePriority = THEMED(windowedMultitaskingCloseButtonPriority); + NSInteger maxPriority = THEMED(windowedMultitaskingMaxButtonPriority); + NSInteger minPriority = THEMED(windowedMultitaskingMinButtonPriority); + NSInteger rotationPriority = THEMED(windowedMultitaskingRotationPriority); + + RAWindowBarIconInfo *tmpItem = [[RAWindowBarIconInfo alloc] init]; + tmpItem.alignment = closeAlignment; + tmpItem.priority = closePriority; + tmpItem.item = closeItemIdentifier; + [infos addObject:tmpItem]; + + tmpItem = [[RAWindowBarIconInfo alloc] init]; + tmpItem.alignment = maxAlignment; + tmpItem.priority = maxPriority; + tmpItem.item = maxItemIdentifier; + [infos addObject:tmpItem]; + + tmpItem = [[RAWindowBarIconInfo alloc] init]; + tmpItem.alignment = minAlignment; + tmpItem.priority = minPriority; + tmpItem.item = minItemIdentifier; + [infos addObject:tmpItem]; + + tmpItem = [[RAWindowBarIconInfo alloc] init]; + tmpItem.alignment = rotationAlignment; + tmpItem.priority = rotationPriority; + tmpItem.item = rotationItemIdentifier; + [infos addObject:tmpItem]; + + NSMutableArray *leftIconOrder = [NSMutableArray array]; + NSMutableArray *rightIconOrder = [NSMutableArray array]; + + for (int i = 0; i < infos.count; i++) { RAWindowBarIconInfo *info = infos[i]; if (info.alignment == 0) @@ -305,12 +305,12 @@ extern BOOL allowOpenApp; -(void) drawRect:(CGRect)rect { - CGRect topRect = CGRectMake(0, 0, rect.size.width, height); - // Fill the rectangle with grey - [barBackgroundColor setFill]; - UIRectFill(topRect); + CGRect topRect = CGRectMake(0, 0, rect.size.width, height); + // Fill the rectangle with grey + [barBackgroundColor setFill]; + UIRectFill(topRect); - [super drawRect:rect]; + [super drawRect:rect]; } -(void) close @@ -425,30 +425,30 @@ extern BOOL allowOpenApp; if (rads != 0) self.transform = CGAffineTransformRotate(self.transform, rads); - if (update) + if (update) { - CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); - CGFloat rotateSnapDegrees = 0; - - if (currentRotation < 0) - currentRotation = 360 + currentRotation; - - if (currentRotation >= 315 || currentRotation <= 45) - rotateSnapDegrees = 360 - currentRotation; - else if (currentRotation > 45 && currentRotation <= 135) - rotateSnapDegrees = 90 - currentRotation; - else if (currentRotation > 135 && currentRotation <= 215) - rotateSnapDegrees = 180 - currentRotation; - else - rotateSnapDegrees = 270 - currentRotation; - - if ([RASettings.sharedInstance snapRotation]) - [UIView animateWithDuration:0.2 animations:^{ - self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(rotateSnapDegrees)); - }]; + CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); + CGFloat rotateSnapDegrees = 0; + + if (currentRotation < 0) + currentRotation = 360 + currentRotation; + + if (currentRotation >= 315 || currentRotation <= 45) + rotateSnapDegrees = 360 - currentRotation; + else if (currentRotation > 45 && currentRotation <= 135) + rotateSnapDegrees = 90 - currentRotation; + else if (currentRotation > 135 && currentRotation <= 215) + rotateSnapDegrees = 180 - currentRotation; + else + rotateSnapDegrees = 270 - currentRotation; + + if ([RASettings.sharedInstance snapRotation]) + [UIView animateWithDuration:0.2 animations:^{ + self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(rotateSnapDegrees)); + }]; if (!appRotationLocked) - [attachedView rotateToOrientation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; + [attachedView rotateToOrientation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; if ([RASettings.sharedInstance snapWindows] && [RAWindowSnapDataProvider shouldSnapWindow:self]) { @@ -457,15 +457,15 @@ extern BOOL allowOpenApp; } [self saveWindowInfo]; - } + } } -(void) updateClientRotation { if (!appRotationLocked) { - CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); - [self updateClientRotation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; + CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); + [self updateClientRotation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; } } @@ -473,8 +473,8 @@ extern BOOL allowOpenApp; { if (!appRotationLocked) { - CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); - [attachedView rotateToOrientation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; + CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); + [attachedView rotateToOrientation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; } } @@ -500,16 +500,16 @@ extern BOOL allowOpenApp; if (![RASettings.sharedInstance alwaysEnableGestures] && !self.isOverlayShowing) return; - if (gesture.state == UIGestureRecognizerStateChanged) - { - [self addRotation:gesture.rotation updateApp:NO]; - //[self setTransform:CGAffineTransformRotate(self.transform, gesture.rotation)]; - gesture.rotation = 0.0; - } - else if (gesture.state == UIGestureRecognizerStateEnded) + if (gesture.state == UIGestureRecognizerStateChanged) { - [self addRotation:0 updateApp:YES]; - } + [self addRotation:gesture.rotation updateApp:NO]; + //[self setTransform:CGAffineTransformRotate(self.transform, gesture.rotation)]; + gesture.rotation = 0.0; + } + else if (gesture.state == UIGestureRecognizerStateEnded) + { + [self addRotation:0 updateApp:YES]; + } } -(void) handleLongPress:(UILongPressGestureRecognizer*)sender @@ -613,13 +613,13 @@ extern BOOL allowOpenApp; } isSnapped = NO; - UIView *view = sender.view; - CGPoint point = [sender translationInView:view.superview]; + UIView *view = sender.view; + CGPoint point = [sender translationInView:view.superview]; - CGPoint translatedPoint = CGPointMake(initialPoint.x + point.x, initialPoint.y + point.y); - view.center = translatedPoint; + CGPoint translatedPoint = CGPointMake(initialPoint.x + point.x, initialPoint.y + point.y); + view.center = translatedPoint; - [self updatePotentialSnapShadow]; + [self updatePotentialSnapShadow]; } - (void)handlePinch:(UIPinchGestureRecognizer *)gesture @@ -627,18 +627,18 @@ extern BOOL allowOpenApp; if (![RASettings.sharedInstance alwaysEnableGestures] && !self.isOverlayShowing) return; - switch (gesture.state) { - case UIGestureRecognizerStateBegan: - enableDrag = NO; enableLongPress = NO; - break; - case UIGestureRecognizerStateChanged: - [self setTransform:CGAffineTransformScale(self.transform, gesture.scale, gesture.scale)]; - //self.bounds = (CGRect){ self.bounds.origin, {self.bounds.size.width * gesture.scale, self.bounds.size.height * gesture.scale} }; + switch (gesture.state) { + case UIGestureRecognizerStateBegan: + enableDrag = NO; enableLongPress = NO; + break; + case UIGestureRecognizerStateChanged: + [self setTransform:CGAffineTransformScale(self.transform, gesture.scale, gesture.scale)]; + //self.bounds = (CGRect){ self.bounds.origin, {self.bounds.size.width * gesture.scale, self.bounds.size.height * gesture.scale} }; - gesture.scale = 1.0; - break; - case UIGestureRecognizerStateEnded: - enableDrag = YES; enableLongPress = YES; + gesture.scale = 1.0; + break; + case UIGestureRecognizerStateEnded: + enableDrag = YES; enableLongPress = YES; if ([RAWindowSnapDataProvider shouldSnapWindow:self]) { @@ -650,11 +650,10 @@ extern BOOL allowOpenApp; return; } [self saveWindowInfo]; - - break; - default: - break; - } + break; + default: + break; + } } -(void) setTransform:(CGAffineTransform)trans @@ -707,10 +706,10 @@ extern BOOL allowOpenApp; snapShadowView.layer.shadowRadius = 20; snapShadowView.layer.shadowOpacity = 0.8; snapShadowView.layer.shadowOffset = CGSizeMake(0, 0); - snapShadowView.layer.borderWidth = 1.5f; - snapShadowView.layer.cornerRadius = 6; - snapShadowView.clipsToBounds = YES; - snapShadowView.layer.masksToBounds = YES; + snapShadowView.layer.borderWidth = 1.5f; + snapShadowView.layer.cornerRadius = 6; + snapShadowView.clipsToBounds = YES; + snapShadowView.layer.masksToBounds = YES; [self.superview insertSubview:snapShadowView belowSubview:self]; } @@ -746,26 +745,26 @@ extern BOOL allowOpenApp; -(void) resignForemostApp { - titleLabel.font = [UIFont systemFontOfSize:18]; + titleLabel.font = [UIFont systemFontOfSize:18]; } -(void) becomeForemostApp { - titleLabel.font = [UIFont boldSystemFontOfSize:20]; + titleLabel.font = [UIFont boldSystemFontOfSize:20]; [self.superview bringSubviewToFront:self]; } -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { - NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; - UIView *subview; - while ((subview = [objects nextObject])) - { - UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; - if (success) - return success; - } - return [super hitTest:point withEvent:event]; + NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; + UIView *subview; + while ((subview = [objects nextObject])) + { + UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; + if (success) + return success; + } + return [super hitTest:point withEvent:event]; } - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event diff --git a/WindowedMultitasking/StartMultitaskingGesture.xm b/WindowedMultitasking/StartMultitaskingGesture.xm index 269a78a..5dbfac7 100644 --- a/WindowedMultitasking/StartMultitaskingGesture.xm +++ b/WindowedMultitasking/StartMultitaskingGesture.xm @@ -11,145 +11,143 @@ BOOL locationIsInValidArea(CGFloat x) { - if (x == 0) return YES; // more than likely, UIGestureRecognizerStateEnded - - switch ([RASettings.sharedInstance windowedMultitaskingGrabArea]) - { - case RAGrabAreaBottomLeftThird: - LogDebug(@"[ReachApp] StartMultitaskingGesture: %f %f", x, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width); - return x <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0; - case RAGrabAreaBottomMiddleThird: - return x >= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0 && x <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0) * 2; - case RAGrabAreaBottomRightThird: - return x >= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0) * 2; - default: - return NO; - } + if (x == 0) return YES; // more than likely, UIGestureRecognizerStateEnded + + switch ([RASettings.sharedInstance windowedMultitaskingGrabArea]) + { + case RAGrabAreaBottomLeftThird: + LogDebug(@"[ReachApp] StartMultitaskingGesture: %f %f", x, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width); + return x <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0; + case RAGrabAreaBottomMiddleThird: + return x >= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0 && x <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0) * 2; + case RAGrabAreaBottomRightThird: + return x >= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0) * 2; + default: + return NO; + } } %ctor { - IF_NOT_SPRINGBOARD - return; - __weak __block UIView *appView = nil; - __block CGFloat lastY = 0; - __block CGPoint originalCenter; - [[RAGestureManager sharedInstance] addGestureRecognizer:^RAGestureCallbackResult(UIGestureRecognizerState state, CGPoint location, CGPoint velocity) { - - SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; - - // Dismiss potential CC - //[[%c(SBUIController) sharedInstance] _showControlCenterGestureEndedWithLocation:CGPointMake(0, UIScreen.mainScreen.bounds.size.height - 1) velocity:CGPointZero]; - - if (state == UIGestureRecognizerStateBegan) - { - [RAControlCenterInhibitor setInhibited:YES]; - - // Show HS/Wallpaper - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; - [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; - - // Assign view - appView = [RAHostManager systemHostViewForApplication:topApp].superview; - if (IS_IOS_OR_NEWER(iOS_9_0)) - appView = appView.superview; - originalCenter = appView.center; - } - else if (state == UIGestureRecognizerStateChanged) - { - lastY = location.y; - CGFloat scale = location.y / UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height; - - if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) - { - scale = MIN(MAX(scale, 0.01), 1); - CGFloat actualScale = scale; - scale = 1 - scale; - RAPreservedWindowInformation info = [RAWindowStatePreservationSystemManager.sharedInstance windowInformationForAppIdentifier:topApp.bundleIdentifier]; - - // Interpolates between A and B with percentage T (T% between state A and state B) - CGFloat (^interpolate)(CGFloat, CGFloat, CGFloat) = ^CGFloat(CGFloat a, CGFloat b, CGFloat t){ - return a + (b - a) * t; - }; - - CGPoint center = CGPointMake( - interpolate(info.center.x, originalCenter.x, actualScale), - interpolate(info.center.y, originalCenter.y, actualScale) - ); - - CGFloat currentRotation = (atan2(info.transform.b, info.transform.a) * scale); - //CGFloat currentScale = 1 - (sqrt(info.transform.a * info.transform.a + info.transform.c * info.transform.c) * scale); - CGFloat currentScale = interpolate(1, sqrt(info.transform.a * info.transform.a + info.transform.c * info.transform.c), scale); - CGAffineTransform transform = CGAffineTransformRotate(CGAffineTransformMakeScale(currentScale, currentScale), currentRotation); - - appView.center = center; - appView.transform = transform; - } - else - { - scale = MIN(MAX(scale, 0.3), 1); - appView.transform = CGAffineTransformMakeScale(scale, scale); - } - } - else if (state == UIGestureRecognizerStateEnded) - { - [RAControlCenterInhibitor setInhibited:NO]; - - if (lastY <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 4) * 3 && lastY != 0) // 75% down, 0 == gesture ended in most situations - { - [UIView animateWithDuration:.3 animations:^{ - - if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) - { - RAPreservedWindowInformation info = [RAWindowStatePreservationSystemManager.sharedInstance windowInformationForAppIdentifier:topApp.bundleIdentifier]; - appView.center = info.center; - appView.transform = info.transform; - } - else - { - appView.transform = CGAffineTransformMakeScale(0.5, 0.5); - appView.center = originalCenter; - } - } completion:^(BOOL _) { - RAIconIndicatorViewInfo indicatorInfo = [[%c(RABackgrounder) sharedInstance] allAggregatedIndicatorInfoForIdentifier:topApp.bundleIdentifier]; - - // Close app - [[%c(RABackgrounder) sharedInstance] temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:topApp andCloseForegroundApp:NO]; - FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ - SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; - [deactiveSets setFlag:YES forDeactivationSetting:20]; - [deactiveSets setFlag:NO forDeactivationSetting:2]; - [topApp _setDeactivationSettings:deactiveSets]; - - SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; - [transaction begin]; - - // Open in window - RAWindowBar *windowBar = [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; - if (!RADesktopManager.sharedInstance.lastUsedWindow) - RADesktopManager.sharedInstance.lastUsedWindow = windowBar; - }]; - [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; - [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; - - // Pop forced foreground backgrounding - [[%c(RABackgrounder) sharedInstance] queueRemoveTemporaryOverrideForIdentifier:topApp.bundleIdentifier]; - [[%c(RABackgrounder) sharedInstance] removeTemporaryOverrideForIdentifier:topApp.bundleIdentifier]; - [[%c(RABackgrounder) sharedInstance] updateIconIndicatorForIdentifier:topApp.bundleIdentifier withInfo:indicatorInfo]; - }]; - } - else - { - appView.center = originalCenter; - [UIView animateWithDuration:0.2 animations:^{ appView.transform = CGAffineTransformIdentity; } completion:^(BOOL _) { - [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; - }]; - } - appView = nil; - } - - return RAGestureCallbackResultSuccess; - } withCondition:^BOOL(CGPoint location, CGPoint velocity) { - return [RASettings.sharedInstance windowedMultitaskingEnabled] && (locationIsInValidArea(location.x) || appView) && ![[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && [UIApplication.sharedApplication _accessibilityFrontMostApplication] && ![[%c(SBNotificationCenterController) sharedInstance] isVisible]; - } forEdge:UIRectEdgeBottom identifier:@"com.efrederickson.reachapp.windowedmultitasking.systemgesture" priority:RAGesturePriorityDefault]; + IF_NOT_SPRINGBOARD + return; + __weak __block UIView *appView = nil; + __block CGFloat lastY = 0; + __block CGPoint originalCenter; + [[RAGestureManager sharedInstance] addGestureRecognizer:^RAGestureCallbackResult(UIGestureRecognizerState state, CGPoint location, CGPoint velocity) { + SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; + + // Dismiss potential CC + //[[%c(SBUIController) sharedInstance] _showControlCenterGestureEndedWithLocation:CGPointMake(0, UIScreen.mainScreen.bounds.size.height - 1) velocity:CGPointZero]; + + if (state == UIGestureRecognizerStateBegan) + { + [RAControlCenterInhibitor setInhibited:YES]; + + // Show HS/Wallpaper + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; + [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; + + // Assign view + appView = [RAHostManager systemHostViewForApplication:topApp].superview; + if (IS_IOS_OR_NEWER(iOS_9_0)) + appView = appView.superview; + originalCenter = appView.center; + } + else if (state == UIGestureRecognizerStateChanged) + { + lastY = location.y; + CGFloat scale = location.y / UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height; + + if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) + { + scale = MIN(MAX(scale, 0.01), 1); + CGFloat actualScale = scale; + scale = 1 - scale; + RAPreservedWindowInformation info = [RAWindowStatePreservationSystemManager.sharedInstance windowInformationForAppIdentifier:topApp.bundleIdentifier]; + + // Interpolates between A and B with percentage T (T% between state A and state B) + CGFloat (^interpolate)(CGFloat, CGFloat, CGFloat) = ^CGFloat(CGFloat a, CGFloat b, CGFloat t){ + return a + (b - a) * t; + }; + + CGPoint center = CGPointMake( + interpolate(info.center.x, originalCenter.x, actualScale), + interpolate(info.center.y, originalCenter.y, actualScale) + ); + + CGFloat currentRotation = (atan2(info.transform.b, info.transform.a) * scale); + //CGFloat currentScale = 1 - (sqrt(info.transform.a * info.transform.a + info.transform.c * info.transform.c) * scale); + CGFloat currentScale = interpolate(1, sqrt(info.transform.a * info.transform.a + info.transform.c * info.transform.c), scale); + CGAffineTransform transform = CGAffineTransformRotate(CGAffineTransformMakeScale(currentScale, currentScale), currentRotation); + + appView.center = center; + appView.transform = transform; + } + else + { + scale = MIN(MAX(scale, 0.3), 1); + appView.transform = CGAffineTransformMakeScale(scale, scale); + } + } + else if (state == UIGestureRecognizerStateEnded) + { + [RAControlCenterInhibitor setInhibited:NO]; + + if (lastY <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 4) * 3 && lastY != 0) // 75% down, 0 == gesture ended in most situations + { + [UIView animateWithDuration:.3 animations:^{ + if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) + { + RAPreservedWindowInformation info = [RAWindowStatePreservationSystemManager.sharedInstance windowInformationForAppIdentifier:topApp.bundleIdentifier]; + appView.center = info.center; + appView.transform = info.transform; + } + else + { + appView.transform = CGAffineTransformMakeScale(0.5, 0.5); + appView.center = originalCenter; + } + } completion:^(BOOL _) { + RAIconIndicatorViewInfo indicatorInfo = [[%c(RABackgrounder) sharedInstance] allAggregatedIndicatorInfoForIdentifier:topApp.bundleIdentifier]; + + // Close app + [[%c(RABackgrounder) sharedInstance] temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:topApp andCloseForegroundApp:NO]; + FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ + SBDeactivationSettings *deactiveSets = [[%c(SBDeactivationSettings) alloc] init]; + [deactiveSets setFlag:YES forDeactivationSetting:20]; + [deactiveSets setFlag:NO forDeactivationSetting:2]; + [topApp _setDeactivationSettings:deactiveSets]; + + SBAppToAppWorkspaceTransaction *transaction = [Multiplexer createSBAppToAppWorkspaceTransactionForExitingApp:topApp]; + [transaction begin]; + + // Open in window + RAWindowBar *windowBar = [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; + if (!RADesktopManager.sharedInstance.lastUsedWindow) + RADesktopManager.sharedInstance.lastUsedWindow = windowBar; + }]; + [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; + [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; + + // Pop forced foreground backgrounding + [[%c(RABackgrounder) sharedInstance] queueRemoveTemporaryOverrideForIdentifier:topApp.bundleIdentifier]; + [[%c(RABackgrounder) sharedInstance] removeTemporaryOverrideForIdentifier:topApp.bundleIdentifier]; + [[%c(RABackgrounder) sharedInstance] updateIconIndicatorForIdentifier:topApp.bundleIdentifier withInfo:indicatorInfo]; + }]; + } + else + { + appView.center = originalCenter; + [UIView animateWithDuration:0.2 animations:^{ appView.transform = CGAffineTransformIdentity; } completion:^(BOOL _) { + [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; + }]; + } + appView = nil; + } + + return RAGestureCallbackResultSuccess; + } withCondition:^BOOL(CGPoint location, CGPoint velocity) { + return [RASettings.sharedInstance windowedMultitaskingEnabled] && (locationIsInValidArea(location.x) || appView) && ![[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && [UIApplication.sharedApplication _accessibilityFrontMostApplication] && ![[%c(SBNotificationCenterController) sharedInstance] isVisible]; + } forEdge:UIRectEdgeBottom identifier:@"com.efrederickson.reachapp.windowedmultitasking.systemgesture" priority:RAGesturePriorityDefault]; } diff --git a/WindowedMultitasking/WindowSorterActivator.xm b/WindowedMultitasking/WindowSorterActivator.xm index 7e3c804..6752355 100644 --- a/WindowedMultitasking/WindowSorterActivator.xm +++ b/WindowedMultitasking/WindowSorterActivator.xm @@ -13,17 +13,17 @@ static RAActivatorSortWindowsListener *sharedInstance$RAActivatorSortWindowsList @implementation RAActivatorSortWindowsListener - (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event { - RADesktopWindow *desktop = RADesktopManager.sharedInstance.currentDesktop; + RADesktopWindow *desktop = RADesktopManager.sharedInstance.currentDesktop; - [RAWindowSorter sortWindowsOnDesktop:desktop resizeIfNecessary:YES]; + [RAWindowSorter sortWindowsOnDesktop:desktop resizeIfNecessary:YES]; } @end %ctor { - IF_SPRINGBOARD - { - sharedInstance$RAActivatorSortWindowsListener = [[RAActivatorSortWindowsListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorSortWindowsListener forName:@"com.efrederickson.reachapp.windowedmultitasking.sortWindows"]; - } + IF_SPRINGBOARD + { + sharedInstance$RAActivatorSortWindowsListener = [[RAActivatorSortWindowsListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorSortWindowsListener forName:@"com.efrederickson.reachapp.windowedmultitasking.sortWindows"]; + } } diff --git a/headers.h b/headers.h index 9ef0859..95219e4 100644 --- a/headers.h +++ b/headers.h @@ -800,9 +800,9 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @end @interface SBDisplayLayout : NSObject { - int _layoutSize; - NSMutableArray* _displayItems; - NSString* _uniqueStringRepresentation; + int _layoutSize; + NSMutableArray* _displayItems; + NSString* _uniqueStringRepresentation; } @property(readonly, assign, nonatomic) NSArray* displayItems; @property(readonly, assign, nonatomic) int layoutSize; @@ -845,7 +845,7 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @end @interface UIGestureRecognizerTarget : NSObject { - id _target; + id _target; } @end @@ -1179,49 +1179,49 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @end @interface SBIconView : UIView { - SBIcon *_icon; - id _delegate; - id _locker; - SBIconImageContainerView *_iconImageContainer; - SBIconImageView *_iconImageView; - UIImageView *_iconDarkeningOverlay; - UIImageView *_ghostlyImageView; - UIImageView *_reflection; - UIImageView *_shadow; - SBIconBadgeImage *_badgeImage; - UIImageView *_badgeView; - SBIconLabel *_label; - BOOL _labelHidden; - BOOL _labelOnWallpaper; - UIView *_closeBox; - int _closeBoxType; - UIImageView *_dropGlow; - unsigned _drawsLabel : 1; - unsigned _isHidden : 1; - unsigned _isGrabbed : 1; - unsigned _isOverlapping : 1; - unsigned _refusesRecipientStatus : 1; - unsigned _highlighted : 1; - unsigned _launchDisabled : 1; - unsigned _isJittering : 1; - unsigned _allowJitter : 1; - unsigned _touchDownInIcon : 1; - unsigned _hideShadow : 1; - NSTimer *_delayedUnhighlightTimer; - unsigned _onWallpaper : 1; - unsigned _ghostlyRequesters; - int _iconLocation; - float _iconImageAlpha; - float _iconImageBrightness; - float _iconLabelAlpha; - float _accessoryAlpha; - CGPoint _unjitterPoint; - CGPoint _grabPoint; - NSTimer *_longPressTimer; - unsigned _ghostlyTag; - UIImage *_ghostlyImage; - BOOL _ghostlyPending; -} + SBIcon *_icon; + id _delegate; + id _locker; + SBIconImageContainerView *_iconImageContainer; + SBIconImageView *_iconImageView; + UIImageView *_iconDarkeningOverlay; + UIImageView *_ghostlyImageView; + UIImageView *_reflection; + UIImageView *_shadow; + SBIconBadgeImage *_badgeImage; + UIImageView *_badgeView; + SBIconLabel *_label; + BOOL _labelHidden; + BOOL _labelOnWallpaper; + UIView *_closeBox; + int _closeBoxType; + UIImageView *_dropGlow; + unsigned _drawsLabel : 1; + unsigned _isHidden : 1; + unsigned _isGrabbed : 1; + unsigned _isOverlapping : 1; + unsigned _refusesRecipientStatus : 1; + unsigned _highlighted : 1; + unsigned _launchDisabled : 1; + unsigned _isJittering : 1; + unsigned _allowJitter : 1; + unsigned _touchDownInIcon : 1; + unsigned _hideShadow : 1; + NSTimer *_delayedUnhighlightTimer; + unsigned _onWallpaper : 1; + unsigned _ghostlyRequesters; + int _iconLocation; + float _iconImageAlpha; + float _iconImageBrightness; + float _iconLabelAlpha; + float _accessoryAlpha; + CGPoint _unjitterPoint; + CGPoint _grabPoint; + NSTimer *_longPressTimer; + unsigned _ghostlyTag; + UIImage *_ghostlyImage; + BOOL _ghostlyPending; + } -(void) RA_updateIndicatorView:(NSInteger)info; @@ -1358,11 +1358,11 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @class NSMapTable; @interface SBIconViewMap : NSObject { - NSMapTable* _iconViewsForIcons; - id _iconViewdelegate; - NSMapTable* _recycledIconViewsByType; - NSMapTable* _labels; - NSMapTable* _badges; + NSMapTable* _iconViewsForIcons; + id _iconViewdelegate; + NSMapTable* _recycledIconViewsByType; + NSMapTable* _labels; + NSMapTable* _badges; } + (SBIconViewMap *)switcherMap; +(SBIconViewMap *)homescreenMap; @@ -1460,7 +1460,7 @@ typedef NS_ENUM(NSInteger, UIScreenEdgePanRecognizerType) { @end @interface _SBAppSwitcherSnapshotContext : NSObject { - SBSwitcherSnapshotImageView* _snapshotImageView; + SBSwitcherSnapshotImageView* _snapshotImageView; } @property (nonatomic,retain) SBSwitcherSnapshotImageView * snapshotImageView; //@synthesize snapshotImageView=_snapshotImageView - In the implementation block - (SBSwitcherSnapshotImageView *)snapshotImageView; diff --git a/reachappbackboarddhooks/Tweak.xm b/reachappbackboarddhooks/Tweak.xm index 04576c0..bd2c752 100644 --- a/reachappbackboarddhooks/Tweak.xm +++ b/reachappbackboarddhooks/Tweak.xm @@ -160,8 +160,8 @@ void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEven void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); if(handle) { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(center); - dlclose(handle); + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(center); + dlclose(handle); } } diff --git a/reachappfakephonemode/Tweak.xm b/reachappfakephonemode/Tweak.xm index bee13af..1f36ecd 100644 --- a/reachappfakephonemode/Tweak.xm +++ b/reachappfakephonemode/Tweak.xm @@ -13,76 +13,76 @@ %hook UIDevice -(UIUserInterfaceIdiom) userInterfaceIdiom { - UIUserInterfaceIdiom origIdiom = %orig; + UIUserInterfaceIdiom origIdiom = %orig; - //if (IS_SPRINGBOARD || ignorePhoneMode) - // return origIdiom; + //if (IS_SPRINGBOARD || ignorePhoneMode) + // return origIdiom; - if (origIdiom != UIUserInterfaceIdiomPhone && [%c(RAFakePhoneMode) shouldFakeForThisProcess]) - return UIUserInterfaceIdiomPhone; + if (origIdiom != UIUserInterfaceIdiomPhone && [%c(RAFakePhoneMode) shouldFakeForThisProcess]) + return UIUserInterfaceIdiomPhone; - return origIdiom; + return origIdiom; } %end %hook UIScreen - (CGRect)_unjailedReferenceBounds { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)_referenceBounds { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)_interfaceOrientedBounds { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)bounds { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)nativeBounds { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)applicationFrame { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)_boundsForInterfaceOrientation:(int)arg1 { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 usingStatusbarHeight:(CGFloat)arg2 ignoreStatusBar:(BOOL)arg3 { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 usingStatusbarHeight:(CGFloat)arg2 { - FAKE; - return %orig; + FAKE; + return %orig; } - (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 { - FAKE; - return %orig; + FAKE; + return %orig; } %end diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index fb2cc05..98da6c0 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -9,21 +9,21 @@ int main(int argc, char **argv, char **envp) { @autoreleasepool { NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; - if (![NSFileManager.defaultManager fileExistsAtPath:filePath]) - { - LogError(@"[ReachApp] FS Daemon: plist does not exist"); - return 0; - } + if (![NSFileManager.defaultManager fileExistsAtPath:filePath]) + { + LogError(@"[ReachApp] FS Daemon: plist does not exist"); + return 0; + } NSDictionary *contents = [NSDictionary dictionaryWithContentsOfFile:filePath]; - LSApplicationProxy *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:contents[@"bundleIdentifier"]]; - NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; - NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; - infoPlist[@"UIApplicationExitsOnSuspend"] = contents[@"UIApplicationExitsOnSuspend"]; - BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; + LSApplicationProxy *appInfo = [objc_getClass("LSApplicationProxy") applicationProxyForIdentifier:contents[@"bundleIdentifier"]]; + NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; + NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; + infoPlist[@"UIApplicationExitsOnSuspend"] = contents[@"UIApplicationExitsOnSuspend"]; + BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; - if (!success) { + if (!success) { LogError(@"[ReachApp] FS Daemon: error writing to plist: %@", path); } else { [NSFileManager.defaultManager removeItemAtPath:filePath error:nil]; diff --git a/reachappsettings/BackgroundPerAppDetailsController.xm b/reachappsettings/BackgroundPerAppDetailsController.xm index b44c8cb..505fbcb 100644 --- a/reachappsettings/BackgroundPerAppDetailsController.xm +++ b/reachappsettings/BackgroundPerAppDetailsController.xm @@ -19,241 +19,241 @@ extern void RA_BGAppsControllerNeedsToReload(); -(id) isBackgroundModeActive:(NSString*)mode withAppInfo:(NSArray*)info { - return [info containsObject:mode] ? @YES : @NO; + return [info containsObject:mode] ? @YES : @NO; } -(NSArray*) customSpecifiers { - LSApplicationProxy *appInfo = [%c(LSApplicationProxy) applicationProxyForIdentifier:_identifier]; - NSArray *bgModes = appInfo.UIBackgroundModes; + LSApplicationProxy *appInfo = [%c(LSApplicationProxy) applicationProxyForIdentifier:_identifier]; + NSArray *bgModes = appInfo.UIBackgroundModes; - BOOL exitsOnSuspend = [[NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]]][@"UIApplicationExitsOnSuspend"] boolValue]; + BOOL exitsOnSuspend = [[NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]]][@"UIApplicationExitsOnSuspend"] boolValue]; - BOOL preventDeath = [[self getActualPrefValue:@"preventDeath"] boolValue]; // Default is NO so it should work fine + BOOL preventDeath = [[self getActualPrefValue:@"preventDeath"] boolValue]; // Default is NO so it should work fine - return @[ - @{ - @"cell": @"PSSwitchCell", - @"label": @"Enabled", - @"key": @"enabled", - @"default": @NO, - }, + return @[ + @{ + @"cell": @"PSSwitchCell", + @"label": @"Enabled", + @"key": @"enabled", + @"default": @NO, + }, - @{ @"label": @""}, - @{ - @"cell": @"PSLinkListCell", - @"label": @"Background Mode", - @"key": @"backgroundMode", - @"validTitles": @[ @"Native", @"Unlimited Backgrounding Time", @"Force Foreground", @"Kill on Exit", @"Suspend Immediately" ], - @"validValues": @[ @(RABackgroundModeNative), @(RABackgroundModeUnlimitedBackgroundingTime), @(RABackgroundModeForcedForeground), @(RABackgroundModeForceNone), @(RABackgroundModeSuspendImmediately)], - @"shortTitles": @[ @"Native", @"∞", @"Forced", @"Disabled", @"SmartClose" ], - @"default": @(RABackgroundModeNative), - @"detail": @"RABackgroundingListItemsController" - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Auto Launch (On Boot)", - @"key": @"autoLaunch", - @"default": @NO, - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Auto Relaunch", - @"key": @"autoRelaunch", - @"default": @NO, - }, + @{ @"label": @""}, + @{ + @"cell": @"PSLinkListCell", + @"label": @"Background Mode", + @"key": @"backgroundMode", + @"validTitles": @[ @"Native", @"Unlimited Backgrounding Time", @"Force Foreground", @"Kill on Exit", @"Suspend Immediately" ], + @"validValues": @[ @(RABackgroundModeNative), @(RABackgroundModeUnlimitedBackgroundingTime), @(RABackgroundModeForcedForeground), @(RABackgroundModeForceNone), @(RABackgroundModeSuspendImmediately)], + @"shortTitles": @[ @"Native", @"∞", @"Forced", @"Disabled", @"SmartClose" ], + @"default": @(RABackgroundModeNative), + @"detail": @"RABackgroundingListItemsController" + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Auto Launch (On Boot)", + @"key": @"autoLaunch", + @"default": @NO, + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Auto Relaunch", + @"key": @"autoRelaunch", + @"default": @NO, + }, - @{ @"footerText": @"If the app's background mode is Disabled, this will remove the app from the switcher in addition to killing it." }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Remove from Switcher", - @"key": @"removeFromSwitcher", - @"default": @NO, - }, + @{ @"footerText": @"If the app's background mode is Disabled, this will remove the app from the switcher in addition to killing it." }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Remove from Switcher", + @"key": @"removeFromSwitcher", + @"default": @NO, + }, - @{ @"footerText": @"This will prevent most cases of the app being terminated (app switcher, low memory, etc). Please note that if you enable this option, and your system runs low on memory or some other situation, it may yield unpredictable results. Enabling both this and \"Exit on Suspend\" (see below) will cause this switch to have no effect." }, - @{ - @"cell": @"PSSwitchCell", - @"key": @"preventDeath", - @"default": @NO, - @"label": @"Prevent Death", - @"enabled": @(!exitsOnSuspend), - @"reloadSpecifiersXX": @YES, - }, - @{ @"footerText": @"This switch causes applications to completely disable their backgrounding, natively. Apps such as BatteryLife, FinalFantasy2, and a certain Solitaire do this. This switch will not revert upon the uninstallation of Multiplexer because it actually writes to the app's data. A respring may be required to apply." }, - @{ - @"cell": @"PSSwitchCell", - @"key": @"UIApplicationExitsOnSuspend", - @"default": @(exitsOnSuspend), - @"label": @"Exit on Suspend", - @"enabled": @(!preventDeath), - @"reloadSpecifiersXX": @YES, - }, - @{ - @"cell": @"PSGroupCell", - @"label": @"Native Backgrounding Modes", - @"footerText": @"A respring is required to apply changes to these values. Just because a mode has been enabled does not necessarily mean it will be used by the app.", - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Unbounded Task Completion", - @"key": kBKSBackgroundModeUnboundedTaskCompletion, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeUnboundedTaskCompletion withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Continuous", - @"key": kBKSBackgroundModeContinuous, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeContinuous withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Fetch", - @"key": kBKSBackgroundModeFetch, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeFetch withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Remote Notification", - @"key": kBKSBackgroundModeRemoteNotification, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeRemoteNotification withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"External Accessory", - @"key": kBKSBackgroundModeExternalAccessory, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeExternalAccessory withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"VoIP", - @"key": kBKSBackgroundModeVoIP, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeVoIP withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Location", - @"key": kBKSBackgroundModeLocation, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeLocation withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Audio", - @"key": kBKSBackgroundModeAudio, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeAudio withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Bluetooth (Central)", - @"key": kBKSBackgroundModeBluetoothCentral, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeBluetoothCentral withAppInfo:bgModes], - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Bluetooth (Peripheral)", - @"key": kBKSBackgroundModeBluetoothPeripheral, - @"prefix": @"backgroundmodes", - @"default": [self isBackgroundModeActive:kBKSBackgroundModeBluetoothPeripheral withAppInfo:bgModes], - }, + @{ @"footerText": @"This will prevent most cases of the app being terminated (app switcher, low memory, etc). Please note that if you enable this option, and your system runs low on memory or some other situation, it may yield unpredictable results. Enabling both this and \"Exit on Suspend\" (see below) will cause this switch to have no effect." }, + @{ + @"cell": @"PSSwitchCell", + @"key": @"preventDeath", + @"default": @NO, + @"label": @"Prevent Death", + @"enabled": @(!exitsOnSuspend), + @"reloadSpecifiersXX": @YES, + }, + @{ @"footerText": @"This switch causes applications to completely disable their backgrounding, natively. Apps such as BatteryLife, FinalFantasy2, and a certain Solitaire do this. This switch will not revert upon the uninstallation of Multiplexer because it actually writes to the app's data. A respring may be required to apply." }, + @{ + @"cell": @"PSSwitchCell", + @"key": @"UIApplicationExitsOnSuspend", + @"default": @(exitsOnSuspend), + @"label": @"Exit on Suspend", + @"enabled": @(!preventDeath), + @"reloadSpecifiersXX": @YES, + }, + @{ + @"cell": @"PSGroupCell", + @"label": @"Native Backgrounding Modes", + @"footerText": @"A respring is required to apply changes to these values. Just because a mode has been enabled does not necessarily mean it will be used by the app.", + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Unbounded Task Completion", + @"key": kBKSBackgroundModeUnboundedTaskCompletion, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeUnboundedTaskCompletion withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Continuous", + @"key": kBKSBackgroundModeContinuous, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeContinuous withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Fetch", + @"key": kBKSBackgroundModeFetch, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeFetch withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Remote Notification", + @"key": kBKSBackgroundModeRemoteNotification, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeRemoteNotification withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"External Accessory", + @"key": kBKSBackgroundModeExternalAccessory, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeExternalAccessory withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"VoIP", + @"key": kBKSBackgroundModeVoIP, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeVoIP withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Location", + @"key": kBKSBackgroundModeLocation, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeLocation withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Audio", + @"key": kBKSBackgroundModeAudio, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeAudio withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Bluetooth (Central)", + @"key": kBKSBackgroundModeBluetoothCentral, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeBluetoothCentral withAppInfo:bgModes], + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Bluetooth (Peripheral)", + @"key": kBKSBackgroundModeBluetoothPeripheral, + @"prefix": @"backgroundmodes", + @"default": [self isBackgroundModeActive:kBKSBackgroundModeBluetoothPeripheral withAppInfo:bgModes], + }, - @{ @"footerText": @"Description of icon letters: \n\ -N - Native\n\ -∞ - Unlimited Backgrounding Time\n\ -F - Force Foreground\n" -//D - Kill on Exit\n\ -"ll - Suspend Immediately\n\ -U - Unkillable\n\ -\n\ -The status bar icon is simply the app icon.", }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Show Icon Indicators", - @"key": @"showIndicatorOnIcon", - @"default": @YES, - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Show in Status Bar", - @"key": @"showStatusBarIcon", - @"default": @YES, - }, - ]; + @{ @"footerText": @"Description of icon letters: \n\ + N - Native\n\ + ∞ - Unlimited Backgrounding Time\n\ + F - Force Foreground\n" + //D - Kill on Exit\n\ + "ll - Suspend Immediately\n\ + U - Unkillable\n\ + \n\ + The status bar icon is simply the app icon.", }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Show Icon Indicators", + @"key": @"showIndicatorOnIcon", + @"default": @YES, + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Show in Status Bar", + @"key": @"showStatusBarIcon", + @"default": @YES, + }, + ]; } -(void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { - //[super setPreferenceValue:value specifier:specifier]; + //[super setPreferenceValue:value specifier:specifier]; - if ([[specifier propertyForKey:@"key"] isEqualToString:@"UIApplicationExitsOnSuspend"]) - { - LSApplicationProxy *appInfo = [%c(LSApplicationProxy) applicationProxyForIdentifier:_identifier]; - NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; - NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; - infoPlist[@"UIApplicationExitsOnSuspend"] = value; - BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; + if ([[specifier propertyForKey:@"key"] isEqualToString:@"UIApplicationExitsOnSuspend"]) + { + LSApplicationProxy *appInfo = [%c(LSApplicationProxy) applicationProxyForIdentifier:_identifier]; + NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; + NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; + infoPlist[@"UIApplicationExitsOnSuspend"] = value; + BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; - if (!success) - { - NSMutableDictionary *daemonDict = [NSMutableDictionary dictionary]; - daemonDict[@"bundleIdentifier"] = _identifier; - daemonDict[@"UIApplicationExitsOnSuspend"] = value; - [daemonDict writeToFile:@"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp" atomically:YES]; - } + if (!success) + { + NSMutableDictionary *daemonDict = [NSMutableDictionary dictionary]; + daemonDict[@"bundleIdentifier"] = _identifier; + daemonDict[@"UIApplicationExitsOnSuspend"] = value; + [daemonDict writeToFile:@"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp" atomically:YES]; + } - if ([[specifier propertyForKey:@"reloadSpecifiers"] boolValue]) - [self reloadSpecifiers]; + if ([[specifier propertyForKey:@"reloadSpecifiers"] boolValue]) + [self reloadSpecifiers]; - return; - } + return; + } CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); - NSString *key = [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,[specifier propertyForKey:@"key"]]; - if ([specifier propertyForKey:@"prefix"]) - key = [NSString stringWithFormat:@"backgrounder-%@-%@-%@",_identifier,[specifier propertyForKey:@"prefix"],[specifier propertyForKey:@"key"]]; - CFPreferencesSetAppValue((__bridge CFStringRef)key, (const void*)value, appID); + NSString *key = [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,[specifier propertyForKey:@"key"]]; + if ([specifier propertyForKey:@"prefix"]) + key = [NSString stringWithFormat:@"backgrounder-%@-%@-%@",_identifier,[specifier propertyForKey:@"prefix"],[specifier propertyForKey:@"key"]]; + CFPreferencesSetAppValue((__bridge CFStringRef)key, (const void*)value, appID); - CFPreferencesAppSynchronize(appID); - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); - RA_BGAppsControllerNeedsToReload(); + CFPreferencesAppSynchronize(appID); + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); + RA_BGAppsControllerNeedsToReload(); - if ([[specifier propertyForKey:@"reloadSpecifiers"] boolValue]) - [self reloadSpecifiers]; + if ([[specifier propertyForKey:@"reloadSpecifiers"] boolValue]) + [self reloadSpecifiers]; } -(id) getActualPrefValue:(NSString*)basename { - CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); - NSString *key = [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,basename]; + CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); + NSString *key = [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,basename]; - CFPropertyListRef value = CFPreferencesCopyValue((__bridge CFStringRef)key, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFPropertyListRef value = CFPreferencesCopyValue((__bridge CFStringRef)key, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - return (__bridge id)value; + return (__bridge id)value; } -(id)readPreferenceValue:(PSSpecifier*)specifier { - CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); - CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (!keyList) { - return [specifier propertyForKey:@"default"]; - } - NSDictionary *_settings = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - CFRelease(keyList); - if (!_settings) { - return [specifier propertyForKey:@"default"]; - } + CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); + CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (!keyList) { + return [specifier propertyForKey:@"default"]; + } + NSDictionary *_settings = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFRelease(keyList); + if (!_settings) { + return [specifier propertyForKey:@"default"]; + } - NSString *key = [specifier propertyForKey:@"prefix"] ? [NSString stringWithFormat:@"backgrounder-%@-%@-%@",_identifier,[specifier propertyForKey:@"prefix"],[specifier propertyForKey:@"key"]] : [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,[specifier propertyForKey:@"key"]]; - return ![_settings objectForKey:key] ? [specifier propertyForKey:@"default"] : _settings[key]; + NSString *key = [specifier propertyForKey:@"prefix"] ? [NSString stringWithFormat:@"backgrounder-%@-%@-%@",_identifier,[specifier propertyForKey:@"prefix"],[specifier propertyForKey:@"key"]] : [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,[specifier propertyForKey:@"key"]]; + return ![_settings objectForKey:key] ? [specifier propertyForKey:@"default"] : _settings[key]; } @end diff --git a/reachappsettings/BackgrounderPerApp.xm b/reachappsettings/BackgrounderPerApp.xm index 6a8dec6..41dd868 100644 --- a/reachappsettings/BackgrounderPerApp.xm +++ b/reachappsettings/BackgrounderPerApp.xm @@ -39,7 +39,7 @@ BOOL reload = NO; void RA_BGAppsControllerNeedsToReload() { - reload = YES; + reload = YES; } @interface RABGPerAppController : PSViewController @@ -57,77 +57,77 @@ void RA_BGAppsControllerNeedsToReload() NSString *enabledList = @""; - CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); - CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (keyList) - { - NSDictionary *prefs = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - CFRelease(keyList); - if (prefs) - { - NSArray *apps = [[ALApplicationList sharedApplicationList] applications].allKeys; - for (NSString* identifier in apps) - { - if ([prefs[[NSString stringWithFormat:@"backgrounder-%@-enabled",identifier]] boolValue]) - { - enabledList = [enabledList stringByAppendingString:[NSString stringWithFormat:@"'%@',", identifier]]; - } - } - } - } - enabledList = [enabledList stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]; + CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); + CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (keyList) + { + NSDictionary *prefs = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFRelease(keyList); + if (prefs) + { + NSArray *apps = [[ALApplicationList sharedApplicationList] applications].allKeys; + for (NSString* identifier in apps) + { + if ([prefs[[NSString stringWithFormat:@"backgrounder-%@-enabled",identifier]] boolValue]) + { + enabledList = [enabledList stringByAppendingString:[NSString stringWithFormat:@"'%@',", identifier]]; + } + } + } + } + enabledList = [enabledList stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]; NSString* filter = (searchText && searchText.length > 0) ? [NSString stringWithFormat:@"displayName beginsWith[cd] '%@'", searchText] : nil; if (filter) { _dataSource.sectionDescriptors = [NSArray arrayWithObjects: - [NSDictionary dictionaryWithObjectsAndKeys: - @"Search Results", ALSectionDescriptorTitleKey, - @"ALLinkCell", ALSectionDescriptorCellClassNameKey, - iconSize, ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - filter, ALSectionDescriptorPredicateKey - , nil] - , nil]; + [NSDictionary dictionaryWithObjectsAndKeys: + @"Search Results", ALSectionDescriptorTitleKey, + @"ALLinkCell", ALSectionDescriptorCellClassNameKey, + iconSize, ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + filter, ALSectionDescriptorPredicateKey + , nil] + , nil]; } else { - if ([enabledList isEqual:@""]) - { - _dataSource.sectionDescriptors = [NSArray arrayWithObjects: - [NSDictionary dictionaryWithObjectsAndKeys: - @"", ALSectionDescriptorTitleKey, - @"ALLinkCell", ALSectionDescriptorCellClassNameKey, - iconSize, ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - [NSString stringWithFormat:@"not bundleIdentifier in {%@}", enabledList], - ALSectionDescriptorPredicateKey - , nil], - nil]; - } - else - { - _dataSource.sectionDescriptors = [NSArray arrayWithObjects: - [NSDictionary dictionaryWithObjectsAndKeys: - @"Enabled Applications", ALSectionDescriptorTitleKey, - @"ALLinkCell", ALSectionDescriptorCellClassNameKey, - iconSize, ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - [NSString stringWithFormat:@"bundleIdentifier in {%@}", enabledList], - ALSectionDescriptorPredicateKey - , nil], - [NSDictionary dictionaryWithObjectsAndKeys: - @"Other Applications", ALSectionDescriptorTitleKey, - @"ALLinkCell", ALSectionDescriptorCellClassNameKey, - iconSize, ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - [NSString stringWithFormat:@"not bundleIdentifier in {%@}", enabledList], - ALSectionDescriptorPredicateKey - , nil], - nil]; - } + if ([enabledList isEqual:@""]) + { + _dataSource.sectionDescriptors = [NSArray arrayWithObjects: + [NSDictionary dictionaryWithObjectsAndKeys: + @"", ALSectionDescriptorTitleKey, + @"ALLinkCell", ALSectionDescriptorCellClassNameKey, + iconSize, ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + [NSString stringWithFormat:@"not bundleIdentifier in {%@}", enabledList], + ALSectionDescriptorPredicateKey + , nil], + nil]; + } + else + { + _dataSource.sectionDescriptors = [NSArray arrayWithObjects: + [NSDictionary dictionaryWithObjectsAndKeys: + @"Enabled Applications", ALSectionDescriptorTitleKey, + @"ALLinkCell", ALSectionDescriptorCellClassNameKey, + iconSize, ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + [NSString stringWithFormat:@"bundleIdentifier in {%@}", enabledList], + ALSectionDescriptorPredicateKey + , nil], + [NSDictionary dictionaryWithObjectsAndKeys: + @"Other Applications", ALSectionDescriptorTitleKey, + @"ALLinkCell", ALSectionDescriptorCellClassNameKey, + iconSize, ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + [NSString stringWithFormat:@"not bundleIdentifier in {%@}", enabledList], + ALSectionDescriptorPredicateKey + , nil], + nil]; + } } - [_tableView reloadData]; + [_tableView reloadData]; } -(instancetype)init @@ -159,16 +159,16 @@ void RA_BGAppsControllerNeedsToReload() -(void) viewWillAppear:(BOOL) animated { - if (reload) - { - [self updateDataSource:nil]; - reload = NO; - } + if (reload) + { + [self updateDataSource:nil]; + reload = NO; + } - ((UIView*)self.view).tintColor = self.tintColor; - self.navigationController.navigationBar.tintColor = self.tintColor; + ((UIView*)self.view).tintColor = self.tintColor; + self.navigationController.navigationBar.tintColor = self.tintColor; - [super viewWillAppear:animated]; + [super viewWillAppear:animated]; } @@ -189,10 +189,10 @@ void RA_BGAppsControllerNeedsToReload() -(UIColor*) tintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } - (void)viewWillDisappear:(BOOL)animated { - [super viewWillDisappear:animated]; + [super viewWillDisappear:animated]; - ((UIView*)self.view).tintColor = nil; - self.navigationController.navigationBar.tintColor = nil; + ((UIView*)self.view).tintColor = nil; + self.navigationController.navigationBar.tintColor = nil; } @end diff --git a/reachappsettings/BackgrounderSettings.xm b/reachappsettings/BackgrounderSettings.xm index 733a192..7311602 100644 --- a/reachappsettings/BackgrounderSettings.xm +++ b/reachappsettings/BackgrounderSettings.xm @@ -38,18 +38,18 @@ @implementation ReachAppBackgrounderSettingsListController -(UIView*) headerView { - RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ - (id) [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:255/255.0f green:111/255.0f blue:124/255.0f alpha:1.0f].CGColor - ]; - header.shouldBlend = NO; - header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/BackgrounderHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(15, 33)]]; - - UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; - [notHeader addSubview:header]; - - return notHeader; + RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; + header.colors = @[ + (id) [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:255/255.0f green:111/255.0f blue:124/255.0f alpha:1.0f].CGColor + ]; + header.shouldBlend = NO; + header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/BackgrounderHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(15, 33)]]; + + UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; + [notHeader addSubview:header]; + + return notHeader; } -(UIColor*) tintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } @@ -66,84 +66,84 @@ -(NSArray*) customSpecifiers { - return @[ - @{ @"footerText": @"Quickly enable or disable Aura. Relaunch apps to apply changes." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"backgrounderEnabled", - @"label": @"Enabled", - }, - - @{ @"label": @"Activator", - @"footerText": @"If enabled, the current app will be closed after performing the activation method.", - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"showActivatorAction", - @"label": @"Activation Method", - //@"enabled": objc_getClass("LAEventSettingsController") != nil, - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Exit App After Menu", - @"default": @YES, - @"key": @"exitAppAfterUsingActivatorAction", - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"label": @"Global", @"footerText": @"" }, - - @{ - @"cell": @"PSLinkListCell", - @"label": @"Background Mode", - @"key": @"globalBackgroundMode", - @"validTitles": @[ @"Native", @"Unlimited Backgrounding Time", @"Force Foreground", @"Kill on Exit", @"Suspend Immediately" ], - @"validValues": @[ @(RABackgroundModeNative), @(RABackgroundModeUnlimitedBackgroundingTime), @(RABackgroundModeForcedForeground), @(RABackgroundModeForceNone), @(RABackgroundModeSuspendImmediately)], - @"shortTitles": @[ @"Native", @"∞", @"Forced", @"Disabled", @"SmartClose" ], - @"default": @(RABackgroundModeNative), - @"detail": @"RABackgroundingListItemsController", - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - @"staticTextMessage": @"Does not apply to apps enabled with differing options in the “Per App” section." - }, - @{ - @"cell": @"PSLinkListCell", - @"detail": @"RABackgrounderIconIndicatorOptionsListController", - @"label": @"Icon Indicator Options", - }, - @{ - @"cell": @"PSLinkListCell", - @"detail": @"RABackgrounderStatusbarOptionsListController", - @"label": @"Status Bar Indicator Options", - }, - @{ @"label": @"Specific" }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Per App", - @"detail": @"RABGPerAppController", - }, - ]; + return @[ + @{ @"footerText": @"Quickly enable or disable Aura. Relaunch apps to apply changes." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"backgrounderEnabled", + @"label": @"Enabled", + }, + + @{ @"label": @"Activator", + @"footerText": @"If enabled, the current app will be closed after performing the activation method.", + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"showActivatorAction", + @"label": @"Activation Method", + //@"enabled": objc_getClass("LAEventSettingsController") != nil, + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Exit App After Menu", + @"default": @YES, + @"key": @"exitAppAfterUsingActivatorAction", + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"label": @"Global", @"footerText": @"" }, + + @{ + @"cell": @"PSLinkListCell", + @"label": @"Background Mode", + @"key": @"globalBackgroundMode", + @"validTitles": @[ @"Native", @"Unlimited Backgrounding Time", @"Force Foreground", @"Kill on Exit", @"Suspend Immediately" ], + @"validValues": @[ @(RABackgroundModeNative), @(RABackgroundModeUnlimitedBackgroundingTime), @(RABackgroundModeForcedForeground), @(RABackgroundModeForceNone), @(RABackgroundModeSuspendImmediately)], + @"shortTitles": @[ @"Native", @"∞", @"Forced", @"Disabled", @"SmartClose" ], + @"default": @(RABackgroundModeNative), + @"detail": @"RABackgroundingListItemsController", + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + @"staticTextMessage": @"Does not apply to apps enabled with differing options in the “Per App” section." + }, + @{ + @"cell": @"PSLinkListCell", + @"detail": @"RABackgrounderIconIndicatorOptionsListController", + @"label": @"Icon Indicator Options", + }, + @{ + @"cell": @"PSLinkListCell", + @"detail": @"RABackgrounderStatusbarOptionsListController", + @"label": @"Status Bar Indicator Options", + }, + @{ @"label": @"Specific" }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Per App", + @"detail": @"RABGPerAppController", + }, + ]; } -(void) showActivatorAction { - id activator = %c(LAListenerSettingsViewController); - if (!activator) - { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; - [alert addAction:cancelAction]; - [self presentViewController:alert animated:YES completion:nil]; - } - else - { - LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; - vc.listenerName = @"com.efrederickson.reachapp.backgrounder.togglemode"; - [self.rootController pushController:vc animate:YES]; - } + id activator = %c(LAListenerSettingsViewController); + if (!activator) + { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; + } + else + { + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; + vc.listenerName = @"com.efrederickson.reachapp.backgrounder.togglemode"; + [self.rootController pushController:vc animate:YES]; + } } @end @@ -155,24 +155,24 @@ -(BOOL) showHeartImage { return NO; } -(NSArray*) customSpecifiers { - return @[ - @{ - @"cell": @"PSSwitchCell", - @"label": @"Show Icon Indicators", - @"default": @YES, - @"key": @"showIconIndicators", - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Show Native Mode Indicators", - @"default": @NO, - @"key": @"showNativeStateIconIndicators", - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - ]; + return @[ + @{ + @"cell": @"PSSwitchCell", + @"label": @"Show Icon Indicators", + @"default": @YES, + @"key": @"showIconIndicators", + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Show Native Mode Indicators", + @"default": @NO, + @"key": @"showNativeStateIconIndicators", + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + ]; } @end @@ -184,23 +184,23 @@ -(BOOL) showHeartImage { return NO; } -(NSArray*) customSpecifiers { - return @[ - @{ - @"cell": @"PSSwitchCell", - @"label": @"Show on Status Bar", - @"default": @YES, - @"key": @"shouldShowStatusBarIcons", - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ - @"cell": @"PSSwitchCell", - @"label": @"Show Native in Status Bar", - @"default": @NO, - @"key": @"shouldShowStatusBarNativeIcons", - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - ]; + return @[ + @{ + @"cell": @"PSSwitchCell", + @"label": @"Show on Status Bar", + @"default": @YES, + @"key": @"shouldShowStatusBarIcons", + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ + @"cell": @"PSSwitchCell", + @"label": @"Show Native in Status Bar", + @"default": @NO, + @"key": @"shouldShowStatusBarNativeIcons", + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + ]; } @end diff --git a/reachappsettings/MissionControlSettings.xm b/reachappsettings/MissionControlSettings.xm index b311aa8..7ec2fcd 100644 --- a/reachappsettings/MissionControlSettings.xm +++ b/reachappsettings/MissionControlSettings.xm @@ -36,18 +36,18 @@ @implementation ReachAppMCSettingsListController -(UIView*) headerView { - RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ - (id) [UIColor colorWithRed:255/255.0f green:205/255.0f blue:2/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:255/255.0f green:227/255.0f blue:113/255.0f alpha:1.0f].CGColor, - ]; - header.shouldBlend = NO; - header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/MissionControlHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(32, 32)]]; + RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; + header.colors = @[ + (id) [UIColor colorWithRed:255/255.0f green:205/255.0f blue:2/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:255/255.0f green:227/255.0f blue:113/255.0f alpha:1.0f].CGColor, + ]; + header.shouldBlend = NO; + header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/MissionControlHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(32, 32)]]; - UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; - [notHeader addSubview:header]; + UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; + [notHeader addSubview:header]; - return notHeader; + return notHeader; } -(UIColor*) tintColor { return [UIColor colorWithRed:255/255.0f green:205/255.0f blue:2/255.0f alpha:1.0f]; } -(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } @@ -56,8 +56,8 @@ -(void) viewDidAppear:(BOOL)arg1 { - [super viewDidAppear:arg1]; - [super performSelector:@selector(setupHeader)]; + [super viewDidAppear:arg1]; + [super performSelector:@selector(setupHeader)]; } -(NSArray*) customSpecifiers @@ -73,7 +73,7 @@ @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", }, - @{ @"footerText": @"If enabled the App Switcher will be replaced with the Mission Control view."}, + @{ @"footerText": @"If enabled the App Switcher will be replaced with the Mission Control view."}, @{ @"cell": @"PSSwitchCell", @"default": @NO, @@ -122,19 +122,19 @@ } -(void) showActivatorAction { - id activator = %c(LAListenerSettingsViewController); - if (!activator) - { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; - [alert addAction:cancelAction]; - [self presentViewController:alert animated:YES completion:nil]; - } - else - { - LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; - vc.listenerName = @"com.efrederickson.reachapp.missioncontrol.activatorlistener"; - [self.rootController pushController:vc animate:YES]; - } + id activator = %c(LAListenerSettingsViewController); + if (!activator) + { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; + } + else + { + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; + vc.listenerName = @"com.efrederickson.reachapp.missioncontrol.activatorlistener"; + [self.rootController pushController:vc animate:YES]; + } } @end diff --git a/reachappsettings/NCApp.xm b/reachappsettings/NCApp.xm index 93d35de..1ec8b03 100644 --- a/reachappsettings/NCApp.xm +++ b/reachappsettings/NCApp.xm @@ -35,18 +35,18 @@ @implementation ReachAppNCAppSettingsListController -(UIView*) headerView { - RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)]; - header.colors = @[ - (id) [UIColor colorWithRed:90/255.0f green:212/255.0f blue:39/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:164/255.0f green:231/255.0f blue:134/255.0f alpha:1.0f].CGColor, - ]; - header.shouldBlend = NO; - header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/NCAppHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(53, 32)]]; - - UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 70)]; - [notHeader addSubview:header]; - - return notHeader; + RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)]; + header.colors = @[ + (id) [UIColor colorWithRed:90/255.0f green:212/255.0f blue:39/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:164/255.0f green:231/255.0f blue:134/255.0f alpha:1.0f].CGColor, + ]; + header.shouldBlend = NO; + header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/NCAppHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(53, 32)]]; + + UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 70)]; + [notHeader addSubview:header]; + + return notHeader; } -(UIColor*) tintColor { return [UIColor colorWithRed:90/255.0f green:212/255.0f blue:39/255.0f alpha:1.0f]; } -(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } @@ -56,55 +56,55 @@ -(void) viewDidAppear:(BOOL)arg1 { - [super viewDidAppear:arg1]; - [super performSelector:@selector(setupHeader)]; + [super viewDidAppear:arg1]; + [super performSelector:@selector(setupHeader)]; } -(NSArray*) customSpecifiers { - return @[ - @{ @"footerText": @"Quickly enable or disable Quick Access." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"ncAppEnabled", - @"label": @"Enabled", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ @"footerText": @"Instead of using the app's name, the tab label will simply show \"App\". Only Works on iOS 9 and below" }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"quickAccessUseGenericTabLabel", - @"label": @"Use Generic Tab Label", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ @"footerText": @"Instead of displaying a label, this will completely hide the Quick Access tab on the Lock Screen." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"ncAppHideOnLS", - @"label": @"Hide on Lock Screen", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ }, - @{ - @"cell": @"PSLinkListCell", - @"detail": @"RANCAppSelectorView", - @"label": @"Selected App", - }, - ]; + return @[ + @{ @"footerText": @"Quickly enable or disable Quick Access." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"ncAppEnabled", + @"label": @"Enabled", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ @"footerText": @"Instead of using the app's name, the tab label will simply show \"App\". Only Works on iOS 9 and below" }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"quickAccessUseGenericTabLabel", + @"label": @"Use Generic Tab Label", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ @"footerText": @"Instead of displaying a label, this will completely hide the Quick Access tab on the Lock Screen." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"ncAppHideOnLS", + @"label": @"Hide on Lock Screen", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ }, + @{ + @"cell": @"PSLinkListCell", + @"detail": @"RANCAppSelectorView", + @"label": @"Selected App", + }, + ]; } @end @interface RANCAppSelectorView : PSViewController { - UITableView* _tableView; - ALApplicationTableDataSource* _dataSource; + UITableView* _tableView; + ALApplicationTableDataSource* _dataSource; } @end @@ -119,31 +119,31 @@ @implementation RANCApplicationTableDataSource - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - //NSInteger row = indexPath.row; - UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; - - NSDictionary *prefs = nil; - - CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); - CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (!keyList) { - return cell; - } - prefs = (__bridge NSDictionary*)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (!prefs) { - return cell; - } - CFRelease(keyList); - - if ([cell isKindOfClass:[ALCheckCell class]]) - { - NSString *dn = [self displayIdentifierForIndexPath:indexPath]; - NSString *key = @"NCApp";// [NSString stringWithFormat:@"NCApp-%@",dn]; - //BOOL value = [prefs[key] boolValue]; - BOOL value = [dn isEqualToString:prefs[key] ?: @"com.apple.Preferences"]; - [(ALCheckCell*)cell loadValue:@(value)]; - } + //NSInteger row = indexPath.row; + UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; + + NSDictionary *prefs = nil; + + CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); + CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (!keyList) { + return cell; + } + prefs = (__bridge NSDictionary*)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (!prefs) { return cell; + } + CFRelease(keyList); + + if ([cell isKindOfClass:[ALCheckCell class]]) + { + NSString *dn = [self displayIdentifierForIndexPath:indexPath]; + NSString *key = @"NCApp";// [NSString stringWithFormat:@"NCApp-%@",dn]; + //BOOL value = [prefs[key] boolValue]; + BOOL value = [dn isEqualToString:prefs[key] ?: @"com.apple.Preferences"]; + [(ALCheckCell*)cell loadValue:@(value)]; + } + return cell; } @end @@ -151,71 +151,71 @@ -(void)updateDataSource:(NSString*)searchText { - _dataSource.sectionDescriptors = [NSArray arrayWithObjects: - [NSDictionary dictionaryWithObjectsAndKeys: - @"", ALSectionDescriptorTitleKey, - @"ALCheckCell", ALSectionDescriptorCellClassNameKey, - @(29), ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - [NSString stringWithFormat:@"not bundleIdentifier in { }"],ALSectionDescriptorPredicateKey, - @YES,@"ALSingleEnabledMode" - , nil], - nil]; - [_tableView reloadData]; + _dataSource.sectionDescriptors = [NSArray arrayWithObjects: + [NSDictionary dictionaryWithObjectsAndKeys: + @"", ALSectionDescriptorTitleKey, + @"ALCheckCell", ALSectionDescriptorCellClassNameKey, + @(29), ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + [NSString stringWithFormat:@"not bundleIdentifier in { }"],ALSectionDescriptorPredicateKey, + @YES,@"ALSingleEnabledMode" + , nil], + nil]; + [_tableView reloadData]; } -(instancetype)init { - if (!(self = [super init])) return nil; + if (!(self = [super init])) return nil; - CGRect bounds = [[UIScreen mainScreen] bounds]; + CGRect bounds = [[UIScreen mainScreen] bounds]; - _dataSource = [[RANCApplicationTableDataSource alloc] init]; + _dataSource = [[RANCApplicationTableDataSource alloc] init]; - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; - _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - _tableView.delegate = self; - _tableView.dataSource = _dataSource; - _dataSource.tableView = _tableView; - [self updateDataSource:nil]; + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; + _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _tableView.delegate = self; + _tableView.dataSource = _dataSource; + _dataSource.tableView = _tableView; + [self updateDataSource:nil]; - return self; + return self; } -(void)viewDidLoad { - ((UIViewController *)self).title = @"Applications"; - [self.view addSubview:_tableView]; - [super viewDidLoad]; + ((UIViewController *)self).title = @"Applications"; + [self.view addSubview:_tableView]; + [super viewDidLoad]; } -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { - [tableView deselectRowAtIndexPath:indexPath animated:true]; - ALCheckCell* cell = (ALCheckCell*)[tableView cellForRowAtIndexPath:indexPath]; - [cell didSelect]; - - UITableViewCellAccessoryType type = [cell accessoryType]; - BOOL selected = type == UITableViewCellAccessoryCheckmark; - - NSString *identifier = [_dataSource displayIdentifierForIndexPath:indexPath]; - if (selected) - CFPreferencesSetAppValue((__bridge CFStringRef)@"NCApp", (CFPropertyListRef)(identifier), CFSTR("com.efrederickson.reachapp.settings")); - - [self updateDataSource:nil]; - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.7 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); - }); - - UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Quick Access" message:@"A respring is required to apply changes. Would you like to respring now?" preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *respringAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); - }]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:nil]; - - [alert addAction:respringAction]; - [alert addAction:cancelAction]; - [self presentViewController:alert animated:YES completion:nil]; + [tableView deselectRowAtIndexPath:indexPath animated:true]; + ALCheckCell* cell = (ALCheckCell*)[tableView cellForRowAtIndexPath:indexPath]; + [cell didSelect]; + + UITableViewCellAccessoryType type = [cell accessoryType]; + BOOL selected = type == UITableViewCellAccessoryCheckmark; + + NSString *identifier = [_dataSource displayIdentifierForIndexPath:indexPath]; + if (selected) + CFPreferencesSetAppValue((__bridge CFStringRef)@"NCApp", (CFPropertyListRef)(identifier), CFSTR("com.efrederickson.reachapp.settings")); + + [self updateDataSource:nil]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.7 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); + }); + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Quick Access" message:@"A respring is required to apply changes. Would you like to respring now?" preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *respringAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); + }]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:nil]; + + [alert addAction:respringAction]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } @end diff --git a/reachappsettings/RAHeaderView.mm b/reachappsettings/RAHeaderView.mm index 0427582..fda2403 100644 --- a/reachappsettings/RAHeaderView.mm +++ b/reachappsettings/RAHeaderView.mm @@ -3,80 +3,80 @@ @implementation UIImage (ext) - (UIImage *)tintedImageWithColor:(UIColor *)tintColor blendingMode:(CGBlendMode)blendMode { - UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); - [tintColor setFill]; - CGRect bounds = CGRectMake(0, 0, self.size.width, self.size.height); - UIRectFill(bounds); - [self drawInRect:bounds blendMode:blendMode alpha:1.0f]; + UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); + [tintColor setFill]; + CGRect bounds = CGRectMake(0, 0, self.size.width, self.size.height); + UIRectFill(bounds); + [self drawInRect:bounds blendMode:blendMode alpha:1.0f]; - if (blendMode != kCGBlendModeDestinationIn) - [self drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0]; + if (blendMode != kCGBlendModeDestinationIn) + [self drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0]; - UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); + UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); - return tintedImage; + return tintedImage; } @end @implementation RAHeaderView + (Class)layerClass { - return [CAGradientLayer class]; + return [CAGradientLayer class]; } -(instancetype) initWithFrame:(CGRect)frame { - if (self = [super initWithFrame:frame]) - { - CAGradientLayer *gradient = (CAGradientLayer*)self.layer; - gradient.colors = @[ (id)[UIColor colorWithRed:255/255.0f green:124/255.0f blue:111/255.0f alpha:1.0f].CGColor, (id)[UIColor colorWithRed:231/255.0f green:76/255.0f blue:60/255.0f alpha:1.0f].CGColor ]; - gradient.locations = @[ @0, @1 ]; - gradient.bounds = CGRectMake(0, 0, frame.size.width, frame.size.height); + if (self = [super initWithFrame:frame]) + { + CAGradientLayer *gradient = (CAGradientLayer*)self.layer; + gradient.colors = @[ (id)[UIColor colorWithRed:255/255.0f green:124/255.0f blue:111/255.0f alpha:1.0f].CGColor, (id)[UIColor colorWithRed:231/255.0f green:76/255.0f blue:60/255.0f alpha:1.0f].CGColor ]; + gradient.locations = @[ @0, @1 ]; + gradient.bounds = CGRectMake(0, 0, frame.size.width, frame.size.height); - label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 200, frame.size.height - 20)]; - label.textColor = [UIColor whiteColor]; - label.font = [UIFont systemFontOfSize:36]; - label.adjustsFontSizeToFitWidth = YES; - label.clipsToBounds = NO; - [self addSubview:label]; + label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 200, frame.size.height - 20)]; + label.textColor = [UIColor whiteColor]; + label.font = [UIFont systemFontOfSize:36]; + label.adjustsFontSizeToFitWidth = YES; + label.clipsToBounds = NO; + [self addSubview:label]; - imageView = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width - 210, 0, 200, 75)]; - [self addSubview:imageView]; + imageView = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width - 210, 0, 200, 75)]; + [self addSubview:imageView]; - self.blendMode = kCGBlendModeOverlay; - self.shouldBlend = YES; - } - return self; + self.blendMode = kCGBlendModeOverlay; + self.shouldBlend = YES; + } + return self; } -(void) setFrame:(CGRect)frame { - [super setFrame:frame]; - ((CAGradientLayer*)self.layer).frame = CGRectMake(0, 0, frame.size.width, frame.size.height); + [super setFrame:frame]; + ((CAGradientLayer*)self.layer).frame = CGRectMake(0, 0, frame.size.width, frame.size.height); } -(void) setColors:(NSArray*)c { - ((CAGradientLayer*)self.layer).colors = c; + ((CAGradientLayer*)self.layer).colors = c; } -(void) setTitle:(NSString*)title { - label.text = title; + label.text = title; } -(void) setImage:(UIImage*)image { - if (label.text.length > 0) - imageView.frame = (CGRect) { { self.frame.size.width - image.size.width - 20, (self.frame.size.height - image.size.height) / 2.0 }, image.size }; - else - imageView.frame = (CGRect) { { (self.frame.size.width - image.size.width) / 2.0, (self.frame.size.height - image.size.height) / 2.0 }, image.size }; - if (self.shouldBlend) - { - UIColor *color = [UIColor colorWithCGColor:(CGColorRef)((CAGradientLayer*)self.layer).colors[0]]; - image = [image tintedImageWithColor:color blendingMode:self.blendMode]; - } - imageView.image = image; + if (label.text.length > 0) + imageView.frame = (CGRect) { { self.frame.size.width - image.size.width - 20, (self.frame.size.height - image.size.height) / 2.0 }, image.size }; + else + imageView.frame = (CGRect) { { (self.frame.size.width - image.size.width) / 2.0, (self.frame.size.height - image.size.height) / 2.0 }, image.size }; + if (self.shouldBlend) + { + UIColor *color = [UIColor colorWithCGColor:(CGColorRef)((CAGradientLayer*)self.layer).colors[0]]; + image = [image tintedImageWithColor:color blendingMode:self.blendMode]; + } + imageView.image = image; } @end diff --git a/reachappsettings/RAListItemsController.xm b/reachappsettings/RAListItemsController.xm index 43d9368..bb3d5ca 100644 --- a/reachappsettings/RAListItemsController.xm +++ b/reachappsettings/RAListItemsController.xm @@ -19,53 +19,53 @@ - (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; + [super viewWillAppear:animated]; - self.navigationController.navigationBar.tintColor = self.navigationTintColor; - [[UIApplication sharedApplication] keyWindow].tintColor = self.navigationTintColor; + self.navigationController.navigationBar.tintColor = self.navigationTintColor; + [[UIApplication sharedApplication] keyWindow].tintColor = self.navigationTintColor; } - (void)viewWillDisappear:(BOOL)animated { - [super viewWillDisappear:animated]; + [super viewWillDisappear:animated]; - [[UIApplication sharedApplication] keyWindow].tintColor = nil; - self.navigationController.navigationBar.tintColor = nil; + [[UIApplication sharedApplication] keyWindow].tintColor = nil; + self.navigationController.navigationBar.tintColor = nil; } -(NSArray*) specifiers { - if (!_specifiers) { - PSSpecifier* themeSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Documentation" - target:self - set:NULL - get:NULL - detail:Nil - cell:PSButtonCell - edit:Nil]; - [themeSpecifier setProperty:SK_RSIMG(@"tutorial.png") forKey:@"iconImage"]; - [themeSpecifier setProperty:@"poop" forKey:@"isTheming"]; - _specifiers = [super specifiers]; - [(NSMutableArray*)_specifiers addObject:[PSSpecifier emptyGroupSpecifier]]; - [(NSMutableArray*)_specifiers addObject:themeSpecifier]; - } - return _specifiers; + if (!_specifiers) { + PSSpecifier* themeSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Documentation" + target:self + set:NULL + get:NULL + detail:Nil + cell:PSButtonCell + edit:Nil]; + [themeSpecifier setProperty:SK_RSIMG(@"tutorial.png") forKey:@"iconImage"]; + [themeSpecifier setProperty:@"poop" forKey:@"isTheming"]; + _specifiers = [super specifiers]; + [(NSMutableArray*)_specifiers addObject:[PSSpecifier emptyGroupSpecifier]]; + [(NSMutableArray*)_specifiers addObject:themeSpecifier]; + } + return _specifiers; } -(void) openThemingDocumentation { - [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com/multiplexer/ThemingDocumentation.html"]]; + [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com/multiplexer/ThemingDocumentation.html"]]; } -(void) tableView:(id)arg1 didSelectRowAtIndexPath:(id)arg2 { - [super tableView:arg1 didSelectRowAtIndexPath:arg2]; + [super tableView:arg1 didSelectRowAtIndexPath:arg2]; - PSTableCell *cell = [self tableView:arg1 cellForRowAtIndexPath:arg2]; - if ([cell.specifier propertyForKey:@"isTheming"]) - { - [self openThemingDocumentation]; - } + PSTableCell *cell = [self tableView:arg1 cellForRowAtIndexPath:arg2]; + if ([cell.specifier propertyForKey:@"isTheming"]) + { + [self openThemingDocumentation]; + } } @end @@ -79,17 +79,17 @@ - (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; + [super viewWillAppear:animated]; - self.navigationController.navigationBar.tintColor = self.navigationTintColor; - [[UIApplication sharedApplication] keyWindow].tintColor = self.navigationTintColor; + self.navigationController.navigationBar.tintColor = self.navigationTintColor; + [[UIApplication sharedApplication] keyWindow].tintColor = self.navigationTintColor; } - (void)viewWillDisappear:(BOOL)animated { - [super viewWillDisappear:animated]; + [super viewWillDisappear:animated]; - [[UIApplication sharedApplication] keyWindow].tintColor = nil; - self.navigationController.navigationBar.tintColor = nil; + [[UIApplication sharedApplication] keyWindow].tintColor = nil; + self.navigationController.navigationBar.tintColor = nil; } @end diff --git a/reachappsettings/RASupportController.xm b/reachappsettings/RASupportController.xm index d58b95e..44d64e3 100644 --- a/reachappsettings/RASupportController.xm +++ b/reachappsettings/RASupportController.xm @@ -20,118 +20,118 @@ -(NSString*) customTitle { return @"Creators"; } - (id)customSpecifiers { - return @[ - @{ @"cell": @"PSGroupCell", @"label": @"Developed and Designed by" }, - @{ - @"cell": @"PSLinkCell", - //@"cellClass": @"RAElijahPersonCell", - @"height": @45, - @"action": @"openElijahTwitter", - @"label": @"Elijah Frederickson", - @"icon": @"elijah" - }, - @{ - @"cell": @"PSLinkCell", - //@"cellClass": @"RAAndrewPersonCell", - @"height": @45, - @"action": @"openAndrewTwitter", - @"label": @"Andrew Abosh", - @"icon": @"andrew" - }, - @{ - @"cell": @"PSLinkCell", - @"height": @45, - @"action": @"openShadeTwitter", - @"label": @"Shade Zepheri", - @"icon": @"shade" - }, + return @[ + @{ @"cell": @"PSGroupCell", @"label": @"Developed and Designed by" }, + @{ + @"cell": @"PSLinkCell", + //@"cellClass": @"RAElijahPersonCell", + @"height": @45, + @"action": @"openElijahTwitter", + @"label": @"Elijah Frederickson", + @"icon": @"elijah" + }, + @{ + @"cell": @"PSLinkCell", + //@"cellClass": @"RAAndrewPersonCell", + @"height": @45, + @"action": @"openAndrewTwitter", + @"label": @"Andrew Abosh", + @"icon": @"andrew" + }, + @{ + @"cell": @"PSLinkCell", + @"height": @45, + @"action": @"openShadeTwitter", + @"label": @"Shade Zepheri", + @"icon": @"shade" + }, - @{ @"label": @"Beta tested by" }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openAndiTwitter", - @"label": @"Andi Andreas", - @"icon": @"Andi" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openBetaPage", - @"label": @"Beta382", - @"icon": @"beta382" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openBindersPAge", - @"label": @"BindersFullOfWomen", - @"icon": @"Binders" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openDavidTwitter", - @"label": @"David", - @"icon": @"David" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openJackTwitter", - @"label": @"Jack Haal", - @"icon": @"Jack" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openMosheTwitter", - @"label": @"Moshe Dancykier", - @"icon": @"Moshe" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openWilsonTwitter", - @"label": @"Wilson (TM3Dev)", - @"icon": @"Wilson" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openZiph0nTwitter", - @"label": @"Ziph0n", - @"icon": @"Ziphon" - }, + @{ @"label": @"Beta tested by" }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openAndiTwitter", + @"label": @"Andi Andreas", + @"icon": @"Andi" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openBetaPage", + @"label": @"Beta382", + @"icon": @"beta382" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openBindersPAge", + @"label": @"BindersFullOfWomen", + @"icon": @"Binders" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openDavidTwitter", + @"label": @"David", + @"icon": @"David" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openJackTwitter", + @"label": @"Jack Haal", + @"icon": @"Jack" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openMosheTwitter", + @"label": @"Moshe Dancykier", + @"icon": @"Moshe" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openWilsonTwitter", + @"label": @"Wilson (TM3Dev)", + @"icon": @"Wilson" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openZiph0nTwitter", + @"label": @"Ziph0n", + @"icon": @"Ziphon" + }, - @{ @"label": @"Special Thanks To" }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openChonTwitter", - @"label": @"Chon Lee", - @"icon": @"Chon" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openEthanTwitter", - @"label": @"Ethan Arbuckle", - @"icon": @"EthanArbuckle" - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"openSharedRoutineTwitter", - @"label": @"sharedRoutine", - @"icon": @"SharedRoutine" - }, + @{ @"label": @"Special Thanks To" }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openChonTwitter", + @"label": @"Chon Lee", + @"icon": @"Chon" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openEthanTwitter", + @"label": @"Ethan Arbuckle", + @"icon": @"EthanArbuckle" + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"openSharedRoutineTwitter", + @"label": @"sharedRoutine", + @"icon": @"SharedRoutine" + }, - @{ @"cell": @"PSGroupCell" }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Site", - @"action": @"openSite", - @"icon": @"ra_makers.png" - }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Source Code", - @"action": @"openGithub", - @"icon": @"github.png" - }, + @{ @"cell": @"PSGroupCell" }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Site", + @"action": @"openSite", + @"icon": @"ra_makers.png" + }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Source Code", + @"action": @"openGithub", + @"icon": @"github.png" + }, - @{ @"cell": @"PSGroupCell", - @"footerText": @"Acknowledgments: \n\ + @{ @"cell": @"PSGroupCell", + @"footerText": @"Acknowledgments: \n\ \n\ This code thanks: \n\ ForceReach, Reference, MessageBox \n\ @@ -143,8 +143,8 @@ A special thanks goes to those who contributed ideas, feature enhancements, bug \n\ Crafted with love in 🇨🇦 and 🇺🇸. \n\ \n", - }, - ]; + }, + ]; } -(void) openGithub diff --git a/reachappsettings/ReachAppSettings.mm b/reachappsettings/ReachAppSettings.mm index 35f2489..ae5a9b0 100644 --- a/reachappsettings/ReachAppSettings.mm +++ b/reachappsettings/ReachAppSettings.mm @@ -41,24 +41,24 @@ @interface ReachAppSettingsListController: SKTintedListController= 300000) - header.title = @"dank memes"; + if (arc4random_uniform(1000000) == 11) + header.title = @"卐卐 TWEAK SUPREMACY 卍卍"; + else if (arc4random_uniform(1000000) >= 300000) + header.title = @"dank memes"; #endif - header.blendMode = kCGBlendModeSoftLight; - header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/MainHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(109.33, 41)]]; + header.blendMode = kCGBlendModeSoftLight; + header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/MainHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(109.33, 41)]]; - UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 115)]; - [notHeader addSubview:header]; + UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 115)]; + [notHeader addSubview:header]; - return notHeader; + return notHeader; } -(UIColor*) navigationTintColor { return [UIColor colorWithRed:190/255.0f green:83/255.0f blue:184/255.0f alpha:1.0f]; } @@ -68,223 +68,223 @@ -(NSString*) shareMessage { return @"I'm multitasking with Multiplexer, by @daem -(NSArray*) customSpecifiers { - return @[ - @{ @"footerText": @"Quickly enable or disable Multiplexer." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"enabled", - @"label": @"Enabled", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - @"icon": @"ra_enabled.png", - }, + return @[ + @{ @"footerText": @"Quickly enable or disable Multiplexer." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"enabled", + @"label": @"Enabled", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + @"icon": @"ra_enabled.png", + }, #if DEBUG - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"debug_showIPCMessages", - @"label": @"Show IPC communication messages", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - @"icon": @"ra_enabled.png", - }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"debug_showIPCMessages", + @"label": @"Show IPC communication messages", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + @"icon": @"ra_enabled.png", + }, #endif - @{ @"footerText": @"Customize the look of Multiplexer." }, + @{ @"footerText": @"Customize the look of Multiplexer." }, - @{ - @"cell": @"PSLinkListCell", - @"default": [RASettings.sharedInstance currentThemeIdentifier], - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - @"label": @"Theme", - @"icon": @"theme.png", - @"key": @"currentThemeIdentifier", - @"detail": @"RAListItemsController", - @"valuesDataSource": @"getThemeValues:", - @"titlesDataSource": @"getThemeTitles:", - @"enabled": @([self getEnabled]) - }, + @{ + @"cell": @"PSLinkListCell", + @"default": [RASettings.sharedInstance currentThemeIdentifier], + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + @"label": @"Theme", + @"icon": @"theme.png", + @"key": @"currentThemeIdentifier", + @"detail": @"RAListItemsController", + @"valuesDataSource": @"getThemeValues:", + @"titlesDataSource": @"getThemeTitles:", + @"enabled": @([self getEnabled]) + }, - @{ @"footerText": @"Let apps run in the background." }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Aura", - @"detail": @"ReachAppBackgrounderSettingsListController", - @"icon": @"aura.png", - @"enabled": @([self getEnabled]) - }, - @{ @"footerText": @"Windowed multitasking." }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Empoleon", - @"detail": @"ReachAppWindowSettingsListController", - @"icon": @"empoleon.png", - @"enabled": @([self getEnabled]) - }, - @{ @"footerText": @"Manage multiple desktops and their windows." }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Mission Control", - @"detail": @"ReachAppMCSettingsListController", - @"icon": @"missioncontrol.png", - @"enabled": @([self getEnabled]) - }, - @{ @"footerText": @"Have an app in Notification Center." }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Quick Access", - @"detail": @"ReachAppNCAppSettingsListController", - @"icon": @"quickaccess.png", - @"enabled": @([self getEnabled]) - }, - @{ @"footerText": @"Use an app in Reachability alongside another." }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Reach App", - @"detail": @"ReachAppReachabilitySettingsListController", - @"icon": @"reachapp.png", - @"enabled": @([self getEnabled]) - }, - @{ @"footerText": @"Access another app simply by swiping in from the right side of the screen." }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Swipe Over", - @"detail": @"ReachAppSwipeOverSettingsListController", - @"icon": @"swipeover.png", - @"enabled": @([self getEnabled]) - }, - @{ @"footerText": [NSString stringWithFormat:@"%@%@", + @{ @"footerText": @"Let apps run in the background." }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Aura", + @"detail": @"ReachAppBackgrounderSettingsListController", + @"icon": @"aura.png", + @"enabled": @([self getEnabled]) + }, + @{ @"footerText": @"Windowed multitasking." }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Empoleon", + @"detail": @"ReachAppWindowSettingsListController", + @"icon": @"empoleon.png", + @"enabled": @([self getEnabled]) + }, + @{ @"footerText": @"Manage multiple desktops and their windows." }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Mission Control", + @"detail": @"ReachAppMCSettingsListController", + @"icon": @"missioncontrol.png", + @"enabled": @([self getEnabled]) + }, + @{ @"footerText": @"Have an app in Notification Center." }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Quick Access", + @"detail": @"ReachAppNCAppSettingsListController", + @"icon": @"quickaccess.png", + @"enabled": @([self getEnabled]) + }, + @{ @"footerText": @"Use an app in Reachability alongside another." }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Reach App", + @"detail": @"ReachAppReachabilitySettingsListController", + @"icon": @"reachapp.png", + @"enabled": @([self getEnabled]) + }, + @{ @"footerText": @"Access another app simply by swiping in from the right side of the screen." }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Swipe Over", + @"detail": @"ReachAppSwipeOverSettingsListController", + @"icon": @"swipeover.png", + @"enabled": @([self getEnabled]) + }, + @{ @"footerText": [NSString stringWithFormat:@"%@%@", #if DEBUG - arc4random_uniform(10000) == 9901 ? @"2fast5me" : + arc4random_uniform(10000) == 9901 ? @"2fast5me" : #endif - @"© 2015 Elijah Frederickson & Andrew Abosh.", + @"© 2015 Elijah Frederickson & Andrew Abosh.", #if DEBUG - @"\n**DEBUG** " + @"\n**DEBUG** " #else - @"" + @"" #endif - ]}, - @{ - @"cell": @"PSLinkCell", - @"label": @"Creators", - @"detail": @"RAMakersController", - @"icon": @"ra_makers.png" - }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Support", - @"action": @"showSupportDialog", - @"icon": @"ra_support.png" - }, + ]}, + @{ + @"cell": @"PSLinkCell", + @"label": @"Creators", + @"detail": @"RAMakersController", + @"icon": @"ra_makers.png" + }, + @{ + @"cell": @"PSLinkCell", + @"label": @"Support", + @"action": @"showSupportDialog", + @"icon": @"ra_support.png" + }, - @{ - @"cell": @"PSLinkCell", - @"label": @"Tutorial", - @"action": @"showTutorial", - @"icon": @"tutorial.png", - //@"enabled": @NO, - },/* - @{ - @"cell": @"PSLinkCell", - @"label": @"Theming Documentation", - @"action": @"openThemingDocumentation", - @"icon": @"tutorial.png", - },*/ - @{ - @"cell": @"PSButtonCell", - @"action": @"resetData", - @"label": @"Reset All Settings & Respring", - @"icon": @"Reset.png" - } - ]; + @{ + @"cell": @"PSLinkCell", + @"label": @"Tutorial", + @"action": @"showTutorial", + @"icon": @"tutorial.png", + //@"enabled": @NO, + },/* + @{ + @"cell": @"PSLinkCell", + @"label": @"Theming Documentation", + @"action": @"openThemingDocumentation", + @"icon": @"tutorial.png", + },*/ + @{ + @"cell": @"PSButtonCell", + @"action": @"resetData", + @"label": @"Reset All Settings & Respring", + @"icon": @"Reset.png" + } + ]; } -(void) resetData { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Please confirm your choice to reset all settings & respring.." preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.resetSettings"), nil, nil, YES); - }]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; - - [alert addAction:resetAction]; - [alert addAction:cancelAction]; - [self presentViewController:alert animated:YES completion:nil]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Please confirm your choice to reset all settings & respring.." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.resetSettings"), nil, nil, YES); + }]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; + + [alert addAction:resetAction]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } -(void) openThemingDocumentation { - [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com/multiplexer/ThemingDocumentation.html"]]; + [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com/multiplexer/ThemingDocumentation.html"]]; } -(NSArray*) getThemeTitles:(id)target { - NSArray *themes = [RAThemeManager.sharedInstance allThemes]; - NSMutableArray *ret = [NSMutableArray array]; - for (RATheme *theme in themes) - [ret addObject:theme.themeName]; - return ret; + NSArray *themes = [RAThemeManager.sharedInstance allThemes]; + NSMutableArray *ret = [NSMutableArray array]; + for (RATheme *theme in themes) + [ret addObject:theme.themeName]; + return ret; } -(NSArray*) getThemeValues:(id)target { - NSArray *themes = [RAThemeManager.sharedInstance allThemes]; - NSMutableArray *ret = [NSMutableArray array]; - for (RATheme *theme in themes) - [ret addObject:theme.themeIdentifier]; - return ret; + NSArray *themes = [RAThemeManager.sharedInstance allThemes]; + NSMutableArray *ret = [NSMutableArray array]; + for (RATheme *theme in themes) + [ret addObject:theme.themeIdentifier]; + return ret; } -(void) showSupportDialog { - MFMailComposeViewController *mailViewController; - if ([MFMailComposeViewController canSendMail]) - { - mailViewController = [[MFMailComposeViewController alloc] init]; - mailViewController.mailComposeDelegate = self; - [mailViewController setSubject:@"Multiplexer"]; + MFMailComposeViewController *mailViewController; + if ([MFMailComposeViewController canSendMail]) + { + mailViewController = [[MFMailComposeViewController alloc] init]; + mailViewController.mailComposeDelegate = self; + [mailViewController setSubject:@"Multiplexer"]; - struct utsname systemInfo; - uname(&systemInfo); - NSString *sysInfo = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; + struct utsname systemInfo; + uname(&systemInfo); + NSString *sysInfo = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; - NSString *msg = [NSString stringWithFormat:@"\n\n%@ %@\nModel: %@\n", [UIDevice currentDevice].systemName, [UIDevice currentDevice].systemVersion, sysInfo]; - [mailViewController setMessageBody:msg isHTML:NO]; - [mailViewController setToRecipients:@[@"elijahandandrew@gmail.com"]]; + NSString *msg = [NSString stringWithFormat:@"\n\n%@ %@\nModel: %@\n", [UIDevice currentDevice].systemName, [UIDevice currentDevice].systemVersion, sysInfo]; + [mailViewController setMessageBody:msg isHTML:NO]; + [mailViewController setToRecipients:@[@"elijahandandrew@gmail.com"]]; - [self.rootController presentViewController:mailViewController animated:YES completion:nil]; - } + [self.rootController presentViewController:mailViewController animated:YES completion:nil]; + } } -(void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { - [super setPreferenceValue:value specifier:specifier]; - [self reloadSpecifiers]; + [super setPreferenceValue:value specifier:specifier]; + [self reloadSpecifiers]; } -(BOOL) getEnabled { - CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); - CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (!keyList) { - return YES; - } - NSDictionary *_settings = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - CFRelease(keyList); - if (!_settings) { - return YES; - } + CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); + CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (!keyList) { + return YES; + } + NSDictionary *_settings = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + CFRelease(keyList); + if (!_settings) { + return YES; + } - return ![_settings objectForKey:@"enabled"] ? YES : [_settings[@"enabled"] boolValue]; + return ![_settings objectForKey:@"enabled"] ? YES : [_settings[@"enabled"] boolValue]; } -(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{ - [self dismissViewControllerAnimated:YES completion:NULL]; + [self dismissViewControllerAnimated:YES completion:NULL]; } -(void) showTutorial { - [UIApplication.sharedApplication launchApplicationWithIdentifier:@"com.andrewabosh.Multiplexer" suspended:NO]; + [UIApplication.sharedApplication launchApplicationWithIdentifier:@"com.andrewabosh.Multiplexer" suspended:NO]; } @end diff --git a/reachappsettings/Reachability.xm b/reachappsettings/Reachability.xm index 2795da5..8d7f2bb 100644 --- a/reachappsettings/Reachability.xm +++ b/reachappsettings/Reachability.xm @@ -35,19 +35,19 @@ @implementation ReachAppReachabilitySettingsListController -(UIView*) headerView { - RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ - (id) [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:82/255.0f green:191/255.0f blue:232/255.0f alpha:1.0f].CGColor - ]; - header.shouldBlend = NO; - //header.title = @"ReachApp"; - header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/ReachAppHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(27.15, 32)]]; - - UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; - [notHeader addSubview:header]; - - return notHeader; + RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; + header.colors = @[ + (id) [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:82/255.0f green:191/255.0f blue:232/255.0f alpha:1.0f].CGColor + ]; + header.shouldBlend = NO; + //header.title = @"ReachApp"; + header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/ReachAppHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(27.15, 32)]]; + + UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; + [notHeader addSubview:header]; + + return notHeader; } -(UIColor*) tintColor { return [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f]; } -(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } @@ -56,122 +56,121 @@ -(void) viewDidAppear:(BOOL)arg1 { - [super viewDidAppear:arg1]; - [super performSelector:@selector(setupHeader)]; + [super viewDidAppear:arg1]; + [super performSelector:@selector(setupHeader)]; } -(NSArray*) customSpecifiers { - return @[ - @{ @"footerText": @"Quickly enable or disable ReachApp." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"reachabilityEnabled", - @"label": @"Enabled", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"footerText": @"If enabled, the Notification Center view is displayed in Reachability." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"showNCInstead", - @"label": @"Show NC Instead of App", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"footerText": @"Disables the default duration that Reachability closes after." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"disableAutoDismiss", - @"label": @"Disable Auto-dismiss", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, + return @[ + @{ @"footerText": @"Quickly enable or disable ReachApp." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"reachabilityEnabled", + @"label": @"Enabled", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"footerText": @"If enabled, the Notification Center view is displayed in Reachability." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"showNCInstead", + @"label": @"Show NC Instead of App", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"footerText": @"Disables the default duration that Reachability closes after." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"disableAutoDismiss", + @"label": @"Disable Auto-dismiss", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, /* - @{ @"footerText": @"Forces apps to rotate to the current orientation" }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"enableRotation", - @"label": @"Enable Rotation", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, + @{ @"footerText": @"Forces apps to rotate to the current orientation" }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"enableRotation", + @"label": @"Enable Rotation", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, */ - @{ @"footerText": @"If enabled, the home button will no longer return to the home screen when Reachability is displayed." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"homeButtonClosesReachability", - @"label": @"Home Button Closes Reachability", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, + @{ @"footerText": @"If enabled, the home button will no longer return to the home screen when Reachability is displayed." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"homeButtonClosesReachability", + @"label": @"Home Button Closes Reachability", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, /* - @{ @"footerText": @"Shows the bottom half of the resizing grabber" }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"showBottomGrabber", - @"label": @"Show Bottom Grabber", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"footerText": @"This attempts to hide the lower status bar and force the upper status bar." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"unifyStatusBar", - @"label": @"Unify Status Bar", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, + @{ @"footerText": @"Shows the bottom half of the resizing grabber" }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"showBottomGrabber", + @"label": @"Show Bottom Grabber", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"footerText": @"This attempts to hide the lower status bar and force the upper status bar." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"unifyStatusBar", + @"label": @"Unify Status Bar", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, */ - @{ @"footerText": @"If enabled, a widget selector will be displayed. If disabled, the last used app will be show in Reachability." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"showAppSelector", - @"label": @"Display Widget Selector", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ - @"cell": @"PSLinkListCell", - @"detail": @"RAAppChooserOptionsListController", - @"label": @"Options", - }, + @{ @"footerText": @"If enabled, a widget selector will be displayed. If disabled, the last used app will be show in Reachability." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"showAppSelector", + @"label": @"Display Widget Selector", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ + @"cell": @"PSLinkListCell", + @"detail": @"RAAppChooserOptionsListController", + @"label": @"Options", + }, /* - @{ @"footerText": @"PLEASE NOTE THESE ARE BETA OPTIONS, STILL UNDER WORK OR TEMPORARILY BEING IGNORED. DO NOT SEND EMAILS RELATING TO THIS FEATURE. THEY WILL BE IGNORED. \n\nThat said, one will force applications into portrait and scale them to the screen size in landscape mode\nand the other will flip the top and bottom panes" }, - @{ - @"cell": @"PSSwitchCell", - @"default": @0, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"rotationMode", - @"label": @"Use Scaling Rotation Mode", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - @"cellClass": @"RASwitchCell", - }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"flipTopAndBottom", - @"label": @"Appear at Bottom", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - */ - ]; - + @{ @"footerText": @"PLEASE NOTE THESE ARE BETA OPTIONS, STILL UNDER WORK OR TEMPORARILY BEING IGNORED. DO NOT SEND EMAILS RELATING TO THIS FEATURE. THEY WILL BE IGNORED. \n\nThat said, one will force applications into portrait and scale them to the screen size in landscape mode\nand the other will flip the top and bottom panes" }, + @{ + @"cell": @"PSSwitchCell", + @"default": @0, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"rotationMode", + @"label": @"Use Scaling Rotation Mode", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + @"cellClass": @"RASwitchCell", + }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"flipTopAndBottom", + @"label": @"Appear at Bottom", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + */ + ]; } @end @@ -182,63 +181,63 @@ -(BOOL) showHeartImage { return NO; } -(NSArray*) customSpecifiers { - return @[ - @{ @"footerText": @"If enabled, the app selector will scale to the size of available apps." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"autoSizeAppChooser", - @"label": @"Auto-size Widget Chooser", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"footerText": @"If enabled, a list of your recent apps will display in the app selector." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"showRecents", - @"label": @"Display Recent Apps", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"footerText": @"Apps that will be displayed in the favorites section of the app selector." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"showFavorites", - @"label": @"Display Favorite Apps", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ - @"cell": @"PSLinkListCell", - @"detail": @"RAFavoritesAppSelectorView", - @"label": @"Favorites", - }, - - @{ @"footerText": @"If enabled, a section with all your apps will display in the app selector." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"showAllAppsInAppChooser", - @"label": @"Display All Apps", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"footerText": @"If enabled, apps will be divided into discrete pages." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"pagingEnabled", - @"label": @"Pagination", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - ]; + return @[ + @{ @"footerText": @"If enabled, the app selector will scale to the size of available apps." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"autoSizeAppChooser", + @"label": @"Auto-size Widget Chooser", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"footerText": @"If enabled, a list of your recent apps will display in the app selector." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"showRecents", + @"label": @"Display Recent Apps", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"footerText": @"Apps that will be displayed in the favorites section of the app selector." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"showFavorites", + @"label": @"Display Favorite Apps", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ + @"cell": @"PSLinkListCell", + @"detail": @"RAFavoritesAppSelectorView", + @"label": @"Favorites", + }, + + @{ @"footerText": @"If enabled, a section with all your apps will display in the app selector." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"showAllAppsInAppChooser", + @"label": @"Display All Apps", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"footerText": @"If enabled, apps will be divided into discrete pages." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"pagingEnabled", + @"label": @"Pagination", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + ]; } @end @@ -248,18 +247,18 @@ @implementation RASwitchCell -(instancetype)initWithStyle:(int)arg1 reuseIdentifier:(id)arg2 specifier:(id)arg3 { //init method - self = [super initWithStyle:arg1 reuseIdentifier:arg2 specifier:arg3]; //call the super init method - if (self) { - [((UISwitch *)[self control]) setOnTintColor:[UIColor redColor]]; //change the switch color - } - return self; + self = [super initWithStyle:arg1 reuseIdentifier:arg2 specifier:arg3]; //call the super init method + if (self) { + [((UISwitch *)[self control]) setOnTintColor:[UIColor redColor]]; //change the switch color + } + return self; } @end @interface RAFavoritesAppSelectorView : PSViewController { - UITableView* _tableView; - ALApplicationTableDataSource* _dataSource; + UITableView* _tableView; + ALApplicationTableDataSource* _dataSource; } @end @@ -275,29 +274,29 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //NSInteger row = indexPath.row; - UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; - - NSDictionary *prefs = nil; - - CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); - CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (!keyList) { - return cell; - } - prefs = (__bridge NSDictionary*)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (!prefs) { - return cell; - } - CFRelease(keyList); - - if ([cell isKindOfClass:[ALCheckCell class]]) - { - NSString *dn = [self displayIdentifierForIndexPath:indexPath]; - NSString *key = [NSString stringWithFormat:@"Favorites-%@",dn]; - BOOL value = [prefs[key] boolValue]; - [(ALCheckCell*)cell loadValue:@(value)]; - } + UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; + + NSDictionary *prefs = nil; + + CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); + CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (!keyList) { + return cell; + } + prefs = (__bridge NSDictionary*)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); + if (!prefs) { return cell; + } + CFRelease(keyList); + + if ([cell isKindOfClass:[ALCheckCell class]]) + { + NSString *dn = [self displayIdentifierForIndexPath:indexPath]; + NSString *key = [NSString stringWithFormat:@"Favorites-%@",dn]; + BOOL value = [prefs[key] boolValue]; + [(ALCheckCell*)cell loadValue:@(value)]; + } + return cell; } @end @@ -305,57 +304,57 @@ -(void)updateDataSource:(NSString*)searchText { - _dataSource.sectionDescriptors = [NSArray arrayWithObjects: - [NSDictionary dictionaryWithObjectsAndKeys: - @"", ALSectionDescriptorTitleKey, - @"ALCheckCell", ALSectionDescriptorCellClassNameKey, - @(29), ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - [NSString stringWithFormat:@"not bundleIdentifier in { }"], - ALSectionDescriptorPredicateKey - , nil], - nil]; - [_tableView reloadData]; + _dataSource.sectionDescriptors = [NSArray arrayWithObjects: + [NSDictionary dictionaryWithObjectsAndKeys: + @"", ALSectionDescriptorTitleKey, + @"ALCheckCell", ALSectionDescriptorCellClassNameKey, + @(29), ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + [NSString stringWithFormat:@"not bundleIdentifier in { }"], + ALSectionDescriptorPredicateKey + , nil], + nil]; + [_tableView reloadData]; } -(instancetype)init { - if (self = [super init]) { - CGRect bounds = [[UIScreen mainScreen] bounds]; - - _dataSource = [[RAApplicationTableDataSource alloc] init]; - - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; - _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - _tableView.delegate = self; - _tableView.dataSource = _dataSource; - _dataSource.tableView = _tableView; - [self updateDataSource:nil]; - } - return self; + if (self = [super init]) { + CGRect bounds = [[UIScreen mainScreen] bounds]; + + _dataSource = [[RAApplicationTableDataSource alloc] init]; + + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; + _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _tableView.delegate = self; + _tableView.dataSource = _dataSource; + _dataSource.tableView = _tableView; + [self updateDataSource:nil]; + } + return self; } -(void)viewDidLoad { - ((UIViewController *)self).title = @"Applications"; - [self.view addSubview:_tableView]; - [super viewDidLoad]; + ((UIViewController *)self).title = @"Applications"; + [self.view addSubview:_tableView]; + [super viewDidLoad]; } -(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { - [tableView deselectRowAtIndexPath:indexPath animated:true]; - ALCheckCell* cell = (ALCheckCell*)[tableView cellForRowAtIndexPath:indexPath]; - [cell didSelect]; + [tableView deselectRowAtIndexPath:indexPath animated:true]; + ALCheckCell* cell = (ALCheckCell*)[tableView cellForRowAtIndexPath:indexPath]; + [cell didSelect]; - UITableViewCellAccessoryType type = [cell accessoryType]; - BOOL selected = type == UITableViewCellAccessoryCheckmark; + UITableViewCellAccessoryType type = [cell accessoryType]; + BOOL selected = type == UITableViewCellAccessoryCheckmark; - NSString *identifier = [_dataSource displayIdentifierForIndexPath:indexPath]; - CFPreferencesSetAppValue((__bridge CFStringRef)[NSString stringWithFormat:@"Favorites-%@", identifier], (CFPropertyListRef)(@(selected)), CFSTR("com.efrederickson.reachapp.settings")); + NSString *identifier = [_dataSource displayIdentifierForIndexPath:indexPath]; + CFPreferencesSetAppValue((__bridge CFStringRef)[NSString stringWithFormat:@"Favorites-%@", identifier], (CFPropertyListRef)(@(selected)), CFSTR("com.efrederickson.reachapp.settings")); - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.7 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); - }); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.7 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); + }); } @end diff --git a/update_status b/update_status index ffdd362..d523922 100644 --- a/update_status +++ b/update_status @@ -31,6 +31,7 @@ Minor Things/Bugs to note: - Some say it causes serious lag (probably because logs werent disabled/due to MC)? - Startup bug still isnt fixed (apparently caused by gesture support?) - General Code Cleanup, feels to messy RN +- Check iPad support/lower iOS versions Things to do/Features to add: - 3D Touch actions? diff --git a/widgets/Reachability/RAAllAppsWidget.xm b/widgets/Reachability/RAAllAppsWidget.xm index 7e46ad6..5ab4583 100644 --- a/widgets/Reachability/RAAllAppsWidget.xm +++ b/widgets/Reachability/RAAllAppsWidget.xm @@ -70,10 +70,10 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) - continue; + if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) + continue; - if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { if (isTop) { @@ -90,15 +90,15 @@ isTop = !isTop; } - iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); - iconView.tag = app.pid; - iconView.restorationIdentifier = app.bundleIdentifier; - UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; - [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; + iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); + iconView.tag = app.pid; + iconView.restorationIdentifier = app.bundleIdentifier; + UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; + [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; - [allAppsView addSubview:iconView]; + [allAppsView addSubview:iconView]; - contentSize.width += iconView.frame.size.width + spacing; + contentSize.width += iconView.frame.size.width + spacing; } contentSize.width = width; contentSize.height = 10 + ((size.height + 10) * (hasSecondRow ? 2 : 1)); diff --git a/widgets/Reachability/RAFavoriteAppsWidget.xm b/widgets/Reachability/RAFavoriteAppsWidget.xm index 2326650..e3ae7ba 100644 --- a/widgets/Reachability/RAFavoriteAppsWidget.xm +++ b/widgets/Reachability/RAFavoriteAppsWidget.xm @@ -53,10 +53,10 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView) - continue; + if (!iconView) + continue; - if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { if (isTop) { @@ -73,16 +73,16 @@ isTop = !isTop; } - iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); + iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); - iconView.tag = app.pid; - iconView.restorationIdentifier = app.bundleIdentifier; - UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; - [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; + iconView.tag = app.pid; + iconView.restorationIdentifier = app.bundleIdentifier; + UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; + [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; - [favoritesView addSubview:iconView]; + [favoritesView addSubview:iconView]; - contentSize.width += iconView.frame.size.width + spacing; + contentSize.width += iconView.frame.size.width + spacing; } contentSize.width = width; contentSize.height = 10 + ((size.height + 10) * (hasSecondRow ? 2 : 1)); diff --git a/widgets/Reachability/RARecentAppsWidget.xm b/widgets/Reachability/RARecentAppsWidget.xm index 4070b5f..51f09a2 100644 --- a/widgets/Reachability/RARecentAppsWidget.xm +++ b/widgets/Reachability/RARecentAppsWidget.xm @@ -62,10 +62,10 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView) - continue; + if (!iconView) + continue; - if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { if (isTop) { @@ -81,16 +81,16 @@ isTop = !isTop; } - iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); + iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); - iconView.tag = index++; - iconView.restorationIdentifier = app.bundleIdentifier; - UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; - [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; + iconView.tag = index++; + iconView.restorationIdentifier = app.bundleIdentifier; + UITapGestureRecognizer *iconViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(appViewItemTap:)]; + [iconView addGestureRecognizer:iconViewTapGestureRecognizer]; - [recentsView addSubview:iconView]; + [recentsView addSubview:iconView]; - contentSize.width += iconView.frame.size.width + spacing; + contentSize.width += iconView.frame.size.width + spacing; } contentSize.width = width; contentSize.height = 10 + ((size.height + 10) * (hasSecondRow ? 2 : 1)); From 3319976ceefcc8db246fe4582c4b0532937dcf4b Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Wed, 15 Mar 2017 22:33:10 -0500 Subject: [PATCH 51/59] Fixed MC snapshot provider --- .../BackgroundModeTogglerActivator.xm | 50 +++--- Backgrounding/IconIndicator.xm | 16 +- Backgrounding/RABackgrounder.xm | 17 +- Backgrounding/SpringBoard.xm | 164 +++++++++--------- .../SpringBoard_UIAppCustomBackgroundModes.xm | 52 +++--- Messaging/RAMessagingClient.xm | 5 +- MissionControl/AppSwitcher.xm | 9 +- MissionControl/RAMissionControlManager.xm | 11 +- RASnapshotProvider.xm | 25 +-- TutorialApp/multiplexertutorial/Tweak.xm | 6 +- update_status | 2 +- 11 files changed, 178 insertions(+), 179 deletions(-) diff --git a/Backgrounding/BackgroundModeTogglerActivator.xm b/Backgrounding/BackgroundModeTogglerActivator.xm index b2f9b5a..f2f6408 100644 --- a/Backgrounding/BackgroundModeTogglerActivator.xm +++ b/Backgrounding/BackgroundModeTogglerActivator.xm @@ -11,43 +11,43 @@ static RAActivatorBackgrounderToggleModeListener *sharedInstance$RAActivatorBack @implementation RAActivatorBackgrounderToggleModeListener - (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event { - SBApplication *app = [UIApplication sharedApplication]._accessibilityFrontMostApplication; + SBApplication *app = [UIApplication sharedApplication]._accessibilityFrontMostApplication; - if (!app) - return; + if (!app) + return; - BOOL dismissApp = [[%c(RASettings) sharedInstance] exitAppAfterUsingActivatorAction]; + BOOL dismissApp = [[%c(RASettings) sharedInstance] exitAppAfterUsingActivatorAction]; - NSString *friendlyCurrentBackgroundMode = FriendlyNameForBackgroundMode((RABackgroundMode)[RABackgrounder.sharedInstance backgroundModeForIdentifier:app.bundleIdentifier]); + NSString *friendlyCurrentBackgroundMode = FriendlyNameForBackgroundMode((RABackgroundMode)[RABackgrounder.sharedInstance backgroundModeForIdentifier:app.bundleIdentifier]); - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:[NSString stringWithFormat:LOCALIZE(@"BACKGROUNDER_POPUP_SWITCHER_TEXT"),app.displayName,friendlyCurrentBackgroundMode] preferredStyle:UIAlertControllerStyleAlert]; - [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"FORCE_FOREGROUND") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:app andCloseForegroundApp:dismissApp]; - }]]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:[NSString stringWithFormat:LOCALIZE(@"BACKGROUNDER_POPUP_SWITCHER_TEXT"),app.displayName,friendlyCurrentBackgroundMode] preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"FORCE_FOREGROUND") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeForcedForeground forApplication:app andCloseForegroundApp:dismissApp]; + }]]; - [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"NATIVE") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeNative forApplication:app andCloseForegroundApp:dismissApp]; - }]]; + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"NATIVE") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeNative forApplication:app andCloseForegroundApp:dismissApp]; + }]]; - [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"SUSPEND_IMMEDIATELY") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeSuspendImmediately forApplication:app andCloseForegroundApp:dismissApp]; - }]]; + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"SUSPEND_IMMEDIATELY") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeSuspendImmediately forApplication:app andCloseForegroundApp:dismissApp]; + }]]; - [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"DISABLE") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeForceNone forApplication:app andCloseForegroundApp:dismissApp]; - }]]; + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"DISABLE") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [RABackgrounder.sharedInstance temporarilyApplyBackgroundingMode:RABackgroundModeForceNone forApplication:app andCloseForegroundApp:dismissApp]; + }]]; - [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"CANCEL") style:UIAlertActionStyleDefault handler:nil]]; + [alert addAction:[UIAlertAction actionWithTitle:LOCALIZE(@"CANCEL") style:UIAlertActionStyleDefault handler:nil]]; - [alert show]; + [alert show]; } @end %ctor { - IF_SPRINGBOARD - { - sharedInstance$RAActivatorBackgrounderToggleModeListener = [[RAActivatorBackgrounderToggleModeListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorBackgrounderToggleModeListener forName:@"com.efrederickson.reachapp.backgrounder.togglemode"]; - } + IF_SPRINGBOARD + { + sharedInstance$RAActivatorBackgrounderToggleModeListener = [[RAActivatorBackgrounderToggleModeListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorBackgrounderToggleModeListener forName:@"com.efrederickson.reachapp.backgrounder.togglemode"]; + } } diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 3d1f2c3..1303de6 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -164,7 +164,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) %new -(void) RA_updateIndicatorViewWithExistingInfo { //if ([self viewWithTag:9962]) - [self RA_updateIndicatorView:GET_INFO]; + [self RA_updateIndicatorView:GET_INFO]; } %new -(void) RA_setIsIconIndicatorInhibited:(BOOL)value @@ -289,13 +289,13 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) BOOL native = (info & RAIconIndicatorViewInfoNative); if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { - LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; - if (![item customViewClass]) - item.customViewClass = @"RAAppIconStatusBarIconView"; - item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; - lsbitems[self.bundleIdentifier] = item; - } + LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; + if (![item customViewClass]) + item.customViewClass = @"RAAppIconStatusBarIconView"; + item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; + lsbitems[self.bundleIdentifier] = item; } + } } } @@ -312,7 +312,7 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) else { if ([self respondsToSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]) - [self performSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]; + [self performSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]; [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]]; SET_INFO_(self.bundleIdentifier, [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]); diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index 1f22a5c..f960a3d 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -200,20 +200,19 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { if ([[[%c(SBIconViewMap) homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) { - // iOS 8.0+ - - SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; - ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; + // iOS 8.0+ + SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; + ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; } else { - // iOS 7.X - SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; - ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; + // iOS 7.X + SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; + ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; } } else { - SBApplicationIcon *icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:identifier]; - ret = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] mappedIconViewForIcon:icon]; + SBApplicationIcon *icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:identifier]; + ret = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] mappedIconViewForIcon:icon]; } [ret RA_updateIndicatorView:info]; diff --git a/Backgrounding/SpringBoard.xm b/Backgrounding/SpringBoard.xm index e7af68d..341f48b 100644 --- a/Backgrounding/SpringBoard.xm +++ b/Backgrounding/SpringBoard.xm @@ -23,113 +23,113 @@ %hook FBUIApplicationResignActiveManager -(void) _sendResignActiveForReason:(int)arg1 toProcess:(__unsafe_unretained FBApplicationProcess*)arg2 { - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2.bundleIdentifier]) - return; + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2.bundleIdentifier]) + return; - %orig; + %orig; - if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg2.bundleIdentifier]) - { - BKSProcess *bkProcess = MSHookIvar(arg2, "_bksProcess"); - //[bkProcess _handleExpirationWarning:nil]; - [arg2 processWillExpire:bkProcess]; - } + if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg2.bundleIdentifier]) + { + BKSProcess *bkProcess = MSHookIvar(arg2, "_bksProcess"); + //[bkProcess _handleExpirationWarning:nil]; + [arg2 processWillExpire:bkProcess]; + } } %end %hook FBUIApplicationSceneDeactivationManager // iOS 9 - (BOOL)_isEligibleProcess:(__unsafe_unretained FBApplicationProcess*)arg1 { - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.bundleIdentifier]) - return NO; + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.bundleIdentifier]) + return NO; - return %orig; + return %orig; } %end %hook FBSSceneImpl - (id)_initWithQueue:(unsafe_id)arg1 callOutQueue:(unsafe_id)arg2 identifier:(unsafe_id)arg3 display:(unsafe_id)arg4 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg5 clientSettings:(unsafe_id)arg6 { - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg3]) + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg3]) + { + // what? + if (!arg5) { - // what? - if (!arg5) - { - UIMutableApplicationSceneSettings *fakeSettings = [[%c(UIMutableApplicationSceneSettings) alloc] init]; - arg5 = fakeSettings; - } - SET_BACKGROUNDED(arg5, NO); + UIMutableApplicationSceneSettings *fakeSettings = [[%c(UIMutableApplicationSceneSettings) alloc] init]; + arg5 = fakeSettings; } - return %orig(arg1, arg2, arg3, arg4, arg5, arg6); + SET_BACKGROUNDED(arg5, NO); + } + return %orig(arg1, arg2, arg3, arg4, arg5, arg6); } - (id)initWithQueue:(id)arg1 identifier:(id)arg2 display:(id)arg3 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg4 clientSettings:(id)arg5 { - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2]) + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2]) + { + // what? + if (!arg4) { - // what? - if (!arg4) - { - UIMutableApplicationSceneSettings *fakeSettings = [[%c(UIMutableApplicationSceneSettings) alloc] init]; - arg4 = fakeSettings; - } - SET_BACKGROUNDED(arg4, NO); + UIMutableApplicationSceneSettings *fakeSettings = [[%c(UIMutableApplicationSceneSettings) alloc] init]; + arg4 = fakeSettings; } - return %orig(arg1, arg2, arg3, arg4, arg5); + SET_BACKGROUNDED(arg4, NO); + } + return %orig(arg1, arg2, arg3, arg4, arg5); } %end %hook FBUIApplicationWorkspaceScene -(void) host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 { - [RABackgrounder.sharedInstance removeTemporaryOverrideForIdentifier:arg1.identifier]; - LogDebug(@"removeTemporaryOverrideForIdentifier: %@", arg1.identifier); + [RABackgrounder.sharedInstance removeTemporaryOverrideForIdentifier:arg1.identifier]; + LogDebug(@"removeTemporaryOverrideForIdentifier: %@", arg1.identifier); - if (arg1 && arg1.identifier && arg2 && arg1.clientProcess) // FIX: sanity check to prevent NC App crash. untested/not working. + if (arg1 && arg1.identifier && arg2 && arg1.clientProcess) // FIX: sanity check to prevent NC App crash. untested/not working. + { + if (arg2.backgrounded) { - if (arg2.backgrounded) - { - if ([RABackgrounder.sharedInstance killProcessOnExit:arg1.identifier]) - { - FBProcess *proc = arg1.clientProcess; - - if ([proc isKindOfClass:[%c(FBApplicationProcess) class]]) - { - FBApplicationProcess *proc2 = (FBApplicationProcess*)proc; - [proc2 killForReason:1 andReport:NO withDescription:@"ReachApp.Backgrounder.killOnExit" completion:nil]; - [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:RAIconIndicatorViewInfoForceDeath]; - if ([RABackgrounder.sharedInstance shouldRemoveFromSwitcherWhenKilledOnExit:arg1.identifier]) - { - [%c(RAAppSwitcherModelWrapper) removeItemWithIdentifier:arg1.identifier]; - } - } - [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; - } - - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.identifier]) - { - [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; - [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; - return; - } - else if ([RABackgrounder.sharedInstance backgroundModeForIdentifier:arg1.identifier] == RABackgroundModeNative) - { - [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; - [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; - } - else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) - { - [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; - [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; - } - } - else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) + if ([RABackgrounder.sharedInstance killProcessOnExit:arg1.identifier]) + { + FBProcess *proc = arg1.clientProcess; + + if ([proc isKindOfClass:[%c(FBApplicationProcess) class]]) { - [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; + FBApplicationProcess *proc2 = (FBApplicationProcess*)proc; + [proc2 killForReason:1 andReport:NO withDescription:@"ReachApp.Backgrounder.killOnExit" completion:nil]; + [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:RAIconIndicatorViewInfoForceDeath]; + if ([RABackgrounder.sharedInstance shouldRemoveFromSwitcherWhenKilledOnExit:arg1.identifier]) + { + [%c(RAAppSwitcherModelWrapper) removeItemWithIdentifier:arg1.identifier]; + } } + [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; + } + + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.identifier]) + { + [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; + [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; + return; + } + else if ([RABackgrounder.sharedInstance backgroundModeForIdentifier:arg1.identifier] == RABackgroundModeNative) + { + [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; + [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; + } + else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) + { + [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; + [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; + } } + else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) + { + [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; + } + } - %orig(arg1, arg2, arg3, arg4, arg5); + %orig(arg1, arg2, arg3, arg4, arg5); } %end @@ -137,19 +137,19 @@ %hook FBApplicationProcess - (void)killForReason:(int)arg1 andReport:(BOOL)arg2 withDescription:(unsafe_id)arg3 completion:(unsafe_id/*block*/)arg4 { - if ([RABackgrounder.sharedInstance preventKillingOfIdentifier:self.bundleIdentifier]) - { - [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]]; - return; - } - %orig; + if ([RABackgrounder.sharedInstance preventKillingOfIdentifier:self.bundleIdentifier]) + { + [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]]; + return; + } + %orig; } %end %ctor { - IF_SPRINGBOARD - { - %init; - } + IF_SPRINGBOARD + { + %init; + } } diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index f193d34..b3d0654 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -27,32 +27,32 @@ ![arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] && // whitelist iCleaner to prevent crash on open ![arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"]) // Whitelist filza to prevent iOS hang (?!) Not sure if the springboard hack is still required { - NSString *identifier = [NSBundle mainBundle].bundleIdentifier; - - if (!identifier) - goto ORIGINAL; - - LogDebug(@"BKSProcessAssertion initWithPID:'%zd' flags:'%tu' reason:'%tu' name:'%@' withHandler:'%@' process identifier:'%@'", arg1, arg2, arg3, arg4, arg5, identifier); - - if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) - { - if ((arg3 >= BKSProcessAssertionReasonAudio && arg3 <= BKSProcessAssertionReasonVOiP)) // In most cases arg3 == 4 (finish task) - { - //NSLog(@"[ReachApp] blocking BKSProcessAssertion"); - - //if (arg5) - //{ - //void (^arg5fix)() = arg5; - //arg5fix(); - // ^^ causes crashes with share menu - //} - return nil; - } - //else if (arg3 == kProcessAssertionReasonActivation) - //{ - // arg2 = ProcessAssertionFlagAllowIdleSleep; - //} - } + NSString *identifier = [NSBundle mainBundle].bundleIdentifier; + + if (!identifier) + goto ORIGINAL; + + //LogDebug(@"BKSProcessAssertion initWithPID:'%zd' flags:'%tu' reason:'%tu' name:'%@' withHandler:'%@' process identifier:'%@'", arg1, arg2, arg3, arg4, arg5, identifier); + + if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) + { + if ((arg3 >= BKSProcessAssertionReasonAudio && arg3 <= BKSProcessAssertionReasonVOiP)) // In most cases arg3 == 4 (finish task) + { + //NSLog(@"[ReachApp] blocking BKSProcessAssertion"); + + //if (arg5) + //{ + //void (^arg5fix)() = arg5; + //arg5fix(); + // ^^ causes crashes with share menu + //} + return nil; + } + //else if (arg3 == kProcessAssertionReasonActivation) + //{ + // arg2 = ProcessAssertionFlagAllowIdleSleep; + //} + } } ORIGINAL: return %orig(arg1, arg2, arg3, arg4, arg5); diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 26aef6f..49ef817 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -212,10 +212,7 @@ void updateFrontmostApp(CFNotificationCenterRef center, void *observer, CFString %ctor { - IF_SPRINGBOARD { - - } - else + IF_NOT_SPRINGBOARD { [RAMessagingClient sharedInstance]; CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadClientData, (__bridge CFStringRef)[NSString stringWithFormat:@"com.efrederickson.reachapp.clientupdate-%@",NSBundle.mainBundle.bundleIdentifier], NULL, CFNotificationSuspensionBehaviorDeliverImmediately); diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 17780fa..45e44a4 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -33,9 +33,9 @@ BOOL toggleOrActivate = NO; if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) { [RAMissionControlManager.sharedInstance showMissionControl:YES]; - } - else - [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } + else + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; return YES; } @@ -100,7 +100,6 @@ BOOL toggleOrActivate = NO; -(void)_showNotificationCenterGestureBeganWithGestureRecognizer:(id)arg1 { CGPoint location = [arg1 locationInView:[[%c(SBMainSwitcherViewController) sharedInstance] view]]; if ([[%c(RASettings) sharedInstance] missionControlEnabled] && [[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && CGRectContainsPoint([[[[%c(SBMainSwitcherViewController) sharedInstance] valueForKey:@"_contentView"] contentView] viewWithTag:999].frame, location)) { - LogDebug(@"contains rect"); return; } @@ -467,6 +466,8 @@ BOOL toggleOrActivate = NO; UIImage *snapshot = [[%c(RASnapshotProvider) sharedInstance] storedSnapshotOfMissionControl]; if (snapshot) { + LogDebug(@"snapshot exists, using"); + fakeView = [[UIImageView alloc] initWithFrame:view.frame]; ((UIImageView*)fakeView).image = snapshot; [view addSubview:fakeView]; diff --git a/MissionControl/RAMissionControlManager.xm b/MissionControl/RAMissionControlManager.xm index 0581bd7..f68e5df 100644 --- a/MissionControl/RAMissionControlManager.xm +++ b/MissionControl/RAMissionControlManager.xm @@ -110,7 +110,7 @@ CGRect swappedForOrientation2(CGRect in) window.frame = CGRectMake(0, 0, window.frame.size.width, window.frame.size.height); if (originalAppView) - originalAppView.frame = swappedForOrientation2(CGRectMake(originalAppFrame.origin.x, originalAppView.frame.size.height, originalAppFrame.size.width, originalAppFrame.size.height)); + originalAppView.frame = swappedForOrientation2(CGRectMake(originalAppFrame.origin.x, originalAppView.frame.size.height, originalAppFrame.size.width, originalAppFrame.size.height)); } completion:nil]; } else if (originalAppView) // dismiss even if not animating open @@ -130,7 +130,8 @@ CGRect swappedForOrientation2(CGRect in) if ([[%c(SBControlCenterController) sharedInstance] isVisible]) [[%c(SBControlCenterController) sharedInstance] dismissAnimated:YES]; - didStoreSnapshot = NO; + LogDebug(@"storeSnapshotOfMissionControl"); + [[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; } -(void) createWindow @@ -189,8 +190,8 @@ CGRect swappedForOrientation2(CGRect in) -(void) hideMissionControl:(BOOL)animated { - if (!didStoreSnapshot) - [[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; + //if (!didStoreSnapshot) + //[[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; [[%c(RARunningAppsProvider) sharedInstance] removeTarget:window]; void (^destructor)() = ^{ @@ -314,7 +315,7 @@ CGRect swappedForOrientation2(CGRect in) else if (state == UIGestureRecognizerStateBegan) { //[[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; - didStoreSnapshot = YES; + //didStoreSnapshot = YES; hasMoved = YES; [%c(RAControlCenterInhibitor) setInhibited:YES]; initialCenter = window.center; diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index 2540399..df072b8 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -69,13 +69,14 @@ if (view) { - UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, [UIScreen mainScreen].scale); - CGContextRef c = UIGraphicsGetCurrentContext(); - //CGContextSetAllowsAntialiasing(c, YES); - [view.layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; + UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, 0); + + ON_MAIN_THREAD(^{ + [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; + }); + image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - view.layer.contents = nil; } } @catch (NSException *ex) @@ -114,8 +115,10 @@ -(void) storeSnapshotOfMissionControl:(UIWindow*)window { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ - UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].RA_interfaceOrientedBounds.size, YES, [UIScreen mainScreen].scale); + LogDebug(@"storing snapshot"); + //Running on background thread results in black screen + //dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + UIGraphicsBeginImageContextWithOptions(window.bounds.size, YES, 0); //CGContextRef c = UIGraphicsGetCurrentContext(); //CGContextSetAllowsAntialiasing(c, YES); //[window.layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; @@ -126,12 +129,10 @@ UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - window.layer.contents = nil; if (image) [imageCache setObject:image forKey:@"missioncontrol"]; - }); - + //}); } -(NSString*) createKeyForDesktop:(RADesktopWindow*)desktop @@ -203,7 +204,7 @@ -(UIImage*) renderPreviewForDesktop:(RADesktopWindow*)desktop { @autoreleasepool { - UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen.bounds.size, YES, UIScreen.mainScreen.scale); + UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, 0); CGContextRef c = UIGraphicsGetCurrentContext(); [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; @@ -267,7 +268,7 @@ if ([imageCache objectForKey:key]) return [imageCache objectForKey:key]; - UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen.bounds.size, YES, UIScreen.mainScreen.scale); + UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen.bounds.size, YES, 0); CGContextRef c = UIGraphicsGetCurrentContext(); [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAWallpaperSnapshot"]; diff --git a/TutorialApp/multiplexertutorial/Tweak.xm b/TutorialApp/multiplexertutorial/Tweak.xm index 90d0bae..1415752 100644 --- a/TutorialApp/multiplexertutorial/Tweak.xm +++ b/TutorialApp/multiplexertutorial/Tweak.xm @@ -16,7 +16,7 @@ void open_settings(CFNotificationCenterRef a, void *b, CFStringRef c, const void %ctor { if (IN_SPRINGBOARD) - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, open_settings, CFSTR("com.elijahandandrew.multiplexer.tutorial.open_settings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - else - %init; + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, open_settings, CFSTR("com.elijahandandrew.multiplexer.tutorial.open_settings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + else + %init; } diff --git a/update_status b/update_status index d523922..06489e8 100644 --- a/update_status +++ b/update_status @@ -30,12 +30,12 @@ Minor Things/Bugs to note: - MC works but causes jittery animations (not as much as before) - Some say it causes serious lag (probably because logs werent disabled/due to MC)? - Startup bug still isnt fixed (apparently caused by gesture support?) -- General Code Cleanup, feels to messy RN - Check iPad support/lower iOS versions Things to do/Features to add: - 3D Touch actions? - (Real distant future) split all 6 features into seperate tweaks +- General Code Cleanup/conform to standards, feels to messy RN (at least indents are fine) notes: use _referenceBounds instead of bounds on UIScreen to get physical bounds. Makes landscape support easier? From 3d58076a7b09022af2bc1e7f895544d7746a60f7 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Thu, 16 Mar 2017 17:46:20 -0500 Subject: [PATCH 52/59] Fixed backgrounder crash + new methods --- Backgrounding/SpringBoard.xm | 109 +++++++++------------- MissionControl/AppSwitcher.xm | 3 - MissionControl/RAMissionControlManager.xm | 21 +++-- RASnapshotProvider.xm | 21 ++--- update_status | 1 + 5 files changed, 63 insertions(+), 92 deletions(-) diff --git a/Backgrounding/SpringBoard.xm b/Backgrounding/SpringBoard.xm index 341f48b..bf807c8 100644 --- a/Backgrounding/SpringBoard.xm +++ b/Backgrounding/SpringBoard.xm @@ -3,33 +3,29 @@ #import "RAAppSwitcherModelWrapper.h" %hook SBApplication --(BOOL) shouldAutoRelaunchAfterExit -{ - return [RABackgrounder.sharedInstance shouldAutoRelaunchApplication:self.bundleIdentifier] || %orig; +- (BOOL)shouldAutoRelaunchAfterExit { + return [RABackgrounder.sharedInstance shouldAutoRelaunchApplication:self.bundleIdentifier] || %orig; } --(BOOL) shouldAutoLaunchOnBootOrInstall -{ - return [RABackgrounder.sharedInstance shouldAutoLaunchApplication:self.bundleIdentifier] || %orig; +- (BOOL)shouldAutoLaunchOnBootOrInstall { + return [RABackgrounder.sharedInstance shouldAutoLaunchApplication:self.bundleIdentifier] || %orig; } --(BOOL) _shouldAutoLaunchOnBootOrInstall:(BOOL)arg1 -{ - return [RABackgrounder.sharedInstance shouldAutoLaunchApplication:self.bundleIdentifier] || %orig; +- (BOOL)_shouldAutoLaunchOnBootOrInstall:(BOOL)arg1 { + return [RABackgrounder.sharedInstance shouldAutoLaunchApplication:self.bundleIdentifier] || %orig; } %end // STAY IN "FOREGROUND" %hook FBUIApplicationResignActiveManager --(void) _sendResignActiveForReason:(int)arg1 toProcess:(__unsafe_unretained FBApplicationProcess*)arg2 -{ - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2.bundleIdentifier]) +- (void)_sendResignActiveForReason:(int)arg1 toProcess:(__unsafe_unretained FBApplicationProcess*)arg2 { + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2.bundleIdentifier]) { return; + } %orig; - if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg2.bundleIdentifier]) - { + if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg2.bundleIdentifier]) { BKSProcess *bkProcess = MSHookIvar(arg2, "_bksProcess"); //[bkProcess _handleExpirationWarning:nil]; [arg2 processWillExpire:bkProcess]; @@ -38,23 +34,20 @@ %end %hook FBUIApplicationSceneDeactivationManager // iOS 9 -- (BOOL)_isEligibleProcess:(__unsafe_unretained FBApplicationProcess*)arg1 -{ - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.bundleIdentifier]) +- (BOOL)_isEligibleProcess:(__unsafe_unretained FBApplicationProcess*)arg1 { + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.bundleIdentifier]) { return NO; + } return %orig; } %end %hook FBSSceneImpl -- (id)_initWithQueue:(unsafe_id)arg1 callOutQueue:(unsafe_id)arg2 identifier:(unsafe_id)arg3 display:(unsafe_id)arg4 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg5 clientSettings:(unsafe_id)arg6 -{ - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg3]) - { +- (id)_initWithQueue:(unsafe_id)arg1 callOutQueue:(unsafe_id)arg2 identifier:(unsafe_id)arg3 display:(unsafe_id)arg4 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg5 clientSettings:(unsafe_id)arg6 { + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg3]) { // what? - if (!arg5) - { + if (!arg5) { UIMutableApplicationSceneSettings *fakeSettings = [[%c(UIMutableApplicationSceneSettings) alloc] init]; arg5 = fakeSettings; } @@ -63,13 +56,10 @@ return %orig(arg1, arg2, arg3, arg4, arg5, arg6); } -- (id)initWithQueue:(id)arg1 identifier:(id)arg2 display:(id)arg3 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg4 clientSettings:(id)arg5 -{ - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2]) - { +- (id)initWithQueue:(id)arg1 identifier:(id)arg2 display:(id)arg3 settings:(__unsafe_unretained UIMutableApplicationSceneSettings*)arg4 clientSettings:(id)arg5 { + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg2]) { // what? - if (!arg4) - { + if (!arg4) { UIMutableApplicationSceneSettings *fakeSettings = [[%c(UIMutableApplicationSceneSettings) alloc] init]; arg4 = fakeSettings; } @@ -80,65 +70,55 @@ %end %hook FBUIApplicationWorkspaceScene --(void) host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 -{ - [RABackgrounder.sharedInstance removeTemporaryOverrideForIdentifier:arg1.identifier]; - LogDebug(@"removeTemporaryOverrideForIdentifier: %@", arg1.identifier); - - if (arg1 && arg1.identifier && arg2 && arg1.clientProcess) // FIX: sanity check to prevent NC App crash. untested/not working. - { - if (arg2.backgrounded) - { - if ([RABackgrounder.sharedInstance killProcessOnExit:arg1.identifier]) - { +- (void)host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 { + if (arg1 && arg1.identifier && arg2 && arg1.clientProcess) { + if (arg2.backgrounded) { + if ([RABackgrounder.sharedInstance killProcessOnExit:arg1.identifier]) { FBProcess *proc = arg1.clientProcess; - if ([proc isKindOfClass:[%c(FBApplicationProcess) class]]) - { + if ([proc isKindOfClass:[%c(FBApplicationProcess) class]]) { FBApplicationProcess *proc2 = (FBApplicationProcess*)proc; [proc2 killForReason:1 andReport:NO withDescription:@"ReachApp.Backgrounder.killOnExit" completion:nil]; [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:RAIconIndicatorViewInfoForceDeath]; - if ([RABackgrounder.sharedInstance shouldRemoveFromSwitcherWhenKilledOnExit:arg1.identifier]) - { + if ([RABackgrounder.sharedInstance shouldRemoveFromSwitcherWhenKilledOnExit:arg1.identifier]) { [%c(RAAppSwitcherModelWrapper) removeItemWithIdentifier:arg1.identifier]; } } [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; } - if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.identifier]) - { + if ([RABackgrounder.sharedInstance shouldKeepInForeground:arg1.identifier]) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; return; - } - else if ([RABackgrounder.sharedInstance backgroundModeForIdentifier:arg1.identifier] == RABackgroundModeNative) - { + } else if ([RABackgrounder.sharedInstance backgroundModeForIdentifier:arg1.identifier] == RABackgroundModeNative) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; - } - else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) - { + } else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; [RABackgrounder.sharedInstance queueRemoveTemporaryOverrideForIdentifier:arg1.identifier]; } } - else if ([RABackgrounder.sharedInstance shouldSuspendImmediately:arg1.identifier]) - { - [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:arg1.identifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:arg1.identifier]]; - } } %orig(arg1, arg2, arg3, arg4, arg5); } %end +%hook FBSceneManager +- (void)_noteSceneMovedToForeground:(FBScene*)arg1 { + if ([arg1.clientProcess isKindOfClass:[%c(FBApplicationProcess) class]]) { + [RABackgrounder.sharedInstance removeTemporaryOverrideForIdentifier:arg1.identifier]; + } + + %orig; +} +%end + // PREVENT KILLING %hook FBApplicationProcess -- (void)killForReason:(int)arg1 andReport:(BOOL)arg2 withDescription:(unsafe_id)arg3 completion:(unsafe_id/*block*/)arg4 -{ - if ([RABackgrounder.sharedInstance preventKillingOfIdentifier:self.bundleIdentifier]) - { +- (void)killForReason:(int)arg1 andReport:(BOOL)arg2 withDescription:(unsafe_id)arg3 completion:(unsafe_id/*block*/)arg4 { + if ([RABackgrounder.sharedInstance preventKillingOfIdentifier:self.bundleIdentifier]) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]]; return; } @@ -146,10 +126,9 @@ } %end -%ctor -{ - IF_SPRINGBOARD - { - %init; +%ctor { + IF_NOT_SPRINGBOARD { + return; } + %init; } diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 45e44a4..6f4c7e1 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -466,8 +466,6 @@ BOOL toggleOrActivate = NO; UIImage *snapshot = [[%c(RASnapshotProvider) sharedInstance] storedSnapshotOfMissionControl]; if (snapshot) { - LogDebug(@"snapshot exists, using"); - fakeView = [[UIImageView alloc] initWithFrame:view.frame]; ((UIImageView*)fakeView).image = snapshot; [view addSubview:fakeView]; @@ -568,7 +566,6 @@ BOOL toggleOrActivate = NO; } else { [[%c(SBMainSwitcherViewController) sharedInstance] RA_dismissSwitcherUnanimated]; } - [[%c(SBUIController) sharedInstance] restoreContentUpdatingStatusBar:YES]; [RAMissionControlManager.sharedInstance showMissionControl:NO]; [fakeView removeFromSuperview]; fakeView = nil; diff --git a/MissionControl/RAMissionControlManager.xm b/MissionControl/RAMissionControlManager.xm index f68e5df..f8fb15a 100644 --- a/MissionControl/RAMissionControlManager.xm +++ b/MissionControl/RAMissionControlManager.xm @@ -123,15 +123,16 @@ CGRect swappedForOrientation2(CGRect in) [[%c(RAGestureManager) sharedInstance] ignoreSwipesBeginningInRect:UIScreen.mainScreen.bounds forIdentifier:@"com.efrederickson.reachapp.windowedmultitasking.systemgesture"]; [[%c(RARunningAppsProvider) sharedInstance] addTarget:window]; [%c(RAOrientationLocker) lockOrientation]; - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAMissionControlManager"]; + if (IS_IOS_OR_OLDER(iOS_10_0)) { //Not required on 10.x, not sure about other versions + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAMissionControlManager"]; + } self.inhibitDismissalGesture = NO; [%c(RAControlCenterInhibitor) setInhibited:YES]; if ([[%c(SBControlCenterController) sharedInstance] isVisible]) [[%c(SBControlCenterController) sharedInstance] dismissAnimated:YES]; - LogDebug(@"storeSnapshotOfMissionControl"); - [[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; + didStoreSnapshot = NO; } -(void) createWindow @@ -140,8 +141,8 @@ CGRect swappedForOrientation2(CGRect in) { if (originalAppView) originalAppView.frame = originalAppFrame; - window.hidden = YES; - window = nil; + window.hidden = YES; + window = nil; } window = [[RAMissionControlWindow alloc] initWithFrame:UIScreen.mainScreen.RA_interfaceOrientedBounds]; @@ -190,8 +191,8 @@ CGRect swappedForOrientation2(CGRect in) -(void) hideMissionControl:(BOOL)animated { - //if (!didStoreSnapshot) - //[[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; + if (!didStoreSnapshot) + [[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; [[%c(RARunningAppsProvider) sharedInstance] removeTarget:window]; void (^destructor)() = ^{ @@ -200,7 +201,9 @@ CGRect swappedForOrientation2(CGRect in) window = nil; // This goes here to prevent the wallpaper from appearing black when dismissing - [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"RAMissionControlManager"]; + if (IS_IOS_OR_OLDER(iOS_10_0)) { + [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"RAMissionControlManager"]; + } }; if (animated) @@ -315,7 +318,7 @@ CGRect swappedForOrientation2(CGRect in) else if (state == UIGestureRecognizerStateBegan) { //[[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; - //didStoreSnapshot = YES; + didStoreSnapshot = YES; hasMoved = YES; [%c(RAControlCenterInhibitor) setInhibited:YES]; initialCenter = window.center; diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index df072b8..5ced566 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -115,24 +115,15 @@ -(void) storeSnapshotOfMissionControl:(UIWindow*)window { - LogDebug(@"storing snapshot"); - //Running on background thread results in black screen - //dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ - UIGraphicsBeginImageContextWithOptions(window.bounds.size, YES, 0); - //CGContextRef c = UIGraphicsGetCurrentContext(); - //CGContextSetAllowsAntialiasing(c, YES); - //[window.layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; + UIGraphicsBeginImageContextWithOptions(window.bounds.size, YES, 0); - ON_MAIN_THREAD(^{ - [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; - }); + [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); + UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); - if (image) - [imageCache setObject:image forKey:@"missioncontrol"]; - //}); + if (image) + [imageCache setObject:image forKey:@"missioncontrol"]; } -(NSString*) createKeyForDesktop:(RADesktopWindow*)desktop diff --git a/update_status b/update_status index 06489e8..2914ddf 100644 --- a/update_status +++ b/update_status @@ -27,6 +27,7 @@ Bugs: - CC inhibitor not reliable on 9.x+? Minor Things/Bugs to note: +- (some of these are leftover from the original release lol: eg MC lag) - MC works but causes jittery animations (not as much as before) - Some say it causes serious lag (probably because logs werent disabled/due to MC)? - Startup bug still isnt fixed (apparently caused by gesture support?) From dcb7b96ee5d2c50d2217c7ce2fc1e84336d1f5dd Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Thu, 16 Mar 2017 18:09:41 -0500 Subject: [PATCH 53/59] Implemented proper formatting --- .../BackgroundModeTogglerActivator.xm | 17 +- Backgrounding/IconIndicator.xm | 182 +++++++----------- Backgrounding/RABackgrounder.h | 36 ++-- Backgrounding/RABackgrounder.xm | 140 +++++++------- .../SpringBoard_UIAppCustomBackgroundModes.xm | 17 +- Backgrounding/UnlimitedBackgrounding.xm | 52 ++--- 6 files changed, 192 insertions(+), 252 deletions(-) diff --git a/Backgrounding/BackgroundModeTogglerActivator.xm b/Backgrounding/BackgroundModeTogglerActivator.xm index f2f6408..426f7e1 100644 --- a/Backgrounding/BackgroundModeTogglerActivator.xm +++ b/Backgrounding/BackgroundModeTogglerActivator.xm @@ -9,12 +9,12 @@ static RAActivatorBackgrounderToggleModeListener *sharedInstance$RAActivatorBackgrounderToggleModeListener; @implementation RAActivatorBackgrounderToggleModeListener -- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event -{ +- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event { SBApplication *app = [UIApplication sharedApplication]._accessibilityFrontMostApplication; - if (!app) + if (!app) { return; + } BOOL dismissApp = [[%c(RASettings) sharedInstance] exitAppAfterUsingActivatorAction]; @@ -43,11 +43,10 @@ static RAActivatorBackgrounderToggleModeListener *sharedInstance$RAActivatorBack } @end -%ctor -{ - IF_SPRINGBOARD - { - sharedInstance$RAActivatorBackgrounderToggleModeListener = [[RAActivatorBackgrounderToggleModeListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorBackgrounderToggleModeListener forName:@"com.efrederickson.reachapp.backgrounder.togglemode"]; +%ctor { + IF_NOT_SPRINGBOARD { + return; } + sharedInstance$RAActivatorBackgrounderToggleModeListener = [[RAActivatorBackgrounderToggleModeListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorBackgrounderToggleModeListener forName:@"com.efrederickson.reachapp.backgrounder.togglemode"]; } diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 1303de6..f4abe75 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -12,51 +12,53 @@ NSMutableDictionary *indicatorStateDict = [[[NSMutableDictionary alloc] init] re #define GET_INFO (self.icon && self.icon.application ? GET_INFO_(self.icon.application.bundleIdentifier) : RAIconIndicatorViewInfoNone) -NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) -{ +NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) { NSString *ret = @""; - if (info & RAIconIndicatorViewInfoNone) + if (info & RAIconIndicatorViewInfoNone) { return nil; + } - if ([[%c(RASettings) sharedInstance] showNativeStateIconIndicators] && (info & RAIconIndicatorViewInfoNative)) + if ([[%c(RASettings) sharedInstance] showNativeStateIconIndicators] && (info & RAIconIndicatorViewInfoNative)) { ret = [ret stringByAppendingString:@"N"]; + } - if (info & RAIconIndicatorViewInfoForced) + if (info & RAIconIndicatorViewInfoForced) { ret = [ret stringByAppendingString:@"F"]; + } //if (info & RAIconIndicatorViewInfoForceDeath) // [ret appendString:@"D"]; - if (info & RAIconIndicatorViewInfoSuspendImmediately) + if (info & RAIconIndicatorViewInfoSuspendImmediately) { ret = [ret stringByAppendingString:@"ll"]; + } - if (info & RAIconIndicatorViewInfoUnkillable) + if (info & RAIconIndicatorViewInfoUnkillable) { ret = [ret stringByAppendingString:@"U"]; + } - if (info & RAIconIndicatorViewInfoUnlimitedBackgroundTime) + if (info & RAIconIndicatorViewInfoUnlimitedBackgroundTime) { ret = [ret stringByAppendingString:@"∞"]; + } return ret; } %hook SBIconView %property (nonatomic, assign) BOOL RA_isIconIndicatorInhibited; -%new -(void) RA_updateIndicatorView:(RAIconIndicatorViewInfo)info -{ +%new - (void)RA_updateIndicatorView:(RAIconIndicatorViewInfo)info { @autoreleasepool { - if (info == RAIconIndicatorViewInfoTemporarilyInhibit || info == RAIconIndicatorViewInfoInhibit) - { + if (info == RAIconIndicatorViewInfoTemporarilyInhibit || info == RAIconIndicatorViewInfoInhibit) { [[self viewWithTag:9962] removeFromSuperview]; [self RA_setIsIconIndicatorInhibited:YES]; - if (info == RAIconIndicatorViewInfoTemporarilyInhibit) + if (info == RAIconIndicatorViewInfoTemporarilyInhibit) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self RA_setIsIconIndicatorInhibited:NO showAgainImmediately:NO]; }); + } return; - } - else if (info == RAIconIndicatorViewInfoUninhibit) - { + } else if (info == RAIconIndicatorViewInfoUninhibit) { [self RA_setIsIconIndicatorInhibited:NO showAgainImmediately:NO]; } @@ -73,8 +75,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) } UILabel *badge = (UILabel*)[self viewWithTag:9962]; - if (!badge) - { + if (!badge) { badge = [[[UILabel alloc] init] retain]; badge.tag = 9962; @@ -86,47 +87,34 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) badge.backgroundColor = GET_COLORBADGES_COLOR(self.icon, THEMED(backgroundingIndicatorBackgroundColor)); //badge.textColor = GET_ACCEPTABLE_TEXT_COLOR(badge.backgroundColor, THEMED(backgroundingIndicatorTextColor)); - if (HAS_COLORBADGES && [%c(ColorBadges) isEnabled]) - { + if (HAS_COLORBADGES && [%c(ColorBadges) isEnabled]) { int bgColor = RGBFromUIColor(badge.backgroundColor); int txtColor = RGBFromUIColor(THEMED(backgroundingIndicatorTextColor)); - if ([%c(ColorBadges) isDarkColor:bgColor]) - { + if ([%c(ColorBadges) isDarkColor:bgColor]) { // dark color - if ([%c(ColorBadges) isDarkColor:txtColor]) - { + if ([%c(ColorBadges) isDarkColor:txtColor]) { // dark + dark badge.textColor = [UIColor whiteColor]; - } - else - { + } else { // dark + light badge.textColor = THEMED(backgroundingIndicatorTextColor); } - } - else - { + } else { // light color - if ([%c(ColorBadges) isDarkColor:txtColor]) - { + if ([%c(ColorBadges) isDarkColor:txtColor]) { // light + dark badge.textColor = THEMED(backgroundingIndicatorTextColor); - } - else - { + } else { //light + light badge.textColor = [UIColor blackColor]; } } - } - else - { + } else { badge.textColor = THEMED(backgroundingIndicatorTextColor); } UIImage *bgImage = [%c(SBIconBadgeView) _checkoutBackgroundImage]; - if (%c(ANEMSettingsManager) && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) - { + if (%c(ANEMSettingsManager) && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) { badge.backgroundColor = [UIColor colorWithPatternImage:bgImage]; } @@ -138,11 +126,9 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) badge.layer.cornerRadius = MAX(badge.frame.size.width, badge.frame.size.height) / 2.0; } - if (%c(ANEMSettingsManager) && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) - { + if (%c(ANEMSettingsManager) && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) { UIImageView *textImageView = (UIImageView*)[badge viewWithTag:42]; - if (!textImageView) - { + if (!textImageView) { CGFloat padding = [%c(SBIconBadgeView) _textPadding]; textImageView = [[UIImageView alloc] initWithFrame:CGRectMake(padding, padding, badge.frame.size.width - (padding * 2.0), badge.frame.size.height - (padding * 2.0))]; @@ -153,39 +139,34 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) UIImage *textImage = [%c(SBIconBadgeView) _checkoutImageForText:text highlighted:NO]; textImageView.image = textImage; - } - else + } else { [badge performSelectorOnMainThread:@selector(setText:) withObject:text waitUntilDone:YES]; + } SET_INFO(info); } } -%new -(void) RA_updateIndicatorViewWithExistingInfo -{ +%new - (void)RA_updateIndicatorViewWithExistingInfo { //if ([self viewWithTag:9962]) [self RA_updateIndicatorView:GET_INFO]; } -%new -(void) RA_setIsIconIndicatorInhibited:(BOOL)value -{ +%new - (void)RA_setIsIconIndicatorInhibited:(BOOL)value { [self RA_setIsIconIndicatorInhibited:value showAgainImmediately:YES]; } -%new -(void) RA_setIsIconIndicatorInhibited:(BOOL)value showAgainImmediately:(BOOL)value2 -{ +%new -(void) RA_setIsIconIndicatorInhibited:(BOOL)value showAgainImmediately:(BOOL)value2 { self.RA_isIconIndicatorInhibited = value; - if (value2 || value) - [self RA_updateIndicatorViewWithExistingInfo]; + if (value2 || value) { + [self RA_updateIndicatorViewWithExistingInfo]; + } } --(void) dealloc -{ - if (self) - { +- (void)dealloc { + if (self) { UIView *view = [self viewWithTag:9962]; - if (view) - { + if (view) { [view removeFromSuperview]; } } @@ -193,8 +174,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) %orig; } --(void) layoutSubviews -{ +- (void)layoutSubviews { %orig; //if ([self viewWithTag:9962] == nil) @@ -202,17 +182,13 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) // [self RA_updateIndicatorView:GET_INFO]; } -- (void)setIsEditing:(_Bool)arg1 animated:(_Bool)arg2 -{ +- (void)setIsEditing:(_Bool)arg1 animated:(_Bool)arg2 { %orig; - if (arg1) - { + if (arg1) { // inhibit icon indicator [self RA_setIsIconIndicatorInhibited:YES]; - } - else - { + } else { [self RA_setIsIconIndicatorInhibited:NO]; } } @@ -268,11 +244,9 @@ Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): *** Terminating a FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) */ -%new -(void) RA_addStatusBarIconForSelfIfOneDoesNotExist -{ +%new - (void)RA_addStatusBarIconForSelfIfOneDoesNotExist { #if DEBUG - if (![lsbitems respondsToSelector:@selector(objectForKey:)]) - { + if (![lsbitems respondsToSelector:@selector(objectForKey:)]) { LogError(@"ERROR: lsbitems is not NSDictionary it is %s", class_getName(lsbitems.class)); //@throw [NSException exceptionWithName:@"OH POOP" reason:@"Expected NSDictionary" userInfo:nil]; } @@ -281,17 +255,15 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) BOOL homescreenMapCheck = [%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)] && [[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]; BOOL homescreenIconViewMapCheck = [[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] containsObject:self.bundleIdentifier]; - if (%c(LSStatusBarItem) && ![lsbitems objectForKey:self.bundleIdentifier] && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) - { - if (homescreenMapCheck || homescreenIconViewMapCheck) - { + if (%c(LSStatusBarItem) && ![lsbitems objectForKey:self.bundleIdentifier] && [RABackgrounder.sharedInstance shouldShowStatusBarIconForIdentifier:self.bundleIdentifier]) { + if (homescreenMapCheck || homescreenIconViewMapCheck) { RAIconIndicatorViewInfo info = [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]; BOOL native = (info & RAIconIndicatorViewInfoNative); - if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) - { + if ((info & RAIconIndicatorViewInfoNone) == 0 && (!native || [[%c(RASettings) sharedInstance] shouldShowStatusBarNativeIcons])) { LSStatusBarItem *item = [[%c(LSStatusBarItem) alloc] initWithIdentifier:[NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier] alignment:StatusBarAlignmentLeft]; - if (![item customViewClass]) + if (![item customViewClass]) { item.customViewClass = @"RAAppIconStatusBarIconView"; + } item.imageName = [NSString stringWithFormat:@"multiplexer-%@",self.bundleIdentifier]; lsbitems[self.bundleIdentifier] = item; } @@ -299,48 +271,41 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) } } -- (void)setApplicationState:(unsigned int)arg1 -{ +- (void)setApplicationState:(unsigned int)arg1 { %orig; - if (!self.isRunning) - { + if (!self.isRunning) { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:RAIconIndicatorViewInfoNone]; //SET_INFO_(self.bundleIdentifier, RAIconIndicatorViewInfoNone); [lsbitems removeObjectForKey:self.bundleIdentifier]; - } - else - { - if ([self respondsToSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]) - [self performSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]; + } else { + if ([self respondsToSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]) { + [self performSelector:@selector(RA_addStatusBarIconForSelfIfOneDoesNotExist)]; + } [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:[RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]]; SET_INFO_(self.bundleIdentifier, [RABackgrounder.sharedInstance allAggregatedIndicatorInfoForIdentifier:self.bundleIdentifier]); } } -%new +(void) RA_clearAllStatusBarIcons -{ +%new + (void)RA_clearAllStatusBarIcons { [lsbitems removeAllObjects]; } -- (void)didAnimateActivation -{ +- (void)didAnimateActivation { //[RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:RAIconIndicatorViewInfoUninhibit]; [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:RAIconIndicatorViewInfoTemporarilyInhibit]; %orig; } -- (void)willAnimateActivation -{ +- (void)willAnimateActivation { [RABackgrounder.sharedInstance updateIconIndicatorForIdentifier:self.bundleIdentifier withInfo:RAIconIndicatorViewInfoInhibit]; %orig; } %end %hook SBIconViewMap -- (id) _iconViewForIcon:(unsafe_id)arg1 -{ +- (id)_iconViewForIcon:(unsafe_id)arg1 { SBIconView *iconView = %orig; [iconView RA_updateIndicatorViewWithExistingInfo]; @@ -356,24 +321,23 @@ FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) @interface UIStatusBarCustomItem : UIStatusBarItem @end -inline NSString *getAppNameFromIndicatorName(NSString *indicatorName) -{ +inline NSString *getAppNameFromIndicatorName(NSString *indicatorName) { return [indicatorName substringFromIndex:(@"multiplexer-").length]; } %subclass RAAppIconStatusBarIconView : UIStatusBarCustomItemView --(id) contentsImage -{ +- (id)contentsImage { UIImage *img = [ALApplicationList.sharedApplicationList iconOfSize:15 forDisplayIdentifier:getAppNameFromIndicatorName(self.item.indicatorName)]; return [_UILegibilityImageSet imageFromImage:img withShadowImage:img]; } --(CGFloat) standardPadding { return 4; } + +- (CGFloat)standardPadding { + return 4; +} %end %hook UIStatusBarCustomItem --(NSUInteger) leftOrder -{ - if ([self.indicatorName hasPrefix:@"multiplexer-"]) - { +- (NSUInteger)leftOrder { + if ([self.indicatorName hasPrefix:@"multiplexer-"]) { return 7; // Shows just after vpn, before the loading/sync indicator } return %orig; @@ -381,10 +345,8 @@ inline NSString *getAppNameFromIndicatorName(NSString *indicatorName) %end %end -%ctor -{ - if ([%c(RASettings) isLibStatusBarInstalled]) - { +%ctor { + if ([%c(RASettings) isLibStatusBarInstalled]) { %init(libstatusbar); } %init; diff --git a/Backgrounding/RABackgrounder.h b/Backgrounding/RABackgrounder.h index 3d63e12..de6d707 100644 --- a/Backgrounding/RABackgrounder.h +++ b/Backgrounding/RABackgrounder.h @@ -29,28 +29,28 @@ typedef NS_ENUM(NSInteger, RAIconIndicatorViewInfo) { NSString *FriendlyNameForBackgroundMode(RABackgroundMode mode); @interface RABackgrounder : NSObject -+(instancetype) sharedInstance; ++ (instancetype) sharedInstance; --(BOOL) shouldAutoLaunchApplication:(NSString*)identifier; --(BOOL) shouldAutoRelaunchApplication:(NSString*)identifier; +- (BOOL)shouldAutoLaunchApplication:(NSString*)identifier; +- (BOOL)shouldAutoRelaunchApplication:(NSString*)identifier; --(BOOL) shouldKeepInForeground:(NSString*)identifier; --(BOOL) shouldSuspendImmediately:(NSString*)identifier; +- (BOOL)shouldKeepInForeground:(NSString*)identifier; +- (BOOL)shouldSuspendImmediately:(NSString*)identifier; --(BOOL) killProcessOnExit:(NSString*)identifier; --(BOOL) shouldRemoveFromSwitcherWhenKilledOnExit:(NSString*)identifier; --(BOOL) preventKillingOfIdentifier:(NSString*)identifier; --(NSInteger) backgroundModeForIdentifier:(NSString*)identifier; --(BOOL) hasUnlimitedBackgroundTime:(NSString*)identifier; +- (BOOL)killProcessOnExit:(NSString*)identifier; +- (BOOL)shouldRemoveFromSwitcherWhenKilledOnExit:(NSString*)identifier; +- (BOOL)preventKillingOfIdentifier:(NSString*)identifier; +- (NSInteger)backgroundModeForIdentifier:(NSString*)identifier; +- (BOOL)hasUnlimitedBackgroundTime:(NSString*)identifier; --(void) temporarilyApplyBackgroundingMode:(RABackgroundMode)mode forApplication:(SBApplication*)app andCloseForegroundApp:(BOOL)close; --(void) queueRemoveTemporaryOverrideForIdentifier:(NSString*)identifier; --(void) removeTemporaryOverrideForIdentifier:(NSString*)identifier; +- (void)temporarilyApplyBackgroundingMode:(RABackgroundMode)mode forApplication:(SBApplication*)app andCloseForegroundApp:(BOOL)close; +- (void)queueRemoveTemporaryOverrideForIdentifier:(NSString*)identifier; +- (void)removeTemporaryOverrideForIdentifier:(NSString*)identifier; --(NSInteger) application:(NSString*)identifier overrideBackgroundMode:(NSString*)mode; +- (NSInteger)application:(NSString*)identifier overrideBackgroundMode:(NSString*)mode; --(RAIconIndicatorViewInfo) allAggregatedIndicatorInfoForIdentifier:(NSString*)identifier; --(void) updateIconIndicatorForIdentifier:(NSString*)identifier withInfo:(RAIconIndicatorViewInfo)info; --(BOOL) shouldShowIndicatorForIdentifier:(NSString*)identifier; --(BOOL) shouldShowStatusBarIconForIdentifier:(NSString*)identifier; +- (RAIconIndicatorViewInfo)allAggregatedIndicatorInfoForIdentifier:(NSString*)identifier; +- (void)updateIconIndicatorForIdentifier:(NSString*)identifier withInfo:(RAIconIndicatorViewInfo)info; +- (BOOL)shouldShowIndicatorForIdentifier:(NSString*)identifier; +- (BOOL)shouldShowStatusBarIconForIdentifier:(NSString*)identifier; @end diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index f960a3d..0f88200 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -2,10 +2,8 @@ #import "RASettings.h" #import "Multiplexer.h" -NSString *FriendlyNameForBackgroundMode(RABackgroundMode mode) -{ - switch (mode) - { +NSString *FriendlyNameForBackgroundMode(RABackgroundMode mode) { + switch (mode) { case RABackgroundModeNative: return LOCALIZE(@"NATIVE"); case RABackgroundModeForcedForeground: @@ -25,134 +23,133 @@ NSMutableDictionary *temporaryOverrides = [NSMutableDictionary dictionary]; NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; @implementation RABackgrounder -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE(RABackgrounder); } --(BOOL) shouldAutoLaunchApplication:(NSString*)identifier -{ - if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return NO; +- (BOOL)shouldAutoLaunchApplication:(NSString*)identifier { + if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) { + return NO; + } NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && (![dict objectForKey:@"autoLaunch"] ? NO : [dict[@"autoLaunch"] boolValue]); } --(BOOL) shouldAutoRelaunchApplication:(NSString*)identifier -{ - if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return NO; +- (BOOL)shouldAutoRelaunchApplication:(NSString*)identifier { + if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) { + return NO; + } NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; return ![self killProcessOnExit:identifier] && [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && (![dict objectForKey:@"autoRelaunch"] ? NO : [dict[@"autoRelaunch"] boolValue]); } --(NSInteger) popTemporaryOverrideForApplication:(NSString*)identifier -{ - if (!identifier) return -1; +- (NSInteger)popTemporaryOverrideForApplication:(NSString*)identifier { + if (!identifier) { + return -1; + } - if (![temporaryOverrides objectForKey:identifier]) + if (![temporaryOverrides objectForKey:identifier]) { return -1; + } RABackgroundMode override = (RABackgroundMode)[temporaryOverrides[identifier] intValue]; return override; } --(void) queueRemoveTemporaryOverrideForIdentifier:(NSString*)identifier -{ - if (!identifier) return; - +- (void)queueRemoveTemporaryOverrideForIdentifier:(NSString*)identifier { + if (!identifier) { + return; + } temporaryShouldPop[identifier] = @YES; } --(void) removeTemporaryOverrideForIdentifier:(NSString*)identifier -{ - if (!identifier) return; +- (void)removeTemporaryOverrideForIdentifier:(NSString*)identifier { + if (!identifier) { + return; + } - if ([temporaryShouldPop objectForKey:identifier] && [[temporaryShouldPop objectForKey:identifier] boolValue]) - { + if ([temporaryShouldPop objectForKey:identifier] && [[temporaryShouldPop objectForKey:identifier] boolValue]) { [temporaryShouldPop removeObjectForKey:identifier]; [temporaryOverrides removeObjectForKey:identifier]; } } --(NSInteger) popTemporaryOverrideForApplication:(NSString*)identifier is:(RABackgroundMode)mode -{ +- (NSInteger)popTemporaryOverrideForApplication:(NSString*)identifier is:(RABackgroundMode)mode { NSInteger popped = [self popTemporaryOverrideForApplication:identifier]; return popped == -1 ? -1 : (popped == mode ? 1 : 0); } --(RABackgroundMode) globalBackgroundMode -{ +- (RABackgroundMode)globalBackgroundMode { return (RABackgroundMode)[(RASettings*)[%c(RASettings) sharedInstance] globalBackgroundMode]; } --(BOOL) shouldKeepInForeground:(NSString*)identifier -{ +- (BOOL)shouldKeepInForeground:(NSString*)identifier { return [self backgroundModeForIdentifier:identifier] == RABackgroundModeForcedForeground; } --(BOOL) shouldSuspendImmediately:(NSString*)identifier -{ +- (BOOL)shouldSuspendImmediately:(NSString*)identifier { return [self backgroundModeForIdentifier:identifier] == RABackgroundModeSuspendImmediately; } --(BOOL) preventKillingOfIdentifier:(NSString*)identifier -{ - if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return NO; +- (BOOL)preventKillingOfIdentifier:(NSString*)identifier { + if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) { + return NO; + } NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && (![dict objectForKey:@"preventDeath"] ? NO : [dict[@"preventDeath"] boolValue]); } --(BOOL) shouldRemoveFromSwitcherWhenKilledOnExit:(NSString*)identifier -{ - if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) return NO; +- (BOOL)shouldRemoveFromSwitcherWhenKilledOnExit:(NSString*)identifier { + if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) { + return NO; + } NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"removeFromSwitcher"] ? [dict[@"removeFromSwitcher"] boolValue] : NO; return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled && (![dict objectForKey:@"removeFromSwitcher"] ? NO : [dict[@"removeFromSwitcher"] boolValue]); } --(NSInteger) backgroundModeForIdentifier:(NSString*)identifier -{ +- (NSInteger)backgroundModeForIdentifier:(NSString*)identifier { @autoreleasepool { - if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) + if (!identifier || ![[%c(RASettings) sharedInstance] backgrounderEnabled]) { return RABackgroundModeNative; + } NSInteger temporaryOverride = [self popTemporaryOverrideForApplication:identifier]; - if (temporaryOverride != -1) + if (temporaryOverride != -1) { return temporaryOverride; + } #if __has_feature(objc_arc) __weak // dictionary is cached by RASettings anyway #endif NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; - if (!enabled) + if (!enabled) { return [self globalBackgroundMode]; + } return [dict[@"backgroundMode"] intValue]; } } --(BOOL) hasUnlimitedBackgroundTime:(NSString*)identifier -{ +- (BOOL)hasUnlimitedBackgroundTime:(NSString*)identifier { return [self backgroundModeForIdentifier:identifier] == RABackgroundModeUnlimitedBackgroundingTime; } --(BOOL) killProcessOnExit:(NSString*)identifier -{ +- (BOOL)killProcessOnExit:(NSString*)identifier { return [self backgroundModeForIdentifier:identifier] == RABackgroundModeForceNone; } --(void) temporarilyApplyBackgroundingMode:(RABackgroundMode)mode forApplication:(SBApplication*)app andCloseForegroundApp:(BOOL)close -{ +- (void)temporarilyApplyBackgroundingMode:(RABackgroundMode)mode forApplication:(SBApplication*)app andCloseForegroundApp:(BOOL)close { temporaryOverrides[app.bundleIdentifier] = @(mode); [temporaryShouldPop removeObjectForKey:app.bundleIdentifier]; - if (close) - { + if (close) { FBWorkspaceEvent *event = [%c(FBWorkspaceEvent) eventWithName:@"ActivateSpringBoard" handler:^{ SBAppToAppWorkspaceTransaction *transaction = [%c(Multiplexer) createSBAppToAppWorkspaceTransactionForExitingApp:app]; [transaction begin]; @@ -161,52 +158,49 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; } } --(NSInteger) application:(NSString*)identifier overrideBackgroundMode:(NSString*)mode -{ +- (NSInteger)application:(NSString*)identifier overrideBackgroundMode:(NSString*)mode { NSDictionary *dict = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL enabled = [dict objectForKey:@"enabled"] ? [dict[@"enabled"] boolValue] : NO; id val = dict[@"backgroundModes"][mode]; return [[%c(RASettings) sharedInstance] backgrounderEnabled] && enabled ? (val ? [val boolValue] : -1) : -1; } --(RAIconIndicatorViewInfo) allAggregatedIndicatorInfoForIdentifier:(NSString*)identifier -{ +- (RAIconIndicatorViewInfo)allAggregatedIndicatorInfoForIdentifier:(NSString*)identifier { int info = RAIconIndicatorViewInfoNone; - if ([self backgroundModeForIdentifier:identifier] == RABackgroundModeNative) + if ([self backgroundModeForIdentifier:identifier] == RABackgroundModeNative) { info |= RAIconIndicatorViewInfoNative; - else if ([self backgroundModeForIdentifier:identifier] == RABackgroundModeForcedForeground) + } else if ([self backgroundModeForIdentifier:identifier] == RABackgroundModeForcedForeground) { info |= RAIconIndicatorViewInfoForced; - else if ([self shouldSuspendImmediately:identifier]) + } else if ([self shouldSuspendImmediately:identifier]) { info |= RAIconIndicatorViewInfoSuspendImmediately; - else if ([self hasUnlimitedBackgroundTime:identifier]) + } else if ([self hasUnlimitedBackgroundTime:identifier]) { info |= RAIconIndicatorViewInfoUnlimitedBackgroundTime; + } - if ([self killProcessOnExit:identifier]) + if ([self killProcessOnExit:identifier]) { info |= RAIconIndicatorViewInfoForceDeath; + } - if ([self preventKillingOfIdentifier:identifier]) + if ([self preventKillingOfIdentifier:identifier]) { info |= RAIconIndicatorViewInfoUnkillable; + } return (RAIconIndicatorViewInfo)info; } #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" --(void) updateIconIndicatorForIdentifier:(NSString*)identifier withInfo:(RAIconIndicatorViewInfo)info -{ +- (void)updateIconIndicatorForIdentifier:(NSString*)identifier withInfo:(RAIconIndicatorViewInfo)info { @autoreleasepool { SBIconView *ret = nil; if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { - if ([[[%c(SBIconViewMap) homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) - { + if ([[[%c(SBIconViewMap) homescreenMap] iconModel] respondsToSelector:@selector(applicationIconForBundleIdentifier:)]) { // iOS 8.0+ SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForBundleIdentifier:identifier]; ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; - } - else - { - // iOS 7.X + } else { + // iOS 7.X could support once all features are seperate tweaks? SBApplicationIcon *icon = [[[%c(SBIconViewMap) homescreenMap] iconModel] applicationIconForDisplayIdentifier:identifier]; ret = [[%c(SBIconViewMap) homescreenMap] mappedIconViewForIcon:icon]; } @@ -221,15 +215,13 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; #pragma GCC diagnostic pop --(BOOL) shouldShowIndicatorForIdentifier:(NSString*)identifier -{ +- (BOOL)shouldShowIndicatorForIdentifier:(NSString*)identifier { NSDictionary *dct = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL globalSetting = [[%c(RASettings) sharedInstance] shouldShowIconIndicatorsGlobally]; return globalSetting ? (![dct objectForKey:@"showIndicatorOnIcon"] ? YES : [dct[@"showIndicatorOnIcon"] boolValue]) : NO; } --(BOOL) shouldShowStatusBarIconForIdentifier:(NSString*)identifier -{ +- (BOOL)shouldShowStatusBarIconForIdentifier:(NSString*)identifier { NSDictionary *dct = [[%c(RASettings) sharedInstance] rawCompiledBackgrounderSettingsForIdentifier:identifier]; BOOL globalSetting = [[%c(RASettings) sharedInstance] shouldShowStatusBarIcons]; return globalSetting ? (![dct objectForKey:@"showStatusBarIcon"] ? YES : [dct[@"showStatusBarIcon"] boolValue]) : NO; diff --git a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm index b3d0654..6892a8f 100644 --- a/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm +++ b/Backgrounding/SpringBoard_UIAppCustomBackgroundModes.xm @@ -6,23 +6,21 @@ @interface FBApplicationInfo : NSObject @property (nonatomic, copy) NSString *bundleIdentifier; --(BOOL) isExitsOnSuspend; +- (BOOL)isExitsOnSuspend; @end %hook FBApplicationInfo -- (BOOL)supportsBackgroundMode:(__unsafe_unretained NSString *)mode -{ +- (BOOL)supportsBackgroundMode:(__unsafe_unretained NSString *)mode { int override = [RABackgrounder.sharedInstance application:self.bundleIdentifier overrideBackgroundMode:mode]; - if (override == -1) + if (override == -1) { return %orig; - + } return override; } %end %hook BKSProcessAssertion -- (id)initWithPID:(NSInteger)arg1 flags:(NSUInteger)arg2 reason:(NSUInteger)arg3 name:(NSString *)arg4 withHandler:(unsafe_id)arg5 -{ +- (instancetype)initWithPID:(NSInteger)arg1 flags:(NSUInteger)arg2 reason:(NSUInteger)arg3 name:(NSString *)arg4 withHandler:(unsafe_id)arg5 { if (arg3 != BKSProcessAssertionReasonViewServices && // whitelist this to allow share menu to work ![arg4 isEqualToString:@"Called by iOS6_iCleaner, from unknown method"] && // whitelist iCleaner to prevent crash on open ![arg4 isEqualToString:@"Called by Filza_main, from -[AppDelegate applicationDidEnterBackground:]"]) // Whitelist filza to prevent iOS hang (?!) Not sure if the springboard hack is still required @@ -34,10 +32,9 @@ //LogDebug(@"BKSProcessAssertion initWithPID:'%zd' flags:'%tu' reason:'%tu' name:'%@' withHandler:'%@' process identifier:'%@'", arg1, arg2, arg3, arg4, arg5, identifier); - if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) - { + if ([RABackgrounder.sharedInstance shouldSuspendImmediately:identifier]) { if ((arg3 >= BKSProcessAssertionReasonAudio && arg3 <= BKSProcessAssertionReasonVOiP)) // In most cases arg3 == 4 (finish task) - { + { //NSLog(@"[ReachApp] blocking BKSProcessAssertion"); //if (arg5) diff --git a/Backgrounding/UnlimitedBackgrounding.xm b/Backgrounding/UnlimitedBackgrounding.xm index 49c4ea1..42524c2 100644 --- a/Backgrounding/UnlimitedBackgrounding.xm +++ b/Backgrounding/UnlimitedBackgrounding.xm @@ -6,51 +6,41 @@ NSMutableDictionary *processAssertions = [NSMutableDictionary dictionary]; BKSProcessAssertion *keepAlive$temp; %hook FBUIApplicationWorkspaceScene --(void) host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 -{ - if ([RABackgrounder.sharedInstance hasUnlimitedBackgroundTime:arg1.identifier] && arg2.backgrounded && ![processAssertions objectForKey:arg1.identifier]) - { - SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:arg1.identifier]; - - keepAlive$temp = [[%c(BKSProcessAssertion) alloc] initWithPID:[app pid] - flags:(BKSProcessAssertionFlagPreventSuspend | BKSProcessAssertionFlagAllowIdleSleep | BKSProcessAssertionFlagPreventThrottleDownCPU | BKSProcessAssertionFlagWantsForegroundResourcePriority) - reason:BKSProcessAssertionReasonBackgroundUI - name:@"reachapp" - withHandler:^{ - LogInfo(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); - if (keepAlive$temp.valid) - processAssertions[arg1.identifier] = keepAlive$temp; - else - { - - } - }]; +- (void)host:(__unsafe_unretained FBScene*)arg1 didUpdateSettings:(__unsafe_unretained FBSSceneSettings*)arg2 withDiff:(unsafe_id)arg3 transitionContext:(unsafe_id)arg4 completion:(unsafe_id)arg5 { + if ([RABackgrounder.sharedInstance hasUnlimitedBackgroundTime:arg1.identifier] && arg2.backgrounded && ![processAssertions objectForKey:arg1.identifier]) { + SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:arg1.identifier]; + + keepAlive$temp = [[%c(BKSProcessAssertion) alloc] initWithPID:[app pid] flags:(BKSProcessAssertionFlagPreventSuspend | BKSProcessAssertionFlagAllowIdleSleep | BKSProcessAssertionFlagPreventThrottleDownCPU | BKSProcessAssertionFlagWantsForegroundResourcePriority) reason:BKSProcessAssertionReasonBackgroundUI name:@"reachapp" withHandler:^{ + LogInfo(@"ReachApp: %d kept alive: %@", [app pid], [keepAlive$temp valid] ? @"TRUE" : @"FALSE"); + if (keepAlive$temp.valid) { + processAssertions[arg1.identifier] = keepAlive$temp; + } + }]; } %orig(arg1, arg2, arg3, arg4, arg5); } %end @interface RAUnlimitedBackgroundingAppWatcher : NSObject -+(void) load; ++ (void)load; @end RAUnlimitedBackgroundingAppWatcher *sharedInstance$RAUnlimitedBackgroundingAppWatcher; @implementation RAUnlimitedBackgroundingAppWatcher -+(void) load -{ - IF_SPRINGBOARD { - sharedInstance$RAUnlimitedBackgroundingAppWatcher = [[RAUnlimitedBackgroundingAppWatcher alloc] init]; - [[%c(RARunningAppsProvider) sharedInstance] addTarget:sharedInstance$RAUnlimitedBackgroundingAppWatcher]; ++ (void)load { + IF_NOT_SPRINGBOARD { + return; } + sharedInstance$RAUnlimitedBackgroundingAppWatcher = [[RAUnlimitedBackgroundingAppWatcher alloc] init]; + [[%c(RARunningAppsProvider) sharedInstance] addTarget:sharedInstance$RAUnlimitedBackgroundingAppWatcher]; } --(void) appDidDie:(__unsafe_unretained SBApplication*)app -{ - if (/*W[RABackgrounder.sharedInstance preventKillingOfIdentifier:app.bundleIdentifier] == NO && */[processAssertions objectForKey:app.bundleIdentifier]) - { - [processAssertions[app.bundleIdentifier] invalidate]; - [processAssertions removeObjectForKey:app.bundleIdentifier]; +- (void)appDidDie:(__unsafe_unretained SBApplication*)app { + if (![processAssertions objectForKey:app.bundleIdentifier]) { + return; } + [processAssertions[app.bundleIdentifier] invalidate]; + [processAssertions removeObjectForKey:app.bundleIdentifier]; } @end From a65790c112acf23b3ac2250011292699a61ccbf1 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 17 Mar 2017 12:52:12 -0500 Subject: [PATCH 54/59] Biggest code reformat + UIBlurEffect --- Asphaleia.h | 19 +- BioLockdown.h | 9 +- ColorBadges.h | 22 +- DRM/Statistics.xm | 52 ++- Debugging/Core.xm | 6 +- GestureSupport/Hooks_iOS8.xm | 186 ++++---- GestureSupport/Hooks_iOS9.xm | 281 ++++++------ GestureSupport/RAGestureManager.h | 36 +- GestureSupport/RAGestureManager.xm | 137 +++--- KeyboardSupport/RAKeyboardStateListener.h | 7 +- KeyboardSupport/RAKeyboardStateListener.xm | 156 ++++--- KeyboardSupport/RAKeyboardWindow.h | 6 +- KeyboardSupport/RAKeyboardWindow.mm | 15 +- KeyboardSupport/RARemoteKeyboardView.h | 2 +- KeyboardSupport/RARemoteKeyboardView.xm | 23 +- .../RASpringBoardKeyboardActivation.h | 8 +- .../RASpringBoardKeyboardActivation.xm | 62 ++- Messaging/RAMessagingClient.h | 32 +- Messaging/RAMessagingClient.xm | 134 +++--- Messaging/RAMessagingServer.h | 36 +- Messaging/RAMessagingServer.xm | 252 ++++------- MissionControl/ActivatorListener.xm | 14 +- MissionControl/AppSwitcher.xm | 146 +++--- MissionControl/RAMissionControlManager.h | 14 +- MissionControl/RAMissionControlManager.xm | 197 ++++---- MissionControl/RAMissionControlPreviewView.h | 6 +- MissionControl/RAMissionControlPreviewView.xm | 38 +- MissionControl/RAMissionControlWindow.h | 10 +- MissionControl/RAMissionControlWindow.xm | 261 ++++------- Multiplexer.h | 12 +- Multiplexer.xm | 34 +- NotificationCenterApp/NCHook.xm | 84 ++-- NotificationCenterApp/RANCViewController.h | 6 +- NotificationCenterApp/RANCViewController.xm | 91 ++-- RAAppKiller.h | 9 +- RAAppKiller.xm | 27 +- RAAppSelectorView.h | 6 +- RAAppSelectorView.xm | 43 +- RAAppSliderProvider.h | 14 +- RAAppSliderProvider.mm | 70 +-- RAAppSliderProviderView.h | 16 +- RAAppSliderProviderView.mm | 68 ++- RAAppSwitcherModelWrapper.h | 10 +- RAAppSwitcherModelWrapper.xm | 35 +- RACompatibilitySystem.h | 11 +- RACompatibilitySystem.mm | 9 +- RAControlCenterInhibitor.h | 6 +- RAControlCenterInhibitor.xm | 33 +- RAFakePhoneMode.h | 12 +- RAFakePhoneMode.xm | 54 +-- RAHostManager.h | 8 +- RAHostManager.xm | 35 +- RAHostedAppView.h | 18 +- RAHostedAppView.xm | 239 +++++----- RAHostedWidgetView.xm | 23 +- RAInsetLabel.mm | 7 +- RALocalizer.h | 5 +- RALocalizer.mm | 24 +- RAOrientationLocker.h | 6 +- RAOrientationLocker.xm | 18 +- RAResourceImageProvider.h | 8 +- RAResourceImageProvider.mm | 55 +-- RARunningAppsProvider.h | 16 +- RARunningAppsProvider.xm | 47 +- RASBWorkspaceFetcher.h | 6 +- RASBWorkspaceFetcher.xm | 14 +- RASettings.h | 140 +++--- RASettings.mm | 265 ++++++----- RASnapshotProvider.h | 18 +- RASnapshotProvider.xm | 128 +++--- ReachAppIntegrator.h | 7 +- Reachability/RAReachabilityManager.h | 10 +- Reachability/RAReachabilityManager.mm | 15 +- Reachability/Reachability.xm | 422 ++++++++---------- Reachability/UIKit.xm | 9 +- SKBounceAnimation.h | 4 +- SpringBoard.xm | 111 ++--- SwipeOver/RASwipeOverManager.h | 22 +- SwipeOver/RASwipeOverManager.xm | 134 +++--- SwipeOver/RASwipeOverOverlay.h | 16 +- SwipeOver/RASwipeOverOverlay.xm | 69 ++- SwipeOver/SwipeOverGesture.xm | 129 +++--- Theming/RAThemeLoader.h | 6 +- Theming/RAThemeLoader.mm | 51 +-- Theming/RAThemeManager.h | 10 +- Theming/RAThemeManager.mm | 33 +- Tweak.xm | 11 +- UIAlertController+Window.m | 24 +- UIColor+HexString.h | 2 +- UIColor+HexString.m | 73 +-- UIKit.xm | 152 +++---- .../ActivatorCreateAppWindow.xm | 17 +- .../ActivatorToggleEditModeListener.xm | 35 +- WindowedMultitasking/LaunchToWindow.xm | 34 +- WindowedMultitasking/RADesktopManager.h | 40 +- WindowedMultitasking/RADesktopManager.xm | 112 ++--- WindowedMultitasking/RADesktopWindow.h | 42 +- WindowedMultitasking/RADesktopWindow.mm | 260 ++++++----- WindowedMultitasking/RAWindowBar.h | 38 +- WindowedMultitasking/RAWindowBar.xm | 412 ++++++++--------- WindowedMultitasking/RAWindowOverlayView.h | 6 +- WindowedMultitasking/RAWindowOverlayView.xm | 68 ++- .../RAWindowSnapDataProvider.h | 10 +- .../RAWindowSnapDataProvider.xm | 122 +++-- WindowedMultitasking/RAWindowSorter.h | 4 +- WindowedMultitasking/RAWindowSorter.xm | 75 ++-- .../RAWindowStatePreservationSystemManager.h | 20 +- .../RAWindowStatePreservationSystemManager.xm | 39 +- .../StartMultitaskingGesture.xm | 56 +-- WindowedMultitasking/WindowSorterActivator.xm | 14 +- dispatch_after_cancel.m | 49 +- headers.h | 11 +- reachappassertiondhooks/Tweak.xm | 19 +- reachappbackboarddhooks/Tweak.xm | 69 +-- reachappfakephonemode/Tweak.xm | 36 +- reachappflipswitch/Switch.x | 11 +- reachappfsdaemon/main.mm | 3 +- .../BackgroundPerAppDetailsController.h | 5 +- .../BackgroundPerAppDetailsController.xm | 47 +- reachappsettings/BackgrounderPerApp.xm | 153 +++---- reachappsettings/BackgrounderSettings.xm | 81 ++-- reachappsettings/MissionControlSettings.xm | 54 ++- reachappsettings/NCApp.xm | 86 ++-- reachappsettings/RAHeaderView.h | 8 +- reachappsettings/RAHeaderView.mm | 40 +- reachappsettings/RAListItemsController.xm | 32 +- reachappsettings/RASupportController.xm | 55 ++- reachappsettings/ReachAppSettings.mm | 75 ++-- reachappsettings/Reachability.xm | 78 ++-- reachappsettings/SwipeOver.xm | 62 +-- reachappsettings/WindowedMultitasking.xm | 405 +++++++++-------- widgets/Core/RAWidgetBase.h | 10 +- widgets/Core/RAWidgetBase.xm | 17 +- widgets/Core/RAWidgetHostManager.h | 10 +- widgets/Core/RAWidgetHostManager.xm | 33 +- widgets/Reachability/RAAllAppsWidget.xm | 58 +-- widgets/Reachability/RADefaultWidgetSection.h | 2 +- .../Reachability/RADefaultWidgetSection.mm | 12 +- widgets/Reachability/RAFavoriteAppsWidget.xm | 54 ++- widgets/Reachability/RARecentAppsWidget.xm | 54 ++- widgets/Reachability/RAWidget.h | 10 +- widgets/Reachability/RAWidget.mm | 14 +- widgets/Reachability/RAWidgetSection.h | 22 +- widgets/Reachability/RAWidgetSection.mm | 40 +- widgets/Reachability/RAWidgetSectionManager.h | 12 +- .../Reachability/RAWidgetSectionManager.mm | 58 ++- 146 files changed, 3833 insertions(+), 4563 deletions(-) diff --git a/Asphaleia.h b/Asphaleia.h index ac77054..46607bb 100644 --- a/Asphaleia.h +++ b/Asphaleia.h @@ -37,12 +37,13 @@ typedef void (^ASCommonAuthenticationHandler) (BOOL wasCancelled); #define IF_ASPHALEIA if (HAS_ASPHALEIA) #define ASPHALEIA_AUTHENTICATE_APP(ident, success, failure_) \ - BOOL isAppProtected = [[objc_getClass("ASCommon") sharedInstance] authenticateAppWithDisplayIdentifier:ident customMessage:nil dismissedHandler:^(BOOL wasCancelled) { \ - if (!wasCancelled) \ - success(); \ - else \ - failure_(); \ - }]; \ - if (!isAppProtected) { \ - success(); \ - } + BOOL isAppProtected = [[objc_getClass("ASCommon") sharedInstance] authenticateAppWithDisplayIdentifier:ident customMessage:nil dismissedHandler:^(BOOL wasCancelled) { \ + if (!wasCancelled) { \ + success(); \ + } else { \ + failure_(); \ + } \ + }]; \ + if (!isAppProtected) { \ + success(); \ + } diff --git a/BioLockdown.h b/BioLockdown.h index b2b16ab..195ff6b 100644 --- a/BioLockdown.h +++ b/BioLockdown.h @@ -26,9 +26,8 @@ __attribute__((visibility("hidden"))) #define IF_BIOLOCKDOWN if (HAS_BIOLOCKDOWN) #define BIOLOCKDOWN_AUTHENTICATE_APP(ident, success, failure_) \ - if ([[objc_getClass("BioLockdownController") sharedController] requiresAuthenticationForIdentifier:ident]) \ - { \ + if ([[objc_getClass("BioLockdownController") sharedController] requiresAuthenticationForIdentifier:ident]) { \ [[objc_getClass("BioLockdownController") sharedController] authenticateForIdentifier:ident actionDescription:LOCALIZE(@"BIOLOCKDOWN_AUTH_DESCRIPTION") completion:success failure:failure_]; \ - } \ - else \ - success() + } else { \ + success(); \ + } diff --git a/ColorBadges.h b/ColorBadges.h index 805343d..a4a4143 100644 --- a/ColorBadges.h +++ b/ColorBadges.h @@ -41,19 +41,17 @@ @end */ -static inline int RGBFromUIColor(UIColor *self) -{ - CGFloat red, green, blue; - if ([self getRed:&red green:&green blue:&blue alpha:NULL]) - { - NSUInteger redInt = (NSUInteger)(red * 255 + 0.5); - NSUInteger greenInt = (NSUInteger)(green * 255 + 0.5); - NSUInteger blueInt = (NSUInteger)(blue * 255 + 0.5); - - return (redInt << 16) | (greenInt << 8) | blueInt; - } +static inline int RGBFromUIColor(UIColor *self) { + CGFloat red, green, blue; + if ([self getRed:&red green:&green blue:&blue alpha:NULL]) { + NSUInteger redInt = (NSUInteger)(red * 255 + 0.5); + NSUInteger greenInt = (NSUInteger)(green * 255 + 0.5); + NSUInteger blueInt = (NSUInteger)(blue * 255 + 0.5); + + return (redInt << 16) | (greenInt << 8) | blueInt; + } - return 0; + return 0; } #define HAS_COLORBADGES (objc_getClass("ColorBadges") != nil) diff --git a/DRM/Statistics.xm b/DRM/Statistics.xm index 55f36bd..ca96103 100644 --- a/DRM/Statistics.xm +++ b/DRM/Statistics.xm @@ -1,32 +1,30 @@ #import "headers.h" -%ctor -{ - IF_SPRINGBOARD { - #if DEBUG - LogInfo(@"[ReachApp][DRM] Not checking statistics on debug build"); - #else - dispatch_async(dispatch_get_main_queue(), ^(void){ - NSString *statsPath = @"/var/mobile/Library/Preferences/.multiplexer.stats_checked"; - if (![NSFileManager.defaultManager fileExistsAtPath:statsPath]) - { - CFStringRef (*$MGCopyAnswer)(CFStringRef); +%ctor { + IF_NOT_SPRINGBOARD { + return; + } +#if DEBUG + LogInfo(@"[ReachApp][DRM] Not checking statistics on debug build"); +#else + dispatch_async(dispatch_get_main_queue(), ^(void){ + NSString *statsPath = @"/var/mobile/Library/Preferences/.multiplexer.stats_checked"; + if (![NSFileManager.defaultManager fileExistsAtPath:statsPath]) { + CFStringRef (*$MGCopyAnswer)(CFStringRef); - void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); - $MGCopyAnswer = (CFStringRef (*)(CFStringRef))dlsym(gestalt, "MGCopyAnswer"); + void *gestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); + $MGCopyAnswer = (CFStringRef (*)(CFStringRef))dlsym(gestalt, "MGCopyAnswer"); - NSString *udid = (__bridge NSString*)$MGCopyAnswer(CFSTR("UniqueDeviceID")); - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://elijahandandrew.com/multiplexer/stats.php?udid=%@", udid]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]; - [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; - int code = [httpResponse statusCode]; - if (!error && (code == 0 || code == 200)) - { - [NSFileManager.defaultManager createFileAtPath:statsPath contents:[NSData new] attributes:nil]; - } - }]; - } - }); - #endif - } + NSString *udid = (__bridge NSString*)$MGCopyAnswer(CFSTR("UniqueDeviceID")); + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://elijahandandrew.com/multiplexer/stats.php?udid=%@", udid]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]; + [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; + int code = [httpResponse statusCode]; + if (!error && (code == 0 || code == 200)) { + [NSFileManager.defaultManager createFileAtPath:statsPath contents:[NSData new] attributes:nil]; + } + }]; + } + }); +#endif } diff --git a/Debugging/Core.xm b/Debugging/Core.xm index 994d0be..e733810 100644 --- a/Debugging/Core.xm +++ b/Debugging/Core.xm @@ -7,14 +7,12 @@ #import "headers.h" %hook NSObject -- (void)doesNotRecognizeSelector:(SEL)selector -{ +- (void)doesNotRecognizeSelector:(SEL)selector { LogDebug(@"[ReachApp] doesNotRecognizeSelector: selector '%@' on class '%s' (image: %s)", NSStringFromSelector(selector), class_getName(self.class), class_getImageName(self.class)); NSArray *symbols = [NSThread callStackSymbols]; LogDebug(@"[ReachApp] Obtained %zd stack frames:\n", symbols.count); - for (NSString *symbol in symbols) - { + for (NSString *symbol in symbols) { LogDebug(@"[ReachApp] %@\n", symbol); } diff --git a/GestureSupport/Hooks_iOS8.xm b/GestureSupport/Hooks_iOS8.xm index f95cda1..1e3b512 100644 --- a/GestureSupport/Hooks_iOS8.xm +++ b/GestureSupport/Hooks_iOS8.xm @@ -8,7 +8,7 @@ License (GPL): https://github.com/hamzasood/MultitaskingGestures/blob/master/Lic */ @interface _UIScreenEdgePanRecognizer (Velocity) --(CGPoint) RA_velocity; +- (CGPoint)RA_velocity; @end static BOOL isTracking = NO; @@ -22,8 +22,7 @@ typedef struct { } VelocityData; %hook _UIScreenEdgePanRecognizer -- (void)incorporateTouchSampleAtLocation:(CGPoint)location timestamp:(double)timestamp modifier:(NSInteger)modifier interfaceOrientation:(UIInterfaceOrientation)orientation -{ +- (void)incorporateTouchSampleAtLocation:(CGPoint)location timestamp:(double)timestamp modifier:(NSInteger)modifier interfaceOrientation:(UIInterfaceOrientation)orientation { %orig; VelocityData newData; @@ -43,8 +42,7 @@ typedef struct { } %new -- (CGPoint)RA_velocity -{ +- (CGPoint)RA_velocity { VelocityData data; [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&data]; @@ -53,119 +51,101 @@ typedef struct { %end %hook SBHandMotionExtractor --(id) init -{ - if ((self = %orig)) - { - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - [recognizer setDelegate:(id<_UIScreenEdgePanRecognizerDelegate>)self]; +- (id)init { + if ((self = %orig)) { + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + [recognizer setDelegate:(id<_UIScreenEdgePanRecognizerDelegate>)self]; } - return self; + } + return self; } --(void) extractHandMotionForActiveTouches:(SBActiveTouch*) activeTouches count:(NSUInteger)count centroid:(CGPoint)centroid -{ - %orig; - dispatch_async(dispatch_get_main_queue(), ^{ - if (count > 0) { - SBActiveTouch touch = activeTouches[0]; - if (touch.type == 0) // Begin - { - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - [recognizer incorporateTouchSampleAtLocation:touch.unrotatedLocation timestamp:CACurrentMediaTime() modifier:touch.modifier interfaceOrientation:touch.interfaceOrientation]; - isTracking = YES; - } - else if (isTracking) // Move - { - _UIScreenEdgePanRecognizer *targetRecognizer = nil; - - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - { - [recognizer incorporateTouchSampleAtLocation:touch.unrotatedLocation timestamp:CACurrentMediaTime() modifier:touch.modifier interfaceOrientation:touch.interfaceOrientation]; - - if (recognizer.targetEdges & currentEdge) - targetRecognizer = recognizer; - } - [RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateChanged withPoint:touch.location velocity:targetRecognizer.RA_velocity forEdge:currentEdge]; - } +- (void)extractHandMotionForActiveTouches:(SBActiveTouch*) activeTouches count:(NSUInteger)count centroid:(CGPoint)centroid { + %orig; + dispatch_async(dispatch_get_main_queue(), ^{ + if (count > 0) { + SBActiveTouch touch = activeTouches[0]; + if (touch.type == 0) { //begin + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + [recognizer incorporateTouchSampleAtLocation:touch.unrotatedLocation timestamp:CACurrentMediaTime() modifier:touch.modifier interfaceOrientation:touch.interfaceOrientation]; } - }); -} + isTracking = YES; + } else if (isTracking) { //move + _UIScreenEdgePanRecognizer *targetRecognizer = nil; -%new -(void) screenEdgePanRecognizerStateDidChange:(_UIScreenEdgePanRecognizer*) screenEdgePanRecognizer -{ - if (screenEdgePanRecognizer.state == UIGestureRecognizerStateBegan) - { - CGPoint location = MSHookIvar(screenEdgePanRecognizer, "_lastTouchLocation"); + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + [recognizer incorporateTouchSampleAtLocation:touch.unrotatedLocation timestamp:CACurrentMediaTime() modifier:touch.modifier interfaceOrientation:touch.interfaceOrientation]; - // Adjust for the two unsupported orientations... what... - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft && (location.x != 0 && location.y != 0)) - { - location.x = UIScreen.mainScreen.bounds.size.width - location.x; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown && (location.x != 0 && location.y != 0)) - { - location.x = UIScreen.mainScreen.bounds.size.width - location.x; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { - CGFloat t = location.y; - location.y = location.x; - location.x = t; + if (recognizer.targetEdges & currentEdge) { + targetRecognizer = recognizer; + } } + [RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateChanged withPoint:touch.location velocity:targetRecognizer.RA_velocity forEdge:currentEdge]; + } + } + }); +} - if ([RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateBegan withPoint:location velocity:screenEdgePanRecognizer.RA_velocity forEdge:screenEdgePanRecognizer.targetEdges]) - { - currentEdge = screenEdgePanRecognizer.targetEdges; - BKSHIDServicesCancelTouchesOnMainDisplay(); // This is needed or open apps, etc will still get touch events. For example open settings app + swipeover without this line and you can still scroll up/down through the settings - } +%new - (void)screenEdgePanRecognizerStateDidChange:(_UIScreenEdgePanRecognizer*)screenEdgePanRecognizer { + if (screenEdgePanRecognizer.state == UIGestureRecognizerStateBegan) { + CGPoint location = MSHookIvar(screenEdgePanRecognizer, "_lastTouchLocation"); + + // Adjust for the two unsupported orientations... what... + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft && (location.x != 0 && location.y != 0)) { + location.x = UIScreen.mainScreen.bounds.size.width - location.x; + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown && (location.x != 0 && location.y != 0)) { + location.x = UIScreen.mainScreen.bounds.size.width - location.x; + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { + CGFloat t = location.y; + location.y = location.x; + location.x = t; } + + if ([RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateBegan withPoint:location velocity:screenEdgePanRecognizer.RA_velocity forEdge:screenEdgePanRecognizer.targetEdges]) { + currentEdge = screenEdgePanRecognizer.targetEdges; + BKSHIDServicesCancelTouchesOnMainDisplay(); // This is needed or open apps, etc will still get touch events. For example open settings app + swipeover without this line and you can still scroll up/down through the settings + } + } } --(void) clear -{ - dispatch_async(dispatch_get_main_queue(), ^{ - if (isTracking) // Ended - { - _UIScreenEdgePanRecognizer *targetRecognizer = nil; - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - { - if (recognizer.targetEdges & currentEdge) - targetRecognizer = recognizer; - } - - [RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateEnded withPoint:CGPointZero velocity:targetRecognizer.RA_velocity forEdge:currentEdge]; - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - [recognizer reset]; // remove current touches it's "incorporated" - currentEdge = UIRectEdgeNone; - isTracking = NO; +- (void)clear { + dispatch_async(dispatch_get_main_queue(), ^{ + if (isTracking) { //ended + _UIScreenEdgePanRecognizer *targetRecognizer = nil; + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + if (recognizer.targetEdges & currentEdge) { + targetRecognizer = recognizer; } - }); - %orig; + } + + [RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateEnded withPoint:CGPointZero velocity:targetRecognizer.RA_velocity forEdge:currentEdge]; + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + [recognizer reset]; // remove current touches it's "incorporated" + } + currentEdge = UIRectEdgeNone; + isTracking = NO; + } + }); + %orig; } %end -%ctor -{ - IF_SPRINGBOARD - { - if (IS_IOS_OR_NEWER(iOS_9_0)) - return; - - class_addProtocol(%c(SBHandMotionExtractor), @protocol(_UIScreenEdgePanRecognizerDelegate)); - - UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; - int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); - gestureRecognizers = [[NSMutableSet alloc] initWithCapacity:edgeCount]; - for (int i = 0; i < edgeCount; i++) - { - _UIScreenEdgePanRecognizer *recognizer = [[_UIScreenEdgePanRecognizer alloc] initWithType:2]; - recognizer.targetEdges = edgesToWatch[i]; - recognizer.screenBounds = UIScreen.mainScreen.bounds; - [gestureRecognizers addObject:recognizer]; - } +%ctor { + if (IS_IOS_OR_NEWER(iOS_9_0) || !IS_SPRINGBOARD) { + return; + } - %init; - } + class_addProtocol(%c(SBHandMotionExtractor), @protocol(_UIScreenEdgePanRecognizerDelegate)); + + UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; + int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); + gestureRecognizers = [[NSMutableSet alloc] initWithCapacity:edgeCount]; + for (int i = 0; i < edgeCount; i++) { + _UIScreenEdgePanRecognizer *recognizer = [[_UIScreenEdgePanRecognizer alloc] initWithType:2]; + recognizer.targetEdges = edgesToWatch[i]; + recognizer.screenBounds = UIScreen.mainScreen.bounds; + [gestureRecognizers addObject:recognizer]; + } + %init; } diff --git a/GestureSupport/Hooks_iOS9.xm b/GestureSupport/Hooks_iOS9.xm index 4d8826a..24b7f0d 100644 --- a/GestureSupport/Hooks_iOS9.xm +++ b/GestureSupport/Hooks_iOS9.xm @@ -16,7 +16,7 @@ typedef void* (*clientCreatePointer)(const CFAllocatorRef); extern "C" void BKSHIDServicesCancelTouchesOnMainDisplay(); @interface _UIScreenEdgePanRecognizer (Velocity) --(CGPoint) RA_velocity; +- (CGPoint)RA_velocity; @end static BOOL isTracking = NO; @@ -30,33 +30,31 @@ typedef struct { } VelocityData; %hook _UIScreenEdgePanRecognizer -- (void)incorporateTouchSampleAtLocation:(CGPoint)location timestamp:(double)timestamp modifier:(NSInteger)modifier interfaceOrientation:(UIInterfaceOrientation)orientation forceState:(int)arg5 -{ - %orig; +- (void)incorporateTouchSampleAtLocation:(CGPoint)location timestamp:(double)timestamp modifier:(NSInteger)modifier interfaceOrientation:(UIInterfaceOrientation)orientation forceState:(int)arg5 { + %orig; - VelocityData newData; - VelocityData oldData; + VelocityData newData; + VelocityData oldData; - [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&oldData]; + [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&oldData]; - // this is really quite simple, it calculates a velocity based off of - // (current location - last location) / (time taken to move from last location to current location) - // which effectively gives you a CGPoint of where it would end if the user continued the gesture. - CGPoint velocity = CGPointMake((location.x - oldData.location.x) / (timestamp - oldData.timestamp), (location.y - oldData.location.y) / (timestamp - oldData.timestamp)); - newData.velocity = velocity; - newData.location = location; - newData.timestamp = timestamp; + // this is really quite simple, it calculates a velocity based off of + // (current location - last location) / (time taken to move from last location to current location) + // which effectively gives you a CGPoint of where it would end if the user continued the gesture. + CGPoint velocity = CGPointMake((location.x - oldData.location.x) / (timestamp - oldData.timestamp), (location.y - oldData.location.y) / (timestamp - oldData.timestamp)); + newData.velocity = velocity; + newData.location = location; + newData.timestamp = timestamp; - objc_setAssociatedObject(self, @selector(RA_velocityData), [NSValue valueWithBytes:&newData objCType:@encode(VelocityData)], OBJC_ASSOCIATION_RETAIN); + objc_setAssociatedObject(self, @selector(RA_velocityData), [NSValue valueWithBytes:&newData objCType:@encode(VelocityData)], OBJC_ASSOCIATION_RETAIN); } %new -- (CGPoint)RA_velocity -{ - VelocityData data; - [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&data]; +- (CGPoint)RA_velocity { + VelocityData data; + [objc_getAssociatedObject(self, @selector(RA_velocityData)) getValue:&data]; - return data.velocity; + return data.velocity; } %end @@ -65,163 +63,138 @@ typedef struct { @end @implementation Hooks9$SBHandMotionExtractorReplacementByMultiplexer --(instancetype) init -{ - if (self = [super init]) - { - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - [recognizer setDelegate:(id<_UIScreenEdgePanRecognizerDelegate>)self]; +- (instancetype)init { + if (self = [super init]) { + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + [recognizer setDelegate:(id<_UIScreenEdgePanRecognizerDelegate>)self]; } - return self; + } + return self; } --(void) screenEdgePanRecognizerStateDidChange:(_UIScreenEdgePanRecognizer*) screenEdgePanRecognizer -{ - if (screenEdgePanRecognizer.state == UIGestureRecognizerStateBegan) - { - CGPoint location = MSHookIvar(screenEdgePanRecognizer, "_lastTouchLocation"); +- (void)screenEdgePanRecognizerStateDidChange:(_UIScreenEdgePanRecognizer*)screenEdgePanRecognizer { + if (screenEdgePanRecognizer.state == UIGestureRecognizerStateBegan) { + CGPoint location = MSHookIvar(screenEdgePanRecognizer, "_lastTouchLocation"); + + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft && (location.x != 0 && location.y != 0)) { + location.x = UIScreen.mainScreen.bounds.size.width - location.x; + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown && (location.x != 0 && location.y != 0)) { + location.x = UIScreen.mainScreen.bounds.size.width - location.x; + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { + CGFloat t = location.y; + location.y = location.x; + location.x = t; + } + LogDebug(@"[ReachApp] _UIScreenEdgePanRecognizer location: %@", NSStringFromCGPoint(location)); + if ([RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateBegan withPoint:location velocity:screenEdgePanRecognizer.RA_velocity forEdge:screenEdgePanRecognizer.targetEdges]) { + currentEdge9 = screenEdgePanRecognizer.targetEdges; + BKSHIDServicesCancelTouchesOnMainDisplay(); // This is needed or open apps, etc will still get touch events. For example open settings app + swipeover without this line and you can still scroll up/down through the settings + } + } +} +@end - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft && (location.x != 0 && location.y != 0)) - { - location.x = UIScreen.mainScreen.bounds.size.width - location.x; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown && (location.x != 0 && location.y != 0)) - { - location.x = UIScreen.mainScreen.bounds.size.width - location.x; +void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event) { + if (IOHIDEventGetType(event) == kIOHIDEventTypeDigitizer) { + NSArray *children = (__bridge NSArray *)IOHIDEventGetChildren(event); + if ([children count] == 1) { + float density = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerDensity); + + float x = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerX) * UIScreen.mainScreen._referenceBounds.size.width; + float y = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerY) * UIScreen.mainScreen._referenceBounds.size.height; + CGPoint location = (CGPoint) { x, y }; + + UIInterfaceOrientation interfaceOrientation = GET_STATUSBAR_ORIENTATION; + + float rotatedX = x; + float rotatedY = y; + + if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) { + rotatedX = y; + rotatedY = UIScreen.mainScreen.bounds.size.height - x; + } else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { + rotatedX = UIScreen.mainScreen._referenceBounds.size.height - y; + rotatedY = x; + } + + CGPoint rotatedLocation = (CGPoint) { rotatedX, rotatedY }; + + LogInfo(@"[ReachApp] (%f, %d) %@ -> %@", density, isTracking, NSStringFromCGPoint(location), NSStringFromCGPoint(rotatedLocation)); + + if (!isTracking) { + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + [recognizer incorporateTouchSampleAtLocation:location timestamp:CACurrentMediaTime() modifier:1 interfaceOrientation:interfaceOrientation forceState:0]; } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { - CGFloat t = location.y; - location.y = location.x; - location.x = t; + isTracking = YES; + } else if (density == 0 && isTracking) { + _UIScreenEdgePanRecognizer *targetRecognizer = nil; + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + if (recognizer.targetEdges & currentEdge9) { + targetRecognizer = recognizer; + } } - LogDebug(@"[ReachApp] _UIScreenEdgePanRecognizer location: %@", NSStringFromCGPoint(location)); - if ([RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateBegan withPoint:location velocity:screenEdgePanRecognizer.RA_velocity forEdge:screenEdgePanRecognizer.targetEdges]) - { - currentEdge9 = screenEdgePanRecognizer.targetEdges; - BKSHIDServicesCancelTouchesOnMainDisplay(); // This is needed or open apps, etc will still get touch events. For example open settings app + swipeover without this line and you can still scroll up/down through the settings + + [RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateEnded withPoint:CGPointZero velocity:targetRecognizer.RA_velocity forEdge:currentEdge9]; + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + [recognizer reset]; // remove current touches it's "incorporated" } - } -} -@end + currentEdge9 = UIRectEdgeNone; + isTracking = NO; -void touch_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event) -{ - if (IOHIDEventGetType(event) == kIOHIDEventTypeDigitizer) - { - NSArray *children = (__bridge NSArray *)IOHIDEventGetChildren(event); - if ([children count] == 1) - { - float density = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerDensity); - - float x = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerX) * UIScreen.mainScreen._referenceBounds.size.width; - float y = IOHIDEventGetFloatValue((__bridge __IOHIDEvent *)children[0], (IOHIDEventField)kIOHIDEventFieldDigitizerY) * UIScreen.mainScreen._referenceBounds.size.height; - CGPoint location = (CGPoint) { x, y }; - - UIInterfaceOrientation interfaceOrientation = GET_STATUSBAR_ORIENTATION; - - float rotatedX = x; - float rotatedY = y; - - if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) - { - rotatedX = y; - rotatedY = UIScreen.mainScreen.bounds.size.height - x; - } - else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) - { - rotatedX = UIScreen.mainScreen._referenceBounds.size.height - y; - rotatedY = x; - } - - CGPoint rotatedLocation = (CGPoint) { rotatedX, rotatedY }; - - LogInfo(@"[ReachApp] (%f, %d) %@ -> %@", density, isTracking, NSStringFromCGPoint(location), NSStringFromCGPoint(rotatedLocation)); - - if (!isTracking) - { - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - [recognizer incorporateTouchSampleAtLocation:location timestamp:CACurrentMediaTime() modifier:1 interfaceOrientation:interfaceOrientation forceState:0]; - isTracking = YES; - } - else if (density == 0 && isTracking) - { - _UIScreenEdgePanRecognizer *targetRecognizer = nil; - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - { - if (recognizer.targetEdges & currentEdge9) - targetRecognizer = recognizer; - } - - [RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateEnded withPoint:CGPointZero velocity:targetRecognizer.RA_velocity forEdge:currentEdge9]; - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - [recognizer reset]; // remove current touches it's "incorporated" - currentEdge9 = UIRectEdgeNone; - isTracking = NO; - - LogInfo(@"[ReachApp] touch ended."); - } - else - { - _UIScreenEdgePanRecognizer *targetRecognizer = nil; - - for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) - { - [recognizer incorporateTouchSampleAtLocation:location timestamp:CACurrentMediaTime() modifier:1 interfaceOrientation:interfaceOrientation forceState:0]; - - if (recognizer.targetEdges & currentEdge9) - targetRecognizer = recognizer; - } - [RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateChanged withPoint:rotatedLocation velocity:targetRecognizer.RA_velocity forEdge:currentEdge9]; - } + LogInfo(@"[ReachApp] touch ended."); + } else { + _UIScreenEdgePanRecognizer *targetRecognizer = nil; + for (_UIScreenEdgePanRecognizer *recognizer in gestureRecognizers) { + [recognizer incorporateTouchSampleAtLocation:location timestamp:CACurrentMediaTime() modifier:1 interfaceOrientation:interfaceOrientation forceState:0]; + + if (recognizer.targetEdges & currentEdge9) { + targetRecognizer = recognizer; + } } + [RAGestureManager.sharedInstance handleMovementOrStateUpdate:UIGestureRecognizerStateChanged withPoint:rotatedLocation velocity:targetRecognizer.RA_velocity forEdge:currentEdge9]; + } } + } } __strong id __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer; -%ctor -{ - - IF_SPRINGBOARD - { - if (IS_IOS_OR_OLDER(iOS_8_4)) - return; +%ctor { + if (IS_IOS_OR_OLDER(iOS_8_4) || !IS_SPRINGBOARD) { + return; + } - LogDebug(@"start of ctor"); + LogDebug(@"start of ctor"); - clientCreatePointer clientCreate; - void *handle = dlopen(0, 9); - *(void**)(&clientCreate) = dlsym(handle,"IOHIDEventSystemClientCreate"); - IOHIDEventSystemClientRef hidEventSystem = (__IOHIDEventSystemClient *)clientCreate(kCFAllocatorDefault); - IOHIDEventSystemClientScheduleWithRunLoop(hidEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); - IOHIDEventSystemClientRegisterEventCallback(hidEventSystem, (IOHIDEventSystemClientEventCallback)touch_event, NULL, NULL); + clientCreatePointer clientCreate; + void *handle = dlopen(0, 9); + *(void**)(&clientCreate) = dlsym(handle,"IOHIDEventSystemClientCreate"); + IOHIDEventSystemClientRef hidEventSystem = (__IOHIDEventSystemClient *)clientCreate(kCFAllocatorDefault); + IOHIDEventSystemClientScheduleWithRunLoop(hidEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + IOHIDEventSystemClientRegisterEventCallback(hidEventSystem, (IOHIDEventSystemClientEventCallback)touch_event, NULL, NULL); - LogDebug(@"did iokit stuff") + LogDebug(@"did iokit stuff") - class_addProtocol(%c(Hooks9$SBHandMotionExtractorReplacementByMultiplexer), @protocol(_UIScreenEdgePanRecognizerDelegate)); + class_addProtocol(%c(Hooks9$SBHandMotionExtractorReplacementByMultiplexer), @protocol(_UIScreenEdgePanRecognizerDelegate)); - LogDebug(@"added protocol"); + LogDebug(@"added protocol"); - UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; - int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); - gestureRecognizers = [[NSMutableSet alloc] initWithCapacity:edgeCount]; - for (int i = 0; i < edgeCount; i++) - { - _UIScreenEdgePanRecognizer *recognizer = [[_UIScreenEdgePanRecognizer alloc] initWithType:2]; - recognizer.targetEdges = edgesToWatch[i]; - recognizer.screenBounds = UIScreen.mainScreen._referenceBounds; - [gestureRecognizers addObject:recognizer]; - } + UIRectEdge edgesToWatch[] = { UIRectEdgeBottom, UIRectEdgeLeft, UIRectEdgeRight, UIRectEdgeTop }; + int edgeCount = sizeof(edgesToWatch) / sizeof(UIRectEdge); + gestureRecognizers = [[NSMutableSet alloc] initWithCapacity:edgeCount]; + for (int i = 0; i < edgeCount; i++) { + _UIScreenEdgePanRecognizer *recognizer = [[_UIScreenEdgePanRecognizer alloc] initWithType:2]; + recognizer.targetEdges = edgesToWatch[i]; + recognizer.screenBounds = UIScreen.mainScreen._referenceBounds; + [gestureRecognizers addObject:recognizer]; + } - LogDebug(@"added gestureRecognizers") + LogDebug(@"added gestureRecognizers") - %init; + %init; - LogDebug(@"inited ctor"); - - __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer = [[Hooks9$SBHandMotionExtractorReplacementByMultiplexer alloc] init]; - } + LogDebug(@"inited ctor"); + __static$Hooks9$SBHandMotionExtractorReplacementByMultiplexer = [[Hooks9$SBHandMotionExtractorReplacementByMultiplexer alloc] init]; } diff --git a/GestureSupport/RAGestureManager.h b/GestureSupport/RAGestureManager.h index 52db0cd..a8ef218 100644 --- a/GestureSupport/RAGestureManager.h +++ b/GestureSupport/RAGestureManager.h @@ -11,8 +11,8 @@ typedef NS_ENUM(NSInteger, RAGestureCallbackResult) { }; @protocol RAGestureCallbackProtocol --(BOOL) RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity; --(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge; +- (BOOL)RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity; +- (RAGestureCallbackResult)RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge; @end typedef BOOL(^RAGestureConditionBlock)(CGPoint location, CGPoint velocity); @@ -26,20 +26,20 @@ const NSUInteger RAGesturePriorityDefault = RAGesturePriorityLow; NSMutableArray *gestures; NSMutableDictionary *ignoredAreas; } -+(instancetype) sharedInstance; - --(void) addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority; --(void) addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier; --(void) addGestureRecognizerWithTarget:(NSObject*)target forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier; --(void) addGestureRecognizerWithTarget:(NSObject*)target forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority; --(void) addGesture:(RAGestureCallback*)callback; --(void) removeGestureWithIdentifier:(NSString*)identifier; - --(BOOL) canHandleMovementWithPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge; --(BOOL) handleMovementOrStateUpdate:(UIGestureRecognizerState)state withPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge; - --(void) ignoreSwipesBeginningInRect:(CGRect)area forIdentifier:(NSString*)identifier; --(void) stopIgnoringSwipesForIdentifier:(NSString*)identifier; --(void) ignoreSwipesBeginningOnSide:(UIRectEdge)side aboveYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier; --(void) ignoreSwipesBeginningOnSide:(UIRectEdge)side belowYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier; ++ (instancetype)sharedInstance; + +- (void)addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority; +- (void)addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier; +- (void)addGestureRecognizerWithTarget:(NSObject*)target forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier; +- (void)addGestureRecognizerWithTarget:(NSObject*)target forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority; +- (void)addGesture:(RAGestureCallback*)callback; +- (void)removeGestureWithIdentifier:(NSString*)identifier; + +- (BOOL)canHandleMovementWithPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge; +- (BOOL)handleMovementOrStateUpdate:(UIGestureRecognizerState)state withPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge; + +- (void)ignoreSwipesBeginningInRect:(CGRect)area forIdentifier:(NSString*)identifier; +- (void)stopIgnoringSwipesForIdentifier:(NSString*)identifier; +- (void)ignoreSwipesBeginningOnSide:(UIRectEdge)side aboveYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier; +- (void)ignoreSwipesBeginningOnSide:(UIRectEdge)side belowYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier; @end diff --git a/GestureSupport/RAGestureManager.xm b/GestureSupport/RAGestureManager.xm index af6c9ad..e29a5f8 100644 --- a/GestureSupport/RAGestureManager.xm +++ b/GestureSupport/RAGestureManager.xm @@ -4,49 +4,44 @@ #import "RAGestureCallback.h" @implementation RAGestureManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RAGestureManager, sharedInstance->gestures = [NSMutableArray array]; sharedInstance->ignoredAreas = [NSMutableDictionary dictionary]; ); } --(void) sortGestureRecognizers -{ +- (void)sortGestureRecognizers { [gestures sortUsingComparator:^NSComparisonResult(RAGestureCallback *a, RAGestureCallback *b) { - if (a.priority > b.priority) + if (a.priority > b.priority) { return NSOrderedAscending; - else if (a.priority < b.priority) + } else if (a.priority < b.priority) { return NSOrderedDescending; + } return NSOrderedSame; }]; } --(void) addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier -{ +- (void)addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier { [self addGestureRecognizer:callbackBlock withCondition:conditionBlock forEdge:screenEdge identifier:identifier priority:RAGesturePriorityDefault]; } --(void) addGesture:(RAGestureCallback*)callback -{ +- (void)addGesture:(RAGestureCallback*)callback { BOOL found = NO; - for (RAGestureCallback *callback_ in gestures) - if ([callback_.identifier isEqual:callback.identifier]) - { + for (RAGestureCallback *callback_ in gestures) { + if ([callback_.identifier isEqual:callback.identifier]) { found = YES; break; } + } - if (!found) - { + if (!found) { [gestures addObject:callback]; [self sortGestureRecognizers]; } } --(void) addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority -{ +- (void)addGestureRecognizer:(RAGestureCallbackBlock)callbackBlock withCondition:(RAGestureConditionBlock)conditionBlock forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority { RAGestureCallback *callback = [[RAGestureCallback alloc] init]; callback.callbackBlock = [callbackBlock copy]; callback.conditionBlock = [conditionBlock copy]; @@ -57,13 +52,11 @@ [self addGesture:callback]; } --(void) addGestureRecognizerWithTarget:(NSObject*)target forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier -{ +- (void)addGestureRecognizerWithTarget:(NSObject*)target forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier { [self addGestureRecognizerWithTarget:target forEdge:screenEdge identifier:identifier priority:RAGesturePriorityDefault]; } --(void) addGestureRecognizerWithTarget:(NSObject*)target forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority -{ +- (void)addGestureRecognizerWithTarget:(NSObject*)target forEdge:(UIRectEdge)screenEdge identifier:(NSString*)identifier priority:(NSUInteger)priority { RAGestureCallback *callback = [[RAGestureCallback alloc] init]; callback.target = target; callback.screenEdge = screenEdge; @@ -73,14 +66,11 @@ [self addGesture:callback]; } --(void) removeGestureWithIdentifier:(NSString*)identifier -{ +- (void)removeGestureWithIdentifier:(NSString*)identifier { int i = 0; - while (i < gestures.count) - { + while (i < gestures.count) { RAGestureCallback *callback = [self callbackAtIndex:i]; - if ([callback.identifier isEqual:identifier]) - { + if ([callback.identifier isEqual:identifier]) { [gestures removeObjectAtIndex:i]; i--; // offset for the change } @@ -89,35 +79,31 @@ } } --(RAGestureCallback*) callbackAtIndex:(NSUInteger)index -{ +- (RAGestureCallback*)callbackAtIndex:(NSUInteger)index { RAGestureCallback *ret = gestures[index]; //[gestures[index] getValue:&ret]; return ret; } --(BOOL) canHandleMovementWithPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge -{ - for (int i = 0; i < gestures.count; i++) - { +- (BOOL)canHandleMovementWithPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { + for (int i = 0; i < gestures.count; i++) { RAGestureCallback *callback = [self callbackAtIndex:i]; - if (callback.screenEdge & edge) - { - if (callback.conditionBlock) - { - if (callback.conditionBlock(point, velocity)) + if (callback.screenEdge & edge) { + if (callback.conditionBlock) { + if (callback.conditionBlock(point, velocity)) { return YES; - } - else if (callback.target && [callback.target respondsToSelector:@selector(RAGestureCallback_canHandle:velocity:)]) - if ([callback.target RAGestureCallback_canHandle:point velocity:velocity]) + } + } else if (callback.target && [callback.target respondsToSelector:@selector(RAGestureCallback_canHandle:velocity:)]) { + if ([callback.target RAGestureCallback_canHandle:point velocity:velocity]) { return YES; + } + } } } return NO; } --(BOOL) handleMovementOrStateUpdate:(UIGestureRecognizerState)state withPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge -{ +- (BOOL)handleMovementOrStateUpdate:(UIGestureRecognizerState)state withPoint:(CGPoint)point velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { // If we don't do this check here, but in canHandleMovementWithPoint:forEdge:, the recognizer hooks will not begin tracking the swipe // This is an issue if someone calls stopIgnoringSwipesForIdentifier: while a swipe is going on. /*for (NSString *key in ignoredAreas.allKeys) @@ -129,47 +115,46 @@ }*/ BOOL ret = NO; - for (int i = 0; i < gestures.count; i++) - { + for (int i = 0; i < gestures.count; i++) { RAGestureCallback *callback = [self callbackAtIndex:i]; NSValue *value = [ignoredAreas objectForKey:callback.identifier]; - if (value) - { + if (value) { CGRect rect = [value CGRectValue]; - if (CGRectContainsPoint(rect, point)) + if (CGRectContainsPoint(rect, point)) { continue; + } } - if (callback.screenEdge & edge) - { + if (callback.screenEdge & edge) { BOOL isThisCallbackCapable = NO; - if (callback.conditionBlock) - { - if (callback.conditionBlock(point, velocity)) + if (callback.conditionBlock) { + if (callback.conditionBlock(point, velocity)) { isThisCallbackCapable = YES; - } - else if (callback.target && [callback.target respondsToSelector:@selector(RAGestureCallback_canHandle:velocity:)]) - if ([callback.target RAGestureCallback_canHandle:point velocity:velocity]) + } + } else if (callback.target && [callback.target respondsToSelector:@selector(RAGestureCallback_canHandle:velocity:)]) { + if ([callback.target RAGestureCallback_canHandle:point velocity:velocity]) { isThisCallbackCapable = YES; + } + } - if (isThisCallbackCapable) - { - if (callback.callbackBlock) - { + if (isThisCallbackCapable) { + if (callback.callbackBlock) { RAGestureCallbackResult result = callback.callbackBlock(state, point, velocity); - if (result == RAGestureCallbackResultSuccessAndContinue || result == RAGestureCallbackResultSuccessAndStop) + if (result == RAGestureCallbackResultSuccessAndContinue || result == RAGestureCallbackResultSuccessAndStop) { ret = YES; - if (result == RAGestureCallbackResultSuccessAndStop) + } + if (result == RAGestureCallbackResultSuccessAndStop) { break; - } - else if (callback.target && [callback.target respondsToSelector:@selector(RAGestureCallback_handle:withPoint:velocity:forEdge:)]) - { + } + } else if (callback.target && [callback.target respondsToSelector:@selector(RAGestureCallback_handle:withPoint:velocity:forEdge:)]) { RAGestureCallbackResult result = [callback.target RAGestureCallback_handle:state withPoint:point velocity:velocity forEdge:edge]; - if (result == RAGestureCallbackResultSuccessAndContinue || result == RAGestureCallbackResultSuccessAndStop) + if (result == RAGestureCallbackResultSuccessAndContinue || result == RAGestureCallbackResultSuccessAndStop) { ret = YES; - if (result == RAGestureCallbackResultSuccessAndStop) + } + if (result == RAGestureCallbackResultSuccessAndStop) { break; + } } } } @@ -177,28 +162,26 @@ return ret; } --(void) ignoreSwipesBeginningInRect:(CGRect)area forIdentifier:(NSString*)identifier -{ +- (void)ignoreSwipesBeginningInRect:(CGRect)area forIdentifier:(NSString*)identifier { [ignoredAreas setObject:[NSValue valueWithCGRect:area] forKey:identifier]; } --(void) stopIgnoringSwipesForIdentifier:(NSString*)identifier -{ +- (void)stopIgnoringSwipesForIdentifier:(NSString*)identifier { [ignoredAreas removeObjectForKey:identifier]; } --(void) ignoreSwipesBeginningOnSide:(UIRectEdge)side aboveYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier -{ - if (side != UIRectEdgeLeft && side != UIRectEdgeRight) +- (void)ignoreSwipesBeginningOnSide:(UIRectEdge)side aboveYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier { + if (side != UIRectEdgeLeft && side != UIRectEdgeRight) { @throw [NSException exceptionWithName:@"InvalidRectEdgeException" reason:@"Expected UIRectEdgeLeft or UIRectEdgeRight" userInfo:nil]; + } CGRect r = CGRectMake(side == UIRectEdgeLeft ? 0 : UIScreen.mainScreen.bounds.size.width / 2.0 , 0, UIScreen.mainScreen.bounds.size.width / 2.0, axis); [self ignoreSwipesBeginningInRect:r forIdentifier:identifier]; } --(void) ignoreSwipesBeginningOnSide:(UIRectEdge)side belowYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier -{ - if (side != UIRectEdgeLeft && side != UIRectEdgeRight) +-(void) ignoreSwipesBeginningOnSide:(UIRectEdge)side belowYAxis:(NSUInteger)axis forIdentifier:(NSString*)identifier { + if (side != UIRectEdgeLeft && side != UIRectEdgeRight) { @throw [NSException exceptionWithName:@"InvalidRectEdgeException" reason:@"Expected UIRectEdgeLeft or UIRectEdgeRight" userInfo:nil]; + } CGRect r = CGRectMake(side == UIRectEdgeLeft ? 0 : UIScreen.mainScreen.bounds.size.width / 2.0 , axis, UIScreen.mainScreen.bounds.size.width / 2.0, UIScreen.mainScreen.bounds.size.height - axis); [self ignoreSwipesBeginningInRect:r forIdentifier:identifier]; } diff --git a/KeyboardSupport/RAKeyboardStateListener.h b/KeyboardSupport/RAKeyboardStateListener.h index 027acbb..7ada633 100644 --- a/KeyboardSupport/RAKeyboardStateListener.h +++ b/KeyboardSupport/RAKeyboardStateListener.h @@ -1,12 +1,11 @@ #import "headers.h" @interface RAKeyboardStateListener : NSObject -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; @property (nonatomic, readonly) BOOL visible; @property (nonatomic, readonly) CGSize size; --(void) _setVisible:(BOOL)val; --(void) _setSize:(CGSize)size; +- (void)_setVisible:(BOOL)val; +- (void)_setSize:(CGSize)size; @end - diff --git a/KeyboardSupport/RAKeyboardStateListener.xm b/KeyboardSupport/RAKeyboardStateListener.xm index 97bf499..03eeb90 100644 --- a/KeyboardSupport/RAKeyboardStateListener.xm +++ b/KeyboardSupport/RAKeyboardStateListener.xm @@ -12,112 +12,106 @@ extern BOOL overrideDisableForStatusBar; BOOL isShowing = NO; @implementation RAKeyboardStateListener -+ (instancetype)sharedInstance -{ - SHARED_INSTANCE(RAKeyboardStateListener); ++ (instancetype)sharedInstance { + SHARED_INSTANCE(RAKeyboardStateListener); } -- (void)didShow:(NSNotification*)notif -{ - LogDebug(@"[ReachApp] keyboard didShow"); - _visible = YES; - _size = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; +- (void)didShow:(NSNotification*)notif { + LogDebug(@"[ReachApp] keyboard didShow"); + _visible = YES; + _size = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; - IF_NOT_SPRINGBOARD { - CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), CFSTR("com.efrederickson.reachapp.keyboard.didShow"), NULL, NULL, true); - [RAMessagingClient.sharedInstance notifyServerOfKeyboardSizeUpdate:_size]; + IF_NOT_SPRINGBOARD { + CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), CFSTR("com.efrederickson.reachapp.keyboard.didShow"), NULL, NULL, true); + [RAMessagingClient.sharedInstance notifyServerOfKeyboardSizeUpdate:_size]; - if ([RAMessagingClient.sharedInstance shouldUseExternalKeyboard]) - { - [RAMessagingClient.sharedInstance notifyServerToShowKeyboard]; - isShowing = YES; - } + if ([RAMessagingClient.sharedInstance shouldUseExternalKeyboard]) { + [RAMessagingClient.sharedInstance notifyServerToShowKeyboard]; + isShowing = YES; } + } } -- (void)didHide -{ - LogDebug(@"[ReachApp] keyboard didHide"); - _visible = NO; +- (void)didHide { + LogDebug(@"[ReachApp] keyboard didHide"); + _visible = NO; - IF_NOT_SPRINGBOARD { - CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.keyboard.didHide"), NULL, NULL, true); - if ([RAMessagingClient.sharedInstance shouldUseExternalKeyboard] || isShowing) - { - isShowing = NO; - [RAMessagingClient.sharedInstance notifyServerToHideKeyboard]; - } + IF_NOT_SPRINGBOARD { + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.keyboard.didHide"), NULL, NULL, true); + if ([RAMessagingClient.sharedInstance shouldUseExternalKeyboard] || isShowing) { + isShowing = NO; + [RAMessagingClient.sharedInstance notifyServerToHideKeyboard]; } + } } -- (instancetype)init -{ - if ((self = [super init])) - { - NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - [center addObserver:self selector:@selector(didShow:) name:UIKeyboardDidShowNotification object:nil]; - [center addObserver:self selector:@selector(didHide) name:UIKeyboardWillHideNotification object:nil]; - [center addObserver:self selector:@selector(didHide) name:UIApplicationWillResignActiveNotification object:nil]; - } - return self; +- (instancetype)init { + if ((self = [super init])) { + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + [center addObserver:self selector:@selector(didShow:) name:UIKeyboardDidShowNotification object:nil]; + [center addObserver:self selector:@selector(didHide) name:UIKeyboardWillHideNotification object:nil]; + [center addObserver:self selector:@selector(didHide) name:UIApplicationWillResignActiveNotification object:nil]; + } + return self; +} + +- (void)_setVisible:(BOOL)val { + _visible = val; } --(void) _setVisible:(BOOL)val { _visible = val; } --(void) _setSize:(CGSize)size { _size = size; } +- (void)_setSize:(CGSize)size { + _size = size; +} @end -void externalKeyboardDidShow(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) -{ - [RAKeyboardStateListener.sharedInstance _setVisible:YES]; +void externalKeyboardDidShow(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { + [RAKeyboardStateListener.sharedInstance _setVisible:YES]; } -void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) -{ - //LogDebug(@"[ReachApp] externalKeyboardDidHide"); - [RAKeyboardStateListener.sharedInstance _setVisible:NO]; +void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { + //LogDebug(@"[ReachApp] externalKeyboardDidHide"); + [RAKeyboardStateListener.sharedInstance _setVisible:NO]; } %hook UIKeyboard --(void) activate -{ - %orig; - - void (^block)() = ^{ - IF_NOT_SPRINGBOARD { - unsigned int contextID = 0; - if (%c(UIRemoteKeyboardWindow) && [UIKeyboard activeKeyboard] && [[UIKeyboard activeKeyboard] window]) - contextID = [[[UIKeyboard activeKeyboard] window] _contextId]; // ((UITextEffectsWindow*)[%c(UIRemoteKeyboardWindow) remoteKeyboardWindowForScreen:UIScreen.mainScreen create:NO])._contextId; - else - contextID = UITextEffectsWindow.sharedTextEffectsWindow._contextId; - [RAMessagingClient.sharedInstance notifyServerWithKeyboardContextId:contextID]; - - #if DEBUG && NO - assert([[[UIKeyboard activeKeyboard] window] _contextId]); - assert(contextID != 0); - assert(contextID == [[[UIKeyboard activeKeyboard] window] _contextId]); - #endif - - LogDebug(@"[ReachApp] c id %d", contextID); +- (void)activate { + %orig; + + void (^block)() = ^{ + IF_NOT_SPRINGBOARD { + unsigned int contextID = 0; + if (%c(UIRemoteKeyboardWindow) && [UIKeyboard activeKeyboard] && [[UIKeyboard activeKeyboard] window]) { + contextID = [[[UIKeyboard activeKeyboard] window] _contextId]; // ((UITextEffectsWindow*)[%c(UIRemoteKeyboardWindow) remoteKeyboardWindowForScreen:UIScreen.mainScreen create:NO])._contextId; + } else { + contextID = UITextEffectsWindow.sharedTextEffectsWindow._contextId; } - }; + [RAMessagingClient.sharedInstance notifyServerWithKeyboardContextId:contextID]; - if (IS_IOS_OR_NEWER(iOS_9_0)) - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), block); - else - block(); + #if DEBUG && NO + assert([[[UIKeyboard activeKeyboard] window] _contextId]); + assert(contextID != 0); + assert(contextID == [[[UIKeyboard activeKeyboard] window] _contextId]); + #endif + LogDebug(@"[ReachApp] c id %d", contextID); + } + }; + + if (IS_IOS_OR_NEWER(iOS_9_0)) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), block); + } else { + block(); + } } %end -%ctor -{ - // Any process - [RAKeyboardStateListener sharedInstance]; +%ctor { + // Any process + [RAKeyboardStateListener sharedInstance]; - // Just SpringBoard - IF_SPRINGBOARD - { - CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, externalKeyboardDidShow, CFSTR("com.efrederickson.reachapp.keyboard.didShow"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, externalKeyboardDidHide, CFSTR("com.efrederickson.reachapp.keyboard.didHide"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - } + // Just SpringBoard + IF_SPRINGBOARD { + CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, externalKeyboardDidShow, CFSTR("com.efrederickson.reachapp.keyboard.didShow"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, externalKeyboardDidHide, CFSTR("com.efrederickson.reachapp.keyboard.didHide"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + } } diff --git a/KeyboardSupport/RAKeyboardWindow.h b/KeyboardSupport/RAKeyboardWindow.h index 366d7e2..e5db643 100644 --- a/KeyboardSupport/RAKeyboardWindow.h +++ b/KeyboardSupport/RAKeyboardWindow.h @@ -5,8 +5,8 @@ RARemoteKeyboardView *kbView; } --(void) setupForKeyboardAndShow:(NSString*)identifier; --(void) removeKeyboard; +- (void)setupForKeyboardAndShow:(NSString*)identifier; +- (void)removeKeyboard; --(unsigned int) contextId; +- (unsigned int)contextId; @end diff --git a/KeyboardSupport/RAKeyboardWindow.mm b/KeyboardSupport/RAKeyboardWindow.mm index b257e40..17ffedc 100644 --- a/KeyboardSupport/RAKeyboardWindow.mm +++ b/KeyboardSupport/RAKeyboardWindow.mm @@ -4,13 +4,13 @@ #import "RADesktopManager.h" @implementation RAKeyboardWindow --(void) setupForKeyboardAndShow:(NSString*)identifier -{ +- (void)setupForKeyboardAndShow:(NSString*)identifier { self.userInteractionEnabled = YES; self.backgroundColor = UIColor.clearColor; - - if (kbView) + + if (kbView) { [self removeKeyboard]; + } kbView = [[RARemoteKeyboardView alloc] initWithFrame:UIScreen.mainScreen.bounds]; [kbView connectToKeyboardWindowForApp:identifier]; @@ -21,12 +21,13 @@ -(void) setupForKeyboardAndShow:(NSString*)identifier [self makeKeyAndVisible]; } --(void) removeKeyboard -{ +- (void)removeKeyboard { [kbView connectToKeyboardWindowForApp:nil]; [kbView removeFromSuperview]; kbView = nil; } --(unsigned int) contextId { return kbView.layerHost.contextId; } +- (unsigned int)contextId { + return kbView.layerHost.contextId; +} @end diff --git a/KeyboardSupport/RARemoteKeyboardView.h b/KeyboardSupport/RARemoteKeyboardView.h index e5bd873..e6f6c0b 100644 --- a/KeyboardSupport/RARemoteKeyboardView.h +++ b/KeyboardSupport/RARemoteKeyboardView.h @@ -9,5 +9,5 @@ NSString *_identifier; } @property (nonatomic, retain) CALayerHost *layerHost; --(void) connectToKeyboardWindowForApp:(NSString*)identifier; +- (void)connectToKeyboardWindowForApp:(NSString*)identifier; @end diff --git a/KeyboardSupport/RARemoteKeyboardView.xm b/KeyboardSupport/RARemoteKeyboardView.xm index 6f6b1f7..6f23fec 100644 --- a/KeyboardSupport/RARemoteKeyboardView.xm +++ b/KeyboardSupport/RARemoteKeyboardView.xm @@ -12,10 +12,8 @@ @implementation RARemoteKeyboardView @synthesize layerHost = _layerHost; --(void) connectToKeyboardWindowForApp:(NSString*)identifier -{ - if (!identifier) - { +- (void)connectToKeyboardWindowForApp:(NSString*)identifier { + if (!identifier) { self.layerHost.contextId = 0; cancelFetchingContextId = YES; return; @@ -26,24 +24,22 @@ self.layerHost.contextId = value; LogDebug(@"[ReachApp] loaded keyboard view with %d", value); - if (value == 0 && !cancelFetchingContextId) - { + if (value == 0 && !cancelFetchingContextId) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self connectToKeyboardWindowForApp:identifier]; }); } } --(instancetype)initWithFrame:(CGRect)frame -{ +- (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; - if (self) - { + if (self) { self.userInteractionEnabled = YES; self.layerHost = [[CALayerHost alloc] init]; self.layerHost.anchorPoint = CGPointMake(0, 0); - if (IS_IOS_OR_OLDER(iOS_8_4)) - self.layerHost.transform = CATransform3DMakeScale(1/[UIScreen mainScreen].scale, 1/[UIScreen mainScreen].scale, 1); + if (IS_IOS_OR_OLDER(iOS_8_4)) { + self.layerHost.transform = CATransform3DMakeScale(1/[UIScreen mainScreen].scale, 1/[UIScreen mainScreen].scale, 1); + } self.layerHost.bounds = self.bounds; [self.layer addSublayer:self.layerHost]; update = NO; @@ -52,8 +48,7 @@ return self; } --(void)dealloc -{ +- (void)dealloc { self.layerHost = nil; } @end diff --git a/KeyboardSupport/RASpringBoardKeyboardActivation.h b/KeyboardSupport/RASpringBoardKeyboardActivation.h index fc5e541..af3384f 100644 --- a/KeyboardSupport/RASpringBoardKeyboardActivation.h +++ b/KeyboardSupport/RASpringBoardKeyboardActivation.h @@ -2,12 +2,12 @@ #import "RARunningAppsProvider.h" @interface RASpringBoardKeyboardActivation : NSObject -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; @property (nonatomic, readonly, copy) NSString *currentIdentifier; --(void) showKeyboardForAppWithIdentifier:(NSString*)identifier; --(void) hideKeyboard; +- (void)showKeyboardForAppWithIdentifier:(NSString*)identifier; +- (void)hideKeyboard; --(UIWindow*) keyboardWindow; +- (UIWindow*)keyboardWindow; @end diff --git a/KeyboardSupport/RASpringBoardKeyboardActivation.xm b/KeyboardSupport/RASpringBoardKeyboardActivation.xm index 31746d7..b8c3c66 100644 --- a/KeyboardSupport/RASpringBoardKeyboardActivation.xm +++ b/KeyboardSupport/RASpringBoardKeyboardActivation.xm @@ -10,47 +10,43 @@ extern BOOL overrideDisableForStatusBar; RAKeyboardWindow *keyboardWindow; @implementation RASpringBoardKeyboardActivation -+(instancetype) sharedInstance -{ - SHARED_INSTANCE2(RASpringBoardKeyboardActivation, - [RARunningAppsProvider.sharedInstance addTarget:self] - ); ++ (instancetype)sharedInstance { + SHARED_INSTANCE2(RASpringBoardKeyboardActivation, + [RARunningAppsProvider.sharedInstance addTarget:self] + ); } --(void) showKeyboardForAppWithIdentifier:(NSString*)identifier -{ - if (keyboardWindow) - { - [self hideKeyboard]; - //NSLog(@"[ReachApp] springboard cancelling - keyboardWindow exists"); - //return; - } +- (void)showKeyboardForAppWithIdentifier:(NSString*)identifier { + if (keyboardWindow) { + [self hideKeyboard]; + //NSLog(@"[ReachApp] springboard cancelling - keyboardWindow exists"); + //return; + } - LogDebug(@"[ReachApp] showing kb window %@", identifier); - keyboardWindow = [[RAKeyboardWindow alloc] init]; - overrideDisableForStatusBar = YES; - [keyboardWindow setupForKeyboardAndShow:identifier]; - overrideDisableForStatusBar = NO; - _currentIdentifier = identifier; + LogDebug(@"[ReachApp] showing kb window %@", identifier); + keyboardWindow = [[RAKeyboardWindow alloc] init]; + overrideDisableForStatusBar = YES; + [keyboardWindow setupForKeyboardAndShow:identifier]; + overrideDisableForStatusBar = NO; + _currentIdentifier = identifier; } --(void) hideKeyboard -{ - LogDebug(@"[ReachApp] remove kb window (%@)", _currentIdentifier); - keyboardWindow.hidden = YES; - [keyboardWindow removeKeyboard]; - keyboardWindow = nil; - _currentIdentifier = nil; +- (void)hideKeyboard { + LogDebug(@"[ReachApp] remove kb window (%@)", _currentIdentifier); + keyboardWindow.hidden = YES; + [keyboardWindow removeKeyboard]; + keyboardWindow = nil; + _currentIdentifier = nil; } --(void) appDidDie:(SBApplication*)app -{ - if ([_currentIdentifier isEqual:app.bundleIdentifier]) - [self hideKeyboard]; +- (void)appDidDie:(SBApplication*)app { + if (![_currentIdentifier isEqual:app.bundleIdentifier]) { + return; + } + [self hideKeyboard]; } --(UIWindow*) keyboardWindow -{ - return keyboardWindow; +- (UIWindow*)keyboardWindow { + return keyboardWindow; } @end diff --git a/Messaging/RAMessagingClient.h b/Messaging/RAMessagingClient.h index 199c1a3..f9173a0 100644 --- a/Messaging/RAMessagingClient.h +++ b/Messaging/RAMessagingClient.h @@ -6,28 +6,28 @@ @interface RAMessagingClient : NSObject { CPDistributedMessagingCenter *serverCenter; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; @property (nonatomic, readonly) RAMessageAppData currentData; @property (nonatomic) BOOL hasRecievedData; @property (nonatomic, copy) NSString *knownFrontmostApp; --(void) requestUpdateFromServer; +- (void)requestUpdateFromServer; --(void) notifyServerWithKeyboardContextId:(unsigned int)cid; --(void) notifyServerOfKeyboardSizeUpdate:(CGSize)size; --(void) notifyServerToShowKeyboard; --(void) notifyServerToHideKeyboard; --(BOOL) notifyServerToOpenURL:(NSURL*)url openInWindow:(BOOL)openWindow; --(void) notifySpringBoardOfFrontAppChangeToSelf; +- (void)notifyServerWithKeyboardContextId:(unsigned int)cid; +- (void)notifyServerOfKeyboardSizeUpdate:(CGSize)size; +- (void)notifyServerToShowKeyboard; +- (void)notifyServerToHideKeyboard; +- (BOOL)notifyServerToOpenURL:(NSURL*)url openInWindow:(BOOL)openWindow; +- (void)notifySpringBoardOfFrontAppChangeToSelf; // Methods to ease the currentData usage --(BOOL) shouldResize; --(CGSize) resizeSize; --(BOOL) shouldHideStatusBar; --(BOOL) shouldShowStatusBar; --(UIInterfaceOrientation) forcedOrientation; --(BOOL) shouldForceOrientation; --(BOOL) shouldUseExternalKeyboard; --(BOOL) isBeingHosted; +- (BOOL)shouldResize; +- (CGSize)resizeSize; +- (BOOL)shouldHideStatusBar; +- (BOOL)shouldShowStatusBar; +- (UIInterfaceOrientation)forcedOrientation; +- (BOOL)shouldForceOrientation; +- (BOOL)shouldUseExternalKeyboard; +- (BOOL)isBeingHosted; @end diff --git a/Messaging/RAMessagingClient.xm b/Messaging/RAMessagingClient.xm index 49ef817..e2c1252 100644 --- a/Messaging/RAMessagingClient.xm +++ b/Messaging/RAMessagingClient.xm @@ -5,17 +5,14 @@ extern BOOL allowClosingReachabilityNatively; #define IS_PROCESS(x) (strcmp(__progname, x) == 0) -@interface RAMessagingClient () { -} - +@interface RAMessagingClient () @property (nonatomic) BOOL allowedProcess; @end @implementation RAMessagingClient @synthesize allowedProcess; -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { IF_SPRINGBOARD { @throw [NSException exceptionWithName:@"IsSpringBoardException" reason:@"Cannot use RAMessagingClient in SpringBoard" userInfo:nil]; } @@ -39,8 +36,7 @@ extern BOOL allowClosingReachabilityNatively; ); } --(void) loadMessagingCenter -{ +- (void)loadMessagingCenter { RAMessageAppData data; data.shouldForceSize = NO; @@ -62,21 +58,18 @@ extern BOOL allowClosingReachabilityNatively; serverCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if (handle) - { + if (handle) { void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); rocketbootstrap_distributedmessagingcenter_apply(serverCenter); dlclose(handle); } } --(void) alertUser:(NSString*)description -{ +- (void)alertUser:(NSString*)description { LogError(@"%@", description); } --(void) _requestUpdateFromServerWithTries:(int)tries -{ +- (void)_requestUpdateFromServerWithTries:(int)tries { /*if (!NSBundle.mainBundle.bundleIdentifier || IS_PROCESS("assertiond") || // Don't need to load into this anyway IS_PROCESS("searchd") || // safe-mode crash fix @@ -85,8 +78,7 @@ extern BOOL allowClosingReachabilityNatively; IS_PROCESS("backboardd") // Backboardd uses its own messaging center for what it does. )*/ - if (!allowedProcess) - { + if (!allowedProcess) { // Anything that's not a UIApp (system app or user app) doesn't need this messaging client // Attempting to reach out will either: // 1. hang the process @@ -98,31 +90,25 @@ extern BOOL allowClosingReachabilityNatively; NSDictionary *dict = @{ @"bundleIdentifier": NSBundle.mainBundle.bundleIdentifier }; NSDictionary *data = [serverCenter sendMessageAndReceiveReplyName:RAMessagingUpdateAppInfoMessageName userInfo:dict]; - if (data && [data objectForKey:@"data"]) - { + if (data && [data objectForKey:@"data"]) { RAMessageAppData actualData; [data[@"data"] getBytes:&actualData length:sizeof(actualData)]; [self updateWithData:actualData]; self.hasRecievedData = YES; - } - else - { - if (tries <= 4) + } else { + if (tries <= 4) { [self _requestUpdateFromServerWithTries:tries + 1]; - else - { + } else { [self alertUser:[NSString stringWithFormat:@"App \"%@\" is unable to communicate with messaging server", [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"] ?: NSBundle.mainBundle.bundleIdentifier]]; } } } --(void) requestUpdateFromServer -{ +- (void)requestUpdateFromServer { [self _requestUpdateFromServerWithTries:0]; } --(void) updateWithData:(RAMessageAppData)data -{ +- (void)updateWithData:(RAMessageAppData)data { BOOL didStatusBarVisibilityChange = _currentData.shouldForceStatusBar != data.shouldForceStatusBar; BOOL didOrientationChange = _currentData.shouldForceOrientation != data.shouldForceOrientation; BOOL didSizingChange =_currentData.shouldForceSize != data.shouldForceSize; @@ -130,49 +116,47 @@ extern BOOL allowClosingReachabilityNatively; /* THE REAL IMPORTANT BIT */ _currentData = data; - if (didStatusBarVisibilityChange && !data.shouldForceStatusBar) + if (didStatusBarVisibilityChange && !data.shouldForceStatusBar) { [UIApplication.sharedApplication RA_forceStatusBarVisibility:_currentData.statusBarVisibility orRevert:YES]; - else if (data.shouldForceStatusBar) + } else if (data.shouldForceStatusBar) { [UIApplication.sharedApplication RA_forceStatusBarVisibility:_currentData.statusBarVisibility orRevert:NO]; + } - if (didSizingChange && !data.shouldForceSize) - [UIApplication.sharedApplication RA_updateWindowsForSizeChange:CGSizeMake(data.wantedClientWidth, data.wantedClientHeight) isReverting:YES]; - else if (data.shouldForceSize) - [UIApplication.sharedApplication RA_updateWindowsForSizeChange:CGSizeMake(data.wantedClientWidth, data.wantedClientHeight) isReverting:NO]; + if (didSizingChange && !data.shouldForceSize) { + [UIApplication.sharedApplication RA_updateWindowsForSizeChange:CGSizeMake(data.wantedClientWidth, data.wantedClientHeight) isReverting:YES]; + } else if (data.shouldForceSize) { + [UIApplication.sharedApplication RA_updateWindowsForSizeChange:CGSizeMake(data.wantedClientWidth, data.wantedClientHeight) isReverting:NO]; + } - if (didOrientationChange && !data.shouldForceOrientation) + if (didOrientationChange && !data.shouldForceOrientation) { [UIApplication.sharedApplication RA_forceRotationToInterfaceOrientation:data.forcedOrientation isReverting:YES]; - else if (data.shouldForceOrientation) + } else if (data.shouldForceOrientation) { [UIApplication.sharedApplication RA_forceRotationToInterfaceOrientation:data.forcedOrientation isReverting:NO]; + } allowClosingReachabilityNatively = YES; } --(void) notifyServerWithKeyboardContextId:(unsigned int)cid -{ +- (void)notifyServerWithKeyboardContextId:(unsigned int)cid { NSDictionary *dict = @{ @"contextId": @(cid), @"bundleIdentifier": NSBundle.mainBundle.bundleIdentifier }; [serverCenter sendMessageName:RAMessagingUpdateKeyboardContextIdMessageName userInfo:dict]; } --(void) notifyServerToShowKeyboard -{ +- (void)notifyServerToShowKeyboard { NSDictionary *dict = @{ @"bundleIdentifier": NSBundle.mainBundle.bundleIdentifier }; [serverCenter sendMessageName:RAMessagingShowKeyboardMessageName userInfo:dict]; } --(void) notifyServerToHideKeyboard -{ +- (void)notifyServerToHideKeyboard { [serverCenter sendMessageName:RAMessagingHideKeyboardMessageName userInfo:nil]; } --(void) notifyServerOfKeyboardSizeUpdate:(CGSize)size -{ +- (void)notifyServerOfKeyboardSizeUpdate:(CGSize)size { NSDictionary *dict = @{ @"size": NSStringFromCGSize(size) }; [serverCenter sendMessageName:RAMessagingUpdateKeyboardSizeMessageName userInfo:dict]; } --(BOOL) notifyServerToOpenURL:(NSURL*)url openInWindow:(BOOL)openWindow -{ +- (BOOL)notifyServerToOpenURL:(NSURL*)url openInWindow:(BOOL)openWindow { NSDictionary *dict = @{ @"url": url.absoluteString, @"openInWindow": @(openWindow) @@ -180,42 +164,56 @@ extern BOOL allowClosingReachabilityNatively; return [[serverCenter sendMessageAndReceiveReplyName:RAMessagingOpenURLKMessageName userInfo:dict][@"success"] boolValue]; } --(void) notifySpringBoardOfFrontAppChangeToSelf -{ +- (void)notifySpringBoardOfFrontAppChangeToSelf { NSString *ident = NSBundle.mainBundle.bundleIdentifier; - if (!ident) + if (!ident) { return; + } - if ([self isBeingHosted] && (!self.knownFrontmostApp || ![self.knownFrontmostApp isEqual:ident])) + if ([self isBeingHosted] && (!self.knownFrontmostApp || ![self.knownFrontmostApp isEqual:ident])) { [serverCenter sendMessageName:RAMessagingChangeFrontMostAppMessageName userInfo:@{ @"bundleIdentifier": ident }]; + } } --(BOOL) shouldUseExternalKeyboard { return _currentData.shouldUseExternalKeyboard; } --(BOOL) shouldResize { return _currentData.shouldForceSize; } --(CGSize) resizeSize { return CGSizeMake(_currentData.wantedClientWidth, _currentData.wantedClientHeight); } --(BOOL) shouldHideStatusBar { return _currentData.shouldForceStatusBar && !_currentData.statusBarVisibility; } --(BOOL) shouldShowStatusBar { return _currentData.shouldForceStatusBar && _currentData.statusBarVisibility; } --(UIInterfaceOrientation) forcedOrientation { return _currentData.forcedOrientation; } --(BOOL) shouldForceOrientation { return _currentData.shouldForceOrientation; } --(BOOL) isBeingHosted { return _currentData.isBeingHosted; } +- (BOOL)shouldUseExternalKeyboard { + return _currentData.shouldUseExternalKeyboard; +} +- (BOOL)shouldResize { + return _currentData.shouldForceSize; +} +- (CGSize)resizeSize { + return CGSizeMake(_currentData.wantedClientWidth, _currentData.wantedClientHeight); +} +- (BOOL)shouldHideStatusBar { + return _currentData.shouldForceStatusBar && !_currentData.statusBarVisibility; +} +- (BOOL)shouldShowStatusBar { + return _currentData.shouldForceStatusBar && _currentData.statusBarVisibility; +} +- (UIInterfaceOrientation)forcedOrientation { + return _currentData.forcedOrientation; +} +- (BOOL)shouldForceOrientation { + return _currentData.shouldForceOrientation; +} +- (BOOL)isBeingHosted { + return _currentData.isBeingHosted; +} @end -void reloadClientData(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) -{ +void reloadClientData(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { [[RAMessagingClient sharedInstance] requestUpdateFromServer]; } -void updateFrontmostApp(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) -{ +void updateFrontmostApp(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { RAMessagingClient.sharedInstance.knownFrontmostApp = ((__bridge NSDictionary*)userInfo)[@"bundleIdentifier"]; } -%ctor -{ - IF_NOT_SPRINGBOARD - { - [RAMessagingClient sharedInstance]; - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadClientData, (__bridge CFStringRef)[NSString stringWithFormat:@"com.efrederickson.reachapp.clientupdate-%@",NSBundle.mainBundle.bundleIdentifier], NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &updateFrontmostApp, CFSTR("com.efrederickson.reachapp.frontmostAppDidUpdate"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); +%ctor { + IF_SPRINGBOARD { + return; } + [RAMessagingClient sharedInstance]; + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reloadClientData, (__bridge CFStringRef)[NSString stringWithFormat:@"com.efrederickson.reachapp.clientupdate-%@",NSBundle.mainBundle.bundleIdentifier], NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &updateFrontmostApp, CFSTR("com.efrederickson.reachapp.frontmostAppDidUpdate"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); } diff --git a/Messaging/RAMessagingServer.h b/Messaging/RAMessagingServer.h index add63e3..a34a3bf 100644 --- a/Messaging/RAMessagingServer.h +++ b/Messaging/RAMessagingServer.h @@ -9,31 +9,31 @@ NSMutableDictionary *contextIds; NSMutableDictionary *waitingCompletions; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(void) loadServer; +- (void)loadServer; --(RAMessageAppData) getDataForIdentifier:(NSString*)identifier; --(void) setData:(RAMessageAppData)data forIdentifier:(NSString*)identifier; --(void) sendStoredDataToApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; +- (RAMessageAppData)getDataForIdentifier:(NSString*)identifier; +- (void)setData:(RAMessageAppData)data forIdentifier:(NSString*)identifier; +- (void)sendStoredDataToApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; --(void) resizeApp:(NSString*)identifier toSize:(CGSize)size completion:(RAMessageCompletionCallback)callback; --(void) moveApp:(NSString*)identifier toOrigin:(CGPoint)origin completion:(RAMessageCompletionCallback)callback; --(void) endResizingApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; +- (void)resizeApp:(NSString*)identifier toSize:(CGSize)size completion:(RAMessageCompletionCallback)callback; +- (void)moveApp:(NSString*)identifier toOrigin:(CGPoint)origin completion:(RAMessageCompletionCallback)callback; +- (void)endResizingApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; --(void) rotateApp:(NSString*)identifier toOrientation:(UIInterfaceOrientation)orientation completion:(RAMessageCompletionCallback)callback; --(void) unRotateApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; +- (void)rotateApp:(NSString*)identifier toOrientation:(UIInterfaceOrientation)orientation completion:(RAMessageCompletionCallback)callback; +- (void)unRotateApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; --(void) forceStatusBarVisibility:(BOOL)visibility forApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; --(void) unforceStatusBarVisibilityForApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; +- (void)forceStatusBarVisibility:(BOOL)visibility forApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; +- (void)unforceStatusBarVisibilityForApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; --(void) setHosted:(BOOL)value forIdentifier:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; +- (void)setHosted:(BOOL)value forIdentifier:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; --(void) forcePhoneMode:(BOOL)value forIdentifier:(NSString*)identifier andRelaunchApp:(BOOL)relaunch; +- (void)forcePhoneMode:(BOOL)value forIdentifier:(NSString*)identifier andRelaunchApp:(BOOL)relaunch; --(unsigned int) getStoredKeyboardContextIdForApp:(NSString*)identifier; +- (unsigned int)getStoredKeyboardContextIdForApp:(NSString*)identifier; --(void) receiveShowKeyboardForAppWithIdentifier:(NSString*)identifier; --(void) receiveHideKeyboard; --(void) setShouldUseExternalKeyboard:(BOOL)value forApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; +- (void)receiveShowKeyboardForAppWithIdentifier:(NSString*)identifier; +- (void)receiveHideKeyboard; +- (void)setShouldUseExternalKeyboard:(BOOL)value forApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback; @end diff --git a/Messaging/RAMessagingServer.xm b/Messaging/RAMessagingServer.xm index aae46bf..4322571 100644 --- a/Messaging/RAMessagingServer.xm +++ b/Messaging/RAMessagingServer.xm @@ -23,8 +23,7 @@ extern BOOL launchNextOpenIntoWindow; @end @implementation RAMessagingServer -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RAMessagingServer, [sharedInstance loadServer]; sharedInstance->dataForApps = [NSMutableDictionary dictionary]; @@ -34,16 +33,14 @@ extern BOOL launchNextOpenIntoWindow; ); } --(void) loadServer -{ +- (void)loadServer { messagingCenter = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if (handle) - { - void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); - rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); - dlclose(handle); + if (handle) { + void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); + rocketbootstrap_distributedmessagingcenter_apply(messagingCenter); + dlclose(handle); } [messagingCenter runServerOnCurrentThread]; @@ -70,36 +67,30 @@ extern BOOL launchNextOpenIntoWindow; [messagingCenter registerForMessageName:RAMessagingDetachCurrentAppMessageName target:self selector:@selector(handleKeyboardEvent:userInfo:)]; } --(NSDictionary*) handleMessageNamed:(NSString*)identifier userInfo:(NSDictionary*)info -{ - if ([identifier isEqual:RAMessagingShowKeyboardMessageName]) +- (NSDictionary*)handleMessageNamed:(NSString*)identifier userInfo:(NSDictionary*)info { + if ([identifier isEqual:RAMessagingShowKeyboardMessageName]) { [self receiveShowKeyboardForAppWithIdentifier:info[@"bundleIdentifier"]]; - else if ([identifier isEqual:RAMessagingHideKeyboardMessageName]) + } else if ([identifier isEqual:RAMessagingHideKeyboardMessageName]) { [self receiveHideKeyboard]; - else if ([identifier isEqual:RAMessagingUpdateKeyboardContextIdMessageName]) + } else if ([identifier isEqual:RAMessagingUpdateKeyboardContextIdMessageName]) { [self setKeyboardContextId:[info[@"contextId"] integerValue] forIdentifier:info[@"bundleIdentifier"]]; - else if ([identifier isEqual:RAMessagingRetrieveKeyboardContextIdMessageName]) + } else if ([identifier isEqual:RAMessagingRetrieveKeyboardContextIdMessageName]) { return @{ @"contextId": @([self getStoredKeyboardContextIdForApp:info[@"bundleIdentifier"]]) }; - else if ([identifier isEqual:RAMessagingUpdateKeyboardSizeMessageName]) - { + } else if ([identifier isEqual:RAMessagingUpdateKeyboardSizeMessageName]) { CGSize size = CGSizeFromString(info[@"size"]); [RAKeyboardStateListener.sharedInstance _setSize:size]; - } - else if ([identifier isEqual:RAMessagingUpdateAppInfoMessageName]) - { + } else if ([identifier isEqual:RAMessagingUpdateAppInfoMessageName]) { NSString *identifier = info[@"bundleIdentifier"]; RAMessageAppData data = [self getDataForIdentifier:identifier]; - if ([waitingCompletions objectForKey:identifier]) - { + if ([waitingCompletions objectForKey:identifier]) { RAMessageCompletionCallback callback = (RAMessageCompletionCallback)waitingCompletions[identifier]; [waitingCompletions removeObjectForKey:identifier]; callback(YES); } // Got the message, cancel the re-sender - if ([asyncHandles objectForKey:identifier]) - { + if ([asyncHandles objectForKey:identifier]) { struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; dispatch_after_cancel(handle); [asyncHandles removeObjectForKey:identifier]; @@ -108,38 +99,33 @@ extern BOOL launchNextOpenIntoWindow; return @{ @"data": [NSData dataWithBytes:&data length:sizeof(data)], }; - } - else if ([identifier isEqual:RAMessagingOpenURLKMessageName]) - { + } else if ([identifier isEqual:RAMessagingOpenURLKMessageName]) { NSURL *url = [NSURL URLWithString:info[@"url"]]; BOOL openInWindow = [RASettings.sharedInstance openLinksInWindows]; // [info[@"openInWindow"] boolValue]; - if (openInWindow) + if (openInWindow) { launchNextOpenIntoWindow = YES; + } BOOL success = [UIApplication.sharedApplication openURL:url]; return @{ @"success": @(success) }; - } - else if ([identifier isEqual:RAMessagingGetFrontMostAppInfoMessageName]) - { - if (UIApplication.sharedApplication._accessibilityFrontMostApplication) + } else if ([identifier isEqual:RAMessagingGetFrontMostAppInfoMessageName]) { + if (UIApplication.sharedApplication._accessibilityFrontMostApplication) { return nil; + } RAWindowBar *window = RADesktopManager.sharedInstance.lastUsedWindow; - if (window) - { + if (window) { SBApplication *app = window.attachedView.app; - if (app.pid) + if (app.pid) { return @{ @"pid": @(app.pid), @"bundleIdentifier": app.bundleIdentifier }; + } } - } - else if ([identifier isEqual:RAMessagingChangeFrontMostAppMessageName]) - { + } else if ([identifier isEqual:RAMessagingChangeFrontMostAppMessageName]) { NSString *bundleIdentifier = info[@"bundleIdentifier"]; RAWindowBar *window = [RADesktopManager.sharedInstance windowForIdentifier:bundleIdentifier]; - if (window) - { + if (window) { RADesktopManager.sharedInstance.lastUsedWindow = window; CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), CFSTR("com.efrederickson.reachapp.frontmostAppDidUpdate"), NULL, (__bridge CFDictionaryRef)@{ @"bundleIdentifier": bundleIdentifier }, YES); } @@ -148,14 +134,11 @@ extern BOOL launchNextOpenIntoWindow; return nil; } --(void) handleKeyboardEvent:(NSString*)identifier userInfo:(NSDictionary*)info -{ - if ([identifier isEqual:RAMessagingDetachCurrentAppMessageName]) - { +- (void)handleKeyboardEvent:(NSString*)identifier userInfo:(NSDictionary*)info { + if ([identifier isEqual:RAMessagingDetachCurrentAppMessageName]) { SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; - if (topApp) - { + if (topApp) { [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; @@ -178,52 +161,39 @@ extern BOOL launchNextOpenIntoWindow; [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; }]; } - } - else if ([identifier isEqual:RAMessagingGoToDesktopOnTheLeftMessageName]) - { + } else if ([identifier isEqual:RAMessagingGoToDesktopOnTheLeftMessageName]) { int newIndex = RADesktopManager.sharedInstance.currentDesktopIndex - 1; BOOL isValid = newIndex >= 0 && newIndex <= RADesktopManager.sharedInstance.numberOfDesktops; - if (isValid) + if (isValid) { [RADesktopManager.sharedInstance switchToDesktop:newIndex]; - } - else if ([identifier isEqual:RAMessagingGoToDesktopOnTheRightMessageName]) - { + } + } else if ([identifier isEqual:RAMessagingGoToDesktopOnTheRightMessageName]) { int newIndex = RADesktopManager.sharedInstance.currentDesktopIndex + 1; BOOL isValid = newIndex >= 0 && newIndex < RADesktopManager.sharedInstance.numberOfDesktops; if (isValid) [RADesktopManager.sharedInstance switchToDesktop:newIndex]; - } - else if ([identifier isEqual:RAMessagingAddNewDesktopMessageName]) - { + } else if ([identifier isEqual:RAMessagingAddNewDesktopMessageName]) { [RADesktopManager.sharedInstance addDesktop:YES]; } RAWindowBar *window = RADesktopManager.sharedInstance.lastUsedWindow; - if (!window) + if (!window) { return; - if ([identifier isEqual:RAMessagingSnapFrontMostWindowLeftMessageName]) - { - [RAWindowSnapDataProvider snapWindow:window toLocation:RAWindowSnapLocationGetLeftOfScreen() animated:YES]; } - else if ([identifier isEqual:RAMessagingSnapFrontMostWindowRightMessageName]) - { + if ([identifier isEqual:RAMessagingSnapFrontMostWindowLeftMessageName]) { + [RAWindowSnapDataProvider snapWindow:window toLocation:RAWindowSnapLocationGetLeftOfScreen() animated:YES]; + } else if ([identifier isEqual:RAMessagingSnapFrontMostWindowRightMessageName]) { [RAWindowSnapDataProvider snapWindow:window toLocation:RAWindowSnapLocationGetRightOfScreen() animated:YES]; - } - else if ([identifier isEqual:RAMessagingMaximizeAppMessageName]) - { + } else if ([identifier isEqual:RAMessagingMaximizeAppMessageName]) { [window maximize]; - } - else if ([identifier isEqual:RAMessagingCloseAppMessageName]) - { + } else if ([identifier isEqual:RAMessagingCloseAppMessageName]) { [window close]; } } --(void) alertUser:(NSString*)description -{ +- (void)alertUser:(NSString*)description { #if DEBUG - if ([RASettings.sharedInstance debug_showIPCMessages]) - { + if ([RASettings.sharedInstance debug_showIPCMessages]) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:description preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; [alert show]; @@ -231,13 +201,11 @@ extern BOOL launchNextOpenIntoWindow; #endif } --(RAMessageAppData) getDataForIdentifier:(NSString*)identifier -{ +- (RAMessageAppData)getDataForIdentifier:(NSString*)identifier { RAMessageAppData ret; - if ([dataForApps objectForKey:identifier] != nil) + if ([dataForApps objectForKey:identifier]) { [dataForApps[identifier] getValue:&ret]; - else - { + } else { // Initialize with some default values ret.shouldForceSize = NO; ret.wantedClientOriginX = -1; @@ -256,50 +224,44 @@ extern BOOL launchNextOpenIntoWindow; return ret; } --(void) setData:(RAMessageAppData)data forIdentifier:(NSString*)identifier -{ - if (identifier) - { - dataForApps[identifier] = [NSValue valueWithBytes:&data objCType:@encode(RAMessageAppData)]; +- (void)setData:(RAMessageAppData)data forIdentifier:(NSString*)identifier { + if (!identifier) { + return; } + dataForApps[identifier] = [NSValue valueWithBytes:&data objCType:@encode(RAMessageAppData)]; } --(void) checkIfCompletionStillExitsForIdentifierAndFailIt:(NSString*)identifier -{ - if ([waitingCompletions objectForKey:identifier]) - { - // We timed out, remove the re-sender - if ([asyncHandles objectForKey:identifier]) - { - struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; - dispatch_after_cancel(handle); - [asyncHandles removeObjectForKey:identifier]; - } +- (void)checkIfCompletionStillExitsForIdentifierAndFailIt:(NSString*)identifier { + if (![waitingCompletions objectForKey:identifier]) { + return; + } + // We timed out, remove the re-sender + if ([asyncHandles objectForKey:identifier]) { + struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; + dispatch_after_cancel(handle); + [asyncHandles removeObjectForKey:identifier]; + } - RAMessageCompletionCallback callback = (RAMessageCompletionCallback)waitingCompletions[identifier]; - [waitingCompletions removeObjectForKey:identifier]; + RAMessageCompletionCallback callback = (RAMessageCompletionCallback)waitingCompletions[identifier]; + [waitingCompletions removeObjectForKey:identifier]; - SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; - [self alertUser:[NSString stringWithFormat:@"Unable to communicate with app %@ (%@)", app.displayName, identifier]]; - callback(NO); - } + SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; + [self alertUser:[NSString stringWithFormat:@"Unable to communicate with app %@ (%@)", app.displayName, identifier]]; + callback(NO); } --(void) sendDataWithCurrentTries:(int)tries toAppWithBundleIdentifier:(NSString*)identifier completion:(RAMessageCompletionCallback)callback -{ +- (void)sendDataWithCurrentTries:(int)tries toAppWithBundleIdentifier:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; - if (!app.isRunning || ![app mainScene]) - { - if (tries > 4) - { + if (!app.isRunning || ![app mainScene]) { + if (tries > 4) { [self alertUser:[NSString stringWithFormat:@"Unable to communicate with app that isn't running: %@ (%@)", app.displayName, identifier]]; - if (callback) + if (callback) { callback(NO); + } return; } - if ([asyncHandles objectForKey:identifier]) - { + if ([asyncHandles objectForKey:identifier]) { struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; dispatch_after_cancel(handle); [asyncHandles removeObjectForKey:identifier]; @@ -314,10 +276,8 @@ extern BOOL launchNextOpenIntoWindow; CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge CFStringRef)[NSString stringWithFormat:@"com.efrederickson.reachapp.clientupdate-%@",identifier], nil, nil, YES); - if (tries <= 4) - { - if ([asyncHandles objectForKey:identifier]) - { + if (tries <= 4) { + if ([asyncHandles objectForKey:identifier]) { struct dispatch_async_handle *handle = (struct dispatch_async_handle *)[asyncHandles[identifier] pointerValue]; dispatch_after_cancel(handle); [asyncHandles removeObjectForKey:identifier]; @@ -328,12 +288,12 @@ extern BOOL launchNextOpenIntoWindow; }); asyncHandles[identifier] = [NSValue valueWithPointer:handle]; - if (![waitingCompletions objectForKey:identifier]) - { + if (![waitingCompletions objectForKey:identifier]) { //if (callback == nil) // callback = ^(BOOL _) { }; - if (callback) + if (callback) { waitingCompletions[identifier] = [callback copy]; + } } // Reset failure checker [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(checkIfCompletionStillExitsForIdentifierAndFailIt:) object:identifier]; @@ -383,16 +343,15 @@ extern BOOL launchNextOpenIntoWindow; */ } --(void) sendStoredDataToApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback -{ - if (!identifier || identifier.length == 0) +- (void)sendStoredDataToApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { + if (!identifier || identifier.length == 0) { return; + } [self sendDataWithCurrentTries:0 toAppWithBundleIdentifier:identifier completion:callback]; } --(void) resizeApp:(NSString*)identifier toSize:(CGSize)size completion:(RAMessageCompletionCallback)callback -{ +- (void)resizeApp:(NSString*)identifier toSize:(CGSize)size completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; data.wantedClientWidth = size.width; data.wantedClientHeight = size.height; @@ -401,8 +360,7 @@ extern BOOL launchNextOpenIntoWindow; [self sendStoredDataToApp:identifier completion:callback]; } --(void) moveApp:(NSString*)identifier toOrigin:(CGPoint)origin completion:(RAMessageCompletionCallback)callback -{ +- (void)moveApp:(NSString*)identifier toOrigin:(CGPoint)origin completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; data.wantedClientOriginX = (float)origin.x; data.wantedClientOriginY = (float)origin.y; @@ -411,8 +369,7 @@ extern BOOL launchNextOpenIntoWindow; [self sendStoredDataToApp:identifier completion:callback]; } --(void) endResizingApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback -{ +- (void)endResizingApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; //data.wantedClientSize = CGSizeMake(-1, -1); data.shouldForceSize = NO; @@ -420,12 +377,12 @@ extern BOOL launchNextOpenIntoWindow; [self sendStoredDataToApp:identifier completion:callback]; } --(void) rotateApp:(NSString*)identifier toOrientation:(UIInterfaceOrientation)orientation completion:(RAMessageCompletionCallback)callback -{ +- (void)rotateApp:(NSString*)identifier toOrientation:(UIInterfaceOrientation)orientation completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; - if (data.forcePhoneMode) + if (data.forcePhoneMode) { return; + } data.forcedOrientation = orientation; data.shouldForceOrientation = YES; @@ -433,8 +390,7 @@ extern BOOL launchNextOpenIntoWindow; [self sendStoredDataToApp:identifier completion:callback]; } --(void) unRotateApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback -{ +- (void)unRotateApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; data.forcedOrientation = UIApplication.sharedApplication.statusBarOrientation; data.shouldForceOrientation = NO; @@ -442,8 +398,7 @@ extern BOOL launchNextOpenIntoWindow; [self sendStoredDataToApp:identifier completion:callback]; } --(void) forceStatusBarVisibility:(BOOL)visibility forApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback -{ +- (void)forceStatusBarVisibility:(BOOL)visibility forApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; data.shouldForceStatusBar = YES; data.statusBarVisibility = visibility; @@ -451,70 +406,61 @@ extern BOOL launchNextOpenIntoWindow; [self sendStoredDataToApp:identifier completion:callback]; } --(void) unforceStatusBarVisibilityForApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback -{ +- (void)unforceStatusBarVisibilityForApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; data.shouldForceStatusBar = NO; [self setData:data forIdentifier:identifier]; [self sendStoredDataToApp:identifier completion:callback]; } --(void) setShouldUseExternalKeyboard:(BOOL)value forApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback -{ +- (void)setShouldUseExternalKeyboard:(BOOL)value forApp:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; data.shouldUseExternalKeyboard = value; [self setData:data forIdentifier:identifier]; [self sendStoredDataToApp:identifier completion:callback]; } --(void) setHosted:(BOOL)value forIdentifier:(NSString*)identifier completion:(RAMessageCompletionCallback)callback -{ +- (void)setHosted:(BOOL)value forIdentifier:(NSString*)identifier completion:(RAMessageCompletionCallback)callback { RAMessageAppData data = [self getDataForIdentifier:identifier]; data.isBeingHosted = value; [self setData:data forIdentifier:identifier]; [self sendStoredDataToApp:identifier completion:callback]; } --(void) forcePhoneMode:(BOOL)value forIdentifier:(NSString*)identifier andRelaunchApp:(BOOL)relaunch -{ +- (void)forcePhoneMode:(BOOL)value forIdentifier:(NSString*)identifier andRelaunchApp:(BOOL)relaunch { RAMessageAppData data = [self getDataForIdentifier:identifier]; data.forcePhoneMode = value; [self setData:data forIdentifier:identifier]; - if (relaunch) - { + if (relaunch) { [RAAppKiller killAppWithIdentifier:identifier completion:^{ [RADesktopManager.sharedInstance updateWindowSizeForApplication:identifier]; }]; } } --(void) receiveShowKeyboardForAppWithIdentifier:(NSString*)identifier -{ +- (void)receiveShowKeyboardForAppWithIdentifier:(NSString*)identifier { [RASpringBoardKeyboardActivation.sharedInstance showKeyboardForAppWithIdentifier:identifier]; } --(void) receiveHideKeyboard -{ +- (void)receiveHideKeyboard { [RASpringBoardKeyboardActivation.sharedInstance hideKeyboard]; } --(void) setKeyboardContextId:(unsigned int)id forIdentifier:(NSString*)identifier -{ +- (void)setKeyboardContextId:(unsigned int)id forIdentifier:(NSString*)identifier { LogDebug(@"[ReachApp] got c id %d", id); contextIds[identifier] = @(id); } --(unsigned int) getStoredKeyboardContextIdForApp:(NSString*)identifier -{ +- (unsigned int)getStoredKeyboardContextIdForApp:(NSString*)identifier { return [contextIds objectForKey:identifier] ? [contextIds[identifier] unsignedIntValue] : 0; } @end -%ctor -{ - IF_SPRINGBOARD { - [RAMessagingServer sharedInstance]; +%ctor { + IF_NOT_SPRINGBOARD { + return; } + [RAMessagingServer sharedInstance]; } diff --git a/MissionControl/ActivatorListener.xm b/MissionControl/ActivatorListener.xm index a1a7f68..bb9a88c 100644 --- a/MissionControl/ActivatorListener.xm +++ b/MissionControl/ActivatorListener.xm @@ -8,8 +8,7 @@ static RAActivatorListener *sharedInstance; @implementation RAActivatorListener -- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event -{ +- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event { if ([[%c(SBLockScreenManager) sharedInstance] isUILocked]) { return; } else if ([[%c(RASettings) sharedInstance] missionControlEnabled]) { @@ -24,11 +23,10 @@ static RAActivatorListener *sharedInstance; } @end -%ctor -{ - IF_SPRINGBOARD - { - sharedInstance = [[RAActivatorListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.missioncontrol.activatorlistener"]; +%ctor { + IF_NOT_SPRINGBOARD { + return; } + sharedInstance = [[RAActivatorListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.missioncontrol.activatorlistener"]; } diff --git a/MissionControl/AppSwitcher.xm b/MissionControl/AppSwitcher.xm index 6f4c7e1..8716ad3 100644 --- a/MissionControl/AppSwitcher.xm +++ b/MissionControl/AppSwitcher.xm @@ -12,83 +12,70 @@ BOOL willShowMissionControl = NO; BOOL toggleOrActivate = NO; %hook SBUIController -- (void)_showNotificationsGestureBeganWithLocation:(CGPoint)arg1 -{ - if ([[[%c(SBUIController) sharedInstance] switcherWindow] isKeyWindow] && CGRectContainsPoint([[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].frame, arg1)) +- (void)_showNotificationsGestureBeganWithLocation:(CGPoint)arg1 { + if ([[[%c(SBUIController) sharedInstance] switcherWindow] isKeyWindow] && CGRectContainsPoint([[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].frame, arg1)) { return; + } - if ([[%c(RASettings) sharedInstance] missionControlEnabled] && self.isAppSwitcherShowing) + if ([[%c(RASettings) sharedInstance] missionControlEnabled] && self.isAppSwitcherShowing) { return; + } %orig; } -- (_Bool)_activateAppSwitcher -{ +- (_Bool)_activateAppSwitcher { statusBarVisibility = UIApplication.sharedApplication.statusBarHidden; willShowMissionControl = NO; - if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) - { - if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) - { + if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) { + if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) { [RAMissionControlManager.sharedInstance showMissionControl:YES]; - } - else + } else { [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } return YES; - } - else - { - if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) - { + } else { + if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) { [RAMissionControlManager.sharedInstance hideMissionControl:YES]; } } BOOL s = %orig; - if (s && [[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999]) - { + if (s && [[%c(RASettings) sharedInstance] missionControlEnabled] && [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999]) { [UIView animateWithDuration:0.3 animations:^{ [[[%c(SBUIController) sharedInstance] switcherWindow] viewWithTag:999].alpha = 1; }]; } - if (s) - { + if (s) { [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; //[[[%c(RADesktopManager) sharedInstance] currentDesktop] unloadApps]; } return s; } -- (void)_hideNotificationsGestureCancelled -{ +- (void)_hideNotificationsGestureCancelled { %orig; RAMissionControlManager.sharedInstance.inhibitDismissalGesture = NO; } -- (void)_hideNotificationsGestureEndedWithCompletionType:(long long)arg1 velocity:(CGPoint)arg2 -{ +- (void)_hideNotificationsGestureEndedWithCompletionType:(long long)arg1 velocity:(CGPoint)arg2 { %orig; RAMissionControlManager.sharedInstance.inhibitDismissalGesture = NO; } -- (void)_hideNotificationsGestureBegan:(CGFloat)arg1 -{ +- (void)_hideNotificationsGestureBegan:(CGFloat)arg1 { RAMissionControlManager.sharedInstance.inhibitDismissalGesture = YES; %orig; } -- (_Bool)isAppSwitcherShowing -{ +- (_Bool)isAppSwitcherShowing { return %orig || RAMissionControlManager.sharedInstance.isShowingMissionControl; } --(void) _dismissSwitcherAnimated:(_Bool)arg1 -{ - if (RAMissionControlManager.sharedInstance.isShowingMissionControl) - { +-(void) _dismissSwitcherAnimated:(_Bool)arg1 { + if (RAMissionControlManager.sharedInstance.isShowingMissionControl) { [RAMissionControlManager.sharedInstance hideMissionControl:arg1]; } @@ -109,10 +96,8 @@ BOOL toggleOrActivate = NO; %hook SBAppSwitcherController // iOS 8 -- (void)switcherWillBeDismissed:(_Bool)arg1 -{ - if (!willShowMissionControl) - { +- (void)switcherWillBeDismissed:(_Bool)arg1 { + if (!willShowMissionControl) { [[%c(RADesktopManager) sharedInstance] reshowDesktop]; //[[[%c(RADesktopManager) sharedInstance] currentDesktop] loadApps]; } @@ -124,8 +109,7 @@ BOOL toggleOrActivate = NO; %orig; } -- (void)switcherScroller:(id)arg1 itemTapped:(__unsafe_unretained SBDisplayLayout*)arg2 -{ +- (void)switcherScroller:(id)arg1 itemTapped:(__unsafe_unretained SBDisplayLayout*)arg2 { SBDisplayItem *item = [arg2 displayItems][0]; NSString *identifier = item.displayIdentifier; @@ -136,26 +120,23 @@ BOOL toggleOrActivate = NO; %end @interface SBAppSwitcherController () --(UIView*) view; +- (UIView*)view; @end //%hook SBAppSwitcherWindow %hook SBAppSwitcherController //-(void) addSubview:(UIView*)view -- (void)_layoutInOrientation:(long long)arg1 -{ +- (void)_layoutInOrientation:(long long)arg1 { %orig; UIView *view = MSHookIvar(self, "_contentView"); - if (![view viewWithTag:999] && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) - { + if (![view viewWithTag:999] && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; - if (IS_IPAD) - { + if (IS_IPAD) { width = 60; - height = 40; + height = 40; } SBControlCenterGrabberView *grabber = [[%c(SBControlCenterGrabberView) alloc] initWithFrame:CGRectMake(0, 0, width, height)]; grabber.center = CGPointMake(view.frame.size.width / 2, 20/2); @@ -176,22 +157,19 @@ BOOL toggleOrActivate = NO; [view addSubview:grabber]; [[%c(RAGestureManager) sharedInstance] addGestureRecognizerWithTarget:(NSObject *)self forEdge:UIRectEdgeTop identifier:@"com.efrederickson.reachapp.appswitchergrabber"]; - } - else + } else { ((UIView*)[view viewWithTag:999]).center = CGPointMake(view.frame.size.width / 2, 20/2); + } } // iOS 8 --(void)viewDidAppear:(BOOL)a -{ +- (void)viewDidAppear:(BOOL)a { %orig; UIView *view = MSHookIvar(self, "_contentView"); - if (![view viewWithTag:999] && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) - { + if (![view viewWithTag:999] && ([[%c(RASettings) sharedInstance] missionControlEnabled] && ![[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC])) { CGFloat width = 50, height = 30; - if (IS_IPAD) - { + if (IS_IPAD) { width = 60; height = 40; } @@ -219,18 +197,16 @@ BOOL toggleOrActivate = NO; [view addSubview:grabber]; [[%c(RAGestureManager) sharedInstance] addGestureRecognizerWithTarget:(NSObject *)self forEdge:UIRectEdgeTop identifier:@"com.efrederickson.reachapp.appswitchergrabber"]; - } - else + } else { ((UIView*)[view viewWithTag:999]).center = CGPointMake(view.frame.size.width / 2, 20/2); + } } -%new -(BOOL) RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity -{ +%new - (BOOL)RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity { return allowMissionControlActivationFromSwitcher && [[%c(RASettings) sharedInstance] missionControlEnabled] && self.view.window.isKeyWindow; } -%new -(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge -{ +%new - (RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { if ([%c(SBUIController) respondsToSelector:@selector(_showNotificationsGestureFailed)]) { [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureFailed)]; [[%c(SBUIController) sharedInstance] performSelector:@selector(_showNotificationsGestureCancelled)]; @@ -243,18 +219,14 @@ BOOL toggleOrActivate = NO; static UIView *fakeView; UIView *view = MSHookIvar(self, "_contentView"); - if (!fakeView) - { + if (!fakeView) { UIImage *snapshot = [[%c(RASnapshotProvider) sharedInstance] storedSnapshotOfMissionControl]; - if (snapshot) - { + if (snapshot) { fakeView = [[UIImageView alloc] initWithFrame:view.frame]; ((UIImageView*)fakeView).image = snapshot; [view addSubview:fakeView]; - } - else - { + } else { fakeView = [[UIView alloc] initWithFrame:view.frame]; CGFloat width = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 4.5714; @@ -322,23 +294,21 @@ BOOL toggleOrActivate = NO; } } - if (origY == -1) - { + if (origY == -1) { CGRect f = fakeView.frame; f.origin.y = -f.size.height; fakeView.frame = f; origY = fakeView.center.y; } - if (state == UIGestureRecognizerStateChanged) + if (state == UIGestureRecognizerStateChanged) { fakeView.center = (CGPoint) { fakeView.center.x, origY + location.y }; + } - if (state == UIGestureRecognizerStateEnded) - { + if (state == UIGestureRecognizerStateEnded) { //NSLog(@"[ReachApp] %@ + %@ = %@ > %@", NSStringFromCGPoint(fakeView.frame.origin), NSStringFromCGPoint(velocity), @(fakeView.frame.origin.y + velocity.y), @(-(UIScreen.mainScreen.bounds.size.height / 2))); - if (fakeView.frame.origin.y + velocity.y > -(UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 2)) - { + if (fakeView.frame.origin.y + velocity.y > -(UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 2)) { willShowMissionControl = YES; CGFloat distance = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - (fakeView.frame.origin.y + fakeView.frame.size.height); CGFloat duration = MIN(distance / velocity.y, 0.3); @@ -360,9 +330,7 @@ BOOL toggleOrActivate = NO; // ((UIWindow*)[[%c(SBUIController) sharedInstance] switcherWindow]).alpha = 1; //}); }]; - } - else - { + } else { CGFloat distance = fakeView.frame.size.height + fakeView.frame.origin.y /* origin.y is less than 0 so the + is actually a - operation */; CGFloat duration = MIN(distance / velocity.y, 0.3); @@ -544,8 +512,9 @@ BOOL toggleOrActivate = NO; origY = fakeView.center.y; } - if (state == UIGestureRecognizerStateChanged) + if (state == UIGestureRecognizerStateChanged) { fakeView.center = CGPointMake(fakeView.center.x, origY + location.y); + } if (state == UIGestureRecognizerStateEnded) { //NSLog(@"[ReachApp] %@ + %@ = %@ > %@", NSStringFromCGPoint(fakeView.frame.origin), NSStringFromCGPoint(velocity), @(fakeView.frame.origin.y + velocity.y), @(-(UIScreen.mainScreen.bounds.size.height / 2))); @@ -661,21 +630,16 @@ BOOL toggleOrActivate = NO; } - (BOOL)activateSwitcherNoninteractively { - if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) - { - if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) - { + if ([[%c(RASettings) sharedInstance] replaceAppSwitcherWithMC] && [[%c(RASettings) sharedInstance] missionControlEnabled]) { + if (!RAMissionControlManager.sharedInstance.isShowingMissionControl) { [RAMissionControlManager.sharedInstance showMissionControl:YES]; - } - else - [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } else { + [RAMissionControlManager.sharedInstance hideMissionControl:YES]; + } return YES; - } - else - { - if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) - { + } else { + if ([RAMissionControlManager.sharedInstance isShowingMissionControl]) { [RAMissionControlManager.sharedInstance hideMissionControl:YES]; } } diff --git a/MissionControl/RAMissionControlManager.h b/MissionControl/RAMissionControlManager.h index 712333c..609a79f 100644 --- a/MissionControl/RAMissionControlManager.h +++ b/MissionControl/RAMissionControlManager.h @@ -5,15 +5,15 @@ @interface RAMissionControlManager : NSObject { RAMissionControlWindow *window; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; @property (nonatomic, readonly) BOOL isShowingMissionControl; @property (nonatomic) BOOL inhibitDismissalGesture; --(void) createWindow; --(void) showMissionControl:(BOOL)animated; --(void) hideMissionControl:(BOOL)animated; --(void) toggleMissionControl:(BOOL)animated; +- (void)createWindow; +- (void)showMissionControl:(BOOL)animated; +- (void)hideMissionControl:(BOOL)animated; +- (void)toggleMissionControl:(BOOL)animated; --(RAMissionControlWindow*) missionControlWindow; -@end \ No newline at end of file +- (RAMissionControlWindow*)missionControlWindow; +@end diff --git a/MissionControl/RAMissionControlManager.xm b/MissionControl/RAMissionControlManager.xm index f8fb15a..68fb139 100644 --- a/MissionControl/RAMissionControlManager.xm +++ b/MissionControl/RAMissionControlManager.xm @@ -29,16 +29,12 @@ } @end -CGRect swappedForOrientation(CGRect in) -{ - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { +CGRect swappedForOrientation(CGRect in) { + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { CGFloat x = in.origin.x; in.origin.x = in.origin.y; in.origin.y = x; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { CGFloat x = in.origin.x; in.origin.x = fabs(in.origin.y) + UIScreen.mainScreen.bounds.size.width; in.origin.y = x; @@ -47,16 +43,12 @@ CGRect swappedForOrientation(CGRect in) return in; } -CGRect swappedForOrientation2(CGRect in) -{ - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { +CGRect swappedForOrientation2(CGRect in) { + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { CGFloat x = in.origin.x; in.origin.x = in.origin.y; in.origin.y = x; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { CGFloat x = in.origin.x; in.origin.x = -in.size.width; in.origin.y = x; @@ -66,8 +58,7 @@ CGRect swappedForOrientation2(CGRect in) } @implementation RAMissionControlManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RAMissionControlManager, sharedInstance->originalAppView = nil; sharedInstance.inhibitDismissalGesture = NO; @@ -75,46 +66,46 @@ CGRect swappedForOrientation2(CGRect in) ); } --(void) showMissionControl:(BOOL)animated -{ - if (![NSThread isMainThread]) - { - dispatch_sync(dispatch_get_main_queue(), ^{ [self showMissionControl:animated]; }); +- (void)showMissionControl:(BOOL)animated { + if (![NSThread isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self showMissionControl:animated]; + }); return; } _isShowingMissionControl = YES; SBApplication *app = UIApplication.sharedApplication._accessibilityFrontMostApplication; - if (app) + if (app) { lastOpenedApp = app; + } [self createWindow]; - if (animated) - //window.alpha = 0; + if (animated) { window.frame = swappedForOrientation(CGRectMake(0, -window.frame.size.height, window.frame.size.width, window.frame.size.height)); + } + //window.alpha = 0; [window makeKeyAndVisible]; - if (lastOpenedApp && lastOpenedApp.isRunning) - { + if (lastOpenedApp && lastOpenedApp.isRunning) { originalAppView = [%c(RAHostManager) systemHostViewForApplication:lastOpenedApp].superview; originalAppFrame = originalAppView.frame; } - if (animated) - { + if (animated) { //[UIView animateWithDuration:0.5 animations:^{ window.alpha = 1; }]; [UIView animateWithDuration:0.5 animations:^{ window.frame = CGRectMake(0, 0, window.frame.size.width, window.frame.size.height); - if (originalAppView) + if (originalAppView) { originalAppView.frame = swappedForOrientation2(CGRectMake(originalAppFrame.origin.x, originalAppView.frame.size.height, originalAppFrame.size.width, originalAppFrame.size.height)); + + } } completion:nil]; - } - else if (originalAppView) // dismiss even if not animating open - { + } else if (originalAppView) { // dismiss even if not animating open originalAppView.frame = swappedForOrientation2(CGRectMake(originalAppFrame.origin.x, originalAppView.frame.size.height, originalAppFrame.size.width, originalAppFrame.size.height)); } @@ -129,18 +120,18 @@ CGRect swappedForOrientation2(CGRect in) self.inhibitDismissalGesture = NO; [%c(RAControlCenterInhibitor) setInhibited:YES]; - if ([[%c(SBControlCenterController) sharedInstance] isVisible]) + if ([[%c(SBControlCenterController) sharedInstance] isVisible]) { [[%c(SBControlCenterController) sharedInstance] dismissAnimated:YES]; + } didStoreSnapshot = NO; } --(void) createWindow -{ - if (window) - { - if (originalAppView) +- (void)createWindow { + if (window) { + if (originalAppView) { originalAppView.frame = originalAppFrame; + } window.hidden = YES; window = nil; } @@ -174,25 +165,22 @@ CGRect swappedForOrientation2(CGRect in) [self reloadOtherAppsSection]; } --(void) reloadDesktopSection -{ +- (void)reloadDesktopSection { [window reloadDesktopSection]; } --(void) reloadWindowedAppsSection -{ +- (void)reloadWindowedAppsSection { [window reloadWindowedAppsSection:[[%c(RARunningAppsProvider) sharedInstance] runningApplications]]; } --(void) reloadOtherAppsSection -{ +- (void)reloadOtherAppsSection { [window reloadOtherAppsSection]; } --(void) hideMissionControl:(BOOL)animated -{ - if (!didStoreSnapshot) +- (void)hideMissionControl:(BOOL)animated { + if (!didStoreSnapshot) { [[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; + } [[%c(RARunningAppsProvider) sharedInstance] removeTarget:window]; void (^destructor)() = ^{ @@ -201,24 +189,26 @@ CGRect swappedForOrientation2(CGRect in) window = nil; // This goes here to prevent the wallpaper from appearing black when dismissing + //once again not needed on 10.x but not sure of older versions if (IS_IOS_OR_OLDER(iOS_10_0)) { [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"RAMissionControlManager"]; } }; - if (animated) - { + if (animated) { [UIView animateWithDuration:0.5 animations:^{ window.frame = swappedForOrientation(CGRectMake(0, -window.frame.size.height, window.frame.size.width, window.frame.size.height)); - if (originalAppView) - originalAppView.frame = originalAppFrame; - } completion:^(BOOL _) { destructor(); }]; - } - else - { - if (originalAppView) + if (originalAppView) { + originalAppView.frame = originalAppFrame; + } + } completion:^(BOOL _) { + destructor(); + }]; + } else { + if (originalAppView) { originalAppView.frame = originalAppFrame; + } destructor(); } @@ -240,133 +230,118 @@ CGRect swappedForOrientation2(CGRect in) lastOpenedApp = nil; // Fix it opening the same app later if on the Homescreen } --(void) toggleMissionControl:(BOOL)animated -{ - if (_isShowingMissionControl) +- (void)toggleMissionControl:(BOOL)animated { + if (_isShowingMissionControl) { [self hideMissionControl:animated]; - else + } else { [self showMissionControl:animated]; + } } --(BOOL) RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity -{ +- (BOOL)RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity { return self.isShowingMissionControl && !self.inhibitDismissalGesture; } --(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge -{ +- (RAGestureCallbackResult)RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { static CGPoint initialCenter; static CGRect initialAppFrame; - if (state == UIGestureRecognizerStateEnded) - { + if (state == UIGestureRecognizerStateEnded) { hasMoved = NO; [%c(RAControlCenterInhibitor) setInhibited:NO]; BOOL dismiss = NO; - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { dismiss = window.frame.origin.x + velocity.y > UIScreen.mainScreen.bounds.size.width / 2.0; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { dismiss = window.frame.origin.x + window.frame.size.width < UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2.0; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortrait) + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortrait) { dismiss = window.frame.origin.y + window.frame.size.height + velocity.y < UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 2; + } - if (dismiss) - { + if (dismiss) { // Close CGFloat distance = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - (window.frame.origin.y + window.frame.size.height); CGFloat duration = MIN(distance / velocity.y, 0.3); [UIView animateWithDuration:duration animations:^{ - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortrait) + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortrait) { window.center = CGPointMake(window.center.x, -initialCenter.y); - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { + } + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { CGRect f = window.frame; f.origin.x = UIScreen.mainScreen.bounds.size.width; window.frame = f; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { CGRect f = window.frame; f.origin.x = -UIScreen.mainScreen.bounds.size.width; window.frame = f; } - if (originalAppView) + if (originalAppView) { originalAppView.frame = originalAppFrame; + } } completion:^(BOOL _) { [self hideMissionControl:NO]; }]; - } - else - { + } else { CGFloat distance = window.center.y + window.frame.origin.y /* origin.y is less than 0 so the + is actually a - operation */; CGFloat duration = MIN(distance / velocity.y, 0.3); [UIView animateWithDuration:duration animations:^{ window.center = initialCenter; - if (originalAppView) + if (originalAppView) { originalAppView.frame = swappedForOrientation2(CGRectMake(originalAppFrame.origin.x, originalAppView.frame.size.height, originalAppFrame.size.width, originalAppFrame.size.height)); + } }]; } - } - else if (state == UIGestureRecognizerStateBegan) - { + } else if (state == UIGestureRecognizerStateBegan) { //[[%c(RASnapshotProvider) sharedInstance] storeSnapshotOfMissionControl:window]; didStoreSnapshot = YES; hasMoved = YES; [%c(RAControlCenterInhibitor) setInhibited:YES]; initialCenter = window.center; - if (originalAppView) + if (originalAppView) { initialAppFrame = initialAppFrame; - } - else - { - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { + } + } else { + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { CGRect f = window.frame; f.origin.x = UIScreen.mainScreen.bounds.size.width - location.y; window.frame = f; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { CGRect f = window.frame; f.origin.x = -UIScreen.mainScreen.bounds.size.width + location.y; window.frame = f; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortrait) + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortrait) { window.center = CGPointMake(window.center.x, location.y - initialCenter.y); + } - if (originalAppView) + if (originalAppView) { originalAppView.frame = swappedForOrientation2(CGRectMake(originalAppView.frame.origin.x, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - location.y), originalAppFrame.size.width, originalAppFrame.size.height)); + } } return RAGestureCallbackResultSuccess; } --(RAMissionControlWindow*) missionControlWindow { return window; } +- (RAMissionControlWindow*)missionControlWindow { + return window; +} --(void) setInhibitDismissalGesture:(BOOL)value -{ +- (void)setInhibitDismissalGesture:(BOOL)value { _inhibitDismissalGesture = value; - if (value && hasMoved) - { + if (value && hasMoved) { [self RAGestureCallback_handle:UIGestureRecognizerStateEnded withPoint:CGPointZero velocity:CGPointZero forEdge:UIRectEdgeBottom]; } } @end %hook SBLockStateAggregator --(void) _updateLockState -{ +- (void)_updateLockState { %orig; - if ([self hasAnyLockState]) - if (RAMissionControlManager.sharedInstance.isShowingMissionControl) - [RAMissionControlManager.sharedInstance hideMissionControl:NO]; + if ([self hasAnyLockState] && [RAMissionControlManager sharedInstance].isShowingMissionControl) { + [RAMissionControlManager.sharedInstance hideMissionControl:NO]; + } } %end diff --git a/MissionControl/RAMissionControlPreviewView.h b/MissionControl/RAMissionControlPreviewView.h index 0599dce..04f244b 100644 --- a/MissionControl/RAMissionControlPreviewView.h +++ b/MissionControl/RAMissionControlPreviewView.h @@ -6,7 +6,7 @@ } @property (nonatomic, retain) SBApplication *application; --(void) generatePreview; --(void) generatePreviewAsync; --(void) generateDesktopPreviewAsync:(id)desktop completion:(dispatch_block_t)completionBlock; +- (void)generatePreview; +- (void)generatePreviewAsync; +- (void)generateDesktopPreviewAsync:(id)desktop completion:(dispatch_block_t)completionBlock; @end diff --git a/MissionControl/RAMissionControlPreviewView.xm b/MissionControl/RAMissionControlPreviewView.xm index bb152e0..2279b21 100644 --- a/MissionControl/RAMissionControlPreviewView.xm +++ b/MissionControl/RAMissionControlPreviewView.xm @@ -3,8 +3,7 @@ #import "RADesktopWindow.h" @implementation RAMissionControlPreviewView --(void) generatePreview -{ +- (void)generatePreview { [self performSelectorOnMainThread:@selector(setBackgroundColor:) withObject:[[UIColor blackColor] colorWithAlphaComponent:0.5] waitUntilDone:NO]; //self.image = [[%c(RASnapshotProvider) sharedInstance] snapshotForIdentifier:self.application.bundleIdentifier]; UIImage *img = [[%c(RASnapshotProvider) sharedInstance] snapshotForIdentifier:self.application.bundleIdentifier]; @@ -48,28 +47,27 @@ [self performSelectorOnMainThread:@selector(updateIconViewFrame) withObject:nil waitUntilDone:NO]; } --(void) generatePreviewAsync -{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ - [self generatePreview]; - }); +- (void)generatePreviewAsync { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ + [self generatePreview]; + }); } --(void) generateDesktopPreviewAsync:(id)desktop_ completion:(dispatch_block_t)completionBlock -{ - RADesktopWindow *desktop = (RADesktopWindow*)desktop_; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ - UIImage *image = [[%c(RASnapshotProvider) sharedInstance] snapshotForDesktop:desktop]; - [self performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES]; - if (completionBlock) - completionBlock(); - }); +- (void)generateDesktopPreviewAsync:(id)desktop_ completion:(dispatch_block_t)completionBlock { + RADesktopWindow *desktop = (RADesktopWindow*)desktop_; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ + UIImage *image = [[%c(RASnapshotProvider) sharedInstance] snapshotForDesktop:desktop]; + [self performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES]; + if (completionBlock) { + completionBlock(); + } + }); } --(void) updateIconViewFrame -{ - if (!iconView) - return; +- (void)updateIconViewFrame { + if (!iconView) { + return; + } [self bringSubviewToFront:iconView]; iconView.frame = CGRectMake( (self.frame.size.width / 2) - (iconView.frame.size.width / 2), (self.frame.size.height / 2) - (iconView.frame.size.height / 2), iconView.frame.size.width, iconView.frame.size.height ); } diff --git a/MissionControl/RAMissionControlWindow.h b/MissionControl/RAMissionControlWindow.h index b6e7d54..4341ded 100644 --- a/MissionControl/RAMissionControlWindow.h +++ b/MissionControl/RAMissionControlWindow.h @@ -6,8 +6,8 @@ @interface RAMissionControlWindow : UIAutoRotatingWindow @property (nonatomic, weak) RAMissionControlManager *manager; --(void) reloadDesktopSection; --(void) reloadWindowedAppsSection; --(void) reloadWindowedAppsSection:(NSArray*)runningApplications; --(void) reloadOtherAppsSection; -@end \ No newline at end of file +- (void)reloadDesktopSection; +- (void)reloadWindowedAppsSection; +- (void)reloadWindowedAppsSection:(NSArray*)runningApplications; +- (void)reloadOtherAppsSection; +@end diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index df34de2..f9d8f95 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -30,34 +30,28 @@ @end @implementation RAMissionControlWindow --(instancetype) initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) - { +- (instancetype)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { trashIcon = [%c(RAResourceImageProvider) imageForFilename:@"Trash.png"]; } return self; } --(UIWindowLevel) windowLevel -{ +- (UIWindowLevel)windowLevel { //return UIWindowLevelStatusBar + 1; return 1000; } -- (BOOL)_shouldAutorotateToInterfaceOrientation:(int)arg1 checkForDismissal:(BOOL)arg2 isRotationDisabled:(BOOL*)arg3 -{ +- (BOOL)_shouldAutorotateToInterfaceOrientation:(int)arg1 checkForDismissal:(BOOL)arg2 isRotationDisabled:(BOOL*)arg3 { return YES; } --(void) reloadDesktopSection -{ +- (void)reloadDesktopSection { width = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 4.5714; height = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 4.36; panePadding = width; int count = 1; - while (panePadding + width < UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width) - { + while (panePadding + width < UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width) { count += 1; panePadding += width; } @@ -71,12 +65,9 @@ // DESKTOP CGFloat y = 20; - if (desktopScrollView) - { + if (desktopScrollView) { [desktopScrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; - } - else - { + } else { desktopLabel = [[UILabel alloc] initWithFrame:CGRectMake(panePadding, y, self.frame.size.width - 20, 25)]; desktopLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; desktopLabel.textColor = UIColor.whiteColor; @@ -94,8 +85,7 @@ CGFloat x = panePadding; int desktopIndex = 0; - for (RADesktopWindow *desktop in [[%c(RADesktopManager) sharedInstance] availableDesktops]) - { + for (RADesktopWindow *desktop in [[%c(RADesktopManager) sharedInstance] availableDesktops]) { RAMissionControlPreviewView *preview = [[RAMissionControlPreviewView alloc] initWithFrame:CGRectMake(x, (desktopScrollView.frame.size.height - height) / 2.0, width, height)]; x += panePadding + preview.frame.size.width; @@ -103,16 +93,13 @@ //preview.image = [[%c(RASnapshotProvider) sharedInstance] snapshotForDesktop:desktop]; [preview generateDesktopPreviewAsync:desktop completion:desktop == [[%c(RADesktopManager) sharedInstance] currentDesktop] ? ^{ [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; } : (dispatch_block_t)nil]; - if (desktop == [[%c(RADesktopManager) sharedInstance] currentDesktop] && [[%c(RASettings) sharedInstance] missionControlDesktopStyle] == 0) - { + if (desktop == [[%c(RADesktopManager) sharedInstance] currentDesktop] && [[%c(RASettings) sharedInstance] missionControlDesktopStyle] == 0) { preview.backgroundColor = [UIColor grayColor]; preview.clipsToBounds = YES; preview.layer.borderWidth = 2; preview.layer.cornerRadius = 10; preview.layer.borderColor = [UIColor whiteColor].CGColor; - } - else if (desktop != [[%c(RADesktopManager) sharedInstance] currentDesktop] && [[%c(RASettings) sharedInstance] missionControlDesktopStyle] == 1) - { + } else if (desktop != [[%c(RADesktopManager) sharedInstance] currentDesktop] && [[%c(RASettings) sharedInstance] missionControlDesktopStyle] == 1) { UIView *crapView = [[UIView alloc] initWithFrame:(CGRect){{ 0, 0 }, preview.frame.size }]; crapView.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.5]; [preview addSubview:crapView]; @@ -154,13 +141,11 @@ //height = UIScreen.mainScreen.bounds.size.height / 4.36; } --(void) reloadWindowedAppsSection -{ +- (void)reloadWindowedAppsSection { [self reloadWindowedAppsSection:runningApplications]; } --(void) reloadWindowedAppsSection:(NSArray*)runningApplicationsArg -{ +-(void) reloadWindowedAppsSection:(NSArray*)runningApplicationsArg { runningApplications = [runningApplicationsArg mutableCopy]; NSArray *switcherOrder = [[%c(RAAppSwitcherModelWrapper) appSwitcherAppIdentiferList] copy]; @@ -176,21 +161,18 @@ visibleIcons = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers]; } - for (SBApplication *app in runningApplications) - { - if (![visibleIcons containsObject:app.bundleIdentifier])// || [RAMissionControlManager.sharedInstance.inhibitedApplications containsObject:app.bundleIdentifier]) + for (SBApplication *app in runningApplications) { + if (![visibleIcons containsObject:app.bundleIdentifier]) { [appsWithoutWindows removeObject:app]; + }// || [RAMissionControlManager.sharedInstance.inhibitedApplications containsObject:app.bundleIdentifier]) } CGFloat x = panePadding; CGFloat y = desktopScrollView.frame.origin.y + desktopScrollView.frame.size.height + 7; - if (windowedAppScrollView) - { + if (windowedAppScrollView) { [windowedAppScrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; - } - else - { + } else { windowedLabel = [[UILabel alloc] initWithFrame:CGRectMake(panePadding, y, self.frame.size.width - 20, 25)]; windowedLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; windowedLabel.textColor = UIColor.whiteColor; @@ -205,8 +187,7 @@ } BOOL empty = YES; - for (RAHostedAppView *app in [[%c(RADesktopManager) sharedInstance] currentDesktop].hostedWindows) - { + for (RAHostedAppView *app in [[%c(RADesktopManager) sharedInstance] currentDesktop].hostedWindows) { SBApplication *sbapp = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:app.bundleIdentifier]; [appsWithoutWindows removeObject:sbapp]; @@ -228,8 +209,7 @@ empty = NO; } - if (empty) - { + if (empty) { UILabel *emptyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (windowedAppScrollView.frame.size.height - 30) / 2, windowedAppScrollView.frame.size.width, 30)]; emptyLabel.textAlignment = NSTextAlignmentCenter; emptyLabel.font = [UIFont systemFontOfSize:25]; @@ -238,16 +218,12 @@ emptyLabel.alpha = 0.7; [windowedAppScrollView addSubview:emptyLabel]; - if (windowedKillAllButton) - { + if (windowedKillAllButton) { [windowedKillAllButton removeFromSuperview]; windowedKillAllButton = nil; } - } - else - { - if (!windowedKillAllButton) - { + } else { + if (!windowedKillAllButton) { windowedKillAllButton = [UIButton buttonWithType:UIButtonTypeCustom]; [windowedKillAllButton setTitle:LOCALIZE(@"KILL_ALL") forState:UIControlStateNormal]; windowedKillAllButton.titleLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; @@ -261,17 +237,13 @@ windowedAppScrollView.contentSize = CGSizeMake(MAX(x, self.frame.size.width + (empty ? 0 : 1)), height * 1.15); // make slightly scrollable } --(void) reloadOtherAppsSection -{ +- (void)reloadOtherAppsSection { CGFloat x = panePadding; CGFloat y = windowedAppScrollView.frame.origin.y + windowedAppScrollView.frame.size.height + 7; - if (otherRunningAppsScrollView) - { + if (otherRunningAppsScrollView) { [otherRunningAppsScrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; - } - else - { + } else { otherLabel = [[UILabel alloc] initWithFrame:CGRectMake(panePadding, y, self.frame.size.width - 20, 25)]; otherLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; otherLabel.textColor = UIColor.whiteColor; @@ -286,8 +258,7 @@ } BOOL empty = YES; - for (SBApplication *app in appsWithoutWindows) - { + for (SBApplication *app in appsWithoutWindows) { empty = NO; RAMissionControlPreviewView *preview = [[RAMissionControlPreviewView alloc] initWithFrame:CGRectMake(x, (otherRunningAppsScrollView.frame.size.height - height) / 2, width, height)]; @@ -307,8 +278,7 @@ preview.userInteractionEnabled = YES; } - if (empty) - { + if (empty) { UILabel *emptyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (windowedAppScrollView.frame.size.height - 30) / 2, windowedAppScrollView.frame.size.width, 30)]; emptyLabel.textAlignment = NSTextAlignmentCenter; emptyLabel.font = [UIFont systemFontOfSize:25]; @@ -317,16 +287,12 @@ emptyLabel.alpha = 0.7; [otherRunningAppsScrollView addSubview:emptyLabel]; - if (otherKillAllButton) - { + if (otherKillAllButton) { [otherKillAllButton removeFromSuperview]; otherKillAllButton = nil; } - } - else - { - if (!otherKillAllButton) - { + } else { + if (!otherKillAllButton) { otherKillAllButton = [UIButton buttonWithType:UIButtonTypeCustom]; [otherKillAllButton setTitle:LOCALIZE(@"KILL_ALL") forState:UIControlStateNormal]; otherKillAllButton.titleLabel.font = [UIFont fontWithName:(IS_IOS_OR_NEWER(iOS_9_0) ? @"SFUIText-Medium" : @"HelveticaNeue-Medium") size:14]; @@ -341,8 +307,7 @@ otherRunningAppsScrollView.contentSize = CGSizeMake(MAX(x, self.frame.size.width + (empty ? 0 : 1)), height * 1.15); // make slightly scrollable } --(void) createNewDesktop:(UIButton*)view -{ +- (void)createNewDesktop:(UIButton*)view { [[%c(RADesktopManager) sharedInstance] addDesktop:NO]; [UIView animateWithDuration:0.4 animations:^{ @@ -352,59 +317,52 @@ }]; } --(void) removeCardForApplication:(SBApplication*)app -{ +- (void)removeCardForApplication:(SBApplication*)app { CGFloat originX = -1; UIView *targetView = nil; UIScrollView *parentView = [appsWithoutWindows containsObject:app] ? otherRunningAppsScrollView : windowedAppScrollView; NSArray *subviews = [parentView.subviews copy]; - for (UIView *view in subviews) - { - if ([view isKindOfClass:[RAMissionControlPreviewView class]]) - { + for (UIView *view in subviews) { + if ([view isKindOfClass:[RAMissionControlPreviewView class]]) { RAMissionControlPreviewView *real = (RAMissionControlPreviewView*)view; - if ([real.application.bundleIdentifier isEqualToString:app.bundleIdentifier]) - { + if ([real.application.bundleIdentifier isEqualToString:app.bundleIdentifier]) { originX = view.frame.origin.x; targetView = view; } } - if (originX == -1) + if (originX == -1) { continue; - else if (view.frame.origin.x == originX) - { + } else if (view.frame.origin.x == originX) { [UIView animateWithDuration:0.2 animations:^{ view.frame = CGRectOffset(view.frame, 0, view.frame.size.height + panePadding); } completion:^(BOOL _) { [view removeFromSuperview]; }]; - } - else if (view.frame.origin.x > originX) + } else if (view.frame.origin.x > originX) { [UIView animateWithDuration:0.4 animations:^{ view.frame = CGRectOffset(view.frame, -view.frame.size.width - panePadding, 0); }]; + } } - if (parentView.contentSize.width - 1 <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width) + if (parentView.contentSize.width - 1 <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width) { ; // don't make it too small to scroll - else if (targetView) + } else if (targetView) { parentView.contentSize = CGSizeMake(parentView.contentSize.width - targetView.frame.size.width - panePadding + 1, parentView.contentSize.height); + } } --(void) handleAppPreviewPan:(UILongPressGestureRecognizer*)gesture -{ +- (void)handleAppPreviewPan:(UILongPressGestureRecognizer*)gesture { static CGPoint initialCenter; static UIView *draggedView; static CGPoint lastPoint; CGPoint point = [gesture locationInView:self]; - if (gesture.state == UIGestureRecognizerStateBegan) - { - if (!trashImageView || !trashImageView.superview /* new window perhaps */) - { + if (gesture.state == UIGestureRecognizerStateBegan) { + if (!trashImageView || !trashImageView.superview /* new window perhaps */) { trashImageView = [[UIImageView alloc] initWithFrame:CGRectMake((UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2) - (75/2), UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height + 75, 75, 75)]; trashImageView.image = trashIcon; [self addSubview:trashImageView]; @@ -424,8 +382,7 @@ trashImageView.frame = CGRectMake((UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2) - (75/2), UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - (75+45), 75, 75); }]; - if (!draggedView) - { + if (!draggedView) { draggedView = [gesture.view snapshotViewAfterScreenUpdates:YES]; draggedView.frame = gesture.view.frame; draggedView.center = [gesture.view.superview convertPoint:gesture.view.center toView:self]; @@ -438,9 +395,7 @@ }]; } initialCenter = draggedView.center; - } - else if (gesture.state == UIGestureRecognizerStateChanged) - { + } else if (gesture.state == UIGestureRecognizerStateChanged) { //CGPoint newCenter = [gesture translationInView:draggedView]; //newCenter.x += initialCenter.x; //newCenter.y += initialCenter.y; @@ -450,9 +405,7 @@ center.x += point.x - lastPoint.x; center.y += point.y - lastPoint.y; draggedView.center = center; - } - else - { + } else { gesture.view.alpha = 1; //CGPoint center = [gesture translationInView:draggedView]; @@ -464,12 +417,11 @@ BOOL didKill = NO; - if (CGRectContainsPoint(trashImageView.frame, center) || CGRectContainsPoint(CGRectOffset(shadowView.frame, 0, -(75/2)), center)) - { + if (CGRectContainsPoint(trashImageView.frame, center) || CGRectContainsPoint(CGRectOffset(shadowView.frame, 0, -(75/2)), center)) { SBApplication *app = ((RAMissionControlPreviewView*)gesture.view).application; [[%c(RADesktopManager) sharedInstance] removeAppWithIdentifier:app.bundleIdentifier animated:NO]; [[%c(RAWindowStatePreservationSystemManager) sharedInstance] removeWindowInformationForIdentifier:app.bundleIdentifier]; - if ([[%c(RASettings) sharedInstance] missionControlKillApps]) + if ([[%c(RASettings) sharedInstance] missionControlKillApps]) { [%c(RAAppKiller) killAppWithSBApplication:app completion:^{ [runningApplications removeObject:app]; @@ -481,6 +433,7 @@ // [self removeCardForApplication:app]; //}); }]; + } didKill = YES; } @@ -488,17 +441,12 @@ shadowView.alpha = 0; trashImageView.alpha = 0; trashImageView.frame = CGRectMake((UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2) - (75/2), UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height + 75, 75, 75); - } completion:^(BOOL _) { - }]; + } completion:nil]; - if (!didKill) - { - for (UIView *subview in desktopScrollView.subviews) - { - if ([subview isKindOfClass:[RAMissionControlPreviewView class]]) - { - if (CGRectContainsPoint((CGRect){ [desktopScrollView convertPoint:subview.frame.origin toView:self], subview.frame.size }, center) || (CGRectContainsPoint((CGRect){ [windowedAppScrollView convertPoint:subview.frame.origin toView:self], windowedAppScrollView.frame.size }, center) && gesture.view.superview != windowedAppScrollView)) - { + if (!didKill) { + for (UIView *subview in desktopScrollView.subviews) { + if ([subview isKindOfClass:[RAMissionControlPreviewView class]]) { + if (CGRectContainsPoint((CGRect){ [desktopScrollView convertPoint:subview.frame.origin toView:self], subview.frame.size }, center) || (CGRectContainsPoint((CGRect){ [windowedAppScrollView convertPoint:subview.frame.origin toView:self], windowedAppScrollView.frame.size }, center) && gesture.view.superview != windowedAppScrollView)) { RADesktopWindow *desktop = [[%c(RADesktopManager) sharedInstance] desktopAtIndex:subview.tag]; SBApplication *app = ((RAMissionControlPreviewView*)gesture.view).application; @@ -518,8 +466,7 @@ } [UIView animateWithDuration:0.4 animations:^{ - if (!didKill) - { + if (!didKill) { draggedView.transform = CGAffineTransformIdentity; draggedView.center = initialCenter; } @@ -531,22 +478,17 @@ lastPoint = point; } --(void) animateDesktopRemovalForDesktopAtIndexReloadingSectionAfter:(NSInteger)index -{ +- (void)animateDesktopRemovalForDesktopAtIndexReloadingSectionAfter:(NSInteger)index { CGFloat originX = -1; - for (UIView *v in desktopScrollView.subviews) - { - if (v.tag == index) - { + for (UIView *v in desktopScrollView.subviews) { + if (v.tag == index) { originX = v.frame.origin.x; [UIView animateWithDuration:0.2 animations:^{ v.frame = CGRectOffset(v.frame, 0, -panePadding); } completion:^(BOOL _) { [v removeFromSuperview]; }]; - } - else if (v.tag > index || (originX != -1 && originX < v.frame.origin.x)) - { + } else if (v.tag > index || (originX != -1 && originX < v.frame.origin.x)) { [UIView animateWithDuration:0.4 animations:^{ v.frame = CGRectOffset(v.frame, -v.frame.size.width - panePadding, 0); }]; @@ -557,51 +499,45 @@ }); } --(void) handleDesktopPan:(UIPanGestureRecognizer*)gesture -{ +- (void)handleDesktopPan:(UIPanGestureRecognizer*)gesture { static CGPoint initialCenter; - if (gesture.state == UIGestureRecognizerStateBegan) - { + if (gesture.state == UIGestureRecognizerStateBegan) { initialCenter = gesture.view.center; - } - else if (gesture.state == UIGestureRecognizerStateChanged) - { + } else if (gesture.state == UIGestureRecognizerStateChanged) { CGPoint newCenter = [gesture translationInView:gesture.view]; //newCenter.x += initialCenter.x; newCenter.x = initialCenter.x; - if (newCenter.y > 0 || gesture.view.tag == 0) + if (newCenter.y > 0 || gesture.view.tag == 0) { newCenter.y = initialCenter.y + (newCenter.y / 5); //initialCenter.y; - else + } else { newCenter.y += initialCenter.y; + } gesture.view.center = newCenter; - } - else - { - if (gesture.view.center.y - initialCenter.y < -80 && gesture.view.tag > 0) - { + } else { + if (gesture.view.center.y - initialCenter.y < -80 && gesture.view.tag > 0) { [[%c(RADesktopManager) sharedInstance] removeDesktopAtIndex:gesture.view.tag]; [UIView animateWithDuration:0.4 animations:^{ gesture.view.center = CGPointMake(gesture.view.center.x, -gesture.view.frame.size.height); } completion:^(BOOL _) { [self animateDesktopRemovalForDesktopAtIndexReloadingSectionAfter:gesture.view.tag]; }]; + } else { + [UIView animateWithDuration:0.4 animations:^{ + gesture.view.center = initialCenter; + }]; } - else - [UIView animateWithDuration:0.4 animations:^{ gesture.view.center = initialCenter; }]; } } --(void) activateDesktop:(UITapGestureRecognizer*)gesture -{ +- (void)activateDesktop:(UITapGestureRecognizer*)gesture { int desktop = gesture.view.tag; [[%c(RADesktopManager) sharedInstance] switchToDesktop:desktop]; [self.manager hideMissionControl:YES]; } --(void) handleSingleDesktopTap:(UITapGestureRecognizer*)gesture -{ +- (void)handleSingleDesktopTap:(UITapGestureRecognizer*)gesture { int desktop = gesture.view.tag; [[%c(RADesktopManager) sharedInstance] switchToDesktop:desktop actuallyShow:NO]; [self reloadDesktopSection]; @@ -609,13 +545,11 @@ [self reloadOtherAppsSection]; } --(void) handleDoubleDesktopTap:(UITapGestureRecognizer*)gesture -{ +- (void)handleDoubleDesktopTap:(UITapGestureRecognizer*)gesture { [self activateDesktop:gesture]; } --(void) topIconViewTap:(UITapGestureRecognizer*)gesture -{ +- (void)topIconViewTap:(UITapGestureRecognizer*)gesture { [self.manager hideMissionControl:YES]; __block __strong NSString *identifier = [[[gesture view] performSelector:@selector(application)] bundleIdentifier]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ @@ -624,12 +558,9 @@ }); } --(void) killAllWindowed -{ - for (UIView *view in windowedAppScrollView.subviews) - { - if ([view isKindOfClass:[RAMissionControlPreviewView class]]) - { +- (void)killAllWindowed { + for (UIView *view in windowedAppScrollView.subviews) { + if ([view isKindOfClass:[RAMissionControlPreviewView class]]) { RAMissionControlPreviewView *realView = (RAMissionControlPreviewView*)view; SBApplication *app = realView.application; [%c(RAAppKiller) killAppWithSBApplication:app completion:^{ @@ -641,12 +572,9 @@ } } --(void) killAllOther -{ - for (UIView *view in otherRunningAppsScrollView.subviews) - { - if ([view isKindOfClass:[RAMissionControlPreviewView class]]) - { +- (void)killAllOther { + for (UIView *view in otherRunningAppsScrollView.subviews) { + if ([view isKindOfClass:[RAMissionControlPreviewView class]]) { RAMissionControlPreviewView *realView = (RAMissionControlPreviewView*)view; SBApplication *app = realView.application; [%c(RAAppKiller) killAppWithSBApplication:app completion:^{ @@ -657,35 +585,32 @@ } } --(void) appDidStart:(SBApplication*)app -{ +- (void)appDidStart:(SBApplication*)app { [self reloadWindowedAppsSection:[[%c(RARunningAppsProvider) sharedInstance] runningApplications]]; [self reloadOtherAppsSection]; } --(void) appDidDie:(SBApplication*)app -{ +- (void)appDidDie:(SBApplication*)app { [self removeCardForApplication:app]; } --(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event -{ +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; UIView *subview; - while ((subview = [objects nextObject])) - { + while ((subview = [objects nextObject])) { UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; - if (success) + if (success) { return success; + } } return self; //return [super hitTest:point withEvent:event]; } -- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event -{ - if (CGRectContainsPoint(self.frame, point)) +- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { + if (CGRectContainsPoint(self.frame, point)) { return YES; + } return [super pointInside:point withEvent:event]; } @end diff --git a/Multiplexer.h b/Multiplexer.h index 1d17cab..218cce6 100644 --- a/Multiplexer.h +++ b/Multiplexer.h @@ -8,13 +8,13 @@ @interface Multiplexer : NSObject { NSMutableArray *activeExtensions; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(NSString*) currentVersion; --(BOOL) isOnSupportedOS; +- (NSString*)currentVersion; +- (BOOL)isOnSupportedOS; --(void) registerExtension:(NSString*)name forMultiplexerVersion:(NSString*)version; +- (void)registerExtension:(NSString*)name forMultiplexerVersion:(NSString*)version; -+(id) createSBAppToAppWorkspaceTransactionForExitingApp:(SBApplication*)app; -+(BOOL) shouldShowControlCenterGrabberOnFirstSwipe; ++ (id)createSBAppToAppWorkspaceTransactionForExitingApp:(SBApplication*)app; ++ (BOOL)shouldShowControlCenterGrabberOnFirstSwipe; @end diff --git a/Multiplexer.xm b/Multiplexer.xm index 7384fd8..ac49f72 100644 --- a/Multiplexer.xm +++ b/Multiplexer.xm @@ -6,18 +6,20 @@ @end @implementation Multiplexer -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(Multiplexer, sharedInstance->activeExtensions = [NSMutableArray array]); } --(NSString*) currentVersion { return @"1.0"; } --(BOOL) isOnSupportedOS { return IS_IOS_BETWEEN(iOS_8_0, iOS_10_2); } +- (NSString*)currentVersion { + return @"1.0"; +} + +- (BOOL)isOnSupportedOS { + return IS_IOS_BETWEEN(iOS_8_0, iOS_10_2); +} --(void) registerExtension:(NSString*)name forMultiplexerVersion:(NSString*)version -{ - if ([self.currentVersion compare:version options:NSNumericSearch] == NSOrderedDescending) - { +- (void)registerExtension:(NSString*)name forMultiplexerVersion:(NSString*)version { + if ([self.currentVersion compare:version options:NSNumericSearch] == NSOrderedDescending) { [RACompatibilitySystem showWarning:[NSString stringWithFormat:@"Extension %@ was built for Multiplexer version %@, which is above the current version. Compliancy issues may occur.", name, version]]; } @@ -27,14 +29,10 @@ [activeExtensions addObject:ext]; } -+ (SBAppToAppWorkspaceTransaction*)createSBAppToAppWorkspaceTransactionForExitingApp:(SBApplication*)app -{ - if ([%c(SBAppToAppWorkspaceTransaction) respondsToSelector:@selector(initWithAlertManager:exitedApp:)]) - { ++ (SBAppToAppWorkspaceTransaction*)createSBAppToAppWorkspaceTransactionForExitingApp:(SBApplication*)app { + if ([%c(SBAppToAppWorkspaceTransaction) respondsToSelector:@selector(initWithAlertManager:exitedApp:)]) { return [[%c(SBAppToAppWorkspaceTransaction) alloc] initWithAlertManager:nil exitedApp:app]; - } - else - { + } else { // ** below code from Mirmir (https://github.com/EthanArbuckle/Mirmir/blob/lamo_no_ms/Lamo/CDTLamo.mm#L114-L138) SBWorkspaceApplicationTransitionContext *transitionContext = [[%c(SBWorkspaceApplicationTransitionContext) alloc] init]; @@ -57,10 +55,10 @@ } } -+(BOOL) shouldShowControlCenterGrabberOnFirstSwipe -{ - if ([%c(SBUIController) respondsToSelector:@selector(shouldShowControlCenterTabControlOnFirstSwipe)]) ++ (BOOL)shouldShowControlCenterGrabberOnFirstSwipe { + if ([%c(SBUIController) respondsToSelector:@selector(shouldShowControlCenterTabControlOnFirstSwipe)]) { [[%c(SBUIController) sharedInstance] shouldShowControlCenterTabControlOnFirstSwipe]; + } return [[%c(SBControlCenterController) sharedInstance] _shouldShowGrabberOnFirstSwipe]; } @end diff --git a/NotificationCenterApp/NCHook.xm b/NotificationCenterApp/NCHook.xm index f578270..dd8e981 100644 --- a/NotificationCenterApp/NCHook.xm +++ b/NotificationCenterApp/NCHook.xm @@ -4,19 +4,18 @@ #import "headers.h" @interface SBNotificationCenterViewController () --(id)_newBulletinObserverViewControllerOfClass:(Class)aClass; +- (id)_newBulletinObserverViewControllerOfClass:(Class)aClass; @end @interface SBNotificationCenterLayoutViewController @end @interface SBModeViewController --(void) _addBulletinObserverViewController:(id)arg1; +- (void)_addBulletinObserverViewController:(id)arg1; - (void)addViewController:(id)arg1; @end -NSString *getAppName() -{ +NSString *getAppName() { NSString *ident = [RASettings.sharedInstance NCApp] ?: @"com.apple.Preferences"; SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:ident]; return app ? app.displayName : nil; @@ -27,49 +26,46 @@ BOOL shouldLoadView = NO; %group iOS8 %hook SBNotificationCenterViewController -- (void)viewWillAppear:(BOOL)animated -{ +- (void)viewWillAppear:(BOOL)animated { %orig; BOOL hideBecauseLS = [[%c(SBLockScreenManager) sharedInstance] isUILocked] ? [RASettings.sharedInstance ncAppHideOnLS] : NO; - if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) - { + if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) { SBModeViewController* modeVC = MSHookIvar(self, "_modeController"); - if (!ncAppViewController) + if (!ncAppViewController) { ncAppViewController = [self _newBulletinObserverViewControllerOfClass:[RANCViewController class]]; + } [modeVC _addBulletinObserverViewController:ncAppViewController]; } } -+ (NSString *)_localizableTitleForBulletinViewControllerOfClass:(__unsafe_unretained Class)aClass -{ - if (aClass == [RANCViewController class]) - { ++ (NSString *)_localizableTitleForBulletinViewControllerOfClass:(__unsafe_unretained Class)aClass { + if (aClass == [RANCViewController class]) { BOOL useGenericLabel = THEMED(quickAccessUseGenericTabLabel) || [RASettings.sharedInstance quickAccessUseGenericTabLabel]; - if (useGenericLabel) + if (useGenericLabel) { return LOCALIZE(@"APP"); + } return ncAppViewController.hostedApp.displayName ?: getAppName() ?: LOCALIZE(@"APP"); - } - else + } else { return %orig; + } } %end %end %group iOS9 %hook SBNotificationCenterLayoutViewController -- (void)viewWillAppear:(BOOL)animated -{ +- (void)viewWillAppear:(BOOL)animated { %orig; BOOL hideBecauseLS = [[%c(SBLockScreenManager) sharedInstance] isUILocked] ? [RASettings.sharedInstance ncAppHideOnLS] : NO; - if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) - { + if ([RASettings.sharedInstance NCAppEnabled] && !hideBecauseLS) { SBModeViewController* modeVC = MSHookIvar(self, "_modeViewController"); - if (!ncAppViewController) + if (!ncAppViewController) { ncAppViewController = [[RANCViewController alloc] init]; + } [modeVC _addBulletinObserverViewController:ncAppViewController]; } } @@ -78,24 +74,23 @@ BOOL shouldLoadView = NO; // This is more of a hack than anything else. Note that `_localizableTitleForColumnViewController` on iOS 9 does not seem to work (I may be doing something else wrong) // if more than one custom nc tab is added, this will not work correctly. %hook SBModeViewController -- (void)_layoutHeaderViewIfNecessary -{ +- (void)_layoutHeaderViewIfNecessary { %orig; NSString *text = @""; BOOL useGenericLabel = THEMED(quickAccessUseGenericTabLabel) || [RASettings.sharedInstance quickAccessUseGenericTabLabel]; - if (useGenericLabel) + if (useGenericLabel) { text = LOCALIZE(@"APP"); - else + } else { text = ncAppViewController.hostedApp.displayName ?: getAppName() ?: LOCALIZE(@"APP"); + } - for (UIView *view in MSHookIvar(self, "_headerView").subviews) - { - if ([view isKindOfClass:[UISegmentedControl class]]) - { + for (UIView *view in MSHookIvar(self, "_headerView").subviews) { + if ([view isKindOfClass:[UISegmentedControl class]]) { UISegmentedControl *segment = (UISegmentedControl*)view; - if (segment.numberOfSegments > 2) + if (segment.numberOfSegments > 2) { [segment setTitle:text forSegmentAtIndex:2]; + } } } } @@ -106,12 +101,10 @@ BOOL shouldLoadView = NO; %hook SBPagedScrollView static BOOL hasEnteredPages = NO; -- (void)layoutSubviews -{ +- (void)layoutSubviews { %orig; - if (!hasEnteredPages && [RASettings.sharedInstance NCAppEnabled] && [self.superview isKindOfClass:[%c(SBSearchEtceteraLayoutView) class]] && [[%c(SBNotificationCenterController) sharedInstance] isVisible]) - { + if (!hasEnteredPages && [RASettings.sharedInstance NCAppEnabled] && [self.superview isKindOfClass:[%c(SBSearchEtceteraLayoutView) class]] && [[%c(SBNotificationCenterController) sharedInstance] isVisible]) { if (!ncAppViewController) { ncAppViewController = [[RANCViewController alloc] init]; } @@ -125,24 +118,21 @@ static BOOL hasEnteredPages = NO; %end %hook SBNotificationCenterViewController -- (void)viewWillAppear:(BOOL)arg1 -{ +- (void)viewWillAppear:(BOOL)arg1 { %orig; shouldLoadView = YES; [ncAppViewController viewDidAppear:arg1]; } -- (void)viewDidDisappear:(BOOL)arg1 -{ +- (void)viewDidDisappear:(BOOL)arg1 { %orig; shouldLoadView = NO; [ncAppViewController viewDidDisappear:arg1]; } -- (UIPageControl*)pageControl -{ +- (UIPageControl*)pageControl { UIPageControl *original = %orig; original.numberOfPages = 3; return original; @@ -150,18 +140,12 @@ static BOOL hasEnteredPages = NO; %end %end -%ctor -{ - if (IS_IOS_OR_NEWER(iOS_10_0)) - { +%ctor { + if (IS_IOS_OR_NEWER(iOS_10_0)) { %init(iOS10); - } - else if (IS_IOS_BETWEEN(iOS_9_0, iOS_9_3)) - { + } else if (IS_IOS_BETWEEN(iOS_9_0, iOS_9_3)) { %init(iOS9); - } - else - { + } else { %init(iOS8); } } diff --git a/NotificationCenterApp/RANCViewController.h b/NotificationCenterApp/RANCViewController.h index 5e9a522..d88f4ea 100644 --- a/NotificationCenterApp/RANCViewController.h +++ b/NotificationCenterApp/RANCViewController.h @@ -6,8 +6,8 @@ @end @interface RANCViewController : SBNCColumnViewController -+(instancetype) sharedViewController; ++ (instancetype)sharedViewController; --(RAHostedAppView*) hostedApp; --(void) forceReloadAppLikelyBecauseTheSettingChanged; +- (RAHostedAppView*)hostedApp; +- (void)forceReloadAppLikelyBecauseTheSettingChanged; @end diff --git a/NotificationCenterApp/RANCViewController.xm b/NotificationCenterApp/RANCViewController.xm index 43d0462..81ce35a 100644 --- a/NotificationCenterApp/RANCViewController.xm +++ b/NotificationCenterApp/RANCViewController.xm @@ -15,32 +15,30 @@ extern RANCViewController *ncAppViewController; extern BOOL shouldLoadView; @implementation RANCViewController -+(instancetype) sharedViewController -{ ++ (instancetype)sharedViewController { return ncAppViewController; } --(void) forceReloadAppLikelyBecauseTheSettingChanged -{ +- (void)forceReloadAppLikelyBecauseTheSettingChanged { [appView unloadApp]; [appView removeFromSuperview]; appView = nil; } -int patchOrientation(int in) -{ - if (in == 3) +int patchOrientation(int in) { + if (in == 3) { return 1; + } return in; } -int rotationDegsForOrientation(int o) -{ - if (o == UIInterfaceOrientationLandscapeRight) +int rotationDegsForOrientation(int o) { + if (o == UIInterfaceOrientationLandscapeRight) { return 270; - else if (o == UIInterfaceOrientationLandscapeLeft) + } else if (o == UIInterfaceOrientationLandscapeLeft) { return 90; + } return 0; } @@ -49,34 +47,27 @@ int rotationDegsForOrientation(int o) //-(void)hostWillDismiss; //-(void)hostDidDismiss; -- (void)insertAppropriateViewWithContent -{ +- (void)insertAppropriateViewWithContent { [self viewDidAppear:YES]; } -- (void)insertTableView -{ +- (void)insertTableView { } -- (void)viewWillLayoutSubviews -{ +- (void)viewWillLayoutSubviews { [self viewDidAppear:YES]; } --(void) viewDidAppear:(BOOL)animated -{ +- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - if (IS_IOS_OR_NEWER(iOS_10_0) && !shouldLoadView) - { + if (IS_IOS_OR_NEWER(iOS_10_0) && !shouldLoadView) { return; } - if ([[%c(SBLockScreenManager) sharedInstance] isUILocked]) - { - if (!isLockedLabel) - { + if ([[%c(SBLockScreenManager) sharedInstance] isUILocked]) { + if (!isLockedLabel) { isLockedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 400)]; isLockedLabel.numberOfLines = 2; isLockedLabel.textAlignment = NSTextAlignmentCenter; @@ -89,15 +80,12 @@ int rotationDegsForOrientation(int o) isLockedLabel.text = LOCALIZE(@"UNLOCK_FOR_NCAPP"); return; - } - else if (isLockedLabel) - { + } else if (isLockedLabel) { [isLockedLabel removeFromSuperview]; isLockedLabel = nil; } - if (!appView) - { + if (!appView) { NSString *ident = [RASettings.sharedInstance NCApp]; appView = [[RAHostedAppView alloc] initWithBundleIdentifier:ident]; appView.frame = UIScreen.mainScreen.bounds; @@ -109,15 +97,12 @@ int rotationDegsForOrientation(int o) [appView loadApp]; appView.hideStatusBar = YES; - if (NO)// (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)) - { + if (NO) {// (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)) appView.autosizesApp = YES; appView.allowHidingStatusBar = YES; appView.transform = CGAffineTransformIdentity; appView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); - } - else - { + } else { appView.autosizesApp = NO; appView.allowHidingStatusBar = YES; @@ -138,55 +123,51 @@ int rotationDegsForOrientation(int o) //[appView rotateToOrientation:UIApplication.sharedApplication.statusBarOrientation]; - if (IS_IOS_BETWEEN(iOS_9_0, iOS_9_3)) // Must manually place view controller :( - { + if (IS_IOS_BETWEEN(iOS_9_0, iOS_9_3)) { // Must manually place view controller :( CGRect frame = self.view.frame; frame.origin.x = UIScreen.mainScreen.bounds.size.width * 2.0; self.view.frame = frame; } } -- (void)hostDidDismiss -{ - if (appView.isCurrentlyHosting) - { +- (void)hostDidDismiss { + if (appView.isCurrentlyHosting) { appView.hideStatusBar = NO; [appView unloadApp]; } } --(void) viewDidDisappear:(BOOL)animated -{ +- (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; appView.hideStatusBar = NO; - if (appView.isCurrentlyHosting) - { + if (appView.isCurrentlyHosting) { [appView unloadApp]; } } --(RAHostedAppView*) hostedApp { return appView; } +- (RAHostedAppView*)hostedApp { + return appView; +} -- (void)forwardInvocation:(NSInvocation *)anInvocation -{ +- (void)forwardInvocation:(NSInvocation *)anInvocation { // Override LogDebug(@"[ReachApp] RANCViewController: ignoring invocation: %@", anInvocation); } -- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector -{ +- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { NSMethodSignature *signature = [super methodSignatureForSelector:aSelector]; - if (!signature && class_respondsToSelector(%c(SBBulletinObserverViewController), aSelector)) + if (!signature && class_respondsToSelector(%c(SBBulletinObserverViewController), aSelector)) { signature = [%c(SBBulletinObserverViewController) instanceMethodSignatureForSelector:aSelector]; + } return signature; } -- (BOOL)isKindOfClass:(Class)aClass -{ - if (aClass == %c(SBBulletinObserverViewController) || aClass == %c(SBNCColumnViewController)) +- (BOOL)isKindOfClass:(Class)aClass { + if (aClass == %c(SBBulletinObserverViewController) || aClass == %c(SBNCColumnViewController)) { return YES; - else + } else { return [super isKindOfClass:aClass]; + } } @end diff --git a/RAAppKiller.h b/RAAppKiller.h index 5f90de7..4229da1 100644 --- a/RAAppKiller.h +++ b/RAAppKiller.h @@ -2,9 +2,8 @@ #import "RARunningAppsProvider.h" @interface RAAppKiller : NSObject -+(void) killAppWithIdentifier:(NSString*)identifier; -+(void) killAppWithIdentifier:(NSString*)identifier completion:(void(^)())handler; -+(void) killAppWithSBApplication:(SBApplication*)app; -+(void) killAppWithSBApplication:(SBApplication*)app completion:(void(^)())handler; ++ (void)killAppWithIdentifier:(NSString*)identifier; ++ (void)killAppWithIdentifier:(NSString*)identifier completion:(void(^)())handler; ++ (void)killAppWithSBApplication:(SBApplication*)app; ++ (void)killAppWithSBApplication:(SBApplication*)app completion:(void(^)())handler; @end - diff --git a/RAAppKiller.xm b/RAAppKiller.xm index 27e6d84..6b48f43 100644 --- a/RAAppKiller.xm +++ b/RAAppKiller.xm @@ -9,35 +9,29 @@ extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSStrin @end @implementation RAAppKiller : NSObject -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RAAppKiller, [sharedInstance initialize]; ); } -+(void) killAppWithIdentifier:(NSString*)identifier -{ ++ (void)killAppWithIdentifier:(NSString*)identifier { return [RAAppKiller killAppWithIdentifier:identifier completion:nil]; } -+(void) killAppWithIdentifier:(NSString*)identifier completion:(void(^)())handler -{ ++ (void)killAppWithIdentifier:(NSString*)identifier completion:(void(^)())handler { return [RAAppKiller killAppWithSBApplication:[[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier] completion:handler]; } -+(void) killAppWithSBApplication:(SBApplication*)app -{ ++ (void)killAppWithSBApplication:(SBApplication*)app { return [RAAppKiller killAppWithSBApplication:app completion:nil]; } -+(void) killAppWithSBApplication:(SBApplication*)app completion:(void(^)())handler -{ ++ (void)killAppWithSBApplication:(SBApplication*)app completion:(void(^)())handler { return [RAAppKiller checkAppDead:app withTries:0 andCompletion:handler]; } -+(void) checkAppDead:(SBApplication*)app withTries:(int)tries andCompletion:(void(^)())handler -{ ++ (void)checkAppDead:(SBApplication*)app withTries:(int)tries andCompletion:(void(^)())handler { /* BOOL isDeadOrMaxed = (app.pid == 0 || app.isRunning == NO) && tries < 5; if (isDeadOrMaxed) @@ -78,16 +72,13 @@ extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSStrin BKSTerminateApplicationForReasonAndReportWithDescription(app.bundleIdentifier, 5, 1, @"Multiplexer requested this process to be slayed."); } --(void) initialize -{ +- (void)initialize { completionDictionary = [NSMutableDictionary dictionary]; [RARunningAppsProvider.sharedInstance addTarget:self]; } --(void) appDidDie:(__unsafe_unretained SBApplication*)app -{ - if (completionDictionary && [completionDictionary objectForKey:app.bundleIdentifier]) - { +- (void)appDidDie:(__unsafe_unretained SBApplication*)app { + if (completionDictionary && [completionDictionary objectForKey:app.bundleIdentifier]) { dispatch_block_t block = completionDictionary[app.bundleIdentifier]; block(); [completionDictionary removeObjectForKey:app.bundleIdentifier]; diff --git a/RAAppSelectorView.h b/RAAppSelectorView.h index 824cfff..0826c21 100644 --- a/RAAppSelectorView.h +++ b/RAAppSelectorView.h @@ -3,11 +3,11 @@ @class RAAppSelectorView; @protocol RAAppSelectorViewDelegate --(void) appSelector:(RAAppSelectorView*)view appWasSelected:(NSString*)bundleIdentifier; +- (void)appSelector:(RAAppSelectorView*)view appWasSelected:(NSString*)bundleIdentifier; @end @interface RAAppSelectorView : UIScrollView @property (nonatomic, weak) NSObject *target; --(void) relayoutApps; -@end \ No newline at end of file +- (void)relayoutApps; +@end diff --git a/RAAppSelectorView.xm b/RAAppSelectorView.xm index 0bd37b7..e844e79 100644 --- a/RAAppSelectorView.xm +++ b/RAAppSelectorView.xm @@ -1,18 +1,16 @@ #import "RAAppSelectorView.h" @implementation RAAppSelectorView --(instancetype) initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) - { +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7]; self.scrollEnabled = YES; } return self; } --(void) relayoutApps -{ +- (void)relayoutApps { [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; static CGSize fullSize = [%c(SBIconView) defaultIconSize]; @@ -21,8 +19,7 @@ NSInteger numIconsPerLine = 0; CGFloat tmpWidth = 10; - while (tmpWidth + fullSize.width <= self.frame.size.width) - { + while (tmpWidth + fullSize.width <= self.frame.size.width) { numIconsPerLine++; tmpWidth += fullSize.width + 20; } @@ -32,22 +29,21 @@ int horizontal = 0; static NSMutableArray *allApps = nil; - if (!allApps) - { + if (!allApps) { if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { allApps = [[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] mutableCopy]; } else { allApps = [[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] mutableCopy]; } - [allApps sortUsingComparator: ^(NSString* a, NSString* b) { - NSString *a_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:a].displayName; - NSString *b_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:b].displayName; - return [a_ caseInsensitiveCompare:b_]; + [allApps sortUsingComparator: ^(NSString* a, NSString* b) { + NSString *a_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:a].displayName; + NSString *b_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:b].displayName; + return [a_ caseInsensitiveCompare:b_]; }]; //[allApps removeObject:currentBundleIdentifier]; } - for (NSString *str in allApps) - { + + for (NSString *str in allApps) { SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:str]; SBApplicationIcon *icon = nil; SBIconView *iconView = nil; @@ -58,15 +54,15 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) + if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) { continue; + } iconView.frame = CGRectMake(contentSize.width, contentSize.height, iconView.frame.size.width, iconView.frame.size.height); contentSize.width += iconView.frame.size.width + padding; horizontal++; - if (horizontal >= numIconsPerLine) - { + if (horizontal >= numIconsPerLine) { horizontal = 0; contentSize.width = padding; contentSize.height += iconView.frame.size.height + 10; @@ -82,10 +78,9 @@ self.contentSize = contentSize; } --(void) appViewItemTap:(UITapGestureRecognizer*)recognizer -{ - if (self.target) - if ([self.target respondsToSelector:@selector(appSelector:appWasSelected:)]) - [self.target appSelector:self appWasSelected:recognizer.view.restorationIdentifier]; +- (void)appViewItemTap:(UITapGestureRecognizer*)recognizer { + if (self.target && [self.target respondsToSelector:@selector(appSelector:appWasSelected:)]) { + [self.target appSelector:self appWasSelected:recognizer.view.restorationIdentifier]; + } } @end diff --git a/RAAppSliderProvider.h b/RAAppSliderProvider.h index 325a8d2..3a5c545 100644 --- a/RAAppSliderProvider.h +++ b/RAAppSliderProvider.h @@ -6,13 +6,13 @@ @property (nonatomic, retain) NSArray *availableIdentifiers; @property (nonatomic) NSInteger currentIndex; --(BOOL) canGoLeft; --(BOOL) canGoRight; +- (BOOL)canGoLeft; +- (BOOL)canGoRight; --(RAHostedAppView*) viewToTheLeft; --(RAHostedAppView*) viewToTheRight; --(RAHostedAppView*) viewAtCurrentIndex; +- (RAHostedAppView*)viewToTheLeft; +- (RAHostedAppView*)viewToTheRight; +- (RAHostedAppView*)viewAtCurrentIndex; --(void) goToTheLeft; --(void) goToTheRight; +- (void)goToTheLeft; +- (void)goToTheRight; @end diff --git a/RAAppSliderProvider.mm b/RAAppSliderProvider.mm index 07d2f14..b3555a6 100644 --- a/RAAppSliderProvider.mm +++ b/RAAppSliderProvider.mm @@ -9,33 +9,32 @@ @interface RAAppSliderProvider () { @implementation RAAppSliderProvider @synthesize currentIndex, availableIdentifiers; --(instancetype) init -{ - if (self = [super init]) - { +- (instancetype)init { + self = [super init]; + if (self) { cachedViews = [NSMutableDictionary dictionary]; } return self; } --(BOOL) canGoLeft -{ +- (BOOL)canGoLeft { return currentIndex - 1 >= 0 && availableIdentifiers.count > 0; } --(BOOL) canGoRight -{ +- (BOOL)canGoRight { return availableIdentifiers.count > currentIndex + 1; } --(RAHostedAppView*) viewToTheLeft -{ - if (self.canGoLeft) - { +- (RAHostedAppView*)viewToTheLeft { + if (self.canGoLeft) { NSString *ident = [availableIdentifiers objectAtIndex:currentIndex - 1]; - if (!ident) return nil; - if ([cachedViews objectForKey:ident]) return cachedViews[ident]; + if (!ident) { + return nil; + } + if ([cachedViews objectForKey:ident]) { + return cachedViews[ident]; + } RAHostedAppView *view = [[RAHostedAppView alloc] initWithBundleIdentifier:ident]; [view preloadApp]; @@ -45,14 +44,16 @@ -(RAHostedAppView*) viewToTheLeft return nil; } --(RAHostedAppView*) viewToTheRight -{ - if (self.canGoRight) - { +- (RAHostedAppView*)viewToTheRight { + if (self.canGoRight) { NSString *ident = [availableIdentifiers objectAtIndex:currentIndex + 1]; - if (!ident) return nil; - if ([cachedViews objectForKey:ident]) return cachedViews[ident]; + if (!ident) { + return nil; + } + if ([cachedViews objectForKey:ident]) { + return cachedViews[ident]; + } RAHostedAppView *view = [[RAHostedAppView alloc] initWithBundleIdentifier:ident]; [view preloadApp]; @@ -62,12 +63,15 @@ -(RAHostedAppView*) viewToTheRight return nil; } --(RAHostedAppView*) viewAtCurrentIndex -{ +- (RAHostedAppView*)viewAtCurrentIndex { NSString *ident = [availableIdentifiers objectAtIndex:currentIndex]; - if (!ident) return nil; - if ([cachedViews objectForKey:ident]) return cachedViews[ident]; + if (!ident) { + return nil; + } + if ([cachedViews objectForKey:ident]) { + return cachedViews[ident]; + } RAHostedAppView *view = [[RAHostedAppView alloc] initWithBundleIdentifier:ident]; [view preloadApp]; @@ -75,15 +79,17 @@ -(RAHostedAppView*) viewAtCurrentIndex return view; } --(void) goToTheLeft -{ - if (self.canGoLeft) - currentIndex--; +- (void)goToTheLeft { + if (!self.canGoLeft) { + return; + } + currentIndex--; } --(void) goToTheRight -{ - if (self.canGoRight) - currentIndex++; +- (void)goToTheRight { + if (!self.canGoRight) { + return; + } + currentIndex++; } @end diff --git a/RAAppSliderProviderView.h b/RAAppSliderProviderView.h index 58206ac..ff68569 100644 --- a/RAAppSliderProviderView.h +++ b/RAAppSliderProviderView.h @@ -10,13 +10,13 @@ @property (nonatomic, retain) RAAppSliderProvider *swipeProvider; @property (nonatomic) BOOL isSwipeable; --(CGRect) clientFrame; --(NSString*) currentBundleIdentifier; +- (CGRect)clientFrame; +- (NSString*)currentBundleIdentifier; --(void) goToTheLeft; --(void) goToTheRight; +- (void)goToTheLeft; +- (void)goToTheRight; --(void) load; --(void) unload; --(void) updateCurrentView; -@end \ No newline at end of file +- (void)load; +- (void)unload; +- (void)updateCurrentView; +@end diff --git a/RAAppSliderProviderView.mm b/RAAppSliderProviderView.mm index 0365d3b..c793d91 100644 --- a/RAAppSliderProviderView.mm +++ b/RAAppSliderProviderView.mm @@ -7,99 +7,89 @@ @implementation RAAppSliderProviderView @synthesize swipeProvider; --(void) goToTheLeft -{ +- (void)goToTheLeft { [swipeProvider goToTheLeft]; [self updateCurrentView]; } --(void) goToTheRight -{ +- (void)goToTheRight { [swipeProvider goToTheRight]; [self updateCurrentView]; } --(void) load -{ +- (void)load { [currentView loadApp]; } --(void) unload -{ - if (!currentView || !currentView.bundleIdentifier) +- (void)unload { + if (!currentView || !currentView.bundleIdentifier) { return; + } [RAGestureManager.sharedInstance removeGestureWithIdentifier:currentView.bundleIdentifier]; [currentView unloadApp]; } --(void) updateCurrentView -{ +- (void)updateCurrentView { [self unload]; - if (currentView) + if (currentView) { [currentView removeFromSuperview]; + } currentView = [swipeProvider viewAtCurrentIndex]; - if (self.isSwipeable && self.swipeProvider) - { + if (self.isSwipeable && self.swipeProvider) { self.backgroundColor = [UIColor clearColor]; // redColor]; self.userInteractionEnabled = YES; - [RAGestureManager.sharedInstance addGestureRecognizerWithTarget:self forEdge:UIRectEdgeLeft | UIRectEdgeRight identifier:currentView.bundleIdentifier priority:RAGesturePriorityHigh]; - //[RAGestureManager.sharedInstance addGestureRecognizerWithTarget:self forEdge:UIRectEdgeRight identifier:currentView.bundleIdentifier priority:RAGesturePriorityHigh]; + [RAGestureManager.sharedInstance addGestureRecognizerWithTarget:self forEdge:UIRectEdgeLeft | UIRectEdgeRight identifier:currentView.bundleIdentifier priority:RAGesturePriorityHigh]; + //[RAGestureManager.sharedInstance addGestureRecognizerWithTarget:self forEdge:UIRectEdgeRight identifier:currentView.bundleIdentifier priority:RAGesturePriorityHigh]; currentView.frame = CGRectMake(0, 0, self.frame.size.width - 0, self.frame.size.height); - } - else + } else { currentView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); + } [self addSubview:currentView]; [self load]; } --(CGRect) clientFrame -{ - if (!currentView) return CGRectZero; +- (CGRect)clientFrame { + if (!currentView) { + return CGRectZero; + } CGRect frame = currentView.frame; frame.size.height = self.frame.size.height; return frame; } --(NSString*) currentBundleIdentifier -{ +- (NSString*)currentBundleIdentifier { return currentView ? currentView.bundleIdentifier : nil; } --(BOOL) RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity -{ +- (BOOL)RAGestureCallback_canHandle:(CGPoint)point velocity:(CGPoint)velocity { return point.y <= [self convertPoint:self.frame.origin toView:nil].y + self.frame.size.height; } --(RAGestureCallbackResult) RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge -{ +- (RAGestureCallbackResult)RAGestureCallback_handle:(UIGestureRecognizerState)state withPoint:(CGPoint)location velocity:(CGPoint)velocity forEdge:(UIRectEdge)edge { static BOOL didHandle = NO; - if (state == UIGestureRecognizerStateEnded) - { + if (state == UIGestureRecognizerStateEnded) { didHandle = NO; return RAGestureCallbackResultSuccessAndStop; } - if (didHandle) return RAGestureCallbackResultSuccessAndStop; + if (didHandle) { + return RAGestureCallbackResultSuccessAndStop; + } - if (edge == UIRectEdgeLeft) - { + if (edge == UIRectEdgeLeft) { didHandle = YES; - if (self.swipeProvider.canGoLeft) - { + if (self.swipeProvider.canGoLeft) { [self unload]; [self goToTheLeft]; } return RAGestureCallbackResultSuccessAndStop; - } - else if (edge == UIRectEdgeRight) - { + } else if (edge == UIRectEdgeRight) { didHandle = YES; - if (self.swipeProvider.canGoRight) - { + if (self.swipeProvider.canGoRight) { [self unload]; [self goToTheRight]; } diff --git a/RAAppSwitcherModelWrapper.h b/RAAppSwitcherModelWrapper.h index 1db8095..699e014 100644 --- a/RAAppSwitcherModelWrapper.h +++ b/RAAppSwitcherModelWrapper.h @@ -1,9 +1,9 @@ #import "headers.h" @interface RAAppSwitcherModelWrapper : NSObject -+(void) addToFront:(SBApplication*)app; -+(void) addIdentifierToFront:(NSString*)ident; -+(NSArray*) appSwitcherAppIdentiferList; ++ (void)addToFront:(SBApplication*)app; ++ (void)addIdentifierToFront:(NSString*)ident; ++ (NSArray*)appSwitcherAppIdentiferList; -+(void) removeItemWithIdentifier:(NSString*)ident; -@end \ No newline at end of file ++ (void)removeItemWithIdentifier:(NSString*)ident; +@end diff --git a/RAAppSwitcherModelWrapper.xm b/RAAppSwitcherModelWrapper.xm index 7c43835..625c4fc 100644 --- a/RAAppSwitcherModelWrapper.xm +++ b/RAAppSwitcherModelWrapper.xm @@ -1,54 +1,47 @@ #import "RAAppSwitcherModelWrapper.h" @implementation RAAppSwitcherModelWrapper -+(void) addToFront:(SBApplication*)app -{ ++ (void)addToFront:(SBApplication*)app { SBAppSwitcherModel *model = [%c(SBAppSwitcherModel) sharedInstance]; - if ([model respondsToSelector:@selector(addToFront:)]) // iOS 7 + 8 - { + if ([model respondsToSelector:@selector(addToFront:)]) { // iOS 7 + 8 SBDisplayLayout *layout = [%c(SBDisplayLayout) fullScreenDisplayLayoutForApplication:app]; [model addToFront:layout]; - } - else // iOS 9 - { + } else { // iOS 9 SBDisplayItem *layout = [%c(SBDisplayItem) displayItemWithType:@"App" displayIdentifier:app.bundleIdentifier]; [model addToFront:layout role:2]; } - } -+(void) addIdentifierToFront:(NSString*)ident -{ ++ (void)addIdentifierToFront:(NSString*)ident { [RAAppSwitcherModelWrapper addToFront:[[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:ident]]; } -+(NSArray*) appSwitcherAppIdentiferList -{ ++ (NSArray*)appSwitcherAppIdentiferList { SBAppSwitcherModel *model = [%c(SBAppSwitcherModel) sharedInstance]; - if ([model respondsToSelector:@selector(snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary)]) + if ([model respondsToSelector:@selector(snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary)]) { return [model snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary]; + } // iOS 9 most likely. NSMutableArray *ret = [NSMutableArray array]; id list = [model mainSwitcherDisplayItems]; // NSArray - for (SBDisplayItem *item in list) - { + for (SBDisplayItem *item in list) { [ret addObject:item.displayIdentifier]; } return ret; } -+(void) removeItemWithIdentifier:(NSString*)ident -{ ++ (void)removeItemWithIdentifier:(NSString*)ident { SBDisplayItem *item = [%c(SBDisplayItem) displayItemWithType:@"App" displayIdentifier:ident]; id appSwitcherModel = [%c(SBAppSwitcherModel) sharedInstance]; - if ([appSwitcherModel respondsToSelector:@selector(removeDisplayItem:)]) - [[%c(SBAppSwitcherModel) sharedInstance] removeDisplayItem:item]; - else - [[%c(SBAppSwitcherModel) sharedInstance] remove:item]; + if ([appSwitcherModel respondsToSelector:@selector(removeDisplayItem:)]) { + [[%c(SBAppSwitcherModel) sharedInstance] removeDisplayItem:item]; + } else { + [[%c(SBAppSwitcherModel) sharedInstance] remove:item]; + } } @end diff --git a/RACompatibilitySystem.h b/RACompatibilitySystem.h index fd27153..064bb51 100644 --- a/RACompatibilitySystem.h +++ b/RACompatibilitySystem.h @@ -1,8 +1,5 @@ -@interface RACompatibilitySystem : NSObject { - -} +@interface RACompatibilitySystem : NSObject //+(instancetype) sharedInstance; - -+(void) showWarning:(NSString*)info; -+(void) showError:(NSString*)info; -@end \ No newline at end of file ++ (void)showWarning:(NSString*)info; ++ (void)showError:(NSString*)info; +@end diff --git a/RACompatibilitySystem.mm b/RACompatibilitySystem.mm index e027585..9295827 100644 --- a/RACompatibilitySystem.mm +++ b/RACompatibilitySystem.mm @@ -6,8 +6,7 @@ #import "UIAlertController+Window.h" @implementation RACompatibilitySystem -+(NSString*) aggregateSystemInfo -{ ++ (NSString*)aggregateSystemInfo { NSMutableString *ret = [[NSMutableString alloc] init]; struct utsname systemInfo; @@ -19,8 +18,7 @@ +(NSString*) aggregateSystemInfo return ret; } -+(void) showWarning:(NSString*)info -{ ++ (void)showWarning:(NSString*)info { NSString *message = [NSString stringWithFormat:@"System info: %@\n\nWARNING: POTENTIAL INCOMPATIBILITY DETECTED\n%@", [self aggregateSystemInfo], info]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Multiplexer Compatibility" message:message preferredStyle:UIAlertControllerStyleAlert]; @@ -28,8 +26,7 @@ +(void) showWarning:(NSString*)info [alert show]; } -+(void) showError:(NSString*)info -{ ++ (void)showError:(NSString*)info { NSString *message = [NSString stringWithFormat:@"System info: %@\n\n***ERROR***: POTENTIAL INCOMPATIBILITY DETECTED\n%@", [self aggregateSystemInfo], info]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Multiplexer Compatibility" message:message preferredStyle:UIAlertControllerStyleAlert]; diff --git a/RAControlCenterInhibitor.h b/RAControlCenterInhibitor.h index 4aa3755..11a090e 100644 --- a/RAControlCenterInhibitor.h +++ b/RAControlCenterInhibitor.h @@ -1,4 +1,4 @@ @interface RAControlCenterInhibitor : NSObject -+(void) setInhibited:(BOOL)value; -+(BOOL) isInhibited; -@end \ No newline at end of file ++ (void)setInhibited:(BOOL)value; ++ (BOOL)isInhibited; +@end diff --git a/RAControlCenterInhibitor.xm b/RAControlCenterInhibitor.xm index 8a0bf3f..a1254b5 100644 --- a/RAControlCenterInhibitor.xm +++ b/RAControlCenterInhibitor.xm @@ -4,35 +4,36 @@ BOOL overrideCC = NO; @implementation RAControlCenterInhibitor : NSObject -+(void) setInhibited:(BOOL)value -{ ++ (void)setInhibited:(BOOL)value { overrideCC = value; } -+(BOOL) isInhibited -{ ++ (BOOL)isInhibited { return overrideCC; } @end %hook SBUIController -- (void)_showControlCenterGestureBeganWithLocation:(CGPoint)arg1 -{ - if (!overrideCC) - %orig; +- (void)_showControlCenterGestureBeganWithLocation:(CGPoint)arg1 { + if (!overrideCC) { + return; + } + %orig; } -- (void)handleShowControlCenterSystemGesture:(__unsafe_unretained id)arg1 -{ - if (!overrideCC) - %orig; +- (void)handleShowControlCenterSystemGesture:(__unsafe_unretained id)arg1 { + if (!overrideCC) { + return; + } + %orig; } %end %hook SBControlCenterController -- (void)presentAnimated:(BOOL)arg1 completion:(id)arg2 -{ - if (!overrideCC) - %orig; +- (void)presentAnimated:(BOOL)arg1 completion:(id)arg2 { + if (!overrideCC) { + return; + } + %orig; } %end diff --git a/RAFakePhoneMode.h b/RAFakePhoneMode.h index bee002b..5a9b9a2 100644 --- a/RAFakePhoneMode.h +++ b/RAFakePhoneMode.h @@ -1,10 +1,10 @@ #import "headers.h" @interface RAFakePhoneMode : NSObject -+(CGSize) fakedSize; -+(BOOL) shouldFakeForThisProcess; -+(void) updateAppSizing; ++ (CGSize)fakedSize; ++ (BOOL)shouldFakeForThisProcess; ++ (void)updateAppSizing; -+(BOOL) shouldFakeForAppWithIdentifier:(NSString*)identifier; -+(CGSize) fakeSizeForAppWithIdentifier:(NSString*)identifier; -@end \ No newline at end of file ++ (BOOL)shouldFakeForAppWithIdentifier:(NSString*)identifier; ++ (CGSize)fakeSizeForAppWithIdentifier:(NSString*)identifier; +@end diff --git a/RAFakePhoneMode.xm b/RAFakePhoneMode.xm index a75db63..e4633f3 100644 --- a/RAFakePhoneMode.xm +++ b/RAFakePhoneMode.xm @@ -14,45 +14,39 @@ I split them apart when i was trying to find some issue with app resizing/touche CGSize forcePhoneModeSize = RA_6P_SIZE; @implementation RAFakePhoneMode -+(void) load -{ ++ (void)load { // Prevent iPhone issue - if (IS_IPAD) - { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // somehow, this is needed to make sure that both force resizing and Fake Phone Mode work. Without the dispatch_after, even if fake phone mode is disabled, - // force resizing seems to render touches incorrectly ¯\_(ツ)_/¯ - IF_NOT_SPRINGBOARD - { - if ([RAFakePhoneMode shouldFakeForThisProcess]) - { - dlopen("/Library/MobileSubstrate/DynamicLibraries/ReachAppFakePhoneMode.dylib", RTLD_NOW); - } - } - }); + if (!IS_IPAD) { + return; } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // somehow, this is needed to make sure that both force resizing and Fake Phone Mode work. Without the dispatch_after, even if fake phone mode is disabled, + // force resizing seems to render touches incorrectly ¯\_(ツ)_/¯ + IF_NOT_SPRINGBOARD { + if ([RAFakePhoneMode shouldFakeForThisProcess]) { + dlopen("/Library/MobileSubstrate/DynamicLibraries/ReachAppFakePhoneMode.dylib", RTLD_NOW); + } + } + }); } -+(CGSize) fakedSize -{ - if (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)) ++ (CGSize)fakedSize { + if (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)) { return CGSizeMake(forcePhoneModeSize.height, forcePhoneModeSize.width); + } return forcePhoneModeSize; } -+(CGSize) fakeSizeForAppWithIdentifier:(NSString*)identifier -{ ++ (CGSize)fakeSizeForAppWithIdentifier:(NSString*)identifier { return forcePhoneModeSize; } -+(void) updateAppSizing -{ - CGRect f = UIWindow.keyWindow.frame; - f.origin = CGPointZero; - UIWindow.keyWindow.frame = f; ++ (void)updateAppSizing { + CGRect f = UIWindow.keyWindow.frame; + f.origin = CGPointZero; + UIWindow.keyWindow.frame = f; } -+(BOOL) shouldFakeForAppWithIdentifier:(NSString*)identifier -{ ++ (BOOL)shouldFakeForAppWithIdentifier:(NSString*)identifier { IF_SPRINGBOARD { return [RAMessagingServer.sharedInstance getDataForIdentifier:identifier].forcePhoneMode; } @@ -60,19 +54,15 @@ CGSize forcePhoneModeSize = RA_6P_SIZE; return NO; } -+(BOOL) shouldFakeForThisProcess -{ ++ (BOOL)shouldFakeForThisProcess { static char fakeFlag = 0; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - if (!RAMessagingClient.sharedInstance.hasRecievedData) - { + if (!RAMessagingClient.sharedInstance.hasRecievedData) { [RAMessagingClient.sharedInstance requestUpdateFromServer]; } - fakeFlag = RAMessagingClient.sharedInstance.currentData.forcePhoneMode; }); - return fakeFlag; } @end diff --git a/RAHostManager.h b/RAHostManager.h index ae34e28..df94627 100644 --- a/RAHostManager.h +++ b/RAHostManager.h @@ -1,7 +1,7 @@ #import "headers.h" @interface RAHostManager : NSObject -+(UIView*) systemHostViewForApplication:(SBApplication*)app; -+(UIView*) enabledHostViewForApplication:(SBApplication*)app; -+(NSObject*) hostManagerForApp:(SBApplication*)app; -@end \ No newline at end of file ++ (UIView*)systemHostViewForApplication:(SBApplication*)app; ++ (UIView*)enabledHostViewForApplication:(SBApplication*)app; ++ (NSObject*)hostManagerForApp:(SBApplication*)app; +@end diff --git a/RAHostManager.xm b/RAHostManager.xm index e735cfb..74b2882 100644 --- a/RAHostManager.xm +++ b/RAHostManager.xm @@ -2,34 +2,34 @@ #import "RACompatibilitySystem.h" @implementation RAHostManager -+(UIView*) systemHostViewForApplication:(SBApplication*)app -{ - if (!app) ++ (UIView*)systemHostViewForApplication:(SBApplication*)app { + if (!app) { return nil; - if ([app respondsToSelector:@selector(mainScene)]) // iOS 8 + } + if ([app respondsToSelector:@selector(mainScene)]) { // iOS 8 return MSHookIvar(app.mainScene.contextHostManager, "_hostView"); - else if ([app respondsToSelector:@selector(mainScreenContextHostManager)]) + } else if ([app respondsToSelector:@selector(mainScreenContextHostManager)]) { return MSHookIvar([app mainScreenContextHostManager], "_hostView"); - + } [RACompatibilitySystem showWarning:@"Unable to find valid method for accessing system context host views"]; return nil; } -+(UIView*) enabledHostViewForApplication:(SBApplication*)app -{ - if (!app) ++ (UIView*)enabledHostViewForApplication:(SBApplication*)app { + if (!app) { return nil; + } - if ([app respondsToSelector:@selector(mainScene)]) - { + if ([app respondsToSelector:@selector(mainScene)]) { [[UIApplication sharedApplication] launchApplicationWithIdentifier:app.bundleIdentifier suspended:YES]; FBScene *scene = [app mainScene]; FBWindowContextHostManager *contextHostManager = [scene contextHostManager]; FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; - if (!settings) - return nil; + if (!settings) { + return nil; + } SET_BACKGROUNDED(settings, NO); [scene _applyMutableSettings:settings withTransitionContext:nil completion:nil]; @@ -43,13 +43,12 @@ return nil; } -+(NSObject*) hostManagerForApp:(SBApplication*)app -{ - if (!app) ++ (NSObject*)hostManagerForApp:(SBApplication*)app { + if (!app) { return nil; + } - if ([app respondsToSelector:@selector(mainScene)]) - { + if ([app respondsToSelector:@selector(mainScene)]) { FBScene *scene = [app mainScene]; return (NSObject*)[scene contextHostManager]; } diff --git a/RAHostedAppView.h b/RAHostedAppView.h index 16de588..e78cea9 100644 --- a/RAHostedAppView.h +++ b/RAHostedAppView.h @@ -8,9 +8,9 @@ FBWindowContextHostWrapperView *view; } -+(void) iPad_iOS83_fixHosting; ++ (void)iPad_iOS83_fixHosting; --(instancetype) initWithBundleIdentifier:(NSString*)bundleIdentifier; +- (instancetype)initWithBundleIdentifier:(NSString*)bundleIdentifier; @property (nonatomic) BOOL showSplashscreenInsteadOfSpinner; @property (nonatomic) BOOL renderWallpaper; @@ -25,15 +25,15 @@ @property (nonatomic) BOOL isCurrentlyHosting; --(SBApplication*) app; --(NSString*) displayName; +- (SBApplication*)app; +- (NSString*)displayName; @property (nonatomic, readonly) UIInterfaceOrientation orientation; --(void) rotateToOrientation:(UIInterfaceOrientation)o; +- (void)rotateToOrientation:(UIInterfaceOrientation)o; --(void) preloadApp; --(void) loadApp; --(void) unloadApp; --(void) unloadApp:(BOOL)forceImmediate; +- (void)preloadApp; +- (void)loadApp; +- (void)unloadApp; +- (void)unloadApp:(BOOL)forceImmediate; @end diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index 357d161..cc34e3a 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -30,10 +30,9 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; @end @implementation RAHostedAppView --(instancetype) initWithBundleIdentifier:(NSString*)bundleIdentifier -{ - if (self = [super init]) - { +- (instancetype)initWithBundleIdentifier:(NSString*)bundleIdentifier { + self = [super init]; + if (self) { self.bundleIdentifier = bundleIdentifier; self.autosizesApp = NO; self.allowHidingStatusBar = YES; @@ -43,48 +42,42 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; self.renderWallpaper = NO; self.backgroundColor = [UIColor clearColor]; } - return self; } --(void) _preloadOrAttemptToUpdateReachabilityCounterpart -{ - if (app) - { - if ([app mainScene]) - { - isPreloading = NO; - if (((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive && [GET_SBWORKSPACE respondsToSelector:@selector(RA_updateViewSizes)]) - [GET_SBWORKSPACE performSelector:@selector(RA_updateViewSizes) withObject:nil afterDelay:0.5]; // App is launched using ReachApp - animations commence. We have to wait for those animations to finish or this won't work. +- (void)_preloadOrAttemptToUpdateReachabilityCounterpart { + if (!app) { + return; + } + + if ([app mainScene]) { + isPreloading = NO; + if (((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive && [GET_SBWORKSPACE respondsToSelector:@selector(RA_updateViewSizes)]) { + [GET_SBWORKSPACE performSelector:@selector(RA_updateViewSizes) withObject:nil afterDelay:0.5]; // App is launched using ReachApp - animations commence. We have to wait for those animations to finish or this won't work. } - else if (![app mainScene]) - { - if (disablePreload) - disablePreload = NO; - else - [self preloadApp]; + } else if (![app mainScene]) { + if (disablePreload) { + disablePreload = NO; + } else { + [self preloadApp]; } } } --(void) setBundleIdentifier:(NSString*)value -{ +- (void)setBundleIdentifier:(NSString*)value { _orientation = UIInterfaceOrientationPortrait; _bundleIdentifier = value; app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:value]; } --(void) setShouldUseExternalKeyboard:(BOOL)value -{ +- (void)setShouldUseExternalKeyboard:(BOOL)value { _shouldUseExternalKeyboard = value; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:value forApp:self.bundleIdentifier completion:nil]; } --(void) preloadApp -{ +- (void)preloadApp { startTries++; - if (startTries > 5) - { + if (startTries > 5) { isPreloading = NO; LogDebug(@"[ReachApp] maxed out preload attempts for app %@", app.bundleIdentifier); UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Zypen" @@ -97,17 +90,17 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; return; } - if (!app) + if (!app) { return; + } - if (_isCurrentlyHosting) + if (_isCurrentlyHosting) { return; + } isPreloading = YES; FBScene *scene = [app mainScene]; - if (![app pid] || !scene) - { - LogDebug(@"has no pid or scene, createApplicationProcessForBundleID"); + if (![app pid] || !scene) { [UIApplication.sharedApplication launchApplicationWithIdentifier:self.bundleIdentifier suspended:YES]; [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:self.bundleIdentifier]; // ummm...? } @@ -116,16 +109,15 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; // it will call it again. } --(void) _actualLoadApp -{ - if (isPreloading) - { +- (void)_actualLoadApp { + if (isPreloading) { [self performSelector:@selector(_actualLoadApp) withObject:nil afterDelay:0.3]; return; } - if (_isCurrentlyHosting) + if (_isCurrentlyHosting) { return; + } _isCurrentlyHosting = YES; @@ -141,8 +133,9 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; [self addSubview:view]; [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; - if (IS_IPAD) + if (IS_IPAD) { [RAHostedAppView iPad_iOS83_fixHosting]; + } [RARunningAppsProvider.sharedInstance addTarget:self]; @@ -150,19 +143,19 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; [[NSRunLoop currentRunLoop] addTimer:loadedTimer forMode:NSRunLoopCommonModes]; } --(void) loadApp -{ +- (void)loadApp { startTries = 0; disablePreload = NO; [self preloadApp]; - if (!app) + if (!app) { return; + } - if (_isCurrentlyHosting) + if (_isCurrentlyHosting) { return; + } - if ([UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:app]) - { + if ([UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:app]) { isForemostAppLabel = [[UILabel alloc] initWithFrame:self.bounds]; isForemostAppLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; isForemostAppLabel.textColor = [UIColor whiteColor]; @@ -178,8 +171,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; IF_BIOLOCKDOWN { id failedBlock = ^{ [self removeLoadingIndicator]; - if (!authenticationDidFailLabel) - { + if (!authenticationDidFailLabel) { authenticationDidFailLabel = [[UILabel alloc] initWithFrame:self.bounds]; authenticationDidFailLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; authenticationDidFailLabel.textColor = [UIColor whiteColor]; @@ -199,13 +191,10 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; BIOLOCKDOWN_AUTHENTICATE_APP(app.bundleIdentifier, ^{ [self _actualLoadApp]; }, failedBlock /* stupid commas */); - } - else IF_ASPHALEIA - { + } else IF_ASPHALEIA { void (^failedBlock)() = ^{ [self removeLoadingIndicator]; - if (!authenticationDidFailLabel) - { + if (!authenticationDidFailLabel) { authenticationDidFailLabel = [[UILabel alloc] initWithFrame:self.bounds]; authenticationDidFailLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; authenticationDidFailLabel.textColor = [UIColor whiteColor]; @@ -225,16 +214,12 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; ASPHALEIA_AUTHENTICATE_APP(app.bundleIdentifier, ^{ [self _actualLoadApp]; }, failedBlock); - } - else - { + } else { [self _actualLoadApp]; } - if (self.showSplashscreenInsteadOfSpinner) - { - if (splashScreenImageView) - { + if (self.showSplashscreenInsteadOfSpinner) { + if (splashScreenImageView) { [splashScreenImageView removeFromSuperview]; splashScreenImageView = nil; } @@ -242,11 +227,8 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; splashScreenImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; splashScreenImageView.image = img; [self insertSubview:splashScreenImageView atIndex:0]; - } - else - { - if (!activityView) - { + } else { + if (!activityView) { activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; [self addSubview:activityView]; } @@ -258,86 +240,75 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; } } --(void) verifyHostingAndRehostIfNecessary -{ - if (!isPreloading && _isCurrentlyHosting && (!app.isRunning || !view.contextHosted)) // && (app.pid == 0 || view == nil || view.manager == nil)) // || view._isReallyHosting == NO)) - { +- (void)verifyHostingAndRehostIfNecessary { + if (!isPreloading && _isCurrentlyHosting && (!app.isRunning || !view.contextHosted)) { // && (app.pid == 0 || view == nil || view.manager == nil)) // || view._isReallyHosting == NO)) //[activityView startAnimating]; [self unloadApp]; [self loadApp]; - } - else - { + } else { [self removeLoadingIndicator]; [loadedTimer invalidate]; loadedTimer = nil; } } --(void) appDidDie:(SBApplication*)app_ -{ - if (app_ == self.app) - { - [self verifyHostingAndRehostIfNecessary]; +- (void)appDidDie:(SBApplication*)app_ { + if (app_ != self.app) { + return; } + [self verifyHostingAndRehostIfNecessary]; } --(void) removeLoadingIndicator -{ - if (self.showSplashscreenInsteadOfSpinner) - { +- (void)removeLoadingIndicator { + if (self.showSplashscreenInsteadOfSpinner) { [splashScreenImageView removeFromSuperview]; splashScreenImageView = nil; - } - else if (activityView) + } else if (activityView) { [activityView stopAnimating]; + } } --(void) drawRect:(CGRect)rect -{ - if (_renderWallpaper) - [[RASnapshotProvider.sharedInstance wallpaperImage] drawInRect:rect]; +- (void)drawRect:(CGRect)rect { + if (!_renderWallpaper) { + return; + } + [[RASnapshotProvider.sharedInstance wallpaperImage] drawInRect:rect]; } --(void) setFrame:(CGRect)frame -{ +- (void)setFrame:(CGRect)frame { [super setFrame:frame]; [view setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; - if (self.autosizesApp) - { + if (self.autosizesApp) { RAMessageAppData data = [RAMessagingServer.sharedInstance getDataForIdentifier:self.bundleIdentifier]; data.canHideStatusBarIfWanted = self.allowHidingStatusBar; [RAMessagingServer.sharedInstance setData:data forIdentifier:self.bundleIdentifier]; [RAMessagingServer.sharedInstance resizeApp:self.bundleIdentifier toSize:CGSizeMake(frame.size.width, frame.size.height) completion:nil]; - } - else if (self.bundleIdentifier) - { + } else if (self.bundleIdentifier) { [RAMessagingServer.sharedInstance endResizingApp:self.bundleIdentifier completion:nil]; } } --(void) setHideStatusBar:(BOOL)value -{ +- (void)setHideStatusBar:(BOOL)value { _hideStatusBar = value; - if (!self.bundleIdentifier) + if (!self.bundleIdentifier) { return; + } - if (value) + if (value) { [RAMessagingServer.sharedInstance forceStatusBarVisibility:!value forApp:self.bundleIdentifier completion:nil]; - else + } else { [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:self.bundleIdentifier completion:nil]; + } } --(void) unloadApp -{ +- (void)unloadApp { [self unloadApp:NO]; } --(void) unloadApp:(BOOL)forceImmediate -{ +- (void)unloadApp:(BOOL)forceImmediate { //if (activityView) // [activityView stopAnimating]; [self removeLoadingIndicator]; @@ -348,15 +319,15 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; disablePreload = YES; - if (!_isCurrentlyHosting) + if (!_isCurrentlyHosting) { return; + } _isCurrentlyHosting = NO; FBScene *scene = [app mainScene]; - if (authenticationDidFailLabel) - { + if (authenticationDidFailLabel) { [authenticationDidFailLabel removeFromSuperview]; authenticationDidFailLabel = nil; @@ -364,17 +335,16 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; self.userInteractionEnabled = NO; } - if (isForemostAppLabel) - { + if (isForemostAppLabel) { [isForemostAppLabel removeFromSuperview]; isForemostAppLabel = nil; } - if ([RASpringBoardKeyboardActivation.sharedInstance.currentIdentifier isEqual:self.bundleIdentifier]) + if ([RASpringBoardKeyboardActivation.sharedInstance.currentIdentifier isEqual:self.bundleIdentifier]) { [RASpringBoardKeyboardActivation.sharedInstance hideKeyboard]; + } - if (contextHostManager) - { + if (contextHostManager) { [contextHostManager disableHostingForRequester:@"reachapp"]; contextHostManager = nil; } @@ -385,15 +355,18 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; __weak RAHostedAppView *weakSelf = self; __block BOOL didRun = NO; RAMessageCompletionCallback block = ^(BOOL success) { - if (didRun || (weakSelf && [UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:weakSelf.app])) + if (didRun || (weakSelf && [UIApplication.sharedApplication._accessibilityFrontMostApplication isEqual:weakSelf.app])) { return; - if (!scene) + } + if (!scene) { return; + } appsBeingHosted[app.bundleIdentifier] = [appsBeingHosted objectForKey:app.bundleIdentifier] ? @([appsBeingHosted[app.bundleIdentifier] intValue] - 1) : @0; - if ([appsBeingHosted[app.bundleIdentifier] intValue] > 0) + if ([appsBeingHosted[app.bundleIdentifier] intValue] > 0) { return; + } FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; SET_BACKGROUNDED(settings, YES); @@ -405,13 +378,10 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:app.bundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:self.bundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance unRotateApp:self.bundleIdentifier completion:nil]; - if (forceImmediate) - { + if (forceImmediate) { [RAMessagingServer.sharedInstance endResizingApp:self.bundleIdentifier completion:nil]; block(YES); - } - else - { + } else { // >Somewhere in the messaging server, the block is being removed from the waitingCompletions dictionary without being called. // >This is a large issue (probably to do with asynchronous code) TODO: FIXME // lol im retarded, it's the default empty callback the messaging server made @@ -422,24 +392,19 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; } } --(void) rotateToOrientation:(UIInterfaceOrientation)o -{ +- (void)rotateToOrientation:(UIInterfaceOrientation)o { _orientation = o; [RAMessagingServer.sharedInstance rotateApp:self.bundleIdentifier toOrientation:o completion:nil]; } -+(void) iPad_iOS83_fixHosting -{ - for (NSString *bundleIdentifier in appsBeingHosted.allKeys) - { ++ (void)iPad_iOS83_fixHosting { + for (NSString *bundleIdentifier in appsBeingHosted.allKeys) { NSNumber *num = appsBeingHosted[bundleIdentifier]; - if (num.intValue > 0) - { + if (num.intValue > 0) { SBApplication *app_ = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:bundleIdentifier]; FBWindowContextHostManager *manager = (FBWindowContextHostManager*)[RAHostManager hostManagerForApp:app_]; - if (manager) - { + if (manager) { LogDebug(@"[ReachApp] rehosting for iPad: %@", bundleIdentifier); [manager enableHostingForRequester:@"reachapp" priority:1]; } @@ -448,17 +413,21 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; } // This allows for any subviews (with gestures) (e.g. the SwipeOver bar with a negative y origin) to recieve touch events. -- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event -{ +- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { BOOL isContained = NO; - for (UIView *subview in self.subviews) - { - if (CGRectContainsPoint(subview.frame, point)) // [self convertPoint:point toView:view])) + for (UIView *subview in self.subviews) { + if (CGRectContainsPoint(subview.frame, point)) { // [self convertPoint:point toView:view])) isContained = YES; + } } return isContained; } --(SBApplication*) app { return app; } --(NSString*) displayName { return app.displayName; } +- (SBApplication*)app { + return app; +} + +- (NSString*)displayName { + return app.displayName; +} @end diff --git a/RAHostedWidgetView.xm b/RAHostedWidgetView.xm index 387ee27..308e3e6 100644 --- a/RAHostedWidgetView.xm +++ b/RAHostedWidgetView.xm @@ -8,32 +8,33 @@ @end @implementation RAHostedWidgetView --(SBApplication*) app { return nil; } --(NSString*) displayName { return [self loadWidget].displayName; } +- (SBApplication*)app { + return nil; +} + +- (NSString*)displayName { + return [self loadWidget].displayName; +} //-(void) rotateToOrientation:(UIInterfaceOrientation)o; --(RAWidgetBase*) loadWidget -{ +- (RAWidgetBase*)loadWidget { widget = [RAWidgetHostManager.sharedInstance widgetForIdentifier:self.bundleIdentifier]; return widget; } --(void) preloadApp -{ +- (void)preloadApp { [self loadWidget]; } --(void) loadApp -{ +- (void)loadApp { widget.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); [self addSubview:widget]; [widget didAppear]; } --(void) unloadApp -{ +- (void)unloadApp { [widget didDisappear]; [widget removeFromSuperview]; } -@end \ No newline at end of file +@end diff --git a/RAInsetLabel.mm b/RAInsetLabel.mm index a3a6886..58ed09f 100644 --- a/RAInsetLabel.mm +++ b/RAInsetLabel.mm @@ -1,8 +1,7 @@ #import "RAInsetLabel.h" @implementation RAInsetLabel -- (void)drawTextInRect:(CGRect)rect -{ - [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.textInset)]; +- (void)drawTextInRect:(CGRect)rect { + [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.textInset)]; } -@end \ No newline at end of file +@end diff --git a/RALocalizer.h b/RALocalizer.h index 0dd0d74..2248678 100644 --- a/RALocalizer.h +++ b/RALocalizer.h @@ -1,7 +1,6 @@ @interface RALocalizer : NSObject { NSDictionary *translation; } -+(instancetype) sharedInstance; - --(NSString*) localizedStringForKey:(NSString*)key; ++ (instancetype)sharedInstance; +- (NSString*)localizedStringForKey:(NSString*)key; @end diff --git a/RALocalizer.mm b/RALocalizer.mm index 40f92fa..b9fcb79 100644 --- a/RALocalizer.mm +++ b/RALocalizer.mm @@ -2,41 +2,37 @@ #import "headers.h" @implementation RALocalizer -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RALocalizer, [sharedInstance loadTranslation]); } --(BOOL) attemptLoadForLanguageCode:(NSString*)code -{ +- (BOOL)attemptLoadForLanguageCode:(NSString*)code { NSString *expandedPath = [NSString stringWithFormat:@"%@/Localizations/%@.strings",RA_BASE_PATH,code]; NSDictionary *plist = [NSDictionary dictionaryWithContentsOfFile:expandedPath]; - if (plist) - { + if (plist) { translation = plist; return YES; } return NO; } --(void) loadTranslation -{ +- (void)loadTranslation { NSArray *langs = [NSLocale preferredLanguages]; - for (NSString *lang in langs) - { + for (NSString *lang in langs) { //NSDictionary *components = [NSLocale componentsFromLocaleIdentifier:lang]; //NSString *languageDesignator = components[NSLocaleLanguageCode]; - if ([self attemptLoadForLanguageCode:lang]) + if ([self attemptLoadForLanguageCode:lang]) { break; + } } - if (!translation) + if (!translation) { LogWarn(@"Failed Translation loading English"); [self attemptLoadForLanguageCode:@"en"]; + } } --(NSString*) localizedStringForKey:(NSString*)key -{ +- (NSString*)localizedStringForKey:(NSString*)key { return [translation objectForKey:key] ? translation[key] : key; } @end diff --git a/RAOrientationLocker.h b/RAOrientationLocker.h index dd6d5d5..9478357 100644 --- a/RAOrientationLocker.h +++ b/RAOrientationLocker.h @@ -1,6 +1,6 @@ #import "headers.h" @interface RAOrientationLocker : NSObject -+(void) lockOrientation; -+(void) unlockOrientation; -@end \ No newline at end of file ++ (void)lockOrientation; ++ (void)unlockOrientation; +@end diff --git a/RAOrientationLocker.xm b/RAOrientationLocker.xm index cfa7dd0..71228c5 100644 --- a/RAOrientationLocker.xm +++ b/RAOrientationLocker.xm @@ -1,19 +1,19 @@ #import "RAOrientationLocker.h" @implementation RAOrientationLocker -+(void) lockOrientation -{ - if ([%c(SBUIController) instancesRespondToSelector:@selector(_lockOrientationForSwitcher)]) ++ (void)lockOrientation { + if ([%c(SBUIController) instancesRespondToSelector:@selector(_lockOrientationForSwitcher)]) { [[%c(SBUIController) sharedInstance] _lockOrientationForSwitcher]; // iOS 8 - else // iOS 9 + } else { // iOS 9 [[%c(SBMainSwitcherGestureCoordinator) sharedInstance] _lockOrientation]; + } } -+(void) unlockOrientation -{ - if ([%c(SBUIController) instancesRespondToSelector:@selector(releaseSwitcherOrientationLock)]) ++ (void)unlockOrientation { + if ([%c(SBUIController) instancesRespondToSelector:@selector(releaseSwitcherOrientationLock)]) { [[%c(SBUIController) sharedInstance] releaseSwitcherOrientationLock]; // iOS 8 - else // iOS 9 + } else { // iOS 9 [[%c(SBMainSwitcherGestureCoordinator) sharedInstance] _releaseOrientationLock]; + } } -@end \ No newline at end of file +@end diff --git a/RAResourceImageProvider.h b/RAResourceImageProvider.h index edf4b5a..def9e08 100644 --- a/RAResourceImageProvider.h +++ b/RAResourceImageProvider.h @@ -1,7 +1,7 @@ #import "headers.h" @interface RAResourceImageProvider : NSObject -+(UIImage*) imageForFilename:(NSString*)filename; -+(UIImage*) imageForFilename:(NSString*)filename size:(CGSize)size tintedTo:(UIColor*)tint; -+(UIImage*) imageForFilename:(NSString*)filename constrainedToSize:(CGSize)size; -@end \ No newline at end of file ++ (UIImage*)imageForFilename:(NSString*)filename; ++ (UIImage*)imageForFilename:(NSString*)filename size:(CGSize)size tintedTo:(UIColor*)tint; ++ (UIImage*)imageForFilename:(NSString*)filename constrainedToSize:(CGSize)size; +@end diff --git a/RAResourceImageProvider.mm b/RAResourceImageProvider.mm index 41b02de..db9d082 100644 --- a/RAResourceImageProvider.mm +++ b/RAResourceImageProvider.mm @@ -5,8 +5,7 @@ NSCache *_rsImgCache = [NSCache new]; @implementation RAResourceImageProvider -+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize -{ ++ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize { // from: https://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage // In next line, pass 0.0 to use the current device's pixel scaling factor (and thus account for Retina resolution). // Pass 1.0 to force exact pixel size. @@ -17,49 +16,42 @@ + (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize return newImage; } -+(id) loadAndCacheImageWithStrippedPath:(NSString*)stripped -{ ++ (id)loadAndCacheImageWithStrippedPath:(NSString*)stripped { NSString *pdfPath = [NSString stringWithFormat:@"%@/Resources/%@.pdf",resourcePath,stripped]; NSString *pngPath = [NSString stringWithFormat:@"%@/Resources/%@.png",resourcePath,stripped]; - if ([NSFileManager.defaultManager fileExistsAtPath:pdfPath]) - { + if ([NSFileManager.defaultManager fileExistsAtPath:pdfPath]) { RAPDFImage *pdf = [RAPDFImage imageWithContentsOfFile:pdfPath]; - if (pdf) - [_rsImgCache setObject:pdf forKey:stripped]; - + if (pdf) { + [_rsImgCache setObject:pdf forKey:stripped]; + } return pdf; - } - else if ([NSFileManager.defaultManager fileExistsAtPath:pngPath]) - { + } else if ([NSFileManager.defaultManager fileExistsAtPath:pngPath]) { UIImage *img = [UIImage imageWithContentsOfFile:pngPath]; - if (img) - [_rsImgCache setObject:img forKey:stripped]; - + if (img) { + [_rsImgCache setObject:img forKey:stripped]; + } return img; } return nil; } -+(id) getOrCacheImageWithFilename:(NSString*)strippedPath -{ ++ (id)getOrCacheImageWithFilename:(NSString*)strippedPath { return [_rsImgCache objectForKey:strippedPath] ?: [self loadAndCacheImageWithStrippedPath:strippedPath]; } -+(UIImage*) convertToUIImageIfNeeded:(id)arg sizeIfNeeded:(CGSize)size forceSizing:(BOOL)force -{ - if ([arg isKindOfClass:UIImage.class]) - { - if (force) - return [self imageWithImage:arg scaledToSize:size]; - else - return (UIImage*)arg; ++ (UIImage*)convertToUIImageIfNeeded:(id)arg sizeIfNeeded:(CGSize)size forceSizing:(BOOL)force { + if ([arg isKindOfClass:UIImage.class]) { + if (force) { + return [self imageWithImage:arg scaledToSize:size]; + } else { + return (UIImage*)arg; + } } - if ([arg isKindOfClass:[RAPDFImage class]]) - { + if ([arg isKindOfClass:[RAPDFImage class]]) { UIImage *image = [arg imageWithOptions:[RAPDFImageOptions optionsWithSize:size]]; return image; } @@ -67,21 +59,18 @@ +(UIImage*) convertToUIImageIfNeeded:(id)arg sizeIfNeeded:(CGSize)size forceSizi return nil; } -+(UIImage*) imageForFilename:(NSString*)filename -{ ++ (UIImage*)imageForFilename:(NSString*)filename { NSString *strippedPath = [[filename lastPathComponent] stringByDeletingPathExtension]; id img = [self getOrCacheImageWithFilename:strippedPath]; return [self convertToUIImageIfNeeded:img sizeIfNeeded:CGSizeMake(200, 200) forceSizing:NO]; } -+(UIImage*) imageForFilename:(NSString*)filename size:(CGSize)size tintedTo:(UIColor*)tint -{ ++ (UIImage*)imageForFilename:(NSString*)filename size:(CGSize)size tintedTo:(UIColor*)tint { return [[self imageForFilename:filename constrainedToSize:size] _flatImageWithColor:tint]; } -+(UIImage*) imageForFilename:(NSString*)filename constrainedToSize:(CGSize)size -{ ++ (UIImage*)imageForFilename:(NSString*)filename constrainedToSize:(CGSize)size { NSString *strippedPath = [[filename lastPathComponent] stringByDeletingPathExtension]; id img = [self getOrCacheImageWithFilename:strippedPath]; diff --git a/RARunningAppsProvider.h b/RARunningAppsProvider.h index 724ca6f..f668603 100644 --- a/RARunningAppsProvider.h +++ b/RARunningAppsProvider.h @@ -3,8 +3,8 @@ @protocol RARunningAppsProviderDelegate @optional --(void) appDidStart:(__unsafe_unretained SBApplication*)app; --(void) appDidDie:(__unsafe_unretained SBApplication*)app; +- (void)appDidStart:(__unsafe_unretained SBApplication*)app; +- (void)appDidDie:(__unsafe_unretained SBApplication*)app; @end @interface RARunningAppsProvider : NSObject { @@ -12,13 +12,13 @@ NSMutableArray *targets; pthread_mutex_t mutex; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(void) addRunningApp:(__unsafe_unretained SBApplication*)app; --(void) removeRunningApp:(__unsafe_unretained SBApplication*)app; +- (void)addRunningApp:(__unsafe_unretained SBApplication*)app; +- (void)removeRunningApp:(__unsafe_unretained SBApplication*)app; --(void) addTarget:(__weak NSObject*)target; --(void) removeTarget:(__weak NSObject*)target; +- (void)addTarget:(__weak NSObject*)target; +- (void)removeTarget:(__weak NSObject*)target; --(NSArray*) runningApplications; +- (NSArray*)runningApplications; @end diff --git a/RARunningAppsProvider.xm b/RARunningAppsProvider.xm index f518b59..6eefc5a 100644 --- a/RARunningAppsProvider.xm +++ b/RARunningAppsProvider.xm @@ -1,8 +1,7 @@ #import "RARunningAppsProvider.h" @implementation RARunningAppsProvider -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RARunningAppsProvider, sharedInstance->apps = [NSMutableArray array]; sharedInstance->targets = [NSMutableArray array]; @@ -17,47 +16,48 @@ return self; } --(void) addRunningApp:(__unsafe_unretained SBApplication*)app -{ +- (void)addRunningApp:(__unsafe_unretained SBApplication*)app { pthread_mutex_lock(&mutex); [apps addObject:app]; - for (NSObject* target in targets) - if ([target respondsToSelector:@selector(appDidStart:)]) + for (NSObject* target in targets) { + if ([target respondsToSelector:@selector(appDidStart:)]) { dispatch_async(dispatch_get_main_queue(), ^{ [target appDidStart:app]; }); + } + } pthread_mutex_unlock(&mutex); } --(void) removeRunningApp:(__unsafe_unretained SBApplication*)app -{ +- (void)removeRunningApp:(__unsafe_unretained SBApplication*)app { pthread_mutex_lock(&mutex); [apps removeObject:app]; - for (NSObject* target in targets) - if ([target respondsToSelector:@selector(appDidDie:)]) + for (NSObject* target in targets) { + if ([target respondsToSelector:@selector(appDidDie:)]) { dispatch_async(dispatch_get_main_queue(), ^{ [target appDidDie:app]; }); + } + } pthread_mutex_unlock(&mutex); } --(void) addTarget:(__weak NSObject*)target -{ +- (void)addTarget:(__weak NSObject*)target { pthread_mutex_lock(&mutex); - if (![targets containsObject:target]) + if (![targets containsObject:target]) { [targets addObject:target]; + } pthread_mutex_unlock(&mutex); } --(void) removeTarget:(__weak NSObject*)target -{ +- (void)removeTarget:(__weak NSObject*)target { pthread_mutex_lock(&mutex); [targets removeObject:target]; @@ -69,18 +69,23 @@ pthread_mutex_destroy(&mutex); } --(NSArray*) runningApplications { return apps; } --(NSMutableArray*) mutableRunningApplications { return apps; } +- (NSArray*)runningApplications { + return apps; +} + +- (NSMutableArray*)mutableRunningApplications { + return apps; +} @end %hook SBApplication -- (void)updateProcessState:(unsafe_id)arg1 -{ +- (void)updateProcessState:(unsafe_id)arg1 { %orig; - if (self.isRunning && ![RARunningAppsProvider.sharedInstance.mutableRunningApplications containsObject:self]) + if (self.isRunning && ![RARunningAppsProvider.sharedInstance.mutableRunningApplications containsObject:self]) { [RARunningAppsProvider.sharedInstance addRunningApp:self]; - else if (!self.isRunning && [RARunningAppsProvider.sharedInstance.mutableRunningApplications containsObject:self]) + } else if (!self.isRunning && [RARunningAppsProvider.sharedInstance.mutableRunningApplications containsObject:self]) { [RARunningAppsProvider.sharedInstance removeRunningApp:self]; + } } %end diff --git a/RASBWorkspaceFetcher.h b/RASBWorkspaceFetcher.h index 12a55db..01b3f3f 100644 --- a/RASBWorkspaceFetcher.h +++ b/RASBWorkspaceFetcher.h @@ -1,6 +1,6 @@ @class SBWorkspace; @interface RASBWorkspaceFetcher : NSObject -+(Class) SBWorkspaceClass; -+(SBWorkspace*) getCurrentSBWorkspaceImplementationInstanceForThisOS; -@end \ No newline at end of file ++ (Class)SBWorkspaceClass; ++ (SBWorkspace*)getCurrentSBWorkspaceImplementationInstanceForThisOS; +@end diff --git a/RASBWorkspaceFetcher.xm b/RASBWorkspaceFetcher.xm index 1615430..5806503 100644 --- a/RASBWorkspaceFetcher.xm +++ b/RASBWorkspaceFetcher.xm @@ -5,28 +5,26 @@ // REASON: HEADERS.H IMPORTS THIS FILE @interface __SBWorkspace__class_impl_dummy : NSObject -+(id) sharedInstance; ++ (id)sharedInstance; @end Class SBWorkspace_class_implementation_class = nil; @implementation RASBWorkspaceFetcher -+(Class) SBWorkspaceClass -{ ++ (Class)SBWorkspaceClass { return SBWorkspace_class_implementation_class; } -+(SBWorkspace*) getCurrentSBWorkspaceImplementationInstanceForThisOS -{ - if ([SBWorkspace_class_implementation_class respondsToSelector:@selector(sharedInstance)]) ++ (SBWorkspace*)getCurrentSBWorkspaceImplementationInstanceForThisOS { + if ([SBWorkspace_class_implementation_class respondsToSelector:@selector(sharedInstance)]) { return [SBWorkspace_class_implementation_class sharedInstance]; + } HBLogError(@"[ReachApp] \"SBWorkspace\" class '%s' does not have '+sharedInstance' method", class_getName(SBWorkspace_class_implementation_class)); return nil; } @end -%ctor -{ +%ctor { // SBMainWorkspace: iOS 9 // SBWorkspace: iOS 8 SBWorkspace_class_implementation_class = %c(SBMainWorkspace) ?: %c(SBWorkspace); diff --git a/RASettings.h b/RASettings.h index 36e3499..10b71d2 100644 --- a/RASettings.h +++ b/RASettings.h @@ -14,79 +14,79 @@ typedef NS_ENUM(NSInteger, RAGrabArea) { @interface RASettings : NSObject { NSDictionary *_settings; } -+(instancetype)sharedInstance; - -+(BOOL) isParagonInstalled; -+(BOOL) isActivatorInstalled; -+(BOOL) isLibStatusBarInstalled; - --(void) reloadSettings; --(void) resetSettings; - --(BOOL) enabled; - --(BOOL) reachabilityEnabled; --(BOOL) disableAutoDismiss; --(BOOL) enableRotation; --(BOOL) showNCInstead; --(BOOL) homeButtonClosesReachability; --(BOOL) showBottomGrabber; --(BOOL) showWidgetSelector; --(BOOL) scalingRotationMode; --(BOOL) autoSizeWidgetSelector; --(BOOL) showAllAppsInWidgetSelector; --(BOOL) showRecentAppsInWidgetSelector; --(BOOL) pagingEnabled; --(NSMutableArray*) favoriteApps; --(BOOL) unifyStatusBar; --(BOOL) flipTopAndBottom; --(BOOL) showFavorites; - --(BOOL) NCAppEnabled; --(NSString*) NCApp; --(BOOL) ncAppHideOnLS; - --(BOOL) alwaysEnableGestures; --(BOOL) snapWindows; --(BOOL) snapRotation; --(BOOL) launchIntoWindows; --(BOOL) windowedMultitaskingCompleteAnimations; --(BOOL) openLinksInWindows; --(BOOL) showSnapHelper; - --(NSInteger) globalBackgroundMode; --(BOOL) shouldShowStatusBarIcons; --(BOOL) shouldShowStatusBarNativeIcons; --(BOOL) backgrounderEnabled; --(BOOL) shouldShowIconIndicatorsGlobally; --(BOOL) showNativeStateIconIndicators; --(NSDictionary*) rawCompiledBackgrounderSettingsForIdentifier:(NSString*)identifier; - --(BOOL) missionControlEnabled; --(BOOL) replaceAppSwitcherWithMC; --(BOOL) missionControlKillApps; --(NSInteger) missionControlDesktopStyle; --(BOOL) missionControlPagingEnabled; - --(BOOL) isFirstRun; --(void) setFirstRun:(BOOL)value; - --(BOOL) swipeOverEnabled; --(BOOL) alwaysShowSOGrabber; - --(BOOL) exitAppAfterUsingActivatorAction; - --(BOOL) quickAccessUseGenericTabLabel; ++ (instancetype)sharedInstance; + ++ (BOOL)isParagonInstalled; ++ (BOOL)isActivatorInstalled; ++ (BOOL)isLibStatusBarInstalled; + +- (void)reloadSettings; +- (void)resetSettings; + +- (BOOL)enabled; + +- (BOOL)reachabilityEnabled; +- (BOOL)disableAutoDismiss; +- (BOOL)enableRotation; +- (BOOL)showNCInstead; +- (BOOL)homeButtonClosesReachability; +- (BOOL)showBottomGrabber; +- (BOOL)showWidgetSelector; +- (BOOL)scalingRotationMode; +- (BOOL)autoSizeWidgetSelector; +- (BOOL)showAllAppsInWidgetSelector; +- (BOOL)showRecentAppsInWidgetSelector; +- (BOOL)pagingEnabled; +- (NSMutableArray*)favoriteApps; +- (BOOL)unifyStatusBar; +- (BOOL)flipTopAndBottom; +- (BOOL)showFavorites; + +- (BOOL)NCAppEnabled; +- (NSString*)NCApp; +- (BOOL)ncAppHideOnLS; + +- (BOOL)alwaysEnableGestures; +- (BOOL)snapWindows; +- (BOOL)snapRotation; +- (BOOL)launchIntoWindows; +- (BOOL)windowedMultitaskingCompleteAnimations; +- (BOOL)openLinksInWindows; +- (BOOL)showSnapHelper; + +- (NSInteger)globalBackgroundMode; +- (BOOL)shouldShowStatusBarIcons; +- (BOOL)shouldShowStatusBarNativeIcons; +- (BOOL)backgrounderEnabled; +- (BOOL)shouldShowIconIndicatorsGlobally; +- (BOOL)showNativeStateIconIndicators; +- (NSDictionary*)rawCompiledBackgrounderSettingsForIdentifier:(NSString*)identifier; + +- (BOOL)missionControlEnabled; +- (BOOL)replaceAppSwitcherWithMC; +- (BOOL)missionControlKillApps; +- (NSInteger)missionControlDesktopStyle; +- (BOOL)missionControlPagingEnabled; + +- (BOOL)isFirstRun; +- (void)setFirstRun:(BOOL)value; + +- (BOOL)swipeOverEnabled; +- (BOOL)alwaysShowSOGrabber; + +- (BOOL)exitAppAfterUsingActivatorAction; + +- (BOOL)quickAccessUseGenericTabLabel; #if DEBUG --(BOOL) debug_showIPCMessages; +- (BOOL)debug_showIPCMessages; #endif --(BOOL) windowedMultitaskingEnabled; --(NSInteger) windowRotationLockMode; --(RAGrabArea) windowedMultitaskingGrabArea; --(RAGrabArea) swipeOverGrabArea; --(BOOL) onlyShowWindowBarIconsOnOverlay; +- (BOOL)windowedMultitaskingEnabled; +- (NSInteger)windowRotationLockMode; +- (RAGrabArea)windowedMultitaskingGrabArea; +- (RAGrabArea)swipeOverGrabArea; +- (BOOL)onlyShowWindowBarIconsOnOverlay; --(NSString*) currentThemeIdentifier; +- (NSString*)currentThemeIdentifier; @end diff --git a/RASettings.mm b/RASettings.mm index 8ef1703..86403ed 100644 --- a/RASettings.mm +++ b/RASettings.mm @@ -10,8 +10,7 @@ @implementation RASettings -+(BOOL) isParagonInstalled -{ ++ (BOOL)isParagonInstalled { static BOOL installed = NO; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -20,58 +19,50 @@ +(BOOL) isParagonInstalled return installed; } -+(BOOL) isActivatorInstalled -{ ++ (BOOL)isActivatorInstalled { static BOOL installed = NO; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - if ([NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/libactivator.dylib"]) - { + if ([NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/libactivator.dylib"]) { installed = YES; - dlopen("/Library/MobileSubstrate/DynamicLibraries/libactivator.dylib", RTLD_LAZY); + dlopen("/Library/MobileSubstrate/DynamicLibraries/libactivator.dylib", RTLD_LAZY); } }); return installed; } -+(BOOL) isLibStatusBarInstalled -{ ++ (BOOL)isLibStatusBarInstalled { static BOOL installed = NO; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - if ([NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib"]) - { + if ([NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib"]) { installed = YES; - dlopen("/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib", RTLD_LAZY); + dlopen("/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib", RTLD_LAZY); } }); return installed; } -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE(RASettings); } --(instancetype) init -{ - if (self = [super init]) - { +- (instancetype)init { + self = [super init]; + if (self) { [self reloadSettings]; } return self; } --(void) reloadSettings -{ +- (void)reloadSettings { @autoreleasepool { //NSLog(@"[ReachApp] reloading settings"); // Prepare specialized setting change cases NSString *previousNCAppSetting = self.NCApp; // Reload Settings - if (_settings) - { + if (_settings) { //CFRelease((__bridge CFDictionaryRef)_settings); _settings = nil; } @@ -81,49 +72,44 @@ -(void) reloadSettings BOOL failed = NO; - if (keyList) - { + if (keyList) { //_settings = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); _settings = (NSDictionary*)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)); CFRelease(keyList); - if (!_settings) - { + if (!_settings) { //NSLog(@"[ReachApp] failure loading from CFPreferences"); failed = YES; } - } - else - { + } else { //NSLog(@"[ReachApp] failure loading keyList"); failed = YES; } CFRelease(appID); - if (failed) - { + if (failed) { _settings = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.efrederickson.reachapp.settings.plist"]; //NSLog(@"[ReachApp] settings sandbox load: %@", _settings == nil ? @"failed" : @"succeed"); } - if (!_settings) - { + if (!_settings) { LogError(@"[ReachApp] could not load settings from CFPreferences or NSDictionary"); } - if (![previousNCAppSetting isEqual:self.NCApp]) + if (![previousNCAppSetting isEqual:self.NCApp]) { [[objc_getClass("RANCViewController") sharedViewController] forceReloadAppLikelyBecauseTheSettingChanged]; // using objc_getClass allows RASettings to be used in reachappsettings and other places + } - if (![self shouldShowStatusBarIcons] && [objc_getClass("SBApplication") respondsToSelector:@selector(RA_clearAllStatusBarIcons)]) + if (![self shouldShowStatusBarIcons] && [objc_getClass("SBApplication") respondsToSelector:@selector(RA_clearAllStatusBarIcons)]) { [objc_getClass("SBApplication") performSelector:@selector(RA_clearAllStatusBarIcons)]; + } [RAThemeManager.sharedInstance invalidateCurrentThemeAndReload:[self currentThemeIdentifier]]; [backgrounderSettingsCache removeAllObjects]; } } --(void) resetSettings -{ +- (void)resetSettings { IF_NOT_SPRINGBOARD { @throw [NSException exceptionWithName:@"NotSpringBoardException" reason:@"Cannot reset settings outside of SpringBoard" userInfo:nil]; } @@ -131,13 +117,10 @@ -(void) resetSettings CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (keyList) - { + if (keyList) { CFPreferencesSetMultiple(NULL, keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); CFRelease(keyList); - } - else - { + } else { LogError(@"[ReachApp] unable to get keyList to reset settings"); } CFPreferencesAppSynchronize(appID); @@ -146,172 +129,154 @@ -(void) resetSettings CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.respring"), nil, nil, YES); } --(BOOL) enabled -{ +- (BOOL)enabled { return BOOL(@"enabled", YES); } #if DEBUG --(BOOL) debug_showIPCMessages { return BOOL(@"debug_showIPCMessages", YES); } +- (BOOL)debug_showIPCMessages { + return BOOL(@"debug_showIPCMessages", YES); +} #endif --(BOOL) reachabilityEnabled { return [self enabled] && BOOL(@"reachabilityEnabled", YES); } +- (BOOL)reachabilityEnabled { + return [self enabled] && BOOL(@"reachabilityEnabled", YES); +} --(BOOL) disableAutoDismiss -{ +- (BOOL)disableAutoDismiss { return BOOL(@"disableAutoDismiss", YES); } --(BOOL) enableRotation -{ +- (BOOL)enableRotation { return BOOL(@"enableRotation", YES); } --(BOOL) showNCInstead -{ +- (BOOL)showNCInstead { return BOOL(@"showNCInstead", NO); } --(BOOL) homeButtonClosesReachability -{ +- (BOOL)homeButtonClosesReachability { return BOOL(@"homeButtonClosesReachability", YES); } --(BOOL) showBottomGrabber -{ +- (BOOL)showBottomGrabber { return BOOL(@"showBottomGrabber", NO); } --(BOOL) showWidgetSelector -{ +- (BOOL)showWidgetSelector { return BOOL(@"showAppSelector", YES); } --(BOOL) scalingRotationMode -{ +- (BOOL)scalingRotationMode { return BOOL(@"rotationMode", NO); } --(BOOL) autoSizeWidgetSelector -{ +- (BOOL)autoSizeWidgetSelector { return BOOL(@"autoSizeAppChooser", YES); } --(BOOL) showAllAppsInWidgetSelector -{ +- (BOOL)showAllAppsInWidgetSelector { return BOOL(@"showAllAppsInAppChooser", YES); } --(BOOL) showRecentAppsInWidgetSelector -{ +- (BOOL)showRecentAppsInWidgetSelector { return BOOL(@"showRecents", YES); } --(BOOL) pagingEnabled -{ +- (BOOL)pagingEnabled { return BOOL(@"pagingEnabled", YES); } --(BOOL) NCAppEnabled -{ +- (BOOL)NCAppEnabled { return [self enabled] && BOOL(@"ncAppEnabled", YES); } --(BOOL) shouldShowStatusBarNativeIcons { return BOOL(@"shouldShowStatusBarNativeIcons", NO); } +- (BOOL)shouldShowStatusBarNativeIcons { + return BOOL(@"shouldShowStatusBarNativeIcons", NO); +} --(NSMutableArray*) favoriteApps -{ +- (NSMutableArray*)favoriteApps { NSMutableArray *favorites = [[NSMutableArray alloc] init]; - for (NSString *key in _settings.allKeys) - { - if ([key hasPrefix:@"Favorites-"]) - { + for (NSString *key in _settings.allKeys) { + if ([key hasPrefix:@"Favorites-"]) { NSString *ident = [key substringFromIndex:10]; - if ([_settings[key] boolValue]) + if ([_settings[key] boolValue]) { [favorites addObject:ident]; + } } } return favorites; } --(BOOL) unifyStatusBar -{ +- (BOOL)unifyStatusBar { return BOOL(@"unifyStatusBar", YES); } --(BOOL) flipTopAndBottom -{ +- (BOOL)flipTopAndBottom { return BOOL(@"flipTopAndBottom", NO); } --(NSString*) NCApp -{ +- (NSString*)NCApp { return ![_settings objectForKey:@"NCApp"] ? @"com.apple.Preferences" : _settings[@"NCApp"]; } --(BOOL) alwaysEnableGestures -{ +- (BOOL)alwaysEnableGestures { return BOOL(@"alwaysEnableGestures", YES); } --(BOOL) snapWindows -{ +- (BOOL)snapWindows { return BOOL(@"snapWindows", YES); } --(BOOL) launchIntoWindows -{ +- (BOOL)launchIntoWindows { return BOOL(@"launchIntoWindows", NO); } --(BOOL) openLinksInWindows { return BOOL(@"openLinksInWindows", NO); } +- (BOOL)openLinksInWindows { + return BOOL(@"openLinksInWindows", NO); +} --(BOOL) backgrounderEnabled -{ +- (BOOL)backgrounderEnabled { return [self enabled] && BOOL(@"backgrounderEnabled", YES); } --(BOOL) shouldShowIconIndicatorsGlobally -{ +- (BOOL)shouldShowIconIndicatorsGlobally { return BOOL(@"showIconIndicators", YES); } --(BOOL) showNativeStateIconIndicators -{ +- (BOOL)showNativeStateIconIndicators { return BOOL(@"showNativeStateIconIndicators", NO); } --(BOOL) missionControlEnabled -{ +- (BOOL)missionControlEnabled { return [self enabled] && BOOL(@"missionControlEnabled", YES); } --(BOOL) replaceAppSwitcherWithMC -{ +- (BOOL)replaceAppSwitcherWithMC { return BOOL(@"replaceAppSwitcherWithMC", NO); } --(BOOL) missionControlKillApps { return BOOL(@"mcKillApps", YES); } +- (BOOL)missionControlKillApps { + return BOOL(@"mcKillApps", YES); +} --(BOOL) snapRotation -{ +- (BOOL)snapRotation { return BOOL(@"snapRotation", YES); } --(NSInteger) globalBackgroundMode -{ +- (NSInteger)globalBackgroundMode { return ![_settings objectForKey:@"globalBackgroundMode"] ? RABackgroundModeNative : [_settings[@"globalBackgroundMode"] intValue]; } --(NSInteger) windowRotationLockMode -{ +- (NSInteger)windowRotationLockMode { return ![_settings objectForKey:@"windowRotationLockMode"] ? 0 : [_settings[@"windowRotationLockMode"] intValue]; } --(BOOL) shouldShowStatusBarIcons { return BOOL(@"shouldShowStatusBarIcons", YES); } +- (BOOL)shouldShowStatusBarIcons { + return BOOL(@"shouldShowStatusBarIcons", YES); +} --(NSDictionary*) _createAndCacheBackgrounderSettingsForIdentifier:(NSString*)identifier -{ +- (NSDictionary*)_createAndCacheBackgrounderSettingsForIdentifier:(NSString*)identifier { NSMutableDictionary *ret = [NSMutableDictionary dictionary]; ret[@"enabled"] = _settings[[NSString stringWithFormat:@"backgrounder-%@-enabled",identifier]] ?: @NO; @@ -341,46 +306,78 @@ -(NSDictionary*) _createAndCacheBackgrounderSettingsForIdentifier:(NSString*)ide return ret; } --(NSDictionary*) rawCompiledBackgrounderSettingsForIdentifier:(NSString*)identifier -{ +- (NSDictionary*)rawCompiledBackgrounderSettingsForIdentifier:(NSString*)identifier { return [backgrounderSettingsCache objectForKey:identifier] ?: [self _createAndCacheBackgrounderSettingsForIdentifier:identifier]; } --(BOOL) isFirstRun -{ +- (BOOL)isFirstRun { LogDebug(@"[ReachApp] %d", BOOL(@"isFirstRun", YES)); return BOOL(@"isFirstRun", YES); } --(void) setFirstRun:(BOOL)value -{ +- (void)setFirstRun:(BOOL)value { CFPreferencesSetAppValue(CFSTR("isFirstRun"), value ? kCFBooleanTrue : kCFBooleanFalse, CFSTR("com.efrederickson.reachapp.settings")); CFPreferencesAppSynchronize(CFSTR("com.efrederickson.reachapp.settings")); [self reloadSettings]; } --(BOOL) alwaysShowSOGrabber { return BOOL(@"alwaysShowSOGrabber", NO); } +- (BOOL)alwaysShowSOGrabber { + return BOOL(@"alwaysShowSOGrabber", NO); +} + +- (BOOL)swipeOverEnabled { + return [self enabled] && BOOL(@"swipeOverEnabled", YES); +} + +- (BOOL)windowedMultitaskingEnabled { + return [self enabled] && BOOL(@"windowedMultitaskingEnabled", YES); +} + +- (BOOL)exitAppAfterUsingActivatorAction { + return BOOL(@"exitAppAfterUsingActivatorAction", YES); +} --(BOOL) swipeOverEnabled { return [self enabled] && BOOL(@"swipeOverEnabled", YES); } --(BOOL) windowedMultitaskingEnabled { return [self enabled] && BOOL(@"windowedMultitaskingEnabled", YES); } --(BOOL) exitAppAfterUsingActivatorAction { return BOOL(@"exitAppAfterUsingActivatorAction", YES); } --(BOOL) windowedMultitaskingCompleteAnimations { return BOOL(@"windowedMultitaskingCompleteAnimations", NO); } --(NSString*) currentThemeIdentifier { return _settings[@"currentThemeIdentifier"] ?: @"com.eljahandandrew.multiplexer.themes.default"; } --(NSInteger) missionControlDesktopStyle { return [_settings[@"missionControlDesktopStyle"] ?: @1 intValue]; } --(BOOL) missionControlPagingEnabled { return BOOL(@"missionControlPagingEnabled", NO); } --(BOOL) showFavorites { return BOOL(@"showFavorites", YES); } --(BOOL) onlyShowWindowBarIconsOnOverlay { return BOOL(@"onlyShowWindowBarIconsOnOverlay", NO); } --(BOOL) quickAccessUseGenericTabLabel { return BOOL(@"quickAccessUseGenericTabLabel", NO); } --(BOOL) ncAppHideOnLS { return BOOL(@"ncAppHideOnLS", NO); } --(BOOL) showSnapHelper { return BOOL(@"showSnapHelper", NO); } +- (BOOL)windowedMultitaskingCompleteAnimations { + return BOOL(@"windowedMultitaskingCompleteAnimations", NO); +} + +- (NSString*)currentThemeIdentifier { + return _settings[@"currentThemeIdentifier"] ?: @"com.eljahandandrew.multiplexer.themes.default"; +} + +- (NSInteger)missionControlDesktopStyle { + return [_settings[@"missionControlDesktopStyle"] ?: @1 intValue]; +} + +- (BOOL)missionControlPagingEnabled { + return BOOL(@"missionControlPagingEnabled", NO); +} + +- (BOOL)showFavorites { + return BOOL(@"showFavorites", YES); +} + +- (BOOL)onlyShowWindowBarIconsOnOverlay { + return BOOL(@"onlyShowWindowBarIconsOnOverlay", NO); +} + +- (BOOL)quickAccessUseGenericTabLabel { + return BOOL(@"quickAccessUseGenericTabLabel", NO); +} + +- (BOOL)ncAppHideOnLS { + return BOOL(@"ncAppHideOnLS", NO); +} + +- (BOOL)showSnapHelper { + return BOOL(@"showSnapHelper", NO); +} --(RAGrabArea) windowedMultitaskingGrabArea -{ +- (RAGrabArea)windowedMultitaskingGrabArea { return ![_settings objectForKey:@"windowedMultitaskingGrabArea"] ? RAGrabAreaBottomLeftThird : (RAGrabArea)[_settings[@"windowedMultitaskingGrabArea"] intValue]; } --(RAGrabArea) swipeOverGrabArea -{ +- (RAGrabArea)swipeOverGrabArea { return ![_settings objectForKey:@"swipeOverGrabArea"] ? RAGrabAreaSideAnywhere : (RAGrabArea)[_settings[@"swipeOverGrabArea"] intValue]; } @end diff --git a/RASnapshotProvider.h b/RASnapshotProvider.h index fd5b7fb..86a901a 100644 --- a/RASnapshotProvider.h +++ b/RASnapshotProvider.h @@ -3,18 +3,18 @@ @interface RASnapshotProvider : NSObject { NSCache *imageCache; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(UIImage*) snapshotForDesktop:(RADesktopWindow*)desktop; --(void) forceReloadSnapshotOfDesktop:(RADesktopWindow*)desktop; +- (UIImage*)snapshotForDesktop:(RADesktopWindow*)desktop; +- (void)forceReloadSnapshotOfDesktop:(RADesktopWindow*)desktop; --(UIImage*) storedSnapshotOfMissionControl; --(void) storeSnapshotOfMissionControl:(UIWindow*)window; +- (UIImage*)storedSnapshotOfMissionControl; +- (void)storeSnapshotOfMissionControl:(UIWindow*)window; --(UIImage*) snapshotForIdentifier:(NSString*)identifier; --(void) forceReloadOfSnapshotForIdentifier:(NSString*)identifier; +- (UIImage*)snapshotForIdentifier:(NSString*)identifier; +- (void)forceReloadOfSnapshotForIdentifier:(NSString*)identifier; --(UIImage*) wallpaperImage; +- (UIImage*)wallpaperImage; --(void) forceReloadEverything; +- (void)forceReloadEverything; @end diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index 5ced566..4e547a5 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -3,13 +3,11 @@ #import "RAWindowBar.h" @implementation RASnapshotProvider -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RASnapshotProvider, sharedInstance->imageCache = [NSCache new]); } --(UIImage*) snapshotForIdentifier:(NSString*)identifier orientation:(UIInterfaceOrientation)orientation -{ +- (UIImage*)snapshotForIdentifier:(NSString*)identifier orientation:(UIInterfaceOrientation)orientation { /*if (![NSThread isMainThread]) { __block id result = nil; @@ -20,10 +18,10 @@ [targetQueue waitUntilAllOperationsAreFinished]; return result; }*/ - @autoreleasepool { - - if ([imageCache objectForKey:identifier]) return [imageCache objectForKey:identifier]; + if ([imageCache objectForKey:identifier]) { + return [imageCache objectForKey:identifier]; + } UIImage *image = nil; @@ -31,20 +29,16 @@ __block SBAppSwitcherSnapshotView *view = nil; ON_MAIN_THREAD(^{ - if ([%c(SBUIController) respondsToSelector:@selector(switcherController)]) - { + if ([%c(SBUIController) respondsToSelector:@selector(switcherController)]) { view = [[[%c(SBUIController) sharedInstance] switcherController] performSelector:@selector(_snapshotViewForDisplayItem:) withObject:item]; [view setOrientation:orientation orientationBehavior:0]; - } - else - { + } else { SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; view = [[%c(SBAppSwitcherSnapshotView) alloc] initWithDisplayItem:item application:app orientation:orientation preferringDownscaledSnapshot:NO async:NO withQueue:nil]; } }); - if (view) - { + if (view) { if ([view respondsToSelector:@selector(_loadSnapshotSync)]) { [view performSelectorOnMainThread:@selector(_loadSnapshotSync) withObject:nil waitUntilDone:YES]; image = MSHookIvar(view, "_snapshotImageView").image; @@ -53,22 +47,17 @@ SBSwitcherSnapshotImageView *snapshotImageView = snapshotContext.snapshotImageView; image = snapshotImageView.image; } - } - if (!image) - { + if (!image) { SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:identifier]; - if (app && app.mainSceneID) - { - @try - { + if (app && app.mainSceneID) { + @try { CGRect frame = CGRectMake(0, 0, 0, 0); UIView *view = [%c(SBUIController) _zoomViewWithSplashboardLaunchImageForApplication:app sceneID:app.mainSceneID screen:UIScreen.mainScreen interfaceOrientation:0 includeStatusBar:YES snapshotFrame:&frame]; - if (view) - { + if (view) { UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, 0); ON_MAIN_THREAD(^{ @@ -79,18 +68,17 @@ UIGraphicsEndImageContext(); } } - @catch (NSException *ex) - { + @catch (NSException *ex) { LogError(@"[ReachApp] error generating snapshot: %@", ex); } } - if (!image) // we can only hope it does not reach this point of desperation + if (!image) { // we can only hope it does not reach this point of desperation image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/Default.png", app.path]]; + } } - if (image) - { + if (image) { [imageCache setObject:image forKey:identifier]; } @@ -98,23 +86,19 @@ } } --(UIImage*) snapshotForIdentifier:(NSString*)identifier -{ +- (UIImage*)snapshotForIdentifier:(NSString*)identifier { return [self snapshotForIdentifier:identifier orientation:UIApplication.sharedApplication.statusBarOrientation]; } --(void) forceReloadOfSnapshotForIdentifier:(NSString*)identifier -{ +- (void)forceReloadOfSnapshotForIdentifier:(NSString*)identifier { [imageCache removeObjectForKey:identifier]; } --(UIImage*) storedSnapshotOfMissionControl -{ +- (UIImage*)storedSnapshotOfMissionControl { return [imageCache objectForKey:@"missioncontrol"]; } --(void) storeSnapshotOfMissionControl:(UIWindow*)window -{ +- (void)storeSnapshotOfMissionControl:(UIWindow*)window { UIGraphicsBeginImageContextWithOptions(window.bounds.size, YES, 0); [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; @@ -122,40 +106,41 @@ UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - if (image) + if (image) { [imageCache setObject:image forKey:@"missioncontrol"]; + } } --(NSString*) createKeyForDesktop:(RADesktopWindow*)desktop -{ +- (NSString*)createKeyForDesktop:(RADesktopWindow*)desktop { return [NSString stringWithFormat:@"desktop-%lu", (unsigned long)desktop.hash]; } --(UIImage*) snapshotForDesktop:(RADesktopWindow*)desktop -{ +- (UIImage*)snapshotForDesktop:(RADesktopWindow*)desktop { NSString *key = [self createKeyForDesktop:desktop]; - if ([imageCache objectForKey:key]) return [imageCache objectForKey:key]; + if ([imageCache objectForKey:key]) { + return [imageCache objectForKey:key]; + } UIImage *img = [self renderPreviewForDesktop:desktop]; - if (img) + if (img) { [imageCache setObject:img forKey:key]; + } return img; } --(void) forceReloadSnapshotOfDesktop:(RADesktopWindow*)desktop -{ +- (void)forceReloadSnapshotOfDesktop:(RADesktopWindow*)desktop { [imageCache removeObjectForKey:[self createKeyForDesktop:desktop]]; } -- (UIImage*)rotateImageToMatchOrientation:(UIImage*)oldImage -{ +- (UIImage*)rotateImageToMatchOrientation:(UIImage*)oldImage { CGFloat degrees = 0; - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight) { degrees = 270; - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { degrees = 90; - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) { degrees = 180; + } // https://stackoverflow.com/questions/20764623/rotate-newly-created-ios-image-90-degrees-prior-to-saving-as-png @@ -192,16 +177,15 @@ return newImage; } --(UIImage*) renderPreviewForDesktop:(RADesktopWindow*)desktop -{ +- (UIImage*)renderPreviewForDesktop:(RADesktopWindow*)desktop { @autoreleasepool { UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, 0); CGContextRef c = UIGraphicsGetCurrentContext(); - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; ON_MAIN_THREAD(^{ - [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; + [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; //}); [MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow").layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Wallpaper @@ -215,17 +199,15 @@ }); //[desktop.layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Desktop windows - for (UIView *view in desktop.subviews) // Application views - { - if ([view isKindOfClass:[RAWindowBar class]]) - { + for (UIView *view in desktop.subviews) { // Application views + if ([view isKindOfClass:[RAWindowBar class]]) { RAHostedAppView *hostedView = [((RAWindowBar*)view) attachedView]; UIImage *image = [self snapshotForIdentifier:hostedView.bundleIdentifier orientation:hostedView.orientation]; CIImage *coreImage = image.CIImage; - if (!coreImage) - coreImage = [CIImage imageWithCGImage:image.CGImage]; - + if (!coreImage) { + coreImage = [CIImage imageWithCGImage:image.CGImage]; + } //coreImage = [coreImage imageByApplyingTransform:view.transform]; CGFloat rotation = atan2(hostedView.transform.b, hostedView.transform.a); @@ -248,34 +230,31 @@ } } --(UIImage*) wallpaperImage -{ +- (UIImage*)wallpaperImage { return [self wallpaperImage:YES]; } --(UIImage*) wallpaperImage:(BOOL)blurred -{ +- (UIImage*)wallpaperImage:(BOOL)blurred { NSString *key = blurred ? @"wallpaperImageBlurred" : @"wallpaperImage"; - if ([imageCache objectForKey:key]) + if ([imageCache objectForKey:key]) { return [imageCache objectForKey:key]; - + } UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen.bounds.size, YES, 0); - CGContextRef c = UIGraphicsGetCurrentContext(); - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAWallpaperSnapshot"]; - [MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow").layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Wallpaper + ON_MAIN_THREAD(^{ + UIWindow *window = MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow"); + [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; + }); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow").layer.contents = nil; [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"RAWallpaperSnapshot"]; //UIImageView *imgView = [[UIImageView alloc] initWithImage:image];//Frame:(CGRect){CGPointZero,image.size}]; //imgView.image = image; - if (blurred) - { + if (blurred) { CIFilter *gaussianBlurFilter = [CIFilter filterWithName:@"CIGaussianBlur"]; [gaussianBlurFilter setDefaults]; CIImage *inputImage = [CIImage imageWithCGImage:[image CGImage]]; @@ -295,8 +274,7 @@ return image; } --(void) forceReloadEverything -{ +- (void)forceReloadEverything { [imageCache removeAllObjects]; } @end diff --git a/ReachAppIntegrator.h b/ReachAppIntegrator.h index 5dcb85a..95aa471 100644 --- a/ReachAppIntegrator.h +++ b/ReachAppIntegrator.h @@ -3,7 +3,8 @@ #import #define CHECK_FOR_REACHAPP \ -if ([NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/ReachApp.dylib"]) \ - dlopen("/Library/MobileSubstrate/DynamicLibraries/ReachApp.dylib", RTLD_NOW | RTLD_GLOBAL); +if ([NSFileManager.defaultManager fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/ReachApp.dylib"]) { \ + dlopen("/Library/MobileSubstrate/DynamicLibraries/ReachApp.dylib", RTLD_NOW | RTLD_GLOBAL); \ +} -#define IF_REACHAPP if (objc_getClass("RAWidget") != nil) \ No newline at end of file +#define IF_REACHAPP if (objc_getClass("RAWidget") != nil) diff --git a/Reachability/RAReachabilityManager.h b/Reachability/RAReachabilityManager.h index 4642c8e..82dbafb 100644 --- a/Reachability/RAReachabilityManager.h +++ b/Reachability/RAReachabilityManager.h @@ -3,11 +3,11 @@ @class RAAppSliderProviderView; @interface RAReachabilityManager : NSObject -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(void) launchTopAppWithIdentifier:(NSString*)identifier; --(void) launchWidget:(RAWidget*)widget; --(void) showAppWithSliderProvider:(__weak RAAppSliderProviderView*)view; +- (void)launchTopAppWithIdentifier:(NSString*)identifier; +- (void)launchWidget:(RAWidget*)widget; +- (void)showAppWithSliderProvider:(__weak RAAppSliderProviderView*)view; --(void) showWidgetSelector; +- (void)showWidgetSelector; @end diff --git a/Reachability/RAReachabilityManager.mm b/Reachability/RAReachabilityManager.mm index 412d090..6cefcb4 100644 --- a/Reachability/RAReachabilityManager.mm +++ b/Reachability/RAReachabilityManager.mm @@ -5,31 +5,26 @@ #import "RAMessagingServer.h" @implementation RAReachabilityManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE(RAReachabilityManager); } --(void) launchTopAppWithIdentifier:(NSString*)identifier -{ +- (void)launchTopAppWithIdentifier:(NSString*)identifier { //[[objc_getClass("SBWorkspace") sharedInstance] RA_closeCurrentView]; [GET_SBWORKSPACE RA_launchTopAppWithIdentifier:identifier]; } --(void) launchWidget:(RAWidget*)widget -{ +- (void)launchWidget:(RAWidget*)widget { //[[objc_getClass("SBWorkspace") sharedInstance] RA_closeCurrentView]; [GET_SBWORKSPACE RA_setView:[widget view] preferredHeight:[widget preferredHeight]]; } --(void) showWidgetSelector -{ +- (void)showWidgetSelector { //[[objc_getClass("SBWorkspace") sharedInstance] RA_closeCurrentView]; [GET_SBWORKSPACE RA_showWidgetSelector]; } --(void) showAppWithSliderProvider:(__weak RAAppSliderProviderView*)view -{ +- (void)showAppWithSliderProvider:(__weak RAAppSliderProviderView*)view { //[[objc_getClass("SBWorkspace") sharedInstance] RA_closeCurrentView]; [view updateCurrentView]; [view load]; diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 91efb32..7cc6651 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -40,59 +40,55 @@ BOOL wasEnabled = NO; %group hooks %hook SBReachabilityManager -+(BOOL)reachabilitySupported -{ ++ (BOOL)reachabilitySupported { return YES; } -- (void)_handleReachabilityActivated -{ +- (void)_handleReachabilityActivated { overrideOrientation = YES; %orig; overrideOrientation = NO; } -- (void)enableExpirationTimerForEndedInteraction -{ - if ([RASettings.sharedInstance disableAutoDismiss]) +- (void)enableExpirationTimerForEndedInteraction { + if ([RASettings.sharedInstance disableAutoDismiss]) { return; + } %orig; } -- (void)_handleSignificantTimeChanged -{ - if ([RASettings.sharedInstance disableAutoDismiss]) +- (void)_handleSignificantTimeChanged { + if ([RASettings.sharedInstance disableAutoDismiss]) { return; + } %orig; } -- (void)_keepAliveTimerFired:(unsafe_id)arg1 -{ - if ([RASettings.sharedInstance disableAutoDismiss]) +- (void)_keepAliveTimerFired:(unsafe_id)arg1 { + if ([RASettings.sharedInstance disableAutoDismiss]) { return; + } %orig; } -- (void)_setKeepAliveTimerForDuration:(double)arg1 -{ - if ([RASettings.sharedInstance disableAutoDismiss]) +- (void)_setKeepAliveTimerForDuration:(double)arg1 { + if ([RASettings.sharedInstance disableAutoDismiss]) { return; + } %orig; } -- (void)deactivateReachabilityModeForObserver:(unsafe_id)arg1 -{ +- (void)deactivateReachabilityModeForObserver:(unsafe_id)arg1 { //Disable for keyboard here - if (overrideDisableForStatusBar) + if (overrideDisableForStatusBar) { return; + } %orig; - if (wasEnabled) - { + if (wasEnabled) { wasEnabled = NO; // Notify both top and bottom apps Reachability is closing - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; @@ -100,46 +96,46 @@ BOOL wasEnabled = NO; [view removeFromSuperview]; view = nil; } - if (lastBundleIdentifier && lastBundleIdentifier.length > 0) - { + if (lastBundleIdentifier && lastBundleIdentifier.length > 0) { [RAMessagingServer.sharedInstance endResizingApp:lastBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:lastBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:lastBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:lastBundleIdentifier completion:nil]; } - if (currentBundleIdentifier) + if (currentBundleIdentifier) { [RAMessagingServer.sharedInstance endResizingApp:currentBundleIdentifier completion:nil]; + } [GET_SBWORKSPACE RA_closeCurrentView]; } } -- (void)_handleReachabilityDeactivated -{ - if (overrideDisableForStatusBar) +- (void)_handleReachabilityDeactivated { + if (overrideDisableForStatusBar) { return; + } %orig; } -- (void)_updateReachabilityModeActive:(_Bool)arg1 withRequestingObserver:(unsafe_id)arg2 -{ - if (overrideDisableForStatusBar) +- (void)_updateReachabilityModeActive:(_Bool)arg1 withRequestingObserver:(unsafe_id)arg2 { + if (overrideDisableForStatusBar) { return; + } %orig; } %end %hook SBReachabilitySettings --(CGFloat) reachabilityDefaultKeepAlive -{ - if ([RASettings.sharedInstance disableAutoDismiss]) +- (CGFloat)reachabilityDefaultKeepAlive { + if ([RASettings.sharedInstance disableAutoDismiss]) { return 9999999999; + } return %orig; } --(CGFloat) reachabilityInteractiveKeepAlive -{ - if ([RASettings.sharedInstance disableAutoDismiss]) +- (CGFloat)reachabilityInteractiveKeepAlive { + if ([RASettings.sharedInstance disableAutoDismiss]) { return 9999999999; + } return %orig; } @@ -147,40 +143,35 @@ BOOL wasEnabled = NO; id SBWorkspace$sharedInstance; %hook SB_WORKSPACE_CLASS -%new +(instancetype) sharedInstance -{ +%new + (instancetype)sharedInstance { return SBWorkspace$sharedInstance; } --(id) init -{ +- (id)init { SBWorkspace$sharedInstance = %orig; return SBWorkspace$sharedInstance; } -%new -(BOOL) isUsingReachApp -{ +%new - (BOOL)isUsingReachApp { return (view || showingNC); } -- (void)_exitReachabilityModeWithCompletion:(unsafe_id)arg1 -{ - if (overrideDisableForStatusBar) +- (void)_exitReachabilityModeWithCompletion:(unsafe_id)arg1 { + if (overrideDisableForStatusBar) { return; + } %orig; } -- (void)handleReachabilityModeDeactivated -{ - if (overrideDisableForStatusBar) +- (void)handleReachabilityModeDeactivated { + if (overrideDisableForStatusBar) { return; + } %orig; } -%new -(void) RA_closeCurrentView -{ - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { +%new - (void)RA_closeCurrentView { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; @@ -192,8 +183,7 @@ id SBWorkspace$sharedInstance; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:currentBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:currentBundleIdentifier completion:nil]; - if ([RASettings.sharedInstance showNCInstead]) - { + if ([RASettings.sharedInstance showNCInstead]) { showingNC = NO; UIWindow *window = MSHookIvar(self, "_reachabilityEffectWindow"); [window _setRotatableViewOrientation:UIInterfaceOrientationPortrait updateStatusBar:YES duration:0.0 force:YES]; @@ -206,27 +196,20 @@ id SBWorkspace$sharedInstance; [viewController performSelector:@selector(_loadContainerView)]; } //[viewController.view removeFromSuperview]; - } - else - { + } else { SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { [((RAAppSliderProviderView*)view) unload]; } // Give them a little time to receive the notifications... - if (view) - { - if ([view superview]) - [view removeFromSuperview]; + if (view && [view superview]) { + [view removeFromSuperview]; } dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - if (lastBundleIdentifier && lastBundleIdentifier.length > 0) - { - if (app && [app pid] && [app mainScene]) - { + if (lastBundleIdentifier && lastBundleIdentifier.length > 0) { + if (app && [app pid] && [app mainScene]) { FBScene *scene = [app mainScene]; FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy]; SET_BACKGROUNDED(settings, YES); @@ -235,8 +218,7 @@ id SBWorkspace$sharedInstance; //MSHookIvar([app mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; SBApplication *currentApp = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:currentBundleIdentifier]; - if ([currentApp mainScene]) - { + if ([currentApp mainScene]) { //MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").frame = pre_topAppFrame; //MSHookIvar([currentApp mainScene].contextHostManager, "_hostView").transform = pre_topAppTransform; } @@ -251,26 +233,23 @@ id SBWorkspace$sharedInstance; } } -- (void)_disableReachabilityImmediately:(_Bool)arg1 -{ +- (void)_disableReachabilityImmediately:(_Bool)arg1 { //Disable for keyboard here - if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) + if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) { return; + } %orig; - if (![RASettings.sharedInstance reachabilityEnabled] && !wasEnabled) - { + if (![RASettings.sharedInstance reachabilityEnabled] && !wasEnabled) { return; } - if (arg1 && wasEnabled) - { + if (arg1 && wasEnabled) { wasEnabled = NO; // Notify both top and bottom apps Reachability is closing - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; @@ -278,27 +257,28 @@ id SBWorkspace$sharedInstance; [view removeFromSuperview]; view = nil; } - if (lastBundleIdentifier && lastBundleIdentifier.length > 0) - { + if (lastBundleIdentifier && lastBundleIdentifier.length > 0) { [RAMessagingServer.sharedInstance endResizingApp:lastBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:lastBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:lastBundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance setHosted:NO forIdentifier:lastBundleIdentifier completion:nil]; } - if (currentBundleIdentifier) + if (currentBundleIdentifier) { [RAMessagingServer.sharedInstance endResizingApp:currentBundleIdentifier completion:nil]; + } [self RA_closeCurrentView]; - if (draggerView) + if (draggerView) { draggerView = nil; + } } } -- (void) handleReachabilityModeActivated -{ +- (void)handleReachabilityModeActivated { %orig; - if (![RASettings.sharedInstance reachabilityEnabled]) + if (![RASettings.sharedInstance reachabilityEnabled]) { return; + } wasEnabled = YES; CGFloat knobWidth = 60; @@ -312,12 +292,12 @@ id SBWorkspace$sharedInstance; grabberCenter_X = draggerView.center.x; UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); - if ([RASettings.sharedInstance showNCInstead]) - { + if ([RASettings.sharedInstance showNCInstead]) { showingNC = YES; - if (!ncViewController) + if (!ncViewController) { ncViewController = [[%c(SBNotificationCenterViewController) alloc] init]; + } ncViewController.view.frame = (CGRect) { { 0, 0 }, w.frame.size }; w.rootViewController = ncViewController; [w addSubview:ncViewController.view]; @@ -330,44 +310,38 @@ id SBWorkspace$sharedInstance; [ncViewController _loadContainerView]; } - if ([RASettings.sharedInstance enableRotation]) - { + if ([RASettings.sharedInstance enableRotation]) { [w _setRotatableViewOrientation:[UIApplication sharedApplication].statusBarOrientation updateStatusBar:YES duration:0.0 force:YES]; } - } - else - { + } else { currentBundleIdentifier = [[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; - if (!currentBundleIdentifier) + if (!currentBundleIdentifier) { return; + } - if ([RASettings.sharedInstance showWidgetSelector]) - { + if ([RASettings.sharedInstance showWidgetSelector]) { [self RA_showWidgetSelector]; - } - else - { + } else { SBApplication *app = nil; FBScene *scene = nil; NSMutableArray *bundleIdentifiers = [[RAAppSwitcherModelWrapper appSwitcherAppIdentiferList] mutableCopy]; - while (!scene && bundleIdentifiers.count > 0) - { + while (!scene && bundleIdentifiers.count > 0) { lastBundleIdentifier = bundleIdentifiers[0]; - if ([lastBundleIdentifier isEqual:currentBundleIdentifier]) - { + if ([lastBundleIdentifier isEqual:currentBundleIdentifier]) { [bundleIdentifiers removeObjectAtIndex:0]; continue; } app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; scene = [app mainScene]; - if (!scene) - if (bundleIdentifiers.count > 0) - [bundleIdentifiers removeObjectAtIndex:0]; + if (!scene && bundleIdentifiers.count > 0) { + [bundleIdentifiers removeObjectAtIndex:0]; + } } - if (!lastBundleIdentifier || lastBundleIdentifier.length == 0) + if (!lastBundleIdentifier || lastBundleIdentifier.length == 0) { return; + } [self RA_launchTopAppWithIdentifier:lastBundleIdentifier]; } @@ -375,10 +349,12 @@ id SBWorkspace$sharedInstance; draggerView.backgroundColor = UIColor.lightGrayColor; UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; - if (grabberCenter_Y == -1) + if (grabberCenter_Y == -1) { grabberCenter_Y = w.frame.size.height - (knobHeight / 2); - if (grabberCenter_Y < 0) + } + if (grabberCenter_Y < 0) { grabberCenter_Y = UIScreen.mainScreen.bounds.size.height * 0.3; + } draggerView.center = CGPointMake(grabberCenter_X, grabberCenter_Y); recognizer.delegate = (id)self; [draggerView addGestureRecognizer:recognizer]; @@ -394,8 +370,7 @@ id SBWorkspace$sharedInstance; [w addSubview:draggerView]; - if ([RASettings.sharedInstance showBottomGrabber]) - { + if ([RASettings.sharedInstance showBottomGrabber]) { bottomDraggerView = [[UIView alloc] initWithFrame:CGRectMake( (UIScreen.mainScreen.bounds.size.width / 2) - (knobWidth / 2), -(knobHeight / 2), @@ -411,10 +386,10 @@ id SBWorkspace$sharedInstance; [self updateViewSizes:draggerView.center animate:NO]; } -%new -(void)RA_showWidgetSelector -{ - if (view) +%new - (void)RA_showWidgetSelector { + if (view) { [self RA_closeCurrentView]; + } UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); //CGSize iconSize = [%c(SBIconView) defaultIconImageSize]; @@ -424,8 +399,7 @@ id SBWorkspace$sharedInstance; NSInteger numIconsPerLine = 0; CGFloat tmpWidth = 10; - while (tmpWidth + fullSize.width <= w.frame.size.width) - { + while (tmpWidth + fullSize.width <= w.frame.size.width) { numIconsPerLine++; tmpWidth += fullSize.width + 20; } @@ -435,17 +409,18 @@ id SBWorkspace$sharedInstance; widgetSelectorView.frame = (CGRect){ { 0, 0 }, widgetSelectorView.frame.size }; //widgetSelectorView.frame = w.frame; - if (draggerView) + if (draggerView) { [w insertSubview:widgetSelectorView belowSubview:draggerView]; - else + } else { [w addSubview:widgetSelectorView]; + } view = widgetSelectorView; - if ([RASettings.sharedInstance autoSizeWidgetSelector]) - { + if ([RASettings.sharedInstance autoSizeWidgetSelector]) { CGFloat moddedHeight = widgetSelectorView.frame.size.height; - if (old_grabberCenterY == -1) + if (old_grabberCenterY == -1) { old_grabberCenterY = UIScreen.mainScreen.bounds.size.height * 0.3; + } old_grabberCenterY = grabberCenter_Y; grabberCenter_Y = moddedHeight; } @@ -456,69 +431,57 @@ id SBWorkspace$sharedInstance; } CGFloat startingY = -1; -%new -(void)handlePan:(UIPanGestureRecognizer*)sender -{ +%new - (void)handlePan:(UIPanGestureRecognizer*)sender { UIView *view = draggerView; //sender.view; - if (sender.state == UIGestureRecognizerStateBegan) - { + if (sender.state == UIGestureRecognizerStateBegan) { startingY = grabberCenter_Y; grabberCenter_X = view.center.x; firstLocation = view.center; grabberCenter_Y = [sender locationInView:view.superview].y; draggerView.alpha = 0.8; bottomDraggerView.alpha = 0; - } - else if (sender.state == UIGestureRecognizerStateChanged) - { + } else if (sender.state == UIGestureRecognizerStateChanged) { CGPoint translation = [sender translationInView:view]; - if (firstLocation.y + translation.y < 50) - { + if (firstLocation.y + translation.y < 50) { view.center = CGPointMake(grabberCenter_X, 50); grabberCenter_Y = 50; - } - else if (firstLocation.y + translation.y > UIScreen.mainScreen.bounds.size.height - 30) - { + } else if (firstLocation.y + translation.y > UIScreen.mainScreen.bounds.size.height - 30) { view.center = CGPointMake(grabberCenter_X, UIScreen.mainScreen.bounds.size.height - 30); grabberCenter_Y = UIScreen.mainScreen.bounds.size.height - 30; - } - else - { + } else { view.center = CGPointMake(grabberCenter_X, firstLocation.y + translation.y); grabberCenter_Y = [sender locationInView:view.superview].y; } [self updateViewSizes:view.center animate:YES]; - } - else if (sender.state == UIGestureRecognizerStateEnded) - { + } else if (sender.state == UIGestureRecognizerStateEnded) { draggerView.alpha = 0.3; bottomDraggerView.alpha = 0.3; - if (startingY != -1 && fabs(grabberCenter_Y - startingY) < 3) + if (startingY != -1 && fabs(grabberCenter_Y - startingY) < 3) { [self RA_handleLongPress:nil]; + } startingY = -1; [self updateViewSizes:view.center animate:YES]; } } -%new -(void) RA_handleLongPress:(UILongPressGestureRecognizer*)gesture -{ +%new - (void)RA_handleLongPress:(UILongPressGestureRecognizer*)gesture { [self RA_showWidgetSelector]; } -%new -(void) RA_detachAppAndClose:(UITapGestureRecognizer*)gesture -{ +%new - (void)RA_detachAppAndClose:(UITapGestureRecognizer*)gesture { NSString *ident = lastBundleIdentifier; - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { RAAppSliderProviderView *temp = (RAAppSliderProviderView*)view; ident = temp.currentBundleIdentifier; [temp unload]; } - if (!ident || ident.length == 0) + if (!ident || ident.length == 0) { return; + } [self handleReachabilityModeDeactivated]; SBApplication *app = [[%c(SBApplicationController) sharedInstance] RA_applicationWithBundleIdentifier:ident]; @@ -543,20 +506,18 @@ CGFloat startingY = -1; [[%c(RABackgrounder) sharedInstance] updateIconIndicatorForIdentifier:ident withInfo:indicatorInfo]; } -%new - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer -{ - if ([view isKindOfClass:[UIScrollView class]]) +%new - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { + if ([view isKindOfClass:[UIScrollView class]]) { return NO; + } return YES; } -%new -(void) RA_updateViewSizes -{ +%new - (void)RA_updateViewSizes { [self updateViewSizes:draggerView.center animate:YES]; } -%new -(void) updateViewSizes:(CGPoint) center animate:(BOOL)animate -{ +%new - (void)updateViewSizes:(CGPoint)center animate:(BOOL)animate { // Resizing UIWindow *topWindow = MSHookIvar(self, "_reachabilityEffectWindow"); UIWindow *bottomWindow = MSHookIvar(self, "_reachabilityWindow"); @@ -564,18 +525,14 @@ CGFloat startingY = -1; CGRect topFrame = CGRectMake(topWindow.frame.origin.x, topWindow.frame.origin.y, topWindow.frame.size.width, center.y); CGRect bottomFrame = CGRectMake(bottomWindow.frame.origin.x, center.y, bottomWindow.frame.size.width, UIScreen.mainScreen._referenceBounds.size.height - center.y); - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { topFrame = CGRectMake(topWindow.frame.origin.x, 0, topWindow.frame.size.width, center.y); bottomFrame = CGRectMake(bottomWindow.frame.origin.x, center.y, bottomWindow.frame.size.width, UIScreen.mainScreen._referenceBounds.size.height - center.y); - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) - { + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) { } - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { RAAppSliderProviderView *sliderView = (RAAppSliderProviderView*)view; sliderView.frame = topFrame; } @@ -587,92 +544,78 @@ CGFloat startingY = -1; bottomFrame = tmp; }*/ - if (animate) - { + if (animate) { [UIView animateWithDuration:0.3 animations:^{ bottomWindow.frame = bottomFrame; topWindow.frame = topFrame; - if (view && [view isKindOfClass:[UIScrollView class]]) + if (view && [view isKindOfClass:[UIScrollView class]]) { view.frame = topFrame; + } }]; - } - else - { + } else { bottomWindow.frame = bottomFrame; topWindow.frame = topFrame; - if (view && [view isKindOfClass:[UIScrollView class]]) + if (view && [view isKindOfClass:[UIScrollView class]]) { view.frame = topFrame; + } } - if ([RASettings.sharedInstance showNCInstead]) - { - if (ncViewController) - ncViewController.view.frame = (CGRect) { { 0, 0 }, topFrame.size }; - } - else if (lastBundleIdentifier || [view isKindOfClass:[RAAppSliderProviderView class]]) - { + if ([RASettings.sharedInstance showNCInstead] && ncViewController) { + ncViewController.view.frame = (CGRect) { { 0, 0 }, topFrame.size }; + } else if (lastBundleIdentifier || [view isKindOfClass:[RAAppSliderProviderView class]]) { // Notify clients CGFloat width = - 1, height = -1; - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { RAAppSliderProviderView *sliderView = (RAAppSliderProviderView*)view; //width = sliderView.clientFrame.size.width; //height = sliderView.clientFrame.size.height; - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) { width = center.y; height = topWindow.frame.size.width; - } - else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { + } else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { //width = topWindow.frame.size.height; width = bottomWindow.frame.origin.y; height = topWindow.frame.size.width; - } - else - { + } else { width = sliderView.clientFrame.size.width; height = sliderView.clientFrame.size.height; } - } - else - { - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { + } else { + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) { width = center.y; height = topWindow.frame.size.width; - } - else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { + } else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { width = bottomWindow.frame.origin.y; height = topWindow.frame.size.width; - } - else - { + } else { width = topWindow.frame.size.width; height = topWindow.frame.size.height; } } NSString *targetIdentifier = lastBundleIdentifier; - if ([view isKindOfClass:[RAAppSliderProviderView class]]) + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { targetIdentifier = [((RAAppSliderProviderView*)view) currentBundleIdentifier]; + } - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { [RAMessagingServer.sharedInstance moveApp:targetIdentifier toOrigin:CGPointMake(bottomWindow.frame.size.height, 0) completion:nil]; + } [RAMessagingServer.sharedInstance resizeApp:targetIdentifier toSize:CGSizeMake(width, height) completion:nil]; } - if (![view isKindOfClass:[%c(FBWindowContextHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_OLDER(iOS_8_4)) + if (![view isKindOfClass:[%c(FBWindowContextHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_OLDER(iOS_8_4)) { return; // only resize when the app is being shown. That way it's more like native Reachability + } - if (![view isKindOfClass:[%c(FBSceneHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_NEWER(iOS_9_0)) + if (![view isKindOfClass:[%c(FBSceneHostWrapperView) class]] && ![view isKindOfClass:[RAAppSliderProviderView class]] && IS_IOS_OR_NEWER(iOS_9_0)) { return; // iOS 9 + } [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:currentBundleIdentifier completion:nil]; @@ -680,46 +623,41 @@ CGFloat startingY = -1; CGFloat width = -1, height = -1; - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) - { + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) { width = bottomWindow.frame.size.height; height = bottomWindow.frame.size.width; - } - else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) - { + } else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { //width = center.y; width = bottomWindow.frame.size.height; height = bottomWindow.frame.size.width; [RAMessagingServer.sharedInstance moveApp:currentBundleIdentifier toOrigin:CGPointMake(bottomWindow.frame.origin.y, 0) completion:nil]; - } - else - { + } else { width = bottomWindow.frame.size.width; height = bottomWindow.frame.size.height; } [RAMessagingServer.sharedInstance resizeApp:currentBundleIdentifier toSize:CGSizeMake(width, height) completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:currentBundleIdentifier completion:nil]; - if ([RASettings.sharedInstance unifyStatusBar]) + if ([RASettings.sharedInstance unifyStatusBar]) { [RAMessagingServer.sharedInstance forceStatusBarVisibility:NO forApp:currentBundleIdentifier completion:nil]; + } } -%new -(void) RA_launchTopAppWithIdentifier:(NSString*) bundleIdentifier -{ +%new - (void)RA_launchTopAppWithIdentifier:(NSString*)bundleIdentifier { UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:lastBundleIdentifier]; FBScene *scene = [app mainScene]; - if (!app) + if (!app) { return; + } [RAMessagingServer.sharedInstance setHosted:YES forIdentifier:app.bundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:app.bundleIdentifier completion:nil]; [RAMessagingServer.sharedInstance rotateApp:app.bundleIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; [RAMessagingServer.sharedInstance forceStatusBarVisibility:YES forApp:app.bundleIdentifier completion:nil]; - if (![app pid] || ![app mainScene]) - { + if (![app pid] || ![app mainScene]) { overrideDisableForStatusBar = YES; [UIApplication.sharedApplication launchApplicationWithIdentifier:bundleIdentifier suspended:YES]; [[%c(FBProcessManager) sharedInstance] createApplicationProcessForBundleID:bundleIdentifier]; @@ -746,10 +684,11 @@ CGFloat startingY = -1; view.accessibilityHint = bundleIdentifier; - if (draggerView && draggerView.superview == w) + if (draggerView && draggerView.superview == w) { [w insertSubview:view belowSubview:draggerView]; - else + } else { [w addSubview:view]; + } //if ([RASettings.sharedInstance enableRotation] && ![RASettings.sharedInstance scalingRotationMode]) { @@ -791,14 +730,11 @@ CGFloat startingY = -1; overrideDisableForStatusBar = NO; } -%new -(void) RA_setView:(UIView*)view_ preferredHeight:(CGFloat)pHeight -{ +%new - (void)RA_setView:(UIView*)view_ preferredHeight:(CGFloat)pHeight { view_.hidden = NO; UIWindow *w = MSHookIvar(self, "_reachabilityEffectWindow"); - if (view) - { - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { + if (view) { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { [RAMessagingServer.sharedInstance endResizingApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:NO forApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; [RAMessagingServer.sharedInstance unforceStatusBarVisibilityForApp:[((RAAppSliderProviderView*)view) currentBundleIdentifier] completion:nil]; @@ -809,16 +745,16 @@ CGFloat startingY = -1; } view = view_; [w addSubview:view]; - if (draggerView && draggerView.superview) + if (draggerView && draggerView.superview) { [draggerView.superview bringSubviewToFront:draggerView]; + } CGPoint center = (CGPoint){ draggerView.center.x, pHeight <= 0 ? draggerView.center.y : pHeight }; [self updateViewSizes:center animate:YES]; draggerView.hidden = NO; draggerView.center = center; - if ([view isKindOfClass:[RAAppSliderProviderView class]]) - { + if ([view isKindOfClass:[RAAppSliderProviderView class]]) { NSString *targetIdentifier = ((RAAppSliderProviderView*)view).currentBundleIdentifier; [RAMessagingServer.sharedInstance setShouldUseExternalKeyboard:YES forApp:targetIdentifier completion:nil]; [RAMessagingServer.sharedInstance rotateApp:targetIdentifier toOrientation:[UIApplication sharedApplication].statusBarOrientation completion:nil]; @@ -826,8 +762,7 @@ CGFloat startingY = -1; } } -%new -(void) RA_animateWidgetSelectorOut:(id)completion -{ +%new - (void)RA_animateWidgetSelectorOut:(id)completion { [UIView animateWithDuration:0.3 animations:^{ view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.01, 0.01); @@ -836,15 +771,14 @@ CGFloat startingY = -1; completion:completion]; } -%new -(void) appViewItemTap:(UITapGestureRecognizer*)sender -{ +%new - (void)appViewItemTap:(UITapGestureRecognizer*)sender { int pid = [sender.view tag]; SBApplication *app = [[%c(SBApplicationController) sharedInstance] applicationWithPid:pid]; - if (!app) + if (!app) { app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:sender.view.restorationIdentifier]; + } - if (app) - { + if (app) { // before we re-assign view... [self RA_animateWidgetSelectorOut:^(BOOL a){ [view removeFromSuperview]; @@ -853,10 +787,10 @@ CGFloat startingY = -1; lastBundleIdentifier = app.bundleIdentifier; [self RA_launchTopAppWithIdentifier:app.bundleIdentifier]; - if ([RASettings.sharedInstance autoSizeWidgetSelector]) - { - if (old_grabberCenterY == -1) + if ([RASettings.sharedInstance autoSizeWidgetSelector]) { + if (old_grabberCenterY == -1) { old_grabberCenterY = UIScreen.mainScreen.bounds.size.height * 0.3; + } grabberCenter_Y = old_grabberCenterY; draggerView.center = CGPointMake(grabberCenter_X, grabberCenter_Y); } @@ -867,19 +801,17 @@ CGFloat startingY = -1; %end %hook SpringBoard -- (UIInterfaceOrientation)activeInterfaceOrientation -{ +- (UIInterfaceOrientation)activeInterfaceOrientation { return overrideOrientation ? UIInterfaceOrientationPortrait : %orig; } %end %end -%ctor -{ - IF_SPRINGBOARD - { - Class c = %c(SBMainWorkspace) ?: %c(SBWorkspace); - %init(hooks, SB_WORKSPACE_CLASS=c); +%ctor { + IF_NOT_SPRINGBOARD { + return; } + Class c = %c(SBMainWorkspace) ?: %c(SBWorkspace); + %init(hooks, SB_WORKSPACE_CLASS=c); } diff --git a/Reachability/UIKit.xm b/Reachability/UIKit.xm index b0fa171..dab3950 100644 --- a/Reachability/UIKit.xm +++ b/Reachability/UIKit.xm @@ -4,16 +4,13 @@ BOOL allowClosingReachabilityNatively = NO; %hook UIApplication -- (void)_deactivateReachability -{ - if (!allowClosingReachabilityNatively) - { +- (void)_deactivateReachability { + if (!allowClosingReachabilityNatively) { LogDebug(@"[ReachApp] attempting to close reachability but not allowed to."); return; } - if ([RAMessagingClient.sharedInstance isBeingHosted]) - { + if ([RAMessagingClient.sharedInstance isBeingHosted]) { LogDebug(@"[ReachApp] stopping reachability from closing because hosted"); return; } diff --git a/SKBounceAnimation.h b/SKBounceAnimation.h index c8d030c..e8a9b65 100644 --- a/SKBounceAnimation.h +++ b/SKBounceAnimation.h @@ -25,7 +25,7 @@ extern SKBounceAnimationStiffness SKBounceAnimationStiffnessHeavy; @property (nonatomic, assign) BOOL shake; //if shaking, set fromValue to the furthest value, and toValue to the current value @property (nonatomic, assign) SKBounceAnimationStiffness stiffness; -+ (SKBounceAnimation*) animationWithKeyPath:(NSString*)keyPath; ++ (SKBounceAnimation*)animationWithKeyPath:(NSString*)keyPath; -@end \ No newline at end of file +@end diff --git a/SpringBoard.xm b/SpringBoard.xm index df52c12..4f9b4ff 100644 --- a/SpringBoard.xm +++ b/SpringBoard.xm @@ -21,23 +21,19 @@ extern BOOL overrideDisableForStatusBar; %hook SBUIController -- (_Bool)clickedMenuButton -{ - if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) - { +- (_Bool)clickedMenuButton { + if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) { [[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver]; return YES; } - if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) - { + if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) { overrideDisableForStatusBar = NO; [[%c(SBReachabilityManager) sharedInstance] _handleReachabilityDeactivated]; return YES; } - if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) - { + if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) { [[%c(RAMissionControlManager) sharedInstance] hideMissionControl:YES]; return YES; } @@ -45,23 +41,19 @@ extern BOOL overrideDisableForStatusBar; return %orig; } -- (BOOL)handleHomeButtonSinglePressUp -{ - if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) - { +- (BOOL)handleHomeButtonSinglePressUp { + if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) { [[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver]; return YES; } - if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) - { + if ([RASettings.sharedInstance homeButtonClosesReachability] && [GET_SBWORKSPACE isUsingReachApp] && ((SBReachabilityManager*)[%c(SBReachabilityManager) sharedInstance]).reachabilityModeActive) { overrideDisableForStatusBar = NO; [[%c(SBReachabilityManager) sharedInstance] _handleReachabilityDeactivated]; return YES; } - if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) - { + if ([[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl]) { [[%c(RAMissionControlManager) sharedInstance] hideMissionControl:YES]; return YES; } @@ -85,16 +77,14 @@ extern BOOL overrideDisableForStatusBar; }*/ // This should help fix the problems where closing an app with Tage or the iPad Gesture would cause the app to suspend(?) and lock up the device. -- (void)_suspendGestureBegan -{ +- (void)_suspendGestureBegan { %orig; [UIApplication.sharedApplication._accessibilityFrontMostApplication clearDeactivationSettings]; } %end %hook SpringBoard --(void) _performDeferredLaunchWork -{ +- (void)_performDeferredLaunchWork { %orig; [RADesktopManager sharedInstance]; // load desktop (and previous windows!) @@ -105,12 +95,12 @@ extern BOOL overrideDisableForStatusBar; %end %hook SBApplicationController -%new -(SBApplication*) RA_applicationWithBundleIdentifier:(__unsafe_unretained NSString*)bundleIdentifier -{ - if ([self respondsToSelector:@selector(applicationWithBundleIdentifier:)]) - return [self applicationWithBundleIdentifier:bundleIdentifier]; - else if ([self respondsToSelector:@selector(applicationWithDisplayIdentifier:)]) - return [self applicationWithDisplayIdentifier:bundleIdentifier]; +%new - (SBApplication*)RA_applicationWithBundleIdentifier:(__unsafe_unretained NSString*)bundleIdentifier { + if ([self respondsToSelector:@selector(applicationWithBundleIdentifier:)]) { + return [self applicationWithBundleIdentifier:bundleIdentifier]; + } else if ([self respondsToSelector:@selector(applicationWithDisplayIdentifier:)]) { + return [self applicationWithDisplayIdentifier:bundleIdentifier]; + } [RACompatibilitySystem showWarning:@"Unable to find valid -[SBApplicationController applicationWithBundleIdentifier:] replacement"]; return nil; @@ -118,16 +108,15 @@ extern BOOL overrideDisableForStatusBar; %end %hook SBToAppsWorkspaceTransaction -- (void)_willBegin -{ +- (void)_willBegin { @autoreleasepool { NSArray *apps = nil; - if ([self respondsToSelector:@selector(toApplications)]) - apps = [self toApplications]; - else - apps = [MSHookIvar(self, "_toApplications") copy]; - for (SBApplication *app in apps) - { + if ([self respondsToSelector:@selector(toApplications)]) { + apps = [self toApplications]; + } else { + apps = [MSHookIvar(self, "_toApplications") copy]; + } + for (SBApplication *app in apps) { dispatch_async(dispatch_get_main_queue(), ^{ [RADesktopManager.sharedInstance removeAppWithIdentifier:app.bundleIdentifier animated:NO forceImmediateUnload:YES]; }); @@ -138,14 +127,14 @@ extern BOOL overrideDisableForStatusBar; // On iOS 8.3 and above, on the iPad, if a FBWindowContextWhatever creates a hosting context / enabled hosting, all the other hosted windows stop. // This fixes that. --(void)_didComplete -{ +- (void)_didComplete { %orig; // can't hurt to check all devices - especially if it changes/has changed to include phones. // however this was presumably done in preparation for the iOS 9 multitasking - if (IS_IPAD) + if (IS_IPAD) { [RAHostedAppView iPad_iOS83_fixHosting]; + } } %end @@ -163,16 +152,14 @@ extern BOOL overrideDisableForStatusBar; */ %hook SpringBoard --(void)noteInterfaceOrientationChanged:(int)arg1 duration:(float)arg2 -{ +- (void)noteInterfaceOrientationChanged:(int)arg1 duration:(float)arg2 { %orig; [RASnapshotProvider.sharedInstance forceReloadEverything]; } %end %hook SBApplication -- (void)didActivateWithTransactionID:(unsigned long long)arg1 -{ +- (void)didActivateWithTransactionID:(unsigned long long)arg1 { dispatch_async(dispatch_get_main_queue(), ^{ [RASnapshotProvider.sharedInstance forceReloadOfSnapshotForIdentifier:self.bundleIdentifier]; }); @@ -182,29 +169,27 @@ extern BOOL overrideDisableForStatusBar; %end %hook SBLockScreenManager -- (void)_postLockCompletedNotification:(_Bool)arg1 -{ +- (void)_postLockCompletedNotification:(_Bool)arg1 { %orig; - if (arg1) - { - if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) - [[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver]; + if (arg1) { + if ([[%c(RASwipeOverManager) sharedInstance] isUsingSwipeOver]) { + [[%c(RASwipeOverManager) sharedInstance] stopUsingSwipeOver]; + } } } %end %hook UIScreen -%new -(CGRect) RA_interfaceOrientedBounds -{ - if ([self respondsToSelector:@selector(_interfaceOrientedBounds)]) - return [self _interfaceOrientedBounds]; +%new - (CGRect)RA_interfaceOrientedBounds { + if ([self respondsToSelector:@selector(_interfaceOrientedBounds)]) { + return [self _interfaceOrientedBounds]; + } return [self bounds]; } %end -void respring_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) -{ +void respring_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { if (IS_IOS_OR_NEWER(iOS_9_3)) { SBSRelaunchAction *restartAction = [%c(SBSRelaunchAction) actionWithReason:@"RestartRenderServer" options:SBSRelaunchOptionsFadeToBlack targetURL:nil]; [[%c(FBSSystemService) sharedService] sendActions:[NSSet setWithObject:restartAction] withResult:nil]; @@ -213,19 +198,17 @@ void respring_notification(CFNotificationCenterRef center, void *observer, CFStr } } -void reset_settings_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) -{ +void reset_settings_notification(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { [RASettings.sharedInstance resetSettings]; } -%ctor -{ - IF_SPRINGBOARD - { - %init; - LOAD_ASPHALEIA; - - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &respring_notification, CFSTR("com.efrederickson.reachapp.respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reset_settings_notification, CFSTR("com.efrederickson.reachapp.resetSettings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); +%ctor { + IF_NOT_SPRINGBOARD { + return; } + %init; + LOAD_ASPHALEIA; + + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &respring_notification, CFSTR("com.efrederickson.reachapp.respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &reset_settings_notification, CFSTR("com.efrederickson.reachapp.resetSettings"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); } diff --git a/SwipeOver/RASwipeOverManager.h b/SwipeOver/RASwipeOverManager.h index 0524fe0..5fae0af 100644 --- a/SwipeOver/RASwipeOverManager.h +++ b/SwipeOver/RASwipeOverManager.h @@ -4,22 +4,22 @@ NSString *currentAppIdentifier; BOOL isUsingSwipeOver; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(void) startUsingSwipeOver; --(void) stopUsingSwipeOver; --(BOOL) isUsingSwipeOver; +- (void)startUsingSwipeOver; +- (void)stopUsingSwipeOver; +- (BOOL)isUsingSwipeOver; --(void) createEdgeView; +- (void)createEdgeView; --(void) showApp:(NSString*)identifier; // if identifier is nil it will use the app switcher data --(void) closeCurrentView; // App or selector --(void) showAppSelector; // No widget chooser, not enough horizontal space. TODO: make it work anyway +- (void)showApp:(NSString*)identifier; // if identifier is nil it will use the app switcher data +- (void)closeCurrentView; // App or selector +- (void)showAppSelector; // No widget chooser, not enough horizontal space. TODO: make it work anyway --(BOOL) isEdgeViewShowing; --(void) convertSwipeOverViewToSideBySide; +- (BOOL)isEdgeViewShowing; +- (void)convertSwipeOverViewToSideBySide; --(void) sizeViewForTranslation:(CGPoint)translation state:(UIGestureRecognizerState)state; +- (void)sizeViewForTranslation:(CGPoint)translation state:(UIGestureRecognizerState)state; @end #define RASWIPEOVER_VIEW_TAG 996 diff --git a/SwipeOver/RASwipeOverManager.xm b/SwipeOver/RASwipeOverManager.xm index 18f7d37..bccbd10 100644 --- a/SwipeOver/RASwipeOverManager.xm +++ b/SwipeOver/RASwipeOverManager.xm @@ -26,17 +26,23 @@ extern int rotationDegsForOrientation(int o); @end @implementation RASwipeOverManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE(RASwipeOverManager); } --(BOOL) isUsingSwipeOver { return isUsingSwipeOver; } --(void) showAppSelector { [overlayWindow showAppSelector]; } --(BOOL) isEdgeViewShowing { return overlayWindow.frame.origin.x < SCREEN_WIDTH; } +- (BOOL)isUsingSwipeOver { + return isUsingSwipeOver; +} + +- (void)showAppSelector { + [overlayWindow showAppSelector]; +} + +- (BOOL)isEdgeViewShowing { + return overlayWindow.frame.origin.x < SCREEN_WIDTH; +} --(void) startUsingSwipeOver -{ +- (void)startUsingSwipeOver { start = 0; isUsingSwipeOver = YES; currentAppIdentifier = [[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; @@ -46,11 +52,9 @@ extern int rotationDegsForOrientation(int o); [%c(RAOrientationLocker) lockOrientation]; } --(void) stopUsingSwipeOver -{ +- (void)stopUsingSwipeOver { [overlayWindow removeOverlayFromUnderlyingAppImmediately]; - if (currentAppIdentifier) - { + if (currentAppIdentifier) { [[%c(RAMessagingServer) sharedInstance] endResizingApp:currentAppIdentifier completion:nil]; [[%c(RAMessagingServer) sharedInstance] setShouldUseExternalKeyboard:YES forApp:currentAppIdentifier completion:nil]; } @@ -61,8 +65,7 @@ extern int rotationDegsForOrientation(int o); currentAppIdentifier = nil; CGRect newFrame = overlayWindow.frame; - switch ([UIApplication.sharedApplication statusBarOrientation]) - { + switch ([UIApplication.sharedApplication statusBarOrientation]) { case UIInterfaceOrientationPortrait: newFrame = (CGRect) { { newFrame.origin.x + newFrame.size.height, newFrame.origin.y }, newFrame.size }; case UIInterfaceOrientationPortraitUpsideDown: @@ -74,9 +77,9 @@ extern int rotationDegsForOrientation(int o); } [UIView animateWithDuration:0.3 animations:^{ - if ([[overlayWindow currentView] isKindOfClass:[%c(RAHostedAppView) class]]) + if ([[overlayWindow currentView] isKindOfClass:[%c(RAHostedAppView) class]]) { [((RAHostedAppView*)overlayWindow.currentView) viewWithTag:9903553].alpha = 0; - + } overlayWindow.frame = newFrame; } completion:^(BOOL _) { [self closeCurrentView]; @@ -86,11 +89,11 @@ extern int rotationDegsForOrientation(int o); }]; } --(void) createEdgeView -{ +- (void)createEdgeView { overlayWindow = [[RASwipeOverOverlay alloc] initWithFrame:UIScreen.mainScreen.RA_interfaceOrientedBounds]; - if (IS_IOS_OR_OLDER(iOS_8_4)) + if (IS_IOS_OR_OLDER(iOS_8_4)) { [overlayWindow _rotateWindowToOrientation:UIApplication.sharedApplication.statusBarOrientation updateStatusBar:YES duration:0.001 skipCallbacks:NO]; + } [overlayWindow showEnoughToDarkenUnderlyingApp]; [overlayWindow makeKeyAndVisible]; [overlayWindow updateForOrientation:UIApplication.sharedApplication.statusBarOrientation]; @@ -98,24 +101,20 @@ extern int rotationDegsForOrientation(int o); [self showApp:nil]; } --(void) showApp:(NSString*)identifier -{ +- (void)showApp:(NSString*)identifier { [self closeCurrentView]; SBApplication *app = nil; FBScene *scene = nil; - if (identifier) + if (identifier) { app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:identifier]; - else - { + } else { NSMutableArray *bundleIdentifiers = [[%c(RAAppSwitcherModelWrapper) appSwitcherAppIdentiferList] mutableCopy]; - while (!scene && bundleIdentifiers.count > 0) - { + while (!scene && bundleIdentifiers.count > 0) { identifier = bundleIdentifiers[0]; - if ([identifier isEqual:currentAppIdentifier]) - { + if ([identifier isEqual:currentAppIdentifier]) { [bundleIdentifiers removeObjectAtIndex:0]; continue; } @@ -125,20 +124,22 @@ extern int rotationDegsForOrientation(int o); } } - if (app) - { + if (app) { SBDisplayLayout *layout = [%c(SBDisplayLayout) fullScreenDisplayLayoutForApplication:app]; - if (layout) + if (layout) { [[%c(SBAppSwitcherModel) sharedInstance] addToFront:layout]; + } } - if (!identifier || identifier.length == 0) + if (!identifier || identifier.length == 0) { return; + } RAHostedAppView *view = [[%c(RAHostedAppView) alloc] initWithBundleIdentifier:identifier]; view.autosizesApp = NO; - if (!overlayWindow.isHidingUnderlyingApp) + if (!overlayWindow.isHidingUnderlyingApp) { view.autosizesApp = YES; + } view.shouldUseExternalKeyboard = YES; view.allowHidingStatusBar = NO; view.frame = UIScreen.mainScreen._referenceBounds; @@ -158,10 +159,9 @@ extern int rotationDegsForOrientation(int o); detachView.tag = 9903553; [view addSubview:detachView]; - if (!overlayWindow.isHidingUnderlyingApp) // side-by-side + if (!overlayWindow.isHidingUnderlyingApp) { // side-by-side view.frame = CGRectMake(10, 0, view.frame.size.width, view.frame.size.height); - else // overlay - { + } else { // overlay view.frame = CGRectMake(SCREEN_WIDTH - 50, 0, view.frame.size.width, view.frame.size.height); CGFloat scale = 0.1; // MIN(MAX(scale, 0.1), 0.98); @@ -175,26 +175,21 @@ extern int rotationDegsForOrientation(int o); [self updateClientSizes:YES]; } --(void) closeCurrentView -{ - if ([[overlayWindow currentView] isKindOfClass:[%c(RAHostedAppView) class]]) - { +- (void)closeCurrentView { + if ([[overlayWindow currentView] isKindOfClass:[%c(RAHostedAppView) class]]) { ((RAHostedAppView*)overlayWindow.currentView).shouldUseExternalKeyboard = NO; [((RAHostedAppView*)overlayWindow.currentView) unloadApp]; } [[overlayWindow currentView] removeFromSuperview]; } --(void) convertSwipeOverViewToSideBySide -{ - if (!currentAppIdentifier || [[%c(SBReachabilityManager) sharedInstance] reachabilityModeActive]) - { +- (void)convertSwipeOverViewToSideBySide { + if (!currentAppIdentifier || [[%c(SBReachabilityManager) sharedInstance] reachabilityModeActive]) { [self stopUsingSwipeOver]; return; } - if (UIApplication.sharedApplication.statusBarOrientation != UIInterfaceOrientationPortrait) - { + if (UIApplication.sharedApplication.statusBarOrientation != UIInterfaceOrientationPortrait) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"MULTIPLEXER") message:@"Sorry, SwipeOver's side-by-side mode is not currently compatible with landscape." preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; [alert show]; @@ -203,8 +198,9 @@ extern int rotationDegsForOrientation(int o); [[%c(RAMessagingServer) sharedInstance] setShouldUseExternalKeyboard:YES forApp:currentAppIdentifier completion:nil]; - if ([[overlayWindow currentView] isKindOfClass:[%c(RAHostedAppView) class]]) + if ([[overlayWindow currentView] isKindOfClass:[%c(RAHostedAppView) class]]) { ((RAHostedAppView*)[overlayWindow currentView]).autosizesApp = YES; + } [overlayWindow currentView].transform = CGAffineTransformIdentity; [overlayWindow removeOverlayFromUnderlyingApp]; [overlayWindow currentView].frame = (CGRect) { { 10, 0 }, [overlayWindow currentView].frame.size }; @@ -213,8 +209,7 @@ extern int rotationDegsForOrientation(int o); [self updateClientSizes:YES]; } --(void) detachViewAndCloseSwipeOver -{ +- (void)detachViewAndCloseSwipeOver { SBApplication *app = ((RAHostedAppView*)overlayWindow.currentView).app; [self stopUsingSwipeOver]; @@ -222,57 +217,49 @@ extern int rotationDegsForOrientation(int o); [desktop createAppWindowForSBApplication:app animated:YES]; } --(void) updateClientSizes:(BOOL)reloadAppSelectorSizeNow -{ - if (currentAppIdentifier && !overlayWindow.isHidingUnderlyingApp) - { +- (void)updateClientSizes:(BOOL)reloadAppSelectorSizeNow { + if (currentAppIdentifier && !overlayWindow.isHidingUnderlyingApp) { CGFloat underWidth = [overlayWindow isHidingUnderlyingApp] ? -1 : overlayWindow.frame.origin.x; [[%c(RAMessagingServer) sharedInstance] resizeApp:currentAppIdentifier toSize:CGSizeMake(underWidth, -1) completion:nil]; } - if (overlayWindow.isShowingAppSelector && reloadAppSelectorSizeNow) + if (overlayWindow.isShowingAppSelector && reloadAppSelectorSizeNow) { [self showAppSelector]; - else if (!overlayWindow.isHidingUnderlyingApp) // Update swiped-over app in side-by-side mode. RAHostedAppView takes care of the app sizing if we resize the RAHostedAppView. - { + } else if (!overlayWindow.isHidingUnderlyingApp) { // Update swiped-over app in side-by-side mode. RAHostedAppView takes care of the app sizing if we resize the RAHostedAppView. overlayWindow.currentView.frame = CGRectMake(10, 0, SCREEN_WIDTH - overlayWindow.frame.origin.x - 10, overlayWindow.currentView.frame.size.height); } } --(void) sizeViewForTranslation:(CGPoint)translation state:(UIGestureRecognizerState)state -{ +- (void)sizeViewForTranslation:(CGPoint)translation state:(UIGestureRecognizerState)state { static CGFloat lastX = -1; static CGFloat overlayOriginX = -1; UIView *targetView = [overlayWindow isHidingUnderlyingApp] ? [overlayWindow viewWithTag:RASWIPEOVER_VIEW_TAG] : overlayWindow; - if (start == 0) + if (start == 0) { start = targetView.center.x; + } - if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled || state == UIGestureRecognizerStateFailed) - { + if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled || state == UIGestureRecognizerStateFailed) { lastX = -1; start = 0; overlayOriginX = -1; CGFloat scale = (SCREEN_WIDTH - targetView.frame.origin.x) / [overlayWindow currentView].bounds.size.width; - if (scale <= 0.12 && (!CGPointEqualToPoint(translation, CGPointZero))) - { + if (scale <= 0.12 && (!CGPointEqualToPoint(translation, CGPointZero))) { [self stopUsingSwipeOver]; return; } - } - else - { + } else { //if (start + translation.x + (targetView.frame.size.width / 2) < UIScreen.mainScreen.bounds.size.width && [overlayWindow isHidingUnderlyingApp]) // return; //if (start + translation.x + targetView.frame.size.width - (targetView.frame.size.width / 2) < 0 && [overlayWindow isHidingUnderlyingApp] == NO) // return; - if (overlayWindow.isHidingUnderlyingApp) - { - if (![[overlayWindow currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) - { - if (lastX == -1) + if (overlayWindow.isHidingUnderlyingApp) { + if (![[overlayWindow currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) { + if (lastX == -1) { lastX = translation.x; + } CGFloat newScale = (lastX - translation.x) / SCREEN_WIDTH; lastX = translation.x; @@ -293,11 +280,10 @@ extern int rotationDegsForOrientation(int o); //targetView.transform = CGAffineTransformMakeScale(scale, scale); //targetView.center = (CGPoint) { SCREEN_WIDTH - (targetView.frame.size.width / 2), targetView.center.y }; } - } - else - { - if (overlayOriginX == -1) + } else { + if (overlayOriginX == -1) { overlayOriginX = overlayWindow.frame.origin.x; + } overlayWindow.frame = CGRectMake(overlayOriginX + translation.x, overlayWindow.frame.origin.y, SCREEN_WIDTH - (overlayOriginX + translation.x), overlayWindow.frame.size.height); //targetView.frame = CGRectMake(SCREEN_WIDTH - (start + translation.x), 0, SCREEN_WIDTH - (SCREEN_WIDTH - start + translation.x), targetView.frame.size.height); targetView.center = (CGPoint) { start + translation.x, targetView.center.y }; diff --git a/SwipeOver/RASwipeOverOverlay.h b/SwipeOver/RASwipeOverOverlay.h index 5a05f7a..a264462 100644 --- a/SwipeOver/RASwipeOverOverlay.h +++ b/SwipeOver/RASwipeOverOverlay.h @@ -4,17 +4,17 @@ @interface RASwipeOverOverlay : UIAutoRotatingWindow { BOOL isHidingUnderlyingApp; - UIView *darkenerView; + UIVisualEffectView *darkenerView; } @property (nonatomic, retain) UIView *grabberView; --(BOOL) isHidingUnderlyingApp; --(void) showEnoughToDarkenUnderlyingApp; --(void) removeOverlayFromUnderlyingApp; --(void) removeOverlayFromUnderlyingAppImmediately; +- (BOOL)isHidingUnderlyingApp; +- (void)showEnoughToDarkenUnderlyingApp; +- (void)removeOverlayFromUnderlyingApp; +- (void)removeOverlayFromUnderlyingAppImmediately; --(BOOL) isShowingAppSelector; --(void) showAppSelector; +- (BOOL)isShowingAppSelector; +- (void)showAppSelector; --(UIView*) currentView; +- (UIView*)currentView; @end diff --git a/SwipeOver/RASwipeOverOverlay.xm b/SwipeOver/RASwipeOverOverlay.xm index f07ff18..263f350 100644 --- a/SwipeOver/RASwipeOverOverlay.xm +++ b/SwipeOver/RASwipeOverOverlay.xm @@ -4,10 +4,8 @@ @implementation RASwipeOverOverlay @synthesize grabberView; --(instancetype) initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) - { +- (instancetype)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { //self.backgroundColor = [UIColor blueColor]; //self.alpha = 0.4; self.windowLevel = UIWindowLevelStatusBar + 1; @@ -31,29 +29,31 @@ return self; } --(BOOL) isHidingUnderlyingApp { return isHidingUnderlyingApp; } +- (BOOL)isHidingUnderlyingApp { + return isHidingUnderlyingApp; +} --(void) showEnoughToDarkenUnderlyingApp -{ - if (isHidingUnderlyingApp) +- (void)showEnoughToDarkenUnderlyingApp { + if (isHidingUnderlyingApp) { return; + } isHidingUnderlyingApp = YES; // TODO: use UIBlurEffect? - darkenerView = [[UIView alloc] initWithFrame:self.frame]; - darkenerView.backgroundColor = [UIColor blackColor]; - darkenerView.alpha = 0.35; - darkenerView.userInteractionEnabled = YES; + UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; + darkenerView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; + darkenerView.frame = self.frame; + darkenerView.alpha = 0.85; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(darkenerViewTap:)]; [darkenerView addGestureRecognizer:tap]; [self addSubview:darkenerView]; grabberView.hidden = YES; } --(void) removeOverlayFromUnderlyingApp -{ - if (!isHidingUnderlyingApp) +- (void)removeOverlayFromUnderlyingApp { + if (!isHidingUnderlyingApp) { return; + } isHidingUnderlyingApp = NO; [UIView animateWithDuration:0.3 animations:^{ @@ -65,47 +65,40 @@ }]; } --(void) removeOverlayFromUnderlyingAppImmediately -{ - if (!isHidingUnderlyingApp) +- (void)removeOverlayFromUnderlyingAppImmediately { + if (!isHidingUnderlyingApp) { return; + } isHidingUnderlyingApp = NO; [darkenerView removeFromSuperview]; darkenerView = nil; } --(void) showAppSelector -{ +- (void)showAppSelector { [self longPress:nil]; } --(UIView*) currentView -{ +- (UIView*)currentView { return [self viewWithTag:RASWIPEOVER_VIEW_TAG]; } --(BOOL) isShowingAppSelector -{ +- (BOOL)isShowingAppSelector { return [[self currentView] isKindOfClass:[%c(RAAppSelectorView) class]]; } --(void) darkenerViewTap:(UITapGestureRecognizer*)gesture -{ +- (void)darkenerViewTap:(UITapGestureRecognizer*)gesture { [RASwipeOverManager.sharedInstance convertSwipeOverViewToSideBySide]; } --(void) handlePan:(UIPanGestureRecognizer*)gesture -{ +- (void)handlePan:(UIPanGestureRecognizer*)gesture { CGPoint newPoint = [gesture translationInView:gesture.view]; [RASwipeOverManager.sharedInstance sizeViewForTranslation:newPoint state:gesture.state]; } --(void) longPress:(UILongPressGestureRecognizer*)gesture -{ +- (void)longPress:(UILongPressGestureRecognizer*)gesture { [RASwipeOverManager.sharedInstance closeCurrentView]; - if ([[self currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) - { + if ([[self currentView] isKindOfClass:[%c(RAAppSelectorView) class]]) { [(RAAppSelectorView*)[self currentView] relayoutApps]; [self currentView].frame = CGRectMake(isHidingUnderlyingApp ? 0 : 10, 0, self.frame.size.width - (isHidingUnderlyingApp ? 0 : 10), self.frame.size.height); return; @@ -117,20 +110,20 @@ [self addSubview:appSelector]; } --(void) appSelector:(RAAppSelectorView*)view appWasSelected:(NSString*)bundleIdentifier -{ +- (void)appSelector:(RAAppSelectorView*)view appWasSelected:(NSString*)bundleIdentifier { grabberView.alpha = 1; [[self currentView] removeFromSuperview]; [RASwipeOverManager.sharedInstance showApp:bundleIdentifier]; } -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer -{ +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { UIView *v = [self viewWithTag:RASWIPEOVER_VIEW_TAG]; - if ([v isKindOfClass:[%c(RAAppSelectorView) class]]) + if ([v isKindOfClass:[%c(RAAppSelectorView) class]]) { return NO; - if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) + } + if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) { return NO; + } return YES; } @end diff --git a/SwipeOver/SwipeOverGesture.xm b/SwipeOver/SwipeOverGesture.xm index ae78cf1..4f9ec5f 100644 --- a/SwipeOver/SwipeOverGesture.xm +++ b/SwipeOver/SwipeOverGesture.xm @@ -16,95 +16,90 @@ NSDate *lastTouch; CGPoint startingPoint; BOOL firstSwipe = NO; -CGRect adjustFrameForRotation() -{ +CGRect adjustFrameForRotation() { CGFloat portraitWidth = 30; CGFloat portraitHeight = 50; CGFloat width = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width; CGFloat height = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height; - switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) - { - case UIInterfaceOrientationPortrait: - LogDebug(@"[ReachApp] portrait"); - return (CGRect){ { width - portraitWidth + 5, (height - portraitHeight) / 2 }, { portraitWidth, portraitHeight } }; - case UIInterfaceOrientationPortraitUpsideDown: - LogDebug(@"[ReachApp] portrait upside down"); - return (CGRect){ { 0, 0}, { 50, 50 } }; - case UIInterfaceOrientationLandscapeLeft: - LogDebug(@"[ReachApp] landscape left"); - return (CGRect){ { ((width - portraitWidth) / 2), -(portraitWidth / 2) }, { portraitWidth, portraitHeight } }; - case UIInterfaceOrientationLandscapeRight: - LogDebug(@"[ReachApp] landscape right"); - return (CGRect){ { (height - portraitHeight) / 2, width - portraitWidth - 5 }, { portraitWidth, portraitHeight } }; + switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) { + case UIInterfaceOrientationPortrait: { + LogDebug(@"[ReachApp] portrait"); + return (CGRect){ { width - portraitWidth + 5, (height - portraitHeight) / 2 }, { portraitWidth, portraitHeight } }; + } + case UIInterfaceOrientationPortraitUpsideDown: { + LogDebug(@"[ReachApp] portrait upside down"); + return (CGRect){ { 0, 0}, { 50, 50 } }; + } + case UIInterfaceOrientationLandscapeLeft: { + LogDebug(@"[ReachApp] landscape left"); + return (CGRect){ { ((width - portraitWidth) / 2), -(portraitWidth / 2) }, { portraitWidth, portraitHeight } }; + } + case UIInterfaceOrientationLandscapeRight: { + LogDebug(@"[ReachApp] landscape right"); + return (CGRect){ { (height - portraitHeight) / 2, width - portraitWidth - 5 }, { portraitWidth, portraitHeight } }; + } } return CGRectZero; } -CGPoint adjustCenterForOffscreenSlide(CGPoint center) -{ +CGPoint adjustCenterForOffscreenSlide(CGPoint center) { CGFloat portraitWidth = 30; //CGFloat portraitHeight = 50; - switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) - { + switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) { case UIInterfaceOrientationPortrait: - return (CGPoint) { center.x + portraitWidth, center.y }; + return (CGPoint) { center.x + portraitWidth, center.y }; case UIInterfaceOrientationPortraitUpsideDown: - return (CGPoint) { center.x - portraitWidth, center.y }; + return (CGPoint) { center.x - portraitWidth, center.y }; case UIInterfaceOrientationLandscapeLeft: - return (CGPoint) { center.x, center.y - portraitWidth }; + return (CGPoint) { center.x, center.y - portraitWidth }; case UIInterfaceOrientationLandscapeRight: - return (CGPoint) { center.x, center.y + portraitWidth }; + return (CGPoint) { center.x, center.y + portraitWidth }; } return CGPointZero; } -CGAffineTransform adjustTransformRotation() -{ - switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) - { +CGAffineTransform adjustTransformRotation() { + switch ([[UIApplication.sharedApplication _accessibilityFrontMostApplication] statusBarOrientation]) { case UIInterfaceOrientationPortrait: - return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0)); + return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0)); case UIInterfaceOrientationPortraitUpsideDown: - return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180)); + return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180)); case UIInterfaceOrientationLandscapeLeft: - return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90)); + return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90)); case UIInterfaceOrientationLandscapeRight: - return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90)); + return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90)); } return CGAffineTransformIdentity; } -BOOL swipeOverLocationIsInValidArea(CGFloat y) -{ - if (y == 0) return YES; // more than likely, UIGestureRecognizerStateEnded +BOOL swipeOverLocationIsInValidArea(CGFloat y) { + if (y == 0) { + return YES; // more than likely, UIGestureRecognizerStateEnded + } - switch ([[%c(RASettings) sharedInstance] swipeOverGrabArea]) - { + switch ([[%c(RASettings) sharedInstance] swipeOverGrabArea]) { case RAGrabAreaSideAnywhere: - return YES; + return YES; case RAGrabAreaSideTopThird: - return y <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0; + return y <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0; case RAGrabAreaSideMiddleThird: - return y >= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0 && y <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0) * 2; + return y >= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0 && y <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0) * 2; case RAGrabAreaSideBottomThird: - return y >= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0) * 2; + return y >= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 3.0) * 2; default: - return NO; + return NO; } } -%ctor -{ +%ctor { [[%c(RAGestureManager) sharedInstance] addGestureRecognizer:^RAGestureCallbackResult(UIGestureRecognizerState state, CGPoint location, CGPoint velocity) { lastTouch = [NSDate date]; - if ([%c(Multiplexer) shouldShowControlCenterGrabberOnFirstSwipe] || [[%c(RASettings) sharedInstance] alwaysShowSOGrabber]) - { - if (!isShowingGrabber && !isPastGrabber) - { + if ([%c(Multiplexer) shouldShowControlCenterGrabberOnFirstSwipe] || [[%c(RASettings) sharedInstance] alwaysShowSOGrabber]) { + if (!isShowingGrabber && !isPastGrabber) { firstSwipe = YES; isShowingGrabber = YES; @@ -128,8 +123,7 @@ BOOL swipeOverLocationIsInValidArea(CGFloat y) [[[%c(RAHostManager) systemHostViewForApplication:UIApplication.sharedApplication._accessibilityFrontMostApplication] superview] addSubview:grabberView]; static void (^dismisser)() = ^{ // top kek, needs "static" so it's not a local, self-retaining block - if ([[NSDate date] timeIntervalSinceDate:lastTouch] > 2) - { + if ([[NSDate date] timeIntervalSinceDate:lastTouch] > 2) { [UIView animateWithDuration:0.2 animations:^{ //grabberView.frame = CGRectOffset(grabberView.frame, 40, 0); grabberView.center = adjustCenterForOffscreenSlide(grabberView.center); @@ -139,9 +133,7 @@ BOOL swipeOverLocationIsInValidArea(CGFloat y) isShowingGrabber = NO; isPastGrabber = NO; }]; - } - else if (grabberView) // left there - { + } else if (grabberView) { // left there dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ dismisser(); }); @@ -150,18 +142,15 @@ BOOL swipeOverLocationIsInValidArea(CGFloat y) dismisser(); return RAGestureCallbackResultSuccess; - } - else if (CGRectContainsPoint(grabberView.frame, location) || (isShowingGrabber && !firstSwipe && [[%c(RASettings) sharedInstance] swipeOverGrabArea] != RAGrabAreaSideAnywhere && [[%c(RASettings) sharedInstance] swipeOverGrabArea] != RAGrabAreaSideMiddleThird)) - { + } else if (CGRectContainsPoint(grabberView.frame, location) || (isShowingGrabber && !firstSwipe && [[%c(RASettings) sharedInstance] swipeOverGrabArea] != RAGrabAreaSideAnywhere && [[%c(RASettings) sharedInstance] swipeOverGrabArea] != RAGrabAreaSideMiddleThird)) { [grabberView removeFromSuperview]; grabberView = nil; isShowingGrabber = NO; isPastGrabber = YES; - } - else if (!isPastGrabber) - { - if (state == UIGestureRecognizerStateEnded) + } else if (!isPastGrabber) { + if (state == UIGestureRecognizerStateEnded) { firstSwipe = NO; + } startingPoint = CGPointZero; isPastGrabber = NO; return RAGestureCallbackResultSuccess; @@ -170,33 +159,37 @@ BOOL swipeOverLocationIsInValidArea(CGFloat y) CGPoint translation; switch (state) { - case UIGestureRecognizerStateBegan: + case UIGestureRecognizerStateBegan: { startingPoint = location; break; - case UIGestureRecognizerStateChanged: + } + case UIGestureRecognizerStateChanged: { translation = CGPointMake(location.x - startingPoint.x, location.y - startingPoint.y); break; - case UIGestureRecognizerStateEnded: + } + case UIGestureRecognizerStateEnded: { startingPoint = CGPointZero; isPastGrabber = NO; break; + } } - if (![RASwipeOverManager.sharedInstance isUsingSwipeOver]) + if (![RASwipeOverManager.sharedInstance isUsingSwipeOver]) { [RASwipeOverManager.sharedInstance startUsingSwipeOver]; + } //if (state == UIGestureRecognizerStateChanged) - [RASwipeOverManager.sharedInstance sizeViewForTranslation:translation state:state]; + [RASwipeOverManager.sharedInstance sizeViewForTranslation:translation state:state]; return RAGestureCallbackResultSuccess; } withCondition:^BOOL(CGPoint location, CGPoint velocity) { - if ([[%c(RAKeyboardStateListener) sharedInstance] visible] && ![RASwipeOverManager.sharedInstance isUsingSwipeOver]) - { + if ([[%c(RAKeyboardStateListener) sharedInstance] visible] && ![RASwipeOverManager.sharedInstance isUsingSwipeOver]) { CGRect realKBFrame = CGRectMake(0, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height, [[%c(RAKeyboardStateListener) sharedInstance] size].width, [[%c(RAKeyboardStateListener) sharedInstance] size].height); realKBFrame = CGRectOffset(realKBFrame, 0, -realKBFrame.size.height); - if (CGRectContainsPoint(realKBFrame, location) || realKBFrame.size.height > 50) + if (CGRectContainsPoint(realKBFrame, location) || realKBFrame.size.height > 50) { return NO; + } } return [[%c(RASettings) sharedInstance] swipeOverEnabled] && ![[%c(SBLockScreenManager) sharedInstance] isUILocked] && ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing] && ![[%c(SBNotificationCenterController) sharedInstance] isVisible] && ![[%c(RAMissionControlManager) sharedInstance] isShowingMissionControl] && (swipeOverLocationIsInValidArea(location.y) || isShowingGrabber); diff --git a/Theming/RAThemeLoader.h b/Theming/RAThemeLoader.h index 59090ac..6a45f9f 100644 --- a/Theming/RAThemeLoader.h +++ b/Theming/RAThemeLoader.h @@ -1,7 +1,7 @@ #import "RATheme.h" @interface RAThemeLoader : NSObject -+(RATheme*)loadFromFile:(NSString*)baseName; ++ (RATheme*)loadFromFile:(NSString*)baseName; -+(RATheme*) themeFromDictionary:(NSDictionary*)dict; -@end \ No newline at end of file ++ (RATheme*)themeFromDictionary:(NSDictionary*)dict; +@end diff --git a/Theming/RAThemeLoader.mm b/Theming/RAThemeLoader.mm index 8dadd52..58a6c25 100644 --- a/Theming/RAThemeLoader.mm +++ b/Theming/RAThemeLoader.mm @@ -6,16 +6,14 @@ //#define COLOR(name) [UIColor RA_colorWithHexString:dict[name]] @implementation RAThemeLoader -+(RATheme*)loadFromFile:(NSString*)baseName -{ ++ (RATheme*)loadFromFile:(NSString*)baseName { NSString *fullPath = [NSString stringWithFormat:@"%@/Themes/%@.plist",RA_BASE_PATH,[[baseName lastPathComponent] stringByDeletingPathExtension]]; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:fullPath]; return [RAThemeLoader themeFromDictionary:dict]; } -+(RATheme*) themeFromDictionary:(NSDictionary*)dict -{ ++ (RATheme*)themeFromDictionary:(NSDictionary*)dict { RATheme *ret = [[RATheme alloc] init]; ret.themeIdentifier = dict[@"identifier"]; @@ -69,47 +67,50 @@ +(RATheme*) themeFromDictionary:(NSDictionary*)dict return ret; } -+(NSTextAlignment) getTextAlignment:(NSObject*)value -{ - if ([value isKindOfClass:[NSString class]]) - { - if ([value isEqual:@"NSTextAlignmentLeft"] || [value isEqual:@"0"] || [value isEqual:@"Left"]) ++ (NSTextAlignment)getTextAlignment:(NSObject*)value { + if ([value isKindOfClass:[NSString class]]) { + if ([value isEqual:@"NSTextAlignmentLeft"] || [value isEqual:@"0"] || [value isEqual:@"Left"]) { return NSTextAlignmentLeft; - if ([value isEqual:@"NSTextAlignmentCenter"] || [value isEqual:@"1"] || [value isEqual:@"Center"]) + } + if ([value isEqual:@"NSTextAlignmentCenter"] || [value isEqual:@"1"] || [value isEqual:@"Center"]) { return NSTextAlignmentCenter; - if ([value isEqual:@"NSTextAlignmentRight"] || [value isEqual:@"2"] || [value isEqual:@"Right"]) + } + if ([value isEqual:@"NSTextAlignmentRight"] || [value isEqual:@"2"] || [value isEqual:@"Right"]) { return NSTextAlignmentRight; - if ([value isEqual:@"NSTextAlignmentJustified"] || [value isEqual:@"3"] || [value isEqual:@"Justified"]) + } + if ([value isEqual:@"NSTextAlignmentJustified"] || [value isEqual:@"3"] || [value isEqual:@"Justified"]) { return NSTextAlignmentJustified; - if ([value isEqual:@"NSTextAlignmentNatural"] || [value isEqual:@"4"] || [value isEqual:@"Natural"]) + } + if ([value isEqual:@"NSTextAlignmentNatural"] || [value isEqual:@"4"] || [value isEqual:@"Natural"]) { return NSTextAlignmentNatural; - } - else if ([value isKindOfClass:[NSNumber class]]) - { + } + } else if ([value isKindOfClass:[NSNumber class]]) { int actualValue = [((NSNumber*)value) intValue]; - if (actualValue == 0) + if (actualValue == 0) { return NSTextAlignmentLeft; - else if (actualValue == 1) + } else if (actualValue == 1) { return NSTextAlignmentCenter; - else if (actualValue == 2) + } else if (actualValue == 2) { return NSTextAlignmentRight; - else if (actualValue == 3) + } else if (actualValue == 3) { return NSTextAlignmentJustified; - else if (actualValue == 4) + } else if (actualValue == 4) { return NSTextAlignmentNatural; + } } return NSTextAlignmentCenter; } -+(UIColor*) tryGetColorFromThemeImageName:(NSString*)name -{ ++ (UIColor*)tryGetColorFromThemeImageName:(NSString*)name { NSString *expandedPath = [NSString stringWithFormat:@"%@/ThemingImages/%@.png",RA_BASE_PATH,[[name lastPathComponent] stringByDeletingPathExtension]]; BOOL exists = [NSFileManager.defaultManager fileExistsAtPath:expandedPath]; - if (!exists) + if (!exists) { return nil; + } UIImage *image = [UIImage imageWithContentsOfFile:expandedPath]; - if (image) + if (image) { return [UIColor colorWithPatternImage:image]; + } return nil; } @end diff --git a/Theming/RAThemeManager.h b/Theming/RAThemeManager.h index 63abe5b..4c7f8ff 100644 --- a/Theming/RAThemeManager.h +++ b/Theming/RAThemeManager.h @@ -5,10 +5,10 @@ RATheme *currentTheme; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(RATheme*) currentTheme; --(NSArray*) allThemes; +- (RATheme*)currentTheme; +- (NSArray*)allThemes; --(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier; -@end \ No newline at end of file +- (void)invalidateCurrentThemeAndReload:(NSString*)currentIdentifier; +@end diff --git a/Theming/RAThemeManager.mm b/Theming/RAThemeManager.mm index 7146e38..105e295 100644 --- a/Theming/RAThemeManager.mm +++ b/Theming/RAThemeManager.mm @@ -4,16 +4,19 @@ #import "headers.h" @implementation RAThemeManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RAThemeManager, [sharedInstance invalidateCurrentThemeAndReload:nil]); // will be reloaded by RASettings } --(RATheme*) currentTheme { return currentTheme; } --(NSArray*) allThemes { return allThemes.allValues; } +- (RATheme*)currentTheme { + return currentTheme; +} + +- (NSArray*)allThemes { + return allThemes.allValues; +} --(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier -{ +- (void)invalidateCurrentThemeAndReload:(NSString*)currentIdentifier { #if DEBUG LogDebug(@"[ReachApp] loading themes..."); NSDate *startTime = [NSDate date]; @@ -26,26 +29,24 @@ -(void) invalidateCurrentThemeAndReload:(NSString*)currentIdentifier NSString *folderName = [NSString stringWithFormat:@"%@/Themes/", RA_BASE_PATH]; NSArray *themeFileNames = [NSFileManager.defaultManager subpathsAtPath:folderName]; - for (NSString *themeName in themeFileNames) - { - if (![themeName hasSuffix:@"plist"]) + for (NSString *themeName in themeFileNames) { + if (![themeName hasSuffix:@"plist"]) { continue; + } RATheme *theme = [RAThemeLoader loadFromFile:themeName]; - if (theme && theme.themeIdentifier) - { + if (theme && theme.themeIdentifier) { //LogDebug(@"[ReachApp] adding %@", theme.themeIdentifier); allThemes[theme.themeIdentifier] = theme; - if ([theme.themeIdentifier isEqual:currentIdentifier]) + if ([theme.themeIdentifier isEqual:currentIdentifier]) { currentTheme = theme; + } } } - if (!currentTheme) - { + if (!currentTheme) { currentTheme = [allThemes objectForKey:@"com.eljahandandrew.multiplexer.themes.default"]; - if (!currentTheme && allThemes.allKeys.count > 0) - { + if (!currentTheme && allThemes.allKeys.count > 0) { currentTheme = allThemes[allThemes.allKeys[0]]; } } diff --git a/Tweak.xm b/Tweak.xm index 3e35cf3..a909a3b 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -20,13 +20,11 @@ Any code based off of or using parts of the above projects is documented. // IS_SPRINGBOARD macro optimized from always comparing NSBundle - because it won't change in-process BOOL $__IS_SPRINGBOARD = NO; -%ctor -{ +%ctor { $__IS_SPRINGBOARD = [[NSBundle mainBundle].bundleIdentifier isEqual:@"com.apple.springboard"]; } -void SET_BACKGROUNDED(id settings, BOOL value) -{ +void SET_BACKGROUNDED(id settings, BOOL value) { #if __has_feature(objc_arc) // stupid ARC... ptrdiff_t bgOffset = ivar_getOffset(class_getInstanceVariable([settings class], "_backgrounded")); @@ -34,10 +32,11 @@ void SET_BACKGROUNDED(id settings, BOOL value) memcpy(bgPtr, &value, sizeof(value)); #else // ARC is off, easy way - if (value) + if (value) { object_setInstanceVariable(settings, "_backgrounded", (void*)YES); // strangely it doesn't like using the val, i have to do this. - else + } else { object_setInstanceVariable(settings, "_backgrounded", (void*)NO); + } #endif } diff --git a/UIAlertController+Window.m b/UIAlertController+Window.m index 8db2d6c..3a48c9c 100644 --- a/UIAlertController+Window.m +++ b/UIAlertController+Window.m @@ -20,11 +20,11 @@ @implementation UIAlertController (Private) @dynamic alertWindow; - (void)setAlertWindow:(UIWindow *)alertWindow { - objc_setAssociatedObject(self, @selector(alertWindow), alertWindow, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + objc_setAssociatedObject(self, @selector(alertWindow), alertWindow, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - (UIWindow *)alertWindow { - return objc_getAssociatedObject(self, @selector(alertWindow)); + return objc_getAssociatedObject(self, @selector(alertWindow)); } @end @@ -32,23 +32,23 @@ - (UIWindow *)alertWindow { @implementation UIAlertController (Window) - (void)show { - [self show:YES]; + [self show:YES]; } - (void)show:(BOOL)animated { - self.alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - self.alertWindow.rootViewController = [[UIViewController alloc] init]; - self.alertWindow.windowLevel = UIWindowLevelAlert + 1; - [self.alertWindow makeKeyAndVisible]; - [self.alertWindow.rootViewController presentViewController:self animated:animated completion:nil]; + self.alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + self.alertWindow.rootViewController = [[UIViewController alloc] init]; + self.alertWindow.windowLevel = UIWindowLevelAlert + 1; + [self.alertWindow makeKeyAndVisible]; + [self.alertWindow.rootViewController presentViewController:self animated:animated completion:nil]; } - (void)viewDidDisappear:(BOOL)animated { - [super viewDidDisappear:animated]; + [super viewDidDisappear:animated]; - // precaution to insure window gets destroyed - self.alertWindow.hidden = YES; - self.alertWindow = nil; + // precaution to insure window gets destroyed + self.alertWindow.hidden = YES; + self.alertWindow = nil; } @end diff --git a/UIColor+HexString.h b/UIColor+HexString.h index 20e266f..1999511 100644 --- a/UIColor+HexString.h +++ b/UIColor+HexString.h @@ -9,6 +9,6 @@ @interface UIColor (HexString) -+ (UIColor *) RA_colorWithHexString:(NSString*)hexString; ++ (UIColor *)RA_colorWithHexString:(NSString*)hexString; @end diff --git a/UIColor+HexString.m b/UIColor+HexString.m index 399fb0a..8eb5cf8 100644 --- a/UIColor+HexString.m +++ b/UIColor+HexString.m @@ -10,48 +10,53 @@ @implementation UIColor (HexString) -+ (CGFloat) RA_colorComponentFrom: (NSString *) string start: (NSUInteger) start length: (NSUInteger) length { - NSString *substring = [string substringWithRange: NSMakeRange(start, length)]; - NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring]; ++ (CGFloat)RA_colorComponentFrom:(NSString *)string start:(NSUInteger)start length:(NSUInteger)length { + NSString *substring = [string substringWithRange:NSMakeRange(start, length)]; + NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat:@"%@%@", substring, substring]; unsigned hexComponent; [[NSScanner scannerWithString:fullHex] scanHexInt:&hexComponent]; return hexComponent / 255.0; } -+ (UIColor *) RA_colorWithHexString: (NSString *) hexString { - if (hexString.length == 0) - return nil; - NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString]; ++ (UIColor *)RA_colorWithHexString: (NSString *) hexString { + if (hexString.length == 0) { + return nil; + } + NSString *colorString = [[hexString stringByReplacingOccurrencesOfString:@"#" withString:@""] uppercaseString]; CGFloat alpha, red, blue, green; switch ([colorString length]) { - case 3: // #RGB - alpha = 1.0f; - red = [self RA_colorComponentFrom: colorString start: 0 length: 1]; - green = [self RA_colorComponentFrom: colorString start: 1 length: 1]; - blue = [self RA_colorComponentFrom: colorString start: 2 length: 1]; - break; - case 4: // #ARGB - alpha = [self RA_colorComponentFrom: colorString start: 0 length: 1]; - red = [self RA_colorComponentFrom: colorString start: 1 length: 1]; - green = [self RA_colorComponentFrom: colorString start: 2 length: 1]; - blue = [self RA_colorComponentFrom: colorString start: 3 length: 1]; - break; - case 6: // #RRGGBB - alpha = 1.0f; - red = [self RA_colorComponentFrom: colorString start: 0 length: 2]; - green = [self RA_colorComponentFrom: colorString start: 2 length: 2]; - blue = [self RA_colorComponentFrom: colorString start: 4 length: 2]; - break; - case 8: // #AARRGGBB - alpha = [self RA_colorComponentFrom: colorString start: 0 length: 2]; - red = [self RA_colorComponentFrom: colorString start: 2 length: 2]; - green = [self RA_colorComponentFrom: colorString start: 4 length: 2]; - blue = [self RA_colorComponentFrom: colorString start: 6 length: 2]; - break; - default: - return nil; + case 3: { // #RGB + alpha = 1.0f; + red = [self RA_colorComponentFrom:colorString start:0 length:1]; + green = [self RA_colorComponentFrom:colorString start:1 length:1]; + blue = [self RA_colorComponentFrom:colorString start:2 length:1]; + break; + } + case 4: { // #ARGB + alpha = [self RA_colorComponentFrom:colorString start:0 length:1]; + red = [self RA_colorComponentFrom:colorString start:1 length:1]; + green = [self RA_colorComponentFrom:colorString start:2 length:1]; + blue = [self RA_colorComponentFrom:colorString start:3 length:1]; + break; + } + case 6: { // #RRGGBB + alpha = 1.0f; + red = [self RA_colorComponentFrom: colorString start: 0 length: 2]; + green = [self RA_colorComponentFrom: colorString start: 2 length: 2]; + blue = [self RA_colorComponentFrom: colorString start: 4 length: 2]; + break; + } + case 8: { // #AARRGGBB + alpha = [self RA_colorComponentFrom: colorString start: 0 length: 2]; + red = [self RA_colorComponentFrom: colorString start: 2 length: 2]; + green = [self RA_colorComponentFrom: colorString start: 4 length: 2]; + blue = [self RA_colorComponentFrom: colorString start: 6 length: 2]; + break; + } + default: + return nil; } - return [UIColor colorWithRed: red green: green blue: blue alpha: alpha]; + return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } @end diff --git a/UIKit.xm b/UIKit.xm index 16f4d13..3a367c1 100644 --- a/UIKit.xm +++ b/UIKit.xm @@ -16,24 +16,24 @@ NSMutableDictionary *oldFrames = [NSMutableDictionary new]; static Class $memorized$UITextEffectsWindow$class; %hook UIWindow --(void) setFrame:(CGRect)frame -{ - if (![self.class isEqual:$memorized$UITextEffectsWindow$class] && [RAMessagingClient.sharedInstance shouldResize]) - { - if (![oldFrames objectForKey:@(self.hash)]) +- (void)setFrame:(CGRect)frame { + if (![self.class isEqual:$memorized$UITextEffectsWindow$class] && [RAMessagingClient.sharedInstance shouldResize]) { + if (![oldFrames objectForKey:@(self.hash)]) { [oldFrames setObject:[NSValue valueWithCGRect:frame] forKey:@(self.hash)]; + } frame.origin.x = RAMessagingClient.sharedInstance.currentData.wantedClientOriginX == -1 ? 0 : RAMessagingClient.sharedInstance.currentData.wantedClientOriginX; frame.origin.y = RAMessagingClient.sharedInstance.currentData.wantedClientOriginY == -1 ? 0 : RAMessagingClient.sharedInstance.currentData.wantedClientOriginY; CGFloat overrideWidth = [RAMessagingClient.sharedInstance resizeSize].width; CGFloat overrideHeight = [RAMessagingClient.sharedInstance resizeSize].height; - if (overrideWidth != -1 && overrideWidth != 0) + if (overrideWidth != -1 && overrideWidth != 0) { frame.size.width = overrideWidth; - if (overrideHeight != -1 && overrideHeight != 0) + } + if (overrideHeight != -1 && overrideHeight != 0) { frame.size.height = overrideHeight; + } - if (self.subviews.count > 0) - { + if (self.subviews.count > 0) { ((UIView*)self.subviews[0]).frame = frame; } } @@ -41,29 +41,28 @@ static Class $memorized$UITextEffectsWindow$class; %orig(frame); } -- (void)_rotateWindowToOrientation:(UIInterfaceOrientation)arg1 updateStatusBar:(BOOL)arg2 duration:(double)arg3 skipCallbacks:(BOOL)arg4 -{ - if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) +- (void)_rotateWindowToOrientation:(UIInterfaceOrientation)arg1 updateStatusBar:(BOOL)arg2 duration:(double)arg3 skipCallbacks:(BOOL)arg4 { + if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) { return; + } %orig; } -- (BOOL)_shouldAutorotateToInterfaceOrientation:(int)arg1 checkForDismissal:(BOOL)arg2 isRotationDisabled:(BOOL*)arg3 -{ - if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) +- (BOOL)_shouldAutorotateToInterfaceOrientation:(int)arg1 checkForDismissal:(BOOL)arg2 isRotationDisabled:(BOOL*)arg3 { + if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) { return NO; + } return %orig; } -- (void)_setWindowInterfaceOrientation:(int)arg1 -{ - if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) +- (void)_setWindowInterfaceOrientation:(int)arg1 { + if ([RAMessagingClient.sharedInstance shouldForceOrientation] && arg1 != [RAMessagingClient.sharedInstance forcedOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:arg1]) { return; + } %orig([RAMessagingClient.sharedInstance shouldForceOrientation] && [UIApplication.sharedApplication _isSupportedOrientation:[RAMessagingClient.sharedInstance forcedOrientation]] ? [RAMessagingClient.sharedInstance forcedOrientation] : arg1); } -- (void)_sendTouchesForEvent:(unsafe_id)arg1 -{ +- (void)_sendTouchesForEvent:(unsafe_id)arg1 { %orig; dispatch_async(dispatch_get_main_queue(), ^{ @@ -74,8 +73,7 @@ static Class $memorized$UITextEffectsWindow$class; %hook UIApplication %property (nonatomic, assign) BOOL RA_networkActivity; --(void) applicationDidResume -{ +- (void)applicationDidResume { %orig; [RAMessagingClient.sharedInstance requestUpdateFromServer]; //[RAFakePhoneMode updateAppSizing]; @@ -88,16 +86,12 @@ static Class $memorized$UITextEffectsWindow$class; [RAFakePhoneMode updateAppSizing]; } */ --(void) _setStatusBarHidden:(BOOL)arg1 animationParameters:(unsafe_id)arg2 changeApplicationFlag:(BOOL)arg3 -{ +- (void)_setStatusBarHidden:(BOOL)arg1 animationParameters:(unsafe_id)arg2 changeApplicationFlag:(BOOL)arg3 { //if ([RASettings.sharedInstance unifyStatusBar]) - if ([RAMessagingClient.sharedInstance shouldHideStatusBar]) - { + if ([RAMessagingClient.sharedInstance shouldHideStatusBar]) { arg1 = YES; arg3 = YES; - } - else if ([RAMessagingClient.sharedInstance shouldShowStatusBar]) - { + } else if ([RAMessagingClient.sharedInstance shouldShowStatusBar]) { arg1 = NO; arg3 = YES; } @@ -115,62 +109,48 @@ static Class $memorized$UITextEffectsWindow$class; } */ -%new -(void) RA_forceRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation isReverting:(BOOL)reverting -{ - if (!reverting) - { - if (!setPreviousOrientation) - { +%new - (void)RA_forceRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation isReverting:(BOOL)reverting { + if (!reverting) { + if (!setPreviousOrientation) { setPreviousOrientation = YES; prevousOrientation = UIApplication.sharedApplication.statusBarOrientation; - if (wasStatusBarHidden == -1) + if (wasStatusBarHidden == -1) { wasStatusBarHidden = UIApplication.sharedApplication.statusBarHidden; + } } - } - else if (setPreviousOrientation) - { + } else if (setPreviousOrientation) { orientation = prevousOrientation; setPreviousOrientation = NO; } - if (![UIApplication.sharedApplication _isSupportedOrientation:orientation]) - { + if (![UIApplication.sharedApplication _isSupportedOrientation:orientation]) { return; } - for (UIWindow *window in [[UIApplication sharedApplication] windows]) - { + for (UIWindow *window in [[UIApplication sharedApplication] windows]) { [window _setRotatableViewOrientation:orientation updateStatusBar:YES duration:0.25 force:YES]; } } -%new -(void) RA_forceStatusBarVisibility:(BOOL)visible orRevert:(BOOL)revert -{ - if (revert) - { - if (wasStatusBarHidden != -1) - { +%new - (void)RA_forceStatusBarVisibility:(BOOL)visible orRevert:(BOOL)revert { + if (revert) { + if (wasStatusBarHidden != -1) { [UIApplication.sharedApplication _setStatusBarHidden:wasStatusBarHidden animationParameters:nil changeApplicationFlag:YES]; } - } - else - { - if (wasStatusBarHidden == -1) + } else { + if (wasStatusBarHidden == -1) { wasStatusBarHidden = UIApplication.sharedApplication.statusBarHidden; + } [UIApplication.sharedApplication _setStatusBarHidden:visible animationParameters:nil changeApplicationFlag:YES]; } } -%new -(void) RA_updateWindowsForSizeChange:(CGSize)size isReverting:(BOOL)revert -{ - if (revert) - { - for (UIWindow *window in [[UIApplication sharedApplication] windows]) - { +%new - (void)RA_updateWindowsForSizeChange:(CGSize)size isReverting:(BOOL)revert { + if (revert) { + for (UIWindow *window in [[UIApplication sharedApplication] windows]) { CGRect frame = window.frame; - if ([oldFrames objectForKey:@(window.hash)]) - { + if ([oldFrames objectForKey:@(window.hash)]) { frame = [[oldFrames objectForKey:@(window.hash)] CGRectValue]; [oldFrames removeObjectForKey:@(window.hash)]; } @@ -180,22 +160,23 @@ static Class $memorized$UITextEffectsWindow$class; }]; } - if ([oldFrames objectForKey:@"statusBar"]) + if ([oldFrames objectForKey:@"statusBar"]) { UIApplication.sharedApplication.statusBar.frame = [oldFrames[@"statusBar"] CGRectValue]; - + } return; } - if (size.width != -1) - { - if (![oldFrames objectForKey:@"statusBar"]) + if (size.width != -1) { + if (![oldFrames objectForKey:@"statusBar"]) { [oldFrames setObject:[NSValue valueWithCGRect:UIApplication.sharedApplication.statusBar.frame] forKey:@"statusBar"]; + } UIApplication.sharedApplication.statusBar.frame = CGRectMake(0, 0, size.width, UIApplication.sharedApplication.statusBar.frame.size.height); } for (UIWindow *window in [[UIApplication sharedApplication] windows]) { - if (![oldFrames objectForKey:@(window.hash)]) + if (![oldFrames objectForKey:@(window.hash)]) { [oldFrames setObject:[NSValue valueWithCGRect:window.frame] forKey:@(window.hash)]; + } [UIView animateWithDuration:0.3 animations:^{ [window setFrame:window.frame]; // updates with client message app data in the setFrame: hook @@ -203,31 +184,26 @@ static Class $memorized$UITextEffectsWindow$class; } } --(BOOL) isNetworkActivityIndicatorVisible -{ - if ([RAMessagingClient.sharedInstance isBeingHosted]) +- (BOOL)isNetworkActivityIndicatorVisible { + if ([RAMessagingClient.sharedInstance isBeingHosted]) { return self.RA_networkActivity; - else + } else { return %orig; + } } --(void) setNetworkActivityIndicatorVisible:(BOOL)arg1 -{ +- (void)setNetworkActivityIndicatorVisible:(BOOL)arg1 { %orig(arg1); - if ([RAMessagingClient.sharedInstance isBeingHosted]) - { + if ([RAMessagingClient.sharedInstance isBeingHosted]) { self.RA_networkActivity = arg1; - StatusBarData *data = [UIStatusBarServer getStatusBarData]; - data->itemIsEnabled[26] = arg1; // 26 = activity indicator + data->itemIsEnabled[26] = arg1; // 26 = activity indicator TODO: check if ios 8 [UIApplication.sharedApplication.statusBar forceUpdateToData:data animated:YES]; } } --(BOOL) openURL:(__unsafe_unretained NSURL*)url -{ - if ([RAMessagingClient.sharedInstance isBeingHosted])// || [RASettings.sharedInstance openLinksInWindows]) - { +- (BOOL)openURL:(__unsafe_unretained NSURL*)url { + if ([RAMessagingClient.sharedInstance isBeingHosted]) { // || [RASettings.sharedInstance openLinksInWindows]) return [RAMessagingClient.sharedInstance notifyServerToOpenURL:url openInWindow:[RASettings.sharedInstance openLinksInWindows]]; } return %orig; @@ -235,21 +211,19 @@ static Class $memorized$UITextEffectsWindow$class; %end %hook UIStatusBar --(void) statusBarServer:(unsafe_id)arg1 didReceiveStatusBarData:(StatusBarData*)arg2 withActions:(int)arg3 -{ - if ([RAMessagingClient.sharedInstance isBeingHosted]) +- (void)statusBarServer:(unsafe_id)arg1 didReceiveStatusBarData:(StatusBarData*)arg2 withActions:(int)arg3 { + if ([RAMessagingClient.sharedInstance isBeingHosted]) { arg2->itemIsEnabled[26] = [UIApplication.sharedApplication isNetworkActivityIndicatorVisible]; + } %orig; } %end -void reloadSettings(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) -{ - [RASettings.sharedInstance reloadSettings]; +void reloadSettings(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { + [RASettings.sharedInstance reloadSettings]; } -%ctor -{ +%ctor { IF_NOT_SPRINGBOARD { %init; $memorized$UITextEffectsWindow$class = %c(UITextEffectsWindow); diff --git a/WindowedMultitasking/ActivatorCreateAppWindow.xm b/WindowedMultitasking/ActivatorCreateAppWindow.xm index 948d3e0..3e9a3ff 100644 --- a/WindowedMultitasking/ActivatorCreateAppWindow.xm +++ b/WindowedMultitasking/ActivatorCreateAppWindow.xm @@ -13,8 +13,7 @@ static RAActivatorCreateWindowListener *sharedInstance$RAActivatorCreateWindowListener; @implementation RAActivatorCreateWindowListener -- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)levent -{ +- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)levent { SBApplication *topApp = [[UIApplication sharedApplication] _accessibilityFrontMostApplication]; RAIconIndicatorViewInfo indicatorInfo = [[%c(RABackgrounder) sharedInstance] allAggregatedIndicatorInfoForIdentifier:topApp.bundleIdentifier]; @@ -31,8 +30,9 @@ static RAActivatorCreateWindowListener *sharedInstance$RAActivatorCreateWindowLi // Open in window RAWindowBar *windowBar = [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; - if (!RADesktopManager.sharedInstance.lastUsedWindow) + if (!RADesktopManager.sharedInstance.lastUsedWindow) { RADesktopManager.sharedInstance.lastUsedWindow = windowBar; + } }]; [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; @@ -43,11 +43,10 @@ static RAActivatorCreateWindowListener *sharedInstance$RAActivatorCreateWindowLi } @end -%ctor -{ - IF_SPRINGBOARD - { - sharedInstance$RAActivatorCreateWindowListener = [[RAActivatorCreateWindowListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorCreateWindowListener forName:@"com.efrederickson.reachapp.windowedmultitasking.createWindow"]; +%ctor { + IF_NOT_SPRINGBOARD { + return; } + sharedInstance$RAActivatorCreateWindowListener = [[RAActivatorCreateWindowListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorCreateWindowListener forName:@"com.efrederickson.reachapp.windowedmultitasking.createWindow"]; } diff --git a/WindowedMultitasking/ActivatorToggleEditModeListener.xm b/WindowedMultitasking/ActivatorToggleEditModeListener.xm index 3ec7728..3be9f58 100644 --- a/WindowedMultitasking/ActivatorToggleEditModeListener.xm +++ b/WindowedMultitasking/ActivatorToggleEditModeListener.xm @@ -10,28 +10,25 @@ static RAActivatorToggleEditModeListener *sharedInstance; @implementation RAActivatorToggleEditModeListener -- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event -{ - RADesktopWindow *desktop = RADesktopManager.sharedInstance.currentDesktop; +- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event { + RADesktopWindow *desktop = RADesktopManager.sharedInstance.currentDesktop; - for (RAWindowBar *view in desktop.subviews) - { - if ([view isKindOfClass:[RAWindowBar class]]) - { - if (view.isOverlayShowing) - [view hideOverlay]; - else - [view showOverlay]; - } - } + for (RAWindowBar *view in desktop.subviews) { + if ([view isKindOfClass:[RAWindowBar class]]) { + if (view.isOverlayShowing) { + [view hideOverlay]; + } else { + [view showOverlay]; + } + } + } } @end -%ctor -{ - IF_SPRINGBOARD - { - sharedInstance = [[RAActivatorToggleEditModeListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"]; +%ctor { + IF_NOT_SPRINGBOARD { + return; } + sharedInstance = [[RAActivatorToggleEditModeListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance forName:@"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"]; } diff --git a/WindowedMultitasking/LaunchToWindow.xm b/WindowedMultitasking/LaunchToWindow.xm index 2bee37d..ce65b3d 100644 --- a/WindowedMultitasking/LaunchToWindow.xm +++ b/WindowedMultitasking/LaunchToWindow.xm @@ -8,57 +8,47 @@ BOOL override = NO; BOOL allowOpenApp = NO; %hook SBIconController --(void)iconWasTapped:(__unsafe_unretained SBApplicationIcon*)arg1 -{ - if ([RASettings.sharedInstance windowedMultitaskingEnabled] && [RASettings.sharedInstance launchIntoWindows] && arg1.application) - { +- (void)iconWasTapped:(__unsafe_unretained SBApplicationIcon*)arg1 { + if ([RASettings.sharedInstance windowedMultitaskingEnabled] && [RASettings.sharedInstance launchIntoWindows] && arg1.application) { [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:arg1.application animated:YES]; override = YES; } %orig; } --(void)_launchIcon:(unsafe_id)icon -{ - if (!override) +- (void)_launchIcon:(unsafe_id)icon { + if (!override) { %orig; - else + } else { override = NO; + } } %end %hook SBUIController -- (void)activateApplicationAnimated:(__unsafe_unretained SBApplication*)arg1 -{ +- (void)activateApplicationAnimated:(__unsafe_unretained SBApplication*)arg1 { // Broken //if (launchNextOpenIntoWindow) - if ([RASettings.sharedInstance windowedMultitaskingEnabled] &&[RASettings.sharedInstance launchIntoWindows] && !allowOpenApp) - { + if ([RASettings.sharedInstance windowedMultitaskingEnabled] &&[RASettings.sharedInstance launchIntoWindows] && !allowOpenApp) { [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:arg1 animated:YES]; //launchNextOpenIntoWindow = NO; return; - } - else - { + } else { [RADesktopManager.sharedInstance removeAppWithIdentifier:arg1.bundleIdentifier animated:NO forceImmediateUnload:YES]; } %orig; } -- (void)activateApplication:(__unsafe_unretained SBApplication*)arg1 -{ +- (void)activateApplication:(__unsafe_unretained SBApplication*)arg1 { // Broken //if (launchNextOpenIntoWindow) - if ([RASettings.sharedInstance windowedMultitaskingEnabled] &&[RASettings.sharedInstance launchIntoWindows] && !allowOpenApp) - { + if ([RASettings.sharedInstance windowedMultitaskingEnabled] &&[RASettings.sharedInstance launchIntoWindows] && !allowOpenApp) { [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:arg1 animated:YES]; //launchNextOpenIntoWindow = NO; return; - } - else - { + } else { [RADesktopManager.sharedInstance removeAppWithIdentifier:arg1.bundleIdentifier animated:NO forceImmediateUnload:YES]; } %orig; diff --git a/WindowedMultitasking/RADesktopManager.h b/WindowedMultitasking/RADesktopManager.h index 20d5917..45b161f 100644 --- a/WindowedMultitasking/RADesktopManager.h +++ b/WindowedMultitasking/RADesktopManager.h @@ -5,31 +5,31 @@ RADesktopWindow *currentDesktop; NSUInteger currentDesktopIndex; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; @property (nonatomic, weak) RAWindowBar *lastUsedWindow; --(void) addDesktop:(BOOL)switchTo; --(void) removeDesktopAtIndex:(NSUInteger)index; --(void) removeAppWithIdentifier:(NSString*)bundleIdentifier animated:(BOOL)animated; --(void) removeAppWithIdentifier:(NSString*)bundleIdentifier animated:(BOOL)animated forceImmediateUnload:(BOOL)force; +- (void)addDesktop:(BOOL)switchTo; +- (void)removeDesktopAtIndex:(NSUInteger)index; +- (void)removeAppWithIdentifier:(NSString*)bundleIdentifier animated:(BOOL)animated; +- (void)removeAppWithIdentifier:(NSString*)bundleIdentifier animated:(BOOL)animated forceImmediateUnload:(BOOL)force; --(BOOL) isAppOpened:(NSString*)identifier; --(RAWindowBar*) windowForIdentifier:(NSString*)identifier; +- (BOOL)isAppOpened:(NSString*)identifier; +- (RAWindowBar*)windowForIdentifier:(NSString*)identifier; --(NSUInteger) currentDesktopIndex; --(NSUInteger) numberOfDesktops; --(void) switchToDesktop:(NSUInteger)index; --(void) switchToDesktop:(NSUInteger)index actuallyShow:(BOOL)show; --(RADesktopWindow*) currentDesktop; --(NSArray*) availableDesktops; --(RADesktopWindow*) desktopAtIndex:(NSUInteger)index; +- (NSUInteger)currentDesktopIndex; +- (NSUInteger)numberOfDesktops; +- (void)switchToDesktop:(NSUInteger)index; +- (void)switchToDesktop:(NSUInteger)index actuallyShow:(BOOL)show; +- (RADesktopWindow*)currentDesktop; +- (NSArray*)availableDesktops; +- (RADesktopWindow*)desktopAtIndex:(NSUInteger)index; --(void) updateWindowSizeForApplication:(NSString*)identifier; --(void) updateRotationOnClients:(UIInterfaceOrientation)orientation; +- (void)updateWindowSizeForApplication:(NSString*)identifier; +- (void)updateRotationOnClients:(UIInterfaceOrientation)orientation; --(void) hideDesktop; --(void) reshowDesktop; +- (void)hideDesktop; +- (void)reshowDesktop; --(void) findNewForemostApp; -@end \ No newline at end of file +- (void)findNewForemostApp; +@end diff --git a/WindowedMultitasking/RADesktopManager.xm b/WindowedMultitasking/RADesktopManager.xm index 70b0afd..a78d890 100644 --- a/WindowedMultitasking/RADesktopManager.xm +++ b/WindowedMultitasking/RADesktopManager.xm @@ -5,8 +5,7 @@ BOOL overrideUIWindow = NO; @implementation RADesktopManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RADesktopManager, sharedInstance->windows = [NSMutableArray array]; [sharedInstance addDesktop:YES]; @@ -14,23 +13,24 @@ BOOL overrideUIWindow = NO; ); } --(void) addDesktop:(BOOL)switchTo -{ +- (void)addDesktop:(BOOL)switchTo { RADesktopWindow *desktopWindow = [[RADesktopWindow alloc] initWithFrame:UIScreen.mainScreen._referenceBounds]; [windows addObject:desktopWindow]; - if (switchTo) + if (switchTo) { [self switchToDesktop:windows.count - 1]; + } [desktopWindow loadInfo:[windows indexOfObject:desktopWindow]]; } --(void) removeDesktopAtIndex:(NSUInteger)index -{ - if (windows.count == 1 && index == 0) +- (void)removeDesktopAtIndex:(NSUInteger)index { + if (windows.count == 1 && index == 0) { return; + } - if (currentDesktopIndex == index) + if (currentDesktopIndex == index) { [self switchToDesktop:0]; + } RADesktopWindow *window = windows[index]; [window saveInfo]; @@ -38,26 +38,24 @@ BOOL overrideUIWindow = NO; [windows removeObjectAtIndex:index]; } --(BOOL) isAppOpened:(NSString*)identifier -{ - for (RADesktopWindow *desktop in windows) - if ([desktop isAppOpened:identifier]) +- (BOOL)isAppOpened:(NSString*)identifier { + for (RADesktopWindow *desktop in windows) { + if ([desktop isAppOpened:identifier]) { return YES; + } + } return NO; } --(NSUInteger) numberOfDesktops -{ +- (NSUInteger)numberOfDesktops { return windows.count; } --(void) switchToDesktop:(NSUInteger)index -{ +- (void)switchToDesktop:(NSUInteger)index { [self switchToDesktop:index actuallyShow:YES]; } --(void) switchToDesktop:(NSUInteger)index actuallyShow:(BOOL)show -{ +- (void)switchToDesktop:(NSUInteger)index actuallyShow:(BOOL)show { RADesktopWindow *newDesktop = windows[index]; currentDesktop.hidden = YES; @@ -65,80 +63,73 @@ BOOL overrideUIWindow = NO; [currentDesktop unloadApps]; [newDesktop loadApps]; - if (!show) + if (!show) { newDesktop.hidden = YES; + } overrideUIWindow = NO; [newDesktop makeKeyAndVisible]; overrideUIWindow = YES; - if (!show) + if (!show) { newDesktop.hidden = YES; + } currentDesktopIndex = index; currentDesktop = newDesktop; //[newDesktop updateForOrientation:UIApplication.sharedApplication.statusBarOrientation]; } --(void) removeAppWithIdentifier:(NSString*)bundleIdentifier animated:(BOOL)animated -{ +- (void)removeAppWithIdentifier:(NSString*)bundleIdentifier animated:(BOOL)animated { [self removeAppWithIdentifier:bundleIdentifier animated:animated forceImmediateUnload:NO]; } --(void) removeAppWithIdentifier:(NSString*)bundleIdentifier animated:(BOOL)animated forceImmediateUnload:(BOOL)force -{ - for (RADesktopWindow *window in windows) - { +- (void)removeAppWithIdentifier:(NSString*)bundleIdentifier animated:(BOOL)animated forceImmediateUnload:(BOOL)force { + for (RADesktopWindow *window in windows) { [window removeAppWithIdentifier:bundleIdentifier animated:animated forceImmediateUnload:force]; } } --(RAWindowBar*) windowForIdentifier:(NSString*)identifier -{ - for (RADesktopWindow *desktop in windows) - if ([desktop isAppOpened:identifier]) +- (RAWindowBar*)windowForIdentifier:(NSString*)identifier { + for (RADesktopWindow *desktop in windows) { + if ([desktop isAppOpened:identifier]) { return [desktop windowForIdentifier:identifier]; + } + } return nil; } --(void) hideDesktop -{ +- (void)hideDesktop { currentDesktop.hidden = YES; } --(void) reshowDesktop -{ +- (void)reshowDesktop { currentDesktop.hidden = NO; } --(void) updateRotationOnClients:(UIInterfaceOrientation)orientation -{ - for (RADesktopWindow *w in windows) +- (void)updateRotationOnClients:(UIInterfaceOrientation)orientation { + for (RADesktopWindow *w in windows) { [w updateRotationOnClients:orientation]; + } } --(void) updateWindowSizeForApplication:(NSString*)identifier -{ - for (RADesktopManager *w in windows) +- (void)updateWindowSizeForApplication:(NSString*)identifier { + for (RADesktopManager *w in windows) { [w updateWindowSizeForApplication:identifier]; + } } --(void) setLastUsedWindow:(RAWindowBar*)window -{ - if (_lastUsedWindow) - { +- (void)setLastUsedWindow:(RAWindowBar*)window { + if (_lastUsedWindow) { [_lastUsedWindow resignForemostApp]; } _lastUsedWindow = window; [_lastUsedWindow becomeForemostApp]; } --(void) findNewForemostApp -{ +- (void)findNewForemostApp { RADesktopWindow *desktop = [self currentDesktop]; - for (RAHostedAppView *hostedApp in desktop.hostedWindows) - { + for (RAHostedAppView *hostedApp in desktop.hostedWindows) { RAWindowBar *bar = [desktop windowForIdentifier:hostedApp.app.bundleIdentifier]; - if (bar) - { + if (bar) { self.lastUsedWindow = bar; return; } @@ -146,10 +137,21 @@ BOOL overrideUIWindow = NO; //self.lastUsedWindow = nil; } --(RADesktopWindow*) desktopAtIndex:(NSUInteger)index { return windows[index]; } --(NSArray*) availableDesktops { return windows; } --(NSUInteger) currentDesktopIndex { return currentDesktopIndex; } --(RADesktopWindow*) currentDesktop { return currentDesktop; } +- (RADesktopWindow*)desktopAtIndex:(NSUInteger)index { + return windows[index]; +} + +- (NSArray*)availableDesktops { + return windows; +} + +- (NSUInteger)currentDesktopIndex { + return currentDesktopIndex; +} + +- (RADesktopWindow*)currentDesktop { + return currentDesktop; +} @end /* diff --git a/WindowedMultitasking/RADesktopWindow.h b/WindowedMultitasking/RADesktopWindow.h index 0feba46..a90b4c2 100644 --- a/WindowedMultitasking/RADesktopWindow.h +++ b/WindowedMultitasking/RADesktopWindow.h @@ -9,30 +9,30 @@ BOOL dontClearForcedPhoneState; } --(RAWindowBar*) addAppWithView:(RAHostedAppView*)view animated:(BOOL)animated; --(RAWindowBar*) createAppWindowForSBApplication:(SBApplication*)app animated:(BOOL)animated; --(RAWindowBar*) createAppWindowWithIdentifier:(NSString*)identifier animated:(BOOL)animated; +- (RAWindowBar*)addAppWithView:(RAHostedAppView*)view animated:(BOOL)animated; +- (RAWindowBar*)createAppWindowForSBApplication:(SBApplication*)app animated:(BOOL)animated; +- (RAWindowBar*)createAppWindowWithIdentifier:(NSString*)identifier animated:(BOOL)animated; --(void) addExistingWindow:(RAWindowBar*)window; --(void) removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated; --(void) removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated forceImmediateUnload:(BOOL)force; +- (void)addExistingWindow:(RAWindowBar*)window; +- (void)removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated; +- (void)removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated forceImmediateUnload:(BOOL)force; --(NSArray*) hostedWindows; --(BOOL) isAppOpened:(NSString*)identifier; --(RAWindowBar*) windowForIdentifier:(NSString*)identifier; +- (NSArray*)hostedWindows; +- (BOOL)isAppOpened:(NSString*)identifier; +- (RAWindowBar*)windowForIdentifier:(NSString*)identifier; --(UIInterfaceOrientation) currentOrientation; --(CGFloat) baseRotationForOrientation; --(UIInterfaceOrientation) appOrientationRelativeToThisOrientation:(CGFloat)currentRotation; --(void) updateRotationOnClients:(UIInterfaceOrientation)orientation; +- (UIInterfaceOrientation)currentOrientation; +- (CGFloat)baseRotationForOrientation; +- (UIInterfaceOrientation)appOrientationRelativeToThisOrientation:(CGFloat)currentRotation; +- (void)updateRotationOnClients:(UIInterfaceOrientation)orientation; --(void) updateWindowSizeForApplication:(NSString*)identifier; +- (void)updateWindowSizeForApplication:(NSString*)identifier; --(void) unloadApps; --(void) loadApps; --(void) closeAllApps; +- (void)unloadApps; +- (void)loadApps; +- (void)closeAllApps; --(void) saveInfo; --(void) loadInfo; --(void) loadInfo:(NSInteger)index; -@end \ No newline at end of file +- (void)saveInfo; +- (void)loadInfo; +- (void)loadInfo:(NSInteger)index; +@end diff --git a/WindowedMultitasking/RADesktopWindow.mm b/WindowedMultitasking/RADesktopWindow.mm index 6406e7b..343e5c9 100644 --- a/WindowedMultitasking/RADesktopWindow.mm +++ b/WindowedMultitasking/RADesktopWindow.mm @@ -7,30 +7,27 @@ #import "RAFakePhoneMode.h" @implementation RADesktopWindow --(instancetype) initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) - { +- (instancetype)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { appViews = [NSMutableArray array]; self.windowLevel = 1000; } return self; } --(RAWindowBar*) addAppWithView:(RAHostedAppView*)view animated:(BOOL)animated -{ +- (RAWindowBar*)addAppWithView:(RAHostedAppView*)view animated:(BOOL)animated { // Avoid adding duplicates - if it already exists as a window, return the existing window - for (RAWindowBar *bar in self.subviews) - if ([bar isKindOfClass:[RAWindowBar class]]) // Just verify - if (bar.attachedView.app == view.app) - return bar; + for (RAWindowBar *bar in self.subviews) { + if ([bar isKindOfClass:[RAWindowBar class]] && bar.attachedView.app == view.app) {// Just verify + return bar; + } + } - if ([RAFakePhoneMode shouldFakeForAppWithIdentifier:view.app.bundleIdentifier]) - { + if ([RAFakePhoneMode shouldFakeForAppWithIdentifier:view.app.bundleIdentifier]) { view.frame = (CGRect){ { 0, 100 }, [RAFakePhoneMode fakeSizeForAppWithIdentifier:view.app.bundleIdentifier] }; - } - else + } else { view.frame = CGRectMake(0, 100, UIScreen.mainScreen._referenceBounds.size.width, UIScreen.mainScreen._referenceBounds.size.height); + } view.center = self.center; RAWindowBar *windowBar = [[RAWindowBar alloc] init]; @@ -38,26 +35,29 @@ -(RAWindowBar*) addAppWithView:(RAHostedAppView*)view animated:(BOOL)animated [windowBar attachView:view]; [appViews addObject:view]; - if (animated) + if (animated) { windowBar.alpha = 0; + } [self addSubview:windowBar]; - if (animated) + if (animated) { [UIView animateWithDuration:0.5 animations:^{ windowBar.alpha = 1; }]; + } - if (!self.hidden) + if (!self.hidden) { [view loadApp]; + } view.hideStatusBar = YES; windowBar.transform = CGAffineTransformMakeScale(0.5, 0.5); - if (![RAFakePhoneMode shouldFakeForAppWithIdentifier:view.app.bundleIdentifier]) + if (![RAFakePhoneMode shouldFakeForAppWithIdentifier:view.app.bundleIdentifier]) { windowBar.transform = CGAffineTransformRotate(windowBar.transform, DEGREES_TO_RADIANS([self baseRotationForOrientation])); + } windowBar.hidden = NO; lastKnownOrientation = -1; //view.shouldUseExternalKeyboard = YES; - if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:view.app.bundleIdentifier]) - { + if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:view.app.bundleIdentifier]) { RAPreservedWindowInformation info = [RAWindowStatePreservationSystemManager.sharedInstance windowInformationForAppIdentifier:view.app.bundleIdentifier]; windowBar.center = info.center; @@ -77,8 +77,7 @@ -(RAWindowBar*) addAppWithView:(RAHostedAppView*)view animated:(BOOL)animated return windowBar; } --(void) addExistingWindow:(RAWindowBar*)window -{ +- (void)addExistingWindow:(RAWindowBar*)window { [appViews addObject:window.attachedView]; [self addSubview:window]; @@ -86,29 +85,23 @@ -(void) addExistingWindow:(RAWindowBar*)window ((UIView*)self.subviews[self.subviews.count - 1]).transform = window.transform; } --(RAWindowBar*) createAppWindowForSBApplication:(SBApplication*)app animated:(BOOL)animated -{ +- (RAWindowBar*)createAppWindowForSBApplication:(SBApplication*)app animated:(BOOL)animated { return [self createAppWindowWithIdentifier:app.bundleIdentifier animated:animated]; } --(RAWindowBar*) createAppWindowWithIdentifier:(NSString*)identifier animated:(BOOL)animated -{ +- (RAWindowBar*)createAppWindowWithIdentifier:(NSString*)identifier animated:(BOOL)animated { RAHostedAppView *view = [[RAHostedAppView alloc] initWithBundleIdentifier:identifier]; view.renderWallpaper = YES; return [self addAppWithView:view animated:animated]; } --(void) removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated -{ +- (void)removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated { [self removeAppWithIdentifier:identifier animated:animated forceImmediateUnload:NO]; } --(void) removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated forceImmediateUnload:(BOOL)force -{ - for (RAHostedAppView *view in appViews) - { - if ([view.bundleIdentifier isEqual:identifier]) - { +- (void)removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated forceImmediateUnload:(BOOL)force { + for (RAHostedAppView *view in appViews) { + if ([view.bundleIdentifier isEqual:identifier]) { void (^destructor)() = ^{ //view.shouldUseExternalKeyboard = NO; [view unloadApp:force]; @@ -117,32 +110,32 @@ -(void) removeAppWithIdentifier:(NSString*)identifier animated:(BOOL)animated fo [appViews removeObject:view]; [self saveInfo]; - if (!dontClearForcedPhoneState && [RAFakePhoneMode shouldFakeForAppWithIdentifier:identifier]) + if (!dontClearForcedPhoneState && [RAFakePhoneMode shouldFakeForAppWithIdentifier:identifier]) { [RAMessagingServer.sharedInstance forcePhoneMode:NO forIdentifier:identifier andRelaunchApp:YES]; + } }; - if (animated) + if (animated) { [UIView animateWithDuration:0.3 animations:^{ view.superview.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1); view.superview.layer.position = CGPointMake(UIScreen.mainScreen._referenceBounds.size.width / 2, UIScreen.mainScreen._referenceBounds.size.height); view.superview.layer.opacity = 0.0f; [RADesktopManager.sharedInstance findNewForemostApp]; //view.superview.alpha = 0; - } completion:^(BOOL _) { destructor(); }]; - else + } completion:^(BOOL _) { + destructor(); + }]; + } else { destructor(); - + } return; } } } --(void) updateWindowSizeForApplication:(NSString*)identifier -{ +- (void)updateWindowSizeForApplication:(NSString*)identifier { NSArray *tempArrayToAvoidMutationCrash = [appViews copy]; - for (RAHostedAppView *view in tempArrayToAvoidMutationCrash) - { - if ([view.bundleIdentifier isEqual:identifier]) - { + for (RAHostedAppView *view in tempArrayToAvoidMutationCrash) { + if ([view.bundleIdentifier isEqual:identifier]) { dontClearForcedPhoneState = YES; [self removeAppWithIdentifier:identifier animated:NO forceImmediateUnload:YES]; [self createAppWindowWithIdentifier:identifier animated:NO]; @@ -162,94 +155,93 @@ -(void) updateWindowSizeForApplication:(NSString*)identifier } } --(NSArray*) hostedWindows -{ +- (NSArray*)hostedWindows { return appViews; } --(void) unloadApps -{ - for (RAHostedAppView *view in appViews) +- (void)unloadApps { + for (RAHostedAppView *view in appViews) { [view unloadApp]; + } } --(void) loadApps -{ - for (RAHostedAppView *view in appViews) +- (void)loadApps { + for (RAHostedAppView *view in appViews) { [view loadApp]; + } } --(void) closeAllApps -{ +- (void)closeAllApps { //while (appViews.count > 0) int i = appViews.count - 1; - while (i --> 0) // Always wanted to use that 😍 - { + while (i --> 0) { // Always wanted to use that 😍 [self removeAppWithIdentifier:((RAHostedAppView*)appViews[i]).bundleIdentifier animated:YES]; } } --(void) updateRotationOnClients:(UIInterfaceOrientation)orientation -{ +- (void)updateRotationOnClients:(UIInterfaceOrientation)orientation { lastKnownOrientation = orientation; - for (RAWindowBar *app in self.subviews) - if ([app isKindOfClass:[RAWindowBar class]]) // could be a diferent kind of UIView actually + for (RAWindowBar *app in self.subviews) { + if ([app isKindOfClass:[RAWindowBar class]]){ // could be a diferent kind of UIView actually [app updateClientRotation:orientation]; + } + } } --(BOOL) isAppOpened:(NSString*)identifier -{ - for (RAHostedAppView *app in appViews) - if ([app.app.bundleIdentifier isEqual:identifier]) +- (BOOL)isAppOpened:(NSString*)identifier { + for (RAHostedAppView *app in appViews) { + if ([app.app.bundleIdentifier isEqual:identifier]) { return YES; + } + } return NO; } --(RAWindowBar*) windowForIdentifier:(NSString*)identifier -{ - for (UIView *view in self.subviews) - if ([view isKindOfClass:[RAWindowBar class]]) - { +- (RAWindowBar*)windowForIdentifier:(NSString*)identifier { + for (UIView *view in self.subviews) { + if ([view isKindOfClass:[RAWindowBar class]]) { RAWindowBar *bar = (RAWindowBar*)view; - if ([bar.attachedView.app.bundleIdentifier isEqual:identifier]) + if ([bar.attachedView.app.bundleIdentifier isEqual:identifier]) { return bar; + } } + } return nil; } --(void) saveInfo -{ +- (void)saveInfo { [RAWindowStatePreservationSystemManager.sharedInstance saveDesktopInformation:self]; [RASnapshotProvider.sharedInstance forceReloadSnapshotOfDesktop:self]; } --(void) loadInfo -{ +- (void)loadInfo { NSInteger index = [RADesktopManager.sharedInstance.availableDesktops indexOfObject:self]; - if (![RAWindowStatePreservationSystemManager.sharedInstance hasDesktopInformationAtIndex:index]) + if (![RAWindowStatePreservationSystemManager.sharedInstance hasDesktopInformationAtIndex:index]) { return; + } RAPreservedDesktopInformation info = [RAWindowStatePreservationSystemManager.sharedInstance desktopInformationForIndex:index]; - for (NSString *bundleIdentifier in info.openApps) + for (NSString *bundleIdentifier in info.openApps) { [self createAppWindowWithIdentifier:bundleIdentifier animated:YES]; + } } --(UIInterfaceOrientation) currentOrientation -{ - if (lastKnownOrientation >= 0) +- (UIInterfaceOrientation)currentOrientation { + if (lastKnownOrientation >= 0) { return lastKnownOrientation; + } return UIApplication.sharedApplication.statusBarOrientation; } --(CGFloat) baseRotationForOrientation -{ +- (CGFloat)baseRotationForOrientation { UIInterfaceOrientation o = [self currentOrientation]; - if (o == UIInterfaceOrientationLandscapeRight) + if (o == UIInterfaceOrientationLandscapeRight) { return 90; - else if (o == UIInterfaceOrientationLandscapeLeft) + } else if (o == UIInterfaceOrientationLandscapeLeft) { return 270; - else if (o == UIInterfaceOrientationPortraitUpsideDown) + } else if (o == UIInterfaceOrientationPortraitUpsideDown) { return 180; + } return 0; } @@ -257,98 +249,96 @@ -(UIInterfaceOrientation) appOrientationRelativeToThisOrientation:(CGFloat)curre { UIInterfaceOrientation base = [self currentOrientation]; - switch (base) - { - case UIInterfaceOrientationLandscapeLeft: - if (currentRotation >= 315 || currentRotation <= 45) + switch (base) { + case UIInterfaceOrientationLandscapeLeft: { + if (currentRotation >= 315 || currentRotation <= 45) { return UIInterfaceOrientationLandscapeLeft; - else if (currentRotation > 45 && currentRotation <= 135) + } else if (currentRotation > 45 && currentRotation <= 135) { return UIInterfaceOrientationPortraitUpsideDown; - else if (currentRotation > 135 && currentRotation <= 215) + } else if (currentRotation > 135 && currentRotation <= 215) { return UIInterfaceOrientationLandscapeRight; - else + } else { return UIInterfaceOrientationPortrait; - - case UIInterfaceOrientationLandscapeRight: - if (currentRotation >= 315 || currentRotation <= 45) + } + } + case UIInterfaceOrientationLandscapeRight: { + if (currentRotation >= 315 || currentRotation <= 45) { return UIInterfaceOrientationLandscapeRight; - else if (currentRotation > 45 && currentRotation <= 135) + } else if (currentRotation > 45 && currentRotation <= 135) { return UIInterfaceOrientationPortrait; - else if (currentRotation > 135 && currentRotation <= 215) + } else if (currentRotation > 135 && currentRotation <= 215) { return UIInterfaceOrientationLandscapeLeft; - else + } else { return UIInterfaceOrientationPortraitUpsideDown; - - case UIInterfaceOrientationPortraitUpsideDown: - if (currentRotation >= 315 || currentRotation <= 45) + } + } + case UIInterfaceOrientationPortraitUpsideDown: { + if (currentRotation >= 315 || currentRotation <= 45) { return UIInterfaceOrientationPortraitUpsideDown; - else if (currentRotation > 45 && currentRotation <= 135) + } else if (currentRotation > 45 && currentRotation <= 135) { return UIInterfaceOrientationLandscapeRight; - else if (currentRotation > 135 && currentRotation <= 215) + } else if (currentRotation > 135 && currentRotation <= 215) { return UIInterfaceOrientationPortrait; - else + } else { return UIInterfaceOrientationLandscapeLeft; - + } + } case UIInterfaceOrientationPortrait: default: break; } - if (currentRotation >= 315 || currentRotation <= 45) - { + if (currentRotation >= 315 || currentRotation <= 45) { return UIInterfaceOrientationPortrait; - } - else if (currentRotation > 45 && currentRotation <= 135) - { + } else if (currentRotation > 45 && currentRotation <= 135) { return UIInterfaceOrientationLandscapeLeft; - } - else if (currentRotation > 135 && currentRotation <= 215) - { + } else if (currentRotation > 135 && currentRotation <= 215) { return UIInterfaceOrientationPortraitUpsideDown; - } - else - { + } else { return UIInterfaceOrientationLandscapeRight; } } --(void) loadInfo:(NSInteger)index -{ - if (![RAWindowStatePreservationSystemManager.sharedInstance hasDesktopInformationAtIndex:index]) +- (void)loadInfo:(NSInteger)index { + if (![RAWindowStatePreservationSystemManager.sharedInstance hasDesktopInformationAtIndex:index]) { return; + } RAPreservedDesktopInformation info = [RAWindowStatePreservationSystemManager.sharedInstance desktopInformationForIndex:index]; - for (NSString *bundleIdentifier in info.openApps) + for (NSString *bundleIdentifier in info.openApps) { [self createAppWindowWithIdentifier:bundleIdentifier animated:YES]; + } } --(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event -{ +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; UIView *subview; - while ((subview = [objects nextObject])) - { - if (self.rootViewController && [self.rootViewController.view isEqual:subview]) + while ((subview = [objects nextObject])) { + if (self.rootViewController && [self.rootViewController.view isEqual:subview]) { continue; - if (subview.hidden) + } + if (subview.hidden) { continue; + } UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; - if (success) - return success; + if (success) { + return success; + } } return [super hitTest:point withEvent:event]; } -- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event -{ +- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { BOOL isContained = NO; - for (UIView *view in self.subviews) - { - if (self.rootViewController && [self.rootViewController.view isEqual:view]) + for (UIView *view in self.subviews) { + if (self.rootViewController && [self.rootViewController.view isEqual:view]) { continue; - if (view.hidden) + } + if (view.hidden) { continue; - if (CGRectContainsPoint(view.frame, point) || CGRectContainsPoint(view.frame, [view convertPoint:point fromView:self])) // [self convertPoint:point toView:view])) + } + if (CGRectContainsPoint(view.frame, point) || CGRectContainsPoint(view.frame, [view convertPoint:point fromView:self])) { // [self convertPoint:point toView:view])) isContained = YES; + } } return isContained; } diff --git a/WindowedMultitasking/RAWindowBar.h b/WindowedMultitasking/RAWindowBar.h index 14cb4a8..9ac0391 100644 --- a/WindowedMultitasking/RAWindowBar.h +++ b/WindowedMultitasking/RAWindowBar.h @@ -9,30 +9,30 @@ @property (nonatomic, weak) RADesktopWindow *desktop; --(void) close; --(void) maximize; --(void) minimize; --(void) sizingLockButtonTap:(id)arg1; --(BOOL) isLocked; +- (void)close; +- (void)maximize; +- (void)minimize; +- (void)sizingLockButtonTap:(id)arg1; +- (BOOL)isLocked; --(void) showOverlay; --(void) hideOverlay; --(BOOL) isOverlayShowing; +- (void)showOverlay; +- (void)hideOverlay; +- (BOOL)isOverlayShowing; --(RAHostedAppView*) attachedView; --(void) attachView:(RAHostedAppView*)view; +- (RAHostedAppView*)attachedView; +- (void)attachView:(RAHostedAppView*)view; --(void) updateClientRotation; --(void) updateClientRotation:(UIInterfaceOrientation)orientation; +- (void)updateClientRotation; +- (void)updateClientRotation:(UIInterfaceOrientation)orientation; --(void) scaleTo:(CGFloat)scale animated:(BOOL)animate; --(void) scaleTo:(CGFloat)scale animated:(BOOL)animate derotate:(BOOL)derotate; +- (void)scaleTo:(CGFloat)scale animated:(BOOL)animate; +- (void)scaleTo:(CGFloat)scale animated:(BOOL)animate derotate:(BOOL)derotate; --(void) saveWindowInfo; +- (void)saveWindowInfo; --(void) disableLongPress; --(void) enableLongPress; +- (void)disableLongPress; +- (void)enableLongPress; --(void) resignForemostApp; --(void) becomeForemostApp; +- (void)resignForemostApp; +- (void)becomeForemostApp; @end diff --git a/WindowedMultitasking/RAWindowBar.xm b/WindowedMultitasking/RAWindowBar.xm index 0fa95f8..9da0bc2 100644 --- a/WindowedMultitasking/RAWindowBar.xm +++ b/WindowedMultitasking/RAWindowBar.xm @@ -44,11 +44,9 @@ extern BOOL allowOpenApp; @end @implementation RAWindowBar --(void) attachView:(RAHostedAppView*)view -{ +- (void)attachView:(RAHostedAppView*)view { height = 40; - if (IS_IPAD) - { + if (IS_IPAD) { height = 45; } @@ -117,13 +115,13 @@ extern BOOL allowOpenApp; [self addSubview:titleLabel]; CGFloat tmp = 16; - while (tmp + 16 < height) + while (tmp + 16 < height) { tmp += 16; + } buttonSize = tmp; spacing = (height - buttonSize) / 2.0; - if (![RASettings.sharedInstance onlyShowWindowBarIconsOnOverlay]) - { + if (![RASettings.sharedInstance onlyShowWindowBarIconsOnOverlay]) { /* alignment: 0 = left @@ -176,31 +174,31 @@ extern BOOL allowOpenApp; NSMutableArray *leftIconOrder = [NSMutableArray array]; NSMutableArray *rightIconOrder = [NSMutableArray array]; - for (int i = 0; i < infos.count; i++) - { + for (int i = 0; i < infos.count; i++) { RAWindowBarIconInfo *info = infos[i]; - if (info.alignment == 0) + if (info.alignment == 0) { [leftIconOrder addObject:info]; - else + } else { [rightIconOrder addObject:info]; + } } [leftIconOrder sortUsingComparator:^(RAWindowBarIconInfo *a, RAWindowBarIconInfo *b) { - if (a.priority > b.priority) + if (a.priority > b.priority) { return (NSComparisonResult)NSOrderedDescending; - else if (a.priority < b.priority) + } else if (a.priority < b.priority) { return (NSComparisonResult)NSOrderedAscending; - - return (NSComparisonResult)NSOrderedSame; + } + return (NSComparisonResult)NSOrderedSame; }]; [rightIconOrder sortUsingComparator:^(RAWindowBarIconInfo *a, RAWindowBarIconInfo *b) { - if (a.priority > b.priority) + if (a.priority > b.priority) { return (NSComparisonResult)NSOrderedDescending; - else if (a.priority < b.priority) + } else if (a.priority < b.priority) { return (NSComparisonResult)NSOrderedAscending; - - return (NSComparisonResult)NSOrderedSame; + } + return (NSComparisonResult)NSOrderedSame; }]; @@ -256,39 +254,37 @@ extern BOOL allowOpenApp; return sizingLockButton; }; - for (RAWindowBarIconInfo *item in leftIconOrder) - { + for (RAWindowBarIconInfo *item in leftIconOrder) { UIButton *button = nil; - if (item.item == closeItemIdentifier) + if (item.item == closeItemIdentifier) { button = createCloseButton(); - else if (item.item == maxItemIdentifier) + } else if (item.item == maxItemIdentifier) { button = createMaxButton(); - else if (item.item == minItemIdentifier) + } else if (item.item == minItemIdentifier) { button = createMinButton(); - else if (item.item == rotationItemIdentifier) + } else if (item.item == rotationItemIdentifier) { button = createRotationButton(); + } - if (button) - { + if (button) { button.frame = CGRectMake(leftSpace, spacing, buttonSize, buttonSize); leftSpace += button.frame.size.width + (THEMED(windowedMultitaskingBarTitleTextInset) ?: 5); } } - for (RAWindowBarIconInfo *item in rightIconOrder) - { + for (RAWindowBarIconInfo *item in rightIconOrder) { UIButton *button = nil; - if (item.item == closeItemIdentifier) + if (item.item == closeItemIdentifier) { button = createCloseButton(); - else if (item.item == maxItemIdentifier) + } else if (item.item == maxItemIdentifier) { button = createMaxButton(); - else if (item.item == minItemIdentifier) + } else if (item.item == minItemIdentifier) { button = createMinButton(); - else if (item.item == rotationItemIdentifier) + } else if (item.item == rotationItemIdentifier) { button = createRotationButton(); + } - if (button) - { + if (button) { button.frame = CGRectMake(rightSpace, spacing, buttonSize, buttonSize); rightSpace -= button.frame.size.width + (THEMED(windowedMultitaskingBarTitleTextInset) ?: 5); } @@ -303,8 +299,7 @@ extern BOOL allowOpenApp; self.layer.mask = maskLayer; } --(void) drawRect:(CGRect)rect -{ +- (void)drawRect:(CGRect)rect { CGRect topRect = CGRectMake(0, 0, rect.size.width, height); // Fill the rectangle with grey [barBackgroundColor setFill]; @@ -313,145 +308,130 @@ extern BOOL allowOpenApp; [super drawRect:rect]; } --(void) close -{ +- (void)close { [RADesktopManager.sharedInstance removeAppWithIdentifier:self.attachedView.bundleIdentifier animated:YES]; } --(void) maximize -{ +- (void)maximize { allowOpenApp = YES; - if ([%c(SBUIController) respondsToSelector:@selector(activateApplicationAnimated:)]) + if ([%c(SBUIController) respondsToSelector:@selector(activateApplicationAnimated:)]) { [[%c(SBUIController) sharedInstance] activateApplicationAnimated:attachedView.app]; - else + } else { [[%c(SBUIController) sharedInstance] activateApplication:attachedView.app]; + } allowOpenApp = NO; } --(void) minimize -{ +- (void)minimize { [attachedView rotateToOrientation:UIInterfaceOrientationPortrait]; [UIView animateWithDuration:0.7 animations:^{ self.transform = CGAffineTransformMakeScale(0.25, 0.25); }]; } --(void) closeButtonTap:(id)arg1 -{ +- (void)closeButtonTap:(id)arg1 { [self close]; } --(void) maximizeButtonTap:(id)arg1 -{ +- (void)maximizeButtonTap:(id)arg1 { [self maximize]; } --(void) minimizeButtonTap:(id)arg1 -{ +- (void)minimizeButtonTap:(id)arg1 { [self minimize]; } --(void) saveWindowInfo -{ +- (void)saveWindowInfo { [RAWindowStatePreservationSystemManager.sharedInstance saveWindowInformation:self]; - if (self.desktop) - { + if (self.desktop) { [self.desktop saveInfo]; } } --(BOOL) isLocked -{ - if ([RASettings.sharedInstance windowRotationLockMode] == 0) - { +- (BOOL)isLocked { + if ([RASettings.sharedInstance windowRotationLockMode] == 0) { return sizingLocked; - } - else - { + } else { return appRotationLocked; } } --(void) sizingLockButtonTap:(id)arg1 -{ - if ([RASettings.sharedInstance windowRotationLockMode] == 0) - { +- (void)sizingLockButtonTap:(id)arg1 { + if ([RASettings.sharedInstance windowRotationLockMode] == 0) { sizingLocked = !sizingLocked; - } - else - { + } else { appRotationLocked = !appRotationLocked; } - if (sizingLocked || appRotationLocked) - { + if (sizingLocked || appRotationLocked) { [sizingLockButton setImage:[RAResourceImageProvider imageForFilename:@"Lock" size:CGSizeMake(16, 16) tintedTo:THEMED(windowedMultitaskingRotationIconTint)] forState:UIControlStateNormal]; - } - else - { + } else { [sizingLockButton setImage:[RAResourceImageProvider imageForFilename:@"Unlocked" size:CGSizeMake(16, 16) tintedTo:THEMED(windowedMultitaskingRotationIconTint)] forState:UIControlStateNormal]; [self updateClientRotation]; } } --(void) scaleTo:(CGFloat)scale animated:(BOOL)animate -{ +- (void)scaleTo:(CGFloat)scale animated:(BOOL)animate { [self scaleTo:scale animated:animate derotate:NO]; } --(void) scaleTo:(CGFloat)scale animated:(BOOL)animate derotate:(BOOL)derotate -{ +- (void)scaleTo:(CGFloat)scale animated:(BOOL)animate derotate:(BOOL)derotate { CGFloat rotation = atan2(self.transform.b, self.transform.a); CGAffineTransform transform = CGAffineTransformMakeScale(scale, scale); - if (!derotate) + if (!derotate) { transform = CGAffineTransformRotate(transform, rotation); + } - if (animate) + if (animate) { [UIView animateWithDuration:0.2 animations:^{ - [self setTransform:transform]; - }]; - else + [self setTransform:transform]; + }]; + } else { [self setTransform:transform]; + } [self saveWindowInfo]; } --(void) addRotation:(CGFloat)rads updateApp:(BOOL)update -{ - if (sizingLocked) +- (void)addRotation:(CGFloat)rads updateApp:(BOOL)update { + if (sizingLocked) { return; + } - if (rads != 0) + if (rads != 0) { self.transform = CGAffineTransformRotate(self.transform, rads); + } - if (update) - { + if (update) { CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); CGFloat rotateSnapDegrees = 0; - if (currentRotation < 0) + if (currentRotation < 0) { currentRotation = 360 + currentRotation; + } - if (currentRotation >= 315 || currentRotation <= 45) + if (currentRotation >= 315 || currentRotation <= 45) { rotateSnapDegrees = 360 - currentRotation; - else if (currentRotation > 45 && currentRotation <= 135) + } else if (currentRotation > 45 && currentRotation <= 135) { rotateSnapDegrees = 90 - currentRotation; - else if (currentRotation > 135 && currentRotation <= 215) + } else if (currentRotation > 135 && currentRotation <= 215) { rotateSnapDegrees = 180 - currentRotation; - else + } else { rotateSnapDegrees = 270 - currentRotation; + } - if ([RASettings.sharedInstance snapRotation]) - [UIView animateWithDuration:0.2 animations:^{ - self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(rotateSnapDegrees)); - }]; + if ([RASettings.sharedInstance snapRotation]) { + [UIView animateWithDuration:0.2 animations:^{ + self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(rotateSnapDegrees)); + }]; + } - if (!appRotationLocked) - [attachedView rotateToOrientation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; + if (!appRotationLocked) { + [attachedView rotateToOrientation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; + } - if ([RASettings.sharedInstance snapWindows] && [RAWindowSnapDataProvider shouldSnapWindow:self]) - { + if ([RASettings.sharedInstance snapWindows] && [RAWindowSnapDataProvider shouldSnapWindow:self]) { [RAWindowSnapDataProvider snapWindow:self toLocation:[RAWindowSnapDataProvider snapLocationForWindow:self] animated:YES]; isSnapped = YES; } @@ -460,70 +440,59 @@ extern BOOL allowOpenApp; } } --(void) updateClientRotation -{ - if (!appRotationLocked) - { - CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); - [self updateClientRotation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; +- (void)updateClientRotation { + if (appRotationLocked) { + return; } + CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); + [self updateClientRotation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; } --(void) updateClientRotation:(UIInterfaceOrientation)orientation -{ - if (!appRotationLocked) - { - CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); - [attachedView rotateToOrientation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; +- (void)updateClientRotation:(UIInterfaceOrientation)orientation { + if (appRotationLocked) { + return; } + CGFloat currentRotation = RADIANS_TO_DEGREES(atan2(self.transform.b, self.transform.a)); + [attachedView rotateToOrientation:[self.desktop appOrientationRelativeToThisOrientation:currentRotation]]; } --(void) disableLongPress -{ +- (void)disableLongPress { enableLongPress = NO; longPressGesture.enabled = NO; longPressGesture.enabled = YES; } --(void) enableLongPress -{ +- (void)enableLongPress { enableLongPress = YES; } --(void) swapOrientationButtonTap:(id)arg1 -{ +- (void)swapOrientationButtonTap:(id)arg1 { [self addRotation:DEGREES_TO_RADIANS(90) updateApp:YES]; } -- (void)handleRotate:(UIRotationGestureRecognizer *)gesture -{ - if (![RASettings.sharedInstance alwaysEnableGestures] && !self.isOverlayShowing) +- (void)handleRotate:(UIRotationGestureRecognizer *)gesture { + if (![RASettings.sharedInstance alwaysEnableGestures] && !self.isOverlayShowing) { return; + } - if (gesture.state == UIGestureRecognizerStateChanged) - { + if (gesture.state == UIGestureRecognizerStateChanged) { [self addRotation:gesture.rotation updateApp:NO]; //[self setTransform:CGAffineTransformRotate(self.transform, gesture.rotation)]; gesture.rotation = 0.0; - } - else if (gesture.state == UIGestureRecognizerStateEnded) - { + } else if (gesture.state == UIGestureRecognizerStateEnded) { [self addRotation:0 updateApp:YES]; } } --(void) handleLongPress:(UILongPressGestureRecognizer*)sender -{ - if (!enableLongPress) - { +- (void)handleLongPress:(UILongPressGestureRecognizer*)sender { + if (!enableLongPress) { return; } [self close]; } --(void) showOverlay -{ +- (void)showOverlay { RAWindowOverlayView *overlay = [[RAWindowOverlayView alloc] initWithFrame:CGRectMake(0, height, self.bounds.size.width, self.bounds.size.height - height)]; overlay.alpha = 0; overlay.tag = 465982; @@ -540,8 +509,7 @@ extern BOOL allowOpenApp; }]; } --(void) hideOverlay -{ +- (void)hideOverlay { [(RAWindowOverlayView*)[self viewWithTag:465982] dismiss]; [UIView animateWithDuration:0.5 animations:^{ closeButton.alpha = 1; @@ -551,52 +519,47 @@ extern BOOL allowOpenApp; }]; } --(BOOL) isOverlayShowing { return [self viewWithTag:465982] != nil; } +- (BOOL)isOverlayShowing { + return [self viewWithTag:465982] != nil; +} --(void) handleTap:(UITapGestureRecognizer*)tap -{ - if (!self.isOverlayShowing) - [self showOverlay]; +- (void)handleTap:(UITapGestureRecognizer*)tap { + if (self.isOverlayShowing) { + return; + } + [self showOverlay]; } --(void) handleDoubleTap:(UITapGestureRecognizer*)tap -{ +- (void)handleDoubleTap:(UITapGestureRecognizer*)tap { [attachedView rotateToOrientation:UIInterfaceOrientationPortrait]; [UIView animateWithDuration:0.7 animations:^{ self.transform = CGAffineTransformMakeScale(0.6, 0.6); }]; } --(void) handleTripleTap:(UITapGestureRecognizer*)tap -{ - if (IS_IPAD) - [RAMessagingServer.sharedInstance forcePhoneMode:![RAFakePhoneMode shouldFakeForAppWithIdentifier:attachedView.app.bundleIdentifier] forIdentifier:attachedView.app.bundleIdentifier andRelaunchApp:YES]; +- (void)handleTripleTap:(UITapGestureRecognizer*)tap { + if (!IS_IPAD) { + return; + } + [RAMessagingServer.sharedInstance forcePhoneMode:![RAFakePhoneMode shouldFakeForAppWithIdentifier:attachedView.app.bundleIdentifier] forIdentifier:attachedView.app.bundleIdentifier andRelaunchApp:YES]; } --(void) handlePan:(UIPanGestureRecognizer*)sender -{ - if (!enableDrag) - { +- (void)handlePan:(UIPanGestureRecognizer*)sender { + if (!enableDrag) { [self removePotentialSnapShadow]; return; } - if (sender.state == UIGestureRecognizerStateBegan) - { + if (sender.state == UIGestureRecognizerStateBegan) { [self.superview bringSubviewToFront:self]; initialPoint = sender.view.center; - } - else if (sender.state == UIGestureRecognizerStateChanged) - { + } else if (sender.state == UIGestureRecognizerStateChanged) { enableLongPress = NO; - } - else if (sender.state == UIGestureRecognizerStateEnded) - { + } else if (sender.state == UIGestureRecognizerStateEnded) { enableLongPress = YES; [self saveWindowInfo]; - if ([RASettings.sharedInstance snapWindows] && [RAWindowSnapDataProvider shouldSnapWindow:self]) - { + if ([RASettings.sharedInstance snapWindows] && [RAWindowSnapDataProvider shouldSnapWindow:self]) { [RAWindowSnapDataProvider snapWindow:self toLocation:[RAWindowSnapDataProvider snapLocationForWindow:self] animated:YES completion:^{ [self removePotentialSnapShadow]; [self saveWindowInfo]; @@ -606,9 +569,9 @@ extern BOOL allowOpenApp; tapGesture.enabled = NO; tapGesture.enabled = YES; return; - } - else + } else { [self removePotentialSnapShadow]; + } return; } @@ -622,26 +585,27 @@ extern BOOL allowOpenApp; [self updatePotentialSnapShadow]; } -- (void)handlePinch:(UIPinchGestureRecognizer *)gesture -{ - if (![RASettings.sharedInstance alwaysEnableGestures] && !self.isOverlayShowing) +- (void)handlePinch:(UIPinchGestureRecognizer *)gesture { + if (![RASettings.sharedInstance alwaysEnableGestures] && !self.isOverlayShowing) { return; + } switch (gesture.state) { - case UIGestureRecognizerStateBegan: - enableDrag = NO; enableLongPress = NO; - break; - case UIGestureRecognizerStateChanged: - [self setTransform:CGAffineTransformScale(self.transform, gesture.scale, gesture.scale)]; - //self.bounds = (CGRect){ self.bounds.origin, {self.bounds.size.width * gesture.scale, self.bounds.size.height * gesture.scale} }; + case UIGestureRecognizerStateBegan: { + enableDrag = NO; enableLongPress = NO; + break; + } + case UIGestureRecognizerStateChanged: { + [self setTransform:CGAffineTransformScale(self.transform, gesture.scale, gesture.scale)]; + //self.bounds = (CGRect){ self.bounds.origin, {self.bounds.size.width * gesture.scale, self.bounds.size.height * gesture.scale} }; - gesture.scale = 1.0; - break; - case UIGestureRecognizerStateEnded: + gesture.scale = 1.0; + break; + } + case UIGestureRecognizerStateEnded: { enableDrag = YES; enableLongPress = YES; - if ([RAWindowSnapDataProvider shouldSnapWindow:self]) - { + if ([RAWindowSnapDataProvider shouldSnapWindow:self]) { [RAWindowSnapDataProvider snapWindow:self toLocation:[RAWindowSnapDataProvider snapLocationForWindow:self] animated:YES]; isSnapped = YES; // Force tap to fail @@ -650,14 +614,14 @@ extern BOOL allowOpenApp; return; } [self saveWindowInfo]; - break; + break; + } default: break; } } --(void) setTransform:(CGAffineTransform)trans -{ +- (void)setTransform:(CGAffineTransform)trans { CGFloat scale = sqrt(trans.a * trans.a + trans.c * trans.c); CGFloat max = 1.0; scale = MIN(max, MAX(0.15, scale)); @@ -666,40 +630,21 @@ extern BOOL allowOpenApp; [super setTransform:trans]; - if (!isBeingTouched) - { - if ([RAWindowSnapDataProvider shouldSnapWindow:self]) - [RAWindowSnapDataProvider snapWindow:self toLocation:[RAWindowSnapDataProvider snapLocationForWindow:self] animated:YES]; - - /*CGPoint origin = self.frame.origin; - CGPoint endPoint = CGPointMake(origin.x + self.frame.size.width, origin.y + self.frame.size.height); - - if (endPoint.x > self.desktop.frame.size.width) - origin.x -= (endPoint.x - self.desktop.frame.size.width); - if (endPoint.y > self.desktop.frame.size.height) - origin.y -= (endPoint.y - self.desktop.frame.size.height); - - if (origin.x < 0) - origin.x = 0; - if (origin.y < 0) - origin.y = 0; - - CGRect adjustedFrame = CGRectMake(origin.x, origin.y, self.frame.size.width, self.frame.size.height); - self.frame = adjustedFrame;*/ - + if (!isBeingTouched && [RAWindowSnapDataProvider shouldSnapWindow:self]) { + [RAWindowSnapDataProvider snapWindow:self toLocation:[RAWindowSnapDataProvider snapLocationForWindow:self] animated:YES]; } } --(void) updatePotentialSnapShadow -{ - if (![RASettings.sharedInstance snapWindows]) +- (void)updatePotentialSnapShadow { + if (![RASettings.sharedInstance snapWindows]) { return; + } - if (![RASettings.sharedInstance showSnapHelper]) + if (![RASettings.sharedInstance showSnapHelper]) { return; + } - if (!snapShadowView) - { + if (!snapShadowView) { snapShadowView = [[UIView alloc] initWithFrame:self.bounds]; snapShadowView.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.1]; // [UIColor.blackColor colorWithAlphaComponent:0.5]; snapShadowView.layer.borderColor = [UIColor whiteColor].CGColor; @@ -714,75 +659,68 @@ extern BOOL allowOpenApp; [self.superview insertSubview:snapShadowView belowSubview:self]; } - if ([RAWindowSnapDataProvider shouldSnapWindow:self]) - { + if ([RAWindowSnapDataProvider shouldSnapWindow:self]) { snapShadowView.hidden = NO; snapShadowView.transform = self.transform; snapShadowView.center = [RAWindowSnapDataProvider snapCenterForWindow:self toLocation:[RAWindowSnapDataProvider snapLocationForWindow:self]]; - } - else - { + } else { snapShadowView.hidden = YES; } } --(void) removePotentialSnapShadow -{ +- (void)removePotentialSnapShadow { [snapShadowView removeFromSuperview]; snapShadowView = nil; } -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { isBeingTouched = YES; RADesktopManager.sharedInstance.lastUsedWindow = self; } -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { isBeingTouched = NO; } --(void) resignForemostApp -{ +- (void)resignForemostApp { titleLabel.font = [UIFont systemFontOfSize:18]; } --(void) becomeForemostApp -{ +- (void)becomeForemostApp { titleLabel.font = [UIFont boldSystemFontOfSize:20]; [self.superview bringSubviewToFront:self]; } --(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event -{ +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { NSEnumerator *objects = [self.subviews reverseObjectEnumerator]; UIView *subview; - while ((subview = [objects nextObject])) - { + while (subview = [objects nextObject]) { UIView *success = [subview hitTest:[self convertPoint:point toView:subview] withEvent:event]; - if (success) - return success; + if (success) { + return success; + } } return [super hitTest:point withEvent:event]; } -- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event -{ +- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { BOOL isContained = NO; - for (UIView *view in self.subviews) - { - if (CGRectContainsPoint(view.frame, point) || CGRectContainsPoint(view.frame, [view convertPoint:point fromView:self])) // [self convertPoint:point toView:view])) + for (UIView *view in self.subviews) { + if (CGRectContainsPoint(view.frame, point) || CGRectContainsPoint(view.frame, [view convertPoint:point fromView:self])) { // [self convertPoint:point toView:view])) isContained = YES; + } } return isContained || [super pointInside:point withEvent:event]; } -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer -{ - if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { + if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { return NO; + } return YES; } --(RAHostedAppView*) attachedView { return attachedView; } + +- (RAHostedAppView*)attachedView { + return attachedView; +} @end diff --git a/WindowedMultitasking/RAWindowOverlayView.h b/WindowedMultitasking/RAWindowOverlayView.h index b99039d..a6e1030 100644 --- a/WindowedMultitasking/RAWindowOverlayView.h +++ b/WindowedMultitasking/RAWindowOverlayView.h @@ -3,6 +3,6 @@ @interface RAWindowOverlayView : UIView @property (nonatomic, weak) RAWindowBar *appWindow; --(void) show; --(void) dismiss; -@end \ No newline at end of file +- (void)show; +- (void)dismiss; +@end diff --git a/WindowedMultitasking/RAWindowOverlayView.xm b/WindowedMultitasking/RAWindowOverlayView.xm index 0f70783..64202e5 100644 --- a/WindowedMultitasking/RAWindowOverlayView.xm +++ b/WindowedMultitasking/RAWindowOverlayView.xm @@ -12,8 +12,7 @@ @end @implementation RAWindowOverlayView --(void) show -{ +- (void)show { probablyAnimating = NO; UIVisualEffect *effect = [UIBlurEffect effectWithStyle:THEMED(windowedMultitaskingBlurStyle)]; @@ -96,20 +95,17 @@ rotationLockButton.layer.cornerRadius = buttonSize/2; [self addSubview:rotationLockButton]; - if (self.appWindow.isLocked) - { + if (self.appWindow.isLocked) { [rotationLockButton setImage:[RAResourceImageProvider imageForFilename:@"Lock" size:CGSizeMake(imageSize, imageSize) tintedTo:THEMED(windowedMultitaskingRotationIconOverlayColor)] forState:UIControlStateNormal]; - } - else - { + } else { [rotationLockButton setImage:[RAResourceImageProvider imageForFilename:@"Unlocked" size:CGSizeMake(imageSize, imageSize) tintedTo:THEMED(windowedMultitaskingRotationIconOverlayColor)] forState:UIControlStateNormal]; } } -- (void) buttonPress:(UIButton*)button -{ - if ([RASettings.sharedInstance windowedMultitaskingCompleteAnimations]) +- (void)buttonPress:(UIButton*)button { + if ([RASettings.sharedInstance windowedMultitaskingCompleteAnimations]) { probablyAnimating = YES; + } //[UIView animateWithDuration:0.2 animations:^{ // button.transform = CGAffineTransformMakeScale(1.1, 1.1); //}]; @@ -124,19 +120,19 @@ sizeAnimation.duration = 0.5f; sizeAnimation.numberOfBounces = 2; sizeAnimation.shouldOvershoot = YES; - + [button.layer addAnimation:sizeAnimation forKey:@"bliss"]; [button.layer setValue:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1, 1.1, 1.0)] forKeyPath:@"transform"]; - + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ probablyAnimating = NO; }); } -- (void) buttonRelease:(UIButton*)button -{ - if ([RASettings.sharedInstance windowedMultitaskingCompleteAnimations]) +- (void)buttonRelease:(UIButton*)button { + if ([RASettings.sharedInstance windowedMultitaskingCompleteAnimations]) { probablyAnimating = YES; + } //[UIView animateWithDuration:0.2 animations:^{ // button.transform = CGAffineTransformMakeScale(1, 1); //}]; @@ -149,7 +145,7 @@ sizeAnimation.duration = 0.3f; sizeAnimation.numberOfBounces = 2; sizeAnimation.shouldOvershoot = YES; - + [button.layer addAnimation:sizeAnimation forKey:@"bliss"]; [button.layer setValue:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1)] forKeyPath:@"transform"]; @@ -160,13 +156,11 @@ }); } --(void) dismiss_ -{ +- (void)dismiss_ { [self.appWindow hideOverlay]; } --(void) dismiss -{ +- (void)dismiss { [UIView animateWithDuration:0.5 animations:^{ self.alpha = 0; } completion:^(BOOL _) { @@ -174,40 +168,36 @@ }]; } --(void) closeButtonTap -{ - if (probablyAnimating) +- (void)closeButtonTap { + if (probablyAnimating) { [self performSelector:@selector(closeButtonTap) withObject:nil afterDelay:0.1]; - else + } else { [self.appWindow close]; + } } --(void) maximizeButtonTap -{ - if (probablyAnimating) +- (void)maximizeButtonTap { + if (probablyAnimating) { [self performSelector:@selector(maximizeButtonTap) withObject:nil afterDelay:0.1]; - else + } else { [self.appWindow maximize]; + } } --(void) minimizeButtonTap -{ - if (probablyAnimating) +- (void)minimizeButtonTap { + if (probablyAnimating) { [self performSelector:@selector(minimizeButtonTap) withObject:nil afterDelay:0.1]; - else + } else { [self.appWindow minimize]; + } } --(void) rotationLockButtonTap -{ +- (void)rotationLockButtonTap { [self.appWindow sizingLockButtonTap:nil]; - if (self.appWindow.isLocked) - { + if (self.appWindow.isLocked) { [rotationLockButton setImage:[RAResourceImageProvider imageForFilename:@"Lock" size:CGSizeMake(imageSize, imageSize) tintedTo:THEMED(windowedMultitaskingRotationIconOverlayColor)] forState:UIControlStateNormal]; - } - else - { + } else { [rotationLockButton setImage:[RAResourceImageProvider imageForFilename:@"Unlocked" size:CGSizeMake(imageSize, imageSize) tintedTo:THEMED(windowedMultitaskingRotationIconOverlayColor)] forState:UIControlStateNormal]; } } diff --git a/WindowedMultitasking/RAWindowSnapDataProvider.h b/WindowedMultitasking/RAWindowSnapDataProvider.h index 111e2cc..ecb80ce 100644 --- a/WindowedMultitasking/RAWindowSnapDataProvider.h +++ b/WindowedMultitasking/RAWindowSnapDataProvider.h @@ -25,11 +25,11 @@ typedef NS_ENUM(NSInteger, RAWindowSnapLocation) { }; @interface RAWindowSnapDataProvider : NSObject -+(BOOL) shouldSnapWindow:(RAWindowBar*)bar; -+(RAWindowSnapLocation) snapLocationForWindow:(RAWindowBar*)windowBar; -+(CGPoint) snapCenterForWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location; -+(void) snapWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location animated:(BOOL)animated; -+(void) snapWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location animated:(BOOL)animated completion:(dispatch_block_t)completionBlock; ++ (BOOL)shouldSnapWindow:(RAWindowBar*)bar; ++ (RAWindowSnapLocation)snapLocationForWindow:(RAWindowBar*)windowBar; ++ (CGPoint)snapCenterForWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location; ++ (void)snapWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location animated:(BOOL)animated; ++ (void)snapWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location animated:(BOOL)animated completion:(dispatch_block_t)completionBlock; @end RAWindowSnapLocation RAWindowSnapLocationGetLeftOfScreen(); diff --git a/WindowedMultitasking/RAWindowSnapDataProvider.xm b/WindowedMultitasking/RAWindowSnapDataProvider.xm index 31937cd..b5c85b6 100644 --- a/WindowedMultitasking/RAWindowSnapDataProvider.xm +++ b/WindowedMultitasking/RAWindowSnapDataProvider.xm @@ -1,13 +1,11 @@ #import "RAWindowSnapDataProvider.h" @implementation RAWindowSnapDataProvider -+(BOOL) shouldSnapWindow:(RAWindowBar*)bar -{ ++ (BOOL)shouldSnapWindow:(RAWindowBar*)bar { return [RAWindowSnapDataProvider snapLocationForWindow:bar] != RAWindowSnapLocationInvalid; } -+(RAWindowSnapLocation) snapLocationForWindow:(RAWindowBar*)windowBar -{ ++ (RAWindowSnapLocation)snapLocationForWindow:(RAWindowBar*)windowBar { CGRect location = windowBar.frame; // Convienence values @@ -39,70 +37,82 @@ bottomRight.x += location.size.width / 2; bottomRight.y += location.size.height / 2; //bottomRight = CGPointApplyAffineTransform(bottomRight, theView.transform); - + // I am not proud of the below jumps, however i do believe it is the best solution to the problem apart from making weird blocks, which would be a considerable amount of work. BOOL didLeft = NO; BOOL didRight = NO; - if (topLeft.x > bottomLeft.x) + if (topLeft.x > bottomLeft.x) { goto try_right; + } - if (topLeft.y > bottomLeft.y) + if (topLeft.y > bottomLeft.y) { goto try_bottom; + } try_left: didLeft = YES; // Left - if (location.origin.x < leftXBuffer && location.origin.y < height / 8) + if (location.origin.x < leftXBuffer && location.origin.y < height / 8) { return RAWindowSnapLocationLeftTop; - if (location.origin.x < leftXBuffer && (location.origin.y >= twoThirdsHeight || location.origin.y + location.size.height > height)) + } + if (location.origin.x < leftXBuffer && (location.origin.y >= twoThirdsHeight || location.origin.y + location.size.height > height)) { return RAWindowSnapLocationLeftBottom; - if (location.origin.x < leftXBuffer && location.origin.y >= height / 8 && location.origin.y < twoThirdsHeight) + } + if (location.origin.x < leftXBuffer && location.origin.y >= height / 8 && location.origin.y < twoThirdsHeight) { return RAWindowSnapLocationLeftMiddle; + } try_right: didRight = YES; // Right - if (location.origin.x + location.size.width > rightXBuffer && location.origin.y < height / 8) + if (location.origin.x + location.size.width > rightXBuffer && location.origin.y < height / 8) { return RAWindowSnapLocationRightTop; - if (location.origin.x + location.size.width > rightXBuffer && (location.origin.y >= twoThirdsHeight || location.origin.y + location.size.height > height)) + } + if (location.origin.x + location.size.width > rightXBuffer && (location.origin.y >= twoThirdsHeight || location.origin.y + location.size.height > height)) { return RAWindowSnapLocationRightBottom; - if (location.origin.x + location.size.width > rightXBuffer && location.origin.y >= height / 8 && location.origin.y < twoThirdsHeight) + } + if (location.origin.x + location.size.width > rightXBuffer && location.origin.y >= height / 8 && location.origin.y < twoThirdsHeight) { return RAWindowSnapLocationRightMiddle; + } - if (!didLeft) + if (!didLeft) { goto try_left; - else if (!didRight) + } else if (!didRight) { goto try_right; + } try_bottom: // Jumps through this off slightly, so we re-check (which may or may not actually be needed, depending on the path it takes) - if (location.origin.x + location.size.width > rightXBuffer && (location.origin.y >= twoThirdsHeight || location.origin.y + location.size.height > height)) + if (location.origin.x + location.size.width > rightXBuffer && (location.origin.y >= twoThirdsHeight || location.origin.y + location.size.height > height)) { return RAWindowSnapLocationRightBottom; - if (location.origin.x < leftXBuffer && (location.origin.y >= twoThirdsHeight || location.origin.y + location.size.height > height)) + } + if (location.origin.x < leftXBuffer && (location.origin.y >= twoThirdsHeight || location.origin.y + location.size.height > height)) { return RAWindowSnapLocationLeftBottom; - - if (location.origin.y + location.size.height > bottomBuffer) + } + if (location.origin.y + location.size.height > bottomBuffer) { return RAWindowSnapLocationBottom; + } //try_top: - if (location.origin.y < 20 + 25) + if (location.origin.y < 20 + 25) { return RAWindowSnapLocationTop; + } // Second time possible verify - if (!didLeft) + if (!didLeft) { goto try_left; - else if (!didRight) + } else if (!didRight) { goto try_right; + } return RAWindowSnapLocationNone; } -+(CGPoint) snapCenterForWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location -{ ++ (CGPoint)snapCenterForWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location { // Convienence values CGFloat width = UIScreen.mainScreen._referenceBounds.size.width; CGFloat height = UIScreen.mainScreen._referenceBounds.size.height; @@ -113,70 +123,63 @@ try_bottom: BOOL adjustStatusBar = NO; - switch (location) - { - case RAWindowSnapLocationLeftTop: + switch (location) { + case RAWindowSnapLocationLeftTop: { newCenter = CGPointMake(frame.size.width / 2, (frame.size.height / 2) + 20); adjustStatusBar = YES; break; + } case RAWindowSnapLocationLeftMiddle: newCenter.x = frame.size.width / 2; break; case RAWindowSnapLocationLeftBottom: newCenter = CGPointMake(frame.size.width / 2, height - (frame.size.height / 2)); break; - - case RAWindowSnapLocationRightTop: + case RAWindowSnapLocationRightTop: { newCenter = CGPointMake(width - (frame.size.width / 2), (frame.size.height / 2) + 20); adjustStatusBar = YES; break; + } case RAWindowSnapLocationRightMiddle: newCenter.x = width - (frame.size.width / 2); break; case RAWindowSnapLocationRightBottom: newCenter = CGPointMake(width - (frame.size.width / 2), height - (frame.size.height / 2)); break; - - case RAWindowSnapLocationTop: + case RAWindowSnapLocationTop: { newCenter.y = (frame.size.height / 2) + 20; adjustStatusBar = YES; break; + } case RAWindowSnapLocationBottom: newCenter.y = height - (frame.size.height / 2); break; - - case RAWindowSnapLocationBottomCenter: + case RAWindowSnapLocationBottomCenter: { newCenter.x = width / 2.0; newCenter.y = height - (frame.size.height / 2); break; - + } case RAWindowSnapLocationInvalid: default: break; } - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight && adjustStatusBar) - { + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight && adjustStatusBar) { newCenter.y -= 20; } - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight && (location == RAWindowSnapLocationRightMiddle || location == RAWindowSnapLocationRightBottom || location == RAWindowSnapLocationRightTop)) - { + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeRight && (location == RAWindowSnapLocationRightMiddle || location == RAWindowSnapLocationRightBottom || location == RAWindowSnapLocationRightTop)) { newCenter.x -= 20; - } - else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft && adjustStatusBar) - { + } else if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft && adjustStatusBar) { newCenter.y -= 20; } - if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft && (location == RAWindowSnapLocationLeftMiddle || location == RAWindowSnapLocationLeftBottom || location == RAWindowSnapLocationLeftTop)) - { + if (UIApplication.sharedApplication.statusBarOrientation == UIInterfaceOrientationLandscapeLeft && (location == RAWindowSnapLocationLeftMiddle || location == RAWindowSnapLocationLeftBottom || location == RAWindowSnapLocationLeftTop)) { newCenter.x += 20; } return newCenter; } -+(void) snapWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location animated:(BOOL)animated -{ ++ (void)snapWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location animated:(BOOL)animated { /* // Convienence values CGFloat width = UIScreen.mainScreen.bounds.size.width; @@ -233,32 +236,28 @@ try_bottom: [self snapWindow:window toLocation:location animated:animated completion:nil]; } -+(void) snapWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location animated:(BOOL)animated completion:(dispatch_block_t)completionBlock -{ ++ (void)snapWindow:(RAWindowBar*)window toLocation:(RAWindowSnapLocation)location animated:(BOOL)animated completion:(dispatch_block_t)completionBlock { CGPoint newCenter = [RAWindowSnapDataProvider snapCenterForWindow:window toLocation:location]; - if (animated) - { + if (animated) { [UIView animateWithDuration:0.2 animations:^{ window.center = newCenter; } completion:^(BOOL _) { - if (completionBlock) + if (completionBlock) { completionBlock(); + } }]; - } - else - { + } else { window.center = newCenter; - if (completionBlock) + if (completionBlock) { completionBlock(); + } } } @end -RAWindowSnapLocation RAWindowSnapLocationGetLeftOfScreen() -{ - switch (UIApplication.sharedApplication.statusBarOrientation) - { +RAWindowSnapLocation RAWindowSnapLocationGetLeftOfScreen() { + switch (UIApplication.sharedApplication.statusBarOrientation) { case UIInterfaceOrientationPortrait: return RAWindowSnapLocationLeft; case UIInterfaceOrientationLandscapeRight: @@ -271,10 +270,8 @@ RAWindowSnapLocation RAWindowSnapLocationGetLeftOfScreen() return RAWindowSnapLocationLeft; } -RAWindowSnapLocation RAWindowSnapLocationGetRightOfScreen() -{ - switch (UIApplication.sharedApplication.statusBarOrientation) - { +RAWindowSnapLocation RAWindowSnapLocationGetRightOfScreen() { + switch (UIApplication.sharedApplication.statusBarOrientation) { case UIInterfaceOrientationPortrait: return RAWindowSnapLocationRight; case UIInterfaceOrientationLandscapeRight: @@ -286,4 +283,3 @@ RAWindowSnapLocation RAWindowSnapLocationGetRightOfScreen() } return RAWindowSnapLocationRight; } - diff --git a/WindowedMultitasking/RAWindowSorter.h b/WindowedMultitasking/RAWindowSorter.h index 268c9db..b549c1a 100644 --- a/WindowedMultitasking/RAWindowSorter.h +++ b/WindowedMultitasking/RAWindowSorter.h @@ -1,5 +1,5 @@ #import "RADesktopWindow.h" @interface RAWindowSorter : NSObject -+(void) sortWindowsOnDesktop:(RADesktopWindow*)desktop resizeIfNecessary:(BOOL)resize; -@end \ No newline at end of file ++ (void)sortWindowsOnDesktop:(RADesktopWindow*)desktop resizeIfNecessary:(BOOL)resize; +@end diff --git a/WindowedMultitasking/RAWindowSorter.xm b/WindowedMultitasking/RAWindowSorter.xm index 044a18e..4f47532 100644 --- a/WindowedMultitasking/RAWindowSorter.xm +++ b/WindowedMultitasking/RAWindowSorter.xm @@ -4,46 +4,42 @@ #import "RAWindowSnapDataProvider.h" @implementation RAWindowSorter -+(void) sortWindowsOnDesktop:(RADesktopWindow*)desktop resizeIfNecessary:(BOOL)resize -{ ++ (void)sortWindowsOnDesktop:(RADesktopWindow*)desktop resizeIfNecessary:(BOOL)resize { NSInteger numberOfWindows = desktop.hostedWindows.count; - if (numberOfWindows == 0) + if (numberOfWindows == 0) { return; + } NSMutableArray *windows = [NSMutableArray array]; - for (UIView *view in desktop.subviews) - if ([view isKindOfClass:[RAWindowBar class]]) + for (UIView *view in desktop.subviews) { + if ([view isKindOfClass:[RAWindowBar class]]) { [windows addObject:view]; + } + } - if (numberOfWindows == 1) - { - if (resize) + if (numberOfWindows == 1) { + if (resize) { [windows[0] scaleTo:0.7 animated:YES derotate:YES]; + } [RAWindowSnapDataProvider snapWindow:windows[0] toLocation:RAWindowSnapLocationLeftTop animated:YES]; - } - else if (numberOfWindows == 2) - { + } else if (numberOfWindows == 2) { RAWindowBar *window1 = windows[0]; RAWindowBar *window2 = windows[1]; - if (resize) - { + if (resize) { [window1 scaleTo:0.5 animated:YES derotate:YES]; [window2 scaleTo:0.5 animated:YES derotate:YES]; } [RAWindowSnapDataProvider snapWindow:window1 toLocation:RAWindowSnapLocationLeftTop animated:YES]; [RAWindowSnapDataProvider snapWindow:window2 toLocation:RAWindowSnapLocationRightTop animated:YES]; - } - else if (numberOfWindows == 3) - { + } else if (numberOfWindows == 3) { RAWindowBar *window1 = windows[0]; RAWindowBar *window2 = windows[1]; RAWindowBar *window3 = windows[2]; - if (resize) - { + if (resize) { [window1 scaleTo:0.5 animated:YES derotate:YES]; [window2 scaleTo:0.5 animated:YES derotate:YES]; [window3 scaleTo:0.4 animated:YES derotate:YES]; @@ -52,68 +48,59 @@ [RAWindowSnapDataProvider snapWindow:window1 toLocation:RAWindowSnapLocationLeftTop animated:YES]; [RAWindowSnapDataProvider snapWindow:window2 toLocation:RAWindowSnapLocationRightTop animated:YES]; [RAWindowSnapDataProvider snapWindow:window3 toLocation:RAWindowSnapLocationBottomCenter animated:YES]; - } - else if (NO && numberOfWindows == 4) - { + } else if (NO && numberOfWindows == 4) { RAWindowBar *window1 = windows[0]; RAWindowBar *window2 = windows[1]; RAWindowBar *window3 = windows[2]; RAWindowBar *window4 = windows[3]; - if (resize) - { + if (resize) { [window1 scaleTo:0.45 animated:YES derotate:YES]; [window2 scaleTo:0.45 animated:YES derotate:YES]; [window3 scaleTo:0.45 animated:YES derotate:YES]; [window4 scaleTo:0.45 animated:YES derotate:YES]; } - + [RAWindowSnapDataProvider snapWindow:window1 toLocation:RAWindowSnapLocationLeftTop animated:YES]; [RAWindowSnapDataProvider snapWindow:window2 toLocation:RAWindowSnapLocationRightTop animated:YES]; [RAWindowSnapDataProvider snapWindow:window3 toLocation:RAWindowSnapLocationBottomLeft animated:YES]; [RAWindowSnapDataProvider snapWindow:window4 toLocation:RAWindowSnapLocationBottomRight animated:YES]; - } - else - { - if (resize) - { + } else { + if (resize) { //CGFloat maxScale = 1.0 / numberOfWindows; // (numberOfWindows / 2.0); //CGFloat maxScale = (desktop.frame.size.width / (numberOfWindows/2.0)) / desktop.frame.size.width; CGFloat factor = desktop.frame.size.height - 20; CGFloat maxScale = factor / (ceil(sqrt(numberOfWindows)) * [windows[0] bounds].size.height); - + CGFloat x = 0, y = 0; int panesPerLine = floor(1.0 / maxScale);// (numberOfWindows & ~1) /* round down to nearest even number */ int currentPane = 0; - for (RAWindowBar *bar in windows) - { + for (RAWindowBar *bar in windows) { [bar scaleTo:maxScale animated:YES derotate:YES]; - if (y == 0) // 20 = statusbar + if (y == 0) { // 20 = statusbar y = 20 + (bar.frame.size.height / 2.0); - if (x == 0) + } + if (x == 0) { x = bar.frame.size.width / 2.0; + } bar.center = CGPointMake(x, y); - if (++currentPane == panesPerLine) - { + if (++currentPane == panesPerLine) { currentPane = 0; x = 0; y += bar.frame.size.height; - } - else + } else { x += bar.frame.size.width; + } } } - else - { - - } } - for (RAWindowBar *bar in windows) + for (RAWindowBar *bar in windows) { [bar saveWindowInfo]; + } } -@end \ No newline at end of file +@end diff --git a/WindowedMultitasking/RAWindowStatePreservationSystemManager.h b/WindowedMultitasking/RAWindowStatePreservationSystemManager.h index d15c155..fef145c 100644 --- a/WindowedMultitasking/RAWindowStatePreservationSystemManager.h +++ b/WindowedMultitasking/RAWindowStatePreservationSystemManager.h @@ -15,19 +15,19 @@ typedef struct { @interface RAWindowStatePreservationSystemManager : NSObject { NSMutableDictionary *dict; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(void) loadInfo; --(void) saveInfo; +- (void)loadInfo; +- (void)saveInfo; // Desktop --(void) saveDesktopInformation:(RADesktopWindow*)desktop; --(BOOL) hasDesktopInformationAtIndex:(NSInteger)index; --(RAPreservedDesktopInformation) desktopInformationForIndex:(NSInteger)index; +- (void)saveDesktopInformation:(RADesktopWindow*)desktop; +- (BOOL)hasDesktopInformationAtIndex:(NSInteger)index; +- (RAPreservedDesktopInformation)desktopInformationForIndex:(NSInteger)index; // Window --(void) saveWindowInformation:(RAWindowBar*)window; --(BOOL) hasWindowInformationForIdentifier:(NSString*)appIdentifier; --(RAPreservedWindowInformation) windowInformationForAppIdentifier:(NSString*)identifier; --(void) removeWindowInformationForIdentifier:(NSString*)appIdentifier; +- (void)saveWindowInformation:(RAWindowBar*)window; +- (BOOL)hasWindowInformationForIdentifier:(NSString*)appIdentifier; +- (RAPreservedWindowInformation) windowInformationForAppIdentifier:(NSString*)identifier; +- (void)removeWindowInformationForIdentifier:(NSString*)appIdentifier; @end diff --git a/WindowedMultitasking/RAWindowStatePreservationSystemManager.xm b/WindowedMultitasking/RAWindowStatePreservationSystemManager.xm index 6b0c038..ce977ee 100644 --- a/WindowedMultitasking/RAWindowStatePreservationSystemManager.xm +++ b/WindowedMultitasking/RAWindowStatePreservationSystemManager.xm @@ -5,28 +5,23 @@ #define FILE_PATH @"/User/Library/Preferences/com.efrederickson.empoleon.windowstates.plist" @implementation RAWindowStatePreservationSystemManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RAWindowStatePreservationSystemManager, [sharedInstance loadInfo]); } --(void) loadInfo -{ +- (void)loadInfo { dict = [NSMutableDictionary dictionaryWithContentsOfFile:FILE_PATH] ?: [NSMutableDictionary dictionary]; } --(void) saveInfo -{ +- (void)saveInfo { [dict writeToFile:FILE_PATH atomically:YES]; } --(void) saveDesktopInformation:(RADesktopWindow*)desktop -{ +- (void)saveDesktopInformation:(RADesktopWindow*)desktop { NSUInteger index = [RADesktopManager.sharedInstance.availableDesktops indexOfObject:desktop]; NSString *key = [NSString stringWithFormat:@"%lu",(unsigned long)index]; NSMutableArray *openApps = [NSMutableArray array]; - for (RAHostedAppView *app in desktop.hostedWindows) - { + for (RAHostedAppView *app in desktop.hostedWindows) { [openApps addObject:app.app.bundleIdentifier]; } @@ -35,21 +30,20 @@ [self saveInfo]; } --(BOOL) hasDesktopInformationAtIndex:(NSInteger)index -{ +- (BOOL)hasDesktopInformationAtIndex:(NSInteger)index { NSString *key = [NSString stringWithFormat:@"%lu",(unsigned long)index]; return [dict objectForKey:key] != nil; } --(RAPreservedDesktopInformation) desktopInformationForIndex:(NSInteger)index -{ +- (RAPreservedDesktopInformation)desktopInformationForIndex:(NSInteger)index { RAPreservedDesktopInformation info; info.index = index; NSString *key = [NSString stringWithFormat:@"%lu",(unsigned long)index]; NSMutableArray *apps = [NSMutableArray array]; - for (NSString *ident in dict[key]) + for (NSString *ident in dict[key]) { [apps addObject:ident]; + } info.openApps = apps; @@ -57,8 +51,7 @@ } // Window --(void) saveWindowInformation:(RAWindowBar*)window -{ +- (void)saveWindowInformation:(RAWindowBar*)window { CGPoint center = window.center; CGAffineTransform transform = window.transform; NSString *appIdent = window.attachedView.app.bundleIdentifier; @@ -71,18 +64,17 @@ [self saveInfo]; } --(BOOL) hasWindowInformationForIdentifier:(NSString*)appIdentifier -{ +- (BOOL)hasWindowInformationForIdentifier:(NSString*)appIdentifier { return [dict objectForKey:appIdentifier] != nil; } --(RAPreservedWindowInformation) windowInformationForAppIdentifier:(NSString*)identifier -{ +- (RAPreservedWindowInformation)windowInformationForAppIdentifier:(NSString*)identifier { RAPreservedWindowInformation info = (RAPreservedWindowInformation) { CGPointZero, CGAffineTransformIdentity }; NSDictionary *appInfo = dict[identifier]; - if (!appInfo) + if (!appInfo) { return info; + } info.center = CGPointFromString(appInfo[@"center"]); info.transform = CGAffineTransformFromString(appInfo[@"transform"]); @@ -90,8 +82,7 @@ return info; } --(void) removeWindowInformationForIdentifier:(NSString*)appIdentifier -{ +- (void)removeWindowInformationForIdentifier:(NSString*)appIdentifier { [dict removeObjectForKey:appIdentifier]; [self saveInfo]; } diff --git a/WindowedMultitasking/StartMultitaskingGesture.xm b/WindowedMultitasking/StartMultitaskingGesture.xm index 5dbfac7..5a8f57f 100644 --- a/WindowedMultitasking/StartMultitaskingGesture.xm +++ b/WindowedMultitasking/StartMultitaskingGesture.xm @@ -9,12 +9,12 @@ #import "RAControlCenterInhibitor.h" #import "Multiplexer.h" -BOOL locationIsInValidArea(CGFloat x) -{ - if (x == 0) return YES; // more than likely, UIGestureRecognizerStateEnded +BOOL locationIsInValidArea(CGFloat x) { + if (x == 0) { // more than likely, UIGestureRecognizerStateEnded + return YES; + } - switch ([RASettings.sharedInstance windowedMultitaskingGrabArea]) - { + switch ([RASettings.sharedInstance windowedMultitaskingGrabArea]) { case RAGrabAreaBottomLeftThird: LogDebug(@"[ReachApp] StartMultitaskingGesture: %f %f", x, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width); return x <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 3.0; @@ -27,10 +27,10 @@ BOOL locationIsInValidArea(CGFloat x) } } -%ctor -{ - IF_NOT_SPRINGBOARD - return; +%ctor { + IF_NOT_SPRINGBOARD { + return; + } __weak __block UIView *appView = nil; __block CGFloat lastY = 0; __block CGPoint originalCenter; @@ -40,8 +40,7 @@ BOOL locationIsInValidArea(CGFloat x) // Dismiss potential CC //[[%c(SBUIController) sharedInstance] _showControlCenterGestureEndedWithLocation:CGPointMake(0, UIScreen.mainScreen.bounds.size.height - 1) velocity:CGPointZero]; - if (state == UIGestureRecognizerStateBegan) - { + if (state == UIGestureRecognizerStateBegan) { [RAControlCenterInhibitor setInhibited:YES]; // Show HS/Wallpaper @@ -50,17 +49,15 @@ BOOL locationIsInValidArea(CGFloat x) // Assign view appView = [RAHostManager systemHostViewForApplication:topApp].superview; - if (IS_IOS_OR_NEWER(iOS_9_0)) + if (IS_IOS_OR_NEWER(iOS_9_0)) { appView = appView.superview; + } originalCenter = appView.center; - } - else if (state == UIGestureRecognizerStateChanged) - { + } else if (state == UIGestureRecognizerStateChanged) { lastY = location.y; CGFloat scale = location.y / UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height; - if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) - { + if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) { scale = MIN(MAX(scale, 0.01), 1); CGFloat actualScale = scale; scale = 1 - scale; @@ -83,28 +80,20 @@ BOOL locationIsInValidArea(CGFloat x) appView.center = center; appView.transform = transform; - } - else - { + } else { scale = MIN(MAX(scale, 0.3), 1); appView.transform = CGAffineTransformMakeScale(scale, scale); } - } - else if (state == UIGestureRecognizerStateEnded) - { + } else if (state == UIGestureRecognizerStateEnded) { [RAControlCenterInhibitor setInhibited:NO]; - if (lastY <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 4) * 3 && lastY != 0) // 75% down, 0 == gesture ended in most situations - { + if (lastY <= (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 4) * 3 && lastY != 0) { // 75% down, 0 == gesture ended in most situations [UIView animateWithDuration:.3 animations:^{ - if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) - { + if ([RAWindowStatePreservationSystemManager.sharedInstance hasWindowInformationForIdentifier:topApp.bundleIdentifier]) { RAPreservedWindowInformation info = [RAWindowStatePreservationSystemManager.sharedInstance windowInformationForAppIdentifier:topApp.bundleIdentifier]; appView.center = info.center; appView.transform = info.transform; - } - else - { + } else { appView.transform = CGAffineTransformMakeScale(0.5, 0.5); appView.center = originalCenter; } @@ -124,8 +113,9 @@ BOOL locationIsInValidArea(CGFloat x) // Open in window RAWindowBar *windowBar = [RADesktopManager.sharedInstance.currentDesktop createAppWindowForSBApplication:topApp animated:YES]; - if (!RADesktopManager.sharedInstance.lastUsedWindow) + if (!RADesktopManager.sharedInstance.lastUsedWindow) { RADesktopManager.sharedInstance.lastUsedWindow = windowBar; + } }]; [(FBWorkspaceEventQueue*)[%c(FBWorkspaceEventQueue) sharedInstance] executeOrAppendEvent:event]; [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; @@ -135,9 +125,7 @@ BOOL locationIsInValidArea(CGFloat x) [[%c(RABackgrounder) sharedInstance] removeTemporaryOverrideForIdentifier:topApp.bundleIdentifier]; [[%c(RABackgrounder) sharedInstance] updateIconIndicatorForIdentifier:topApp.bundleIdentifier withInfo:indicatorInfo]; }]; - } - else - { + } else { appView.center = originalCenter; [UIView animateWithDuration:0.2 animations:^{ appView.transform = CGAffineTransformIdentity; } completion:^(BOOL _) { [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; diff --git a/WindowedMultitasking/WindowSorterActivator.xm b/WindowedMultitasking/WindowSorterActivator.xm index 6752355..dfcbed2 100644 --- a/WindowedMultitasking/WindowSorterActivator.xm +++ b/WindowedMultitasking/WindowSorterActivator.xm @@ -11,19 +11,17 @@ static RAActivatorSortWindowsListener *sharedInstance$RAActivatorSortWindowsListener; @implementation RAActivatorSortWindowsListener -- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event -{ +- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event { RADesktopWindow *desktop = RADesktopManager.sharedInstance.currentDesktop; [RAWindowSorter sortWindowsOnDesktop:desktop resizeIfNecessary:YES]; } @end -%ctor -{ - IF_SPRINGBOARD - { - sharedInstance$RAActivatorSortWindowsListener = [[RAActivatorSortWindowsListener alloc] init]; - [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorSortWindowsListener forName:@"com.efrederickson.reachapp.windowedmultitasking.sortWindows"]; +%ctor { + IF_NOT_SPRINGBOARD { + return; } + sharedInstance$RAActivatorSortWindowsListener = [[RAActivatorSortWindowsListener alloc] init]; + [[%c(LAActivator) sharedInstance] registerListener:sharedInstance$RAActivatorSortWindowsListener forName:@"com.efrederickson.reachapp.windowedmultitasking.sortWindows"]; } diff --git a/dispatch_after_cancel.m b/dispatch_after_cancel.m index a6ba379..d8263c5 100644 --- a/dispatch_after_cancel.m +++ b/dispatch_after_cancel.m @@ -1,35 +1,32 @@ #include "dispatch_after_cancel.h" -struct dispatch_async_handle *dispatch_after_cancellable(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t payload) -{ - struct dispatch_async_handle *handle = malloc(sizeof(struct dispatch_async_handle)); +struct dispatch_async_handle *dispatch_after_cancellable(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t payload) { + struct dispatch_async_handle *handle = malloc(sizeof(struct dispatch_async_handle)); - handle->didFire = 0; - handle->shouldCall = 1; // initially, payload should be called - handle->shouldFree = 0; // and handles belong to owner + handle->didFire = 0; + handle->shouldCall = 1; // initially, payload should be called + handle->shouldFree = 0; // and handles belong to owner - dispatch_after(when, queue, ^{ + dispatch_after(when, queue, ^{ - //NSLog(@"[ReachApp][%p] (control block) call=%d, free=%d, didfree=%d", handle, handle->shouldCall, handle->shouldFree, handle->didFree); + //NSLog(@"[ReachApp][%p] (control block) call=%d, free=%d, didfree=%d", handle, handle->shouldCall, handle->shouldFree, handle->didFree); - handle->didFire = 1; - if (handle->shouldCall) payload(); - if (handle->shouldFree && handle->didFree == 0) free(handle); - }); + handle->didFire = 1; + if (handle->shouldCall) payload(); + if (handle->shouldFree && handle->didFree == 0) free(handle); + }); - return handle; // to owner + return handle; // to owner } -void dispatch_after_cancel(struct dispatch_async_handle *handle) -{ - if (handle->didFire && handle->shouldFree == 0) { - //printf("[%p] (owner) too late, freeing myself\n", handle); - handle->didFree = 1; - free(handle); - } - else { - //printf("[%p] (owner) set call=0, free=1\n", handle); - handle->shouldCall = 0; - handle->shouldFree = 1; // control block is owner now - } -} \ No newline at end of file +void dispatch_after_cancel(struct dispatch_async_handle *handle) { + if (handle->didFire && handle->shouldFree == 0) { + //printf("[%p] (owner) too late, freeing myself\n", handle); + handle->didFree = 1; + free(handle); + } else { + //printf("[%p] (owner) set call=0, free=1\n", handle); + handle->shouldCall = 0; + handle->shouldFree = 1; // control block is owner now + } +} diff --git a/headers.h b/headers.h index 95219e4..2b1914d 100644 --- a/headers.h +++ b/headers.h @@ -63,11 +63,12 @@ extern BOOL $__IS_SPRINGBOARD; #define ON_MAIN_THREAD(block) \ { \ - dispatch_block_t _blk = block; \ - if (NSThread.isMainThread) \ - _blk(); \ - else \ - dispatch_sync(dispatch_get_main_queue(), _blk); \ + dispatch_block_t _blk = block; \ + if (NSThread.isMainThread) { \ + _blk(); \ + } else { \ + dispatch_sync(dispatch_get_main_queue(), _blk); \ + } \ } #define IF_SPRINGBOARD if (IS_SPRINGBOARD) diff --git a/reachappassertiondhooks/Tweak.xm b/reachappassertiondhooks/Tweak.xm index eb2ada7..cb73906 100644 --- a/reachappassertiondhooks/Tweak.xm +++ b/reachappassertiondhooks/Tweak.xm @@ -3,10 +3,8 @@ #import %group iOS8 -%hookf(int, BSAuditTokenTaskHasEntitlement, id connection, NSString *entitlement) -{ - if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) - { +%hookf(int, BSAuditTokenTaskHasEntitlement, id connection, NSString *entitlement) { + if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { return true; } @@ -15,10 +13,8 @@ %end %group iOS9andUp -%hookf(int, BSXPCConnectionHasEntitlement, id connection, NSString *entitlement) -{ - if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) - { +%hookf(int, BSXPCConnectionHasEntitlement, id connection, NSString *entitlement) { + if ([entitlement isEqualToString:@"com.apple.multitasking.unlimitedassertions"]) { return true; } @@ -29,13 +25,10 @@ %ctor { // We can never be too sure (im pretty sure we can) dlopen("/System/Library/PrivateFrameworks/XPCObjects.framework/XPCObjects", RTLD_LAZY); - if (IS_IOS_OR_NEWER(iOS_9_0)) - { + if (IS_IOS_OR_NEWER(iOS_9_0)) { void *BSXPCConnectionHasEntitlement = MSFindSymbol(NULL, "_BSXPCConnectionHasEntitlement"); %init(iOS9andUp); - } - else - { + } else { void *BSAuditTokenTaskHasEntitlement = MSFindSymbol(NULL, "_BSAuditTokenTaskHasEntitlement"); %init(iOS8); } diff --git a/reachappbackboarddhooks/Tweak.xm b/reachappbackboarddhooks/Tweak.xm index bd2c752..237888c 100644 --- a/reachappbackboarddhooks/Tweak.xm +++ b/reachappbackboarddhooks/Tweak.xm @@ -32,59 +32,39 @@ CPDistributedMessagingCenter *center; // TODO: Ensure all keyboard commands do not conflict with // https://support.apple.com/en-us/HT201236 -void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event) -{ - if (IOHIDEventGetType(event) == kIOHIDEventTypeKeyboard) - { +void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEventRef event) { + if (IOHIDEventGetType(event) == kIOHIDEventTypeKeyboard) { IOHIDEventRef event2 = IOHIDEventCreateCopy(kCFAllocatorDefault, event); BOOL isDown = IOHIDEventGetIntegerValue(event2, kIOHIDEventFieldKeyboardDown); int key = IOHIDEventGetIntegerValue(event2, kIOHIDEventFieldKeyboardUsage); - if (key == CTRL_KEY) + if (key == CTRL_KEY) { isControlKeyDown = isDown; - else if (key == CMD_KEY || key == CMD_KEY2) + } else if (key == CMD_KEY || key == CMD_KEY2) { isWindowsKeyDown = isDown; - else if (key == SHIFT_KEY || key == SHIFT_KEY2) + } else if (key == SHIFT_KEY || key == SHIFT_KEY2) { isShiftKeyDown = isDown; - else if (key == ALT_KEY || key == ALT_KEY2) + } else if (key == ALT_KEY || key == ALT_KEY2) { isAltKeyDown = isDown; - else if (isDown && isWindowsKeyDown && isControlKeyDown) - { - if (key == ARROW_LEFT_KEY) - { + } else if (isDown && isWindowsKeyDown && isControlKeyDown) { + if (key == ARROW_LEFT_KEY) { [center sendMessageName:RAMessagingGoToDesktopOnTheLeftMessageName userInfo:nil]; - } - else if (key == ARROW_RIGHT_KEY) - { + } else if (key == ARROW_RIGHT_KEY) { [center sendMessageName:RAMessagingGoToDesktopOnTheRightMessageName userInfo:nil]; - } - else if (key == BKSPCE_KEY) - { + } else if (key == BKSPCE_KEY) { [center sendMessageName:RAMessagingDetachCurrentAppMessageName userInfo:nil]; - } - else if (key == D_KEY || key == EQUALS_OR_PLUS_KEY) - { - + } else if (key == D_KEY || key == EQUALS_OR_PLUS_KEY) { [center sendMessageName:RAMessagingAddNewDesktopMessageName userInfo:nil]; } - } - else if (isDown && isWindowsKeyDown && isAltKeyDown) - { - if (key == ARROW_LEFT_KEY) - { + } else if (isDown && isWindowsKeyDown && isAltKeyDown) { + if (key == ARROW_LEFT_KEY) { [center sendMessageName:RAMessagingSnapFrontMostWindowLeftMessageName userInfo:nil]; - } - else if (key == ARROW_RIGHT_KEY) - { + } else if (key == ARROW_RIGHT_KEY) { [center sendMessageName:RAMessagingSnapFrontMostWindowRightMessageName userInfo:nil]; - } - else if (key == ARROW_UP_KEY) - { + } else if (key == ARROW_UP_KEY) { [center sendMessageName:RAMessagingMaximizeAppMessageName userInfo:nil]; - } - else if (key == ARROW_DOWN_KEY) - { + } else if (key == ARROW_DOWN_KEY) { [center sendMessageName:RAMessagingCloseAppMessageName userInfo:nil]; } } @@ -100,20 +80,19 @@ void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEven %hook BKEventFocusManager @interface BKEventDestination --(id ) initWithPid:(unsigned int)arg1 clientID:(NSString*)arg2; +- (instancetype)initWithPid:(NSUInteger)arg1 clientID:(NSString*)arg2; @end --(id) destinationForFocusedEventWithDisplay:(__unsafe_unretained id)arg1 -{ +- (id)destinationForFocusedEventWithDisplay:(__unsafe_unretained id)arg1 { NSDictionary *response = [center sendMessageAndReceiveReplyName:RAMessagingGetFrontMostAppInfoMessageName userInfo:nil]; - if (response) - { + if (response) { int pid = [response[@"pid"] unsignedIntValue]; NSString *clientId = response[@"bundleIdentifier"]; - if (pid && clientId) + if (pid && clientId) { return [[[%c(BKEventDestination) alloc] initWithPid:pid clientID:clientId] autorelease]; + } } return %orig; } @@ -153,13 +132,11 @@ void handle_event(void *target, void *refcon, IOHIDServiceRef service, IOHIDEven %end */ -%ctor -{ +%ctor { center = [%c(CPDistributedMessagingCenter) centerNamed:@"com.efrederickson.reachapp.messaging.server"]; void* handle = dlopen("/usr/lib/librocketbootstrap.dylib", RTLD_LAZY); - if(handle) - { + if (handle) { void (*rocketbootstrap_distributedmessagingcenter_apply)(CPDistributedMessagingCenter*) = (void(*)(CPDistributedMessagingCenter*))dlsym(handle, "rocketbootstrap_distributedmessagingcenter_apply"); rocketbootstrap_distributedmessagingcenter_apply(center); dlclose(handle); diff --git a/reachappfakephonemode/Tweak.xm b/reachappfakephonemode/Tweak.xm index 1f36ecd..48cc3d4 100644 --- a/reachappfakephonemode/Tweak.xm +++ b/reachappfakephonemode/Tweak.xm @@ -11,77 +11,67 @@ } %hook UIDevice --(UIUserInterfaceIdiom) userInterfaceIdiom -{ +- (UIUserInterfaceIdiom)userInterfaceIdiom { UIUserInterfaceIdiom origIdiom = %orig; //if (IS_SPRINGBOARD || ignorePhoneMode) // return origIdiom; - if (origIdiom != UIUserInterfaceIdiomPhone && [%c(RAFakePhoneMode) shouldFakeForThisProcess]) + if (origIdiom != UIUserInterfaceIdiomPhone && [%c(RAFakePhoneMode) shouldFakeForThisProcess]) { return UIUserInterfaceIdiomPhone; + } return origIdiom; } %end %hook UIScreen -- (CGRect)_unjailedReferenceBounds -{ +- (CGRect)_unjailedReferenceBounds { FAKE; return %orig; } -- (CGRect)_referenceBounds -{ +- (CGRect)_referenceBounds { FAKE; return %orig; } -- (CGRect)_interfaceOrientedBounds -{ +- (CGRect)_interfaceOrientedBounds { FAKE; return %orig; } -- (CGRect)bounds -{ +- (CGRect)bounds { FAKE; return %orig; } -- (CGRect)nativeBounds -{ +- (CGRect)nativeBounds { FAKE; return %orig; } -- (CGRect)applicationFrame -{ +- (CGRect)applicationFrame { FAKE; return %orig; } -- (CGRect)_boundsForInterfaceOrientation:(int)arg1 -{ +- (CGRect)_boundsForInterfaceOrientation:(int)arg1 { FAKE; return %orig; } -- (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 usingStatusbarHeight:(CGFloat)arg2 ignoreStatusBar:(BOOL)arg3 -{ +- (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 usingStatusbarHeight:(CGFloat)arg2 ignoreStatusBar:(BOOL)arg3 { FAKE; return %orig; } -- (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 usingStatusbarHeight:(CGFloat)arg2 -{ +- (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 usingStatusbarHeight:(CGFloat)arg2 { FAKE; return %orig; } -- (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 -{ +- (CGRect)_applicationFrameForInterfaceOrientation:(int)arg1 { FAKE; return %orig; } diff --git a/reachappflipswitch/Switch.x b/reachappflipswitch/Switch.x index ca186b8..ae2e16d 100644 --- a/reachappflipswitch/Switch.x +++ b/reachappflipswitch/Switch.x @@ -7,21 +7,20 @@ @implementation ReachAppFlipswitchSwitch -- (FSSwitchState)stateForSwitchIdentifier:(NSString *)switchIdentifier -{ +- (FSSwitchState)stateForSwitchIdentifier:(NSString *)switchIdentifier { Boolean keyExistsAndHasValidFormat; BOOL enabled = CFPreferencesGetAppBooleanValue(CFSTR("enabled"), CFSTR("com.efrederickson.reachapp.settings"), &keyExistsAndHasValidFormat); return enabled ? FSSwitchStateOn : FSSwitchStateOff; } -- (void)applyState:(FSSwitchState)newState forSwitchIdentifier:(NSString *)switchIdentifier -{ - if (newState == FSSwitchStateIndeterminate) +- (void)applyState:(FSSwitchState)newState forSwitchIdentifier:(NSString *)switchIdentifier { + if (newState == FSSwitchStateIndeterminate) { return; + } CFPreferencesSetAppValue(CFSTR("enabled"), (CFPropertyListRef)(newState == FSSwitchStateOn ? @YES : @NO), CFSTR("com.efrederickson.reachapp.settings")); notify_post("com.efrederickson.reachapp.settings/reloadSettings"); } -@end \ No newline at end of file +@end diff --git a/reachappfsdaemon/main.mm b/reachappfsdaemon/main.mm index 98da6c0..893ab0e 100644 --- a/reachappfsdaemon/main.mm +++ b/reachappfsdaemon/main.mm @@ -9,8 +9,7 @@ int main(int argc, char **argv, char **envp) { @autoreleasepool { NSString *filePath = @"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp"; - if (![NSFileManager.defaultManager fileExistsAtPath:filePath]) - { + if (![NSFileManager.defaultManager fileExistsAtPath:filePath]) { LogError(@"[ReachApp] FS Daemon: plist does not exist"); return 0; } diff --git a/reachappsettings/BackgroundPerAppDetailsController.h b/reachappsettings/BackgroundPerAppDetailsController.h index 57ca3c3..3b2ce18 100644 --- a/reachappsettings/BackgroundPerAppDetailsController.h +++ b/reachappsettings/BackgroundPerAppDetailsController.h @@ -2,10 +2,9 @@ #import #import -@interface RABGPerAppDetailsController : SKTintedListController -{ +@interface RABGPerAppDetailsController : SKTintedListController { NSString* _appName; NSString* _identifier; } --(id)initWithAppName:(NSString*)appName identifier:(NSString*)identifier; +- (instancetype)initWithAppName:(NSString*)appName identifier:(NSString*)identifier; @end diff --git a/reachappsettings/BackgroundPerAppDetailsController.xm b/reachappsettings/BackgroundPerAppDetailsController.xm index 505fbcb..62e72e6 100644 --- a/reachappsettings/BackgroundPerAppDetailsController.xm +++ b/reachappsettings/BackgroundPerAppDetailsController.xm @@ -6,24 +6,29 @@ extern void RA_BGAppsControllerNeedsToReload(); @implementation RABGPerAppDetailsController --(instancetype)initWithAppName:(NSString*)appName identifier:(NSString*)identifier -{ +- (instancetype)initWithAppName:(NSString*)appName identifier:(NSString*)identifier { _appName = appName; _identifier = identifier; return [self init]; } --(NSString*) customTitle { return _appName; } --(BOOL) showHeartImage { return NO; } --(UIColor*) navigationTintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } +- (NSString*)customTitle { + return _appName; +} + +- (BOOL)showHeartImage { + return NO; +} + +- (UIColor*)navigationTintColor { + return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; +} --(id) isBackgroundModeActive:(NSString*)mode withAppInfo:(NSArray*)info -{ +- (id)isBackgroundModeActive:(NSString*)mode withAppInfo:(NSArray*)info { return [info containsObject:mode] ? @YES : @NO; } --(NSArray*) customSpecifiers -{ +- (NSArray*)customSpecifiers { LSApplicationProxy *appInfo = [%c(LSApplicationProxy) applicationProxyForIdentifier:_identifier]; NSArray *bgModes = appInfo.UIBackgroundModes; @@ -189,28 +194,26 @@ extern void RA_BGAppsControllerNeedsToReload(); ]; } --(void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier -{ +- (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { //[super setPreferenceValue:value specifier:specifier]; - if ([[specifier propertyForKey:@"key"] isEqualToString:@"UIApplicationExitsOnSuspend"]) - { + if ([[specifier propertyForKey:@"key"] isEqualToString:@"UIApplicationExitsOnSuspend"]) { LSApplicationProxy *appInfo = [%c(LSApplicationProxy) applicationProxyForIdentifier:_identifier]; NSString *path = [NSString stringWithFormat:@"%@/Info.plist",appInfo.bundleURL.absoluteString]; NSMutableDictionary *infoPlist = [NSMutableDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:path]]; infoPlist[@"UIApplicationExitsOnSuspend"] = value; BOOL success = [infoPlist writeToURL:[NSURL URLWithString:path] atomically:YES]; - if (!success) - { + if (!success) { NSMutableDictionary *daemonDict = [NSMutableDictionary dictionary]; daemonDict[@"bundleIdentifier"] = _identifier; daemonDict[@"UIApplicationExitsOnSuspend"] = value; [daemonDict writeToFile:@"/var/mobile/Library/.reachapp.uiappexitsonsuspend.wantstochangerootapp" atomically:YES]; } - if ([[specifier propertyForKey:@"reloadSpecifiers"] boolValue]) + if ([[specifier propertyForKey:@"reloadSpecifiers"] boolValue]) { [self reloadSpecifiers]; + } return; } @@ -218,20 +221,21 @@ extern void RA_BGAppsControllerNeedsToReload(); CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); NSString *key = [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,[specifier propertyForKey:@"key"]]; - if ([specifier propertyForKey:@"prefix"]) + if ([specifier propertyForKey:@"prefix"]) { key = [NSString stringWithFormat:@"backgrounder-%@-%@-%@",_identifier,[specifier propertyForKey:@"prefix"],[specifier propertyForKey:@"key"]]; + } CFPreferencesSetAppValue((__bridge CFStringRef)key, (const void*)value, appID); CFPreferencesAppSynchronize(appID); CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.settings/reloadSettings"), nil, nil, YES); RA_BGAppsControllerNeedsToReload(); - if ([[specifier propertyForKey:@"reloadSpecifiers"] boolValue]) + if ([[specifier propertyForKey:@"reloadSpecifiers"] boolValue]) { [self reloadSpecifiers]; + } } --(id) getActualPrefValue:(NSString*)basename -{ +- (id)getActualPrefValue:(NSString*)basename { CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); NSString *key = [NSString stringWithFormat:@"backgrounder-%@-%@",_identifier,basename]; @@ -240,8 +244,7 @@ extern void RA_BGAppsControllerNeedsToReload(); return (__bridge id)value; } --(id)readPreferenceValue:(PSSpecifier*)specifier -{ +- (id)readPreferenceValue:(PSSpecifier*)specifier { CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); if (!keyList) { diff --git a/reachappsettings/BackgrounderPerApp.xm b/reachappsettings/BackgrounderPerApp.xm index 41dd868..8b3e8be 100644 --- a/reachappsettings/BackgrounderPerApp.xm +++ b/reachappsettings/BackgrounderPerApp.xm @@ -9,9 +9,9 @@ #import "BackgroundPerAppDetailsController.h" @interface PSViewController (SettingsKit2) --(UINavigationController*)navigationController; --(void)viewWillAppear:(BOOL)animated; --(void)viewWillDisappear:(BOOL)animated; +- (UINavigationController*)navigationController; +- (void)viewWillAppear:(BOOL)animated; +- (void)viewWillDisappear:(BOOL)animated; @end @interface ALApplicationTableDataSource (Private) @@ -22,28 +22,27 @@ @end @implementation ALLinkCell --(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier -{ - if (!(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) return nil; - self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + } return self; } @end @interface PSViewController (Protean) --(void) viewDidLoad; --(void) viewWillDisappear:(BOOL)animated; +- (void)viewDidLoad; +- (void)viewWillDisappear:(BOOL)animated; - (void)viewDidAppear:(BOOL)animated; @end BOOL reload = NO; -void RA_BGAppsControllerNeedsToReload() -{ +void RA_BGAppsControllerNeedsToReload() { reload = YES; } -@interface RABGPerAppController : PSViewController -{ +@interface RABGPerAppController : PSViewController { UITableView* _tableView; ALApplicationTableDataSource* _dataSource; } @@ -51,25 +50,20 @@ void RA_BGAppsControllerNeedsToReload() @implementation RABGPerAppController --(void)updateDataSource:(NSString*)searchText -{ +- (void)updateDataSource:(NSString*)searchText { NSNumber *iconSize = [NSNumber numberWithUnsignedInteger:ALApplicationIconSizeSmall]; NSString *enabledList = @""; CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - if (keyList) - { + if (keyList) { NSDictionary *prefs = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); CFRelease(keyList); - if (prefs) - { + if (prefs) { NSArray *apps = [[ALApplicationList sharedApplicationList] applications].allKeys; - for (NSString* identifier in apps) - { - if ([prefs[[NSString stringWithFormat:@"backgrounder-%@-enabled",identifier]] boolValue]) - { + for (NSString* identifier in apps) { + if ([prefs[[NSString stringWithFormat:@"backgrounder-%@-enabled",identifier]] boolValue]) { enabledList = [enabledList stringByAppendingString:[NSString stringWithFormat:@"'%@',", identifier]]; } } @@ -78,8 +72,7 @@ void RA_BGAppsControllerNeedsToReload() enabledList = [enabledList stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]; NSString* filter = (searchText && searchText.length > 0) ? [NSString stringWithFormat:@"displayName beginsWith[cd] '%@'", searchText] : nil; - if (filter) - { + if (filter) { _dataSource.sectionDescriptors = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: @"Search Results", ALSectionDescriptorTitleKey, @@ -89,67 +82,60 @@ void RA_BGAppsControllerNeedsToReload() filter, ALSectionDescriptorPredicateKey , nil] , nil]; - } - else - { - if ([enabledList isEqual:@""]) - { - _dataSource.sectionDescriptors = [NSArray arrayWithObjects: - [NSDictionary dictionaryWithObjectsAndKeys: - @"", ALSectionDescriptorTitleKey, - @"ALLinkCell", ALSectionDescriptorCellClassNameKey, - iconSize, ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - [NSString stringWithFormat:@"not bundleIdentifier in {%@}", enabledList], - ALSectionDescriptorPredicateKey - , nil], - nil]; - } - else - { - _dataSource.sectionDescriptors = [NSArray arrayWithObjects: - [NSDictionary dictionaryWithObjectsAndKeys: - @"Enabled Applications", ALSectionDescriptorTitleKey, - @"ALLinkCell", ALSectionDescriptorCellClassNameKey, - iconSize, ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - [NSString stringWithFormat:@"bundleIdentifier in {%@}", enabledList], - ALSectionDescriptorPredicateKey - , nil], - [NSDictionary dictionaryWithObjectsAndKeys: - @"Other Applications", ALSectionDescriptorTitleKey, - @"ALLinkCell", ALSectionDescriptorCellClassNameKey, - iconSize, ALSectionDescriptorIconSizeKey, - @YES, ALSectionDescriptorSuppressHiddenAppsKey, - [NSString stringWithFormat:@"not bundleIdentifier in {%@}", enabledList], - ALSectionDescriptorPredicateKey - , nil], - nil]; - } + } else { + if ([enabledList isEqual:@""]) { + _dataSource.sectionDescriptors = [NSArray arrayWithObjects: + [NSDictionary dictionaryWithObjectsAndKeys: + @"", ALSectionDescriptorTitleKey, + @"ALLinkCell", ALSectionDescriptorCellClassNameKey, + iconSize, ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + [NSString stringWithFormat:@"not bundleIdentifier in {%@}", enabledList], + ALSectionDescriptorPredicateKey + , nil], + nil]; + } else { + _dataSource.sectionDescriptors = [NSArray arrayWithObjects: + [NSDictionary dictionaryWithObjectsAndKeys: + @"Enabled Applications", ALSectionDescriptorTitleKey, + @"ALLinkCell", ALSectionDescriptorCellClassNameKey, + iconSize, ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + [NSString stringWithFormat:@"bundleIdentifier in {%@}", enabledList], + ALSectionDescriptorPredicateKey + , nil], + [NSDictionary dictionaryWithObjectsAndKeys: + @"Other Applications", ALSectionDescriptorTitleKey, + @"ALLinkCell", ALSectionDescriptorCellClassNameKey, + iconSize, ALSectionDescriptorIconSizeKey, + @YES, ALSectionDescriptorSuppressHiddenAppsKey, + [NSString stringWithFormat:@"not bundleIdentifier in {%@}", enabledList], + ALSectionDescriptorPredicateKey + , nil], + nil]; + } } [_tableView reloadData]; } --(instancetype)init -{ - if (!(self = [super init])) return nil; - - CGRect bounds = [[UIScreen mainScreen] bounds]; - - _dataSource = [[ALApplicationTableDataSource alloc] init]; +- (instancetype)init { + self = [super init]; + if (self) { + CGRect bounds = [[UIScreen mainScreen] bounds]; - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; - _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - _tableView.delegate = self; - _tableView.dataSource = _dataSource; - _dataSource.tableView = _tableView; - [self updateDataSource:nil]; + _dataSource = [[ALApplicationTableDataSource alloc] init]; + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; + _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _tableView.delegate = self; + _tableView.dataSource = _dataSource; + _dataSource.tableView = _tableView; + [self updateDataSource:nil]; + } return self; } --(void)viewDidLoad -{ +- (void)viewDidLoad { ((UIViewController *)self).title = @"Applications"; [self.view addSubview:_tableView]; @@ -157,10 +143,8 @@ void RA_BGAppsControllerNeedsToReload() [super viewDidLoad]; } --(void) viewWillAppear:(BOOL) animated -{ - if (reload) - { +- (void)viewWillAppear:(BOOL)animated { + if (reload) { [self updateDataSource:nil]; reload = NO; } @@ -172,8 +156,7 @@ void RA_BGAppsControllerNeedsToReload() } --(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath -{ +- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath]; // Need to mimic what PSListController does when it handles didSelectRowAtIndexPath @@ -186,7 +169,9 @@ void RA_BGAppsControllerNeedsToReload() [tableView deselectRowAtIndexPath:indexPath animated:true]; } --(UIColor*) tintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } +- (UIColor*)tintColor { + return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; +} - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; diff --git a/reachappsettings/BackgrounderSettings.xm b/reachappsettings/BackgrounderSettings.xm index 7311602..ecf8fb4 100644 --- a/reachappsettings/BackgrounderSettings.xm +++ b/reachappsettings/BackgrounderSettings.xm @@ -17,15 +17,15 @@ #define PLIST_NAME @"/var/mobile/Library/Preferences/com.efrederickson.reachapp.settings.plist" @interface PSViewController (Protean) --(void) viewDidLoad; --(void) viewWillDisappear:(BOOL)animated; +- (void)viewDidLoad; +- (void)viewWillDisappear:(BOOL)animated; - (void)viewDidAppear:(BOOL)animated; @end @interface PSViewController (SettingsKit2) --(UINavigationController*)navigationController; --(void)viewWillAppear:(BOOL)animated; --(void)viewWillDisappear:(BOOL)animated; +- (UINavigationController*)navigationController; +- (void)viewWillAppear:(BOOL)animated; +- (void)viewWillDisappear:(BOOL)animated; @end @interface ALApplicationTableDataSource (Private) @@ -36,12 +36,11 @@ @end @implementation ReachAppBackgrounderSettingsListController --(UIView*) headerView -{ +- (UIView*)headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; header.colors = @[ - (id) [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:255/255.0f green:111/255.0f blue:124/255.0f alpha:1.0f].CGColor + (id) [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:255/255.0f green:111/255.0f blue:124/255.0f alpha:1.0f].CGColor ]; header.shouldBlend = NO; header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/BackgrounderHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(15, 33)]]; @@ -52,20 +51,28 @@ return notHeader; } --(UIColor*) tintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } --(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } +- (UIColor*)tintColor { + return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; +} + +- (UIColor*)switchTintColor { + return [[UISwitch alloc] init].tintColor; +} + +- (NSString*)customTitle { + return @"Aura"; +} --(NSString*) customTitle { return @"Aura"; } --(BOOL) showHeartImage { return NO; } +- (BOOL)showHeartImage { + return NO; +} --(void) viewDidAppear:(BOOL)arg1 -{ - [super viewDidAppear:arg1]; - [super performSelector:@selector(setupHeader)]; +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [super performSelector:@selector(setupHeader)]; } --(NSArray*) customSpecifiers -{ +- (NSArray*)customSpecifiers { return @[ @{ @"footerText": @"Quickly enable or disable Aura. Relaunch apps to apply changes." }, @{ @@ -128,18 +135,14 @@ ]; } --(void) showActivatorAction -{ +- (void)showActivatorAction { id activator = %c(LAListenerSettingsViewController); - if (!activator) - { + if (!activator) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; - } - else - { + } else { LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.backgrounder.togglemode"; [self.rootController pushController:vc animate:YES]; @@ -151,10 +154,15 @@ @end @implementation RABackgrounderIconIndicatorOptionsListController --(UIColor*) navigationTintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } --(BOOL) showHeartImage { return NO; } --(NSArray*) customSpecifiers -{ +- (UIColor*)navigationTintColor { + return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; +} + +- (BOOL)showHeartImage { + return NO; +} + +- (NSArray*)customSpecifiers { return @[ @{ @"cell": @"PSSwitchCell", @@ -180,10 +188,15 @@ @end @implementation RABackgrounderStatusbarOptionsListController --(UIColor*) navigationTintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } --(BOOL) showHeartImage { return NO; } --(NSArray*) customSpecifiers -{ +- (UIColor*)navigationTintColor { + return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; +} + +- (BOOL)showHeartImage { + return NO; +} + +- (NSArray*)customSpecifiers { return @[ @{ @"cell": @"PSSwitchCell", diff --git a/reachappsettings/MissionControlSettings.xm b/reachappsettings/MissionControlSettings.xm index 7ec2fcd..8ae442e 100644 --- a/reachappsettings/MissionControlSettings.xm +++ b/reachappsettings/MissionControlSettings.xm @@ -15,15 +15,15 @@ #define PLIST_NAME @"/var/mobile/Library/Preferences/com.efrederickson.reachapp.settings.plist" @interface PSViewController (Protean) --(void) viewDidLoad; --(void) viewWillDisappear:(BOOL)animated; +- (void)viewDidLoad; +- (void)viewWillDisappear:(BOOL)animated; - (void)viewDidAppear:(BOOL)animated; @end @interface PSViewController (SettingsKit2) --(UINavigationController*)navigationController; --(void)viewWillAppear:(BOOL)animated; --(void)viewWillDisappear:(BOOL)animated; +- (UINavigationController*)navigationController; +- (void)viewWillAppear:(BOOL)animated; +- (void)viewWillDisappear:(BOOL)animated; @end @interface ALApplicationTableDataSource (Private) @@ -34,8 +34,7 @@ @end @implementation ReachAppMCSettingsListController --(UIView*) headerView -{ +- (UIView*)headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; header.colors = @[ (id) [UIColor colorWithRed:255/255.0f green:205/255.0f blue:2/255.0f alpha:1.0f].CGColor, @@ -49,19 +48,29 @@ return notHeader; } --(UIColor*) tintColor { return [UIColor colorWithRed:255/255.0f green:205/255.0f blue:2/255.0f alpha:1.0f]; } --(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } --(NSString*) customTitle { return @"Mission Control"; } --(BOOL) showHeartImage { return NO; } - --(void) viewDidAppear:(BOOL)arg1 -{ - [super viewDidAppear:arg1]; + +- (UIColor*)tintColor { + return [UIColor colorWithRed:255/255.0f green:205/255.0f blue:2/255.0f alpha:1.0f]; +} + +- (UIColor*)switchTintColor { + return [[UISwitch alloc] init].tintColor; +} + +- (NSString*)customTitle { + return @"Mission Control"; +} + +- (BOOL)showHeartImage { + return NO; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; [super performSelector:@selector(setupHeader)]; } --(NSArray*) customSpecifiers -{ +- (NSArray*)customSpecifiers { return @[ @{ @"footerText": @"Quickly enable or disable Mission Control." }, @{ @@ -120,18 +129,15 @@ }, ]; } --(void) showActivatorAction -{ + +- (void)showActivatorAction { id activator = %c(LAListenerSettingsViewController); - if (!activator) - { + if (!activator) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:cancelAction]; [self presentViewController:alert animated:YES completion:nil]; - } - else - { + } else { LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; vc.listenerName = @"com.efrederickson.reachapp.missioncontrol.activatorlistener"; [self.rootController pushController:vc animate:YES]; diff --git a/reachappsettings/NCApp.xm b/reachappsettings/NCApp.xm index 1ec8b03..574e310 100644 --- a/reachappsettings/NCApp.xm +++ b/reachappsettings/NCApp.xm @@ -14,15 +14,15 @@ #define PLIST_NAME @"/var/mobile/Library/Preferences/com.efrederickson.reachapp.settings.plist" @interface PSViewController (Protean) --(void) viewDidLoad; --(void) viewWillDisappear:(BOOL)animated; +- (void)viewDidLoad; +- (void)viewWillDisappear:(BOOL)animated; - (void)viewDidAppear:(BOOL)animated; @end @interface PSViewController (SettingsKit2) --(UINavigationController*)navigationController; --(void)viewWillAppear:(BOOL)animated; --(void)viewWillDisappear:(BOOL)animated; +- (UINavigationController*)navigationController; +- (void)viewWillAppear:(BOOL)animated; +- (void)viewWillDisappear:(BOOL)animated; @end @interface ALApplicationTableDataSource (Private) @@ -33,8 +33,7 @@ @end @implementation ReachAppNCAppSettingsListController --(UIView*) headerView -{ +- (UIView*)headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)]; header.colors = @[ (id) [UIColor colorWithRed:90/255.0f green:212/255.0f blue:39/255.0f alpha:1.0f].CGColor, @@ -48,20 +47,29 @@ return notHeader; } --(UIColor*) tintColor { return [UIColor colorWithRed:90/255.0f green:212/255.0f blue:39/255.0f alpha:1.0f]; } --(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } --(NSString*) customTitle { return @"Quick Access"; } --(BOOL) showHeartImage { return NO; } +- (UIColor*)tintColor { + return [UIColor colorWithRed:90/255.0f green:212/255.0f blue:39/255.0f alpha:1.0f]; +} + +- (UIColor*)switchTintColor { + return [[UISwitch alloc] init].tintColor; +} + +- (NSString*)customTitle { + return @"Quick Access"; +} + +- (BOOL)showHeartImage { + return NO; +} --(void) viewDidAppear:(BOOL)arg1 -{ - [super viewDidAppear:arg1]; +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; [super performSelector:@selector(setupHeader)]; } --(NSArray*) customSpecifiers -{ +- (NSArray*)customSpecifiers { return @[ @{ @"footerText": @"Quickly enable or disable Quick Access." }, @{ @@ -101,8 +109,7 @@ @end -@interface RANCAppSelectorView : PSViewController -{ +@interface RANCAppSelectorView : PSViewController { UITableView* _tableView; ALApplicationTableDataSource* _dataSource; } @@ -117,8 +124,7 @@ @end @implementation RANCApplicationTableDataSource -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //NSInteger row = indexPath.row; UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; @@ -135,8 +141,7 @@ } CFRelease(keyList); - if ([cell isKindOfClass:[ALCheckCell class]]) - { + if ([cell isKindOfClass:[ALCheckCell class]]) { NSString *dn = [self displayIdentifierForIndexPath:indexPath]; NSString *key = @"NCApp";// [NSString stringWithFormat:@"NCApp-%@",dn]; //BOOL value = [prefs[key] boolValue]; @@ -149,8 +154,7 @@ @implementation RANCAppSelectorView --(void)updateDataSource:(NSString*)searchText -{ +- (void)updateDataSource:(NSString*)searchText { _dataSource.sectionDescriptors = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: @"", ALSectionDescriptorTitleKey, @@ -164,33 +168,30 @@ [_tableView reloadData]; } --(instancetype)init -{ - if (!(self = [super init])) return nil; - - CGRect bounds = [[UIScreen mainScreen] bounds]; - - _dataSource = [[RANCApplicationTableDataSource alloc] init]; +- (instancetype)init { + self = [super init]; + if (self) { + CGRect bounds = [[UIScreen mainScreen] bounds]; - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; - _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - _tableView.delegate = self; - _tableView.dataSource = _dataSource; - _dataSource.tableView = _tableView; - [self updateDataSource:nil]; + _dataSource = [[RANCApplicationTableDataSource alloc] init]; + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height) style:UITableViewStyleGrouped]; + _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _tableView.delegate = self; + _tableView.dataSource = _dataSource; + _dataSource.tableView = _tableView; + [self updateDataSource:nil]; + } return self; } --(void)viewDidLoad -{ +- (void)viewDidLoad { ((UIViewController *)self).title = @"Applications"; [self.view addSubview:_tableView]; [super viewDidLoad]; } --(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath -{ +- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:true]; ALCheckCell* cell = (ALCheckCell*)[tableView cellForRowAtIndexPath:indexPath]; [cell didSelect]; @@ -199,8 +200,9 @@ BOOL selected = type == UITableViewCellAccessoryCheckmark; NSString *identifier = [_dataSource displayIdentifierForIndexPath:indexPath]; - if (selected) + if (selected) { CFPreferencesSetAppValue((__bridge CFStringRef)@"NCApp", (CFPropertyListRef)(identifier), CFSTR("com.efrederickson.reachapp.settings")); + } [self updateDataSource:nil]; diff --git a/reachappsettings/RAHeaderView.h b/reachappsettings/RAHeaderView.h index 084be15..d4884de 100644 --- a/reachappsettings/RAHeaderView.h +++ b/reachappsettings/RAHeaderView.h @@ -6,7 +6,7 @@ } @property (nonatomic) CGBlendMode blendMode; @property (nonatomic) BOOL shouldBlend; --(void) setColors:(NSArray*)colors; --(void) setTitle:(NSString*)title; --(void) setImage:(UIImage*)image; -@end \ No newline at end of file +- (void)setColors:(NSArray*)colors; +- (void)setTitle:(NSString*)title; +- (void)setImage:(UIImage*)image; +@end diff --git a/reachappsettings/RAHeaderView.mm b/reachappsettings/RAHeaderView.mm index fda2403..25d027b 100644 --- a/reachappsettings/RAHeaderView.mm +++ b/reachappsettings/RAHeaderView.mm @@ -1,16 +1,16 @@ #import "RAHeaderView.h" @implementation UIImage (ext) -- (UIImage *)tintedImageWithColor:(UIColor *)tintColor blendingMode:(CGBlendMode)blendMode -{ +- (UIImage *)tintedImageWithColor:(UIColor *)tintColor blendingMode:(CGBlendMode)blendMode { UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); [tintColor setFill]; CGRect bounds = CGRectMake(0, 0, self.size.width, self.size.height); UIRectFill(bounds); [self drawInRect:bounds blendMode:blendMode alpha:1.0f]; - if (blendMode != kCGBlendModeDestinationIn) + if (blendMode != kCGBlendModeDestinationIn) { [self drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0]; + } UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); @@ -20,15 +20,13 @@ - (UIImage *)tintedImageWithColor:(UIColor *)tintColor blendingMode:(CGBlendMode @end @implementation RAHeaderView -+ (Class)layerClass -{ ++ (Class)layerClass { return [CAGradientLayer class]; } --(instancetype) initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) - { +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { CAGradientLayer *gradient = (CAGradientLayer*)self.layer; gradient.colors = @[ (id)[UIColor colorWithRed:255/255.0f green:124/255.0f blue:111/255.0f alpha:1.0f].CGColor, (id)[UIColor colorWithRed:231/255.0f green:76/255.0f blue:60/255.0f alpha:1.0f].CGColor ]; gradient.locations = @[ @0, @1 ]; @@ -50,30 +48,26 @@ -(instancetype) initWithFrame:(CGRect)frame return self; } --(void) setFrame:(CGRect)frame -{ +- (void)setFrame:(CGRect)frame { [super setFrame:frame]; ((CAGradientLayer*)self.layer).frame = CGRectMake(0, 0, frame.size.width, frame.size.height); } --(void) setColors:(NSArray*)c -{ +- (void)setColors:(NSArray*)c { ((CAGradientLayer*)self.layer).colors = c; } --(void) setTitle:(NSString*)title -{ +- (void)setTitle:(NSString*)title { label.text = title; } --(void) setImage:(UIImage*)image -{ - if (label.text.length > 0) - imageView.frame = (CGRect) { { self.frame.size.width - image.size.width - 20, (self.frame.size.height - image.size.height) / 2.0 }, image.size }; - else - imageView.frame = (CGRect) { { (self.frame.size.width - image.size.width) / 2.0, (self.frame.size.height - image.size.height) / 2.0 }, image.size }; - if (self.shouldBlend) - { +- (void)setImage:(UIImage*)image { + if (label.text.length > 0) { + imageView.frame = (CGRect) { { self.frame.size.width - image.size.width - 20, (self.frame.size.height - image.size.height) / 2.0 }, image.size }; + } else { + imageView.frame = (CGRect) { { (self.frame.size.width - image.size.width) / 2.0, (self.frame.size.height - image.size.height) / 2.0 }, image.size }; + } + if (self.shouldBlend) { UIColor *color = [UIColor colorWithCGColor:(CGColorRef)((CAGradientLayer*)self.layer).colors[0]]; image = [image tintedImageWithColor:color blendingMode:self.blendMode]; } diff --git a/reachappsettings/RAListItemsController.xm b/reachappsettings/RAListItemsController.xm index bb3d5ca..60dff5f 100644 --- a/reachappsettings/RAListItemsController.xm +++ b/reachappsettings/RAListItemsController.xm @@ -15,26 +15,25 @@ @end @implementation RAListItemsController --(UIColor*) navigationTintColor { return [UIColor blackColor]; } +- (UIColor*)navigationTintColor { + return [UIColor blackColor]; +} -- (void)viewWillAppear:(BOOL)animated -{ +- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.tintColor = self.navigationTintColor; [[UIApplication sharedApplication] keyWindow].tintColor = self.navigationTintColor; } -- (void)viewWillDisappear:(BOOL)animated -{ +- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [[UIApplication sharedApplication] keyWindow].tintColor = nil; self.navigationController.navigationBar.tintColor = nil; } --(NSArray*) specifiers -{ +- (NSArray*)specifiers { if (!_specifiers) { PSSpecifier* themeSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Documentation" target:self @@ -52,18 +51,15 @@ return _specifiers; } --(void) openThemingDocumentation -{ +- (void)openThemingDocumentation { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com/multiplexer/ThemingDocumentation.html"]]; } --(void) tableView:(id)arg1 didSelectRowAtIndexPath:(id)arg2 -{ +- (void)tableView:(id)arg1 didSelectRowAtIndexPath:(id)arg2 { [super tableView:arg1 didSelectRowAtIndexPath:arg2]; PSTableCell *cell = [self tableView:arg1 cellForRowAtIndexPath:arg2]; - if ([cell.specifier propertyForKey:@"isTheming"]) - { + if ([cell.specifier propertyForKey:@"isTheming"]) { [self openThemingDocumentation]; } } @@ -75,18 +71,18 @@ @end @implementation RABackgroundingListItemsController --(UIColor*) navigationTintColor { return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; } +- (UIColor*)navigationTintColor { + return [UIColor colorWithRed:248/255.0f green:73/255.0f blue:88/255.0f alpha:1.0f]; +} -- (void)viewWillAppear:(BOOL)animated -{ +- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.tintColor = self.navigationTintColor; [[UIApplication sharedApplication] keyWindow].tintColor = self.navigationTintColor; } -- (void)viewWillDisappear:(BOOL)animated -{ +- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [[UIApplication sharedApplication] keyWindow].tintColor = nil; diff --git a/reachappsettings/RASupportController.xm b/reachappsettings/RASupportController.xm index 44d64e3..b635c70 100644 --- a/reachappsettings/RASupportController.xm +++ b/reachappsettings/RASupportController.xm @@ -12,14 +12,24 @@ @end @implementation RAMakersController --(BOOL) showHeartImage { return NO; } --(UIColor*) navigationTintColor { return [UIColor blackColor]; } --(UIColor*) switchOnTintColor { return self.navigationTintColor; } +- (BOOL)showHeartImage { + return NO; +} + +- (UIColor*)navigationTintColor { + return [UIColor blackColor]; +} + +- (UIColor*)switchOnTintColor { + return self.navigationTintColor; +} //-(UIColor*) iconColor { return self.navigationTintColor; } --(NSString*) customTitle { return @"Creators"; } +- (NSString*)customTitle { + return @"Creators"; +} -- (id)customSpecifiers { +- (NSArray*)customSpecifiers { return @[ @{ @"cell": @"PSGroupCell", @"label": @"Developed and Designed by" }, @{ @@ -147,24 +157,23 @@ Crafted with love in 🇨🇦 and 🇺🇸. \n\ ]; } --(void) openGithub -{ - [SKSharedHelper openGitHub:@"mlnlover11/Multiplexer"]; +- (void)openGithub { + [SKSharedHelper openGitHub:@"mlnlover11/Multiplexer"]; } --(void) openElijahTwitter { [SKSharedHelper openTwitter:@"daementor"]; } --(void) openAndrewTwitter { [SKSharedHelper openTwitter:@"drewplex"]; } --(void) openShadeTwitter { [SKSharedHelper openTwitter:@"ShadeZepheri"]; } --(void) openAndiTwitter { [SKSharedHelper openTwitter:@"Nexuist"]; } --(void) openBetaPage { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://www.reddit.com/user/beta382"]]; } --(void) openChonTwitter { [SKSharedHelper openTwitter:@"HikoMitsuketa"]; } --(void) openDavidTwitter { [SKSharedHelper openTwitter:@"djaovx"]; } --(void) openJackTwitter { [SKSharedHelper openTwitter:@"JackHaal"]; } --(void) openMosheTwitter { [SKSharedHelper openTwitter:@"oniconpack"]; } --(void) openBindersPAge { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://www.reddit.com/user/_BindersFullOfWomen_"]]; } --(void) openWilsonTwitter { [SKSharedHelper openTwitter:@"xTM3x"]; } --(void) openZiph0nTwitter { [SKSharedHelper openTwitter:@"ziph0n"]; } --(void) openSharedRoutineTwitter { [SKSharedHelper openTwitter:@"sharedRoutine"]; } --(void) openEthanTwitter { [SKSharedHelper openTwitter:@"its_not_herpes"]; } --(void) openSite { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com"]]; } +- (void)openElijahTwitter { [SKSharedHelper openTwitter:@"daementor"]; } +- (void)openAndrewTwitter { [SKSharedHelper openTwitter:@"drewplex"]; } +- (void)openShadeTwitter { [SKSharedHelper openTwitter:@"ShadeZepheri"]; } +- (void)openAndiTwitter { [SKSharedHelper openTwitter:@"Nexuist"]; } +- (void)openBetaPage { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://www.reddit.com/user/beta382"]]; } +- (void)openChonTwitter { [SKSharedHelper openTwitter:@"HikoMitsuketa"]; } +- (void)openDavidTwitter { [SKSharedHelper openTwitter:@"djaovx"]; } +- (void)openJackTwitter { [SKSharedHelper openTwitter:@"JackHaal"]; } +- (void)openMosheTwitter { [SKSharedHelper openTwitter:@"oniconpack"]; } +- (void)openBindersPAge { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://www.reddit.com/user/_BindersFullOfWomen_"]]; } +- (void)openWilsonTwitter { [SKSharedHelper openTwitter:@"xTM3x"]; } +- (void)openZiph0nTwitter { [SKSharedHelper openTwitter:@"ziph0n"]; } +- (void)openSharedRoutineTwitter { [SKSharedHelper openTwitter:@"sharedRoutine"]; } +- (void)openEthanTwitter { [SKSharedHelper openTwitter:@"its_not_herpes"]; } +- (void)openSite { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com"]]; } @end diff --git a/reachappsettings/ReachAppSettings.mm b/reachappsettings/ReachAppSettings.mm index ae5a9b0..9f7e960 100644 --- a/reachappsettings/ReachAppSettings.mm +++ b/reachappsettings/ReachAppSettings.mm @@ -20,15 +20,15 @@ #import "RASettings.h" @interface PSViewController (Protean) --(void) viewDidLoad; --(void) viewWillDisappear:(BOOL)animated; +- (void)viewDidLoad; +- (void)viewWillDisappear:(BOOL)animated; - (void)viewDidAppear:(BOOL)animated; @end @interface PSViewController (SettingsKit2) --(UINavigationController*)navigationController; --(void)viewWillAppear:(BOOL)animated; --(void)viewWillDisappear:(BOOL)animated; +- (UINavigationController*)navigationController; +- (void)viewWillAppear:(BOOL)animated; +- (void)viewWillDisappear:(BOOL)animated; @end @interface ALApplicationTableDataSource (Private) @@ -39,18 +39,18 @@ @interface ReachAppSettingsListController: SKTintedListController= 300000) + } else if (arc4random_uniform(1000000) >= 300000) { header.title = @"dank memes"; + } #endif header.blendMode = kCGBlendModeSoftLight; header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/MainHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(109.33, 41)]]; @@ -61,13 +61,23 @@ -(UIView*) headerView return notHeader; } --(UIColor*) navigationTintColor { return [UIColor colorWithRed:190/255.0f green:83/255.0f blue:184/255.0f alpha:1.0f]; } --(NSString*) customTitle { return @"Multiplexer"; } --(BOOL) showHeartImage { return YES; } --(NSString*) shareMessage { return @"I'm multitasking with Multiplexer, by @daementor and @drewplex"; } +- (UIColor*)navigationTintColor { + return [UIColor colorWithRed:190/255.0f green:83/255.0f blue:184/255.0f alpha:1.0f]; +} + +- (NSString*)customTitle { + return @"Multiplexer"; +} + +- (BOOL)showHeartImage { + return YES; +} + +- (NSString*)shareMessage { + return @"I'm multitasking with Multiplexer, by @daementor and @drewplex"; +} --(NSArray*) customSpecifiers -{ +- (NSArray*)customSpecifiers { return @[ @{ @"footerText": @"Quickly enable or disable Multiplexer." }, @{ @@ -200,8 +210,7 @@ -(NSArray*) customSpecifiers ]; } --(void) resetData -{ +- (void)resetData { UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Please confirm your choice to reset all settings & respring.." preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *resetAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.efrederickson.reachapp.resetSettings"), nil, nil, YES); @@ -213,34 +222,31 @@ -(void) resetData [self presentViewController:alert animated:YES completion:nil]; } --(void) openThemingDocumentation -{ +- (void)openThemingDocumentation { [UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://elijahandandrew.com/multiplexer/ThemingDocumentation.html"]]; } --(NSArray*) getThemeTitles:(id)target -{ +- (NSArray*)getThemeTitles:(id)target { NSArray *themes = [RAThemeManager.sharedInstance allThemes]; NSMutableArray *ret = [NSMutableArray array]; - for (RATheme *theme in themes) + for (RATheme *theme in themes) { [ret addObject:theme.themeName]; + } return ret; } --(NSArray*) getThemeValues:(id)target -{ +- (NSArray*)getThemeValues:(id)target { NSArray *themes = [RAThemeManager.sharedInstance allThemes]; NSMutableArray *ret = [NSMutableArray array]; - for (RATheme *theme in themes) + for (RATheme *theme in themes) { [ret addObject:theme.themeIdentifier]; + } return ret; } --(void) showSupportDialog -{ +- (void)showSupportDialog { MFMailComposeViewController *mailViewController; - if ([MFMailComposeViewController canSendMail]) - { + if ([MFMailComposeViewController canSendMail]) { mailViewController = [[MFMailComposeViewController alloc] init]; mailViewController.mailComposeDelegate = self; [mailViewController setSubject:@"Multiplexer"]; @@ -257,14 +263,12 @@ -(void) showSupportDialog } } --(void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier -{ +- (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { [super setPreferenceValue:value specifier:specifier]; [self reloadSpecifiers]; } --(BOOL) getEnabled -{ +- (BOOL)getEnabled { CFStringRef appID = CFSTR("com.efrederickson.reachapp.settings"); CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); if (!keyList) { @@ -279,12 +283,11 @@ -(BOOL) getEnabled return ![_settings objectForKey:@"enabled"] ? YES : [_settings[@"enabled"] boolValue]; } --(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{ +- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { [self dismissViewControllerAnimated:YES completion:NULL]; } --(void) showTutorial -{ +- (void)showTutorial { [UIApplication.sharedApplication launchApplicationWithIdentifier:@"com.andrewabosh.Multiplexer" suspended:NO]; } @end diff --git a/reachappsettings/Reachability.xm b/reachappsettings/Reachability.xm index 8d7f2bb..c079ec3 100644 --- a/reachappsettings/Reachability.xm +++ b/reachappsettings/Reachability.xm @@ -14,15 +14,15 @@ #define PLIST_NAME @"/var/mobile/Library/Preferences/com.efrederickson.reachapp.settings.plist" @interface PSViewController (Protean) --(void) viewDidLoad; --(void) viewWillDisappear:(BOOL)animated; +- (void) viewDidLoad; +- (void) viewWillDisappear:(BOOL)animated; - (void)viewDidAppear:(BOOL)animated; @end @interface PSViewController (SettingsKit2) --(UINavigationController*)navigationController; --(void)viewWillAppear:(BOOL)animated; --(void)viewWillDisappear:(BOOL)animated; +- (UINavigationController*)navigationController; +- (void)viewWillAppear:(BOOL)animated; +- (void)viewWillDisappear:(BOOL)animated; @end @interface ALApplicationTableDataSource (Private) @@ -33,12 +33,11 @@ @end @implementation ReachAppReachabilitySettingsListController --(UIView*) headerView -{ +- (UIView*)headerView { RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; header.colors = @[ - (id) [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:82/255.0f green:191/255.0f blue:232/255.0f alpha:1.0f].CGColor + (id) [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:82/255.0f green:191/255.0f blue:232/255.0f alpha:1.0f].CGColor ]; header.shouldBlend = NO; //header.title = @"ReachApp"; @@ -49,19 +48,29 @@ return notHeader; } --(UIColor*) tintColor { return [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f]; } --(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } --(NSString*) customTitle { return @"Reach App"; } --(BOOL) showHeartImage { return NO; } - --(void) viewDidAppear:(BOOL)arg1 -{ - [super viewDidAppear:arg1]; + +- (UIColor*)tintColor { + return [UIColor colorWithRed:29/255.0f green:119/255.0f blue:239/255.0f alpha:1.0f]; +} + +- (UIColor*)switchTintColor { + return [[UISwitch alloc] init].tintColor; +} + +- (NSString*)customTitle { + return @"Reach App"; +} + +- (BOOL)showHeartImage { + return NO; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; [super performSelector:@selector(setupHeader)]; } --(NSArray*) customSpecifiers -{ +- (NSArray*)customSpecifiers { return @[ @{ @"footerText": @"Quickly enable or disable ReachApp." }, @{ @@ -178,9 +187,11 @@ @end @implementation RAAppChooserOptionsListController --(BOOL) showHeartImage { return NO; } --(NSArray*) customSpecifiers -{ +- (BOOL)showHeartImage { + return NO; +} + +- (NSArray*)customSpecifiers { return @[ @{ @"footerText": @"If enabled, the app selector will scale to the size of available apps." }, @{ @@ -246,7 +257,7 @@ @end @implementation RASwitchCell --(instancetype)initWithStyle:(int)arg1 reuseIdentifier:(id)arg2 specifier:(id)arg3 { //init method +- (instancetype)initWithStyle:(int)arg1 reuseIdentifier:(id)arg2 specifier:(id)arg3 { //init method self = [super initWithStyle:arg1 reuseIdentifier:arg2 specifier:arg3]; //call the super init method if (self) { [((UISwitch *)[self control]) setOnTintColor:[UIColor redColor]]; //change the switch color @@ -255,8 +266,7 @@ } @end -@interface RAFavoritesAppSelectorView : PSViewController -{ +@interface RAFavoritesAppSelectorView : PSViewController { UITableView* _tableView; ALApplicationTableDataSource* _dataSource; } @@ -271,8 +281,7 @@ @end @implementation RAApplicationTableDataSource -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //NSInteger row = indexPath.row; UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; @@ -289,8 +298,7 @@ } CFRelease(keyList); - if ([cell isKindOfClass:[ALCheckCell class]]) - { + if ([cell isKindOfClass:[ALCheckCell class]]) { NSString *dn = [self displayIdentifierForIndexPath:indexPath]; NSString *key = [NSString stringWithFormat:@"Favorites-%@",dn]; BOOL value = [prefs[key] boolValue]; @@ -302,8 +310,7 @@ @implementation RAFavoritesAppSelectorView --(void)updateDataSource:(NSString*)searchText -{ +-(void)updateDataSource:(NSString*)searchText { _dataSource.sectionDescriptors = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: @"", ALSectionDescriptorTitleKey, @@ -317,8 +324,7 @@ [_tableView reloadData]; } --(instancetype)init -{ +- (instancetype)init { if (self = [super init]) { CGRect bounds = [[UIScreen mainScreen] bounds]; @@ -334,15 +340,13 @@ return self; } --(void)viewDidLoad -{ +- (void)viewDidLoad { ((UIViewController *)self).title = @"Applications"; [self.view addSubview:_tableView]; [super viewDidLoad]; } --(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath -{ +- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:true]; ALCheckCell* cell = (ALCheckCell*)[tableView cellForRowAtIndexPath:indexPath]; [cell didSelect]; diff --git a/reachappsettings/SwipeOver.xm b/reachappsettings/SwipeOver.xm index 81778c1..1b95b7b 100644 --- a/reachappsettings/SwipeOver.xm +++ b/reachappsettings/SwipeOver.xm @@ -15,49 +15,57 @@ #define PLIST_NAME @"/var/mobile/Library/Preferences/com.efrederickson.reachapp.settings.plist" @interface PSViewController (Protean) --(void) viewDidLoad; --(void) viewWillDisappear:(BOOL)animated; +- (void)viewDidLoad; +- (void)viewWillDisappear:(BOOL)animated; - (void)viewDidAppear:(BOOL)animated; @end @interface PSViewController (SettingsKit2) --(UINavigationController*)navigationController; --(void)viewWillAppear:(BOOL)animated; --(void)viewWillDisappear:(BOOL)animated; +- (UINavigationController*)navigationController; +- (void)viewWillAppear:(BOOL)animated; +- (void)viewWillDisappear:(BOOL)animated; @end @interface ReachAppSwipeOverSettingsListController: SKTintedListController @end @implementation ReachAppSwipeOverSettingsListController --(UIView*) headerView -{ - RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ - (id) [UIColor colorWithRed:88/255.0f green:86/255.0f blue:214/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:198/255.0f green:68/255.0f blue:252/255.0f alpha:1.0f].CGColor, - ]; - header.shouldBlend = NO; - header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/SwipeOverHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(54, 32)]]; +- (UIView*)headerView { + RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; + header.colors = @[ + (id) [UIColor colorWithRed:88/255.0f green:86/255.0f blue:214/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:198/255.0f green:68/255.0f blue:252/255.0f alpha:1.0f].CGColor, + ]; + header.shouldBlend = NO; + header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/SwipeOverHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(54, 32)]]; - UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; - [notHeader addSubview:header]; + UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; + [notHeader addSubview:header]; - return notHeader; + return notHeader; +} +- (NSString*)customTitle { + return @"Swipe Over"; +} + +- (UIColor*)tintColor { + return [UIColor colorWithRed:88/255.0f green:86/255.0f blue:214/255.0f alpha:1.0f]; +} + +- (UIColor*)switchTintColor { + return [[UISwitch alloc] init].tintColor; +} + +- (BOOL)showHeartImage { + return NO; } --(NSString*) customTitle { return @"Swipe Over"; } --(UIColor*) tintColor { return [UIColor colorWithRed:88/255.0f green:86/255.0f blue:214/255.0f alpha:1.0f]; } --(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } --(BOOL) showHeartImage { return NO; } --(void) viewDidAppear:(BOOL)arg1 -{ - [super viewDidAppear:arg1]; - [super performSelector:@selector(setupHeader)]; +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [super performSelector:@selector(setupHeader)]; } --(NSArray*) customSpecifiers -{ +- (NSArray*)customSpecifiers { return @[ @{ @"footerText": @"Quickly enable or disable Swipe Over." }, @{ diff --git a/reachappsettings/WindowedMultitasking.xm b/reachappsettings/WindowedMultitasking.xm index 5a5ee33..d045a00 100644 --- a/reachappsettings/WindowedMultitasking.xm +++ b/reachappsettings/WindowedMultitasking.xm @@ -16,15 +16,15 @@ #define PLIST_NAME @"/var/mobile/Library/Preferences/com.efrederickson.reachapp.settings.plist" @interface PSViewController (Protean) --(void) viewDidLoad; --(void) viewWillDisappear:(BOOL)animated; +- (void)viewDidLoad; +- (void)viewWillDisappear:(BOOL)animated; - (void)viewDidAppear:(BOOL)animated; @end @interface PSViewController (SettingsKit2) --(UINavigationController*)navigationController; --(void)viewWillAppear:(BOOL)animated; --(void)viewWillDisappear:(BOOL)animated; +- (UINavigationController*)navigationController; +- (void)viewWillAppear:(BOOL)animated; +- (void)viewWillDisappear:(BOOL)animated; @end @interface ALApplicationTableDataSource (Private) @@ -35,213 +35,210 @@ @end @implementation ReachAppWindowSettingsListController --(UIView*) headerView -{ - RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; - header.colors = @[ - (id) [UIColor colorWithRed:255/255.0f green:94/255.0f blue:58/255.0f alpha:1.0f].CGColor, - (id) [UIColor colorWithRed:255/255.0f green:149/255.0f blue:0/255.0f alpha:1.0f].CGColor, - ]; - header.shouldBlend = NO; - header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/EmpoleonHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(32, 32)]]; - - UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; - [notHeader addSubview:header]; - - return notHeader; +- (UIView*)headerView { + RAHeaderView *header = [[RAHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; + header.colors = @[ + (id) [UIColor colorWithRed:255/255.0f green:94/255.0f blue:58/255.0f alpha:1.0f].CGColor, + (id) [UIColor colorWithRed:255/255.0f green:149/255.0f blue:0/255.0f alpha:1.0f].CGColor, + ]; + header.shouldBlend = NO; + header.image = [[RAPDFImage imageWithContentsOfFile:@"/Library/PreferenceBundles/ReachAppSettings.bundle/EmpoleonHeader.pdf"] imageWithOptions:[RAPDFImageOptions optionsWithSize:CGSizeMake(32, 32)]]; + + UIView *notHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)]; + [notHeader addSubview:header]; + + return notHeader; } --(UIColor*) tintColor { return [UIColor colorWithRed:255/255.0f green:94/255.0f blue:58/255.0f alpha:1.0f]; } --(UIColor*) switchTintColor { return [[UISwitch alloc] init].tintColor; } --(NSString*) customTitle { return @"Empoleon"; } --(BOOL) showHeartImage { return NO; } - --(void) viewDidAppear:(BOOL)arg1 -{ - [super viewDidAppear:arg1]; - [super performSelector:@selector(setupHeader)]; + +- (UIColor*)tintColor { + return [UIColor colorWithRed:255/255.0f green:94/255.0f blue:58/255.0f alpha:1.0f]; +} + +- (UIColor*)switchTintColor { + return [[UISwitch alloc] init].tintColor; +} + +- (NSString*)customTitle { + return @"Empoleon"; +} + +- (BOOL)showHeartImage { + return NO; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [super performSelector:@selector(setupHeader)]; } --(NSArray*) customSpecifiers -{ - return @[ - @{ @"footerText": @"Quickly enable or disable Empoleon." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"windowedMultitaskingEnabled", - @"label": @"Enabled", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"label": @"Swipe Up From Bottom...", @"footerText": @"Launches all apps into windows rather than fullscreen." }, - @{ - @"cell": @"PSSegmentCell", - @"validTitles": @[ @"Left", @"Middle", @"Right" ], - @"validValues": @[ @(RAGrabAreaBottomLeftThird), @(RAGrabAreaBottomMiddleThird), @(RAGrabAreaBottomRightThird), ], - @"default": @(RAGrabAreaBottomLeftThird), - @"key": @"windowedMultitaskingGrabArea", - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"launchIntoWindows", - @"label": @"Launch Into Window", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"footerText": @"If disabled, you will not be able to resize and rotate windows unless the easy-tap-mode overlay is displayed." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"alwaysEnableGestures", - @"label": @"Always Enable Gestures", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"onlyShowWindowBarIconsOnOverlay", - @"label": @"Only Show Icons in Easy-Tap-Mode", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"footerText": @"If enabled, tapping an icon on the easy-tap-mode overlay will be delayed until the bounce animation is complete." }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"windowedMultitaskingCompleteAnimations", - @"label": @"Complete Animations", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"label": @"Snapping" }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"snapWindows", - @"label": @"Snap Windows", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ - @"cell": @"PSSwitchCell", - @"default": @YES, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"snapRotation", - @"label": @"Rotation Snapping", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"showSnapHelper", - @"label": @"Show Snap Helper", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"label": @"Lock button action" }, - @{ - @"cell": @"PSSegmentCell", - @"validTitles": @[ @"Lock All Rotation", @"Lock App Rotation" ], - @"validValues": @[ @0, @1 ], - @"default": @0, - @"key": @"windowRotationLockMode", - @"defaults": @"com.efrederickson.reachapp.settings", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - - @{ @"label": @"Activator" }, - @{ - @"cell": @"PSLinkCell", - @"action": @"showActivatorAction", - @"label": @"Sort Windows Activation", - //@"enabled": objc_getClass("LAEventSettingsController") != nil, - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"showActivatorAction2", - @"label": @"Easy-Tap-Mode Activation", - //@"enabled": objc_getClass("LAEventSettingsController") != nil, - }, - @{ - @"cell": @"PSLinkCell", - @"action": @"showActivatorAction3", - @"label": @"Create App Window Activation", - //@"enabled": objc_getClass("LAEventSettingsController") != nil, - }, - - /* - @{ - @"cell": @"PSSwitchCell", - @"default": @NO, - @"defaults": @"com.efrederickson.reachapp.settings", - @"key": @"openLinksInWindows", - @"label": @"Open links in windows", - @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", - }, - */ - ]; +- (NSArray*)customSpecifiers { + return @[ + @{ @"footerText": @"Quickly enable or disable Empoleon." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"windowedMultitaskingEnabled", + @"label": @"Enabled", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"label": @"Swipe Up From Bottom...", @"footerText": @"Launches all apps into windows rather than fullscreen." }, + @{ + @"cell": @"PSSegmentCell", + @"validTitles": @[ @"Left", @"Middle", @"Right" ], + @"validValues": @[ @(RAGrabAreaBottomLeftThird), @(RAGrabAreaBottomMiddleThird), @(RAGrabAreaBottomRightThird), ], + @"default": @(RAGrabAreaBottomLeftThird), + @"key": @"windowedMultitaskingGrabArea", + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"launchIntoWindows", + @"label": @"Launch Into Window", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"footerText": @"If disabled, you will not be able to resize and rotate windows unless the easy-tap-mode overlay is displayed." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"alwaysEnableGestures", + @"label": @"Always Enable Gestures", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"onlyShowWindowBarIconsOnOverlay", + @"label": @"Only Show Icons in Easy-Tap-Mode", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"footerText": @"If enabled, tapping an icon on the easy-tap-mode overlay will be delayed until the bounce animation is complete." }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"windowedMultitaskingCompleteAnimations", + @"label": @"Complete Animations", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"label": @"Snapping" }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"snapWindows", + @"label": @"Snap Windows", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ + @"cell": @"PSSwitchCell", + @"default": @YES, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"snapRotation", + @"label": @"Rotation Snapping", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"showSnapHelper", + @"label": @"Show Snap Helper", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"label": @"Lock button action" }, + @{ + @"cell": @"PSSegmentCell", + @"validTitles": @[ @"Lock All Rotation", @"Lock App Rotation" ], + @"validValues": @[ @0, @1 ], + @"default": @0, + @"key": @"windowRotationLockMode", + @"defaults": @"com.efrederickson.reachapp.settings", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + + @{ @"label": @"Activator" }, + @{ + @"cell": @"PSLinkCell", + @"action": @"showActivatorAction", + @"label": @"Sort Windows Activation", + //@"enabled": objc_getClass("LAEventSettingsController") != nil, + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"showActivatorAction2", + @"label": @"Easy-Tap-Mode Activation", + //@"enabled": objc_getClass("LAEventSettingsController") != nil, + }, + @{ + @"cell": @"PSLinkCell", + @"action": @"showActivatorAction3", + @"label": @"Create App Window Activation", + //@"enabled": objc_getClass("LAEventSettingsController") != nil, + }, + + /* + @{ + @"cell": @"PSSwitchCell", + @"default": @NO, + @"defaults": @"com.efrederickson.reachapp.settings", + @"key": @"openLinksInWindows", + @"label": @"Open links in windows", + @"PostNotification": @"com.efrederickson.reachapp.settings/reloadSettings", + }, + */ + ]; } --(void) showActivatorAction -{ - id activator = %c(LAListenerSettingsViewController); - if (!activator) - { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; - [alert addAction:cancelAction]; - [self presentViewController:alert animated:YES completion:nil]; - } - else - { - LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; - vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.sortWindows"; - [self.rootController pushController:vc animate:YES]; - } +- (void)showActivatorAction { + id activator = %c(LAListenerSettingsViewController); + if (!activator) { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; + } else { + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; + vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.sortWindows"; + [self.rootController pushController:vc animate:YES]; + } } --(void) showActivatorAction2 -{ - id activator = %c(LAListenerSettingsViewController); - if (!activator) - { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; - [alert addAction:cancelAction]; - [self presentViewController:alert animated:YES completion:nil]; - } - else - { - LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; - vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"; - [self.rootController pushController:vc animate:YES]; - } +- (void)showActivatorAction2 { + id activator = %c(LAListenerSettingsViewController); + if (!activator) { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; + } else { + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; + vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.toggleEditMode"; + [self.rootController pushController:vc animate:YES]; + } } --(void) showActivatorAction3 -{ - id activator = %c(LAListenerSettingsViewController); - if (!activator) - { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; - [alert addAction:cancelAction]; - [self presentViewController:alert animated:YES completion:nil]; - } - else - { - LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; - vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.createWindow"; - [self.rootController pushController:vc animate:YES]; - } +- (void)showActivatorAction3 { + id activator = %c(LAListenerSettingsViewController); + if (!activator) { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:LOCALIZE(@"Multiplexer") message:@"Activator must be installed to use this feature." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; + } else { + LAListenerSettingsViewController *vc = [[%c(LAListenerSettingsViewController) alloc] init]; + vc.listenerName = @"com.efrederickson.reachapp.windowedmultitasking.createWindow"; + [self.rootController pushController:vc animate:YES]; + } } @end diff --git a/widgets/Core/RAWidgetBase.h b/widgets/Core/RAWidgetBase.h index c2f4e0f..144d0ba 100644 --- a/widgets/Core/RAWidgetBase.h +++ b/widgets/Core/RAWidgetBase.h @@ -1,9 +1,9 @@ #import "headers.h" @interface RAWidgetBase : UIView --(NSString*) identifier; --(NSString*) displayName; +- (NSString*)identifier; +- (NSString*)displayName; --(void) didAppear; --(void) didDisappear; -@end \ No newline at end of file +- (void)didAppear; +- (void)didDisappear; +@end diff --git a/widgets/Core/RAWidgetBase.xm b/widgets/Core/RAWidgetBase.xm index 4e922a5..90c04d0 100644 --- a/widgets/Core/RAWidgetBase.xm +++ b/widgets/Core/RAWidgetBase.xm @@ -1,16 +1,19 @@ #import "RAWidgetBase.h" @implementation RAWidgetBase --(NSString*) identifier { return nil; } --(NSString*) displayName { return nil; } +- (NSString*)identifier { + return nil; +} + +- (NSString*)displayName { + return nil; +} --(void) didAppear -{ +- (void)didAppear { } --(void) didDisappear -{ +- (void)didDisappear { } -@end \ No newline at end of file +@end diff --git a/widgets/Core/RAWidgetHostManager.h b/widgets/Core/RAWidgetHostManager.h index 37363eb..792cd19 100644 --- a/widgets/Core/RAWidgetHostManager.h +++ b/widgets/Core/RAWidgetHostManager.h @@ -4,10 +4,10 @@ @interface RAWidgetHostManager : NSObject { NSMutableArray *widgets; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(void) addWidget:(RAWidgetBase*)widget; --(void) removeWidget:(RAWidgetBase*)widget; --(void) removeWidgetWithIdentifier:(NSString*)identifier; --(RAWidgetBase*) widgetForIdentifier:(NSString*)identifier; +- (void)addWidget:(RAWidgetBase*)widget; +- (void)removeWidget:(RAWidgetBase*)widget; +- (void)removeWidgetWithIdentifier:(NSString*)identifier; +- (RAWidgetBase*)widgetForIdentifier:(NSString*)identifier; @end diff --git a/widgets/Core/RAWidgetHostManager.xm b/widgets/Core/RAWidgetHostManager.xm index 0b6f035..c4731cc 100644 --- a/widgets/Core/RAWidgetHostManager.xm +++ b/widgets/Core/RAWidgetHostManager.xm @@ -1,40 +1,33 @@ #import "RAWidgetHostManager.h" @implementation RAWidgetHostManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE2(RAWidgetHostManager, sharedInstance->widgets = [NSMutableArray array]); } --(void) addWidget:(RAWidgetBase*)widget -{ - if (![widgets containsObject:widget]) - [widgets addObject:widget]; +- (void)addWidget:(RAWidgetBase*)widget { + if ([widgets containsObject:widget]) { + return; + } + [widgets addObject:widget]; } --(void) removeWidget:(RAWidgetBase*)widget -{ +- (void)removeWidget:(RAWidgetBase*)widget { [self removeWidgetWithIdentifier:widget.identifier]; } --(void) removeWidgetWithIdentifier:(NSString*)identifier -{ - for (RAWidgetBase *w in widgets) - { - if ([w.identifier isEqual:identifier]) - { +- (void)removeWidgetWithIdentifier:(NSString*)identifier { + for (RAWidgetBase *w in widgets) { + if ([w.identifier isEqual:identifier]) { [widgets removeObject:w]; return; } } } --(RAWidgetBase*) widgetForIdentifier:(NSString*)identifier -{ - for (RAWidgetBase *w in widgets) - { - if ([w.identifier isEqual:identifier]) - { +- (RAWidgetBase*)widgetForIdentifier:(NSString*)identifier { + for (RAWidgetBase *w in widgets) { + if ([w.identifier isEqual:identifier]) { return w; } } diff --git a/widgets/Reachability/RAAllAppsWidget.xm b/widgets/Reachability/RAAllAppsWidget.xm index 5ab4583..910f960 100644 --- a/widgets/Reachability/RAAllAppsWidget.xm +++ b/widgets/Reachability/RAAllAppsWidget.xm @@ -10,16 +10,27 @@ @end @implementation RAAllAppsWidget --(BOOL) enabled { return [RASettings.sharedInstance showAllAppsInWidgetSelector]; } +- (BOOL)enabled { + return [RASettings.sharedInstance showAllAppsInWidgetSelector]; +} --(NSInteger) sortOrder { return 3; } +- (NSInteger)sortOrder { + return 3; +} --(NSString*) displayName { return LOCALIZE(@"ALL_APPS"); } --(NSString*) identifier { return @"com.efrederickson.reachapp.widgets.sections.allapps"; } --(CGFloat) titleOffset { return savedX; } +- (NSString*)displayName { + return LOCALIZE(@"ALL_APPS"); +} + +- (NSString*)identifier { + return @"com.efrederickson.reachapp.widgets.sections.allapps"; +} --(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size_ iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing -{ +- (CGFloat)titleOffset { + return savedX; +} + +- (UIView*)viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size_ iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing { UIScrollView *allAppsView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 200)]; CGSize size = [%c(SBIconView) defaultIconSize]; @@ -40,17 +51,16 @@ allAppsView.pagingEnabled = [RASettings.sharedInstance pagingEnabled]; static NSMutableArray *allApps = nil; - if (!allApps) - { + if (!allApps) { if ([%c(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { allApps = [[[[%c(SBIconViewMap) homescreenMap] iconModel] visibleIconIdentifiers] mutableCopy]; } else { allApps = [[[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] visibleIconIdentifiers] mutableCopy]; } - [allApps sortUsingComparator: ^(NSString* a, NSString* b) { - NSString *a_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:a].displayName; - NSString *b_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:b].displayName; - return [a_ caseInsensitiveCompare:b_]; + [allApps sortUsingComparator: ^(NSString* a, NSString* b) { + NSString *a_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:a].displayName; + NSString *b_ = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:b].displayName; + return [a_ caseInsensitiveCompare:b_]; }]; //[allApps removeObject:currentBundleIdentifier]; } @@ -58,8 +68,7 @@ isTop = YES; intervalCount = 1; hasSecondRow = NO; - for (NSString *str in allApps) - { + for (NSString *str in allApps) { app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:str]; SBApplicationIcon *icon = nil; SBIconView *iconView = nil; @@ -70,18 +79,15 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) + if (!iconView || ![icon isKindOfClass:[%c(SBApplicationIcon) class]]) { continue; + } - if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) - { - if (isTop) - { + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { + if (isTop) { contentSize.height += size.height + 10; contentSize.width -= interval; - } - else - { + } else { intervalCount++; contentSize.height -= (size.height + 10); width += interval; @@ -109,15 +115,13 @@ return allAppsView; } --(void) appViewItemTap:(UIGestureRecognizer*)gesture -{ +- (void)appViewItemTap:(UIGestureRecognizer*)gesture { [GET_SBWORKSPACE appViewItemTap:gesture]; //[[RAReachabilityManager sharedInstance] launchTopAppWithIdentifier:gesture.view.restorationIdentifier]; } @end -%ctor -{ +%ctor { static id _widget = [[RAAllAppsWidget alloc] init]; [RAWidgetSectionManager.sharedInstance registerSection:_widget]; } diff --git a/widgets/Reachability/RADefaultWidgetSection.h b/widgets/Reachability/RADefaultWidgetSection.h index 421a1bd..7ebaff4 100644 --- a/widgets/Reachability/RADefaultWidgetSection.h +++ b/widgets/Reachability/RADefaultWidgetSection.h @@ -2,5 +2,5 @@ #import "RAWidget.h" @interface RADefaultWidgetSection : RAWidgetSection -+(instancetype) sharedDefaultWidgetSection; ++ (instancetype)sharedDefaultWidgetSection; @end diff --git a/widgets/Reachability/RADefaultWidgetSection.mm b/widgets/Reachability/RADefaultWidgetSection.mm index a3aeb21..76dd71c 100644 --- a/widgets/Reachability/RADefaultWidgetSection.mm +++ b/widgets/Reachability/RADefaultWidgetSection.mm @@ -4,24 +4,20 @@ #import "headers.h" @implementation RADefaultWidgetSection -+(instancetype) sharedDefaultWidgetSection -{ ++ (instancetype)sharedDefaultWidgetSection { SHARED_INSTANCE2(RADefaultWidgetSection, [[RAWidgetSectionManager sharedInstance] registerSection:sharedInstance]); } --(NSString*) displayName -{ +- (NSString*)displayName { return LOCALIZE(@"WIDGETS"); } --(NSString*) identifier -{ +- (NSString*)identifier { return @"com.efrederickson.reachapp.widgets.sections.default"; } @end -static __attribute__((constructor)) void cant_believe_i_forgot_this_before() -{ +static __attribute__((constructor)) void cant_believe_i_forgot_this_before() { static id _widget = [RADefaultWidgetSection sharedDefaultWidgetSection]; [RAWidgetSectionManager.sharedInstance registerSection:_widget]; } diff --git a/widgets/Reachability/RAFavoriteAppsWidget.xm b/widgets/Reachability/RAFavoriteAppsWidget.xm index e3ae7ba..9148451 100644 --- a/widgets/Reachability/RAFavoriteAppsWidget.xm +++ b/widgets/Reachability/RAFavoriteAppsWidget.xm @@ -10,20 +10,33 @@ @end @implementation RAFavoriteAppsWidget --(BOOL) enabled { return [RASettings.sharedInstance showFavorites]; } +- (BOOL)enabled { + return [RASettings.sharedInstance showFavorites]; +} + +- (NSInteger)sortOrder { + return 2; +} + +- (NSString*)displayName { + return LOCALIZE(@"FAVORITES"); +} + +- (NSString*)identifier { + return @"com.efrederickson.reachapp.widgets.sections.favoriteapps"; +} --(NSInteger) sortOrder { return 2; } --(NSString*) displayName { return LOCALIZE(@"FAVORITES"); } --(NSString*) identifier { return @"com.efrederickson.reachapp.widgets.sections.favoriteapps"; } --(CGFloat) titleOffset { return savedX; } +- (CGFloat)titleOffset { + return savedX; +} --(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size_ iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing -{ +- (UIView*)viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size_ iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing { CGSize size = [%c(SBIconView) defaultIconSize]; spacing = (frame.size.width - (iconsPerLine * size.width)) / iconsPerLine; NSString *currentBundleIdentifier = [[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; - if (!currentBundleIdentifier) + if (!currentBundleIdentifier) { return nil; + } CGSize contentSize = CGSizeMake((spacing / 2.0), 10); CGFloat interval = (size.width + spacing) * iconsPerLine; NSInteger intervalCount = 1; @@ -35,14 +48,14 @@ NSMutableArray *favorites = [RASettings.sharedInstance favoriteApps]; [favorites removeObject:currentBundleIdentifier]; - if (favorites.count == 0) + if (favorites.count == 0) { return nil; + } UIScrollView *favoritesView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 200)]; favoritesView.backgroundColor = [UIColor clearColor]; favoritesView.pagingEnabled = [RASettings.sharedInstance pagingEnabled]; - for (NSString *str in favorites) - { + for (NSString *str in favorites) { app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:str]; SBApplicationIcon *icon = nil; SBIconView *iconView = nil; @@ -53,18 +66,15 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView) + if (!iconView) { continue; + } - if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) - { - if (isTop) - { + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { + if (isTop) { contentSize.height += size.height + 10; contentSize.width -= interval; - } - else - { + } else { intervalCount++; contentSize.height -= (size.height + 10); width += interval; @@ -93,15 +103,13 @@ return favoritesView; } --(void) appViewItemTap:(UIGestureRecognizer*)gesture -{ +- (void)appViewItemTap:(UIGestureRecognizer*)gesture { [GET_SBWORKSPACE appViewItemTap:gesture]; //[[RAReachabilityManager sharedInstance] launchTopAppWithIdentifier:gesture.view.restorationIdentifier]; } @end -%ctor -{ +%ctor { static id _widget = [[RAFavoriteAppsWidget alloc] init]; [RAWidgetSectionManager.sharedInstance registerSection:_widget]; } diff --git a/widgets/Reachability/RARecentAppsWidget.xm b/widgets/Reachability/RARecentAppsWidget.xm index 51f09a2..3c56407 100644 --- a/widgets/Reachability/RARecentAppsWidget.xm +++ b/widgets/Reachability/RARecentAppsWidget.xm @@ -15,21 +15,34 @@ @end @implementation RARecentAppsWidget --(BOOL) enabled { return [RASettings.sharedInstance showRecentAppsInWidgetSelector]; } +- (BOOL)enabled { + return [RASettings.sharedInstance showRecentAppsInWidgetSelector]; +} + +- (NSInteger)sortOrder { + return 1; +} + +- (NSString*)displayName { + return LOCALIZE(@"RECENTS"); +} + +- (NSString*)identifier { + return @"com.efrederickson.reachapp.widgets.sections.recentapps"; +} --(NSInteger) sortOrder { return 1; } --(NSString*) displayName { return LOCALIZE(@"RECENTS"); } --(NSString*) identifier { return @"com.efrederickson.reachapp.widgets.sections.recentapps"; } --(CGFloat) titleOffset { return savedX; } +- (CGFloat)titleOffset { + return savedX; +} --(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size_ iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing -{ +- (UIView*)viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size_ iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing { viewFrame = frame; CGSize size = [%c(SBIconView) defaultIconSize]; spacing = (frame.size.width - (iconsPerLine * size.width)) / (iconsPerLine + 0); NSString *currentBundleIdentifier = [[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; - if (!currentBundleIdentifier) + if (!currentBundleIdentifier) { return nil; + } CGSize contentSize = CGSizeMake((spacing / 2.0), 10); CGFloat interval = ((size.width + spacing) * iconsPerLine); NSInteger intervalCount = 1; @@ -41,8 +54,9 @@ NSMutableArray *recents = [[RAAppSwitcherModelWrapper appSwitcherAppIdentiferList] mutableCopy]; [recents removeObject:currentBundleIdentifier]; - if (recents.count == 0) + if (recents.count == 0) { return nil; + } BOOL hasSecondRow = recents.count >= iconsPerLine; @@ -50,8 +64,7 @@ recentsView.backgroundColor = [UIColor clearColor]; recentsView.pagingEnabled = [RASettings.sharedInstance pagingEnabled]; - for (NSString *str in recents) - { + for (NSString *str in recents) { app = [[%c(SBApplicationController) sharedInstance] applicationWithBundleIdentifier:str]; SBApplicationIcon *icon = nil; SBIconView *iconView = nil; @@ -62,18 +75,15 @@ icon = [[[[%c(SBIconController) sharedInstance] homescreenIconViewMap] iconModel] applicationIconForBundleIdentifier:app.bundleIdentifier]; iconView = [[[%c(SBIconController) sharedInstance] homescreenIconViewMap] _iconViewForIcon:icon]; } - if (!iconView) + if (!iconView) { continue; + } - if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) - { - if (isTop) - { + if (interval != 0 && contentSize.width + iconView.frame.size.width > interval * intervalCount) { + if (isTop) { contentSize.height += size.height + 10; contentSize.width -= interval; - } - else - { + } else { intervalCount++; contentSize.height -= (size.height + 10); width += interval; @@ -101,8 +111,7 @@ return recentsView; } --(void) appViewItemTap:(UIGestureRecognizer*)gesture -{ +- (void)appViewItemTap:(UIGestureRecognizer*)gesture { @autoreleasepool { //[[%c(SBWorkspace) sharedInstance] appViewItemTap:gesture]; @@ -120,8 +129,7 @@ } @end -%ctor -{ +%ctor { static id _widget = [[RARecentAppsWidget alloc] init]; [RAWidgetSectionManager.sharedInstance registerSection:_widget]; } diff --git a/widgets/Reachability/RAWidget.h b/widgets/Reachability/RAWidget.h index f0f1b27..6929a82 100644 --- a/widgets/Reachability/RAWidget.h +++ b/widgets/Reachability/RAWidget.h @@ -2,13 +2,13 @@ @interface RAWidget : NSObject --(NSString*) identifier; +- (NSString*)identifier; // actual view for showing in Reachability --(UIView*) view; +- (UIView*)view; // Similar to an app icon with the image/title --(UIView*) iconForSize:(CGSize)size; +- (UIView*)iconForSize:(CGSize)size; --(CGFloat) preferredHeight; -@end \ No newline at end of file +- (CGFloat)preferredHeight; +@end diff --git a/widgets/Reachability/RAWidget.mm b/widgets/Reachability/RAWidget.mm index 608b2c1..3f24a0a 100644 --- a/widgets/Reachability/RAWidget.mm +++ b/widgets/Reachability/RAWidget.mm @@ -2,23 +2,19 @@ @implementation RAWidget --(NSString*)identifier -{ +- (NSString*)identifier { @throw @"This is an abstract method and must be overriden"; } --(UIView*) view -{ +- (UIView*)view { @throw @"This is an abstract method and must be overriden"; } --(UIView*) iconForSize:(CGSize)size -{ +- (UIView*)iconForSize:(CGSize)size { @throw @"This is an abstract method and must be overriden"; } --(CGFloat) preferredHeight -{ +- (CGFloat)preferredHeight { return self.view.frame.size.height; } -@end \ No newline at end of file +@end diff --git a/widgets/Reachability/RAWidgetSection.h b/widgets/Reachability/RAWidgetSection.h index ea7cd34..afd7dac 100644 --- a/widgets/Reachability/RAWidgetSection.h +++ b/widgets/Reachability/RAWidgetSection.h @@ -5,17 +5,17 @@ NSMutableArray *_widgets; } --(BOOL) enabled; +- (BOOL)enabled; --(NSInteger) sortOrder; --(BOOL) showTitle; --(NSString*) displayName; --(NSString*) identifier; --(CGFloat) titleOffset; +- (NSInteger)sortOrder; +- (BOOL)showTitle; +- (NSString*)displayName; +- (NSString*)identifier; +- (CGFloat)titleOffset; -// The view should cache, if possible, to speed up loading times. -// It should NOT show the title view. --(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing; +// The view should cache, if possible, to speed up loading times. +// It should NOT show the title view. +- (UIView*)viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing; --(void) addWidget:(RAWidget*)widget; -@end \ No newline at end of file +- (void)addWidget:(RAWidget*)widget; +@end diff --git a/widgets/Reachability/RAWidgetSection.mm b/widgets/Reachability/RAWidgetSection.mm index bc8d881..8977b60 100644 --- a/widgets/Reachability/RAWidgetSection.mm +++ b/widgets/Reachability/RAWidgetSection.mm @@ -3,43 +3,43 @@ @implementation RAWidgetSection --(instancetype) init -{ - if (self = [super init]) - { +- (instancetype)init { + if (self = [super init]) { _widgets = [NSMutableArray array]; } return self; } --(BOOL) enabled { return _widgets.count > 0; } --(BOOL) showTitle { return YES; } +- (BOOL)enabled { + return _widgets.count > 0; +} + +- (BOOL)showTitle { + return YES; +} --(NSInteger) sortOrder { return 10; } +- (NSInteger)sortOrder { + return 10; +} --(NSString*) displayName -{ +- (NSString*)displayName { @throw @"This is an abstract method and should be overriden."; } --(NSString*) identifier -{ +- (NSString*)identifier { @throw @"This is an abstract method and should be overriden."; } --(void) addWidget:(RAWidget*)widget -{ +- (void)addWidget:(RAWidget*)widget { [_widgets addObject:widget]; } --(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing -{ +- (UIView*)viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing { UIView *view = [[UIView alloc] initWithFrame:frame]; view.userInteractionEnabled = YES; CGPoint origin = CGPointMake(10, 10); - for (NSInteger index = 0; index < _widgets.count; index++) - { + for (NSInteger index = 0; index < _widgets.count; index++) { RAWidget *widget = _widgets[index]; UIView *subView = [widget iconForSize:size]; @@ -61,14 +61,12 @@ -(UIView*) viewForFrame:(CGRect)frame preferredIconSize:(CGSize)size iconsThatFi return view; } --(void) widgetIconTap:(UITapGestureRecognizer*)gesture -{ +- (void)widgetIconTap:(UITapGestureRecognizer*)gesture { NSInteger widgetIndex = gesture.view.tag; [[RAReachabilityManager sharedInstance] launchWidget:_widgets[widgetIndex]]; } --(CGFloat) titleOffset -{ +- (CGFloat)titleOffset { return 10; } @end diff --git a/widgets/Reachability/RAWidgetSectionManager.h b/widgets/Reachability/RAWidgetSectionManager.h index fecb99d..8a3b243 100644 --- a/widgets/Reachability/RAWidgetSectionManager.h +++ b/widgets/Reachability/RAWidgetSectionManager.h @@ -5,12 +5,12 @@ NSMutableDictionary *_sections; } -+(instancetype) sharedInstance; ++ (instancetype)sharedInstance; --(void) registerSection:(RAWidgetSection*)section; +- (void)registerSection:(RAWidgetSection*)section; --(NSArray*) sections; --(NSArray*) enabledSections; +- (NSArray*)sections; +- (NSArray*)enabledSections; --(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIconSize:(CGSize)size iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing; -@end \ No newline at end of file +- (UIView*)createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIconSize:(CGSize)size iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing; +@end diff --git a/widgets/Reachability/RAWidgetSectionManager.mm b/widgets/Reachability/RAWidgetSectionManager.mm index 3fdc949..fbee16f 100644 --- a/widgets/Reachability/RAWidgetSectionManager.mm +++ b/widgets/Reachability/RAWidgetSectionManager.mm @@ -6,43 +6,39 @@ @implementation RAWidgetSectionManager -+(instancetype) sharedInstance -{ ++ (instancetype)sharedInstance { SHARED_INSTANCE(RAWidgetSectionManager); } --(instancetype) init -{ - if (self = [super init]) - { +- (instancetype)init { + if (self = [super init]) { _sections = [NSMutableDictionary dictionary]; } return self; } --(void) registerSection:(RAWidgetSection*)section -{ - if (!section || !section.identifier) +- (void)registerSection:(RAWidgetSection*)section { + if (!section || !section.identifier) { return; - if ([_sections.allKeys containsObject:section.identifier]) + } + if ([_sections.allKeys containsObject:section.identifier]) { return; + } //NSLog(@"[ReachApp] registering section %@", section.identifier); _sections[section.identifier] = section; } --(NSArray*) sections -{ +- (NSArray*)sections { return _sections.allValues; } --(NSArray*) enabledSections -{ +- (NSArray*)enabledSections { NSMutableArray *arr = [NSMutableArray array]; - for (RAWidgetSection* section in _sections.allValues) - { - if ([section enabled]) + for (RAWidgetSection* section in _sections.allValues) { + if ([section enabled]) { [arr addObject:section]; + } } //[arr sortUsingComparator:^(RAWidgetSection *a, RAWidgetSection *b) { @@ -50,19 +46,19 @@ -(NSArray*) enabledSections //}]; [arr sortUsingComparator:^NSComparisonResult(RAWidgetSection *a, RAWidgetSection *b) { - if (a.sortOrder < b.sortOrder) + if (a.sortOrder < b.sortOrder) { return NSOrderedAscending; - else if (a.sortOrder > b.sortOrder) + } else if (a.sortOrder > b.sortOrder) { return NSOrderedDescending; - else + } else { return NSOrderedSame; + } }]; return arr; } --(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIconSize:(CGSize)iconSize iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing -{ +- (UIView*)createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIconSize:(CGSize)iconSize iconsThatFitPerLine:(NSInteger)iconsPerLine spacing:(CGFloat)spacing { // vertical scroll view? UIView *view = [[UIView alloc] initWithFrame:frame]; view.backgroundColor = [UIColor clearColor]; @@ -71,17 +67,14 @@ -(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIcon CGFloat currentY = VERTICAL_PADDING; - for (RAWidgetSection* section in [self enabledSections]) - { - if (!section.enabled) + for (RAWidgetSection* section in [self enabledSections]) { + if (!section.enabled) { continue; - @try - { + } + @try { UIView *sectionView = [section viewForFrame:CGRectMake(0, currentY, view.frame.size.width, iconSize.height + VERTICAL_PADDING) preferredIconSize:iconSize iconsThatFitPerLine:iconsPerLine spacing:spacing]; - if (sectionView) - { - if (section.showTitle) - { + if (sectionView) { + if (section.showTitle) { CGFloat x = [section respondsToSelector:@selector(titleOffset)] ? section.titleOffset : 10; UILabel *titleView = [[UILabel alloc] initWithFrame:CGRectMake(x, currentY, 300, 20)]; titleView.text = section.displayName; @@ -106,8 +99,7 @@ -(UIView*) createViewForEnabledSectionsWithBaseFrame:(CGRect)frame preferredIcon [view addSubview:sectionView]; } } - @catch (NSException *ex) - { + @catch (NSException *ex) { LogError(@"[ReachApp] an error occurred creating the view for section '%@': %@", section.identifier, ex); } } From 6706ecd15fe9a8a4b9acc65681bb16d5b2a8f8f1 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 17 Mar 2017 19:54:17 -0500 Subject: [PATCH 55/59] Fixed localizations + Spanish localization --- MissionControl/RAMissionControlManager.xm | 8 +++---- MissionControl/RAMissionControlWindow.xm | 7 +++++- RALocalizer.mm | 10 ++++---- SwipeOver/RASwipeOverOverlay.xm | 2 -- headers.h | 2 +- .../Multiplexer/Localizations/es.strings | 24 +++++++++++++++++++ 6 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 layout/Library/Multiplexer/Localizations/es.strings diff --git a/MissionControl/RAMissionControlManager.xm b/MissionControl/RAMissionControlManager.xm index 68fb139..c742c19 100644 --- a/MissionControl/RAMissionControlManager.xm +++ b/MissionControl/RAMissionControlManager.xm @@ -102,7 +102,6 @@ CGRect swappedForOrientation2(CGRect in) { if (originalAppView) { originalAppView.frame = swappedForOrientation2(CGRectMake(originalAppFrame.origin.x, originalAppView.frame.size.height, originalAppFrame.size.width, originalAppFrame.size.height)); - } } completion:nil]; } else if (originalAppView) { // dismiss even if not animating open @@ -141,8 +140,7 @@ CGRect swappedForOrientation2(CGRect in) { [window _rotateWindowToOrientation:UIApplication.sharedApplication.statusBarOrientation updateStatusBar:YES duration:1 skipCallbacks:NO]; //_UIBackdropView *blurView = [[%c(_UIBackdropView) alloc] initWithStyle:1]; - _UIBackdropViewSettings *blurSettings = [_UIBackdropViewSettings settingsForStyle:THEMED(missionControlBlurStyle)]; - [blurSettings setBlurQuality:@"low"]; // speed++ hopefully + _UIBackdropViewSettings *blurSettings = [_UIBackdropViewSettings settingsForStyle:THEMED(missionControlBlurStyle) graphicsQuality:10]; // speed++ hopefully _UIBackdropView *blurView = [[%c(_UIBackdropView) alloc] initWithSettings:blurSettings]; blurView.frame = window.frame; [window addSubview:blurView]; @@ -155,10 +153,10 @@ CGRect swappedForOrientation2(CGRect in) { [window addSubview:statusBar]; [statusBar setOrientation:UIApplication.sharedApplication.statusBarOrientation]; - // DESKTOPS + // DESKTOPS TODO: causes lag [self reloadDesktopSection]; - // APPS WITH PANES + // APPS WITH PANES TODO: also causes minor lag [self reloadWindowedAppsSection]; // APPS WITHOUT PANES diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index f9d8f95..06d34f3 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -88,8 +88,13 @@ for (RADesktopWindow *desktop in [[%c(RADesktopManager) sharedInstance] availableDesktops]) { RAMissionControlPreviewView *preview = [[RAMissionControlPreviewView alloc] initWithFrame:CGRectMake(x, (desktopScrollView.frame.size.height - height) / 2.0, width, height)]; x += panePadding + preview.frame.size.width; + preview.alpha = 0; - [desktopScrollView addSubview:preview]; + [UIView animateWithDuration:1 animations:^{ + preview.alpha = 1; + } completion:^(BOOL finished) { + [desktopScrollView addSubview:preview]; + }]; //preview.image = [[%c(RASnapshotProvider) sharedInstance] snapshotForDesktop:desktop]; [preview generateDesktopPreviewAsync:desktop completion:desktop == [[%c(RADesktopManager) sharedInstance] currentDesktop] ? ^{ [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; } : (dispatch_block_t)nil]; diff --git a/RALocalizer.mm b/RALocalizer.mm index b9fcb79..3446cc3 100644 --- a/RALocalizer.mm +++ b/RALocalizer.mm @@ -20,19 +20,19 @@ - (void)loadTranslation { NSArray *langs = [NSLocale preferredLanguages]; for (NSString *lang in langs) { - //NSDictionary *components = [NSLocale componentsFromLocaleIdentifier:lang]; - //NSString *languageDesignator = components[NSLocaleLanguageCode]; - if ([self attemptLoadForLanguageCode:lang]) { + NSDictionary *components = [NSLocale componentsFromLocaleIdentifier:lang]; + NSString *languageDesignator = components[NSLocaleLanguageCode]; + + if ([self attemptLoadForLanguageCode:languageDesignator]) { break; } } if (!translation) { - LogWarn(@"Failed Translation loading English"); [self attemptLoadForLanguageCode:@"en"]; } } - (NSString*)localizedStringForKey:(NSString*)key { - return [translation objectForKey:key] ? translation[key] : key; + return ![translation objectForKey:key] ? key : translation[key]; } @end diff --git a/SwipeOver/RASwipeOverOverlay.xm b/SwipeOver/RASwipeOverOverlay.xm index 263f350..b6cfb81 100644 --- a/SwipeOver/RASwipeOverOverlay.xm +++ b/SwipeOver/RASwipeOverOverlay.xm @@ -39,11 +39,9 @@ } isHidingUnderlyingApp = YES; - // TODO: use UIBlurEffect? UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; darkenerView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; darkenerView.frame = self.frame; - darkenerView.alpha = 0.85; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(darkenerViewTap:)]; [darkenerView addGestureRecognizer:tap]; [self addSubview:darkenerView]; diff --git a/headers.h b/headers.h index 2b1914d..21e3296 100644 --- a/headers.h +++ b/headers.h @@ -40,7 +40,7 @@ #import "RASBWorkspaceFetcher.h" #define GET_SBWORKSPACE [RASBWorkspaceFetcher getCurrentSBWorkspaceImplementationInstanceForThisOS] -#define GET_STATUSBAR_ORIENTATION (UIApplication.sharedApplication._accessibilityFrontMostApplication == nil ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) +#define GET_STATUSBAR_ORIENTATION (![UIApplication sharedApplication]._accessibilityFrontMostApplication ? UIApplication.sharedApplication.statusBarOrientation : UIApplication.sharedApplication._accessibilityFrontMostApplication.statusBarOrientation) #if DEBUG #define LogDebug HBLogDebug diff --git a/layout/Library/Multiplexer/Localizations/es.strings b/layout/Library/Multiplexer/Localizations/es.strings new file mode 100644 index 0000000..25c88bd --- /dev/null +++ b/layout/Library/Multiplexer/Localizations/es.strings @@ -0,0 +1,24 @@ +"BIOLOCKDOWN_AUTH_DESCRIPTION" = "Multiplexer necesita autenticación"; +"BIOLOCKDOWN_AUTH_FAILED" = "Autenticación de BioLockdown falló para %@. Toca para tratar otra vez."; +"MULTIPLEXER" = "Multiplexer"; +"BACKGROUNDER_POPUP_SWITCHER_TEXT" = "Cual modo de fondo quieres usar par %@ (Ahorita es %@)?"; +"CANCEL" = "Cancela"; +"FORCE_FOREGROUND" = "Forzar primer plano"; +"NATIVE" = "Nativo"; +"SUSPEND_IMMEDIATELY" = "Suspende inmediatamente"; +"DISABLE" = "Inhabilitar"; +"THANK_YOU_TEXT" = "Gracias por instalando Multiplexer! Toca aquí para ver el tutorial."; +"DESKTOPS" = "Escritorio"; +"ON_THIS_DESKTOP" = "En este Escritorio"; +"RUNNING_ELSEWHERE" = "Corriendo en otra parte"; +"NO_APPS" = "Ningun Aplicaciones"; +"APP" = "Aplicacion"; +"UNLOCK_FOR_NCAPP" = "Desbloquear para usar\nQuick Access"; +"ALL_APPS" = "All Apps"; +"WIDGETS" = "Widgets"; +"FAVORITES" = "Favoritos"; +"RECENTS" = "Reciente"; +"ACTIVE_APP_WARNING" = "%@\n está abierto"; +"ASPHALEIA_AUTH_FAILED" = "Asphaleia \n Autenticación falló para\n %@.\nToca para tratar otra vez."; +"UNLIMITED_BACKGROUNDING_TIME" = "Ilimitado tiemp en el fondo"; +"KILL_ALL" = "Mata Todos"; From 382d70b00a606b9f5288558da0b4cb410c044c62 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Fri, 17 Mar 2017 21:52:16 -0500 Subject: [PATCH 56/59] Fixed MC lag, broke wallpaper render --- MissionControl/RAMissionControlPreviewView.xm | 4 +- MissionControl/RAMissionControlWindow.xm | 33 +++++------ RASnapshotProvider.xm | 59 ++++++++----------- headers.h | 2 + update_status | 2 +- 5 files changed, 43 insertions(+), 57 deletions(-) diff --git a/MissionControl/RAMissionControlPreviewView.xm b/MissionControl/RAMissionControlPreviewView.xm index 2279b21..1bc38a9 100644 --- a/MissionControl/RAMissionControlPreviewView.xm +++ b/MissionControl/RAMissionControlPreviewView.xm @@ -48,14 +48,14 @@ } - (void)generatePreviewAsync { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ [self generatePreview]; }); } - (void)generateDesktopPreviewAsync:(id)desktop_ completion:(dispatch_block_t)completionBlock { RADesktopWindow *desktop = (RADesktopWindow*)desktop_; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ UIImage *image = [[%c(RASnapshotProvider) sharedInstance] snapshotForDesktop:desktop]; [self performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES]; if (completionBlock) { diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index 06d34f3..e625b4c 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -33,33 +33,29 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { trashIcon = [%c(RAResourceImageProvider) imageForFilename:@"Trash.png"]; + self.windowLevel = 1000; } return self; } -- (UIWindowLevel)windowLevel { - //return UIWindowLevelStatusBar + 1; - return 1000; -} - - (BOOL)_shouldAutorotateToInterfaceOrientation:(int)arg1 checkForDismissal:(BOOL)arg2 isRotationDisabled:(BOOL*)arg3 { return YES; } - (void)reloadDesktopSection { - width = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 4.5714; - height = UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height / 4.36; + width = [UIScreen mainScreen].RA_interfaceOrientedBounds.size.width / 4.5714; + height = [UIScreen mainScreen].RA_interfaceOrientedBounds.size.height / 4.36; panePadding = width; int count = 1; - while (panePadding + width < UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width) { + while (panePadding + width < [UIScreen mainScreen].RA_interfaceOrientedBounds.size.width) { count += 1; panePadding += width; } - panePadding = (UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width - panePadding) / 5; + panePadding = ([UIScreen mainScreen].RA_interfaceOrientedBounds.size.width - panePadding) / 5; /*if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - width = (UIScreen.mainScreen.bounds.size.width / 3) * 0.9; - height = (UIScreen.mainScreen.bounds.size.height / 4) * 0.9; + width = ([UIScreen mainScreen].bounds.size.width / 3) * 0.9; + height = ([UIScreen mainScreen].bounds.size.height / 4) * 0.9; }*/ // DESKTOP @@ -96,6 +92,7 @@ [desktopScrollView addSubview:preview]; }]; //preview.image = [[%c(RASnapshotProvider) sharedInstance] snapshotForDesktop:desktop]; + //fixed lag but need to fix wallpaper; [preview generateDesktopPreviewAsync:desktop completion:desktop == [[%c(RADesktopManager) sharedInstance] currentDesktop] ? ^{ [[%c(RADesktopManager) sharedInstance] performSelectorOnMainThread:@selector(hideDesktop) withObject:nil waitUntilDone:NO]; } : (dispatch_block_t)nil]; if (desktop == [[%c(RADesktopManager) sharedInstance] currentDesktop] && [[%c(RASettings) sharedInstance] missionControlDesktopStyle] == 0) { @@ -142,8 +139,8 @@ //[RADesktopManager.sharedInstance hideDesktop]; // ^^ see the generateDesktopPreviewAsync:completion: call about 40 lines up - //width = UIScreen.mainScreen.bounds.size.width / 4.5714; - //height = UIScreen.mainScreen.bounds.size.height / 4.36; + //width = [UIScreen mainScreen].bounds.size.width / 4.5714; + //height = [UIScreen mainScreen].bounds.size.height / 4.36; } - (void)reloadWindowedAppsSection { @@ -352,7 +349,7 @@ } } - if (parentView.contentSize.width - 1 <= UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width) { + if (parentView.contentSize.width - 1 <= [UIScreen mainScreen].RA_interfaceOrientedBounds.size.width) { ; // don't make it too small to scroll } else if (targetView) { parentView.contentSize = CGSizeMake(parentView.contentSize.width - targetView.frame.size.width - panePadding + 1, parentView.contentSize.height); @@ -368,11 +365,11 @@ if (gesture.state == UIGestureRecognizerStateBegan) { if (!trashImageView || !trashImageView.superview /* new window perhaps */) { - trashImageView = [[UIImageView alloc] initWithFrame:CGRectMake((UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2) - (75/2), UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height + 75, 75, 75)]; + trashImageView = [[UIImageView alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].RA_interfaceOrientedBounds.size.width / 2) - (75/2), [UIScreen mainScreen].RA_interfaceOrientedBounds.size.height + 75, 75, 75)]; trashImageView.image = trashIcon; [self addSubview:trashImageView]; - shadowView = [[UIView alloc] initWithFrame:CGRectMake(0, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height, UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width, 75)]; + shadowView = [[UIView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].RA_interfaceOrientedBounds.size.height, [UIScreen mainScreen].RA_interfaceOrientedBounds.size.width, 75)]; shadowView.backgroundColor = [UIColor blackColor]; shadowView.layer.shadowColor = [UIColor blackColor].CGColor; shadowView.layer.shadowRadius = 75/2; @@ -384,7 +381,7 @@ [UIView animateWithDuration:0.4 animations:^{ shadowView.alpha = 1; trashImageView.alpha = 1; - trashImageView.frame = CGRectMake((UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2) - (75/2), UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height - (75+45), 75, 75); + trashImageView.frame = CGRectMake(([UIScreen mainScreen].RA_interfaceOrientedBounds.size.width / 2) - (75/2), [UIScreen mainScreen].RA_interfaceOrientedBounds.size.height - (75+45), 75, 75); }]; if (!draggedView) { @@ -445,7 +442,7 @@ [UIView animateWithDuration:0.4 animations:^{ shadowView.alpha = 0; trashImageView.alpha = 0; - trashImageView.frame = CGRectMake((UIScreen.mainScreen.RA_interfaceOrientedBounds.size.width / 2) - (75/2), UIScreen.mainScreen.RA_interfaceOrientedBounds.size.height + 75, 75, 75); + trashImageView.frame = CGRectMake(([UIScreen mainScreen].RA_interfaceOrientedBounds.size.width / 2) - (75/2), [UIScreen mainScreen].RA_interfaceOrientedBounds.size.height + 75, 75, 75); } completion:nil]; if (!didKill) { diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index 4e547a5..5c81d45 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -180,51 +180,50 @@ - (UIImage*)renderPreviewForDesktop:(RADesktopWindow*)desktop { @autoreleasepool { UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, 0); - CGContextRef c = UIGraphicsGetCurrentContext(); + //CGContextRef context = UIGraphicsGetCurrentContext(); - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; ON_MAIN_THREAD(^{ [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; //}); - [MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow").layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Wallpaper + UIImage *image = [[%c(SBWallpaperController) sharedInstance] sharedWallpaperView].wallpaperImage; + [image drawInRect:[UIScreen mainScreen].bounds]; // Wallpaper //[[[[%c(SBUIController) sharedInstance] window] layer] performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Icons //ON_MAIN_THREAD(^{ //[MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow") drawViewHierarchyInRect:UIScreen.mainScreen.bounds afterScreenUpdates:YES]; - [[[%c(SBUIController) sharedInstance] window] drawViewHierarchyInRect:UIScreen.mainScreen.bounds afterScreenUpdates:YES]; + [[[%c(SBUIController) sharedInstance] window] drawViewHierarchyInRect:[UIScreen mainScreen].bounds afterScreenUpdates:NO]; - [desktop drawViewHierarchyInRect:UIScreen.mainScreen.bounds afterScreenUpdates:YES]; + [desktop drawViewHierarchyInRect:desktop.bounds afterScreenUpdates:NO]; }); //[desktop.layer performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Desktop windows for (UIView *view in desktop.subviews) { // Application views - if ([view isKindOfClass:[RAWindowBar class]]) { - RAHostedAppView *hostedView = [((RAWindowBar*)view) attachedView]; - - UIImage *image = [self snapshotForIdentifier:hostedView.bundleIdentifier orientation:hostedView.orientation]; - CIImage *coreImage = image.CIImage; - if (!coreImage) { - coreImage = [CIImage imageWithCGImage:image.CGImage]; - } - //coreImage = [coreImage imageByApplyingTransform:view.transform]; - CGFloat rotation = atan2(hostedView.transform.b, hostedView.transform.a); + if (![view isKindOfClass:[RAWindowBar class]]) { + continue; + } + RAHostedAppView *hostedView = [((RAWindowBar*)view) attachedView]; - CGAffineTransform transform = CGAffineTransformMakeRotation(rotation); - coreImage = [coreImage imageByApplyingTransform:transform]; - image = [UIImage imageWithCIImage:coreImage]; - [image drawInRect:view.frame]; // by using frame, we take care of scale. + UIImage *image = [self snapshotForIdentifier:hostedView.bundleIdentifier orientation:hostedView.orientation]; + CIImage *coreImage = image.CIImage; + if (!coreImage) { + coreImage = [CIImage imageWithCGImage:image.CGImage]; } + //coreImage = [coreImage imageByApplyingTransform:view.transform]; + CGFloat rotation = atan2(hostedView.transform.b, hostedView.transform.a); + + CGAffineTransform transform = CGAffineTransformMakeRotation(rotation); + coreImage = [coreImage imageByApplyingTransform:transform]; + image = [UIImage imageWithCIImage:coreImage]; + [image drawInRect:view.frame]; // by using frame, we take care of scale. } //if (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)) // CGContextRotateCTM(c, DEGREES_TO_RADIANS(90)); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); image = [self rotateImageToMatchOrientation:image]; - MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow").layer.contents = nil; - [[[%c(SBUIController) sharedInstance] window] layer].contents = nil; - desktop.layer.contents = nil; [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; return image; } @@ -239,20 +238,8 @@ if ([imageCache objectForKey:key]) { return [imageCache objectForKey:key]; } - UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen.bounds.size, YES, 0); - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"RAWallpaperSnapshot"]; - - ON_MAIN_THREAD(^{ - UIWindow *window = MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow"); - [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; - }); - - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"RAWallpaperSnapshot"]; - - //UIImageView *imgView = [[UIImageView alloc] initWithImage:image];//Frame:(CGRect){CGPointZero,image.size}]; - //imgView.image = image; + //its really that easy elijah + UIImage *image = [[%c(SBWallpaperController) sharedInstance] sharedWallpaperView].wallpaperImage; if (blurred) { CIFilter *gaussianBlurFilter = [CIFilter filterWithName:@"CIGaussianBlur"]; diff --git a/headers.h b/headers.h index 21e3296..0606f8c 100644 --- a/headers.h +++ b/headers.h @@ -234,6 +234,7 @@ return sharedInstance; @end @interface SBFWallpaperView : UIView +@property (nonatomic,readonly) UIImage *wallpaperImage; - (void)setGeneratesBlurredImages:(BOOL)arg1; - (void)_startGeneratingBlurredImages; - (void)prepareToAppear; @@ -485,6 +486,7 @@ typedef struct { @end @interface SBWallpaperController +@property (nonatomic,retain) SBFWallpaperView * sharedWallpaperView; +(id) sharedInstance; -(void) beginRequiringWithReason:(NSString*)reason; -(void) endRequiringWithReason:(NSString*)reason; diff --git a/update_status b/update_status index 2914ddf..66b935b 100644 --- a/update_status +++ b/update_status @@ -28,7 +28,7 @@ Bugs: Minor Things/Bugs to note: - (some of these are leftover from the original release lol: eg MC lag) -- MC works but causes jittery animations (not as much as before) +- Wallpaper doesnt render in Desktops in MC - Some say it causes serious lag (probably because logs werent disabled/due to MC)? - Startup bug still isnt fixed (apparently caused by gesture support?) - Check iPad support/lower iOS versions From 784c51000ca80f63325ea73ec4561fe37c9b43f4 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 18 Mar 2017 11:31:50 -0500 Subject: [PATCH 57/59] Fixed desktop wallpaper in MC --- RAResourceImageProvider.h | 1 + RASnapshotProvider.xm | 23 +++++++++++++++-------- headers.h | 6 +++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/RAResourceImageProvider.h b/RAResourceImageProvider.h index def9e08..585fc2c 100644 --- a/RAResourceImageProvider.h +++ b/RAResourceImageProvider.h @@ -1,6 +1,7 @@ #import "headers.h" @interface RAResourceImageProvider : NSObject ++ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize; + (UIImage*)imageForFilename:(NSString*)filename; + (UIImage*)imageForFilename:(NSString*)filename size:(CGSize)size tintedTo:(UIColor*)tint; + (UIImage*)imageForFilename:(NSString*)filename constrainedToSize:(CGSize)size; diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index 5c81d45..f6681f1 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -1,6 +1,7 @@ #import "headers.h" #import "RASnapshotProvider.h" #import "RAWindowBar.h" +#import "RAResourceImageProvider.h" @implementation RASnapshotProvider + (instancetype)sharedInstance { @@ -180,16 +181,22 @@ - (UIImage*)renderPreviewForDesktop:(RADesktopWindow*)desktop { @autoreleasepool { UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, 0); - //CGContextRef context = UIGraphicsGetCurrentContext(); - - [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; + CGContextRef context = UIGraphicsGetCurrentContext(); ON_MAIN_THREAD(^{ [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; //}); - UIImage *image = [[%c(SBWallpaperController) sharedInstance] sharedWallpaperView].wallpaperImage; - [image drawInRect:[UIScreen mainScreen].bounds]; // Wallpaper + UIImage *image = [self wallpaperImage:NO]; + CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height); + //since drawInRect doesnt work + CGContextTranslateCTM(context, 0, image.size.height); + CGContextScaleCTM(context, 1.0, -1.0); + + CGContextDrawImage(context, imageRect, image.CGImage); // Wallpaper + + CGContextScaleCTM(context, 1.0, -1.0); + CGContextTranslateCTM(context, 0, -imageRect.size.height); //[[[[%c(SBUIController) sharedInstance] window] layer] performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Icons //ON_MAIN_THREAD(^{ //[MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow") drawViewHierarchyInRect:UIScreen.mainScreen.bounds afterScreenUpdates:YES]; @@ -224,7 +231,6 @@ UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); image = [self rotateImageToMatchOrientation:image]; - [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; return image; } } @@ -238,8 +244,9 @@ if ([imageCache objectForKey:key]) { return [imageCache objectForKey:key]; } - //its really that easy elijah - UIImage *image = [[%c(SBWallpaperController) sharedInstance] sharedWallpaperView].wallpaperImage; + //its really that easy elijah (ok maybe i need to resize the image); + UIImage *oldImage = [[%c(SBWallpaperController) sharedInstance] sharedWallpaperView].displayedImage; + UIImage *image = [RAResourceImageProvider imageWithImage:oldImage scaledToSize:[UIScreen mainScreen].bounds.size]; if (blurred) { CIFilter *gaussianBlurFilter = [CIFilter filterWithName:@"CIGaussianBlur"]; diff --git a/headers.h b/headers.h index 0606f8c..7335241 100644 --- a/headers.h +++ b/headers.h @@ -240,6 +240,10 @@ return sharedInstance; - (void)prepareToAppear; @end +@interface SBFStaticWallpaperView : SBFWallpaperView +@property (setter=_setDisplayedImage:,getter=_displayedImage,nonatomic,retain) UIImage *displayedImage; +@end + @interface SBControlCenterController : UIViewController + (id)sharedInstance; @property(nonatomic, getter=isPresented) _Bool presented; // @synthesize presented=_presented; @@ -486,7 +490,7 @@ typedef struct { @end @interface SBWallpaperController -@property (nonatomic,retain) SBFWallpaperView * sharedWallpaperView; +@property (nonatomic,retain) SBFStaticWallpaperView *sharedWallpaperView; +(id) sharedInstance; -(void) beginRequiringWithReason:(NSString*)reason; -(void) endRequiringWithReason:(NSString*)reason; From 3d6e76f3940c47bd9e236078e050aa858509f076 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 18 Mar 2017 12:46:22 -0500 Subject: [PATCH 58/59] updated ColorBadges support + borders --- Backgrounding/IconIndicator.xm | 5 +++++ Backgrounding/RABackgrounder.xm | 5 +---- ColorBadges.h | 4 ++++ RAHostedAppView.xm | 12 ++---------- update_status | 4 +--- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index f4abe75..097a72e 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -110,6 +110,11 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) { badge.textColor = [UIColor blackColor]; } } + + if ([%c(ColorBadges) areBordersEnabled]) { + badge.layer.borderColor = badge.textColor.CGColor; + badge.layer.borderWidth = 1.0; + } } else { badge.textColor = THEMED(backgroundingIndicatorTextColor); } diff --git a/Backgrounding/RABackgrounder.xm b/Backgrounding/RABackgrounder.xm index 0f88200..06c89cf 100644 --- a/Backgrounding/RABackgrounder.xm +++ b/Backgrounding/RABackgrounder.xm @@ -48,13 +48,10 @@ NSMutableDictionary *temporaryShouldPop = [NSMutableDictionary dictionary]; } - (NSInteger)popTemporaryOverrideForApplication:(NSString*)identifier { - if (!identifier) { + if (!identifier || ![temporaryOverrides objectForKey:identifier]) { return -1; } - if (![temporaryOverrides objectForKey:identifier]) { - return -1; - } RABackgroundMode override = (RABackgroundMode)[temporaryOverrides[identifier] intValue]; return override; } diff --git a/ColorBadges.h b/ColorBadges.h index a4a4143..567e1b3 100644 --- a/ColorBadges.h +++ b/ColorBadges.h @@ -14,6 +14,10 @@ + (BOOL)areBordersEnabled; + (BOOL)isEnabled; +// Added in ColorBadges v1.1.1. ++ (BOOL)isDarkColorOrIsAlwaysWhiteEnabled:(int)color; ++ (BOOL)isAlwaysWhiteEnabled; + // Return RGB ints. i.e. 0xRRGGBB. - (int)colorForImage:(UIImage *)image; - (int)colorForIcon:(id)icon; // Must be an SBIcon * diff --git a/RAHostedAppView.xm b/RAHostedAppView.xm index cc34e3a..1aaffed 100644 --- a/RAHostedAppView.xm +++ b/RAHostedAppView.xm @@ -90,11 +90,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; return; } - if (!app) { - return; - } - - if (_isCurrentlyHosting) { + if (!app || _isCurrentlyHosting) { return; } @@ -147,11 +143,7 @@ NSMutableDictionary *appsBeingHosted = [NSMutableDictionary dictionary]; startTries = 0; disablePreload = NO; [self preloadApp]; - if (!app) { - return; - } - - if (_isCurrentlyHosting) { + if (!app || _isCurrentlyHosting) { return; } diff --git a/update_status b/update_status index 66b935b..03e06ec 100644 --- a/update_status +++ b/update_status @@ -23,19 +23,17 @@ Bugs: - Individual app force foregrounding is broken when used in conjunction with auto (re)launch; - Invoking keyboard in reachapp closes view (I think reachability dismisses when using KB) - Showing NC with reachapp doesnt properly resize (not even sure if possible) -- Foregrounding through activator broken (override gets removed when launching another app) - CC inhibitor not reliable on 9.x+? Minor Things/Bugs to note: - (some of these are leftover from the original release lol: eg MC lag) -- Wallpaper doesnt render in Desktops in MC - Some say it causes serious lag (probably because logs werent disabled/due to MC)? - Startup bug still isnt fixed (apparently caused by gesture support?) - Check iPad support/lower iOS versions Things to do/Features to add: - 3D Touch actions? -- (Real distant future) split all 6 features into seperate tweaks +- (Soon) split all 6 features into seperate tweaks - General Code Cleanup/conform to standards, feels to messy RN (at least indents are fine) notes: From 80670b12ea8b6acf3a4c4ddc252a3c148a439469 Mon Sep 17 00:00:00 2001 From: Shade-Zepheri Date: Sat, 18 Mar 2017 19:59:09 -0500 Subject: [PATCH 59/59] Final commits b4 'great split' --- Backgrounding/IconIndicator.xm | 50 +------------- KeyboardSupport/RAKeyboardStateListener.xm | 8 ++- MissionControl/RAMissionControlWindow.xm | 76 +++++++++++++--------- RASnapshotProvider.xm | 11 +++- Reachability/Reachability.xm | 4 +- SwipeOver/RASwipeOverManager.xm | 6 +- headers.h | 7 ++ update_status | 10 ++- 8 files changed, 78 insertions(+), 94 deletions(-) diff --git a/Backgrounding/IconIndicator.xm b/Backgrounding/IconIndicator.xm index 097a72e..6c72e0a 100644 --- a/Backgrounding/IconIndicator.xm +++ b/Backgrounding/IconIndicator.xm @@ -118,6 +118,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) { } else { badge.textColor = THEMED(backgroundingIndicatorTextColor); } + UIImage *bgImage = [%c(SBIconBadgeView) _checkoutBackgroundImage]; if (%c(ANEMSettingsManager) && [[[%c(ANEMSettingsManager) sharedManager] themeSettings] containsObject:@"ModernBadges"]) { badge.backgroundColor = [UIColor colorWithPatternImage:bgImage]; @@ -161,7 +162,7 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) { [self RA_setIsIconIndicatorInhibited:value showAgainImmediately:YES]; } -%new -(void) RA_setIsIconIndicatorInhibited:(BOOL)value showAgainImmediately:(BOOL)value2 { +%new - (void)RA_setIsIconIndicatorInhibited:(BOOL)value showAgainImmediately:(BOOL)value2 { self.RA_isIconIndicatorInhibited = value; if (value2 || value) { [self RA_updateIndicatorViewWithExistingInfo]; @@ -202,53 +203,6 @@ NSString *stringFromIndicatorInfo(RAIconIndicatorViewInfo info) { NSMutableDictionary *lsbitems = [[[NSMutableDictionary alloc] init] retain]; %hook SBApplication - -/* - -TODO: fix this crash - -Last Exception Backtrace: -0 CoreFoundation 0x273cefea 0x272c7000 + 0x107fea // __exceptionPreprocess + 0x7a -1 libobjc.A.dylib 0x35a72c86 0x35a6c000 + 0x6c86 // objc_exception_throw + 0x22 -2 CoreFoundation 0x273d4404 0x272c7000 + 0x10d404 // -[NSObject(NSObject) doesNotRecognizeSelector:] + 0xb8 -3 + ReachApp.dylib 0x0665540a 0x065d7000 + 0x7e40a // Logos hook for -[NSObject(_ungrouped) doesNotRecognizeSelector:](NSObject*, objc_selector*, objc_selector) + 0x1b2 -4 CoreFoundation 0x273d2322 0x272c7000 + 0x10b322 // ___forwarding___ + 0x2c6 -5 CoreFoundation 0x27301e74 0x272c7000 + 0x3ae74 // _CF_forwarding_prep_0 + 0x14 -6 + ReachAppBackgrounding.dylib 0x0644a252 0x06442000 + 0x8252 // Logos hook for -[SBApplication(_ungrouped) RA_addStatusBarIconForSelfIfOneDoesNotExist](SBApplication*, objc_selector*) + 0x76 -7 + ReachAppBackgrounding.dylib 0x0644a8b6 0x06442000 + 0x88b6 // Logos hook for -[SBApplication(_ungrouped) setApplicationState:](SBApplication*, objc_selector*, unsigned int) + 0x156 -8 libdispatch.dylib 0x360032de 0x36002000 + 0x12de // _dispatch_call_block_and_release + 0x6 -9 libdispatch.dylib 0x360032ca 0x36002000 + 0x12ca // _dispatch_client_callout + 0x12 -10 libdispatch.dylib 0x36006d2a 0x36002000 + 0x4d2a // _dispatch_main_queue_callback_4CF + 0x52e -11 CoreFoundation 0x27394604 0x272c7000 + 0xcd604 // __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 0x4 -12 CoreFoundation 0x27392d04 0x272c7000 + 0xcbd04 // __CFRunLoopRun + 0x5e4 -13 CoreFoundation 0x272df1fc 0x272c7000 + 0x181fc // CFRunLoopRunSpecific + 0x1d8 -14 CoreFoundation 0x272df00e 0x272c7000 + 0x1800e // CFRunLoopRunInMode + 0x66 -15 GraphicsServices 0x2edb01fc 0x2eda7000 + 0x91fc // GSEventRunModal + 0x84 -16 UIKit 0x2aaaba04 0x2aa3c000 + 0x6fa04 // UIApplicationMain + 0x59c -17 + FolderCloser.dylib 0x06337fe8 0x06337000 + 0xfe8 // my_UIApplicationMainX + 0x140 -18 SpringBoard (*) 0x0007f296 0x00077000 + 0x8296 // 0x00007ae8 + 0x7ae -19 libdyld.dylib 0x36024aaa 0x36023000 + 0x1aaa // tlv_initializer + 0x2 - -Tue Sep 8 12:44:18 2015: SpringBoard (com.apple.springboard): [ReachApp] doesNotRecognizeSelector: selector 'objectForKey:' on class '__NSCFString' (image: /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation) -Tue Sep 8 12:44:18 2015: SpringBoard (com.apple.springboard): [ReachApp] Obtained 10 stack frames: -Tue Sep 8 12:44:18 2015: SpringBoard (com.apple.springboard): [ReachApp] 0 ReachApp.dylib 0x06655379 _ZL59_logos_method$_ungrouped$NSObject$doesNotRecognizeSelector$P8NSObjectP13objc_selectorS1_ + 288 -Tue Sep 8 12:44:18 2015: SpringBoard (com.apple.springboard): [ReachApp] 1 CoreFoundation 0x273d2327 + 714 -Tue Sep 8 12:44:18 2015: SpringBoard (com.apple.springboard): [ReachApp] 2 CoreFoundation 0x27301e78 _CF_forwarding_prep_0 + 24 -Tue Sep 8 12:44:18 2015: SpringBoard (com.apple.springboard): [ReachApp] 3 ReachAppBackgrounding.dylib 0x0644a257 _ZL82_logos_method$_ungrouped$SBApplication$RA_addStatusBarIconForSelfIfOneDoesNotExistP13SBApplicationP13objc_selector + 122 -Tue Sep 8 12:44:18 2015: SpringBoard (com.apple.springboard): [ReachApp] 4 ReachAppBackgrounding.dylib 0x0644a8bb _ZL59_logos_method$_ungrouped$SBApplication$setApplicationState$P13SBApplicationP13objc_selectorj + 346 -Tue Sep 8 12:44:18 2015: SpringBoard (com.apple.springboard): [ReachApp] 5 libdispatch.dylib 0x360032e3 + 10 -Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): [ReachApp] 6 libdispatch.dylib 0x360032cf + 22 -Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): [ReachApp] 7 libdispatch.dylib 0x36006d2f _dispatch_main_queue_callback_4CF + 1330 -Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): [ReachApp] 8 CoreFoundation 0x27394609 + 8 -Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): [ReachApp] 9 CoreFoundation 0x27392d09 + 1512 -Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x1d50e650 -Tue Sep 8 12:44:19 2015: SpringBoard (com.apple.springboard): *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x1d50e650' -*** First throw call stack: -(0x273cefef 0x35a72c8b 0x273d4409 0x665540f 0x273d2327 0x27301e78 0x644a257 0x644a8bb 0x360032e3 0x360032cf 0x36006d2f 0x27394609 0x27392d09 0x272df201 0x272df013 0x2edb0201 0x2aaaba09 0x6337fec 0x7f29b 0x36024aaf) - -FIXED?: Forgot to -retain the dictionary. (It was autoreleased i believe?) - -*/ %new - (void)RA_addStatusBarIconForSelfIfOneDoesNotExist { #if DEBUG if (![lsbitems respondsToSelector:@selector(objectForKey:)]) { diff --git a/KeyboardSupport/RAKeyboardStateListener.xm b/KeyboardSupport/RAKeyboardStateListener.xm index 03eeb90..80e09c4 100644 --- a/KeyboardSupport/RAKeyboardStateListener.xm +++ b/KeyboardSupport/RAKeyboardStateListener.xm @@ -46,7 +46,8 @@ BOOL isShowing = NO; } - (instancetype)init { - if ((self = [super init])) { + self = [super init]; + if (self) { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(didShow:) name:UIKeyboardDidShowNotification object:nil]; [center addObserver:self selector:@selector(didHide) name:UIKeyboardWillHideNotification object:nil]; @@ -103,6 +104,11 @@ void externalKeyboardDidHide(CFNotificationCenterRef center, void *observer, CFS block(); } } + ++ (void)initImplementationNow { + %orig; + LogDebug(@"initImplementationNow"); +} %end %ctor { diff --git a/MissionControl/RAMissionControlWindow.xm b/MissionControl/RAMissionControlWindow.xm index e625b4c..fb10f16 100644 --- a/MissionControl/RAMissionControlWindow.xm +++ b/MissionControl/RAMissionControlWindow.xm @@ -147,7 +147,7 @@ [self reloadWindowedAppsSection:runningApplications]; } --(void) reloadWindowedAppsSection:(NSArray*)runningApplicationsArg { +- (void)reloadWindowedAppsSection:(NSArray*)runningApplicationsArg { runningApplications = [runningApplicationsArg mutableCopy]; NSArray *switcherOrder = [[%c(RAAppSwitcherModelWrapper) appSwitcherAppIdentiferList] copy]; @@ -164,9 +164,10 @@ } for (SBApplication *app in runningApplications) { - if (![visibleIcons containsObject:app.bundleIdentifier]) { - [appsWithoutWindows removeObject:app]; + if ([visibleIcons containsObject:app.bundleIdentifier]) { + continue; }// || [RAMissionControlManager.sharedInstance.inhibitedApplications containsObject:app.bundleIdentifier]) + [appsWithoutWindows removeObject:app]; } CGFloat x = panePadding; @@ -197,7 +198,11 @@ x += panePadding + preview.frame.size.width; preview.application = sbapp; - [windowedAppScrollView addSubview:preview]; + [UIView animateWithDuration:1 animations:^{ + preview.alpha = 1; + } completion:^(BOOL finished) { + [windowedAppScrollView addSubview:preview]; + }]; [preview generatePreviewAsync]; UITapGestureRecognizer *g = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(topIconViewTap:)]; @@ -267,7 +272,11 @@ x += panePadding + preview.frame.size.width; preview.application = app; - [otherRunningAppsScrollView addSubview:preview]; + [UIView animateWithDuration:1 animations:^{ + preview.alpha = 1; + } completion:^(BOOL finished) { + [otherRunningAppsScrollView addSubview:preview]; + }]; [preview generatePreviewAsync]; UITapGestureRecognizer *g = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(topIconViewTap:)]; @@ -447,22 +456,23 @@ if (!didKill) { for (UIView *subview in desktopScrollView.subviews) { - if ([subview isKindOfClass:[RAMissionControlPreviewView class]]) { - if (CGRectContainsPoint((CGRect){ [desktopScrollView convertPoint:subview.frame.origin toView:self], subview.frame.size }, center) || (CGRectContainsPoint((CGRect){ [windowedAppScrollView convertPoint:subview.frame.origin toView:self], windowedAppScrollView.frame.size }, center) && gesture.view.superview != windowedAppScrollView)) { - RADesktopWindow *desktop = [[%c(RADesktopManager) sharedInstance] desktopAtIndex:subview.tag]; - SBApplication *app = ((RAMissionControlPreviewView*)gesture.view).application; + if (![subview isKindOfClass:[RAMissionControlPreviewView class]]) { + continue; + } + if (CGRectContainsPoint((CGRect){ [desktopScrollView convertPoint:subview.frame.origin toView:self], subview.frame.size }, center) || (CGRectContainsPoint((CGRect){ [windowedAppScrollView convertPoint:subview.frame.origin toView:self], windowedAppScrollView.frame.size }, center) && gesture.view.superview != windowedAppScrollView)) { + RADesktopWindow *desktop = [[%c(RADesktopManager) sharedInstance] desktopAtIndex:subview.tag]; + SBApplication *app = ((RAMissionControlPreviewView*)gesture.view).application; - [[[%c(RADesktopManager) sharedInstance] currentDesktop] removeAppWithIdentifier:app.bundleIdentifier animated:NO]; + [[[%c(RADesktopManager) sharedInstance] currentDesktop] removeAppWithIdentifier:app.bundleIdentifier animated:NO]; - [desktop createAppWindowForSBApplication:app animated:NO]; + [desktop createAppWindowForSBApplication:app animated:NO]; - [[%c(RASnapshotProvider) sharedInstance] forceReloadSnapshotOfDesktop:[[%c(RADesktopManager) sharedInstance] currentDesktop]]; - [[%c(RASnapshotProvider) sharedInstance] forceReloadSnapshotOfDesktop:desktop]; + [[%c(RASnapshotProvider) sharedInstance] forceReloadSnapshotOfDesktop:[[%c(RADesktopManager) sharedInstance] currentDesktop]]; + [[%c(RASnapshotProvider) sharedInstance] forceReloadSnapshotOfDesktop:desktop]; - [self reloadDesktopSection]; - [self reloadWindowedAppsSection]; - [self reloadOtherAppsSection]; - } + [self reloadDesktopSection]; + [self reloadWindowedAppsSection]; + [self reloadOtherAppsSection]; } } } @@ -562,28 +572,30 @@ - (void)killAllWindowed { for (UIView *view in windowedAppScrollView.subviews) { - if ([view isKindOfClass:[RAMissionControlPreviewView class]]) { - RAMissionControlPreviewView *realView = (RAMissionControlPreviewView*)view; - SBApplication *app = realView.application; - [%c(RAAppKiller) killAppWithSBApplication:app completion:^{ - [runningApplications removeObject:app]; - [self performSelectorOnMainThread:@selector(reloadWindowedAppsSection:) withObject:[[%c(RARunningAppsProvider) sharedInstance] runningApplications] waitUntilDone:YES]; - [self performSelectorOnMainThread:@selector(reloadOtherAppsSection) withObject:nil waitUntilDone:YES]; - }]; + if (![view isKindOfClass:[RAMissionControlPreviewView class]]) { + continue; } + RAMissionControlPreviewView *realView = (RAMissionControlPreviewView*)view; + SBApplication *app = realView.application; + [%c(RAAppKiller) killAppWithSBApplication:app completion:^{ + [runningApplications removeObject:app]; + [self performSelectorOnMainThread:@selector(reloadWindowedAppsSection:) withObject:[[%c(RARunningAppsProvider) sharedInstance] runningApplications] waitUntilDone:YES]; + [self performSelectorOnMainThread:@selector(reloadOtherAppsSection) withObject:nil waitUntilDone:YES]; + }]; } } - (void)killAllOther { for (UIView *view in otherRunningAppsScrollView.subviews) { - if ([view isKindOfClass:[RAMissionControlPreviewView class]]) { - RAMissionControlPreviewView *realView = (RAMissionControlPreviewView*)view; - SBApplication *app = realView.application; - [%c(RAAppKiller) killAppWithSBApplication:app completion:^{ - [self performSelectorOnMainThread:@selector(reloadWindowedAppsSection:) withObject:[[%c(RARunningAppsProvider) sharedInstance] runningApplications] waitUntilDone:YES]; - [self performSelectorOnMainThread:@selector(reloadOtherAppsSection) withObject:nil waitUntilDone:YES]; - }]; + if (![view isKindOfClass:[RAMissionControlPreviewView class]]) { + continue; } + RAMissionControlPreviewView *realView = (RAMissionControlPreviewView*)view; + SBApplication *app = realView.application; + [%c(RAAppKiller) killAppWithSBApplication:app completion:^{ + [self performSelectorOnMainThread:@selector(reloadWindowedAppsSection:) withObject:[[%c(RARunningAppsProvider) sharedInstance] runningApplications] waitUntilDone:YES]; + [self performSelectorOnMainThread:@selector(reloadOtherAppsSection) withObject:nil waitUntilDone:YES]; + }]; } } diff --git a/RASnapshotProvider.xm b/RASnapshotProvider.xm index f6681f1..f93ee3a 100644 --- a/RASnapshotProvider.xm +++ b/RASnapshotProvider.xm @@ -183,6 +183,8 @@ UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, 0); CGContextRef context = UIGraphicsGetCurrentContext(); + [[%c(SBWallpaperController) sharedInstance] beginRequiringWithReason:@"BeautifulAnimation"]; + ON_MAIN_THREAD(^{ [[%c(SBUIController) sharedInstance] restoreContentAndUnscatterIconsAnimated:NO]; //}); @@ -200,8 +202,12 @@ //[[[[%c(SBUIController) sharedInstance] window] layer] performSelectorOnMainThread:@selector(renderInContext:) withObject:(__bridge id)c waitUntilDone:YES]; // Icons //ON_MAIN_THREAD(^{ //[MSHookIvar([%c(SBWallpaperController) sharedInstance], "_wallpaperWindow") drawViewHierarchyInRect:UIScreen.mainScreen.bounds afterScreenUpdates:YES]; - - [[[%c(SBUIController) sharedInstance] window] drawViewHierarchyInRect:[UIScreen mainScreen].bounds afterScreenUpdates:NO]; + if (IS_IOS_OR_NEWER(iOS_9_0)) { //not sure why broken + UIView *view = [[%c(SBIconController) sharedInstance] view]; + [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; + } else { + [[[%c(SBUIController) sharedInstance] window] drawViewHierarchyInRect:[UIScreen mainScreen].bounds afterScreenUpdates:NO]; + } [desktop drawViewHierarchyInRect:desktop.bounds afterScreenUpdates:NO]; }); @@ -231,6 +237,7 @@ UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); image = [self rotateImageToMatchOrientation:image]; + [[%c(SBWallpaperController) sharedInstance] endRequiringWithReason:@"BeautifulAnimation"]; return image; } } diff --git a/Reachability/Reachability.xm b/Reachability/Reachability.xm index 7cc6651..70729b2 100644 --- a/Reachability/Reachability.xm +++ b/Reachability/Reachability.xm @@ -80,7 +80,7 @@ BOOL wasEnabled = NO; - (void)deactivateReachabilityModeForObserver:(unsafe_id)arg1 { //Disable for keyboard here - if (overrideDisableForStatusBar) { + if (overrideDisableForStatusBar || [RAKeyboardStateListener sharedInstance].visible) { return; } %orig; @@ -235,7 +235,7 @@ id SBWorkspace$sharedInstance; - (void)_disableReachabilityImmediately:(_Bool)arg1 { //Disable for keyboard here - if (overrideDisableForStatusBar || [UIKeyboard isOnScreen]) { + if (overrideDisableForStatusBar || [RAKeyboardStateListener sharedInstance].visible) { return; } diff --git a/SwipeOver/RASwipeOverManager.xm b/SwipeOver/RASwipeOverManager.xm index bccbd10..2255378 100644 --- a/SwipeOver/RASwipeOverManager.xm +++ b/SwipeOver/RASwipeOverManager.xm @@ -90,13 +90,13 @@ extern int rotationDegsForOrientation(int o); } - (void)createEdgeView { - overlayWindow = [[RASwipeOverOverlay alloc] initWithFrame:UIScreen.mainScreen.RA_interfaceOrientedBounds]; + overlayWindow = [[RASwipeOverOverlay alloc] initWithFrame:[UIScreen mainScreen].RA_interfaceOrientedBounds]; if (IS_IOS_OR_OLDER(iOS_8_4)) { - [overlayWindow _rotateWindowToOrientation:UIApplication.sharedApplication.statusBarOrientation updateStatusBar:YES duration:0.001 skipCallbacks:NO]; + [overlayWindow _rotateWindowToOrientation:[UIApplication sharedApplication].statusBarOrientation updateStatusBar:YES duration:0.001 skipCallbacks:NO]; } [overlayWindow showEnoughToDarkenUnderlyingApp]; [overlayWindow makeKeyAndVisible]; - [overlayWindow updateForOrientation:UIApplication.sharedApplication.statusBarOrientation]; + [overlayWindow updateForOrientation:[UIApplication sharedApplication].statusBarOrientation]; [self showApp:nil]; } diff --git a/headers.h b/headers.h index 7335241..435646b 100644 --- a/headers.h +++ b/headers.h @@ -605,6 +605,13 @@ typedef enum @property(readonly, nonatomic) NSString *type; // @synthesize type=_type; @end +@interface SBHomeScreenViewController : UIViewController +@end + +@interface SBHomeScreenWindow : UIWindow +@property (nonatomic, weak,readonly) SBHomeScreenViewController *homeScreenViewController; +@end + @interface SBLockScreenManager +(id) sharedInstance; -(BOOL) isUILocked; diff --git a/update_status b/update_status index 03e06ec..b9454df 100644 --- a/update_status +++ b/update_status @@ -13,17 +13,15 @@ assertiond hooks: working backboardd hooks: unknown fake phone mode: working - -- adding items to SBAppSwitcherModel is broken -- SwipeOver sliding off screen animation is broken (RASwipeOverManager.xm:L62) -- icons and apps do not show up in RASnapshotProvider -- GestureSupport: LandscapeLeft is, once again, broken - Bugs: - Individual app force foregrounding is broken when used in conjunction with auto (re)launch; - Invoking keyboard in reachapp closes view (I think reachability dismisses when using KB) - Showing NC with reachapp doesnt properly resize (not even sure if possible) - CC inhibitor not reliable on 9.x+? +- adding items to SBAppSwitcherModel is broken (fixed now?) +- SwipeOver sliding off screen animation is broken (RASwipeOverManager.xm:L62) +- icons and apps do not show up in RASnapshotProvider +- GestureSupport: LandscapeLeft is, once again, broken Minor Things/Bugs to note: - (some of these are leftover from the original release lol: eg MC lag)