hide/show/change stuff on the LS and HS https://github.com/viggou/Kage
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

294 Zeilen
8.1KB

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