Browse Source

Add Reddit v2021 support

master
lint 3 years ago
parent
commit
c78f263125
2 changed files with 33 additions and 48 deletions
  1. +15
    -4
      tweak/Reddit.h
  2. +18
    -44
      tweak/Reddit.xm

+ 15
- 4
tweak/Reddit.h View File

#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
/* ---- Reddit v3 & v4 ---- */
/* ---- Reddit v3 & v4 & v2020 & v2021 ---- */
/* -- Comment Interfaces -- */ /* -- Comment Interfaces -- */
@end @end
/* ---- Reddit v4 ---- */
/* ---- Reddit v4+ ---- */
@interface ASDisplayNode
- (id)supernode;
@end
/* -- Comment Interfaces -- */ /* -- Comment Interfaces -- */
@interface CommentTreeNode @interface CommentTreeNode
@property(strong, nonatomic) id commentNode; @property(strong, nonatomic) id commentNode;
@end @end
@interface CommentTreeHeaderNode
@interface CommentTreeHeaderNode : ASDisplayNode
@property(strong, nonatomic) id commentTreeNode; @property(strong, nonatomic) id commentTreeNode;
- (void)updateContentViewsForData:(id)arg1; - (void)updateContentViewsForData:(id)arg1;
- (void)configureNodes; - (void)configureNodes;
@interface CommentTreeHeaderView @interface CommentTreeHeaderView
@property(strong, nonatomic) id commentTreeNode; @property(strong, nonatomic) id commentTreeNode;
- (void)updateContentViewsForData:(id)arg1; - (void)updateContentViewsForData:(id)arg1;
@end @end
@interface CommentTreeTextNode
- (void)configureTextNode;
@end
@interface CommentTreeContentNode
@property(strong, nonatomic) CommentTreeTextNode *textNode;
@end
/* -- Post Interfaces -- */ /* -- Post Interfaces -- */
@interface Post @interface Post

+ 18
- 44
tweak/Reddit.xm View File

id isNightMode; id isNightMode;
UIColor *textColor; UIColor *textColor;
if (firstVersionPart == 2020) {
if (firstVersionPart >= 2021) {
RUIThemeGuidance *themeGuidance = [%c(RUIThemeGuidance) sharedGuidance];
textColor = [[themeGuidance currentTheme] bodyTextColor];
} else if (firstVersionPart == 2020) {
if (secondVersionPart <= 40) { if (secondVersionPart <= 40) {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
} }
CommentTreeHeaderNode *headerNode = [commentTreeNode commentTreeHeaderNode]; CommentTreeHeaderNode *headerNode = [commentTreeNode commentTreeHeaderNode];
[headerNode updateContentViewsForData:comment]; [headerNode updateContentViewsForData:comment];
[headerNode configureNodes]; [headerNode configureNodes];
if (firstVersionPart >= 2021) {
CommentTreeTextNode *textNode = [[headerNode supernode] textNode];
[textNode configureTextNode];
}
[bodyMutableAttributedText release]; [bodyMutableAttributedText release];
} }
%end %end
/*
%hook Post
- (id)previewTextWithTheme:(id)arg1 {
%log;
id orig = %orig;
HBLogDebug(@"previewTextWithTheme: orig: %@", orig);
return orig;
}
- (id)previewFeedPostTextString {
%log;
id orig = %orig;
HBLogDebug(@"previewFeedPostTextString orig: %@", orig);
return orig;
}
- (id)previewPostText:(id)arg1 {
%log;
id orig = %orig;
HBLogDebug(@"previewPostText: orig: %@", orig);
return orig;
}
%end
*/
%hook PostDetailViewController %hook PostDetailViewController
%property(strong,nonatomic) id feedPostTextWithThumbnailNode; %property(strong,nonatomic) id feedPostTextWithThumbnailNode;
%orig; %orig;
} }
- (void)handleDidSelectActionSheetItem:(id)arg1 { - (void)handleDidSelectActionSheetItem:(id)arg1 {
%orig; %orig;
Post *feedPost = [titleNode post]; Post *feedPost = [titleNode post];
[feedPost setAuthor:author]; [feedPost setAuthor:author];
if (firstVersionPart == 2020) {
if (firstVersionPart >= 2021) {
RichTextDisplayNode *selfTextNode = [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] selfTextNode];
[selfTextNode setAttributedText:bodyMutableAttributedText];
[selfTextNode configureDisplayNodes];
[titleNode configureNodes];
} else if (firstVersionPart == 2020) {
if (secondVersionPart >= 42) { if (secondVersionPart >= 42) {
RichTextDisplayNode *selfTextNode = [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] selfTextNode]; RichTextDisplayNode *selfTextNode = [[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] selfTextNode];
[selfTextNode setAttributedText:bodyMutableAttributedText]; [selfTextNode setAttributedText:bodyMutableAttributedText];
[commentsViewController reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO]; [commentsViewController reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
} }
-(id) initWithFrame:(id)arg1{ -(id) initWithFrame:(id)arg1{
id orig = %orig; id orig = %orig;
id commandView = [self commandView]; id commandView = [self commandView];
return orig; return orig;
} }
%end %end
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
/*
if (firstVersionPart == 4 || firstVersionPart == 2020) {
if (secondVersionPart <= 32 && firstVersionPart != 2020) {
%init(Reddit_v4_ios10);
} else{
%init(Reddit_v4_current);
}
} else if (firstVersionPart == 3) {
%init(Reddit_v3);
}
*/
if (firstVersionPart >= 2020 || (firstVersionPart == 4 && secondVersionPart > 32)) { if (firstVersionPart >= 2020 || (firstVersionPart == 4 && secondVersionPart > 32)) {
%init(Reddit_v4_current); %init(Reddit_v4_current);
} else if (firstVersionPart == 4 && secondVersionPart <= 32) { } else if (firstVersionPart == 4 && secondVersionPart <= 32) {

Loading…
Cancel
Save