Skip to content
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
50 changes: 50 additions & 0 deletions src/Features/General/SCSettingsMenuEntry.x
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,54 @@

[SCIUtils showSettingsVC:[self window]];
}
%end

// Tapping the side tray (hamburger) button on the profile lets the user choose
// between the normal Instagram settings and the SCInsta tweak settings
@protocol SCSideTrayController
- (void)onSideTrayButton;
@end

static BOOL sciBypassSideTray = NO;

%hook _TtC19IGProfileNavigation34IGProfileNavigationItemsController
- (void)onSideTrayButton {
// Re-entrant call from the "Instagram Settings" option: run the original
if (sciBypassSideTray) {
sciBypassSideTray = NO;
%orig;
return;
}

UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIViewController *presenter = [window rootViewController];
while (presenter.presentedViewController) presenter = presenter.presentedViewController;

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Settings"
message:@"Which settings would you like to open?"
preferredStyle:UIAlertControllerStyleActionSheet];

[alert addAction:[UIAlertAction actionWithTitle:@"Instagram Settings"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
sciBypassSideTray = YES;
[(id<SCSideTrayController>)self onSideTrayButton];
}]];

[alert addAction:[UIAlertAction actionWithTitle:@"SCInsta Settings"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[SCIUtils showSettingsVC:window];
}]];

[alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];

// Required for iPad to avoid a crash when presenting an action sheet
if (alert.popoverPresentationController) {
alert.popoverPresentationController.sourceView = presenter.view;
alert.popoverPresentationController.sourceRect = CGRectMake(presenter.view.bounds.size.width / 2.0, presenter.view.bounds.size.height / 2.0, 1.0, 1.0);
}

[presenter presentViewController:alert animated:YES completion:nil];
}
%end
12 changes: 10 additions & 2 deletions src/Features/Media/MediaDownload.xm
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,16 @@ static void initDownloaders () {
}
%new - (void)handleLongPress:(UILongPressGestureRecognizer *)sender {
if (sender.state != UIGestureRecognizerStateBegan) return;

NSURL *videoUrl = [SCIUtils getVideoUrlForMedia:self.video];

// Older versions expose the media via `video`; newer ones store it in the
// `_mediaPassthrough` ivar, so fall back to KVC when `video` is unavailable.
IGMedia *media = [self respondsToSelector:@selector(video)] ? self.video : nil;
if (!media) {
@try { media = [self valueForKey:@"mediaPassthrough"]; }
@catch (NSException *e) { media = nil; }
}

NSURL *videoUrl = [SCIUtils getVideoUrlForMedia:media];
if (!videoUrl) {
[SCIUtils showErrorHUDWithDescription:@"Could not extract video url from reel"];

Expand Down
3 changes: 3 additions & 0 deletions src/InstagramHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
@end

@interface IGSundialViewerVideoCell : UIView
{
IGMedia *_mediaPassthrough;
}
@property(readonly, nonatomic) IGMedia *video;

- (void)addLongPressGestureRecognizer; // new
Expand Down