diff --git a/.gitignore b/.gitignore index cd0b69e..c4ebd42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .theos packages +**/.DS_Store HAOUtils* \ No newline at end of file diff --git a/Makefile b/Makefile index af0749c..a90c42f 100644 --- a/Makefile +++ b/Makefile @@ -19,3 +19,6 @@ include $(THEOS_MAKE_PATH)/aggregate.mk internal-stage:: $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/Application\ Support/MessengerNoAds.bundle/$(ECHO_END) $(ECHO_NOTHING)cp -a settingsview/Resources/. $(THEOS_STAGING_DIR)/Library/Application\ Support/MessengerNoAds.bundle/$(ECHO_END) + +clean:: + rm -rf .theos packages \ No newline at end of file diff --git a/README.md b/README.md index 590fbdc..f64f39f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Not only removing ads but shipped with many nice features - Disable Story Seen (see others's stories but they won't know it) - Can save friend's story. (Tap ... on top right of story view -> Save) - Hide Search Bar (iOS12) / Hide Stories Row / Hide People tab +- Hide Suggested Contact in Search - Extend Story Video Upload Length (from default is 20 seconds to 10 minutes) - Support iOS 11 (tested) - 12 (tested) - 13 (tested) - Support latest Messenger version (If it doesn't work, you should update the app to latest version >=258.0) diff --git a/Tweak.h b/Tweak.h index 231dd92..3b4c9a2 100644 --- a/Tweak.h +++ b/Tweak.h @@ -51,4 +51,9 @@ @interface MSGListBinder : NSObject @property (nonatomic, assign) BOOL didAddMNACellHeaderView; +@end + +@interface LSContactListViewController : UIViewController { + NSString *_featureIdentifier; +} @end \ No newline at end of file diff --git a/Tweak.xm b/Tweak.xm index 4eeecff..f0860e5 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -12,6 +12,7 @@ BOOL cansavefriendsstory; BOOL hidesearchbar; BOOL hidestoriesrow; BOOL hidepeopletab; +BOOL hideSuggestedContactInSearch; BOOL showTheEyeButton; BOOL extendStoryVideoUploadLength; NSString *plistPath; @@ -30,6 +31,7 @@ static void reloadPrefs() { hidesearchbar = [[settings objectForKey:@"hidesearchbar"] ?: @(NO) boolValue]; hidestoriesrow = [[settings objectForKey:@"hidestoriesrow"] ?: @(NO) boolValue]; hidepeopletab = [[settings objectForKey:@"hidepeopletab"] ?: @(NO) boolValue]; + hideSuggestedContactInSearch = [[settings objectForKey:@"hideSuggestedContactInSearch"] ?: @(NO) boolValue]; showTheEyeButton = [[settings objectForKey:@"showTheEyeButton"] ?: @(YES) boolValue]; extendStoryVideoUploadLength = [[settings objectForKey:@"extendStoryVideoUploadLength"] ?: @(YES) boolValue]; } @@ -182,9 +184,22 @@ static void reloadPrefs() { - (void)handleMNACellTap:(UITapGestureRecognizer *)recognizer { MNASettingsViewController *settingsVC = [[MNASettingsViewController alloc] init]; UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:settingsVC]; + navVC.modalPresentationStyle = UIModalPresentationFullScreen; [[%c(LSAppDelegate) sharedInstance] presentViewController:navVC animated:true completion:nil]; } %end + + %hook LSContactListViewController + - (void)_updateContactList { + if (hideSuggestedContactInSearch) { + NSString *_featureIdentifier = MSHookIvar(self, "_featureIdentifier"); + if ([_featureIdentifier isEqualToString:@"universal_search_null_state"]) { + return; + } + } + %orig; + } + %end %end %group NoAdsNoStoriesRow diff --git a/control b/control index 7080b36..5a87494 100644 --- a/control +++ b/control @@ -1,7 +1,7 @@ Package: com.haoict.messengernoads Name: Messenger No Ads Depends: mobilesubstrate, com.haoict.libhdev (>= 4.5.0), firmware (>= 10) -Version: 3.7.0 +Version: 3.8.0 Architecture: iphoneos-arm Description: The best tweak for Messenger app. The best tweak for Messenger app. @@ -13,6 +13,7 @@ Description: The best tweak for Messenger app. - Disable Story Seen Receipt - Can Save Friend's Story - Hide Search Bar, Stories row, People tab + - Hide Suggested Contact in Search - Extend Story Video Upload Length (from default is 20 seconds to 10 minutes) - Support iOS 10 (not tested) - 11 (tested) - 12 (tested) - 13 (tested) - Support latest Messenger version (If it doesn't work, you should update the app to latest version >= 258.0) diff --git a/layout/DEBIAN/postinst b/layout/DEBIAN/postinst new file mode 100755 index 0000000..660544f --- /dev/null +++ b/layout/DEBIAN/postinst @@ -0,0 +1,7 @@ +echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" +echo "👋 Thank you for installing" +echo "💪 I work very hard to make good, free and open source tweaks for everyone" +echo "💰 If you want to support, you can buy me a coffee at www.paypal.me/haoict" +echo "💖 Hope you enjoy the tweak" +echo "👨‍💻 Developer: Hao Nguyen" +echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" \ No newline at end of file diff --git a/release/com.haoict.messengernoads_3.8.0_iphoneos-arm.deb b/release/com.haoict.messengernoads_3.8.0_iphoneos-arm.deb new file mode 100644 index 0000000..a80e8ca Binary files /dev/null and b/release/com.haoict.messengernoads_3.8.0_iphoneos-arm.deb differ diff --git a/settingsview/MNASettingsViewController.h b/settingsview/MNASettingsViewController.h index abd95f3..aa3ee5b 100644 --- a/settingsview/MNASettingsViewController.h +++ b/settingsview/MNASettingsViewController.h @@ -10,5 +10,6 @@ UIImageView *_headerImageView; UILabel *_titleLabel; UIImageView *_iconView; + NSMutableDictionary *_originalSettings; } @end \ No newline at end of file diff --git a/settingsview/MNASettingsViewController.m b/settingsview/MNASettingsViewController.m index 53c0caa..ec111dc 100644 --- a/settingsview/MNASettingsViewController.m +++ b/settingsview/MNASettingsViewController.m @@ -55,6 +55,8 @@ - (void)viewWillAppear:(BOOL)animated { [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}]; // set status bar text color // [UIApplication sharedApplication] + + _originalSettings = [MNAUtil getCurrentSettingsFromPlist]; } - (void)viewWillDisappear:(BOOL)animated { @@ -84,7 +86,7 @@ - (void)viewDidLoad { [_tableView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor], [_tableView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor], [_tableView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor], - [_tableView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor], + [_tableView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor], ]]; } else { [NSLayoutConstraint activateConstraints:@[ @@ -95,12 +97,14 @@ - (void)viewDidLoad { ]]; } + // setup table image header _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; _headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; _headerImageView.contentMode = (IS_iPAD || self.view.bounds.size.width > self.view.bounds.size.height) ? UIViewContentModeScaleAspectFit : UIViewContentModeScaleAspectFill; _headerImageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", @PREF_BUNDLE_PATH, @"Banner.jpg"]]; _headerImageView.translatesAutoresizingMaskIntoConstraints = NO; + _headerImageView.clipsToBounds = YES; [_headerView addSubview:_headerImageView]; [NSLayoutConstraint activateConstraints:@[ @@ -149,6 +153,10 @@ - (void)initTableData { hidePeopleTabSwitchCell.prefKey = @"hidepeopletab"; hidePeopleTabSwitchCell.defaultValue = @"false"; hidePeopleTabSwitchCell.isRestartRequired = TRUE; + MNACellModel *hideSuggestedContactInSearch = [[MNACellModel alloc] initWithType:Switch withLabel:[MNAUtil localizedItem:@"HIDE_SUGGESTED_CONTACT_IN_SEARCH"]]; + hideSuggestedContactInSearch.prefKey = @"hideSuggestedContactInSearch"; + hideSuggestedContactInSearch.defaultValue = @"false"; + hideSuggestedContactInSearch.isRestartRequired = TRUE; MNACellModel *extendStoryVideoUploadLengthSwitchCell = [[MNACellModel alloc] initWithType:Switch withLabel:[MNAUtil localizedItem:@"EXTEND_STORY_VIDEO_UPLOAD_LENGTH"]]; extendStoryVideoUploadLengthSwitchCell.prefKey = @"extendStoryVideoUploadLength"; @@ -186,6 +194,7 @@ - (void)initTableData { [_tableData addObject:hideSearchBarSwitchCell]; [_tableData addObject:hideStoriesRowSwitchCell]; [_tableData addObject:hidePeopleTabSwitchCell]; + [_tableData addObject:hideSuggestedContactInSearch]; [_tableData addObject:extendStoryVideoUploadLengthSwitchCell]; [_tableData addObject:otherPreferencesCell]; @@ -209,7 +218,38 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO } - (void)close { - [self dismissViewControllerAnimated:YES completion:nil]; + BOOL isRestartRequired = FALSE; + NSMutableDictionary *newSettings = [MNAUtil getCurrentSettingsFromPlist]; + + // get diff from original settings with new settings + NSDictionary *diff = [MNAUtil compareNSDictionary:_originalSettings withNSDictionary:newSettings]; + // get all keys array from diff + NSArray *diffAllKeys = [diff allKeys]; + + if ([diffAllKeys count] > 0) { + // check if changed keys has isRestartRequired + for (NSString *key in diffAllKeys) { + for (MNACellModel *cellModel in _tableData) { + if ([key isEqualToString:cellModel.prefKey] && cellModel.isRestartRequired) { + isRestartRequired = TRUE; + } + } + } + } + + if (isRestartRequired) { + // show restart required alert + UIAlertController* alert = [UIAlertController alertControllerWithTitle:[MNAUtil localizedItem:@"APP_RESTART_REQUIRED"] message:[MNAUtil localizedItem:@"DO_YOU_REALLY_WANT_TO_KILL_MESSENGER"] preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:[MNAUtil localizedItem:@"CONFIRM"] style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { + exit(0); + }]]; + [alert addAction:[UIAlertAction actionWithTitle:[MNAUtil localizedItem:@"CANCEL"] style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + [self dismissViewControllerAnimated:YES completion:nil]; + }]]; + [self presentViewController:alert animated:YES completion:nil]; + } else { + [self dismissViewControllerAnimated:YES completion:nil]; + } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { @@ -249,12 +289,19 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } - (void)resetSettings { - NSString *plistPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@PLIST_FILENAME]; - [@{} writeToFile:plistPath atomically:YES]; - [_tableView reloadData]; - notify_post(PREF_CHANGED_NOTIF); - // [HCommon showToastMessage:@"" withTitle:@"Done!" timeout:0.5 viewController:self]; - [MNAUtil showRequireRestartAlert:self]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Are you sure?" message:@"" preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) { + NSString *plistPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@PLIST_FILENAME]; + [@{} writeToFile:plistPath atomically:YES]; + [_tableView reloadData]; + notify_post(PREF_CHANGED_NOTIF); + exit(0); + }]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; + [alert addAction:confirmAction]; + [alert addAction:cancelAction]; + [self presentViewController:alert animated:YES completion:nil]; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { diff --git a/settingsview/MNATableViewCell.m b/settingsview/MNATableViewCell.m index f58c081..683ff0d 100644 --- a/settingsview/MNATableViewCell.m +++ b/settingsview/MNATableViewCell.m @@ -17,7 +17,7 @@ - (id)initWithData:(MNACellModel *)cellData reuseIdentifier:(NSString *)reuseIde self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier]; _cellData = cellData; _vc = vc; - _plistPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@PLIST_FILENAME]; + _plistPath = [MNAUtil getPlistPath]; if (self) { self.textLabel.text = cellData.label; self.textLabel.textColor = [HCommon colorFromHex:[HCommon isDarkMode] ? @LABEL_COLOR_DARKMODE : @LABEL_COLOR]; @@ -100,9 +100,9 @@ - (void)setPreferenceValue:(id)value { } else { notify_post(PREF_CHANGED_NOTIF); - if (_cellData.isRestartRequired) { - [MNAUtil showRequireRestartAlert:_vc]; - } + // if (_cellData.isRestartRequired) { + // [MNAUtil showRequireRestartAlert:_vc]; + // } } } diff --git a/settingsview/MNAUtil.h b/settingsview/MNAUtil.h index 9de47d9..73a15b0 100644 --- a/settingsview/MNAUtil.h +++ b/settingsview/MNAUtil.h @@ -10,4 +10,7 @@ @interface MNAUtil : NSObject + (NSString *)localizedItem:(NSString *)key; + (void)showRequireRestartAlert:(UIViewController *)vc; ++ (NSString *)getPlistPath; ++ (NSMutableDictionary *)getCurrentSettingsFromPlist; ++ (NSDictionary *)compareNSDictionary:(NSDictionary *)d1 withNSDictionary:(NSDictionary *)d2; @end \ No newline at end of file diff --git a/settingsview/MNAUtil.m b/settingsview/MNAUtil.m index 79e4934..1d60b0b 100644 --- a/settingsview/MNAUtil.m +++ b/settingsview/MNAUtil.m @@ -35,4 +35,36 @@ + (void)showRequireRestartAlert:(UIViewController *)vc { [vc presentViewController:alert animated:YES completion:nil]; } } + ++ (NSString *)getPlistPath { + return [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@PLIST_FILENAME]; +} + ++ (NSMutableDictionary *)getCurrentSettingsFromPlist { + return [[NSMutableDictionary alloc] initWithContentsOfFile:[MNAUtil getPlistPath]] ?: [@{} mutableCopy]; +} + ++ (NSDictionary *)compareNSDictionary:(NSDictionary *)d1 withNSDictionary:(NSDictionary *)d2 { + NSMutableDictionary *result = NSMutableDictionary.dictionary; + + // Find objects in d1 that don't exist or are different in d2 + [d1 enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { + id otherObj = d2[key]; + + if (![obj isEqual:otherObj]) { + result[key] = obj; + } + }]; + + // Find objects in d2 that don't exist in d1 + [d2 enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { + id d1Obj = d1[key]; + + if (!d1Obj) { + result[key] = obj; + } + }]; + + return result; +} @end \ No newline at end of file diff --git a/settingsview/Resources/ar.lproj/Root.strings b/settingsview/Resources/ar.lproj/Root.strings index 891dee8..a20be9b 100644 --- a/settingsview/Resources/ar.lproj/Root.strings +++ b/settingsview/Resources/ar.lproj/Root.strings @@ -15,6 +15,7 @@ "HIDE_SEARCH_BAR" = "اخفاء شريط البحث - تعمل فقط مع الاصدار 12"; "HIDE_STORIES_ROW" = "الغاء شريط الحاله"; "HIDE_PEOPLE_TAB" = "اخفاء ايقونه الاشخاص"; + "HIDE_SUGGESTED_CONTACT_IN_SEARCH" = "Hide Suggested Contact In Search"; "EXTEND_STORY_VIDEO_UPLOAD_LENGTH" = "تمديد طول تحميل الفيديو القصة"; "OTHER_PREFERENCES" = "الاعدادات الاخرى"; "SHOW_THE_EYE_BUTTON" = "إظهار زر العين"; diff --git a/settingsview/Resources/base.lproj/Root.strings b/settingsview/Resources/base.lproj/Root.strings index 28fb507..ec3bf0b 100644 --- a/settingsview/Resources/base.lproj/Root.strings +++ b/settingsview/Resources/base.lproj/Root.strings @@ -15,6 +15,7 @@ "HIDE_SEARCH_BAR" = "Hide Search Bar (iOS 12 only)"; "HIDE_STORIES_ROW" = "Hide Stories Row"; "HIDE_PEOPLE_TAB" = "Hide People Tab"; + "HIDE_SUGGESTED_CONTACT_IN_SEARCH" = "Hide Suggested Contact In Search"; "EXTEND_STORY_VIDEO_UPLOAD_LENGTH" = "Extend Story Video Upload Length"; "OTHER_PREFERENCES" = "Other Preferences"; "SHOW_THE_EYE_BUTTON" = "Show The Eye Button"; diff --git a/settingsview/Resources/en.lproj/Root.strings b/settingsview/Resources/en.lproj/Root.strings index 28fb507..ec3bf0b 100644 --- a/settingsview/Resources/en.lproj/Root.strings +++ b/settingsview/Resources/en.lproj/Root.strings @@ -15,6 +15,7 @@ "HIDE_SEARCH_BAR" = "Hide Search Bar (iOS 12 only)"; "HIDE_STORIES_ROW" = "Hide Stories Row"; "HIDE_PEOPLE_TAB" = "Hide People Tab"; + "HIDE_SUGGESTED_CONTACT_IN_SEARCH" = "Hide Suggested Contact In Search"; "EXTEND_STORY_VIDEO_UPLOAD_LENGTH" = "Extend Story Video Upload Length"; "OTHER_PREFERENCES" = "Other Preferences"; "SHOW_THE_EYE_BUTTON" = "Show The Eye Button"; diff --git a/settingsview/Resources/fr.lproj/Root.strings b/settingsview/Resources/fr.lproj/Root.strings index 3520c64..77784f7 100644 --- a/settingsview/Resources/fr.lproj/Root.strings +++ b/settingsview/Resources/fr.lproj/Root.strings @@ -15,6 +15,7 @@ "HIDE_SEARCH_BAR" = "Cacher barre de recherche (iOS12)"; "HIDE_STORIES_ROW" = "Cacher la rangée des Stories"; "HIDE_PEOPLE_TAB" = "Cacher l'onglet Personnes"; + "HIDE_SUGGESTED_CONTACT_IN_SEARCH" = "Hide Suggested Contact In Search"; "EXTEND_STORY_VIDEO_UPLOAD_LENGTH" = "Prolonger la durée de téléchargement de la vidéo de l'histoire"; "OTHER_PREFERENCES" = "Autres réglages"; "SHOW_THE_EYE_BUTTON" = "Afficher le bouton oeil"; diff --git a/settingsview/Resources/nl.lproj/Root.strings b/settingsview/Resources/nl.lproj/Root.strings index e951bda..552599a 100644 --- a/settingsview/Resources/nl.lproj/Root.strings +++ b/settingsview/Resources/nl.lproj/Root.strings @@ -15,6 +15,7 @@ "HIDE_SEARCH_BAR" = "Zoekbalk verbergen (alleen iOS 12)"; "HIDE_STORIES_ROW" = "Verhalenrij verbergen"; "HIDE_PEOPLE_TAB" = "Tabblad Personen verbergen"; + "HIDE_SUGGESTED_CONTACT_IN_SEARCH" = "Hide Suggested Contact In Search"; "EXTEND_STORY_VIDEO_UPLOAD_LENGTH" = "Verleng de lengte van de uploadvideo van het verhaal"; "OTHER_PREFERENCES" = "Andere voorkeuren"; "SHOW_THE_EYE_BUTTON" = "Toon de oogknop"; diff --git a/settingsview/Resources/th.lproj/Root.strings b/settingsview/Resources/th.lproj/Root.strings index 1bd8c90..d1fbec9 100644 --- a/settingsview/Resources/th.lproj/Root.strings +++ b/settingsview/Resources/th.lproj/Root.strings @@ -15,6 +15,7 @@ "HIDE_SEARCH_BAR" = "ซ่อนแท็บค้นหา (เฉพาะ iOS 12)"; "HIDE_STORIES_ROW" = "ซ่อนแถบสตอรี่"; "HIDE_PEOPLE_TAB" = "ซ่อนแท็บผู้คน"; + "HIDE_SUGGESTED_CONTACT_IN_SEARCH" = "Hide Suggested Contact In Search"; "EXTEND_STORY_VIDEO_UPLOAD_LENGTH" = "เพิ่มความยาวเวลาบันทึกวิดีโอสตอรี่"; "OTHER_PREFERENCES" = "ตั้งค่าอื่น ๆ"; "SHOW_THE_EYE_BUTTON" = "แสดงปุ่มดวงตา"; diff --git a/settingsview/Resources/vi.lproj/Root.strings b/settingsview/Resources/vi.lproj/Root.strings index 248026b..ffb3a4e 100644 --- a/settingsview/Resources/vi.lproj/Root.strings +++ b/settingsview/Resources/vi.lproj/Root.strings @@ -15,6 +15,7 @@ "HIDE_SEARCH_BAR" = "Ẩn ô tìm kiếm (iOS 12)"; "HIDE_STORIES_ROW" = "Ẩn hàng story"; "HIDE_PEOPLE_TAB" = "Ẩn tab Mọi người"; + "HIDE_SUGGESTED_CONTACT_IN_SEARCH" = "Ẩn bạn bè \"được gợi ý\" trong mục tìm kiếm"; "EXTEND_STORY_VIDEO_UPLOAD_LENGTH" = "Tăng thời lượng tải lên Story video"; "OTHER_PREFERENCES" = "Tùy chỉnh phụ"; "SHOW_THE_EYE_BUTTON" = "Hiện nút con mắt";