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.

317 lines
8.9KB

  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 hideStatusBarLS;
  28. static BOOL hideCCGrabber;
  29. static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
  30. NSNumber *eEnabled = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"enabled" inDomain:nsDomainString];
  31. NSNumber *eHideQuickActionsBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideQuickActionsBG" inDomain:nsDomainString];
  32. NSNumber *eGridSwitcher = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"gridSwitcher" inDomain:nsDomainString];
  33. NSNumber *eHideLSBatt = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLSBatt" inDomain:nsDomainString];
  34. NSNumber *eStatusBarShowTimeLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"statusBarShowTimeLS" inDomain:nsDomainString];
  35. NSNumber *eHideLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLabels" inDomain:nsDomainString];
  36. NSNumber *eHideCarPlayLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCarPlayLabels" inDomain:nsDomainString];
  37. NSNumber *eHideFolderBadges = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBadges" inDomain:nsDomainString];
  38. NSNumber *eHideFolderTitle = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderTitle" inDomain:nsDomainString];
  39. //NSNumber *eHideFolderBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBG" inDomain:nsDomainString];
  40. //NSNumber *eHideStatusBarLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideStatusBarLS" inDomain:nsDomainString];
  41. NSNumber *eHideCCGrabber = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCCGrabber" inDomain:nsDomainString];
  42. enabled = (eEnabled) ? [eEnabled boolValue]:NO;
  43. hideQuickActionsBG = (eHideQuickActionsBG) ? [eHideQuickActionsBG boolValue]:NO;
  44. gridSwitcher = (eGridSwitcher) ? [eGridSwitcher boolValue]:NO;
  45. hideLSBatt = (eHideLSBatt) ? [eHideLSBatt boolValue]:NO;
  46. statusBarShowTimeLS = (eStatusBarShowTimeLS) ? [eStatusBarShowTimeLS boolValue]:NO;
  47. hideLabels = (eHideLabels) ? [eHideLabels boolValue]:NO;
  48. hideCarPlayLabels = (eHideCarPlayLabels) ? [eHideCarPlayLabels boolValue]:NO;
  49. hideFolderBadges = (eHideFolderBadges) ? [eHideFolderBadges boolValue]:NO;
  50. hideFolderTitle = (eHideFolderTitle) ? [eHideFolderTitle boolValue]:NO;
  51. //hideFolderBG = (eHideFolderBG) ? [eHideFolderBG boolValue]:NO;
  52. //hideStatusBarLS = (eHideStatusBarLS) ? [eHideStatusBarLS boolValue]:NO;
  53. hideCCGrabber = (eHideCCGrabber) ? [eHideCCGrabber boolValue]:NO;
  54. }
  55. // headers and hooks
  56. #import <UIKit/UIKit.h>
  57. @interface SBIconView : UIView
  58. -(void)setLabelHidden:(BOOL)hidden;
  59. @end
  60. @interface SBIcon : NSObject
  61. -(id)badgeNumberOrString;
  62. @end
  63. @interface CSTeachableMomentsContainerView
  64. @property (nonatomic,retain) UIView * controlCenterGrabberView;
  65. @end
  66. @interface SBDashBoardTeachableMomentsContainerView
  67. @property (nonatomic,retain) UIView * controlCenterGrabberView;
  68. @end
  69. #ifndef kCFCoreFoundationVersionNumber_iOS_13_0
  70. #define kCFCoreFoundationVersionNumber_iOS_13_0 1665.15
  71. #endif
  72. #define kSLSystemVersioniOS13 kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_13_0
  73. %group universal
  74. // QUICK ACTIONS BG START //
  75. %hook UICoverSheetButton
  76. -(id)_backgroundEffectsWithBrightness:(double)arg1 {
  77. if (enabled && hideQuickActionsBG) {
  78. return 0;
  79. }
  80. else {
  81. return %orig;
  82. }
  83. }
  84. %end
  85. // QUICK ACTIONS BG END //
  86. // HIDE FOLDER BADGE TEXT START //
  87. %hook SBIcon
  88. -(id)badgeNumberOrString {
  89. if (enabled && hideFolderBadges) {
  90. return @"";
  91. }
  92. else {
  93. return %orig;
  94. }
  95. }
  96. %end
  97. // HIDE FOLDER BADGE TEXT END //
  98. // HIDE LABELS START //
  99. %hook SBIconView
  100. -(void)setLabelHidden:(BOOL)hidden {
  101. if (enabled && hideLabels) {
  102. hidden = YES;
  103. }
  104. %orig;
  105. }
  106. %end
  107. // HIDE LABELS END //
  108. // GRID SWITCHER START //
  109. %hook SBAppSwitcherSettings
  110. - (void)setGridSwitcherPageScale:(double)arg1 {
  111. if (enabled && gridSwitcher) {
  112. arg1 = 0.4;
  113. }
  114. %orig;
  115. }
  116. - (void)setGridSwitcherHorizontalInterpageSpacingPortrait:(double)arg1 {
  117. if (enabled && gridSwitcher) {
  118. arg1 = 25.5;
  119. }
  120. %orig;
  121. }
  122. - (void)setGridSwitcherHorizontalInterpageSpacingLandscape:(double)arg1 {
  123. if (enabled && gridSwitcher) {
  124. arg1 = 11.6;
  125. }
  126. %orig;
  127. }
  128. - (void)setGridSwitcherVerticalNaturalSpacingPortrait:(double)arg1 {
  129. if (enabled && gridSwitcher) {
  130. arg1 = 42;
  131. }
  132. %orig;
  133. }
  134. - (void)setGridSwitcherVerticalNaturalSpacingLandscape:(double)arg1 {
  135. if (enabled && gridSwitcher) {
  136. arg1 = 38;
  137. }
  138. %orig;
  139. }
  140. - (void)setSwitcherStyle:(long long)arg1 {
  141. if (enabled && gridSwitcher) {
  142. arg1 = 2;
  143. }
  144. %orig;
  145. }
  146. %end
  147. // GRID SWITCHER END //
  148. // NO LS BATTERY START //
  149. %hook CSCoverSheetViewController
  150. - (void)_transitionChargingViewToVisible:(bool)arg1 showBattery:(bool)arg2 animated:(bool)arg3 {
  151. if (enabled && hideLSBatt) {
  152. arg1 = 0;
  153. }
  154. %orig;
  155. }
  156. %end
  157. // NO LS BATTERY END //
  158. // SHOW FOLDER TITLE START //
  159. %hook SBFloatyFolderView
  160. -(BOOL)_showsTitle {
  161. if (enabled && hideFolderTitle) {
  162. return NO;
  163. }
  164. else {
  165. return %orig;
  166. }
  167. }
  168. %end
  169. // SHOW FOLDER TITLE END //
  170. // HIDE FOLDER BACKGROUND START //
  171. /*%hook SBFolderBackgroundView
  172. -(void)layoutSubviews {
  173. %orig;
  174. if (enabled && hideFolderBG) {
  175. UIImageView * tintView = MSHookIvar<UIImageView *>(self, "_tintView");
  176. tintView.alpha = 0;
  177. }
  178. }
  179. %end*/
  180. // HIDE FOLDER BACKGROUND END //
  181. %end // end universal group
  182. // stuff that only works on iOS 13
  183. %group ios13
  184. // SHOW TIME IN LS STATUSBAR START //
  185. %hook CSCoverSheetViewController
  186. - (bool)shouldShowLockStatusBarTime {
  187. if (enabled && statusBarShowTimeLS) {
  188. return YES;
  189. }
  190. else {
  191. return %orig;
  192. }
  193. }
  194. %end
  195. // SHOW TIME IN LS STATUSBAR END //
  196. // HIDE CC GRABBER START //
  197. %hook CSTeachableMomentsContainerView
  198. - (void)layoutSubviews {
  199. if (enabled && hideCCGrabber) {
  200. [self.controlCenterGrabberView setHidden:YES];
  201. }
  202. else {
  203. [self.controlCenterGrabberView setHidden:NO];
  204. }
  205. return %orig;
  206. }
  207. %end
  208. // HIDE CC GRABBER END //
  209. // HIDE CARPLAY LABELS START //
  210. %hook CARIconView
  211. +(CGSize)maxLabelSizeForIconImageSize:(CGSize)imageSize {
  212. if (enabled && hideCarPlayLabels) {
  213. return CGSizeZero;
  214. }
  215. else {
  216. return %orig;
  217. }
  218. }
  219. %end
  220. // HIDE CARPLAY LABELS END //
  221. %end // end ios13 group
  222. // stuff that only works on iOS 12
  223. %group ios12
  224. // SHOW TIME IN LS STATUSBAR START //
  225. %hook SBLockScreenViewControllerBase
  226. - (bool)shouldShowLockStatusBarTime {
  227. if (enabled && statusBarShowTimeLS) {
  228. return YES;
  229. }
  230. else {
  231. return %orig;
  232. }
  233. }
  234. %end
  235. // SHOW TIME IN LS STATUSBAR END //
  236. // HIDE CC GRABBER START //
  237. %hook SBDashBoardTeachableMomentsContainerView
  238. - (void)layoutSubviews {
  239. if (enabled && hideCCGrabber) {
  240. [self.controlCenterGrabberView setHidden:YES];
  241. }
  242. else {
  243. [self.controlCenterGrabberView setHidden:NO];
  244. }
  245. return %orig;
  246. }
  247. %end
  248. // HIDE CC GRABBER END //
  249. // HIDE CARPLAY LABELS START //
  250. %hook SBStarkIconView
  251. +(CGSize)maxLabelSize {
  252. if (enabled && hideCarPlayLabels) {
  253. return CGSizeZero;
  254. }
  255. else {
  256. return %orig;
  257. }
  258. }
  259. %end
  260. // HIDE CARPLAY LABELS END //
  261. %end // end ios12 group
  262. // LISTENERS
  263. %ctor {
  264. %init(universal);
  265. // check iOS version
  266. if (kSLSystemVersioniOS13) {
  267. %init(ios13);
  268. }
  269. else {
  270. %init(ios12);
  271. }
  272. // prefs changed listener
  273. notificationCallback(NULL, NULL, NULL, NULL, NULL);
  274. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
  275. // respring listener
  276. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.yaypixxo.kage/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
  277. }