hide/show/change stuff on the LS and HS
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

435 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 void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
  33. NSNumber *eEnabled = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"enabled" inDomain:nsDomainString];
  34. NSNumber *eHideQuickActionsBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideQuickActionsBG" inDomain:nsDomainString];
  35. NSNumber *eGridSwitcher = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"gridSwitcher" inDomain:nsDomainString];
  36. NSNumber *eHideLSBatt = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLSBatt" inDomain:nsDomainString];
  37. NSNumber *eStatusBarShowTimeLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"statusBarShowTimeLS" inDomain:nsDomainString];
  38. NSNumber *eHideLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLabels" inDomain:nsDomainString];
  39. NSNumber *eHideCarPlayLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCarPlayLabels" inDomain:nsDomainString];
  40. NSNumber *eHideFolderBadges = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBadges" inDomain:nsDomainString];
  41. NSNumber *eHideFolderTitle = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderTitle" inDomain:nsDomainString];
  42. NSNumber *eHideFolderBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBG" inDomain:nsDomainString];
  43. NSNumber *eHideFolderBGSB = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBGSB" inDomain:nsDomainString];
  44. NSNumber *eHideFolderDots = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderDots" inDomain:nsDomainString];
  45. NSNumber *eHideNoOlderNotifs = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideNoOlderNotifs" inDomain:nsDomainString];
  46. //NSNumber *eHideStatusBarLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideStatusBarLS" inDomain:nsDomainString];
  47. NSNumber *eHideCCGrabber = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCCGrabber" inDomain:nsDomainString];
  48. enabled = (eEnabled) ? [eEnabled boolValue]:NO;
  49. hideQuickActionsBG = (eHideQuickActionsBG) ? [eHideQuickActionsBG boolValue]:NO;
  50. gridSwitcher = (eGridSwitcher) ? [eGridSwitcher boolValue]:NO;
  51. hideLSBatt = (eHideLSBatt) ? [eHideLSBatt boolValue]:NO;
  52. statusBarShowTimeLS = (eStatusBarShowTimeLS) ? [eStatusBarShowTimeLS boolValue]:NO;
  53. hideLabels = (eHideLabels) ? [eHideLabels boolValue]:NO;
  54. hideCarPlayLabels = (eHideCarPlayLabels) ? [eHideCarPlayLabels boolValue]:NO;
  55. hideFolderBadges = (eHideFolderBadges) ? [eHideFolderBadges boolValue]:NO;
  56. hideFolderTitle = (eHideFolderTitle) ? [eHideFolderTitle boolValue]:NO;
  57. hideFolderBG = (eHideFolderBG) ? [eHideFolderBG boolValue]:NO;
  58. hideFolderBGSB = (eHideFolderBGSB) ? [eHideFolderBGSB boolValue]:NO;
  59. hideFolderDots = (eHideFolderDots) ? [eHideFolderDots boolValue]:NO;
  60. hideNoOlderNotifs = (eHideNoOlderNotifs) ? [eHideNoOlderNotifs boolValue]:NO;
  61. //hideStatusBarLS = (eHideStatusBarLS) ? [eHideStatusBarLS boolValue]:NO;
  62. hideCCGrabber = (eHideCCGrabber) ? [eHideCCGrabber boolValue]:NO;
  63. }
  64. // headers and hooks
  65. #import <UIKit/UIKit.h>
  66. /*@interface SBFolderView : UIView
  67. @end*/
  68. @interface SBIconView : UIView
  69. -(void)setLabelHidden:(BOOL)hidden;
  70. @end
  71. @interface SBIcon : NSObject
  72. -(id)badgeNumberOrString;
  73. @end
  74. @interface CSTeachableMomentsContainerView
  75. @property (nonatomic,retain) UIView * controlCenterGrabberView;
  76. @end
  77. @interface SBDashBoardTeachableMomentsContainerView
  78. @property (nonatomic,retain) UIView * controlCenterGrabberView;
  79. @end
  80. @interface SBFolderIconImageView : UIView
  81. @property (nonatomic, retain) UIView *backgroundView;
  82. @end
  83. @interface SBIconListPageControl
  84. @property (nonatomic, assign, readwrite, getter=isHidden) BOOL hidden;
  85. @end
  86. @interface SBIconController : NSObject
  87. +(id)sharedInstance;
  88. -(void)_closeFolderController:(id)arg1 animated:(BOOL)arg2 withCompletion:(id)arg3;
  89. @end
  90. @interface SBUILegibilityLabel : UIView
  91. @property (nonatomic,copy) NSString *string;
  92. @end
  93. @interface NCNotificationListSectionRevealHintView : UIView
  94. @property (nonatomic,retain)SBUILegibilityLabel *revealHintTitle;
  95. @end
  96. @interface SBIconListPageControl : UIView
  97. @end
  98. /*@interface SBFloatyFolderView : SBFolderView
  99. -(void)_handleOutsideTap:(id)arg1 ;
  100. @end
  101. @interface SBFolderController : UIViewController
  102. @property (nonatomic,readonly) UIView * containerView;
  103. @end
  104. @interface SBFloatyFolderScrollView : UIScrollView
  105. -(void)closeFolder:(id)selector;
  106. -(id)_viewControllerForAncestor;
  107. @end*/
  108. #ifndef kCFCoreFoundationVersionNumber_iOS_13_0
  109. #define kCFCoreFoundationVersionNumber_iOS_13_0 1665.15
  110. #endif
  111. #define kSLSystemVersioniOS13 kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_13_0
  112. %group universal
  113. // HIDE NO OLDER NOTIFICATIONS START //
  114. %hook NCNotificationListSectionRevealHintView
  115. -(void)didMoveToWindow {
  116. %orig;
  117. if (enabled && hideNoOlderNotifs) {
  118. self.revealHintTitle.string = @"";
  119. }
  120. }
  121. %end
  122. // HIDE NO OLDER NOTIFICATIONS END //
  123. // QUICK ACTIONS BG START //
  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. // QUICK ACTIONS BG END //
  135. // HIDE FOLDER BADGE TEXT START //
  136. %hook SBIcon
  137. -(id)badgeNumberOrString {
  138. if (enabled && hideFolderBadges) {
  139. return @"";
  140. }
  141. else {
  142. return %orig;
  143. }
  144. }
  145. %end
  146. // HIDE FOLDER BADGE TEXT END //
  147. // HIDE LABELS START //
  148. %hook SBIconView
  149. -(void)setLabelHidden:(BOOL)hidden {
  150. if (enabled && hideLabels) {
  151. hidden = YES;
  152. }
  153. %orig;
  154. }
  155. %end
  156. // HIDE LABELS END //
  157. // GRID SWITCHER START //
  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. // GRID SWITCHER END //
  197. // NO LS BATTERY START //
  198. %hook CSCoverSheetViewController
  199. - (void)_transitionChargingViewToVisible:(bool)arg1 showBattery:(bool)arg2 animated:(bool)arg3 {
  200. if (enabled && hideLSBatt) {
  201. arg1 = 0;
  202. }
  203. %orig;
  204. }
  205. %end
  206. // NO LS BATTERY END //
  207. // SHOW FOLDER TITLE START //
  208. %hook SBFloatyFolderView
  209. -(BOOL)_showsTitle {
  210. if (enabled && hideFolderTitle) {
  211. return NO;
  212. }
  213. else {
  214. return %orig;
  215. }
  216. }
  217. %end
  218. // SHOW FOLDER TITLE END //
  219. // HIDE FOLDER BACKGROUND START //
  220. %hook SBFloatyFolderView
  221. -(void)setBackgroundAlpha:(CGFloat)arg1 {
  222. if (enabled && hideFolderBG) {
  223. %orig(0.0);
  224. }
  225. else {
  226. %orig;
  227. }
  228. }
  229. %end
  230. %hook SBFolderIconImageView
  231. -(void)layoutSubviews {
  232. %orig;
  233. if (enabled && hideFolderBGSB) {
  234. self.backgroundView.alpha = 0;
  235. self.backgroundView.hidden = 1;
  236. }
  237. }
  238. %end
  239. // Close folder when tapped inside
  240. /*%hook SBFloatyFolderScrollView
  241. -(SBFloatyFolderScrollView *)initWithFrame:(CGRect)frame {
  242. if (enabled && hideFolderBG) {
  243. SBFloatyFolderScrollView *yeet = %orig;
  244. UITapGestureRecognizer *closeGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeFolder)];
  245. [yeet addGestureRecognizer:closeGesture];
  246. return yeet;
  247. }
  248. else {
  249. return %orig;
  250. }
  251. }
  252. %new
  253. -(void)closeFolder:(id)sender {
  254. UIViewController *parentController = [self _viewControllerForAncestor];
  255. if ([parentController isKindOfClass:[objc_getClass("SBFolderController") class]]) {
  256. SBFolderController *sbfc = (SBFolderController *)parentController;
  257. if (sbfc && [sbfc.containerView isKindOfClass:[objc_getClass("SBFloatyFolderView") class]]) {
  258. [(SBFloatyFolderView *)sbfc.containerView _handleOutsideTap:nil];
  259. }
  260. }
  261. }
  262. %end*/
  263. // HIDE FOLDER BACKGROUND END //
  264. // HIDE FOLDER DOTS START //
  265. %hook SBIconListPageControl
  266. -(void)layoutSubviews {
  267. if (enabled && hideFolderDots) {
  268. self.hidden = YES;
  269. }
  270. else {
  271. %orig;
  272. }
  273. }
  274. %end
  275. // HIDE FOLDER DOTS END //
  276. %end // end universal group
  277. // stuff that only works on iOS 13
  278. %group ios13
  279. // SHOW TIME IN LS STATUSBAR START //
  280. %hook CSCoverSheetViewController
  281. - (bool)shouldShowLockStatusBarTime {
  282. if (enabled && statusBarShowTimeLS) {
  283. return YES;
  284. }
  285. else {
  286. return %orig;
  287. }
  288. }
  289. %end
  290. // SHOW TIME IN LS STATUSBAR END //
  291. // HIDE CC GRABBER START //
  292. %hook CSTeachableMomentsContainerView
  293. - (void)layoutSubviews {
  294. if (enabled && hideCCGrabber) {
  295. [self.controlCenterGrabberView setHidden:YES];
  296. }
  297. else {
  298. [self.controlCenterGrabberView setHidden:NO];
  299. }
  300. return %orig;
  301. }
  302. %end
  303. // HIDE CC GRABBER END //
  304. // HIDE CARPLAY LABELS START //
  305. %hook CARIconView
  306. +(CGSize)maxLabelSizeForIconImageSize:(CGSize)imageSize {
  307. if (enabled && hideCarPlayLabels) {
  308. return CGSizeZero;
  309. }
  310. else {
  311. return %orig;
  312. }
  313. }
  314. %end
  315. // HIDE CARPLAY LABELS END //
  316. %end // end ios13 group
  317. // stuff that only works on iOS 12
  318. %group ios12
  319. // SHOW TIME IN LS STATUSBAR START //
  320. %hook SBLockScreenViewControllerBase
  321. - (bool)shouldShowLockStatusBarTime {
  322. if (enabled && statusBarShowTimeLS) {
  323. return YES;
  324. }
  325. else {
  326. return %orig;
  327. }
  328. }
  329. %end
  330. // SHOW TIME IN LS STATUSBAR END //
  331. // HIDE CC GRABBER START //
  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 CC GRABBER END //
  344. // HIDE CARPLAY LABELS START //
  345. %hook SBStarkIconView
  346. +(CGSize)maxLabelSize {
  347. if (enabled && hideCarPlayLabels) {
  348. return CGSizeZero;
  349. }
  350. else {
  351. return %orig;
  352. }
  353. }
  354. %end
  355. // HIDE CARPLAY LABELS END //
  356. %end // end ios12 group
  357. // LISTENERS
  358. %ctor {
  359. %init(universal);
  360. // check iOS version
  361. if (kSLSystemVersioniOS13) {
  362. %init(ios13);
  363. }
  364. else {
  365. %init(ios12);
  366. }
  367. // prefs changed listener
  368. notificationCallback(NULL, NULL, NULL, NULL, NULL);
  369. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
  370. // respring listener
  371. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.yaypixxo.kage/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
  372. }