|
|
|
|
|
|
|
|
|
|
|
|
|
|
%group Slide
|
|
|
%group Slide
|
|
|
|
|
|
|
|
|
|
|
|
BOOL shouldSlideOverridePostInfo = NO;
|
|
|
|
|
|
NSString *slidePostOverrideAuthor;
|
|
|
|
|
|
NSString *slidePostOverrideBodyHtml;
|
|
|
|
|
|
|
|
|
@implementation FontGenerator
|
|
|
@implementation FontGenerator
|
|
|
|
|
|
|
|
|
+(UIFont *) fontOfSize:(CGFloat) size submission:(BOOL) isSubmission willOffset:(BOOL) willOffset{
|
|
|
+(UIFont *) fontOfSize:(CGFloat) size submission:(BOOL) isSubmission willOffset:(BOOL) willOffset{
|
|
|
|
|
|
|
|
|
@end
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static UIButton * createUndeleteButton(){
|
|
|
|
|
|
|
|
|
static UIButton *createUndeleteButton(){
|
|
|
|
|
|
|
|
|
UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
UIButton *undeleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
UIImage *undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160white.png"];
|
|
|
UIImage *undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160white.png"];
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//because it wont compile without this
|
|
|
|
|
|
%hook RComment
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%hook UIColor
|
|
|
%hook UIColor
|
|
|
|
|
|
|
|
|
%new
|
|
|
%new
|
|
|
|
|
|
|
|
|
//Attributed string generation rewrote from Slide_for_Reddit.TextDisplayStackView.createAttributedChunk(...)
|
|
|
//Attributed string generation rewrote from Slide_for_Reddit.TextDisplayStackView.createAttributedChunk(...)
|
|
|
|
|
|
|
|
|
UIFont *font = [%c(FontGenerator) fontOfSize:MSHookIvar<CGFloat>(textStackDisplayView, "fontSize") submission:NO willOffset:YES];
|
|
|
UIFont *font = [%c(FontGenerator) fontOfSize:MSHookIvar<CGFloat>(textStackDisplayView, "fontSize") submission:NO willOffset:YES];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSString *themeName = [userDefaults stringForKey:@"theme"];
|
|
|
NSString *themeName = [userDefaults stringForKey:@"theme"];
|
|
|
UIColor *fontColor = [%c(ColorUtil) fontColorForTheme:themeName];
|
|
|
UIColor *fontColor = [%c(ColorUtil) fontColorForTheme:themeName];
|
|
|
UIColor *accentColor = [%c(ColorUtil) accentColorForSub:[comment subreddit]];
|
|
|
UIColor *accentColor = [%c(ColorUtil) accentColorForSub:[comment subreddit]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%hook RSubmission
|
|
|
|
|
|
|
|
|
|
|
|
-(id) author{
|
|
|
|
|
|
if (shouldSlideOverridePostInfo){
|
|
|
|
|
|
return slidePostOverrideAuthor;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return %orig;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(id) htmlBody{
|
|
|
|
|
|
if (shouldSlideOverridePostInfo){
|
|
|
|
|
|
return slidePostOverrideBodyHtml;
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
return %orig;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%hook CommentViewController
|
|
|
|
|
|
%property(strong, nonatomic) UIButton *undeleteButton;
|
|
|
|
|
|
|
|
|
|
|
|
-(void) viewDidLoad {
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
shouldSlideOverridePostInfo = NO;
|
|
|
|
|
|
slidePostOverrideAuthor = nil;
|
|
|
|
|
|
slidePostOverrideBodyHtml = nil;
|
|
|
|
|
|
|
|
|
|
|
|
UIButton *undeleteButton = createUndeleteButton();
|
|
|
|
|
|
[undeleteButton setImage:[[undeleteButton currentImage] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
|
|
|
|
|
[undeleteButton addTarget:self action:@selector(handleUndeletePost:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
[self setUndeleteButton:undeleteButton];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void) viewDidLayoutSubviews{
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
if ([self undeleteButton]){
|
|
|
|
|
|
if ([self shouldAddUndeleteButtonToToolbar]){
|
|
|
|
|
|
[self addUndeleteButtonToToolbar];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void) loadAll:(id) arg1{
|
|
|
|
|
|
%orig;
|
|
|
|
|
|
|
|
|
|
|
|
if ([self undeleteButton]){
|
|
|
|
|
|
if ([self shouldAddUndeleteButtonToToolbar]){
|
|
|
|
|
|
[self addUndeleteButtonToToolbar];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%new
|
|
|
|
|
|
-(BOOL) shouldAddUndeleteButtonToToolbar{
|
|
|
|
|
|
id post = MSHookIvar<id>(self, "submission");
|
|
|
|
|
|
|
|
|
|
|
|
if ([post isSelf]){
|
|
|
|
|
|
|
|
|
|
|
|
NSString *postBody = [post body];
|
|
|
|
|
|
|
|
|
|
|
|
if ((isTFDeletedOnly && ([postBody isEqualToString:@"[deleted]"] || [postBody isEqualToString:@"[removed]"])) || !isTFDeletedOnly){
|
|
|
|
|
|
return YES;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%new
|
|
|
|
|
|
-(void) addUndeleteButtonToToolbar{
|
|
|
|
|
|
UIToolbar *toolbar = [[self navigationController] toolbar];
|
|
|
|
|
|
NSMutableArray *toolbarItems = [[toolbar items] mutableCopy];
|
|
|
|
|
|
UIView *firstView = [toolbarItems[0] customView];
|
|
|
|
|
|
|
|
|
|
|
|
if (firstView){
|
|
|
|
|
|
UIColor *tintColor = [toolbar tintColor];
|
|
|
|
|
|
|
|
|
|
|
|
UIButton *undeleteButton = [self undeleteButton];
|
|
|
|
|
|
[undeleteButton setTintColor:tintColor];
|
|
|
|
|
|
|
|
|
|
|
|
if ([firstView isMemberOfClass:[UIView class]]){
|
|
|
|
|
|
if (![undeleteButton isDescendantOfView:firstView]){
|
|
|
|
|
|
[firstView addSubview:undeleteButton];
|
|
|
|
|
|
[undeleteButton setFrame:firstView.bounds];
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if ([firstView isMemberOfClass:[UIButton class]] && undeleteButton != firstView){
|
|
|
|
|
|
UIBarButtonItem *undeleteItem = [[UIBarButtonItem alloc] initWithCustomView:undeleteButton];
|
|
|
|
|
|
|
|
|
|
|
|
[toolbarItems insertObject:toolbarItems[1] atIndex:0];
|
|
|
|
|
|
[toolbarItems insertObject:undeleteItem atIndex:0];
|
|
|
|
|
|
[toolbar setItems:toolbarItems animated:NO];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%new
|
|
|
|
|
|
-(void) handleUndeletePost:(id) sender{
|
|
|
|
|
|
shouldSlideOverridePostInfo = YES;
|
|
|
|
|
|
|
|
|
|
|
|
[sender setEnabled:NO];
|
|
|
|
|
|
|
|
|
|
|
|
[%c(TFHelper) getUndeleteDataWithID:[MSHookIvar<id>(self, "submission") name] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:@{@"sender" : sender} completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%new
|
|
|
|
|
|
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
|
|
|
|
|
|
|
|
|
|
|
slidePostOverrideAuthor = data[@"author"];
|
|
|
|
|
|
slidePostOverrideBodyHtml = [%c(MMMarkdown) HTMLStringWithMarkdown:data[@"body"] extensions:MMMarkdownExtensionsGitHubFlavored error:nil];
|
|
|
|
|
|
|
|
|
|
|
|
[self refresh:nil];
|
|
|
|
|
|
|
|
|
|
|
|
[data[@"sender"] setEnabled:YES];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%end
|
|
|
|
|
|
|
|
|
%end
|
|
|
%end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
|
|
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
|
|
|
|
|
|
|
|
%init(Slide, CommentDepthCell = objc_getClass("Slide_for_Reddit.CommentDepthCell"), RComment = objc_getClass("Slide_for_Reddit.RSubmission"));
|
|
|
|
|
|
|
|
|
%init(Slide, CommentDepthCell = objc_getClass("Slide_for_Reddit.CommentDepthCell"), RSubmission = objc_getClass("Slide_for_Reddit.RSubmission"), CommentViewController = objc_getClass("Slide_for_Reddit.CommentViewController"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|