diff --git a/Theos/Classes/Exts.h b/Theos/Classes/Exts.h index 420ceb6..9e03f01 100644 --- a/Theos/Classes/Exts.h +++ b/Theos/Classes/Exts.h @@ -8,4 +8,8 @@ @interface NSUserDefaults (Colors) - (void)setColor:(UIColor*)color forKey:(NSString*)key; - (UIColor*)colorForKey:(NSString*)key; +@end + +@interface UIView (FindUIViewController) +- (UIViewController *) firstAvailableUIViewController; @end \ No newline at end of file diff --git a/Theos/Classes/Exts.m b/Theos/Classes/Exts.m index 16b3ee3..9860bec 100644 --- a/Theos/Classes/Exts.m +++ b/Theos/Classes/Exts.m @@ -43,4 +43,18 @@ - (UIColor*)colorForKey:(NSString*)key{ } return nil; } +@end + +@implementation UIView (FindUIViewController) +- (UIViewController *) firstAvailableUIViewController { + UIResponder *responder = [self nextResponder]; + while (responder != nil) { + if ([responder isKindOfClass:[UIViewController class]]) { + return (UIViewController *)responder; + } + responder = [responder nextResponder]; + } + return nil; +} + @end \ No newline at end of file diff --git a/Theos/Classes/JDESettingsManager.m b/Theos/Classes/JDESettingsManager.m index 163895a..3fd7aea 100644 --- a/Theos/Classes/JDESettingsManager.m +++ b/Theos/Classes/JDESettingsManager.m @@ -82,9 +82,13 @@ - (NSDictionary*)cellInfoForPath:(NSIndexPath*)indexPath{ case 6: info = @{ @"title": [self localizedStringForKey:@"screenshot_protection"], - @"desc": [self localizedStringForKey:@"screenshot_protection_desc"], @"image": [UIImage systemImageNamed:@"bell.slash"] }; break; + case 7: + info = @{ + @"title": [self localizedStringForKey:@"detect_links"], + @"image": [UIImage systemImageNamed:@"link"] + }; break; } break; case 1: @@ -105,6 +109,11 @@ - (NSDictionary*)cellInfoForPath:(NSIndexPath*)indexPath{ @"title": [self localizedStringForKey:@"logs"], @"image": [UIImage systemImageNamed:@"doc.text"] }; break; + case 3: + info = @{ + @"title": @"Theming", + @"image": [UIImage systemImageNamed:@"scribble"] + }; break; } } return info; diff --git a/Theos/Headers/ZSWTappableLabel.h b/Theos/Headers/ZSWTappableLabel.h new file mode 100644 index 0000000..e29ed8d --- /dev/null +++ b/Theos/Headers/ZSWTappableLabel.h @@ -0,0 +1,36 @@ +// +// ZSWTappableLabel.h +// ZSWTappableLabel +// +// Copyright (c) 2019 Zachary West. All rights reserved. +// +// MIT License +// https://github.com/zacwest/ZSWTappableLabel +// + +#import + + + +NS_ASSUME_NONNULL_BEGIN +@interface ZSWTappableLabel : UILabel +@end +#pragma mark - Attributes you include in strings + +NSAttributedStringKey const ZSWTappableLabelHighlightedBackgroundAttributeName + NS_SWIFT_NAME(tappableHighlightedBackgroundColor) = @"ZSWTappableLabelHighlightedBackgroundAttributeName"; + +NSAttributedStringKey const ZSWTappableLabelHighlightedForegroundAttributeName + NS_SWIFT_NAME(tappableHighlightedForegroundColor) = @"ZSWTappableLabelHighlightedForegroundAttributeName"; + +NSAttributedStringKey const ZSWTappableLabelTappableRegionAttributeName + NS_SWIFT_NAME(tappableRegion) = @"ZSWTappableLabelTappableRegionAttributeName"; + +@protocol ZSWTappableLabelTapDelegate + +- (void)tappableLabel:(ZSWTappableLabel *)tappableLabel + tappedAtIndex:(NSInteger)idx + withAttributes:(NSDictionary *)attributes; +@end + +NS_ASSUME_NONNULL_END diff --git a/Theos/JDEViewController.m b/Theos/JDEViewController.m index 0ac3bbb..4806fff 100644 --- a/Theos/JDEViewController.m +++ b/Theos/JDEViewController.m @@ -97,7 +97,7 @@ - (void)openLinkForIndexPath:(NSIndexPath*)indexPath{ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if(section == 0){ return 7;} + if(section == 0){ return 8;} return 4; } @@ -195,10 +195,6 @@ - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForR UIImage *icon = [UIImage resizeImageFromImage:infoDict[@"image"] withSize:CGSizeMake(25, 25)]; cell.imageView.image = icon; } - else if (indexPath.row == 3) { - cell.imageView.image = [UIImage systemImageNamed:@"scribble"]; - cell.textLabel.text = @"Theming"; - } } [NSLayoutConstraint activateConstraints:consts]; diff --git a/Theos/Tweak.h b/Theos/Tweak.h index e93911d..aa55d58 100644 --- a/Theos/Tweak.h +++ b/Theos/Tweak.h @@ -3,6 +3,8 @@ #import #import "JDEViewController.h" #import "Headers/AppHaptic.h" +#import "Headers/ZSWTappableLabel.h" +#import @interface PictureFeedViewController : UIViewController @property (weak, nonatomic, readwrite) UIButton *addReactionButton; @@ -25,7 +27,8 @@ @interface JDLFeedTableViewSource //Its both delegate and dataSource. BLKFlexibleHeightBar forwards calls to it @end -@interface JDLPostDetailsPostCellV2 : UITableViewCell +@interface JDLPostDetailsPostCell : UITableViewCell + - (id)contentLabel; - (void)setContentLabel:(id)contentLabel; @end @@ -45,3 +48,8 @@ - (void)upvoteTap:(id)sender; - (UIViewController *) firstAvailableUIViewController:(UIView*)view; //Getting the VC to show an alert @end + +@interface TappableLabel : UILabel +@end +@interface FeedCellTappableLabelDelegate : NSObject +@end \ No newline at end of file diff --git a/Theos/Tweak.x b/Theos/Tweak.x index 4278a4c..b18136b 100644 --- a/Theos/Tweak.x +++ b/Theos/Tweak.x @@ -310,7 +310,7 @@ //Copying for sub posts else if([cellClass isEqualToString:@"Jodel.JDLPostDetailsPostCell"]){ //Change cell type to access methods interfaced methods - JDLPostDetailsPostCellV2 *cell = [tableView cellForRowAtIndexPath:indexPath]; + JDLPostDetailsPostCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UIPasteboard.generalPasteboard.string = [[cell contentLabel] text]; [[JDESettingsManager sharedInstance] logString:[NSString stringWithFormat:@"Successfully copied for (%@)", cellClass]]; } @@ -329,8 +329,46 @@ } %end +%hook TappableLabel +-(void)setAttributedText:(NSAttributedString *)arg1{ + NSMutableAttributedString *newAttributedString = [[NSMutableAttributedString alloc] initWithAttributedString:arg1]; + if([[JDESettingsManager sharedInstance] featureStateForTag:7]){ + NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil]; + [detector enumerateMatchesInString:arg1.string options:0 range:NSMakeRange(0, arg1.string.length) + usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { + NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; + attributes[ZSWTappableLabelTappableRegionAttributeName] = @YES; + attributes[ZSWTappableLabelHighlightedBackgroundAttributeName] = UIColor.lightGrayColor; + attributes[ZSWTappableLabelHighlightedForegroundAttributeName] = UIColor.whiteColor; + attributes[NSUnderlineStyleAttributeName] = @(NSUnderlineStyleSingle); + attributes[@"NSTextCheckingResult"] = result; + [newAttributedString addAttributes:attributes range:result.range]; + }]; + } + + %orig(newAttributedString); + +} +%end + +%hook FeedCellTappableLabelDelegate +- (void)tappableLabel:(ZSWTappableLabel *)tappableLabel tappedAtIndex:(NSInteger)idx withAttributes:(NSDictionary *)attributes{ + if([[JDESettingsManager sharedInstance] featureStateForTag:7]){ + NSTextCheckingResult *result = attributes[@"NSTextCheckingResult"]; + if(result.resultType == NSTextCheckingTypeLink){ + UIViewController *presentationController = [tappableLabel firstAvailableUIViewController]; + if (presentationController != nil){ + SFSafariViewController *inApp = [[SFSafariViewController alloc] initWithURL:result.URL]; + [presentationController presentViewController:inApp animated:YES completion:nil]; + } + } + } + %orig; +} +%end + //DON'T DELETE WILL BREAK ABOVE METHOD -%hook JDLPostDetailsPostCellV2 +%hook JDLPostDetailsPostCell %end %hook UIColor @@ -350,10 +388,12 @@ PictureFeedViewController=objc_getClass("Jodel.PictureFeedViewController"), ScreenshotService=objc_getClass("Jodel.ScreenshotService"), FeedCellVoteView=objc_getClass("Jodel.JDLFeedCellVoteView"), - JDLPostDetailsPostCellV2=objc_getClass("Jodel.JDLPostDetailsPostCellV2"), + JDLPostDetailsPostCell=objc_getClass("Jodel.JDLPostDetailsPostCell"), ChatboxViewController=objc_getClass("Jodel.ChatboxViewController"), JDLFeedTableViewSource=objc_getClass("Jodel.JDLFeedTableViewSource"), MainFeedViewController=objc_getClass("Jodel.MainFeedViewController"), - ImageCaptureViewController=objc_getClass("Jodel.ImageCaptureViewController")); + ImageCaptureViewController=objc_getClass("Jodel.ImageCaptureViewController"), + TappableLabel=objc_getClass("Jodel.TappableLabel"), + FeedCellTappableLabelDelegate=objc_getClass("Jodel.FeedCellTappableLabelDelegate")); } diff --git a/Theos/layout/DEBIAN/control b/Theos/layout/DEBIAN/control index ccd1bdf..d5772ff 100644 --- a/Theos/layout/DEBIAN/control +++ b/Theos/layout/DEBIAN/control @@ -1,6 +1,6 @@ Package: dev.extbh.jodelemproved Name: Jodel EMPROVED -Version: 1.1.4-1 +Version: 1.1.5 Architecture: iphoneos-arm Description: Customizing the Jodel app Depiction: https://repo.depiction.extbh.dev/dev.extbh.jodelemproved/ diff --git a/Theos/layout/Library/Application Support/Jodel EMPROVED.bundle/Contents/Resources/ar.lproj/Localizable.strings b/Theos/layout/Library/Application Support/Jodel EMPROVED.bundle/Contents/Resources/ar.lproj/Localizable.strings index 0c42353..93ec268 100644 --- a/Theos/layout/Library/Application Support/Jodel EMPROVED.bundle/Contents/Resources/ar.lproj/Localizable.strings +++ b/Theos/layout/Library/Application Support/Jodel EMPROVED.bundle/Contents/Resources/ar.lproj/Localizable.strings @@ -29,17 +29,13 @@ "confirm_replies" = "تأكيد الردود"; "screenshot_protection" = "حماية تصوير الشاشة"; "tracking_protection" = "حماية التتبع"; +"detect_links" = "فتح الروابط"; ///More Section "source_code" = "السورس كود"; "twitter" = "ExTBH"; "logs" = "لوقات الاداه"; -//Settings description -"copy_paste_desc" = "تتفعل بالضفط المطول, تحتاج إلى ريستارت للتغيير"; -"screenshot_protection_desc" = "أخذ صور للشاشة بدون تنبيه"; -"tracking_protection_desc" = "إيقاف التتبع للخصوصية"; - //Confirm Alerts "confirm_reply_title" = "تأكيد الرد"; "confirm_reply_ok" = "أرسل"; diff --git a/Theos/layout/Library/Application Support/Jodel EMPROVED.bundle/Contents/Resources/en.lproj/Localizable.strings b/Theos/layout/Library/Application Support/Jodel EMPROVED.bundle/Contents/Resources/en.lproj/Localizable.strings index f736137..78c9169 100644 --- a/Theos/layout/Library/Application Support/Jodel EMPROVED.bundle/Contents/Resources/en.lproj/Localizable.strings +++ b/Theos/layout/Library/Application Support/Jodel EMPROVED.bundle/Contents/Resources/en.lproj/Localizable.strings @@ -29,17 +29,13 @@ "confirm_replies" = "Confirm Replies"; "screenshot_protection" = "Screenshot Protection"; "tracking_protection" = "Tracking Protection"; +"detect_links" = "Detect Links in text"; ///More Section "source_code" = "Source Code"; "twitter" = "ExTBH"; "logs" = "Tweak Logs"; -//Settings description -"copy_paste_desc" = "Activates by long press, needs restart for changes"; -"screenshot_protection_desc" = "Takes screenshot without anyone knowing"; -"tracking_protection_desc" = "No more tracking"; - //Confirm Alerts "confirm_reply_title" = "Confirm Reply"; "confirm_reply_ok" = "Reply";