The source code, duh.
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.

192 lines
5.9KB

  1. //Please note, in order to use MSHookIvar, this file needs to be .xm
  2. #import <Cephei/HBPreferences.h>
  3. #import <Foundation/Foundation.h>
  4. @interface SBCoverSheetPrimarySlidingViewController : UIViewController
  5. - (void)viewDidDisappear:(BOOL)arg1;
  6. - (void)viewDidAppear:(BOOL)arg1;
  7. @end
  8. @interface SBIconListGridLayoutConfiguration
  9. @property (nonatomic, assign) NSString *location;
  10. - (NSString *)findLocation;
  11. - (NSUInteger)numberOfPortraitColumns;
  12. - (NSUInteger)numberOfPortraitRows;
  13. @end
  14. //Set up variables for use with Cephei
  15. static BOOL tweakEnabled;
  16. static BOOL transparent;
  17. static BOOL hidden;
  18. static double setHeight;
  19. static double customOpacity;
  20. static NSInteger setIconNumber;
  21. //nepeta like drm
  22. BOOL dpkgInvalid = NO;
  23. HBPreferences *preferences;
  24. %group allVersions
  25. %hook SBCoverSheetPrimarySlidingViewController
  26. - (void)viewDidDisappear:(BOOL)arg1 {
  27. %orig; // Thanks to Nepeta for the DRM
  28. if (!dpkgInvalid) return;
  29. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Pirate Detected!"
  30. message:@"Seriously? Pirating a free Tweak is awful!\nPiracy repo's Tweaks could contain Malware if you didn't know that, so go ahead and get Dockify from the official Source https://Burrit0z.github.io/repo/.\nIf you're seeing this but you got it from the official source then make sure to add https://Burrit0z.github.io/repo to Cydia or Sileo."
  31. preferredStyle:UIAlertControllerStyleAlert];
  32. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Aww man" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) {
  33. UIApplication *application = [UIApplication sharedApplication];
  34. [application openURL:[NSURL URLWithString:@"https://Burrit0z.github.io/repo"] options:@{} completionHandler:nil];
  35. }];
  36. [alertController addAction:cancelAction];
  37. [self presentViewController:alertController animated:YES completion:nil];
  38. }
  39. %end
  40. %end
  41. %group version12
  42. //hook the dock
  43. %hook SBDockView
  44. //ios 12
  45. -(double)dockHeight {
  46. if (hidden) {
  47. return (0);
  48. } else {
  49. return (%orig*setHeight); //sets custom height if dock is not set to hidden
  50. }
  51. }
  52. //this deals with everything adjusting opacity/transparency
  53. //ios 12 and 13
  54. -(void)setBackgroundAlpha:(double)arg1 {
  55. if (transparent == NO && hidden == NO) { //if not transparent and not hidden
  56. %orig(customOpacity);
  57. }else if (transparent || hidden) { // Note: || means or in objc
  58. %orig(0.0); //hides background of the dock (transparent)
  59. } else {
  60. NSLog(@"Dock not Transparent/hidden, no custom opacity\n");
  61. }
  62. }
  63. %end
  64. //NEW HOOK FOR ICON STATE
  65. %hook SBDockIconListView
  66. //ios 12 required piece
  67. +(NSInteger)maxIcons {
  68. if (hidden) {
  69. return (0);
  70. } else {
  71. return (setIconNumber);
  72. }
  73. }
  74. %end
  75. %end
  76. //NEW GROUP FOR ios13
  77. %group version13
  78. %hook SBDockView
  79. //ios 13
  80. -(double)dockHeight {
  81. if (hidden) {
  82. return (0);
  83. } else {
  84. return (%orig*setHeight); //sets custom height if dock is not set to hidden
  85. }
  86. }
  87. //this deals with everything adjusting opacity/transparency
  88. //ios 12 and 13
  89. -(void)setBackgroundAlpha:(double)arg1 {
  90. if (transparent == NO && hidden == NO) { //if not transparent and not hidden
  91. %orig(customOpacity);
  92. }else if (transparent || hidden) { // Note: || means or in objc
  93. %orig(0.0); //hides background of the dock (transparent)
  94. } else {
  95. NSLog(@"Dock not Transparent/hidden, no custom opacity\n");
  96. }
  97. }
  98. %end
  99. %hook SBDockIconListView
  100. - (NSUInteger)iconColumnsForCurrentOrientation {
  101. if (hidden) {
  102. return (0);
  103. } else {
  104. return (setIconNumber);
  105. }
  106. }
  107. %end
  108. //fix for icons being off the page ios 13
  109. %hook SBIconListGridLayoutConfiguration
  110. %property (nonatomic, assign) NSString *location;
  111. %new //Modeled off of Kritanta's solution with ivars
  112. - (NSString *)findLocation {
  113. if (self.location) return self.location;
  114. else {
  115. NSUInteger rows = MSHookIvar<NSUInteger>(self, "_numberOfPortraitRows");
  116. NSUInteger columns = MSHookIvar<NSUInteger>(self, "_numberOfPortraitColumns");
  117. // dock
  118. if (rows <= 2 && columns == 4) {
  119. self.location = @"Dock";
  120. } else if (rows == 3 && columns == 3) {
  121. self.location = @"Folder";
  122. } else {
  123. self.location = @"Root";
  124. }
  125. }
  126. return self.location;
  127. }
  128. - (NSUInteger)numberOfPortraitColumns {
  129. [self findLocation];
  130. if ([self.location isEqualToString:@"Dock"]) {
  131. if (hidden) {
  132. return (0);
  133. } else {
  134. return (setIconNumber);
  135. }
  136. } else {
  137. return (%orig);
  138. }
  139. }
  140. %end
  141. %end
  142. // Thanks to Nepeta for the DRM, and thanks to Litten as well
  143. %ctor {
  144. dpkgInvalid = ![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/com.burritoz.dockify.list"];
  145. if (!dpkgInvalid) dpkgInvalid = ![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/com.burritoz.dockify.md5sums"];
  146. preferences = [[HBPreferences alloc] initWithIdentifier:@"com.burritoz.dockifyprefs"];
  147. [preferences registerDefaults:@ { //defaults for prefernces
  148. @"tweakEnabled": @YES,
  149. @"setHeight": @1,
  150. @"customOpacity": @1,
  151. @"hidden": @NO,
  152. @"setIconNumber": @4,
  153. }];
  154. [preferences registerBool:&tweakEnabled default:YES forKey:@"tweakEnabled"];
  155. [preferences registerBool:&transparent default:YES forKey:@"transparent"]; //registering transparent as a Boolean
  156. [preferences registerBool:&hidden default:NO forKey:@"hidden"]; //registering hidden as a Boolean
  157. [preferences registerDouble:(double *)&setHeight default:1 forKey:@"setHeight"]; //registering setHeigt as a double (number)
  158. [preferences registerDouble:(double *)&customOpacity default:1 forKey:@"customOpacity"]; //registering customOpacity as a double (number)
  159. [preferences registerInteger:(NSInteger *)&setIconNumber default:4 forKey:@"setIconNumber"]; //Integer of how many icons to allow
  160. if (tweakEnabled) {
  161. %init(allVersions);
  162. if (kCFCoreFoundationVersionNumber < 1600) //This means version < 12
  163. {
  164. %init(version12);
  165. }
  166. else
  167. {
  168. %init(version13);
  169. }
  170. }
  171. }