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.

200 lines
6.0KB

  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 hideFolderBadges;
  24. //static BOOL hideStatusBarLS;
  25. static BOOL hideCCGrabber;
  26. static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
  27. NSNumber *eEnabled = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"enabled" inDomain:nsDomainString];
  28. NSNumber *eHideQuickActionsBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideQuickActionsBG" inDomain:nsDomainString];
  29. NSNumber *eGridSwitcher = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"gridSwitcher" inDomain:nsDomainString];
  30. NSNumber *eHideLSBatt = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLSBatt" inDomain:nsDomainString];
  31. NSNumber *eStatusBarShowTimeLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"statusBarShowTimeLS" inDomain:nsDomainString];
  32. NSNumber *eHideLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLabels" inDomain:nsDomainString];
  33. NSNumber *eHideFolderBadges = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBadges" inDomain:nsDomainString];
  34. //NSNumber *eHideStatusBarLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideStatusBarLS" inDomain:nsDomainString];
  35. NSNumber *eHideCCGrabber = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCCGrabber" inDomain:nsDomainString];
  36. enabled = (eEnabled) ? [eEnabled boolValue]:NO;
  37. hideQuickActionsBG = (eHideQuickActionsBG) ? [eHideQuickActionsBG boolValue]:NO;
  38. gridSwitcher = (eGridSwitcher) ? [eGridSwitcher boolValue]:NO;
  39. hideLSBatt = (eHideLSBatt) ? [eHideLSBatt boolValue]:NO;
  40. statusBarShowTimeLS = (eStatusBarShowTimeLS) ? [eStatusBarShowTimeLS boolValue]:NO;
  41. hideLabels = (eHideLabels) ? [eHideLabels boolValue]:NO;
  42. hideFolderBadges = (eHideFolderBadges) ? [eHideFolderBadges boolValue]:NO;
  43. //hideStatusBarLS = (eHideStatusBarLS) ? [eHideStatusBarLS boolValue]:NO;
  44. hideCCGrabber = (eHideCCGrabber) ? [eHideCCGrabber boolValue]:NO;
  45. }
  46. // headers and hooks
  47. #import <UIKit/UIKit.h>
  48. @interface SBIconView : UIView
  49. -(void)setLabelHidden:(BOOL)hidden;
  50. @end
  51. @interface SBIcon : NSObject
  52. -(id)badgeNumberOrString;
  53. @end
  54. @interface CSTeachableMomentsContainerView {
  55. }
  56. @property (nonatomic,retain) UIView * controlCenterGrabberView;
  57. @end
  58. // HIDE CC GRABBER START //
  59. %hook CSTeachableMomentsContainerView
  60. - (void)layoutSubviews {
  61. if (enabled && hideCCGrabber) {
  62. [self.controlCenterGrabberView setHidden:YES];
  63. }
  64. else {
  65. [self.controlCenterGrabberView setHidden:NO];
  66. }
  67. return %orig;
  68. }
  69. %end
  70. // HIDE CC GRABBER END //
  71. // QUICK ACTIONS BG START //
  72. %hook UICoverSheetButton
  73. -(id)_backgroundEffectsWithBrightness:(double)arg1 {
  74. if (enabled && hideQuickActionsBG) {
  75. return 0;
  76. }
  77. else {
  78. return %orig;
  79. }
  80. }
  81. %end
  82. // QUICK ACTIONS BG END //
  83. // HIDE BADGE TEXT START //
  84. %hook SBIcon
  85. -(id)badgeNumberOrString {
  86. if (enabled && hideFolderBadges) {
  87. return @"";
  88. }
  89. else {
  90. return %orig;
  91. }
  92. }
  93. %end
  94. // HIDE BADGE TEXT END //
  95. // HIDE LABELS START //
  96. %hook SBIconView
  97. -(void)setLabelHidden:(BOOL)hidden {
  98. if (enabled && hideLabels) {
  99. hidden = YES;
  100. }
  101. %orig;
  102. }
  103. %end
  104. // HIDE LABELS END //
  105. // GRID SWITCHER START //
  106. %hook SBAppSwitcherSettings
  107. - (void)setGridSwitcherPageScale:(double)arg1 {
  108. if (enabled && gridSwitcher) {
  109. arg1 = 0.4;
  110. }
  111. %orig;
  112. }
  113. - (void)setGridSwitcherHorizontalInterpageSpacingPortrait:(double)arg1 {
  114. if (enabled && gridSwitcher) {
  115. arg1 = 25.5;
  116. }
  117. %orig;
  118. }
  119. - (void)setGridSwitcherHorizontalInterpageSpacingLandscape:(double)arg1 {
  120. if (enabled && gridSwitcher) {
  121. arg1 = 11.6;
  122. }
  123. %orig;
  124. }
  125. - (void)setGridSwitcherVerticalNaturalSpacingPortrait:(double)arg1 {
  126. if (enabled && gridSwitcher) {
  127. arg1 = 42;
  128. }
  129. %orig;
  130. }
  131. - (void)setGridSwitcherVerticalNaturalSpacingLandscape:(double)arg1 {
  132. if (enabled && gridSwitcher) {
  133. arg1 = 38;
  134. }
  135. %orig;
  136. }
  137. - (void)setSwitcherStyle:(long long)arg1 {
  138. if (enabled && gridSwitcher) {
  139. arg1 = 2;
  140. }
  141. %orig;
  142. }
  143. %end
  144. // GRID SWITCHER END //
  145. // NO LS BATTERY START //
  146. %hook CSCoverSheetViewController
  147. - (void)_transitionChargingViewToVisible:(bool)arg1 showBattery:(bool)arg2 animated:(bool)arg3 {
  148. if (enabled && hideLSBatt) {
  149. arg1 = 0;
  150. }
  151. %orig;
  152. }
  153. %end
  154. // NO LS BATTERY END //
  155. // SHOW TIME IN LS STATUSBAR START //
  156. %hook CSCoverSheetViewController
  157. - (bool)shouldShowLockStatusBarTime {
  158. if (enabled && statusBarShowTimeLS) {
  159. return 1;
  160. }
  161. else {
  162. return %orig;
  163. }
  164. }
  165. %end
  166. // SHOW TIME IN LS STATUSBAR END //
  167. // LISTENERS
  168. %ctor {
  169. // prefs changed listener
  170. notificationCallback(NULL, NULL, NULL, NULL, NULL);
  171. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
  172. // respring listener
  173. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.yaypixxo.kage/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
  174. }