MSClassHook(CKMessageCell)
MSClassHook(CKTimestampView)
+MSClassHook(CKTranscriptCell)
MSClassHook(CKTranscriptController)
MSClassHook(CKTranscriptTableView)
MSClassHook(SBAwayView)
MSClassHook(SBBookmarkIcon)
MSClassHook(SBButtonBar)
+MSClassHook(SBCalendarApplicationIcon)
MSClassHook(SBCalendarIconContentsView)
MSClassHook(SBDockIconListView)
MSClassHook(SBIcon)
MSClassHook(SBIconBadge)
+MSClassHook(SBIconBadgeFactory)
MSClassHook(SBIconController)
MSClassHook(SBIconLabel)
MSClassHook(SBIconList)
MSClassHook(SBUIController)
MSClassHook(SBWidgetApplicationIcon)
+extern "C" void WKSetCurrentGraphicsContext(CGContextRef);
+
__attribute__((__constructor__))
static void MSFixClass() {
if ($SBIcon == nil)
(_GSFontGetUseLegacyFontMetrics == NULL ? YES : _GSFontGetUseLegacyFontMetrics())
static bool Debug_ = false;
+static bool UIDebug_ = false;
static bool Engineer_ = false;
static bool SummerBoard_ = true;
static bool SpringBoard_;
}
static NSArray *$useScale$(NSArray *files, bool use = true) {
- if (!use)
- return files;
-
if (Scale_ == 0) {
UIScreen *screen([UIScreen mainScreen]);
if ([screen respondsToSelector:@selector(scale)])
NSMutableArray *scaled([NSMutableArray arrayWithCapacity:([files count] * 2)]);
for (NSString *file in files) {
- [scaled addObject:[NSString stringWithFormat:@"%@@2x.%@", [file stringByDeletingPathExtension], [file pathExtension]]];
+ if (use && Scale_ == 2)
+ [scaled addObject:[NSString stringWithFormat:@"%@@2x.%@", [file stringByDeletingPathExtension], [file pathExtension]]];
+ if ([file hasSuffix:@"@2x~iphone.png"])
+ [scaled addObject:[[file substringWithRange:NSMakeRange(0, [file length] - 11)] stringByAppendingPathExtension:@"png"]];
[scaled addObject:file];
}
return scaled;
}
-static NSString *$getTheme$(NSArray *files) {
+static NSString *$getTheme$(NSArray *files, NSArray *themes = Themes_) {
if (NSString *path = [Themed_ objectForKey:files])
return reinterpret_cast<id>(path) == [NSNull null] ? nil : path;
}
// }}}
+static struct WBStringDrawingState {
+ WBStringDrawingState *next_;
+ NSString *base_;
+ NSString *info_;
+} *stringDrawingState_;
+
+MSInstanceMessageHook4(CGSize, NSString, drawAtPoint,forWidth,withFont,lineBreakMode, CGPoint, point, float, width, UIFont *, font, int, mode) {
+ if (stringDrawingState_ == NULL || stringDrawingState_->info_ == nil)
+ return MSOldCall(point, width, font, mode);
+
+ NSString *info([Info_ objectForKey:stringDrawingState_->info_]);
+ if (info == nil)
+ return MSOldCall(point, width, font, mode);
+
+ NSString *base(stringDrawingState_->base_ ?: @"");
+ stringDrawingState_ = stringDrawingState_->next_;
+
+ [self drawAtPoint:point withStyle:[NSString stringWithFormat:@"%@;%@;%@", [font markupDescription], base, info]];
+ return CGSizeZero;
+}
+
+MSInstanceMessageHook2(CGSize, NSString, drawAtPoint,withFont, CGPoint, point, UIFont *, font) {
+ if (stringDrawingState_ == NULL || stringDrawingState_->info_ == nil)
+ return MSOldCall(point, font);
+
+ NSString *info([Info_ objectForKey:stringDrawingState_->info_]);
+ if (info == nil)
+ return MSOldCall(point, font);
+
+ NSString *base(stringDrawingState_->base_ ?: @"");
+ stringDrawingState_ = stringDrawingState_->next_;
+
+ [self drawAtPoint:point withStyle:[NSString stringWithFormat:@"%@;%@;%@", [font markupDescription], base, info]];
+ return CGSizeZero;
+}
+
+MSInstanceMessageHook1(UIImage *, SBIconBadgeFactory, checkoutBadgeImageForText, NSString *, text) {
+ WBStringDrawingState badgeState = {NULL, @""
+ "color: white;"
+ , @"BadgeStyle"};
+
+ stringDrawingState_ = &badgeState;
+
+ UIImage *image(MSOldCall(text));
+
+ stringDrawingState_ = NULL;
+ return image;
+}
+
+MSInstanceMessageHook1(UIImage *, SBCalendarApplicationIcon, generateIconImage, int, type) {
+ WBStringDrawingState dayState = {NULL, @""
+ "color: white;"
+ // XXX: this is only correct on an iPod dock
+ "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px;"
+ , @"CalendarIconDayStyle"};
+
+ WBStringDrawingState dateState = {&dayState, @""
+ "color: #333333;"
+ , @"CalendarIconDateStyle"};
+
+ stringDrawingState_ = &dateState;
+
+ UIImage *image(MSOldCall(type));
+
+ stringDrawingState_ = NULL;
+ return image;
+}
+
MSHook(void, SBCalendarIconContentsView$drawRect$, SBCalendarIconContentsView *self, SEL sel, CGRect rect) {
NSBundle *bundle([NSBundle mainBundle]);
return nil;
NSString *paper($getTheme$(Wallpapers_));
+ if (paper != nil)
+ paper = [paper stringByDeletingLastPathComponent];
{
size_t size;
_release(WallpaperPage_);
_release(WallpaperURL_);
- if (NSString *path = paper) {
- if ([path hasSuffix:@".mp4"]) {
+ if (paper != nil) {
+ NSArray *themes([NSArray arrayWithObject:paper]);
+
+ if (NSString *path = $getTheme$([NSArray arrayWithObject:@"Wallpaper.mp4"], themes)) {
#if UseAVController
NSError *error;
[indirect addSubview:video];
}
- if ([path hasSuffix:@".png"] || [path hasSuffix:@".jpg"]) {
+ if (NSString *path = $getTheme$($useScale$([NSArray arrayWithObjects:@"Wallpaper.png", @"Wallpaper.jpg", nil]), themes)) {
if (UIImage *image = $getImage$(path)) {
WallpaperFile_ = [path retain];
WallpaperImage_ = [[UIImageView alloc] initWithImage:image];
}
}
- if ([path hasSuffix:@".html"]) {
+ if (NSString *path = $getTheme$([NSArray arrayWithObject:@"Wallpaper.html"], themes)) {
CGRect bounds = [indirect bounds];
UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
bool ellipsis(false);
- float max = 75, width;
+ float max = [self frame].size.width - 11, width;
width:
width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
[balloon setBackgroundColor:[UIColor clearColor]];
}
+MSInstanceMessageHook1(void, CKTranscriptCell, setBackgroundColor, UIColor *, color) {
+ MSOldCall([UIColor clearColor]);
+}
+
+MSInstanceMessageHook2(id, CKTranscriptCell, initWithStyle,reuseIdentifier, int, style, NSString *, reuse) {
+ if ((self = MSOldCall(style, reuse)) != nil) {
+ [self setBackgroundColor:[UIColor clearColor]];
+ [[self contentView] setBackgroundColor:[UIColor clearColor]];
+ } return self;
+}
+
MSInstanceMessageHook2(id, CKMessageCell, initWithStyle,reuseIdentifier, int, style, NSString *, reuse) {
if ((self = MSOldCall(style, reuse)) != nil) {
+ [self setBackgroundColor:[UIColor clearColor]];
[[self contentView] setBackgroundColor:[UIColor clearColor]];
} return self;
}
MSInstanceMessageHook0(void, CKTranscriptController, loadView) {
MSOldCall();
- if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]))
- if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]) {
- [image autorelease];
-
+ if (NSString *path = $getTheme$($useScale$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil])))
+ if (UIImage *image = $getImage$(path)) {
UIView *&_transcriptTable(MSHookIvar<UIView *>(self, "_transcriptTable"));
UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer"));
UIView *table;
if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true))
image = $getImage$(path);
[UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
- return image == nil ? __UIImageWithName(name) : image;
+ if (image != nil)
+ return image;
+
+ image = __UIImageWithName(name);
+
+ if (UIDebug_) {
+ NSString *path([@"/tmp/UIImages/" stringByAppendingString:name]);
+ if (![Manager_ fileExistsAtPath:path])
+ [UIImagePNGRepresentation(image) writeToFile:path atomically:YES];
+ }
+
+ return image;
}
}
// }}}
}
// }}}
-extern "C" void WKSetCurrentGraphicsContext(CGContextRef);
-
static void NSString$drawAtPoint$withStyle$(NSString *self, SEL _cmd, CGPoint point, NSString *style) {
WKSetCurrentGraphicsContext(UIGraphicsGetCurrentContext());
if (style == nil || [style length] == 0)
}
// }}}
+ if (Debug_ && [Manager_ fileExistsAtPath:@"/tmp/UIImages"])
+ UIDebug_ = true;
+
[pool release];
}