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.

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