mirror of
https://github.com/lint/TFDidThatSay
synced 2025-07-01 23:46:47 +00:00
Style and prefs loading improvements
This commit is contained in:
@ -29,7 +29,7 @@
|
||||
@end
|
||||
|
||||
@interface CommentsViewController
|
||||
-(void) respondToStyleChange;
|
||||
- (void)respondToStyleChange;
|
||||
@end
|
||||
|
||||
@interface CommentPostHeaderNode
|
||||
@ -47,15 +47,15 @@
|
||||
@property(assign, nonatomic) BOOL isPostHeader;
|
||||
@property(strong, nonatomic) id delegate;
|
||||
@property(strong, nonatomic) id node;
|
||||
-(void) addButton:(id) arg1;
|
||||
- (void)addButton:(id)arg1;
|
||||
@end
|
||||
|
||||
/* -- Other Interfaces -- */
|
||||
|
||||
@interface MarkupEngine
|
||||
+(id) markDownHTML:(id) arg1 forSubreddit:(id) arg2;
|
||||
+ (id)markDownHTML:(id)arg1 forSubreddit:(id)arg2;
|
||||
@end
|
||||
|
||||
@interface Resources
|
||||
+(BOOL) isNight;
|
||||
+ (BOOL)isNight;
|
||||
@end
|
||||
|
@ -3,6 +3,7 @@
|
||||
#import "assets/TFHelper.h"
|
||||
#import "assets/MMMarkdown/MMMarkdown.h"
|
||||
|
||||
static BOOL isEnabled;
|
||||
static BOOL isAlienBlueEnabled;
|
||||
static BOOL isTFDeletedOnly;
|
||||
static CGFloat pushshiftRequestTimeoutValue;
|
||||
@ -11,7 +12,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
|
||||
%hook CommentOptionsDrawerView
|
||||
|
||||
-(id) initWithNode:(id) arg1 {
|
||||
- (id)initWithNode:(id)arg1 {
|
||||
id orig = %orig;
|
||||
|
||||
NSString *body;
|
||||
@ -51,7 +52,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) didTapCommentUndeleteButton:(id) sender {
|
||||
- (void)didTapCommentUndeleteButton:(id)sender {
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
@ -61,7 +62,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
id comment = [[self node] comment];
|
||||
|
||||
@ -79,7 +80,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) didTapPostUndeleteButton:(id) sender {
|
||||
- (void)didTapPostUndeleteButton:(id)sender {
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
@ -89,7 +90,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
|
||||
id post = [[self node] post];
|
||||
id postComment = [[self node] comment]; //Don't know why he used a comment to store info about a post, but it exists
|
||||
@ -116,26 +117,12 @@ static void loadPrefs(){
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
if (prefs){
|
||||
|
||||
if ([prefs objectForKey:@"isAlienBlueEnabled"] != nil){
|
||||
isAlienBlueEnabled = [[prefs objectForKey:@"isAlienBlueEnabled"] boolValue];
|
||||
} else {
|
||||
isAlienBlueEnabled = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil){
|
||||
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
|
||||
} else {
|
||||
isTFDeletedOnly = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
|
||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
|
||||
} else {
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
}
|
||||
|
||||
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
|
||||
isAlienBlueEnabled = [prefs objectForKey:@"isAlienBlueEnabled"] ? [[prefs objectForKey:@"isAlienBlueEnabled"] boolValue] : YES;
|
||||
isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
|
||||
pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
|
||||
} else {
|
||||
isEnabled = YES;
|
||||
isAlienBlueEnabled = YES;
|
||||
isTFDeletedOnly = YES;
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
@ -153,9 +140,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
if ([processName isEqualToString:@"AlienBlue"]){
|
||||
if (isAlienBlueEnabled){
|
||||
if (isAlienBlueEnabled && isEnabled){
|
||||
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
%init(AlienBlue);
|
||||
}
|
||||
|
@ -18,24 +18,24 @@
|
||||
|
||||
@interface RCCommentCell : NSObject
|
||||
@property(strong, nonatomic) id comment;
|
||||
-(void) updateWithModelObject:(id) arg1;
|
||||
- (void)updateWithModelObject:(id)arg1;
|
||||
@end
|
||||
|
||||
@interface RCPostCommentsController
|
||||
@property(strong, nonatomic) id postCommentsCollector;
|
||||
@property(strong, nonatomic) id delegate;
|
||||
@property(strong, nonatomic) NSMutableDictionary *commentHeightCache;
|
||||
-(void) controllerWillChangeContent:(id) arg1;
|
||||
-(void) controllerDidChangeContent:(id) arg1;
|
||||
-(void) controller:(id) arg1 didChange:(id) arg2 at:(id) arg3 for:(long long) arg4 newIndexPath:(id) arg5;
|
||||
- (void)controllerWillChangeContent:(id)arg1;
|
||||
- (void)controllerDidChangeContent:(id)arg1;
|
||||
- (void)controller:(id)arg1 didChange:(id)arg2 at:(id)arg3 for:(long long)arg4 newIndexPath:(id)arg5;
|
||||
|
||||
//custom elements
|
||||
-(void)handleUndeleteCommentAction;
|
||||
- (void)handleUndeleteCommentAction;
|
||||
@end
|
||||
|
||||
@interface AHKActionSheet
|
||||
@property(strong, nonatomic) NSMutableArray *items;
|
||||
-(void) addButtonWithTitle:(id) arg1 image:(id) arg2 type:(long long) arg3 handler:(id) arg4;
|
||||
- (void)addButtonWithTitle:(id)arg1 image:(id)arg2 type:(long long)arg3 handler:(id)arg4;
|
||||
@end
|
||||
|
||||
@interface AHKActionSheetItem
|
||||
@ -49,7 +49,7 @@
|
||||
@property(strong, nonatomic) NSNumber *isSelf;
|
||||
@property(strong, nonatomic) NSString *itemId;
|
||||
@property(strong, nonatomic) id selfCommentText;
|
||||
-(BOOL) isSelfPost;
|
||||
- (BOOL)isSelfPost;
|
||||
@end
|
||||
|
||||
@interface RCPostActionsSectionHeader : UIView
|
||||
@ -73,8 +73,8 @@
|
||||
@interface RCPostHeaderCellController : NSObject
|
||||
@property(strong, nonatomic) id post;
|
||||
@property(strong, nonatomic) UITableView *tableView;
|
||||
-(void) loadView;
|
||||
- (void)loadView;
|
||||
|
||||
//custom elements
|
||||
-(void) handleUndeletePostAction:(id) arg1;
|
||||
- (void)handleUndeletePostAction:(id)arg1;
|
||||
@end
|
||||
|
@ -3,6 +3,7 @@
|
||||
#import "assets/TFHelper.h"
|
||||
#import "assets/MMMarkdown/MMMarkdown.h"
|
||||
|
||||
static BOOL isEnabled;
|
||||
static BOOL isAntennaEnabled;
|
||||
static BOOL isTFDeletedOnly;
|
||||
static CGFloat pushshiftRequestTimeoutValue;
|
||||
@ -22,7 +23,7 @@ id tfAntennaCommentCell;
|
||||
|
||||
%hook RCCommentSwift
|
||||
|
||||
-(BOOL) isCommentDeleted{
|
||||
- (BOOL)isCommentDeleted{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@ -31,7 +32,7 @@ id tfAntennaCommentCell;
|
||||
|
||||
%hook RCPostCommentsController
|
||||
|
||||
-(void) didLongPressCell:(id) arg1 gesture:(id) arg2 {
|
||||
- (void)didLongPressCell:(id)arg1 gesture:(id)arg2 {
|
||||
|
||||
NSString *commentBody = [[[arg1 comment] commentText] body];
|
||||
|
||||
@ -47,13 +48,13 @@ id tfAntennaCommentCell;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeleteCommentAction{
|
||||
- (void)handleUndeleteCommentAction{
|
||||
|
||||
[%c(TFHelper) getUndeleteDataWithID:[[tfAntennaCommentCell comment] itemId] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
id comment = [tfAntennaCommentCell comment];
|
||||
id commentText = [comment commentText];
|
||||
@ -78,9 +79,9 @@ id tfAntennaCommentCell;
|
||||
|
||||
%hook AHKActionSheet
|
||||
|
||||
-(void)show{
|
||||
- (void)show {
|
||||
|
||||
if (shouldHaveAntennaUndeleteAction){
|
||||
if (shouldHaveAntennaUndeleteAction) {
|
||||
|
||||
UIImage *undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
|
||||
@ -107,7 +108,7 @@ id tfAntennaCommentCell;
|
||||
%hook RCPostActionsSectionHeader
|
||||
%property(strong, nonatomic) UIButton *undeleteButton;
|
||||
|
||||
-(void) layoutSubviews{
|
||||
- (void)layoutSubviews {
|
||||
|
||||
BOOL isAbleToUndeletePost = NO;
|
||||
|
||||
@ -155,7 +156,7 @@ id tfAntennaCommentCell;
|
||||
%hook RCPostHeaderCellController
|
||||
|
||||
%new
|
||||
-(void) handleUndeletePostAction:(id) sender{
|
||||
- (void)handleUndeletePostAction:(id)sender {
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
@ -163,7 +164,7 @@ id tfAntennaCommentCell;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
|
||||
id post = [self post];
|
||||
id postText = [post selfCommentText];
|
||||
@ -193,26 +194,12 @@ static void loadPrefs(){
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
if (prefs){
|
||||
|
||||
if ([prefs objectForKey:@"isAntennaEnabled"] != nil){
|
||||
isAntennaEnabled = [[prefs objectForKey:@"isAntennaEnabled"] boolValue];
|
||||
} else {
|
||||
isAntennaEnabled = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil){
|
||||
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
|
||||
} else {
|
||||
isTFDeletedOnly = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
|
||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
|
||||
} else {
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
}
|
||||
|
||||
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
|
||||
isAntennaEnabled = [prefs objectForKey:@"isAntennaEnabled"] ? [[prefs objectForKey:@"isAntennaEnabled"] boolValue] : YES;
|
||||
isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
|
||||
pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
|
||||
} else {
|
||||
isEnabled = YES;
|
||||
isAntennaEnabled = YES;
|
||||
isTFDeletedOnly = YES;
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
@ -230,9 +217,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
if ([processName isEqualToString:@"amrc"]){
|
||||
if (isAntennaEnabled){
|
||||
if (isAntennaEnabled && isEnabled){
|
||||
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
%init(Antenna, RCCommentSwift = objc_getClass("amrc.RCCommentSwift"), RCPostSwift = objc_getClass("amrc.RCPostSwift"), RCCommentTextSwift = objc_getClass("amrc.RCCommentTextSwift"));
|
||||
}
|
||||
|
@ -17,14 +17,14 @@
|
||||
|
||||
@interface CommentCellNode
|
||||
@property(assign,nonatomic)id view;
|
||||
-(BOOL) isSelected;
|
||||
-(void) _layoutSublayouts;
|
||||
-(void) didLoad;
|
||||
-(void) calculatedLayoutDidChange;
|
||||
- (BOOL)isSelected;
|
||||
- (void)_layoutSublayouts;
|
||||
- (void)didLoad;
|
||||
- (void)calculatedLayoutDidChange;
|
||||
|
||||
//custom elements
|
||||
@property(strong,nonatomic) UIButton *undeleteButton;
|
||||
-(void) undeleteCellWasSelected;
|
||||
- (void)undeleteCellWasSelected;
|
||||
@end
|
||||
|
||||
/* -- Post Interfaces -- */
|
||||
@ -33,7 +33,7 @@
|
||||
@property(assign,nonatomic) NSString *selfText;
|
||||
@property(assign,nonatomic) NSString *author;
|
||||
@property(assign,nonatomic) NSString *fullName;
|
||||
-(BOOL) isSelfPost;
|
||||
- (BOOL)isSelfPost;
|
||||
|
||||
//custom elements
|
||||
@property(strong, nonatomic) NSString *undeleteAuthor;
|
||||
@ -43,7 +43,7 @@
|
||||
@property(assign,nonatomic) NSString *selfText;
|
||||
@property(assign,nonatomic) NSString *author;
|
||||
@property(assign,nonatomic) NSString *fullName;
|
||||
-(BOOL) isSelfPost;
|
||||
- (BOOL)isSelfPost;
|
||||
|
||||
//custom elements
|
||||
@property(strong, nonatomic) NSString *undeleteAuthor;
|
||||
@ -58,18 +58,18 @@
|
||||
|
||||
//custom elements
|
||||
@property(strong, nonatomic) id headerCellNode;
|
||||
-(void) undeleteCellWasSelected;
|
||||
- (void)undeleteCellWasSelected;
|
||||
@end
|
||||
|
||||
/* -- Other Interfaces -- */
|
||||
|
||||
@interface MarkdownRenderer
|
||||
+(id) attributedStringFromMarkdown:(id) arg1 withAttributes:(id) arg2;
|
||||
+ (id)attributedStringFromMarkdown:(id)arg1 withAttributes:(id)arg2;
|
||||
@end
|
||||
|
||||
@interface ActionController
|
||||
-(id) tableView:(id) arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2;
|
||||
-(NSInteger) tableView:(id) arg1 numberOfRowsInSection:(NSInteger) arg2;
|
||||
- (id)tableView:(id)arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2;
|
||||
- (NSInteger)tableView:(id)arg1 numberOfRowsInSection:(NSInteger)arg2;
|
||||
@end
|
||||
|
||||
@interface UIImage (ios13)
|
||||
@ -88,7 +88,7 @@
|
||||
@property(assign,nonatomic)id image;
|
||||
@property(assign,nonatomic) CGRect frame;
|
||||
@property(assign,nonatomic) id view;
|
||||
-(CGRect)_frameInWindow;
|
||||
- (CGRect)_frameInWindow;
|
||||
@end
|
||||
|
||||
@interface ASTextNode
|
||||
@ -99,6 +99,6 @@
|
||||
|
||||
@interface ApolloButtonNode
|
||||
@property(assign,nonatomic) ASTextNode *titleNode;
|
||||
-(void) setAttributedTitle:(id) arg1 forState:(NSInteger) arg2;
|
||||
-(id) attributedTitleForState:(NSInteger) arg1;
|
||||
- (void) setAttributedTitle:(id)arg1 forState:(NSInteger)arg2;
|
||||
- (id) attributedTitleForState:(NSInteger)arg1;
|
||||
@end
|
||||
|
@ -2,8 +2,9 @@
|
||||
#import "Apollo.h"
|
||||
#import "assets/TFHelper.h"
|
||||
|
||||
static BOOL isTFDeletedOnly;
|
||||
static BOOL isEnabled;
|
||||
static BOOL isApolloEnabled;
|
||||
static BOOL isTFDeletedOnly;
|
||||
static CGFloat pushshiftRequestTimeoutValue;
|
||||
static BOOL shouldApolloHaveButton;
|
||||
|
||||
@ -69,7 +70,7 @@ id apolloCommentController;
|
||||
|
||||
%hook MarkdownRenderer
|
||||
|
||||
+(id) attributedStringFromHTML:(id)arg1 attributes:(id) arg2 compact:(BOOL) arg3{
|
||||
+ (id)attributedStringFromHTML:(id)arg1 attributes:(id)arg2 compact:(BOOL)arg3 {
|
||||
|
||||
apolloBodyAttributes = [arg2 copy];
|
||||
|
||||
@ -81,9 +82,9 @@ id apolloCommentController;
|
||||
|
||||
%hook ActionController
|
||||
|
||||
-(id) tableView:(id) arg1 cellForRowAtIndexPath:(NSIndexPath *) arg2{
|
||||
- (id) tableView:(id)arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2 {
|
||||
|
||||
if (shouldAddUndeleteCell){
|
||||
if (shouldAddUndeleteCell) {
|
||||
if ([arg2 row] == [self tableView:arg1 numberOfRowsInSection:0] - 1){
|
||||
|
||||
id undeleteCell = [arg1 dequeueReusableCellWithIdentifier:@"IconActionCell" forIndexPath:arg2];
|
||||
@ -94,12 +95,20 @@ id apolloCommentController;
|
||||
|
||||
UIImage *undeleteImage;
|
||||
|
||||
if (@available(iOS 13.0, *)){
|
||||
//if (@available(iOS 13.0, *)){
|
||||
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0")) {
|
||||
|
||||
undeleteImage = [UIImage systemImageNamed:@"eye"];
|
||||
|
||||
if (!undeleteImage){
|
||||
undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
} else {
|
||||
CGSize squareSize = CGSizeMake(undeleteImage.size.width, undeleteImage.size.width);
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(squareSize, NO, 0);
|
||||
[undeleteImage drawInRect:CGRectMake(0, (squareSize.height - undeleteImage.size.height) / 2, squareSize.width, undeleteImage.size.height)];
|
||||
undeleteImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
}
|
||||
} else {
|
||||
undeleteImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
@ -107,7 +116,7 @@ id apolloCommentController;
|
||||
|
||||
CGFloat undeleteImageSizeValue = prevImageSize.width > prevImageSize.height ? prevImageSize.width : prevImageSize.height;
|
||||
|
||||
if (undeleteImageSizeValue == 0){
|
||||
if (undeleteImageSizeValue == 0) {
|
||||
undeleteImageSizeValue = 25;
|
||||
}
|
||||
|
||||
@ -129,12 +138,12 @@ id apolloCommentController;
|
||||
return %orig;
|
||||
}
|
||||
|
||||
-(void) tableView:(id) arg1 didSelectRowAtIndexPath:(NSIndexPath *)arg2{
|
||||
- (void)tableView:(id)arg1 didSelectRowAtIndexPath:(NSIndexPath *)arg2 {
|
||||
|
||||
if (shouldAddUndeleteCell){
|
||||
if (shouldAddUndeleteCell) {
|
||||
if ([arg2 row] == [self tableView:arg1 numberOfRowsInSection:0] - 1){
|
||||
|
||||
if (apolloCommentCell){
|
||||
if (apolloCommentCell) {
|
||||
[apolloCommentCell undeleteCellWasSelected];
|
||||
} else {
|
||||
[apolloCommentController undeleteCellWasSelected];
|
||||
@ -145,7 +154,7 @@ id apolloCommentController;
|
||||
%orig;
|
||||
}
|
||||
|
||||
-(NSInteger) tableView:(id) arg1 numberOfRowsInSection:(NSInteger) arg2{
|
||||
- (NSInteger) tableView:(id)arg1 numberOfRowsInSection:(NSInteger)arg2 {
|
||||
|
||||
if (shouldAddUndeleteCell){
|
||||
return %orig + 1;
|
||||
@ -154,7 +163,7 @@ id apolloCommentController;
|
||||
}
|
||||
}
|
||||
|
||||
-(id) animationControllerForDismissedController:(id) arg1{
|
||||
- (id) animationControllerForDismissedController:(id)arg1 {
|
||||
|
||||
shouldAddUndeleteCell = NO;
|
||||
|
||||
@ -167,7 +176,7 @@ id apolloCommentController;
|
||||
%hook CommentCellNode
|
||||
%property(strong,nonatomic) UIButton *undeleteButton;
|
||||
|
||||
-(void) moreOptionsTappedWithSender:(id) arg1{
|
||||
- (void)moreOptionsTappedWithSender:(id)arg1 {
|
||||
|
||||
if (!shouldApolloHaveButton){
|
||||
|
||||
@ -183,7 +192,7 @@ id apolloCommentController;
|
||||
%orig;
|
||||
}
|
||||
|
||||
-(void) longPressedWithGestureRecognizer:(id) arg1{
|
||||
- (void)longPressedWithGestureRecognizer:(id)arg1 {
|
||||
|
||||
if (!shouldApolloHaveButton){
|
||||
|
||||
@ -199,7 +208,7 @@ id apolloCommentController;
|
||||
%orig;
|
||||
}
|
||||
|
||||
-(void) didLoad {
|
||||
- (void)didLoad {
|
||||
%orig;
|
||||
|
||||
if (shouldApolloHaveButton){
|
||||
@ -223,7 +232,7 @@ id apolloCommentController;
|
||||
}
|
||||
}
|
||||
|
||||
-(void) _layoutSublayouts{
|
||||
- (void)_layoutSublayouts {
|
||||
%orig;
|
||||
|
||||
if (shouldApolloHaveButton){
|
||||
@ -244,7 +253,7 @@ id apolloCommentController;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) didTapUndeleteButton:(id) sender{
|
||||
- (void)didTapUndeleteButton:(id)sender {
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
@ -254,7 +263,7 @@ id apolloCommentController;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) undeleteCellWasSelected{
|
||||
- (void)undeleteCellWasSelected {
|
||||
|
||||
RKComment *comment = MSHookIvar<RKComment *>(self, "comment");
|
||||
|
||||
@ -262,7 +271,7 @@ id apolloCommentController;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
RKComment *comment = MSHookIvar<RKComment *>(self, "comment");
|
||||
id bodyNode = MSHookIvar<id>(self, "bodyNode");
|
||||
@ -292,7 +301,7 @@ id apolloCommentController;
|
||||
%hook CommentsViewController
|
||||
%property(strong, nonatomic) id headerCellNode;
|
||||
|
||||
-(void) moreOptionsBarButtonItemTappedWithSender:(id) arg1{
|
||||
- (void)moreOptionsBarButtonItemTappedWithSender:(id)arg1 {
|
||||
|
||||
RKLink *post = MSHookIvar<RKLink *>(self, "link");
|
||||
NSString *postBody = [post selfText];
|
||||
@ -309,7 +318,7 @@ id apolloCommentController;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) undeleteCellWasSelected{
|
||||
- (void)undeleteCellWasSelected {
|
||||
|
||||
RKLink *post = MSHookIvar<RKLink *>(self, "link");
|
||||
|
||||
@ -317,7 +326,7 @@ id apolloCommentController;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
|
||||
RKLink *post = MSHookIvar<RKLink *>(self, "link");
|
||||
|
||||
@ -346,24 +355,24 @@ id apolloCommentController;
|
||||
|
||||
%hook CommentsHeaderCellNode
|
||||
|
||||
-(void) didLoad{
|
||||
- (void)didLoad {
|
||||
%orig;
|
||||
|
||||
[[self closestViewController] setHeaderCellNode:self];
|
||||
}
|
||||
|
||||
-(void) _layoutSublayouts{
|
||||
- (void)_layoutSublayouts {
|
||||
%orig;
|
||||
|
||||
[[self closestViewController] setHeaderCellNode:self];
|
||||
}
|
||||
|
||||
-(void) longPressedWithGestureRecognizer:(id) arg1{
|
||||
- (void)longPressedWithGestureRecognizer:(id)arg1 {
|
||||
|
||||
RKLink *post = MSHookIvar<RKLink *>(self, "link");
|
||||
NSString *postBody = [post selfText];
|
||||
|
||||
if ([post isSelfPost]){
|
||||
if ([post isSelfPost]) {
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
|
||||
shouldAddUndeleteCell = YES;
|
||||
apolloCommentCell = nil;
|
||||
@ -383,32 +392,13 @@ static void loadPrefs(){
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
if (prefs){
|
||||
|
||||
if ([prefs objectForKey:@"isApolloEnabled"] != nil) {
|
||||
isApolloEnabled = [[prefs objectForKey:@"isApolloEnabled"] boolValue];
|
||||
} else {
|
||||
isApolloEnabled = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
|
||||
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
|
||||
} else {
|
||||
isTFDeletedOnly = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
|
||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
|
||||
} else {
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"shouldApolloHaveButton"] != nil){
|
||||
shouldApolloHaveButton = [[prefs objectForKey:@"shouldApolloHaveButton"] boolValue];
|
||||
} else {
|
||||
shouldApolloHaveButton = NO;
|
||||
}
|
||||
|
||||
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
|
||||
isApolloEnabled = [prefs objectForKey:@"isApolloEnabled"] ? [[prefs objectForKey:@"isApolloEnabled"] boolValue] : YES;
|
||||
isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
|
||||
pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
|
||||
shouldApolloHaveButton = [prefs objectForKey:@"shouldApolloHaveButton"] ? [[prefs objectForKey:@"shouldApolloHaveButton"] boolValue] : NO;
|
||||
} else {
|
||||
isEnabled = YES;
|
||||
isApolloEnabled = YES;
|
||||
isTFDeletedOnly = YES;
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
@ -427,9 +417,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
if ([processName isEqualToString:@"Apollo"]){
|
||||
if (isApolloEnabled){
|
||||
if (isApolloEnabled && isEnabled){
|
||||
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
%init(Apollo, CommentsHeaderCellNode = objc_getClass("Apollo.CommentsHeaderCellNode"), CommentCellNode = objc_getClass("Apollo.CommentCellNode"), ApolloButtonNode = objc_getClass("Apollo.ApolloButtonNode"), ActionController = objc_getClass("Apollo.ActionController"), IconActionTableViewCell = objc_getClass("Apollo.IconActionTableViewCell"), CommentsViewController = objc_getClass("Apollo.CommentsViewController"));
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
@interface StoryDetailView
|
||||
@property(strong, nonatomic) UITableView *tableView;
|
||||
-(void) refreshTouched;
|
||||
- (void)refreshTouched;
|
||||
@end
|
||||
|
||||
@interface StoryDetailViewController
|
||||
@ -47,13 +47,13 @@
|
||||
@property(strong, nonatomic) id detailPage;
|
||||
|
||||
//custom elements
|
||||
-(void) handleUndeleteCommentAction;
|
||||
-(void) handleUndeletePostAction;
|
||||
- (void)handleUndeleteCommentAction;
|
||||
- (void)handleUndeletePostAction;
|
||||
@end
|
||||
|
||||
/* -- Other Interfaces -- */
|
||||
|
||||
@interface BRUtils
|
||||
+(id) attributedDescriptionForComment:(id) arg1;
|
||||
+(id) createAttributedStringFromHTML:(id) arg1 options:(id) arg2;
|
||||
+ (id)attributedDescriptionForComment:(id)arg1;
|
||||
+ (id)createAttributedStringFromHTML:(id)arg1 options:(id)arg2;
|
||||
@end
|
||||
|
@ -3,6 +3,7 @@
|
||||
#import "assets/TFHelper.h"
|
||||
#import "assets/MMMarkdown/MMMarkdown.h"
|
||||
|
||||
static BOOL isEnabled;
|
||||
static BOOL isBaconReaderEnabled;
|
||||
static BOOL isTFDeletedOnly;
|
||||
static CGFloat pushshiftRequestTimeoutValue;
|
||||
@ -28,19 +29,19 @@ id tfStoryController;
|
||||
|
||||
%hook BRComment
|
||||
|
||||
-(BOOL) contains_htmlValue{
|
||||
- (BOOL)contains_htmlValue {
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL) primitiveContains_htmlValue{
|
||||
- (BOOL)primitiveContains_htmlValue {
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL) is_deletedValue{
|
||||
- (BOOL)is_deletedValue {
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(BOOL) primitiveIs_deletedValue{
|
||||
- (BOOL)primitiveIs_deletedValue {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@ -49,10 +50,10 @@ id tfStoryController;
|
||||
|
||||
%hook BRStory
|
||||
|
||||
+(id) storyWithDictionary:(id) arg1 inContext:(id) arg2 {
|
||||
+ (id)storyWithDictionary:(id)arg1 inContext:(id)arg2 {
|
||||
id orig = %orig;
|
||||
|
||||
if (tfPostSelftext){
|
||||
if (tfPostSelftext) {
|
||||
[orig setSelftext_html:tfPostSelftext];
|
||||
[orig setAuthor:tfPostAuthor];
|
||||
tfPostSelftext = nil;
|
||||
@ -67,13 +68,13 @@ id tfStoryController;
|
||||
|
||||
%hook UIViewController
|
||||
|
||||
-(void) presentViewController:(id) arg1 animated:(BOOL) arg2 completion:(id) arg3 {
|
||||
- (void)presentViewController:(id)arg1 animated:(BOOL)arg2 completion:(id)arg3 {
|
||||
|
||||
if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveBRUndeleteAction){
|
||||
if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveBRUndeleteAction) {
|
||||
|
||||
UIAlertAction *undeleteAction;
|
||||
|
||||
if (tfCommentCellView){
|
||||
if (tfCommentCellView) {
|
||||
undeleteAction = [UIAlertAction actionWithTitle:@"TF Did That Say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfStoryController handleUndeleteCommentAction];}];
|
||||
} else {
|
||||
undeleteAction = [UIAlertAction actionWithTitle:@"TF Did That Say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfStoryController handleUndeletePostAction];}];
|
||||
@ -90,11 +91,11 @@ id tfStoryController;
|
||||
|
||||
%hook StoryDetailViewController
|
||||
|
||||
-(void) showMoreCommentActions:(id) arg1 showAll:(BOOL) arg2 {
|
||||
- (void)showMoreCommentActions:(id)arg1 showAll:(BOOL)arg2 {
|
||||
|
||||
NSString *commentBody = [[arg1 comment] body];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
shouldHaveBRUndeleteAction = YES;
|
||||
tfCommentCellView = arg1;
|
||||
tfStoryController = self;
|
||||
@ -106,12 +107,12 @@ id tfStoryController;
|
||||
shouldHaveBRUndeleteAction = NO;
|
||||
}
|
||||
|
||||
-(void) menuTouchedWithSender:(id) arg1 {
|
||||
- (void)menuTouchedWithSender:(id)arg1 {
|
||||
|
||||
if ([[self story] is_selfValue]){
|
||||
if ([[self story] is_selfValue]) {
|
||||
NSString *postBody = [[self story] selftext];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
shouldHaveBRUndeleteAction = YES;
|
||||
tfCommentCellView = nil;
|
||||
tfStoryController = self;
|
||||
@ -125,13 +126,13 @@ id tfStoryController;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeleteCommentAction{
|
||||
- (void)handleUndeleteCommentAction {
|
||||
|
||||
[%c(TFHelper) getUndeleteDataWithID:[[tfCommentCellView comment] serverID] isComment:YES timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeleteCommentAction:)];
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
id comment = [tfCommentCellView comment];
|
||||
|
||||
@ -149,13 +150,13 @@ id tfStoryController;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeletePostAction{
|
||||
- (void)handleUndeletePostAction {
|
||||
|
||||
[%c(TFHelper) getUndeleteDataWithID:[[self story] serverID] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
|
||||
tfPostAuthor = data[@"author"];
|
||||
tfPostSelftext = [%c(MMMarkdown) HTMLStringWithMarkdown:data[@"body"] extensions:MMMarkdownExtensionsGitHubFlavored error:nil];
|
||||
@ -172,26 +173,12 @@ static void loadPrefs(){
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
if (prefs){
|
||||
|
||||
if ([prefs objectForKey:@"isBaconReaderEnabled"] != nil){
|
||||
isBaconReaderEnabled = [[prefs objectForKey:@"isBaconReaderEnabled"] boolValue];
|
||||
} else {
|
||||
isBaconReaderEnabled = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
|
||||
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
|
||||
} else {
|
||||
isTFDeletedOnly = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
|
||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
|
||||
} else {
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
}
|
||||
|
||||
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
|
||||
isBaconReaderEnabled = [prefs objectForKey:@"isBaconReaderEnabled"] ? [[prefs objectForKey:@"isBaconReaderEnabled"] boolValue] : YES;
|
||||
isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
|
||||
pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
|
||||
} else {
|
||||
isEnabled = YES;
|
||||
isBaconReaderEnabled = YES;
|
||||
isTFDeletedOnly = YES;
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
@ -209,9 +196,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
if ([processName isEqualToString:@"BaconReader"]){
|
||||
if (isBaconReaderEnabled){
|
||||
if (isBaconReaderEnabled && isEnabled){
|
||||
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
%init(BaconReader, StoryDetailView = objc_getClass("BaconReader.StoryDetailView"), StoryDetailViewController = objc_getClass("BaconReader.StoryDetailViewController"), CommentCellView = objc_getClass("BaconReader.CommentCellView"), CommentCell = objc_getClass("BaconReader.CommentCell"));
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
@property(strong, nonatomic) id authorButton;
|
||||
@property(assign, nonatomic) BOOL isCollapsed;
|
||||
@property(assign, nonatomic) BOOL commentDidChange;
|
||||
-(void) reloadContents;
|
||||
- (void)reloadContents;
|
||||
|
||||
//custom elements
|
||||
@property(strong, nonatomic) UIButton *undeleteButton;
|
||||
@ -48,7 +48,7 @@
|
||||
@end
|
||||
|
||||
@interface PostSelfTextPartCell
|
||||
-(id) _viewControllerForAncestor;
|
||||
- (id)_viewControllerForAncestor;
|
||||
@end
|
||||
|
||||
@interface PostMetadataView
|
||||
|
@ -2,6 +2,7 @@
|
||||
#import "Beam.h"
|
||||
#import "assets/TFHelper.h"
|
||||
|
||||
static BOOL isEnabled;
|
||||
static BOOL isBeamEnabled;
|
||||
static BOOL isTFDeletedOnly;
|
||||
static CGFloat pushshiftRequestTimeoutValue;
|
||||
@ -11,13 +12,13 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
%hook CommentCell
|
||||
%property(strong, nonatomic) UIButton *undeleteButton;
|
||||
|
||||
-(void) layoutSubviews{
|
||||
- (void)layoutSubviews {
|
||||
%orig;
|
||||
|
||||
UIButton *undeleteButton = [self undeleteButton];
|
||||
|
||||
if (undeleteButton){
|
||||
if ([self isCollapsed]){
|
||||
if (undeleteButton) {
|
||||
if ([self isCollapsed]) {
|
||||
[undeleteButton setHidden:YES];
|
||||
} else {
|
||||
[undeleteButton setHidden:NO];
|
||||
@ -26,7 +27,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
|
||||
NSString *commentBody = [[self comment] content];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
|
||||
CGFloat authorTextHeight = [[self authorButton] frame].size.height;
|
||||
|
||||
@ -46,7 +47,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeleteCommentAction:(id) sender{
|
||||
- (void)handleUndeleteCommentAction:(id)sender {
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
@ -54,7 +55,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
id comment = [self comment];
|
||||
|
||||
@ -74,12 +75,12 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
|
||||
%hook PostSelfTextPartCell
|
||||
|
||||
-(void) setSelected:(BOOL) arg1 animated:(BOOL) arg2{
|
||||
- (void)setSelected:(BOOL)arg1 animated:(BOOL)arg2{
|
||||
%orig;
|
||||
|
||||
id postViewController = [self _viewControllerForAncestor];
|
||||
|
||||
if ([postViewController isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]){
|
||||
if ([postViewController isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]) {
|
||||
|
||||
[postViewController setSelfTextView:self];
|
||||
[postViewController setPost:[self post]];
|
||||
@ -91,12 +92,12 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
|
||||
%hook PostMetadataView
|
||||
|
||||
-(void) layoutSubviews{
|
||||
- (void)layoutSubviews {
|
||||
%orig;
|
||||
|
||||
id postViewController = MSHookIvar<id>(self, "delegate");
|
||||
|
||||
if ([postViewController isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]){
|
||||
if ([postViewController isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]) {
|
||||
[postViewController setMetadataView:self];
|
||||
}
|
||||
}
|
||||
@ -107,14 +108,14 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
%hook PostToolbarView
|
||||
%property(strong, nonatomic) UIButton *undeleteButton;
|
||||
|
||||
-(void) layoutSubviews{
|
||||
- (void)layoutSubviews {
|
||||
%orig;
|
||||
|
||||
if (![self undeleteButton] && [[[self post] isSelfText] boolValue] && [MSHookIvar<id>(self, "delegate") isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]){
|
||||
if (![self undeleteButton] && [[[self post] isSelfText] boolValue] && [MSHookIvar<id>(self, "delegate") isMemberOfClass:objc_getClass("beam.PostDetailEmbeddedViewController")]) {
|
||||
|
||||
NSString *postBody = [[self post] content];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
|
||||
id moreButton = MSHookIvar<id>(self, "moreButton");
|
||||
|
||||
@ -143,7 +144,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
%property(strong, nonatomic) id post;
|
||||
|
||||
%new
|
||||
-(void) handleUndeletePostAction:(id) sender{
|
||||
- (void)handleUndeletePostAction:(id)sender {
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
@ -156,7 +157,7 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
|
||||
id post = [self post];
|
||||
|
||||
@ -164,11 +165,11 @@ static CGFloat pushshiftRequestTimeoutValue;
|
||||
[post setContent:data[@"body"]];
|
||||
[post setMarkdownString:nil];
|
||||
|
||||
if ([self selfTextView]){
|
||||
if ([self selfTextView]) {
|
||||
[[self selfTextView] reloadContents];
|
||||
}
|
||||
|
||||
if ([self metadataView]){
|
||||
if ([self metadataView]) {
|
||||
[[self metadataView] setPost:post];
|
||||
}
|
||||
|
||||
@ -186,26 +187,12 @@ static void loadPrefs(){
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
if (prefs){
|
||||
|
||||
if ([prefs objectForKey:@"isBeamEnabled"] != nil){
|
||||
isBeamEnabled = [[prefs objectForKey:@"isBeamEnabled"] boolValue];
|
||||
} else {
|
||||
isBeamEnabled = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
|
||||
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
|
||||
} else {
|
||||
isTFDeletedOnly = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
|
||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
|
||||
} else {
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
}
|
||||
|
||||
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
|
||||
isBeamEnabled = [prefs objectForKey:@"isBeamEnabled"] ? [[prefs objectForKey:@"isBeamEnabled"] boolValue] : YES;
|
||||
isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
|
||||
pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
|
||||
} else {
|
||||
isEnabled = YES;
|
||||
isBeamEnabled = YES;
|
||||
isTFDeletedOnly = YES;
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
@ -223,9 +210,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
if ([processName isEqualToString:@"beam"]){
|
||||
if (isBeamEnabled){
|
||||
if (isBeamEnabled && isEnabled){
|
||||
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
%init(Beam, CommentCell = objc_getClass("beam.CommentCell"), PostDetailEmbeddedViewController = objc_getClass("beam.PostDetailEmbeddedViewController"), PostToolbarView = objc_getClass("beam.PostToolbarView"), PostSelfTextPartCell = objc_getClass("beam.PostSelfTextPartCell"), PostMetadataView = objc_getClass("beam.PostMetadataView"));
|
||||
}
|
||||
|
112
tweak/Narwhal.h
112
tweak/Narwhal.h
@ -7,13 +7,13 @@
|
||||
@property(assign,nonatomic) NSString* body;
|
||||
@property(assign,nonatomic) NSString* fullName;
|
||||
|
||||
-(BOOL) isSaved;
|
||||
- (BOOL)isSaved;
|
||||
@end
|
||||
|
||||
@interface NRTCommentsManager
|
||||
@property(assign,nonatomic) NSMutableArray* comments;
|
||||
|
||||
-(void) updateComment:(id) arg1 fromEdited:(id) arg2;
|
||||
- (void)updateComment:(id)arg1 fromEdited:(id)arg2;
|
||||
@end
|
||||
|
||||
/* -- Post Interfaces -- */
|
||||
@ -25,13 +25,13 @@
|
||||
@end
|
||||
|
||||
@interface NRTLinkTitleCell
|
||||
-(void) configureCellForLink:(id) arg1;
|
||||
- (void)configureCellForLink:(id)arg1;
|
||||
@end
|
||||
|
||||
@interface NRTLinkTextCell
|
||||
@property(assign,nonatomic) id bodyLabel;
|
||||
|
||||
-(void) configureCellForText:(id) arg1 links:(id) arg2;
|
||||
- (void)configureCellForText:(id)arg1 links:(id)arg2;
|
||||
@end
|
||||
|
||||
/* -- Other Interfaces -- */
|
||||
@ -39,11 +39,11 @@
|
||||
@interface NRTAuthManager
|
||||
@property(assign,nonatomic) NSString* currentUsername;
|
||||
|
||||
+(id) sharedManager;
|
||||
+ (id)sharedManager;
|
||||
@end
|
||||
|
||||
@interface NRTMarkdownManager
|
||||
+(id) attributedStringFromMarkdown:(id) arg1 type:(id) arg2;
|
||||
+ (id)attributedStringFromMarkdown:(id)arg1 type:(id)arg2;
|
||||
@end
|
||||
|
||||
@interface NRTAttributedLabel
|
||||
@ -62,70 +62,58 @@
|
||||
@property(assign,nonatomic) id linkText;
|
||||
@property(assign,nonatomic) id tableView;
|
||||
|
||||
-(void) _handleActionSheetCopyCommentText:(id) arg1;
|
||||
-(void) _handleActionSheetDeleteComment:(id) arg1;
|
||||
-(void) _handleActionSheetDeletePost;
|
||||
-(void) _handleActionSheetEditComment:(id) arg1;
|
||||
-(void) _handleActionSheetEditPost;
|
||||
-(void) _handleActionSheetOpenChrome;
|
||||
-(void) _handleActionSheetOpenSafari;
|
||||
-(void) _handleActionSheetPrivateMessage:(id) arg1;
|
||||
-(void) _handleActionSheetRefreshComments;
|
||||
-(void) _handleActionSheetRefreshPost;
|
||||
-(void) _handleActionSheetReportComment:(id) arg1;
|
||||
-(void) _handleActionSheetReportPost;
|
||||
-(void) _handleActionSheetSaveComment:(id) arg1 index:(NSUInteger) arg2;
|
||||
-(void) _handleActionSheetShareComment:(id) arg1;
|
||||
-(void) _handleActionSheetShareLink;
|
||||
-(void) _handleActionSheetSharePost;
|
||||
-(void) _handleActionSheetSortComments;
|
||||
-(void) _handleActionSheetUnsaveComment:(id) arg1 index:(NSUInteger) arg2;
|
||||
-(void) _handleActionSheetViewParent:(id) arg1;
|
||||
-(void) _handleActionSheetViewProfile:(id) arg1;
|
||||
- (void)_handleActionSheetCopyCommentText:(id)arg1;
|
||||
- (void)_handleActionSheetDeleteComment:(id)arg1;
|
||||
- (void)_handleActionSheetDeletePost;
|
||||
- (void)_handleActionSheetEditComment:(id)arg1;
|
||||
- (void)_handleActionSheetEditPost;
|
||||
- (void)_handleActionSheetOpenChrome;
|
||||
- (void)_handleActionSheetOpenSafari;
|
||||
- (void)_handleActionSheetPrivateMessage:(id)arg1;
|
||||
- (void)_handleActionSheetRefreshComments;
|
||||
- (void)_handleActionSheetRefreshPost;
|
||||
- (void)_handleActionSheetReportComment:(id)arg1;
|
||||
- (void)_handleActionSheetReportPost;
|
||||
- (void)_handleActionSheetSaveComment:(id)arg1 index:(NSUInteger)arg2;
|
||||
- (void)_handleActionSheetShareComment:(id)arg1;
|
||||
- (void)_handleActionSheetShareLink;
|
||||
- (void)_handleActionSheetSharePost;
|
||||
- (void)_handleActionSheetSortComments;
|
||||
- (void)_handleActionSheetUnsaveComment:(id)arg1 index:(NSUInteger)arg2;
|
||||
- (void)_handleActionSheetViewParent:(id)arg1;
|
||||
- (void)_handleActionSheetViewProfile:(id)arg1;
|
||||
|
||||
//custom elements
|
||||
-(void) handleUndeleteAction:(id) arg1;
|
||||
-(void) handleUndeletePostAction;
|
||||
-(void) mainThreadTest:(id) arg1;
|
||||
- (void) handleUndeleteAction:(id)arg1;
|
||||
- (void) handleUndeletePostAction;
|
||||
- (void) mainThreadTest:(id)arg1;
|
||||
@end
|
||||
|
||||
@interface NRTMediaTableViewDataSource
|
||||
@property(assign,nonatomic) id commentsManager;
|
||||
@property(assign,nonatomic) id parentController;
|
||||
|
||||
-(void) _handleActionSheetCopyCommentText:(id) arg1;
|
||||
-(void) _handleActionSheetDeleteComment:(id) arg1;
|
||||
-(void) _handleActionSheetDeletePost;
|
||||
-(void) _handleActionSheetEditComment:(id) arg1;
|
||||
-(void) _handleActionSheetEditPost;
|
||||
-(void) _handleActionSheetOpenChrome;
|
||||
-(void) _handleActionSheetOpenSafari;
|
||||
-(void) _handleActionSheetPrivateMessage:(id) arg1;
|
||||
-(void) _handleActionSheetRefreshComments;
|
||||
-(void) _handleActionSheetRefreshPost;
|
||||
-(void) _handleActionSheetReportComment:(id) arg1;
|
||||
-(void) _handleActionSheetReportPost;
|
||||
-(void) _handleActionSheetSaveComment:(id) arg1 index:(NSUInteger) arg2;
|
||||
-(void) _handleActionSheetShareComment:(id) arg1;
|
||||
-(void) _handleActionSheetShareLink;
|
||||
-(void) _handleActionSheetSharePost;
|
||||
-(void) _handleActionSheetSortComments;
|
||||
-(void) _handleActionSheetUnsaveComment:(id) arg1 index:(NSUInteger) arg2;
|
||||
-(void) _handleActionSheetViewParent:(id) arg1;
|
||||
-(void) _handleActionSheetViewProfile:(id) arg1;
|
||||
- (void)_handleActionSheetCopyCommentText:(id)arg1;
|
||||
- (void)_handleActionSheetDeleteComment:(id)arg1;
|
||||
- (void)_handleActionSheetDeletePost;
|
||||
- (void)_handleActionSheetEditComment:(id)arg1;
|
||||
- (void)_handleActionSheetEditPost;
|
||||
- (void)_handleActionSheetOpenChrome;
|
||||
- (void)_handleActionSheetOpenSafari;
|
||||
- (void)_handleActionSheetPrivateMessage:(id)arg1;
|
||||
- (void)_handleActionSheetRefreshComments;
|
||||
- (void)_handleActionSheetRefreshPost;
|
||||
- (void)_handleActionSheetReportComment:(id)arg1;
|
||||
- (void)_handleActionSheetReportPost;
|
||||
- (void)_handleActionSheetSaveComment:(id)arg1 index:(NSUInteger)arg2;
|
||||
- (void)_handleActionSheetShareComment:(id)arg1;
|
||||
- (void)_handleActionSheetShareLink;
|
||||
- (void)_handleActionSheetSharePost;
|
||||
- (void)_handleActionSheetSortComments;
|
||||
- (void)_handleActionSheetUnsaveComment:(id)arg1 index:(NSUInteger)arg2;
|
||||
- (void)_handleActionSheetViewParent:(id)arg1;
|
||||
- (void)_handleActionSheetViewProfile:(id)arg1;
|
||||
|
||||
//custom elements
|
||||
-(void) handleUndeleteCommentAction:(id) comment;
|
||||
- (void)handleUndeleteCommentAction:(id)comment;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#import "Narwhal.h"
|
||||
#import "assets/TFHelper.h"
|
||||
|
||||
static BOOL isEnabled;
|
||||
static BOOL isNarwhalEnabled;
|
||||
static BOOL isTFDeletedOnly;
|
||||
static CGFloat pushshiftRequestTimeoutValue;
|
||||
@ -19,13 +20,13 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
|
||||
%hook UIViewController
|
||||
|
||||
-(void) presentViewController:(id) arg1 animated:(BOOL) arg2 completion:(id) arg3{
|
||||
- (void)presentViewController:(id)arg1 animated:(BOOL)arg2 completion:(id)arg3 {
|
||||
|
||||
if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveUndeleteAction){
|
||||
if ([arg1 isKindOfClass:[UIAlertController class]] && shouldHaveUndeleteAction) {
|
||||
|
||||
UIAlertAction* undeleteAction;
|
||||
|
||||
if (tfComment){
|
||||
if (tfComment) {
|
||||
undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){getUndeleteCommentData(tfController, tfComment);}];
|
||||
} else {
|
||||
undeleteAction = [UIAlertAction actionWithTitle:@"tf did that say?" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){[tfController handleUndeletePostAction];}];
|
||||
@ -42,9 +43,9 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
|
||||
%hook NRTLinkViewController
|
||||
|
||||
-(void) swipeCell:(id) arg1 didEndDragWithState:(NSUInteger) arg2{
|
||||
- (void)swipeCell:(id)arg1 didEndDragWithState:(NSUInteger)arg2 {
|
||||
|
||||
if (arg2 == 2){
|
||||
if (arg2 == 2) {
|
||||
if ([arg1 isKindOfClass:[%c(NRTCommentTableViewCell) class]]) {
|
||||
|
||||
NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
|
||||
@ -62,13 +63,13 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
shouldHaveUndeleteAction = NO;
|
||||
}
|
||||
|
||||
-(void) _dotsButtonTouched:(id) arg1{
|
||||
- (void)_dotsButtonTouched:(id)arg1 {
|
||||
|
||||
if ([self linkTextOffscreenCell]){
|
||||
if ([self linkTextOffscreenCell]) {
|
||||
|
||||
NSString *postBody = [[self link] selfText];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
tfController = self;
|
||||
tfComment = nil;
|
||||
shouldHaveUndeleteAction = YES;
|
||||
@ -81,7 +82,7 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeletePostAction{
|
||||
- (void)handleUndeletePostAction {
|
||||
|
||||
id post = [self link];
|
||||
|
||||
@ -89,7 +90,7 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
|
||||
id post = data[@"post"];
|
||||
|
||||
@ -102,11 +103,11 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
id comment = data[@"comment"];
|
||||
|
||||
if (comment){
|
||||
if (comment) {
|
||||
|
||||
MSHookIvar<NSString*>(comment, "_author") = data[@"author"];
|
||||
MSHookIvar<NSString*>(comment, "_body") = data[@"body"];
|
||||
@ -120,14 +121,14 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
|
||||
%hook NRTMediaTableViewDataSource
|
||||
|
||||
-(void) swipeCell:(id) arg1 didEndDragWithState:(NSUInteger) arg2{
|
||||
- (void)swipeCell:(id)arg1 didEndDragWithState:(NSUInteger)arg2 {
|
||||
|
||||
if (arg2 == 2){
|
||||
if (arg2 == 2) {
|
||||
if ([arg1 isKindOfClass:[%c(NRTCommentTableViewCell) class]]) {
|
||||
|
||||
NSString *commentBody = MSHookIvar<NSString*>([arg1 comment], "_body");
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
tfComment = [arg1 comment];
|
||||
tfController = self;
|
||||
shouldHaveUndeleteAction = YES;
|
||||
@ -141,11 +142,11 @@ void getUndeleteCommentData(id controller, id comment){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
id comment = data[@"comment"];
|
||||
|
||||
if (comment){
|
||||
if (comment) {
|
||||
|
||||
MSHookIvar<NSString*>(comment, "_author") = data[@"author"];
|
||||
MSHookIvar<NSString*>(comment, "_body") = data[@"body"];
|
||||
@ -163,26 +164,12 @@ static void loadPrefs(){
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
if (prefs){
|
||||
|
||||
if ([prefs objectForKey:@"isNarwhalEnabled"] != nil){
|
||||
isNarwhalEnabled = [[prefs objectForKey:@"isNarwhalEnabled"] boolValue];
|
||||
} else {
|
||||
isNarwhalEnabled = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
|
||||
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
|
||||
} else {
|
||||
isTFDeletedOnly = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
|
||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
|
||||
} else {
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
}
|
||||
|
||||
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
|
||||
isNarwhalEnabled = [prefs objectForKey:@"isNarwhalEnabled"] ? [[prefs objectForKey:@"isNarwhalEnabled"] boolValue] : YES;
|
||||
isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
|
||||
pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
|
||||
} else {
|
||||
isEnabled = YES;
|
||||
isNarwhalEnabled = YES;
|
||||
isTFDeletedOnly = YES;
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
@ -200,9 +187,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
if ([processName isEqualToString:@"narwhal"]){
|
||||
if (isNarwhalEnabled){
|
||||
if (isNarwhalEnabled && isEnabled){
|
||||
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
%init(Narwhal);
|
||||
}
|
||||
|
@ -16,22 +16,22 @@
|
||||
|
||||
@interface CommentsViewController : NSObject
|
||||
@property(strong,nonatomic) id postData;
|
||||
-(void) reloadCommentsWithNewCommentsHighlight:(BOOL) arg1 autoScroll:(BOOL) arg2 animated:(BOOL) arg3;
|
||||
-(void) reloadCommentsSection:(BOOL) arg1;
|
||||
-(void) reloadPostSection:(BOOL) arg1;
|
||||
-(void) feedPostViewDidUpdatePost:(id) arg1 shouldReloadFeed:(BOOL) arg2;
|
||||
-(void) updateFloatingViews;
|
||||
- (void)reloadCommentsWithNewCommentsHighlight:(BOOL)arg1 autoScroll:(BOOL)arg2 animated:(BOOL)arg3;
|
||||
- (void)reloadCommentsSection:(BOOL)arg1;
|
||||
- (void)reloadPostSection:(BOOL)arg1;
|
||||
- (void)feedPostViewDidUpdatePost:(id)arg1 shouldReloadFeed:(BOOL)arg2;
|
||||
- (void)updateFloatingViews;
|
||||
|
||||
//custom elements
|
||||
-(void) updateComments;
|
||||
-(void) updatePostText;
|
||||
- (void)updateComments;
|
||||
- (void)updatePostText;
|
||||
@end
|
||||
|
||||
@interface CommentActionSheetViewController : UIViewController
|
||||
@property(strong,nonatomic) Comment *comment;
|
||||
@property(strong,nonatomic) id commentTreeNode;
|
||||
@property(strong,nonatomic) CommentsViewController *commentActionSheetDelegate;
|
||||
-(id)animationControllerForDismissedController:(id) arg1;
|
||||
- (id)animationControllerForDismissedController:(id)arg1;
|
||||
@end
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
|
||||
@interface CommentTreeHeaderNode
|
||||
@property(strong,nonatomic) id commentTreeNode;
|
||||
-(void) updateContentViewsForData:(id)arg1;
|
||||
- (void)updateContentViewsForData:(id)arg1;
|
||||
@end
|
||||
|
||||
@interface CommentTreeCommandBarNode
|
||||
@ -68,7 +68,7 @@
|
||||
@interface CommentTreeHeaderView
|
||||
@property(strong,nonatomic) id commentTreeNode;
|
||||
|
||||
-(void) updateContentViewsForData:(id) arg1;
|
||||
- (void)updateContentViewsForData:(id)arg1;
|
||||
@end
|
||||
|
||||
/* -- Post Interfaces -- */
|
||||
@ -85,7 +85,7 @@
|
||||
|
||||
@interface PostDetailViewController
|
||||
@property(strong,nonatomic) id selfTextNode;
|
||||
-(void) configureSelfTextNode;
|
||||
- (void)configureSelfTextNode;
|
||||
|
||||
//custom elements
|
||||
@property(strong,nonatomic) id feedPostTextWithThumbnailNode;
|
||||
@ -111,7 +111,7 @@
|
||||
|
||||
@interface FeedPostTitleNode
|
||||
@property(strong,nonatomic) id delegate;
|
||||
-(void) configureNodes;
|
||||
- (void)configureNodes;
|
||||
@end
|
||||
|
||||
@interface FeedPostDetailDelegator
|
||||
@ -119,7 +119,7 @@
|
||||
@end
|
||||
|
||||
@interface FeedPostContentNode
|
||||
-(void) configureSelfTextNode;
|
||||
- (void)configureSelfTextNode;
|
||||
@end
|
||||
|
||||
/* -- Other Interfaces -- */
|
||||
@ -130,14 +130,14 @@
|
||||
|
||||
@interface RUIActionSheetItem : NSObject
|
||||
@property(strong,nonatomic) id leftIconImage;
|
||||
-(id) initWithLeftIconImage:(id) arg1 text:(id) arg2 identifier:(id) arg3 context:(id) arg4;
|
||||
- (id)initWithLeftIconImage:(id)arg1 text:(id)arg2 identifier:(id)arg3 context:(id)arg4;
|
||||
@end
|
||||
|
||||
|
||||
@interface ActionSheetItem : NSObject
|
||||
// <= 4.17
|
||||
@property(strong,nonatomic) id leftIconImage;
|
||||
-(id) initWithLeftIconImage:(id) arg1 text:(id) arg2 identifier:(id) arg3 context:(id) arg4;
|
||||
- (id) initWithLeftIconImage:(id)arg1 text:(id)arg2 identifier:(id)arg3 context:(id)arg4;
|
||||
@end
|
||||
|
||||
@interface RUITheme
|
||||
@ -145,65 +145,66 @@
|
||||
@end
|
||||
|
||||
@interface NSAttributedStringMarkdownParser
|
||||
+(id) currentConfig;
|
||||
+(id) attributedStringUsingCurrentConfig:(id) arg1;
|
||||
-(id) attributedStringFromMarkdownString:(id) arg1;
|
||||
-(id) initWithConfig:(id) arg1;
|
||||
+ (id)currentConfig;
|
||||
+ (id)attributedStringUsingCurrentConfig:(id)arg1;
|
||||
- (id)attributedStringFromMarkdownString:(id)arg1;
|
||||
- (id)initWithConfig:(id)arg1;
|
||||
@end
|
||||
|
||||
@interface ThemeManager
|
||||
|
||||
+(id) sharedManager;
|
||||
+ (id)sharedManager;
|
||||
|
||||
// >= 4.45.0
|
||||
@property(strong,nonatomic) id darkTheme;
|
||||
@property(strong,nonatomic) id lightTheme;
|
||||
-(id) initWithAppSettings:(id) arg1;
|
||||
- (id)initWithAppSettings:(id)arg1;
|
||||
|
||||
// < 4.45.0
|
||||
@property(strong,nonatomic) id dayTheme;
|
||||
@property(strong,nonatomic) id nightTheme;
|
||||
-(id) initWithTraitCollection:(id) arg1 appSettings:(id) arg2;
|
||||
- (id)initWithTraitCollection:(id)arg1 appSettings:(id)arg2;
|
||||
|
||||
@end
|
||||
|
||||
@interface AppSettings
|
||||
+(id) sharedSettings;
|
||||
+ (id)sharedSettings;
|
||||
@end
|
||||
|
||||
@interface AccountManager
|
||||
@property(assign,nonatomic) id defaults;
|
||||
+(id) sharedManager;
|
||||
+ (id)sharedManager;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
/* ---- Reddit v3 ---- */
|
||||
|
||||
|
||||
/* -- Comment Interfaces -- */
|
||||
|
||||
@interface CommentCell : UIView
|
||||
-(id) delegate;
|
||||
-(id) comment;
|
||||
@interface CommentCell : UIView
|
||||
- (id)delegate;
|
||||
- (id)comment;
|
||||
- (id)commentView;
|
||||
@end
|
||||
|
||||
@interface CommentView
|
||||
-(void) configureSubviews;
|
||||
-(void) layoutSubviews;
|
||||
-(id) commandView;
|
||||
-(id) comment;
|
||||
@interface CommentView
|
||||
- (void)configureSubviews;
|
||||
- (void)layoutSubviews;
|
||||
- (id)commandView;
|
||||
- (id)comment;
|
||||
- (id)delegate;
|
||||
@end
|
||||
|
||||
@interface CommentCommandView
|
||||
@property (strong, nonatomic) id undeleteButton;
|
||||
-(id)overflowButton;
|
||||
-(id) comment;
|
||||
@property (strong, nonatomic) id undeleteButton;
|
||||
- (id)overflowButton;
|
||||
- (id)comment;
|
||||
- (id)delegate;
|
||||
@end
|
||||
|
||||
/* -- Other Interfaces -- */
|
||||
|
||||
@interface MarkDownParser
|
||||
@interface MarkDownParser
|
||||
+ (id)attributedStringFromMarkdownString:(id)arg1;
|
||||
|
138
tweak/Reddit.xm
138
tweak/Reddit.xm
@ -2,6 +2,7 @@
|
||||
#import "Reddit.h"
|
||||
#import "assets/TFHelper.h"
|
||||
|
||||
static BOOL isEnabled;
|
||||
static BOOL isRedditEnabled;
|
||||
static BOOL isTFDeletedOnly;
|
||||
static CGFloat pushshiftRequestTimeoutValue;
|
||||
@ -18,7 +19,7 @@ int secondVersionPart = 0;
|
||||
|
||||
%hook CommentTreeHeaderView
|
||||
|
||||
-(void) layoutSubviews{
|
||||
- (void)layoutSubviews {
|
||||
%orig;
|
||||
|
||||
[[self commentTreeNode] setCommentTreeHeaderNode:self];
|
||||
@ -28,7 +29,7 @@ int secondVersionPart = 0;
|
||||
|
||||
%hook CommentTreeHeaderNode
|
||||
|
||||
-(void) didLoad{
|
||||
- (void)didLoad {
|
||||
%orig;
|
||||
|
||||
[[self commentTreeNode] setCommentTreeHeaderNode:self];
|
||||
@ -38,7 +39,7 @@ int secondVersionPart = 0;
|
||||
|
||||
%hook CommentTreeCommandBarNode
|
||||
|
||||
-(void) didLoad{
|
||||
- (void)didLoad {
|
||||
%orig;
|
||||
|
||||
[[self commentTreeNode] setCommentTreeCommandBarNode:self];
|
||||
@ -48,11 +49,11 @@ int secondVersionPart = 0;
|
||||
|
||||
%hook CommentActionSheetViewController
|
||||
|
||||
-(void) setItems:(id) arg1{
|
||||
- (void)setItems:(id)arg1 {
|
||||
|
||||
NSString *commentBody = [[self comment] bodyText];
|
||||
NSString *commentAuthor = [[self comment] author];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentAuthor isDeletedOnly:isTFDeletedOnly]) {
|
||||
|
||||
UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
|
||||
@ -71,10 +72,10 @@ int secondVersionPart = 0;
|
||||
%orig;
|
||||
}
|
||||
|
||||
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
||||
- (void)handleDidSelectActionSheetItem:(id)arg1 {
|
||||
%orig;
|
||||
|
||||
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
|
||||
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
@ -86,7 +87,7 @@ int secondVersionPart = 0;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
id commentTreeNode = [self commentTreeNode];
|
||||
Comment *comment = [commentTreeNode comment];
|
||||
@ -100,38 +101,38 @@ int secondVersionPart = 0;
|
||||
id isNightMode;
|
||||
id textColor;
|
||||
|
||||
if (firstVersionPart == 2020){
|
||||
if (firstVersionPart == 2020) {
|
||||
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
|
||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||
|
||||
if (isNightMode) {
|
||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
||||
} else{
|
||||
} else {
|
||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
||||
}
|
||||
|
||||
[themeManager release];
|
||||
} else {
|
||||
|
||||
if (secondVersionPart >= 45){
|
||||
if (secondVersionPart >= 45) {
|
||||
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
|
||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||
|
||||
if (isNightMode) {
|
||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
||||
} else{
|
||||
} else {
|
||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
||||
}
|
||||
|
||||
[themeManager release];
|
||||
|
||||
} else if (secondVersionPart >= 37){
|
||||
} else if (secondVersionPart >= 37) {
|
||||
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||
|
||||
if (isNightMode) {
|
||||
textColor = [[themeManager nightTheme] bodyTextColor];
|
||||
} else{
|
||||
} else {
|
||||
textColor = [[themeManager dayTheme] bodyTextColor];
|
||||
}
|
||||
|
||||
@ -143,7 +144,7 @@ int secondVersionPart = 0;
|
||||
|
||||
if (isNightMode) {
|
||||
textColor = [[themeManager nightTheme] bodyTextColor];
|
||||
} else{
|
||||
} else {
|
||||
textColor = [[themeManager dayTheme] bodyTextColor];
|
||||
}
|
||||
}
|
||||
@ -178,7 +179,7 @@ int secondVersionPart = 0;
|
||||
|
||||
%hook FeedPostDetailCellNode
|
||||
|
||||
-(void) didLoad{
|
||||
- (void)didLoad {
|
||||
%orig;
|
||||
|
||||
[[[self delegate] viewController] setFeedPostDetailCellNode:self];
|
||||
@ -187,13 +188,13 @@ int secondVersionPart = 0;
|
||||
|
||||
%hook PostActionSheetViewController
|
||||
|
||||
-(void) setItems:(id) arg1{
|
||||
- (void)setItems:(id)arg1 {
|
||||
|
||||
Post *post = [self post];
|
||||
NSString *postBody = [post selfText];
|
||||
|
||||
if ([post isSelfPost]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([post isSelfPost]) {
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
|
||||
UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
|
||||
@ -214,10 +215,10 @@ int secondVersionPart = 0;
|
||||
}
|
||||
|
||||
|
||||
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
||||
- (void)handleDidSelectActionSheetItem:(id)arg1 {
|
||||
%orig;
|
||||
|
||||
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
|
||||
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
@ -231,7 +232,7 @@ int secondVersionPart = 0;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
Post *post = [self post];
|
||||
|
||||
NSString *author = data[@"author"];
|
||||
@ -241,38 +242,38 @@ int secondVersionPart = 0;
|
||||
id isNightMode;
|
||||
id textColor;
|
||||
|
||||
if (firstVersionPart == 2020){
|
||||
if (firstVersionPart == 2020) {
|
||||
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
|
||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||
|
||||
if (isNightMode) {
|
||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
||||
} else{
|
||||
} else {
|
||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
||||
}
|
||||
|
||||
[themeManager release];
|
||||
} else {
|
||||
|
||||
if (secondVersionPart >= 45){
|
||||
if (secondVersionPart >= 45) {
|
||||
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
|
||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||
|
||||
if (isNightMode) {
|
||||
textColor = [[themeManager darkTheme] bodyTextColor];
|
||||
} else{
|
||||
} else {
|
||||
textColor = [[themeManager lightTheme] bodyTextColor];
|
||||
}
|
||||
|
||||
[themeManager release];
|
||||
|
||||
} else if (secondVersionPart >= 37){
|
||||
} else if (secondVersionPart >= 37) {
|
||||
themeManager = [[%c(ThemeManager) alloc] initWithTraitCollection:nil appSettings:[%c(AppSettings) sharedSettings]];
|
||||
isNightMode = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"];
|
||||
|
||||
if (isNightMode) {
|
||||
textColor = [[themeManager nightTheme] bodyTextColor];
|
||||
} else{
|
||||
} else {
|
||||
textColor = [[themeManager dayTheme] bodyTextColor];
|
||||
}
|
||||
|
||||
@ -284,7 +285,7 @@ int secondVersionPart = 0;
|
||||
|
||||
if (isNightMode) {
|
||||
textColor = [[themeManager nightTheme] bodyTextColor];
|
||||
} else{
|
||||
} else {
|
||||
textColor = [[themeManager dayTheme] bodyTextColor];
|
||||
}
|
||||
}
|
||||
@ -304,10 +305,10 @@ int secondVersionPart = 0;
|
||||
[post setSelfPostRichTextAttributed:bodyMutableAttributedText];
|
||||
[post setPreviewFeedPostTextString:bodyMutableAttributedText];
|
||||
|
||||
if (firstVersionPart == 2020){
|
||||
if (firstVersionPart == 2020) {
|
||||
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
|
||||
} else {
|
||||
if (secondVersionPart >= 44){
|
||||
if (secondVersionPart >= 44) {
|
||||
[[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] contentNode] configureSelfTextNode];
|
||||
} else if (secondVersionPart >= 38) {
|
||||
[[[[self postActionSheetDelegate] controller] feedPostDetailCellNode] configureSelfTextNode];
|
||||
@ -330,12 +331,12 @@ int secondVersionPart = 0;
|
||||
%hook CommentsViewController
|
||||
|
||||
%new
|
||||
-(void) updateComments{
|
||||
- (void)updateComments {
|
||||
[self reloadCommentsWithNewCommentsHighlight:NO autoScroll:NO animated:NO];
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) updatePostText{
|
||||
- (void)updatePostText {
|
||||
|
||||
if (secondVersionPart >= 2){
|
||||
[self reloadPostSection:YES];
|
||||
@ -348,11 +349,11 @@ int secondVersionPart = 0;
|
||||
|
||||
%hook CommentActionSheetViewController
|
||||
|
||||
-(void) setItems:(id) arg1{
|
||||
- (void)setItems:(id)arg1 {
|
||||
|
||||
NSString *commentBody = [[self comment] bodyText];
|
||||
NSString *commentAuthor = [[self comment] author];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentAuthor isDeletedOnly:isTFDeletedOnly]) {
|
||||
|
||||
UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
|
||||
@ -378,10 +379,10 @@ int secondVersionPart = 0;
|
||||
}
|
||||
|
||||
// >= 4.21
|
||||
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
||||
- (void)handleDidSelectActionSheetItem:(id)arg1 {
|
||||
%orig;
|
||||
|
||||
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
|
||||
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
@ -392,7 +393,7 @@ int secondVersionPart = 0;
|
||||
}
|
||||
|
||||
// <= 4.20
|
||||
-(void) actionSheetViewController:(id) arg1 didSelectItem:(id) arg2{
|
||||
- (void)actionSheetViewController:(id)arg1 didSelectItem:(id)arg2 {
|
||||
%orig;
|
||||
|
||||
if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]){
|
||||
@ -406,7 +407,7 @@ int secondVersionPart = 0;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
Comment *comment = [self comment];
|
||||
|
||||
@ -431,13 +432,13 @@ int secondVersionPart = 0;
|
||||
|
||||
%hook PostActionSheetViewController
|
||||
|
||||
-(void) setItems:(id) arg1{
|
||||
- (void)setItems:(id)arg1{
|
||||
|
||||
Post *post = [self post];
|
||||
NSString *postBody = [post selfText];
|
||||
|
||||
if ([post isSelfPost]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([post isSelfPost]) {
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
|
||||
UIImage* origImage = [UIImage imageWithContentsOfFile:@"/var/mobile/Library/Application Support/TFDidThatSay/eye160dark.png"];
|
||||
|
||||
@ -464,27 +465,26 @@ int secondVersionPart = 0;
|
||||
}
|
||||
|
||||
// >= 4.21
|
||||
-(void) handleDidSelectActionSheetItem:(id) arg1{
|
||||
- (void)handleDidSelectActionSheetItem:(id)arg1 {
|
||||
%orig;
|
||||
|
||||
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]){
|
||||
if ([[arg1 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
Post *post = [self post];
|
||||
|
||||
if ([post isSelfPost]){
|
||||
|
||||
if ([post isSelfPost]) {
|
||||
[%c(TFHelper) getUndeleteDataWithID:[[post pk] componentsSeparatedByString:@"_"][1] isComment:NO timeout:pushshiftRequestTimeoutValue extraData:nil completionTarget:self completionSelector:@selector(completeUndeletePostAction:)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// <= 4.20
|
||||
-(void) actionSheetViewController:(id) arg1 didSelectItem:(id) arg2{
|
||||
- (void)actionSheetViewController:(id)arg1 didSelectItem:(id)arg2 {
|
||||
%orig;
|
||||
|
||||
if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]){
|
||||
if ([[arg2 identifier] isEqualToString:@"undeleteItemIdentifier"]) {
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
@ -498,7 +498,7 @@ int secondVersionPart = 0;
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
|
||||
Post *post = [self post];
|
||||
|
||||
@ -615,26 +615,12 @@ static void loadPrefs(){
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
if (prefs){
|
||||
|
||||
if ([prefs objectForKey:@"isRedditEnabled"] != nil){
|
||||
isRedditEnabled = [[prefs objectForKey:@"isRedditEnabled"] boolValue];
|
||||
} else {
|
||||
isRedditEnabled = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil) {
|
||||
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
|
||||
} else {
|
||||
isTFDeletedOnly = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
|
||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
|
||||
} else {
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
}
|
||||
|
||||
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
|
||||
isRedditEnabled = [prefs objectForKey:@"isRedditEnabled"] ? [[prefs objectForKey:@"isRedditEnabled"] boolValue] : YES;
|
||||
isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
|
||||
pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
|
||||
} else {
|
||||
isEnabled = YES;
|
||||
isRedditEnabled = YES;
|
||||
isTFDeletedOnly = YES;
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
@ -651,24 +637,24 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
|
||||
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
@try{
|
||||
@try {
|
||||
NSArray *redditVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] componentsSeparatedByString:@"."];
|
||||
|
||||
firstVersionPart = [redditVersion[0] intValue];
|
||||
secondVersionPart = [redditVersion[1] intValue];
|
||||
}
|
||||
@catch (NSException *exc){
|
||||
@catch (NSException *exc) {
|
||||
firstVersionPart = 2020;
|
||||
secondVersionPart = 0;
|
||||
}
|
||||
|
||||
if ([processName isEqualToString:@"Reddit"]){
|
||||
if (isRedditEnabled) {
|
||||
if (isRedditEnabled && isEnabled) {
|
||||
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
if (firstVersionPart == 4 || firstVersionPart == 2020){
|
||||
if (secondVersionPart <= 32 && firstVersionPart != 2020){
|
||||
if (firstVersionPart == 4 || firstVersionPart == 2020) {
|
||||
if (secondVersionPart <= 32 && firstVersionPart != 2020) {
|
||||
%init(Reddit_v4_ios10);
|
||||
} else{
|
||||
%init(Reddit_v4_current);
|
||||
|
@ -9,10 +9,10 @@
|
||||
@end
|
||||
|
||||
@interface CommentDepthCell
|
||||
-(void) showMenu:(id) arg1;
|
||||
- (void)showMenu:(id)arg1;
|
||||
|
||||
//custom elements
|
||||
-(void) addUndeleteButtonToMenu;
|
||||
- (void)addUndeleteButtonToMenu;
|
||||
@end
|
||||
|
||||
/* -- Post Interfaces -- */
|
||||
@ -22,38 +22,38 @@
|
||||
@end
|
||||
|
||||
@interface CommentViewController : UIViewController
|
||||
-(void) refresh:(id) arg1;
|
||||
- (void)refresh:(id)arg1;
|
||||
|
||||
//custom elements
|
||||
@property(strong, nonatomic) UIButton *undeleteButton;
|
||||
-(void) addUndeleteButtonToToolbar;
|
||||
-(BOOL) shouldAddUndeleteButtonToToolbar;
|
||||
- (void)addUndeleteButtonToToolbar;
|
||||
- (BOOL)shouldAddUndeleteButtonToToolbar;
|
||||
@end
|
||||
|
||||
/* -- Utility Interfaces -- */
|
||||
|
||||
@interface UIColor ()
|
||||
+(UIColor *) colorWithHex:(NSString *) arg1;
|
||||
-(NSString *) hexString;
|
||||
+ (UIColor *)colorWithHex:(NSString *)arg1;
|
||||
- (NSString *)hexString;
|
||||
@end
|
||||
|
||||
@interface NSAttributedString ()
|
||||
-(void) yy_setTextHighlightRange:(NSRange) range color:(UIColor *) color backgroundColor:(UIColor *) backgroundColor userInfo:(NSDictionary *) userInfo;
|
||||
- (void)yy_setTextHighlightRange:(NSRange)range color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor userInfo:(NSDictionary *)userInfo;
|
||||
@end
|
||||
|
||||
@interface ColorUtil : NSObject
|
||||
+(UIColor *) accentColorForSub:(NSString *) arg1;
|
||||
+(UIColor *) fontColorForTheme:(NSString *) arg1;
|
||||
+(UIColor *) backgroundColorForTheme:(NSString *) arg1;
|
||||
+ (UIColor *)accentColorForSub:(NSString *)arg1;
|
||||
+ (UIColor *)fontColorForTheme:(NSString *)arg1;
|
||||
+ (UIColor *)backgroundColorForTheme:(NSString *)arg1;
|
||||
@end
|
||||
|
||||
@interface DTHTMLAttributedStringBuilder
|
||||
-(id) initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary * __autoreleasing*)docAttributes;
|
||||
-(NSAttributedString *) generatedAttributedString;
|
||||
- (id) initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary * __autoreleasing*)docAttributes;
|
||||
- (NSAttributedString *)generatedAttributedString;
|
||||
@end
|
||||
|
||||
@interface FontGenerator : NSObject
|
||||
+(UIFont *) fontOfSize:(CGFloat) arg1 submission:(BOOL) arg2 willOffset:(BOOL) arg3;
|
||||
+(UIFont *) boldFontOfSize:(CGFloat) arg1 submission:(BOOL) arg2 willOffset:(BOOL) arg3;
|
||||
+(UIFont *) italicFontOfSize:(CGFloat) arg1 submission:(BOOL) arg2 willOffset:(BOOL) arg3;
|
||||
+ (UIFont *)fontOfSize:(CGFloat)arg1 submission:(BOOL)arg2 willOffset:(BOOL)arg3;
|
||||
+ (UIFont *)boldFontOfSize:(CGFloat)arg1 submission:(BOOL)arg2 willOffset:(BOOL)arg3;
|
||||
+ (UIFont *)italicFontOfSize:(CGFloat)arg1 submission:(BOOL)arg2 willOffset:(BOOL)arg3;
|
||||
@end
|
116
tweak/Slide.xm
116
tweak/Slide.xm
@ -3,6 +3,7 @@
|
||||
#import "assets/TFHelper.h"
|
||||
#import "assets/MMMarkdown/MMMarkdown.h"
|
||||
|
||||
static BOOL isEnabled;
|
||||
static BOOL isSlideEnabled;
|
||||
static BOOL isTFDeletedOnly;
|
||||
static CGFloat pushshiftRequestTimeoutValue;
|
||||
@ -15,13 +16,13 @@ NSString *slidePostOverrideBodyHtml;
|
||||
|
||||
@implementation FontGenerator
|
||||
|
||||
+(UIFont *) fontOfSize:(CGFloat) size submission:(BOOL) isSubmission willOffset:(BOOL) willOffset{
|
||||
+ (UIFont *)fontOfSize:(CGFloat)size submission:(BOOL)isSubmission willOffset:(BOOL)willOffset {
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
NSString *fontName;
|
||||
CGFloat fontSize = size;
|
||||
|
||||
if (willOffset){
|
||||
if (willOffset) {
|
||||
if (isSubmission){
|
||||
fontSize += ([userDefaults objectForKey:@"POST_FONT_SIZE"] == nil) ? 0 : [userDefaults integerForKey:@"POST_FONT_SIZE"];
|
||||
} else {
|
||||
@ -29,7 +30,7 @@ NSString *slidePostOverrideBodyHtml;
|
||||
}
|
||||
}
|
||||
|
||||
if ([userDefaults stringForKey:(isSubmission ? @"postfont" : @"commentfont")] == nil){
|
||||
if ([userDefaults stringForKey:(isSubmission ? @"postfont" : @"commentfont")] == nil) {
|
||||
fontName = isSubmission ? @"AvenirNext-DemiBold" : @"AvenirNext-Medium";
|
||||
} else {
|
||||
fontName = [userDefaults stringForKey:(isSubmission ? @"postfont" : @"commentfont")];
|
||||
@ -37,14 +38,14 @@ NSString *slidePostOverrideBodyHtml;
|
||||
|
||||
UIFont *font = [UIFont fontWithName:fontName size:fontSize];
|
||||
|
||||
if (!font){
|
||||
if (!font) {
|
||||
font = [UIFont systemFontOfSize:fontSize];
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
+(UIFont *) boldFontOfSize:(CGFloat) size submission:(BOOL) isSubmission willOffset:(BOOL) willOffset {
|
||||
+ (UIFont *)boldFontOfSize:(CGFloat)size submission:(BOOL)isSubmission willOffset:(BOOL)willOffset {
|
||||
UIFont *font = [self fontOfSize:size submission:isSubmission willOffset:willOffset];
|
||||
|
||||
if ([font.fontName isEqualToString:[UIFont systemFontOfSize:10].fontName]){
|
||||
@ -60,15 +61,15 @@ NSString *slidePostOverrideBodyHtml;
|
||||
}
|
||||
}
|
||||
|
||||
+(UIFont *) italicFontOfSize:(CGFloat) size submission:(BOOL) isSubmission willOffset:(BOOL) willOffset {
|
||||
+ (UIFont *)italicFontOfSize:(CGFloat)size submission:(BOOL)isSubmission willOffset:(BOOL)willOffset {
|
||||
UIFont *font = [self fontOfSize:size submission:isSubmission willOffset:willOffset];
|
||||
|
||||
if ([font.fontName isEqualToString:[UIFont systemFontOfSize:10].fontName]){
|
||||
if ([font.fontName isEqualToString:[UIFont systemFontOfSize:10].fontName]) {
|
||||
return [UIFont italicSystemFontOfSize:font.pointSize];
|
||||
} else {
|
||||
UIFontDescriptor *desc = [font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic];
|
||||
|
||||
if (desc == nil){
|
||||
if (desc == nil) {
|
||||
return font;
|
||||
} else {
|
||||
return [UIFont fontWithDescriptor:desc size: 0];
|
||||
@ -81,7 +82,7 @@ NSString *slidePostOverrideBodyHtml;
|
||||
|
||||
@implementation ColorUtil
|
||||
|
||||
+(UIColor *) accentColorForSub:(NSString *) subreddit{
|
||||
+ (UIColor *)accentColorForSub:(NSString *)subreddit {
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSData *colorData = [userDefaults dataForKey:[NSString stringWithFormat:@"accent+%@", subreddit]];
|
||||
UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData];
|
||||
@ -90,7 +91,7 @@ NSString *slidePostOverrideBodyHtml;
|
||||
} else {
|
||||
UIColor *baseAccentColor = [NSKeyedUnarchiver unarchiveObjectWithData:[userDefaults dataForKey:@"accentcolor"]];
|
||||
|
||||
if (baseAccentColor){
|
||||
if (baseAccentColor) {
|
||||
return baseAccentColor;
|
||||
} else {
|
||||
return [UIColor colorWithRed:0.161 green:0.475 blue:1.0 alpha:1.0];
|
||||
@ -98,7 +99,7 @@ NSString *slidePostOverrideBodyHtml;
|
||||
}
|
||||
}
|
||||
|
||||
+(UIColor *) fontColorForTheme:(NSString *)theme{
|
||||
+ (UIColor *)fontColorForTheme:(NSString *)theme {
|
||||
UIColor *fontColor;
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
@ -142,7 +143,7 @@ NSString *slidePostOverrideBodyHtml;
|
||||
return fontColor;
|
||||
}
|
||||
|
||||
+(UIColor *) backgroundColorForTheme:(NSString *) theme{
|
||||
+ (UIColor *)backgroundColorForTheme:(NSString *)theme {
|
||||
UIColor *backgroundColor;
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
@ -216,7 +217,7 @@ static UIButton *createUndeleteButton(){
|
||||
%hook UIColor
|
||||
|
||||
%new
|
||||
+(UIColor *) colorWithHex:(NSString *) arg1 {
|
||||
+ (UIColor *)colorWithHex:(NSString *)arg1 {
|
||||
if (!arg1){
|
||||
NSString *firstChar = [arg1 substringToIndex:1];
|
||||
if ([firstChar isEqualToString:@"#"]){
|
||||
@ -234,7 +235,7 @@ static UIButton *createUndeleteButton(){
|
||||
}
|
||||
|
||||
%new
|
||||
-(NSString *) hexString {
|
||||
- (NSString *)hexString {
|
||||
const CGFloat *components = CGColorGetComponents(self.CGColor);
|
||||
|
||||
CGFloat r = components[0];
|
||||
@ -249,32 +250,32 @@ static UIButton *createUndeleteButton(){
|
||||
|
||||
%hook CommentDepthCell
|
||||
|
||||
-(void) doShortClick{
|
||||
- (void)doShortClick {
|
||||
%orig;
|
||||
|
||||
[self addUndeleteButtonToMenu];
|
||||
}
|
||||
|
||||
-(void) doLongClick {
|
||||
- (void)doLongClick {
|
||||
%orig;
|
||||
|
||||
[self addUndeleteButtonToMenu];
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) addUndeleteButtonToMenu{
|
||||
- (void)addUndeleteButtonToMenu {
|
||||
|
||||
NSString *commentBody = [MSHookIvar<id>(self, "comment") body];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:commentBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
|
||||
id controller = MSHookIvar<id>(self, "parent");
|
||||
|
||||
if (MSHookIvar<id>(controller, "menuCell")){
|
||||
if (MSHookIvar<id>(controller, "menuCell")) {
|
||||
|
||||
UIStackView *menu = MSHookIvar<UIStackView *>(self, "menu");
|
||||
|
||||
if (![[[[menu arrangedSubviews] lastObject] actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] containsObject:@"handleUndeleteComment:"]){
|
||||
if (![[[[menu arrangedSubviews] lastObject] actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] containsObject:@"handleUndeleteComment:"]) {
|
||||
UIButton *undeleteButton = createUndeleteButton();
|
||||
[undeleteButton addTarget:self action:@selector(handleUndeleteComment:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
@ -285,7 +286,7 @@ static UIButton *createUndeleteButton(){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeleteComment:(id) sender{
|
||||
- (void)handleUndeleteComment:(id)sender {
|
||||
|
||||
[sender setEnabled:NO];
|
||||
|
||||
@ -295,7 +296,7 @@ static UIButton *createUndeleteButton(){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeleteCommentAction:(NSDictionary *) data{
|
||||
- (void)completeUndeleteCommentAction:(NSDictionary *)data {
|
||||
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
id textStackDisplayView = MSHookIvar<id>(self, "commentBody");
|
||||
@ -330,21 +331,21 @@ static UIButton *createUndeleteButton(){
|
||||
[htmlAttributedString removeAttribute:@"CTForegroundColorFromContext" range:htmlStringRange];
|
||||
|
||||
[htmlAttributedString enumerateAttributesInRange:htmlStringRange options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) {
|
||||
for (NSString *key in attributes){
|
||||
for (NSString *key in attributes) {
|
||||
|
||||
if ([(UIColor *) attributes[key] isKindOfClass:[UIColor class]]){
|
||||
if ([(UIColor *) attributes[key] isKindOfClass:[UIColor class]]) {
|
||||
UIColor *attrColor = (UIColor *) attributes[key];
|
||||
if ([[attrColor hexString] isEqualToString:@"#0000FF"]){
|
||||
if ([[attrColor hexString] isEqualToString:@"#0000FF"]) {
|
||||
UIFont *tempFont = [UIFont fontWithName:@"Courier" size:font.pointSize];
|
||||
|
||||
[htmlAttributedString setAttributes:@{NSForegroundColorAttributeName: accentColor, NSBackgroundColorAttributeName: [%c(ColorUtil) backgroundColorForTheme:themeName], NSFontAttributeName: (tempFont ? tempFont : font)} range:range];
|
||||
} else if ([[attrColor hexString] isEqualToString:@"#008000"]) {
|
||||
[htmlAttributedString setAttributes:@{NSForegroundColorAttributeName: fontColor, NSFontAttributeName:font} range:range];
|
||||
}
|
||||
} else if ([(NSURL *) attributes[key] isKindOfClass:[NSURL class]]){
|
||||
} else if ([(NSURL *) attributes[key] isKindOfClass:[NSURL class]]) {
|
||||
NSURL *attrUrl = (NSURL *)attributes[key];
|
||||
|
||||
if (([userDefaults objectForKey:@"ENLARGE_LINKS"] == nil) ? YES : [userDefaults boolForKey:@"ENLARGE_LINKS"]){
|
||||
if (([userDefaults objectForKey:@"ENLARGE_LINKS"] == nil) ? YES : [userDefaults boolForKey:@"ENLARGE_LINKS"]) {
|
||||
[htmlAttributedString addAttribute:NSFontAttributeName value:[%c(FontGenerator) boldFontOfSize:18 submission:NO willOffset:YES] range:range];
|
||||
}
|
||||
|
||||
@ -360,7 +361,7 @@ static UIButton *createUndeleteButton(){
|
||||
}];
|
||||
|
||||
[htmlAttributedString beginEditing];
|
||||
[htmlAttributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, [htmlAttributedString length]) options:0 usingBlock:^(id value, NSRange range, BOOL *stop){
|
||||
[htmlAttributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, [htmlAttributedString length]) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
|
||||
|
||||
UIFont *attrFont = (UIFont *)value;
|
||||
|
||||
@ -401,7 +402,7 @@ static UIButton *createUndeleteButton(){
|
||||
|
||||
%hook RSubmission
|
||||
|
||||
-(id) author{
|
||||
- (id)author {
|
||||
if (shouldSlideOverridePostInfo){
|
||||
return slidePostOverrideAuthor;
|
||||
} else {
|
||||
@ -409,7 +410,7 @@ static UIButton *createUndeleteButton(){
|
||||
}
|
||||
}
|
||||
|
||||
-(id) htmlBody{
|
||||
- (id)htmlBody {
|
||||
if (shouldSlideOverridePostInfo){
|
||||
return slidePostOverrideBodyHtml;
|
||||
}
|
||||
@ -424,7 +425,7 @@ static UIButton *createUndeleteButton(){
|
||||
%hook CommentViewController
|
||||
%property(strong, nonatomic) UIButton *undeleteButton;
|
||||
|
||||
-(void) viewDidLoad {
|
||||
- (void)viewDidLoad {
|
||||
%orig;
|
||||
|
||||
shouldSlideOverridePostInfo = NO;
|
||||
@ -437,17 +438,17 @@ static UIButton *createUndeleteButton(){
|
||||
[self setUndeleteButton:undeleteButton];
|
||||
}
|
||||
|
||||
-(void) viewDidLayoutSubviews{
|
||||
- (void)viewDidLayoutSubviews {
|
||||
%orig;
|
||||
|
||||
if ([self undeleteButton]){
|
||||
if ([self shouldAddUndeleteButtonToToolbar]){
|
||||
if ([self undeleteButton]) {
|
||||
if ([self shouldAddUndeleteButtonToToolbar]) {
|
||||
[self addUndeleteButtonToToolbar];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(void) loadAll:(id) arg1{
|
||||
- (void)loadAll:(id)arg1 {
|
||||
%orig;
|
||||
|
||||
if ([self undeleteButton]){
|
||||
@ -458,14 +459,14 @@ static UIButton *createUndeleteButton(){
|
||||
}
|
||||
|
||||
%new
|
||||
-(BOOL) shouldAddUndeleteButtonToToolbar{
|
||||
- (BOOL)shouldAddUndeleteButtonToToolbar {
|
||||
id post = MSHookIvar<id>(self, "submission");
|
||||
|
||||
if ([post isSelf]){
|
||||
if ([post isSelf]) {
|
||||
|
||||
NSString *postBody = [post body];
|
||||
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]){
|
||||
if ([%c(TFHelper) shouldShowUndeleteButtonWithInfo:postBody isDeletedOnly:isTFDeletedOnly]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
@ -474,23 +475,23 @@ static UIButton *createUndeleteButton(){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) addUndeleteButtonToToolbar{
|
||||
- (void)addUndeleteButtonToToolbar {
|
||||
UIToolbar *toolbar = [[self navigationController] toolbar];
|
||||
NSMutableArray *toolbarItems = [[toolbar items] mutableCopy];
|
||||
UIView *firstView = [toolbarItems[0] customView];
|
||||
|
||||
if (firstView){
|
||||
if (firstView) {
|
||||
UIColor *tintColor = [toolbar tintColor];
|
||||
|
||||
UIButton *undeleteButton = [self undeleteButton];
|
||||
[undeleteButton setTintColor:tintColor];
|
||||
|
||||
if ([firstView isMemberOfClass:[UIView class]]){
|
||||
if ([firstView isMemberOfClass:[UIView class]]) {
|
||||
if (![undeleteButton isDescendantOfView:firstView]){
|
||||
[firstView addSubview:undeleteButton];
|
||||
[undeleteButton setFrame:firstView.bounds];
|
||||
}
|
||||
} else if ([firstView isMemberOfClass:[UIButton class]] && undeleteButton != firstView){
|
||||
} else if ([firstView isMemberOfClass:[UIButton class]] && undeleteButton != firstView) {
|
||||
UIBarButtonItem *undeleteItem = [[UIBarButtonItem alloc] initWithCustomView:undeleteButton];
|
||||
|
||||
[toolbarItems insertObject:toolbarItems[1] atIndex:0];
|
||||
@ -501,7 +502,7 @@ static UIButton *createUndeleteButton(){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) handleUndeletePost:(id) sender{
|
||||
- (void)handleUndeletePost:(id)sender {
|
||||
shouldSlideOverridePostInfo = YES;
|
||||
|
||||
[sender setEnabled:NO];
|
||||
@ -510,7 +511,7 @@ static UIButton *createUndeleteButton(){
|
||||
}
|
||||
|
||||
%new
|
||||
-(void) completeUndeletePostAction:(NSDictionary *) data{
|
||||
- (void)completeUndeletePostAction:(NSDictionary *)data {
|
||||
|
||||
slidePostOverrideAuthor = data[@"author"];
|
||||
slidePostOverrideBodyHtml = [%c(MMMarkdown) HTMLStringWithMarkdown:data[@"body"] extensions:MMMarkdownExtensionsGitHubFlavored error:nil];
|
||||
@ -529,26 +530,13 @@ static void loadPrefs(){
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/User/Library/Preferences/com.lint.undelete.prefs.plist"];
|
||||
|
||||
if (prefs){
|
||||
|
||||
if ([prefs objectForKey:@"isSlideEnabled"] != nil){
|
||||
isSlideEnabled = [[prefs objectForKey:@"isSlideEnabled"] boolValue];
|
||||
} else {
|
||||
isSlideEnabled = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"isTFDeletedOnly"] != nil){
|
||||
isTFDeletedOnly = [[prefs objectForKey:@"isTFDeletedOnly"] boolValue];
|
||||
} else {
|
||||
isTFDeletedOnly = YES;
|
||||
}
|
||||
|
||||
if ([prefs objectForKey:@"requestTimeoutValue"] != nil){
|
||||
pushshiftRequestTimeoutValue = [[prefs objectForKey:@"requestTimeoutValue"] doubleValue];
|
||||
} else {
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
}
|
||||
isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES;
|
||||
isSlideEnabled = [prefs objectForKey:@"isSlideEnabled"] ? [[prefs objectForKey:@"isSlideEnabled"] boolValue] : YES;
|
||||
isTFDeletedOnly = [prefs objectForKey:@"isTFDeletedOnly"] ? [[prefs objectForKey:@"isTFDeletedOnly"] boolValue] : YES;
|
||||
pushshiftRequestTimeoutValue = [prefs objectForKey:@"requestTimeoutValue"] ? [[prefs objectForKey:@"requestTimeoutValue"] doubleValue] : 10;
|
||||
|
||||
} else {
|
||||
isEnabled = YES;
|
||||
isSlideEnabled = YES;
|
||||
isTFDeletedOnly = YES;
|
||||
pushshiftRequestTimeoutValue = 10;
|
||||
@ -566,9 +554,9 @@ static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStrin
|
||||
NSString* processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
if ([processName isEqualToString:@"Slide for Reddit"]){
|
||||
if (isSlideEnabled){
|
||||
if (isSlideEnabled && isEnabled){
|
||||
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)prefsChanged, CFSTR("com.lint.undelete.prefs.changed"), NULL, CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
%init(Slide, CommentDepthCell = objc_getClass("Slide_for_Reddit.CommentDepthCell"), RSubmission = objc_getClass("Slide_for_Reddit.RSubmission"), CommentViewController = objc_getClass("Slide_for_Reddit.CommentViewController"));
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
|
||||
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
|
||||
|
||||
@interface TFHelper : NSObject
|
||||
|
||||
+(void) getUndeleteDataWithID:(NSString *) ident isComment:(BOOL) isComment timeout:(CGFloat) timeout extraData:(NSDictionary *) extra completionTarget:(id) target completionSelector:(SEL) sel;
|
||||
+(BOOL) shouldShowUndeleteButtonWithInfo:(NSString *) content isDeletedOnly:(BOOL) isDeletedOnly;
|
||||
+ (void)getUndeleteDataWithID:(NSString *)ident isComment:(BOOL)isComment timeout:(CGFloat)timeout extraData:(NSDictionary *)extra completionTarget:(id)target completionSelector:(SEL)sel;
|
||||
+ (BOOL)shouldShowUndeleteButtonWithInfo:(NSString *)content isDeletedOnly:(BOOL)isDeletedOnly;
|
||||
|
||||
@end
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
@implementation TFHelper
|
||||
|
||||
+(void) getUndeleteDataWithID:(NSString *) ident isComment:(BOOL) isComment timeout:(CGFloat) timeout extraData:(NSDictionary *) extra completionTarget:(id) target completionSelector:(SEL) sel{
|
||||
+ (void)getUndeleteDataWithID:(NSString *)ident isComment:(BOOL)isComment timeout:(CGFloat)timeout extraData:(NSDictionary *)extra completionTarget:(id)target completionSelector:(SEL)sel {
|
||||
|
||||
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
||||
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
|
||||
|
Reference in New Issue
Block a user