From 0c8aea88873bd5d1d7602e33f0b3f9651c095e7b Mon Sep 17 00:00:00 2001 From: BandarHelal <31299470+BandarHL@users.noreply.github.com> Date: Tue, 29 Aug 2023 06:59:37 +0300 Subject: [PATCH] Update 4.0 - Add stopHidingTabBar - Add advancedSearch - Add change Background of direct msg - Fix removing trackingParams from url - Fix show images as Full frame - Remove unnecessary options --- BHTwitter.xcodeproj/project.pbxproj | 52 ++++----- BHTwitter/BHTBundle.m | 2 + BHTwitter/BHTManager.h | 7 +- BHTwitter/BHTManager.m | 21 ++-- BHTwitter/BHTwitter-Prefix.pch | 2 +- BHTwitter/BHTwitter.x | 107 +++++++++--------- BHTwitter/Package/DEBIAN/control | 4 +- .../BHT/BHTwitter.bundle/Info.plist | Bin 536 -> 534 bytes .../ar.lproj/Localizable.strings | 12 ++ .../en.lproj/Localizable.strings | 13 +++ .../es.lproj/Localizable.strings | 61 +++++----- .../ja.lproj/Localizable.strings | 5 +- .../ru.lproj/Localizable.strings | 5 + .../zh-Hant.lproj/Localizable.strings | 3 + .../zh_CN.lproj/Localizable.strings | 46 ++++++-- BHTwitter/SettingsViewController.m | 98 +++++++++++++--- BHTwitter/TWHeaders.h | 11 +- 17 files changed, 299 insertions(+), 150 deletions(-) diff --git a/BHTwitter.xcodeproj/project.pbxproj b/BHTwitter.xcodeproj/project.pbxproj index 04c55a4b..628e2cb3 100644 --- a/BHTwitter.xcodeproj/project.pbxproj +++ b/BHTwitter.xcodeproj/project.pbxproj @@ -45,15 +45,15 @@ 50EE4D4B286F7F70007DE117 /* BHColorThemeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50EE4D4A286F7F70007DE117 /* BHColorThemeViewController.swift */; }; 50F7929028A0EA22000A2269 /* BHTBundle.m in Sources */ = {isa = PBXBuildFile; fileRef = 50F7928E28A0EA22000A2269 /* BHTBundle.m */; }; 50F7929128A0EA22000A2269 /* BHTBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F7928F28A0EA22000A2269 /* BHTBundle.h */; }; - 50FAE057288545DB00CDCEB2 /* CepheiPrefs.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50FAE054288545DB00CDCEB2 /* CepheiPrefs.framework */; }; - 50FAE059288545DB00CDCEB2 /* Cephei.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50FAE055288545DB00CDCEB2 /* Cephei.framework */; }; - 50FAE05B288545DC00CDCEB2 /* CepheiUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50FAE056288545DB00CDCEB2 /* CepheiUI.framework */; }; 50FAE060288545F600CDCEB2 /* SettingsViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FAE05E288545F600CDCEB2 /* SettingsViewController.h */; }; 50FAE061288545F600CDCEB2 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 50FAE05F288545F600CDCEB2 /* SettingsViewController.m */; }; 91086148293001530011609E /* FLEX in Frameworks */ = {isa = PBXBuildFile; productRef = 91086147293001530011609E /* FLEX */; }; 9108614B293005750011609E /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = 9108614A293005750011609E /* JGProgressHUD */; }; 916CFDE12971A4CF00325345 /* BHTwitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 916CFDE02971A4CF00325345 /* BHTwitter.m */; }; - 916F1E1B2912F16D00865DD2 /* Preferences.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 916F1E1A2912F16D00865DD2 /* Preferences.framework */; }; + 91F030DC2A292C0E00A0CC36 /* CepheiPrefs.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F030D92A292C0E00A0CC36 /* CepheiPrefs.framework */; }; + 91F030DE2A292C0F00A0CC36 /* Cephei.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F030DA2A292C0E00A0CC36 /* Cephei.framework */; }; + 91F030E02A292C0F00A0CC36 /* CepheiUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F030DB2A292C0E00A0CC36 /* CepheiUI.framework */; }; + 91F030E42A292E8B00A0CC36 /* Preferences.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F030E32A292E8B00A0CC36 /* Preferences.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -90,7 +90,6 @@ 5020AA7824E759960080F292 /* SafariServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SafariServices.framework; path = System/Library/Frameworks/SafariServices.framework; sourceTree = SDKROOT; }; 5020AA7A24E7599B0080F292 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 5020AA7C24E759A20080F292 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; - 504C1C5A288F32050056F5EC /* Preferences.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Preferences.framework; path = ../../../../../opt/theos/sdks/iPhoneOS15.0.sdk/System/Library/PrivateFrameworks/Preferences.framework; sourceTree = ""; }; 505C0EBB2801ECAB0028D1C9 /* BHDownloadInlineButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BHDownloadInlineButton.h; sourceTree = ""; }; 505C0EBD2801ED020028D1C9 /* BHDownloadInlineButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BHDownloadInlineButton.m; sourceTree = ""; }; 505C0ED028038B810028D1C9 /* BHTwitter-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BHTwitter-Bridging-Header.h"; sourceTree = ""; }; @@ -102,13 +101,13 @@ 50EE4D4A286F7F70007DE117 /* BHColorThemeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BHColorThemeViewController.swift; sourceTree = ""; }; 50F7928E28A0EA22000A2269 /* BHTBundle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BHTBundle.m; sourceTree = ""; }; 50F7928F28A0EA22000A2269 /* BHTBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BHTBundle.h; sourceTree = ""; }; - 50FAE054288545DB00CDCEB2 /* CepheiPrefs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CepheiPrefs.framework; path = ../../../../../opt/theos/vendor/lib/CepheiPrefs.framework; sourceTree = ""; }; - 50FAE055288545DB00CDCEB2 /* Cephei.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cephei.framework; path = ../../../../../opt/theos/vendor/lib/Cephei.framework; sourceTree = ""; }; - 50FAE056288545DB00CDCEB2 /* CepheiUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CepheiUI.framework; path = ../../../../../opt/theos/vendor/lib/CepheiUI.framework; sourceTree = ""; }; 50FAE05E288545F600CDCEB2 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; 50FAE05F288545F600CDCEB2 /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; 916CFDE02971A4CF00325345 /* BHTwitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BHTwitter.m; sourceTree = ""; }; - 916F1E1A2912F16D00865DD2 /* Preferences.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Preferences.framework; path = ../../../../../opt/theos/sdks/iPhoneOS16.0.sdk/System/Library/PrivateFrameworks/Preferences.framework; sourceTree = ""; }; + 91F030D92A292C0E00A0CC36 /* CepheiPrefs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CepheiPrefs.framework; path = ../../../theos/vendor/lib/CepheiPrefs.framework; sourceTree = ""; }; + 91F030DA2A292C0E00A0CC36 /* Cephei.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cephei.framework; path = ../../../theos/vendor/lib/Cephei.framework; sourceTree = ""; }; + 91F030DB2A292C0E00A0CC36 /* CepheiUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CepheiUI.framework; path = ../../../theos/vendor/lib/CepheiUI.framework; sourceTree = ""; }; + 91F030E32A292E8B00A0CC36 /* Preferences.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Preferences.framework; path = ../../../theos/sdks/iPhoneOS16.4.sdk/System/Library/PrivateFrameworks/Preferences.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -121,23 +120,23 @@ 5020AA7D24E759A20080F292 /* QuartzCore.framework in Frameworks */, 91086148293001530011609E /* FLEX in Frameworks */, 5020AA7324E759860080F292 /* Photos.framework in Frameworks */, - 916F1E1B2912F16D00865DD2 /* Preferences.framework in Frameworks */, - 50FAE05B288545DC00CDCEB2 /* CepheiUI.framework in Frameworks */, 50D73502252CBFC6007838C7 /* SceneKit.framework in Frameworks */, 50D73500252CBFC1007838C7 /* libz.tbd in Frameworks */, + 91F030DE2A292C0F00A0CC36 /* Cephei.framework in Frameworks */, 5020AA6924E759700080F292 /* Accelerate.framework in Frameworks */, - 50FAE057288545DB00CDCEB2 /* CepheiPrefs.framework in Frameworks */, 9108614B293005750011609E /* JGProgressHUD in Frameworks */, 5020AA7124E7597F0080F292 /* ImageIO.framework in Frameworks */, 5020AA7524E7598D0080F292 /* CoreServices.framework in Frameworks */, 5020A87824E758E00080F292 /* UIKit.framework in Frameworks */, 5020AA7724E759910080F292 /* SystemConfiguration.framework in Frameworks */, + 91F030E42A292E8B00A0CC36 /* Preferences.framework in Frameworks */, 5020A87A24E758E00080F292 /* Foundation.framework in Frameworks */, 5020AA6D24E759790080F292 /* CoreImage.framework in Frameworks */, - 50FAE059288545DB00CDCEB2 /* Cephei.framework in Frameworks */, + 91F030DC2A292C0E00A0CC36 /* CepheiPrefs.framework in Frameworks */, 5020AA6E24E759790080F292 /* CoreMedia.framework in Frameworks */, 50D73504252CBFD0007838C7 /* libsqlite3.tbd in Frameworks */, 5020AA7B24E7599B0080F292 /* Security.framework in Frameworks */, + 91F030E02A292C0F00A0CC36 /* CepheiUI.framework in Frameworks */, 5020AA7924E759960080F292 /* SafariServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -180,11 +179,10 @@ 5020A87624E758E00080F292 /* Frameworks */ = { isa = PBXGroup; children = ( - 504C1C5A288F32050056F5EC /* Preferences.framework */, - 916F1E1A2912F16D00865DD2 /* Preferences.framework */, - 50FAE055288545DB00CDCEB2 /* Cephei.framework */, - 50FAE054288545DB00CDCEB2 /* CepheiPrefs.framework */, - 50FAE056288545DB00CDCEB2 /* CepheiUI.framework */, + 91F030E32A292E8B00A0CC36 /* Preferences.framework */, + 91F030DA2A292C0E00A0CC36 /* Cephei.framework */, + 91F030D92A292C0E00A0CC36 /* CepheiPrefs.framework */, + 91F030DB2A292C0E00A0CC36 /* CepheiUI.framework */, 50D73503252CBFCB007838C7 /* libsqlite3.tbd */, 50D73501252CBFC6007838C7 /* SceneKit.framework */, 50D734FF252CBFBD007838C7 /* libz.tbd */, @@ -566,16 +564,16 @@ DYLIB_CURRENT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - /opt/theos/lib, - /opt/theos/vendor/lib, - /opt/theos/sdks/iPhoneOS16.0.sdk/System/Library/PrivateFrameworks, + /Users/bandaralruwaili/theos/lib, + /Users/bandaralruwaili/theos/vendor/lib, + /Users/bandaralruwaili/theos/sdks/iPhoneOS16.4.sdk/System/Library/PrivateFrameworks, ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "BHTwitter/BHTwitter-Prefix.pch"; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = ""; INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -595,6 +593,7 @@ MonkeyDevDevicePort = ""; MonkeyDevInstallOnAnyBuild = YES; MonkeyDevInstallOnProfiling = YES; + MonkeyDevTheosPath = /Users/bandaralruwaili/theos; MonkeyDevkillProcessOnInstall = "Twitter || true"; OTHER_LDFLAGS = ""; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -630,16 +629,16 @@ DYLIB_CURRENT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - /opt/theos/lib, - /opt/theos/vendor/lib, - /opt/theos/sdks/iPhoneOS16.0.sdk/System/Library/PrivateFrameworks, + /Users/bandaralruwaili/theos/lib, + /Users/bandaralruwaili/theos/vendor/lib, + /Users/bandaralruwaili/theos/sdks/iPhoneOS16.4.sdk/System/Library/PrivateFrameworks, ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "BHTwitter/BHTwitter-Prefix.pch"; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = ""; INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -659,6 +658,7 @@ MonkeyDevDevicePort = ""; MonkeyDevInstallOnAnyBuild = YES; MonkeyDevInstallOnProfiling = YES; + MonkeyDevTheosPath = /Users/bandaralruwaili/theos; MonkeyDevkillProcessOnInstall = "Twitter || true"; OTHER_LDFLAGS = ""; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/BHTwitter/BHTBundle.m b/BHTwitter/BHTBundle.m index 1e36a317..ae023941 100644 --- a/BHTwitter/BHTBundle.m +++ b/BHTwitter/BHTBundle.m @@ -20,6 +20,8 @@ + (instancetype)sharedBundle { NSURL *bundlePath = [NSURL new]; if ([fileManager fileExistsAtPath:@"/Library/Application Support/BHT/BHTwitter.bundle"]) { bundlePath = [NSURL fileURLWithPath:@"/Library/Application Support/BHT/BHTwitter.bundle"]; + } else if ([fileManager fileExistsAtPath:@"/var/jb/Library/Application Support/BHT/BHTwitter.bundle"]) { + bundlePath = [NSURL fileURLWithPath:@"/var/jb/Library/Application Support/BHT/BHTwitter.bundle"]; } else { bundlePath = [[NSBundle mainBundle] URLForResource:@"BHTwitter" withExtension:@"bundle"]; } diff --git a/BHTwitter/BHTManager.h b/BHTwitter/BHTManager.h index 302a0ff7..f2f02fc7 100644 --- a/BHTwitter/BHTManager.h +++ b/BHTwitter/BHTManager.h @@ -21,9 +21,7 @@ + (BOOL)DownloadingVideos; + (BOOL)DirectSave; -+ (BOOL)VoiceFeature; + (BOOL)UndoTweet; -+ (BOOL)ReaderMode; + (BOOL)VideoZoom; + (BOOL)NoHistory; + (BOOL)BioTranslate; @@ -38,7 +36,6 @@ + (BOOL)changeFont; + (BOOL)FLEX; + (BOOL)autoHighestLoad; -+ (BOOL)DmModularSearch; + (BOOL)disableSensitiveTweetWarnings; + (BOOL)TwitterCircle; + (BOOL)showScrollIndicator; @@ -54,5 +51,9 @@ + (BOOL)stripTrackingParams; + (BOOL)disableImmersive; + (BOOL)alwaysFollowingPage; ++ (BOOL)stopHidingTabBar; ++ (BOOL)advancedSearch; ++ (BOOL)changeBackground; ++ (bool)backgroundImage; @end diff --git a/BHTwitter/BHTManager.m b/BHTwitter/BHTManager.m index 51f7d10d..960f5219 100644 --- a/BHTwitter/BHTManager.m +++ b/BHTwitter/BHTManager.m @@ -105,9 +105,6 @@ + (BOOL)DownloadingVideos { + (BOOL)DirectSave { return [[NSUserDefaults standardUserDefaults] boolForKey:@"direct_save"]; } -+ (BOOL)VoiceFeature { - return [[NSUserDefaults standardUserDefaults] boolForKey:@"voice"]; -} + (BOOL)LikeConfirm { return [[NSUserDefaults standardUserDefaults] boolForKey:@"like_con"]; } @@ -129,9 +126,6 @@ + (BOOL)DisableVODCaptions { + (BOOL)UndoTweet { return [[NSUserDefaults standardUserDefaults] boolForKey:@"undo_tweet"]; } -+ (BOOL)ReaderMode { - return [[NSUserDefaults standardUserDefaults] boolForKey:@"reader_mode"]; -} + (BOOL)VideoZoom { return [[NSUserDefaults standardUserDefaults] boolForKey:@"video_zoom"]; } @@ -159,9 +153,6 @@ + (BOOL)autoHighestLoad { + (BOOL)disableSensitiveTweetWarnings { return [[NSUserDefaults standardUserDefaults] boolForKey:@"disableSensitiveTweetWarnings"]; } -+ (BOOL)DmModularSearch { - return [[NSUserDefaults standardUserDefaults] boolForKey:@"DmModularSearch"]; -} + (BOOL)TwitterCircle { return [[NSUserDefaults standardUserDefaults] boolForKey:@"TrustedFriends"]; } @@ -204,6 +195,18 @@ + (BOOL)disableImmersive { + (BOOL)alwaysFollowingPage { return [[NSUserDefaults standardUserDefaults] boolForKey:@"always_following_page"]; } ++ (BOOL)stopHidingTabBar { + return [[NSUserDefaults standardUserDefaults] boolForKey:@"no_tab_bar_hiding"]; +} ++ (BOOL)advancedSearch { + return [[NSUserDefaults standardUserDefaults] boolForKey:@"advanced_search"]; +} ++ (BOOL)changeBackground { + return [[NSUserDefaults standardUserDefaults] boolForKey:@"change_msg_background"]; +} ++ (bool)backgroundImage { + return [[NSUserDefaults standardUserDefaults] boolForKey:@"background_image"]; +} + (UIViewController *)BHTSettingsWithAccount:(TFNTwitterAccount *)twAccount { SettingsViewController *pref = [[SettingsViewController alloc] initWithTwitterAccount:twAccount]; [pref.navigationItem setTitleView:[objc_getClass("TFNTitleView") titleViewWithTitle:@"BHTwitter" subtitle:twAccount.displayUsername]]; diff --git a/BHTwitter/BHTwitter-Prefix.pch b/BHTwitter/BHTwitter-Prefix.pch index ffc3ddc6..68167233 100644 --- a/BHTwitter/BHTwitter-Prefix.pch +++ b/BHTwitter/BHTwitter-Prefix.pch @@ -4,5 +4,5 @@ #ifdef __OBJC__ #import - #import "/opt/theos/Prefix.pch" //path/to/theos/Prefix.pch + #import "/Users/bandaralruwaili/theos/Prefix.pch" //path/to/theos/Prefix.pch #endif diff --git a/BHTwitter/BHTwitter.x b/BHTwitter/BHTwitter.x index 4372c982..958a7bbb 100644 --- a/BHTwitter/BHTwitter.x +++ b/BHTwitter/BHTwitter.x @@ -6,6 +6,7 @@ %config(generator=internal) +static bool didMoveToFollowingPage = false; static UIFont * _Nullable TAEStandardFontGroupReplacement(UIFont *self, SEL _cmd, CGFloat arg1, CGFloat arg2) { BH_BaseImp orig = originalFontsIMP[NSStringFromSelector(_cmd)].pointerValue; NSUInteger nArgs = [[self class] instanceMethodSignatureForSelector:_cmd].numberOfArguments; @@ -117,6 +118,48 @@ static void batchSwizzlingOnClass(Class cls, NSArray*origSelectors, I } } } + +- (void)setTabBarHidden:(BOOL)arg1 withDuration:(CGFloat)arg2 { + if ([BHTManager stopHidingTabBar]) { + return; + } + + return %orig; +} +- (void)setTabBarHidden:(BOOL)arg1 { + if ([BHTManager stopHidingTabBar]) { + return; + } + + return %orig; +} +%end + + +%hook T1DirectMessageConversationEntriesViewController +- (void)viewDidLoad { + %orig; + if ([BHTManager changeBackground]) { + if ([BHTManager backgroundImage]) { // set the backgeound as image + NSFileManager *manager = [NSFileManager defaultManager]; + NSString *DocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true).firstObject; + NSURL *imagePath = [[NSURL fileURLWithPath:DocPath] URLByAppendingPathComponent:@"msg_background.png"]; + + if ([manager fileExistsAtPath:imagePath.path]) { + UIImageView *backgroundImage = [[UIImageView alloc] initWithFrame:UIScreen.mainScreen.bounds]; + backgroundImage.image = [UIImage imageNamed:imagePath.path]; + [backgroundImage setContentMode:UIViewContentModeScaleAspectFill]; + [self.view insertSubview:backgroundImage atIndex:0]; + } + } + + if ([[NSUserDefaults standardUserDefaults] objectForKey:@"background_color"]) { // set the backgeound as color + NSString *hexCode = [[NSUserDefaults standardUserDefaults] objectForKey:@"background_color"]; + UIColor *selectedColor = [UIColor colorFromHexString:hexCode]; + self.view.backgroundColor = selectedColor; + } + } +} %end // MARK: Copy user information @@ -594,28 +637,6 @@ static void batchSwizzlingOnClass(Class cls, NSArray*origSelectors, I %end -// MARK: Always use Following page -%hook TFNScrollingHorizontalLabelView -- (NSUInteger)startingIndex { - if ([BHTManager alwaysFollowingPage]) { - UIViewController *Navigation = self.NearestViewController; - if ([Navigation.childViewControllers[0] isKindOfClass:%c(THFHomeTimelineContainerViewController)] || [Navigation.childViewControllers[0] isKindOfClass:%c(T1HomeTimelineContainerViewController)]) { - [self setValue:[NSNumber numberWithInteger:1] forKey:@"_startingIndex"]; - return 1; - } - } - return %orig; -} - -%new - (UIViewController *)NearestViewController { - UIResponder *responder = self; - while ([responder isKindOfClass:[UIView class]]) - responder = [responder nextResponder]; - return (UIViewController *)responder; -} -%end - - // MARK: Always open in Safrai // Thanks nyuszika7h https://github.com/nyuszika7h/noinappsafari/ %hook SFSafariViewController @@ -699,15 +720,15 @@ static void batchSwizzlingOnClass(Class cls, NSArray*origSelectors, I // Twitter save all the features and keys in side JSON file in bundle of application fs_embedded_defaults_production.json, and use it in TFNTwitterAccount class but with DM voice maybe developers forget to add boolean variable in the class, so i had to change it from the file. // also, you can find every key for every feature i used in this tweak, i can remove all the codes below and find every key for it but I'm lazy to do that, :) - (BOOL)boolForKey:(NSString *)key { - if ([BHTManager VoiceFeature] && [key isEqualToString:@"dm_voice_creation_enabled"]) { + if ([key isEqualToString:@"edit_tweet_enabled"] || [key isEqualToString:@"edit_tweet_ga_composition_enabled"] || [key isEqualToString:@"edit_tweet_pdp_dialog_enabled"] || [key isEqualToString:@"edit_tweet_upsell_enabled"]) { return true; } - if ([key isEqualToString:@"edit_tweet_enabled"] || [key isEqualToString:@"edit_tweet_ga_composition_enabled"] || [key isEqualToString:@"edit_tweet_pdp_dialog_enabled"] || [key isEqualToString:@"edit_tweet_upsell_enabled"]) { + if ([key isEqualToString:@"conversational_replies_ios_pinned_replies_consumption_enabled"] || [key isEqualToString:@"conversational_replies_ios_pinned_replies_creation_enabled"]) { return true; } - if ([key isEqualToString:@"conversational_replies_ios_pinned_replies_consumption_enabled"] || [key isEqualToString:@"conversational_replies_ios_pinned_replies_creation_enabled"]) { + if ([BHTManager advancedSearch] && [key isEqualToString:@"search_features_advanced_search_enabled"]) { return true; } @@ -722,7 +743,10 @@ static void batchSwizzlingOnClass(Class cls, NSArray*origSelectors, I // MARK: Force Tweets to show images as Full frame: https://github.com/BandarHL/BHTwitter/issues/101 %hook T1StandardStatusAttachmentViewAdapter - (NSUInteger)displayType { - return [BHTManager forceTweetFullFrame] ? 1 : %orig; + if (self.attachmentType == 2) { + return [BHTManager forceTweetFullFrame] ? 1 : %orig; + } + return %orig; } %end @@ -805,9 +829,6 @@ static void batchSwizzlingOnClass(Class cls, NSArray*origSelectors, I - (_Bool)isSensitiveTweetWarningsConsumeEnabled { return [BHTManager disableSensitiveTweetWarnings] ? false : %orig; } -- (_Bool)isDmModularSearchEnabled { - return [BHTManager DmModularSearch] ? true : %orig; -} - (_Bool)isVideoDynamicAdEnabled { return [BHTManager HidePromoted] ? false : %orig; } @@ -827,24 +848,6 @@ static void batchSwizzlingOnClass(Class cls, NSArray*origSelectors, I - (_Bool)isVideoZoomEnabled { return [BHTManager VideoZoom] ? true : %orig; } -- (_Bool)isDMVoiceRenderingEnabled { - return [BHTManager VoiceFeature] ? true : %orig; -} -- (_Bool)isDMVoiceCreationEnabled { - return [BHTManager VoiceFeature] ? true : %orig; -} -%end - -%hook T1PhotoMediaRailViewController -- (void)setVoiceButtonHidden:(BOOL)arg1 { - if ([BHTManager VoiceFeature]) { - arg1 = false; - } - return %orig(arg1); -} -- (BOOL)isVoiceButtonHidden { - return [BHTManager VoiceFeature] ? false : %orig; -} %end // MARK: Tweet confirm @@ -978,13 +981,6 @@ static void batchSwizzlingOnClass(Class cls, NSArray*origSelectors, I } %end -// MARK: Reader mode -%hook T1ReaderModeConfig -- (_Bool)isReaderModeEnabled { - return [BHTManager ReaderMode] ? true : %orig; -} -%end - // MARK: Old tweet style %hook TTACoreAnatomyFeatures - (BOOL)isUnifiedCardEnabled { @@ -1216,7 +1212,8 @@ static void batchSwizzlingOnClass(Class cls, NSArray*origSelectors, I static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ trackingParams = @{ - @"twitter.com" : @[@"s", @"t"] + @"twitter.com" : @[@"s", @"t"], + @"x.com" : @[@"s", @"t"], }; }); diff --git a/BHTwitter/Package/DEBIAN/control b/BHTwitter/Package/DEBIAN/control index bc5b266c..42048649 100644 --- a/BHTwitter/Package/DEBIAN/control +++ b/BHTwitter/Package/DEBIAN/control @@ -1,9 +1,9 @@ Package: com.bandarhl.BHTwitter Name: BHTwitter -Version: 3.9.1 +Version: 4.0 Description: Awesome tweak for Twitter Section: Tweaks -Depends: firmware (>= 13.0), mobilesubstrate, ws.hbang.common (>= 1.17) +Depends: firmware (>= 14.0), mobilesubstrate, ws.hbang.common (>= 1.17) Priority: optional Architecture: iphoneos-arm Author: BandarHelal diff --git a/BHTwitter/Package/Library/Application Support/BHT/BHTwitter.bundle/Info.plist b/BHTwitter/Package/Library/Application Support/BHT/BHTwitter.bundle/Info.plist index 89ae214409d16e9512946deed07875eb2a94c1c3..6dfaca87596434b09eff297abcde8b8bcf7beb9f 100644 GIT binary patch delta 32 ocmbQiGL2=!6h@X{6Fq~;vlv4;XE4rXT*A1Pal_;vjPi`T0H*8;kpKVy delta 34 qcmbQnGJ|Eq6h^jCV?9ef!^txkLpf(L&SzZ4xSny- +@interface SettingsViewController () @property (nonatomic, strong) TFNTwitterAccount *twAccount; @property (nonatomic, assign) BOOL hasDynamicSpecifiers; @property (nonatomic, retain) NSMutableDictionary *dynamicSpecifiers; @@ -150,8 +151,6 @@ - (NSArray *)specifiers { PSSpecifier *videoLayerCaption = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"DISABLE_VIDEO_LAYER_CAPTIONS_OPTION_TITLE"] detailTitle:nil key:@"dis_VODCaptions" defaultValue:false changeAction:nil]; - PSSpecifier *voice = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"VOICE_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"VOICE_OPTION_DETAIL_TITLE"] key:@"voice" defaultValue:true changeAction:nil]; - PSSpecifier *videoZoom = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"VIDEO_ZOOM_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"VIDEO_ZOOM_OPTION_DETAIL_TITLE"] key:@"video_zoom" defaultValue:false changeAction:nil]; PSSpecifier *noHistory = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"NO_HISTORY_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"NO_HISTORY_OPTION_DETAIL_TITLE"] key:@"no_his" defaultValue:false changeAction:nil]; @@ -166,8 +165,6 @@ - (NSArray *)specifiers { PSSpecifier *padLock = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"PADLOCK_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"PADLOCK_OPTION_DETAIL_TITLE"] key:@"padlock" defaultValue:false changeAction:nil]; - PSSpecifier *DmModularSearch = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"DN_MODULAR_SEARCH_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"DN_MODULAR_SEARCH_OPTION_DETAIL_TITLE"] key:@"DmModularSearch" defaultValue:false changeAction:nil]; - PSSpecifier *autoHighestLoad = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"AUTO_HIGHEST_LOAD_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"AUTO_HIGHEST_LOAD_OPTION_DETAIL_TITLE"] key:@"autoHighestLoad" defaultValue:true changeAction:nil]; PSSpecifier *disableSensitiveTweetWarnings = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"DISABLE_SENSITIVE_TWEET_WARNINGS_OPTION_TITLE"] detailTitle:nil key:@"disableSensitiveTweetWarnings" defaultValue:true changeAction:nil]; @@ -185,19 +182,23 @@ - (NSArray *)specifiers { PSSpecifier *alwaysOpenSafari = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ALWAYS_OPEN_SAFARI_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ALWAYS_OPEN_SAFARI_OPTION_DETAIL_TITLE"] key:@"openInBrowser" defaultValue:false changeAction:nil]; PSSpecifier *stripTrackingParams = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"STRIP_URL_TRACKING_PARAMETERS_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"STRIP_URL_TRACKING_PARAMETERS_DETAIL_TITLE"] key:@"strip_tracking_params" defaultValue:false changeAction:nil]; + + PSSpecifier *advancedSearch = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ADVANCED_SEARCH_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ADVANCED_SEARCH_DETAIL_TITLE"] key:@"advanced_search" defaultValue:false changeAction:nil]; // Twitter bule section PSSpecifier *undoTweet = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"UNDO_TWEET_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"UNDO_TWEET_OPTION_DETAIL_TITLE"] key:@"undo_tweet" defaultValue:false changeAction:nil]; - PSSpecifier *readerMode = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"READER_MODE_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"READER_MODE_OPTION_DETAIL_TITLE"] key:@"reader_mode" defaultValue:false changeAction:nil]; - PSSpecifier *appTheme = [self newButtonCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"THEME_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"THEME_OPTION_DETAIL_TITLE"] dynamicRule:nil action:@selector(showThemeViewController:)]; PSSpecifier *customTabBarVC = [self newButtonCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_TAB_BAR_OPTION_TITLE"] detailTitle:nil dynamicRule:nil action:@selector(showCustomTabBarVC:)]; // Layout customization section + PSSpecifier *customDirectBackgroundView = [self newButtonCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_DIRECT_BACKGROUND_VIEW_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_DIRECT_BACKGROUND_VIEW_DETAIL_TITLE"] dynamicRule:nil action:@selector(showCustomBackgroundViewViewController:)]; + PSSpecifier *origTweetStyle = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ORIG_TWEET_STYLE_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ORIG_TWEET_STYLE_OPTION_DETAIL_TITLE"] key:@"old_style" defaultValue:true changeAction:nil]; + PSSpecifier *stopHidingTabBar = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"STOP_HIDING_TAB_BAR_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"STOP_HIDING_TAB_BAR_DETAIL_TITLE"] key:@"no_tab_bar_hiding" defaultValue:false changeAction:nil]; + PSSpecifier *hideViewCount = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"HIDE_VIEW_COUNT_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"HIDE_VIEW_COUNT_OPTION_DETAIL_TITLE"] key:@"hide_view_count" defaultValue:false changeAction:nil]; PSSpecifier *forceFullFrame = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"FORCE_TWEET_FULL_FRAME_TITLE"] detailTitle:nil key:@"force_tweet_full_frame" defaultValue:false changeAction:nil]; @@ -206,8 +207,6 @@ - (NSArray *)specifiers { PSSpecifier *showScrollIndicator = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"SHOW_SCOLL_INDICATOR_OPTION_TITLE"] detailTitle:nil key:@"showScollIndicator" defaultValue:false changeAction:nil]; - PSSpecifier *alwaysFollowingPage = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ALWAYS_FOLLOWING_PAGE_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"ALWAYS_FOLLOWING_PAGE_OPTION_DETAIL_TITLE"] key:@"always_following_page" defaultValue:false changeAction:nil]; - PSSpecifier *font = [self newSwitchCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"FONT_OPTION_TITLE"] detailTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"FONT_OPTION_DETAIL_TITLE"] key:@"en_font" defaultValue:false changeAction:nil]; PSSpecifier *regularFontsPicker = [self newButtonCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"REQULAR_FONTS_PICKER_OPTION_TITLE"] detailTitle:[[NSUserDefaults standardUserDefaults] objectForKey:@"bhtwitter_font_1"] dynamicRule:@"en_font, ==, 0" action:@selector(showRegularFontPicker:)]; @@ -236,7 +235,6 @@ - (NSArray *)specifiers { hideTopicsToFollow, videoLayerCaption, directSave, - voice, videoZoom, noHistory, bioTranslate, @@ -244,7 +242,6 @@ - (NSArray *)specifiers { tweetConfirm, followConfirm, padLock, - DmModularSearch, autoHighestLoad, disableSensitiveTweetWarnings, copyProfileInfo, @@ -254,20 +251,21 @@ - (NSArray *)specifiers { alwaysOpenSafari, stripTrackingParams, trustedFriends, + advancedSearch, twitterBlueSection, // 1 undoTweet, - readerMode, appTheme, customTabBarVC, layoutSection, // 2 + customDirectBackgroundView, origTweetStyle, + stopHidingTabBar, hideViewCount, forceFullFrame, disableImmersive, showScrollIndicator, - alwaysFollowingPage, font, regularFontsPicker, boldFontsPicker, @@ -486,6 +484,48 @@ - (void)showThemeViewController:(PSSpecifier *)specifier { } [self.navigationController pushViewController:themeVC animated:true]; } +- (void)showCustomBackgroundViewViewController:(PSSpecifier *)specifier { + UITableViewCell *specifierCell = [specifier propertyForKey:PSTableCellKey]; + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"BHTwitter" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; + + if (alert.popoverPresentationController != nil) { + CGFloat midX = CGRectGetMidX(specifierCell.frame); + CGFloat midY = CGRectGetMidY(specifierCell.frame); + + alert.popoverPresentationController.sourceRect = CGRectMake(midX, midY, 0, 0); + alert.popoverPresentationController.sourceView = specifierCell; + } + + UIAlertAction *imageAction = [UIAlertAction actionWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_DIRECT_BACKGROUND_ALERT_OPTION_1"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + imagePicker.delegate = self; + [self presentViewController:imagePicker animated:YES completion:nil]; + }]; + + UIAlertAction *colorAction = [UIAlertAction actionWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_DIRECT_BACKGROUND_ALERT_OPTION_2"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + UIColorPickerViewController *colorPicker = [[UIColorPickerViewController alloc] init]; + colorPicker.delegate = self; + [self presentViewController:colorPicker animated:true completion:nil]; + }]; + + UIAlertAction *resetAction = [UIAlertAction actionWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_DIRECT_BACKGROUND_ALERT_OPTION_3"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [[NSUserDefaults standardUserDefaults] setBool:false forKey:@"change_msg_background"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"background_image"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"background_color"]; + }]; + + UIAlertAction *cancel = [UIAlertAction actionWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CANCEL_BUTTON_TITLE"] style:UIAlertActionStyleCancel handler:nil]; + + [alert addAction:imageAction]; + [alert addAction:colorAction]; + [alert addAction:resetAction]; + [alert addAction:cancel]; + + [self presentViewController:alert animated:true completion:nil]; +} + - (void)FLEXAction:(UISwitch *)sender { if (sender.isOn) { [[FLEXManager sharedManager] showExplorer]; @@ -493,6 +533,38 @@ - (void)FLEXAction:(UISwitch *)sender { [[FLEXManager sharedManager] hideExplorer]; } } + + +- (void)colorPickerViewControllerDidSelectColor:(UIColorPickerViewController *)viewController { + [[NSUserDefaults standardUserDefaults] setBool:true forKey:@"change_msg_background"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"background_image"]; + + + UIColor *selectedColor = viewController.selectedColor; + [[NSUserDefaults standardUserDefaults] setObject:selectedColor.hexString forKey:@"background_color"]; +} +- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { + NSFileManager *manager = [NSFileManager defaultManager]; + NSString *DocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true).firstObject; + + NSURL *oldImgPath = info[UIImagePickerControllerImageURL]; + NSURL *newImgPath = [[NSURL fileURLWithPath:DocPath] URLByAppendingPathComponent:@"msg_background.png"]; + + if ([manager fileExistsAtPath:newImgPath.path]) { + [manager removeItemAtURL:newImgPath error:nil]; + } + + [manager copyItemAtURL:oldImgPath toURL:newImgPath error:nil]; + + [[NSUserDefaults standardUserDefaults] setBool:true forKey:@"change_msg_background"]; + [[NSUserDefaults standardUserDefaults] setBool:true forKey:@"background_image"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"background_color"]; + + [picker dismissViewControllerAnimated:true completion:nil]; +} +- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { + [picker dismissViewControllerAnimated:true completion:nil]; +} @end @implementation BHButtonTableViewCell diff --git a/BHTwitter/TWHeaders.h b/BHTwitter/TWHeaders.h index 512bd47c..abe059e9 100644 --- a/BHTwitter/TWHeaders.h +++ b/BHTwitter/TWHeaders.h @@ -46,6 +46,13 @@ static NSString *_lastCopiedURL; @property (nonatomic, strong) id scribe; @end +@interface T1StandardStatusAttachmentViewAdapter : NSObject +@property (nonatomic, assign, readonly) NSUInteger attachmentType; +@end + +@interface T1DirectMessageConversationEntriesViewController: UIViewController +@end + @interface TFNTableView : UITableView - (void)setShowsVerticalScrollIndicator:(BOOL)arg1; @end @@ -84,10 +91,6 @@ static NSString *_lastCopiedURL; @property (nonatomic, strong) TFNTwitterAccount *account; @end -@interface TFNScrollingHorizontalLabelView : UIView -- (UIViewController *)NearestViewController; -@end - @interface TFNNavigationController : UINavigationController @end