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.

182 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. //fix for icons being off the page ios 13
  100. %hook SBIconListGridLayoutConfiguration
  101. %property (nonatomic, assign) NSString *location;
  102. %new //Modeled off of Kritanta's solution with ivars
  103. - (NSString *)findLocation {
  104. if (self.location) return self.location;
  105. else {
  106. NSUInteger rows = MSHookIvar<NSUInteger>(self, "_numberOfPortraitRows");
  107. NSUInteger columns = MSHookIvar<NSUInteger>(self, "_numberOfPortraitColumns");
  108. // dock
  109. if (rows <= 2 && columns == 4) { //Only checks the columns so if for some stupid reason the user has another dock tweak, it won't break things.
  110. self.location = @"Dock";
  111. } else if (rows == 3 && columns == 3) {
  112. self.location = @"Folder";
  113. } else {
  114. self.location = @"Root";
  115. }
  116. }
  117. return self.location;
  118. }
  119. - (NSUInteger)numberOfPortraitColumns {
  120. [self findLocation];
  121. if ([self.location isEqualToString:@"Dock"]) {
  122. if (hidden) {
  123. return (0);
  124. } else {
  125. return (setIconNumber);
  126. }
  127. } else {
  128. return (%orig);
  129. }
  130. }
  131. %end
  132. %end
  133. // Thanks to Nepeta for the DRM, and thanks to Litten as well
  134. %ctor {
  135. dpkgInvalid = ![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/com.burritoz.dockify.list"];
  136. if (!dpkgInvalid) dpkgInvalid = ![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/com.burritoz.dockify.md5sums"];
  137. preferences = [[HBPreferences alloc] initWithIdentifier:@"com.burritoz.dockifyprefs"];
  138. [preferences registerDefaults:@ { //defaults for prefernces
  139. @"tweakEnabled": @YES,
  140. @"setHeight": @1,
  141. @"customOpacity": @1,
  142. @"hidden": @NO,
  143. @"setIconNumber": @4,
  144. }];
  145. [preferences registerBool:&tweakEnabled default:YES forKey:@"tweakEnabled"];
  146. [preferences registerBool:&transparent default:YES forKey:@"transparent"]; //registering transparent as a Boolean
  147. [preferences registerBool:&hidden default:NO forKey:@"hidden"]; //registering hidden as a Boolean
  148. [preferences registerDouble:(double *)&setHeight default:1 forKey:@"setHeight"]; //registering setHeigt as a double (number)
  149. [preferences registerDouble:(double *)&customOpacity default:1 forKey:@"customOpacity"]; //registering customOpacity as a double (number)
  150. [preferences registerInteger:(NSInteger *)&setIconNumber default:4 forKey:@"setIconNumber"]; //Integer of how many icons to allow
  151. if (tweakEnabled) {
  152. %init(allVersions);
  153. if (kCFCoreFoundationVersionNumber < 1600) //This means version < 12
  154. {
  155. %init(version12);
  156. }
  157. else
  158. {
  159. %init(version13);
  160. }
  161. }
  162. }