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.

Tweak.x 4.6KB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
  24. NSNumber *eEnabled = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"enabled" inDomain:nsDomainString];
  25. NSNumber *eHideQuickActionsBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideQuickActionsBG" inDomain:nsDomainString];
  26. NSNumber *eGridSwitcher = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"gridSwitcher" inDomain:nsDomainString];
  27. NSNumber *eHideLSBatt = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLSBatt" inDomain:nsDomainString];
  28. NSNumber *eStatusBarShowTimeLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"statusBarShowTimeLS" inDomain:nsDomainString];
  29. NSNumber *eHideLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLabels" inDomain:nsDomainString];
  30. enabled = (eEnabled) ? [eEnabled boolValue]:NO;
  31. hideQuickActionsBG = (eHideQuickActionsBG) ? [eHideQuickActionsBG boolValue]:NO;
  32. gridSwitcher = (eGridSwitcher) ? [eGridSwitcher boolValue]:NO;
  33. hideLSBatt = (eHideLSBatt) ? [eHideLSBatt boolValue]:NO;
  34. statusBarShowTimeLS = (eStatusBarShowTimeLS) ? [eStatusBarShowTimeLS boolValue]:NO;
  35. hideLabels = (eHideLabels) ? [eHideLabels boolValue]:NO;
  36. }
  37. // hooks and stuff
  38. #import <UIKit/UIKit.h>
  39. @interface SBIconView : UIView
  40. -(void)setLabelHidden:(BOOL)hidden;
  41. @end
  42. // QUICK ACTIONS BG START //
  43. %hook UICoverSheetButton
  44. -(id)_backgroundEffectsWithBrightness:(double)arg1 {
  45. if (enabled && hideQuickActionsBG) {
  46. return 0;
  47. }
  48. else {
  49. return %orig;
  50. }
  51. }
  52. %end
  53. // QUICK ACTIONS BG END //
  54. // HIDE LABELS START //
  55. %hook SBIconView
  56. -(void)setLabelHidden:(BOOL)hidden {
  57. if (enabled && hideLabels) {
  58. hidden = YES;
  59. }
  60. %orig;
  61. }
  62. %end
  63. // HIDE LABELS END //
  64. // GRID SWITCHER START //
  65. %hook SBAppSwitcherSettings
  66. - (void)setGridSwitcherPageScale:(double)arg1 {
  67. if (enabled && gridSwitcher) {
  68. arg1 = 0.4;
  69. }
  70. %orig;
  71. }
  72. - (void)setGridSwitcherHorizontalInterpageSpacingPortrait:(double)arg1 {
  73. if (enabled && gridSwitcher) {
  74. arg1 = 25.5;
  75. }
  76. %orig;
  77. }
  78. - (void)setGridSwitcherHorizontalInterpageSpacingLandscape:(double)arg1 {
  79. if (enabled && gridSwitcher) {
  80. arg1 = 11.6;
  81. }
  82. %orig;
  83. }
  84. - (void)setGridSwitcherVerticalNaturalSpacingPortrait:(double)arg1 {
  85. if (enabled && gridSwitcher) {
  86. arg1 = 42;
  87. }
  88. %orig;
  89. }
  90. - (void)setGridSwitcherVerticalNaturalSpacingLandscape:(double)arg1 {
  91. if (enabled && gridSwitcher) {
  92. arg1 = 38;
  93. }
  94. %orig;
  95. }
  96. - (void)setSwitcherStyle:(long long)arg1 {
  97. if (enabled && gridSwitcher) {
  98. arg1 = 2;
  99. }
  100. %orig;
  101. }
  102. %end
  103. // GRID SWITCHER END //
  104. // NO LS BATTERY START //
  105. %hook CSCoverSheetViewController
  106. - (void)_transitionChargingViewToVisible:(bool)arg1 showBattery:(bool)arg2 animated:(bool)arg3 {
  107. if (enabled && hideLSBatt) {
  108. arg1 = 0;
  109. }
  110. %orig;
  111. }
  112. %end
  113. // NO LS BATTERY END //
  114. // SHOW TIME IN LS STATUSBAR START //
  115. %hook CSCoverSheetViewController
  116. - (bool)shouldShowLockStatusBarTime {
  117. if (enabled && statusBarShowTimeLS) {
  118. return 1;
  119. }
  120. else {
  121. return %orig;
  122. }
  123. }
  124. %end
  125. // SHOW TIME IN LS STATUSBAR END //
  126. // LISTENERS
  127. %ctor {
  128. // prefs changed listener
  129. notificationCallback(NULL, NULL, NULL, NULL, NULL);
  130. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
  131. // respring listener
  132. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.yaypixxo.kage/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
  133. }