Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @interface _UIStatusBar : UIView
- @property (weak, nonatomic) IBOutlet UILabel *Status;
- @end
- @interface RoundProgressView: UIView {
- CGFloat startAngle;
- CGFloat endAngle;
- }
- @property (assign) int percent;
- @end
- RoundProgressView* m_progressView;
- @implementation RoundProgressView
- - (id)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- // Initialization code
- self.backgroundColor = [UIColor whiteColor];
- // Determine our start and stop angles for the arc (in radians)
- startAngle = M_PI * 1.5;
- endAngle = startAngle + (M_PI * 2);
- }
- return self;
- }
- - (void)drawRect:(CGRect)rect
- {
- // Display our percentage as a string
- NSString* textContent = [NSString stringWithFormat:@"%d", self.percent];
- UIBezierPath* bezierPath = [UIBezierPath bezierPath];
- // Create our arc, with the correct angles
- [bezierPath addArcWithCenter:CGPointMake(rect.size.width / 2, rect.size.height / 2)
- radius:130
- startAngle:startAngle
- endAngle:(endAngle - startAngle) * (_percent / 100.0) + startAngle
- clockwise:YES];
- // Set the display for the path, and stroke it
- bezierPath.lineWidth = 20;
- [[UIColor redColor] setStroke];
- [bezierPath stroke];
- // Text Drawing
- CGRect textRect = CGRectMake((rect.size.width / 2.0) - 71/2.0, (rect.size.height / 2.0) - 45/2.0, 71, 45);
- [[UIColor blackColor] setFill];
- [textContent drawInRect: textRect withFont: [UIFont fontWithName: @"Helvetica-Bold" size: 42.5] lineBreakMode: NSLineBreakByWordWrapping alignment: NSTextAlignmentCenter];
- }
- @end
- %hook _UIStatusBar
- // Hub main view and add modules page to it
- %property (nonatomic, retain) UIView *deviceInfoView;
- %property (retain) UILabel *deviceLabel;
- %property (retain) UILabel *versionLabel;
- %property (retain) UILabel *wifi_IPLabel;
- -(void)layoutSubviews {
- %orig;
- UITapGestureRecognizer *tapGesture1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showHub)];
- tapGesture1.numberOfTapsRequired = 2;
- [self addGestureRecognizer:tapGesture1];
- }
- %new
- -(void)showHub {
- // Device info view
- self.deviceInfoView = [[UIView alloc] initWithFrame:CGRectMake(scrollView.frame.size.width * page, 0, SCREEN_WIDTH, 50)];
- self.deviceInfoView.backgroundColor = [UIColor hubLayersColor];
- self.deviceInfoView.layer.cornerRadius = 20;
- self.modulesView.clipsToBounds = YES;
- [self.centralHubView addSubview:self.deviceInfoView];
- // Device info view constraint
- self.deviceInfoView.translatesAutoresizingMaskIntoConstraints = NO;
- [self.deviceInfoView.topAnchor constraintEqualToAnchor:self.centralHubView.topAnchor constant:270.0].active = YES;
- [self.deviceInfoView.bottomAnchor constraintEqualToAnchor:self.centralHubView.bottomAnchor constant:-40.0].active = YES;
- [self.deviceInfoView.leadingAnchor constraintEqualToAnchor:self.centralHubView.leadingAnchor constant:20.0].active = YES;
- [self.deviceInfoView.trailingAnchor constraintEqualToAnchor:self.centralHubView.trailingAnchor constant:-20.0].active = YES;
- NSDictionary * spaces = [self getSpaces];
- NSLog(@"Fee space: %@", [spaces objectForKey:@"FreeSpace"]);
- NSLog(@"Total space: %@", [spaces objectForKey:@"TotalSpace"]);
- NSLog(@"Used space: %@", [spaces objectForKey:@"UsedSpace"]);
- m_progressView = [[RoundProgressView alloc] initWithFrame:self.view.bounds];
- m_progressView.percent = ([(NSNumber*)[spaces objectForKey:@"UsedSpace"] doubleValue]) / ([(NSNumber*)[spaces objectForKey:@"TotalSpace"] doubleValue]) * 100;
- [self.deviceInfoView addSubview:m_progressView];
- }
- -(NSDictionary*) getSpaces {
- unsigned long long totalSpace = 0;
- unsigned long long totalFreeSpace = 0;
- unsigned long long usedSpace = 0;
- NSError *error = nil;
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
- NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
- NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
- totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
- totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
- usedSpace = totalSpace - totalFreeSpace;
- NSDictionary *spaceDict = @{
- @"FreeSpace":[NSNumber numberWithDouble:totalFreeSpace*(pow(10,-9))],
- @"TotalSpace":[NSNumber numberWithDouble:totalSpace*(pow(10,-9))],
- @"UsedSpace":[NSNumber numberWithDouble:usedSpace*(pow(10,-9))]
- };
- return spaceDict;
- }
- %end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement