Skip to content

Instantly share code, notes, and snippets.

@jontelang
Last active December 10, 2015 06:49
Show Gist options
  • Save jontelang/4397260 to your computer and use it in GitHub Desktop.
Save jontelang/4397260 to your computer and use it in GitHub Desktop.
Boover
%hook SBIconBadgeImage
@interface SBIconBadgeImage
@property(readonly, copy) NSString* text;
@end
-(id)initWithCGImage:(CGImageRef)cgimage scale:(float)scale orientation:(int)orientation text:(id)text{
NSDictionary *d = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.jontelang.boover.plist"];
float s = [[d valueForKey:@"scale"] floatValue];
// For some reason the default scale is 2.0f .... ?
if( s ) scale = 3-s;
return %orig;
}
%end
%hook SBIconView
@interface SBIconView : UIView
-(void)setLabelHidden:(BOOL)hidden;
-(void)updateLabel;
@end
-(void)updateBadge{
%orig;
UIImageView *v = MSHookIvar<UIImageView *>(self, "_badgeView");
NSDictionary *d = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.jontelang.boover.plist"];
int p = [[d valueForKey:@"BadgePosition"] intValue];
int offsetX = [[d valueForKey:@"offsetX"] intValue];
int offsetY = [[d valueForKey:@"offsetY"] intValue];
switch(p){
case 0: [v setFrame:CGRectMake( -9+offsetX,-9+offsetY,v.bounds.size.width,v.bounds.size.height)]; break;
case 1: [v setCenter:CGPointMake(self.bounds.size.width/2+offsetX, v.center.y+offsetY)]; break;
case 2: [v setFrame:CGRectMake(v.frame.origin.x+offsetX, v.frame.origin.y+offsetY, v.bounds.size.width,v.bounds.size.height)]; break;
case 3: [v setFrame:CGRectMake(-9+offsetX,self.bounds.size.height/2-9+3-v.bounds.size.height/2+offsetY, v.bounds.size.width,v.bounds.size.height)]; break;
case 4: [v setCenter:CGPointMake(self.bounds.size.width/2+offsetX, self.bounds.size.height/2-9+3+offsetY)]; break;
case 5: [v setFrame:CGRectMake(v.frame.origin.x+offsetX,self.bounds.size.height/2-9+3-v.bounds.size.height/2+offsetY, v.bounds.size.width,v.bounds.size.height)]; break;
case 6: [v setFrame:CGRectMake(-9+offsetX, self.bounds.size.height-9+3-v.bounds.size.height+offsetY, v.bounds.size.width,v.bounds.size.height)]; break;
case 7: [v setCenter:CGPointMake(self.bounds.size.width/2+offsetX, self.bounds.size.height-9+3-v.bounds.size.height/2+offsetY)]; break;
case 8: [v setFrame:CGRectMake(v.frame.origin.x+offsetX,self.bounds.size.height-9+3-v.bounds.size.height+offsetY,v.bounds.size.width,v.bounds.size.height)]; break;
case 9: [v setCenter:CGPointMake(self.bounds.size.width/2+offsetX, self.bounds.size.height-3+offsetY)]; break;
default: break;
}
// If the icon has a badge and labels is 9 and such shit .. yadayada..
SBIconBadgeImage *im = MSHookIvar<SBIconBadgeImage *>(self, "_badgeImage");
if(im.text==@""||im.text==nil){ // no badge
[self setLabelHidden:NO];
[self updateLabel];
}
else{ // badge
if(p==9){ // replace
[self setLabelHidden:YES];
[self updateLabel];
}else{
[self setLabelHidden:NO];
[self updateLabel];
}
}
}
-(void)setLabelHidden:(BOOL)hidden{
NSDictionary *d = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.jontelang.boover.plist"];
hidden = ([[d valueForKey:@"hideLabels"] boolValue] == TRUE ? YES : hidden);
%orig;
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment