Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reel Controls Hider Button #96

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Controllers/SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ - (NSArray *)specifiers {
[self newSwitchCellWithTitle:@"Hide Meta AI" detailTitle:@"Hides the meta ai buttons within the app" key:@"hide_meta_ai" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Copy description" detailTitle:@"Copy the post description with a long press" key:@"copy_description" defaultValue:true changeAction:nil],
[self newSwitchCellWithTitle:@"Hide reels tab" detailTitle:@"Hides the reels tab on the bottom navbar" key:@"hide_reels_tab" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Hide Create tab" detailTitle:@"Hides the Create tab on the bottom navbar" key:@"hide_create_tab" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Disable scrolling reels" detailTitle:@"Prevents reels from being scrolled to the next video" key:@"disable_scrolling_reels" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Do not save recent searches" detailTitle:@"Search bars will no longer save your recent searches" key:@"no_recent_searches" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Hide explore posts grid" detailTitle:@"Hides the grid of suggested posts on the explore/search tab" key:@"hide_explore_grid" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Hide trending searches" detailTitle:@"Hides the trending searches under the explore search bar" key:@"hide_trending_searches" defaultValue:true changeAction:nil],
[self newSwitchCellWithTitle:@"No suggested chats" detailTitle:@"Hides the suggested broadcast channels in direct messages" key:@"no_suggested_chats" defaultValue:true changeAction:nil],
[self newSwitchCellWithTitle:@"No suggested users" detailTitle:@"Hides the suggested users for you to follow" key:@"no_suggested_users" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Show Control Hider Button" detailTitle:@"Adds button to hide Reel Controls" key:@"hide_controls" defaultValue:false changeAction:nil]

// Section 2: Feed
[self newSectionWithTitle:@"Feed" footer:nil],
Expand Down Expand Up @@ -328,4 +330,4 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
}
return self;
}
@end
@end
26 changes: 26 additions & 0 deletions src/Features/General/HideReelsAndCreateTab.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#import "../../InstagramHeaders.h"
#import "../../Manager.h"

// Hide reels tab and create tab
%hook IGTabBarController

- (id)initWithUserSession:(id)a tabBarSurfaces:(id)b accountSwitcherPresenter:(id)c initMode:(NSInteger)d {

NSMutableArray *surfaces = [NSMutableArray arrayWithArray:b];

[surfaces enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(IGMainAppSurfaceIntent *surface, NSUInteger idx, BOOL *stop) {

NSInteger subtype = [[surface valueForKey:@"_subtype"] integerValue];

if (subtype == 2 && [SCIManager getPref:@"hide_reels_tab"]) {
[surfaces removeObjectAtIndex:idx];
}

if (subtype == 3 && [SCIManager getPref:@"hide_create_tab"]) {
[surfaces removeObjectAtIndex:idx];
}
}];
return %orig(a, surfaces, c, d);
}

%end
21 changes: 0 additions & 21 deletions src/Features/General/HideReelsTab.x

This file was deleted.

65 changes: 65 additions & 0 deletions src/Features/General/hideReelControls.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#import "../../InstagramHeaders.h"
#import "../../Manager.h"


%hook IGSundialViewerVideoCell
%property(nonatomic, assign) BOOL controlsHidden;

- (void)videoViewDidLoadVideo:(id)video {
%orig;
if ([SCIManager getPref:@"hide_controls"]) {
self.controlsHidden = false;
[self addControlsHiderButton];
}
}

- (void)prepareForReuse {
%orig;
if ([SCIManager getPref:@"hide_controls"]) {
self.controlsHidden = false;
UIButton *hideButton = [self viewWithTag:123];
if (hideButton) {
[hideButton setImage:[UIImage systemImageNamed:@"eye.slash.fill"] forState:UIControlStateNormal];
}
[self.viewController animateCurrentVideoControllerVideoCellControlsOverlayVisible:YES];
}
}

%new - (void)addControlsHiderButton {
UIButton *ControlsHiderButton = [UIButton buttonWithType:UIButtonTypeSystem];
[ControlsHiderButton setTag:123];
[ControlsHiderButton setTranslatesAutoresizingMaskIntoConstraints:false];
[ControlsHiderButton addTarget:self action:@selector(ControlsHiderButtonHandler:) forControlEvents:UIControlEventTouchUpInside];
if (self.controlsHidden) {
[ControlsHiderButton setImage:[UIImage systemImageNamed:@"eye.fill"] forState:UIControlStateNormal];
} else {
[ControlsHiderButton setImage:[UIImage systemImageNamed:@"eye.slash.fill"] forState:UIControlStateNormal];
}

if (![self viewWithTag:123]) {
[ControlsHiderButton setTintColor:[UIColor whiteColor]];
[self addSubview:ControlsHiderButton];
[NSLayoutConstraint activateConstraints:@[
[ControlsHiderButton.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor constant:70],
[ControlsHiderButton.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor constant:-10],
[ControlsHiderButton.widthAnchor constraintEqualToConstant:30],
[ControlsHiderButton.heightAnchor constraintEqualToConstant:30],
]];
}
}

%new - (void)ControlsHiderButtonHandler:(UIButton *)sender {
IGSundialFeedViewController *rootVC = self.viewController;
if (self.controlsHidden) {
self.controlsHidden = false;
[rootVC animateCurrentVideoControllerVideoCellControlsOverlayVisible:YES];
[sender setImage:[UIImage systemImageNamed:@"eye.slash.fill"] forState:UIControlStateNormal];
} else {
self.controlsHidden = true;
[rootVC animateCurrentVideoControllerVideoCellControlsOverlayVisible:NO];
[sender setImage:[UIImage systemImageNamed:@"eye.fill"] forState:UIControlStateNormal];
}
}


%end
2 changes: 1 addition & 1 deletion src/Features/Save/MediaSave.x
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
NSLog(@"[SCInsta] Save media: Preparing alert");

IGFeedItemPagePhotoCell *currentCell = self.delegate;
IGPostItem *currentPost = [currentCell post];
IGPostItem *currentPost = [currentCell post] ?: currentCell.pagePhotoPost; // Attempt to fix Carousel items download

NSSet <NSString *> *knownImageURLIdentifiers = [currentPost.photo valueForKey:@"_knownImageURLIdentifiers"];
NSArray *knownImageURLIdentifiersArray = [knownImageURLIdentifiers allObjects];
Expand Down
16 changes: 13 additions & 3 deletions src/InstagramHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,19 @@
@interface IGFeedPhotoView () <SCIDownloadDelegate>
@end

@interface IGSundialViewerVideoCell : UIView
@interface IGSundialFeedViewController : UIViewController
- (void)animateCurrentVideoControllerVideoCellControlsOverlayVisible:(BOOL)a;
@end

@interface IGSundialViewerVideoCell : UICollectionViewCell
- (void)addHandleLongPress; // new
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender; // new
@property (nonatomic, strong) JGProgressHUD *hud;
- (void)addControlsHiderButton; // new
- (void)ControlsHiderButtonHandler:(UIButton *)sender; // new
@property (nonatomic, strong) JGProgressHUD *hud;
@property(readonly, nonatomic) IGMedia *video;
@property (nonatomic, assign, readonly) IGSundialFeedViewController *viewController; // new property
@property(nonatomic, assign) BOOL controlsHidden; // new property
@end

@interface IGSundialViewerVideoCell () <SCIDownloadDelegate>
Expand Down Expand Up @@ -337,6 +345,8 @@
@interface IGUnifiedVideoCollectionView : UIScrollView
@end

@interface IGMainAppSurfaceIntent:NSObject
@end


/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -457,4 +467,4 @@ typedef FLEXAlertAction * _Nonnull (^FLEXAlertActionHandler)(void(^handler)(NSAr
- (void)showExplorer;
- (void)hideExplorer;
- (void)toggleExplorer;
@end
@end