hide/show/change stuff on the LS and HS https://github.com/viggou/Kage
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

446 lines
12KB

  1. // Respring function
  2. @interface FBSystemService : NSObject
  3. +(id)sharedInstance;
  4. -(void)exitAndRelaunch:(bool)arg1;
  5. @end
  6. static void RespringDevice() {
  7. [[%c(FBSystemService) sharedInstance] exitAndRelaunch:YES];
  8. }
  9. // Prefs
  10. @interface NSUserDefaults (KagePrefs)
  11. -(id)objectForKey:(NSString *)key inDomain:(NSString *)domain;
  12. -(void)setObject:(id)value forKey:(NSString *)key inDomain:(NSString *)domain;
  13. @end
  14. static NSString *nsDomainString = @"com.yaypixxo.kage";
  15. static NSString *nsNotificationString = @"com.yaypixxo.kage/preferences.changed";
  16. // Declare pref things here (switches, buttons, etc.)
  17. static BOOL enabled;
  18. static BOOL hideQuickActionsBG;
  19. static BOOL gridSwitcher;
  20. static BOOL hideLSBatt;
  21. static BOOL statusBarShowTimeLS;
  22. static BOOL hideLabels;
  23. //static BOOL hideCarPlayLabels;
  24. static BOOL hideFolderBadges;
  25. static BOOL hideFolderTitle;
  26. static BOOL hideFolderBG;
  27. static BOOL hideFolderBGSB;
  28. static BOOL hideFolderDots;
  29. static BOOL hideNoOlderNotifs;
  30. //static BOOL hideStatusBarLS;
  31. static BOOL hideCCGrabber;
  32. static BOOL noBetaAlert;
  33. static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
  34. NSNumber *eEnabled = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"enabled" inDomain:nsDomainString];
  35. NSNumber *eHideQuickActionsBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideQuickActionsBG" inDomain:nsDomainString];
  36. NSNumber *eGridSwitcher = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"gridSwitcher" inDomain:nsDomainString];
  37. NSNumber *eHideLSBatt = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLSBatt" inDomain:nsDomainString];
  38. NSNumber *eStatusBarShowTimeLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"statusBarShowTimeLS" inDomain:nsDomainString];
  39. NSNumber *eHideLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLabels" inDomain:nsDomainString];
  40. //NSNumber *eHideCarPlayLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCarPlayLabels" inDomain:nsDomainString];
  41. NSNumber *eHideFolderBadges = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBadges" inDomain:nsDomainString];
  42. NSNumber *eHideFolderTitle = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderTitle" inDomain:nsDomainString];
  43. NSNumber *eHideFolderBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBG" inDomain:nsDomainString];
  44. NSNumber *eHideFolderBGSB = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBGSB" inDomain:nsDomainString];
  45. NSNumber *eHideFolderDots = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderDots" inDomain:nsDomainString];
  46. NSNumber *eHideNoOlderNotifs = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideNoOlderNotifs" inDomain:nsDomainString];
  47. //NSNumber *eHideStatusBarLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideStatusBarLS" inDomain:nsDomainString];
  48. NSNumber *eHideCCGrabber = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCCGrabber" inDomain:nsDomainString];
  49. NSNumber *eNoBetaAlert = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"noBetaAlert" inDomain:nsDomainString];
  50. enabled = (eEnabled) ? [eEnabled boolValue]:NO;
  51. hideQuickActionsBG = (eHideQuickActionsBG) ? [eHideQuickActionsBG boolValue]:NO;
  52. gridSwitcher = (eGridSwitcher) ? [eGridSwitcher boolValue]:NO;
  53. hideLSBatt = (eHideLSBatt) ? [eHideLSBatt boolValue]:NO;
  54. statusBarShowTimeLS = (eStatusBarShowTimeLS) ? [eStatusBarShowTimeLS boolValue]:NO;
  55. hideLabels = (eHideLabels) ? [eHideLabels boolValue]:NO;
  56. //hideCarPlayLabels = (eHideCarPlayLabels) ? [eHideCarPlayLabels boolValue]:NO;
  57. hideFolderBadges = (eHideFolderBadges) ? [eHideFolderBadges boolValue]:NO;
  58. hideFolderTitle = (eHideFolderTitle) ? [eHideFolderTitle boolValue]:NO;
  59. hideFolderBG = (eHideFolderBG) ? [eHideFolderBG boolValue]:NO;
  60. hideFolderBGSB = (eHideFolderBGSB) ? [eHideFolderBGSB boolValue]:NO;
  61. hideFolderDots = (eHideFolderDots) ? [eHideFolderDots boolValue]:NO;
  62. hideNoOlderNotifs = (eHideNoOlderNotifs) ? [eHideNoOlderNotifs boolValue]:NO;
  63. //hideStatusBarLS = (eHideStatusBarLS) ? [eHideStatusBarLS boolValue]:NO;
  64. hideCCGrabber = (eHideCCGrabber) ? [eHideCCGrabber boolValue]:NO;
  65. noBetaAlert = (eNoBetaAlert) ? [eNoBetaAlert boolValue]:NO;
  66. }
  67. // Headers
  68. #import <UIKit/UIKit.h>
  69. /*@interface SBFolderView : UIView
  70. @end*/
  71. @interface SBIconView : UIView
  72. -(void)setLabelHidden:(BOOL)hidden;
  73. @end
  74. @interface SBIcon : NSObject
  75. -(id)badgeNumberOrString;
  76. @end
  77. @interface CSTeachableMomentsContainerView
  78. @property (nonatomic,retain) UIView * controlCenterGrabberView;
  79. @end
  80. @interface SBDashBoardTeachableMomentsContainerView
  81. @property (nonatomic,retain) UIView * controlCenterGrabberView;
  82. @end
  83. @interface SBFolderIconImageView : UIView
  84. @property (nonatomic, retain) UIView *backgroundView;
  85. @end
  86. @interface SBIconListPageControl
  87. @property (nonatomic, assign, readwrite, getter=isHidden) BOOL hidden;
  88. @end
  89. @interface SBIconController : NSObject
  90. +(id)sharedInstance;
  91. -(void)_closeFolderController:(id)arg1 animated:(BOOL)arg2 withCompletion:(id)arg3;
  92. @end
  93. @interface SBUILegibilityLabel : UIView
  94. @property (nonatomic,copy) NSString *string;
  95. @end
  96. @interface NCNotificationListSectionRevealHintView : UIView
  97. @property (nonatomic,retain)SBUILegibilityLabel *revealHintTitle;
  98. @end
  99. /*@interface SBFloatyFolderView : SBFolderView
  100. -(void)_handleOutsideTap:(id)arg1 ;
  101. @end
  102. @interface SBFolderController : UIViewController
  103. @property (nonatomic,readonly) UIView * containerView;
  104. @end
  105. @interface SBFloatyFolderScrollView : UIScrollView
  106. -(void)closeFolder:(id)selector;
  107. -(id)_viewControllerForAncestor;
  108. @end*/
  109. #ifndef kCFCoreFoundationVersionNumber_iOS_13_0
  110. #define kCFCoreFoundationVersionNumber_iOS_13_0 1665.15
  111. #endif
  112. #define kSLSystemVersioniOS13 kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_13_0
  113. %group universal // Stuff that works on both iOS 12 & iOS 13 (and some things 9+)
  114. // Hide no older notifications
  115. %hook NCNotificationListSectionRevealHintView
  116. -(void)didMoveToWindow {
  117. %orig;
  118. if (enabled && hideNoOlderNotifs) {
  119. self.revealHintTitle.string = @"";
  120. }
  121. }
  122. %end
  123. // Hide quick actions BG
  124. %hook UICoverSheetButton
  125. -(id)_backgroundEffectsWithBrightness:(double)arg1 {
  126. if (enabled && hideQuickActionsBG) {
  127. return 0;
  128. }
  129. else {
  130. return %orig;
  131. }
  132. }
  133. %end
  134. // Hide folder badges text
  135. %hook SBIcon
  136. -(id)badgeNumberOrString {
  137. if (enabled && hideFolderBadges) {
  138. return @"";
  139. }
  140. else {
  141. return %orig;
  142. }
  143. }
  144. %end
  145. // Hide icon labels
  146. %hook SBIconView
  147. -(void)setLabelHidden:(BOOL)hidden {
  148. if (enabled && hideLabels) {
  149. hidden = YES;
  150. }
  151. %orig;
  152. }
  153. %end
  154. // Grid switcher
  155. %hook SBAppSwitcherSettings
  156. - (void)setGridSwitcherPageScale:(double)arg1 {
  157. if (enabled && gridSwitcher) {
  158. arg1 = 0.4;
  159. }
  160. %orig;
  161. }
  162. - (void)setGridSwitcherHorizontalInterpageSpacingPortrait:(double)arg1 {
  163. if (enabled && gridSwitcher) {
  164. arg1 = 25.5;
  165. }
  166. %orig;
  167. }
  168. - (void)setGridSwitcherHorizontalInterpageSpacingLandscape:(double)arg1 {
  169. if (enabled && gridSwitcher) {
  170. arg1 = 11.6;
  171. }
  172. %orig;
  173. }
  174. - (void)setGridSwitcherVerticalNaturalSpacingPortrait:(double)arg1 {
  175. if (enabled && gridSwitcher) {
  176. arg1 = 42;
  177. }
  178. %orig;
  179. }
  180. - (void)setGridSwitcherVerticalNaturalSpacingLandscape:(double)arg1 {
  181. if (enabled && gridSwitcher) {
  182. arg1 = 38;
  183. }
  184. %orig;
  185. }
  186. - (void)setSwitcherStyle:(long long)arg1 {
  187. if (enabled && gridSwitcher) {
  188. arg1 = 2;
  189. }
  190. %orig;
  191. }
  192. %end
  193. // Hide LS battery
  194. %hook CSCoverSheetViewController
  195. - (void)_transitionChargingViewToVisible:(bool)arg1 showBattery:(bool)arg2 animated:(bool)arg3 {
  196. if (enabled && hideLSBatt) {
  197. arg1 = 0;
  198. }
  199. %orig;
  200. }
  201. %end
  202. // Hide folder title
  203. %hook SBFloatyFolderView
  204. -(BOOL)_showsTitle {
  205. if (enabled && hideFolderTitle) {
  206. return NO;
  207. }
  208. else {
  209. return %orig;
  210. }
  211. }
  212. %end
  213. // Hide folder backgrounds
  214. %hook SBFloatyFolderView
  215. -(void)setBackgroundAlpha:(CGFloat)arg1 {
  216. if (enabled && hideFolderBG) {
  217. %orig(0.0);
  218. }
  219. else {
  220. %orig;
  221. }
  222. }
  223. %end
  224. %hook SBFolderIconImageView
  225. -(void)layoutSubviews {
  226. %orig;
  227. if (enabled && hideFolderBGSB) {
  228. self.backgroundView.alpha = 0;
  229. self.backgroundView.hidden = 1;
  230. }
  231. }
  232. %end
  233. // Close folder when tapped inside
  234. /*%hook SBFloatyFolderScrollView
  235. -(SBFloatyFolderScrollView *)initWithFrame:(CGRect)frame {
  236. if (enabled && hideFolderBG) {
  237. SBFloatyFolderScrollView *yeet = %orig;
  238. UITapGestureRecognizer *closeGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeFolder)];
  239. [yeet addGestureRecognizer:closeGesture];
  240. return yeet;
  241. }
  242. else {
  243. return %orig;
  244. }
  245. }
  246. %new
  247. -(void)closeFolder:(id)sender {
  248. UIViewController *parentController = [self _viewControllerForAncestor];
  249. if ([parentController isKindOfClass:[objc_getClass("SBFolderController") class]]) {
  250. SBFolderController *sbfc = (SBFolderController *)parentController;
  251. if (sbfc && [sbfc.containerView isKindOfClass:[objc_getClass("SBFloatyFolderView") class]]) {
  252. [(SBFloatyFolderView *)sbfc.containerView _handleOutsideTap:nil];
  253. }
  254. }
  255. }
  256. %end*/
  257. // Hide folder dots
  258. %hook SBIconListPageControl
  259. -(void)layoutSubviews {
  260. if (enabled && hideFolderDots) {
  261. self.hidden = YES;
  262. }
  263. else {
  264. %orig;
  265. }
  266. }
  267. %end
  268. // Hide beta alert
  269. // iOS 9-10
  270. %hook SBIconController
  271. -(void)showDeveloperBuildExpirationAlertIfNecesarryFromLockscreen:(BOOL)arg1 toLauncher:(BOOL)arg2 {
  272. if (enabled && noBetaAlert) {
  273. }
  274. else {
  275. %orig;
  276. }
  277. }
  278. %end
  279. // iOS 11-13
  280. %hook SBDeveloperBuildExpirationTrigger
  281. -(void)showDeveloperBuildExpirationAlertIfNecesarryFromLockscreen:(BOOL)arg1 toLauncher:(BOOL)arg2 {
  282. if (enabled && noBetaAlert) {
  283. }
  284. else {
  285. %orig;
  286. }
  287. }
  288. %end
  289. %end // End universal group
  290. // Stuff that only works on iOS 13
  291. %group ios13
  292. // Show time in LS statusbar
  293. %hook CSCoverSheetViewController
  294. - (bool)shouldShowLockStatusBarTime {
  295. if (enabled && statusBarShowTimeLS) {
  296. return YES;
  297. }
  298. else {
  299. return %orig;
  300. }
  301. }
  302. %end
  303. // Hide CC LS grabber
  304. %hook CSTeachableMomentsContainerView
  305. - (void)layoutSubviews {
  306. if (enabled && hideCCGrabber) {
  307. [self.controlCenterGrabberView setHidden:YES];
  308. }
  309. else {
  310. [self.controlCenterGrabberView setHidden:NO];
  311. }
  312. return %orig;
  313. }
  314. %end
  315. // Hide CarPlay labels
  316. /*%hook CARIconView
  317. +(CGSize)maxLabelSizeForIconImageSize:(CGSize)imageSize {
  318. if (enabled && hideCarPlayLabels) {
  319. return CGSizeZero;
  320. }
  321. else {
  322. return %orig;
  323. }
  324. }
  325. %end*/
  326. %end // End ios13 group
  327. // Stuff that only works on iOS 12
  328. %group ios12
  329. // Show time in LS statusbar
  330. %hook SBLockScreenViewControllerBase
  331. - (bool)shouldShowLockStatusBarTime {
  332. if (enabled && statusBarShowTimeLS) {
  333. return YES;
  334. }
  335. else {
  336. return %orig;
  337. }
  338. }
  339. %end
  340. // Hide CC LS grabber
  341. %hook SBDashBoardTeachableMomentsContainerView
  342. - (void)layoutSubviews {
  343. if (enabled && hideCCGrabber) {
  344. [self.controlCenterGrabberView setHidden:YES];
  345. }
  346. else {
  347. [self.controlCenterGrabberView setHidden:NO];
  348. }
  349. return %orig;
  350. }
  351. %end
  352. // Hide CarPlay labels
  353. /*%hook SBStarkIconView
  354. +(CGSize)maxLabelSize {
  355. if (enabled && hideCarPlayLabels) {
  356. return CGSizeZero;
  357. }
  358. else {
  359. return %orig;
  360. }
  361. }
  362. %end*/
  363. %end // End ios12 group
  364. // Listeners
  365. %ctor {
  366. %init(universal);
  367. // Check iOS version
  368. if (kSLSystemVersioniOS13) {
  369. %init(ios13);
  370. }
  371. else {
  372. %init(ios12);
  373. }
  374. // Prefs changed listener
  375. notificationCallback(NULL, NULL, NULL, NULL, NULL);
  376. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
  377. // Respring listener
  378. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.yaypixxo.kage/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
  379. }