iOSthemem0d

Untitled

Mar 26th, 2020
185
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @interface _UIStatusBar : UIView
  2. @property (weak, nonatomic) IBOutlet UILabel *Status;
  3. @end
  4.  
  5. @interface RoundProgressView: UIView {
  6.     CGFloat startAngle;
  7.     CGFloat endAngle;
  8. }
  9. @property (assign) int percent;
  10. @end
  11.  
  12. RoundProgressView* m_progressView;
  13.  
  14.  
  15. @implementation RoundProgressView
  16.  
  17. - (id)initWithFrame:(CGRect)frame
  18. {
  19.     self = [super initWithFrame:frame];
  20.     if (self) {
  21.         // Initialization code
  22.         self.backgroundColor = [UIColor whiteColor];
  23.  
  24.         // Determine our start and stop angles for the arc (in radians)
  25.         startAngle = M_PI * 1.5;
  26.         endAngle = startAngle + (M_PI * 2);
  27.  
  28.     }
  29.     return self;
  30. }
  31.  
  32. - (void)drawRect:(CGRect)rect
  33. {
  34.     // Display our percentage as a string
  35.     NSString* textContent = [NSString stringWithFormat:@"%d", self.percent];
  36.  
  37.     UIBezierPath* bezierPath = [UIBezierPath bezierPath];
  38.  
  39.     // Create our arc, with the correct angles
  40.     [bezierPath addArcWithCenter:CGPointMake(rect.size.width / 2, rect.size.height / 2)
  41.                           radius:130
  42.                       startAngle:startAngle
  43.                         endAngle:(endAngle - startAngle) * (_percent / 100.0) + startAngle
  44.                        clockwise:YES];
  45.  
  46.     // Set the display for the path, and stroke it
  47.     bezierPath.lineWidth = 20;
  48.     [[UIColor redColor] setStroke];
  49.     [bezierPath stroke];
  50.  
  51.     // Text Drawing
  52.     CGRect textRect = CGRectMake((rect.size.width / 2.0) - 71/2.0, (rect.size.height / 2.0) - 45/2.0, 71, 45);
  53.     [[UIColor blackColor] setFill];
  54.     [textContent drawInRect: textRect withFont: [UIFont fontWithName: @"Helvetica-Bold" size: 42.5] lineBreakMode: NSLineBreakByWordWrapping alignment: NSTextAlignmentCenter];
  55. }
  56. @end
  57.  
  58.  
  59.  
  60. %hook _UIStatusBar
  61.  
  62. // Hub main view and add modules page to it
  63. %property (nonatomic, retain) UIView *deviceInfoView;
  64. %property (retain) UILabel *deviceLabel;
  65. %property (retain) UILabel *versionLabel;
  66. %property (retain) UILabel *wifi_IPLabel;
  67.  
  68.  
  69. -(void)layoutSubviews {
  70.   %orig;
  71.  
  72.     UITapGestureRecognizer *tapGesture1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showHub)];
  73.     tapGesture1.numberOfTapsRequired = 2;
  74.     [self addGestureRecognizer:tapGesture1];
  75. }
  76.  
  77. %new
  78. -(void)showHub {
  79.  
  80.   // Device info view
  81. self.deviceInfoView = [[UIView alloc] initWithFrame:CGRectMake(scrollView.frame.size.width * page, 0, SCREEN_WIDTH, 50)];
  82. self.deviceInfoView.backgroundColor = [UIColor hubLayersColor];
  83. self.deviceInfoView.layer.cornerRadius = 20;
  84. self.modulesView.clipsToBounds = YES;
  85. [self.centralHubView addSubview:self.deviceInfoView];
  86.  
  87. // Device info view constraint
  88. self.deviceInfoView.translatesAutoresizingMaskIntoConstraints = NO;
  89. [self.deviceInfoView.topAnchor constraintEqualToAnchor:self.centralHubView.topAnchor constant:270.0].active = YES;
  90. [self.deviceInfoView.bottomAnchor constraintEqualToAnchor:self.centralHubView.bottomAnchor constant:-40.0].active = YES;
  91. [self.deviceInfoView.leadingAnchor constraintEqualToAnchor:self.centralHubView.leadingAnchor constant:20.0].active = YES;
  92. [self.deviceInfoView.trailingAnchor constraintEqualToAnchor:self.centralHubView.trailingAnchor constant:-20.0].active = YES;
  93.  
  94.  
  95. NSDictionary * spaces = [self getSpaces];
  96.  
  97. NSLog(@"Fee space: %@", [spaces objectForKey:@"FreeSpace"]);
  98. NSLog(@"Total space: %@", [spaces objectForKey:@"TotalSpace"]);
  99. NSLog(@"Used space: %@", [spaces objectForKey:@"UsedSpace"]);
  100.  
  101. m_progressView = [[RoundProgressView alloc] initWithFrame:self.view.bounds];
  102. m_progressView.percent = ([(NSNumber*)[spaces objectForKey:@"UsedSpace"] doubleValue]) / ([(NSNumber*)[spaces objectForKey:@"TotalSpace"] doubleValue]) * 100;
  103. [self.deviceInfoView addSubview:m_progressView];
  104. }
  105.  
  106. -(NSDictionary*) getSpaces {
  107.     unsigned long long totalSpace = 0;
  108.     unsigned long long totalFreeSpace = 0;
  109.     unsigned long long usedSpace = 0;
  110.  
  111.     NSError *error = nil;
  112.     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  113.     NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
  114.  
  115.     NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
  116.     NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
  117.     totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
  118.     totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
  119.     usedSpace = totalSpace - totalFreeSpace;
  120.    
  121.     NSDictionary *spaceDict = @{
  122.         @"FreeSpace":[NSNumber numberWithDouble:totalFreeSpace*(pow(10,-9))],
  123.         @"TotalSpace":[NSNumber numberWithDouble:totalSpace*(pow(10,-9))],
  124.         @"UsedSpace":[NSNumber numberWithDouble:usedSpace*(pow(10,-9))]
  125.     };
  126.    
  127.     return spaceDict;
  128. }
  129. %end
RAW Paste Data