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.

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