Skip to content

Commit

Permalink
Merge pull request #33 from 0wb3/main
Browse files Browse the repository at this point in the history
  • Loading branch information
BandarHL authored Jan 3, 2025
2 parents d9841f9 + c29c07a commit 7b4bebc
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 103 deletions.
67 changes: 61 additions & 6 deletions InstagramHeaders.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#import <Foundation/Foundation.h>
#include <objc/NSObject.h>
#import <UIKit/UIKit.h>
#import "BHIManager.h"
#import "SettingsViewController.h"
#import "SecurityViewController.h"
#import "BHDownload.h"
#import "JGProgressHUD/JGProgressHUD.h"
#include "RemoteLog.h" // For debugging purposes : https://github.com/Muirey03/RemoteLog -- Remove If Not Needed

@interface IGViewController: UIViewController
- (void)_superPresentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(id)completion;
Expand Down Expand Up @@ -32,7 +34,9 @@
@property(readonly, nonatomic) NSURL *url;
@end

@interface IGVideo : NSObject
@interface IGVideo : NSObject {
NSSet *_allVideoURLs;
}
@property(readonly, nonatomic) NSSet *allVideoURLs;
@end

Expand Down Expand Up @@ -134,8 +138,25 @@
@property(readonly, nonatomic) IGImageProgressView *photoView;
@end

// @protocol IGFNFVideoPlayable
// @property (readonly, nonatomic) IGFNFVideoPlayer *videoPlayer;
// @end

@protocol IGVideoURLProvider
@end

@interface IGFNFVideoPlayer : NSObject
@property id<IGVideoURLProvider> video;
@end

@interface IGStatefulVideoPlayer : NSObject
@property IGFNFVideoPlayer *video;
@end
@protocol IGFNFVideoPlayable
@property (readonly, nonatomic) IGFNFVideoPlayer *videoPlayer;
@end
@interface IGStoryVideoView : UIView<IGStoryPlayerMediaViewType>
@property(retain, nonatomic) IGVideoPlayer *videoPlayer;
@property(nonatomic, strong, readwrite) id<IGFNFVideoPlayable> videoPlayer;
@end

@interface IGStoryFullscreenDefaultFooterView: UIView
Expand All @@ -151,25 +172,40 @@

@interface IGStoryFullscreenCell: UICollectionViewCell
@end

@protocol IGStoryItemType
@end
@protocol IGUnitltemInformationProviding
@end
@interface IGStoryViewerViewModel: NSObject
@end
@interface IGStoryViewerViewController : UIViewController
{
id _focusStoryItemOnEntry;
// id <IGStoryItemType><IGUnitItemInformationProviding> _focusStoryItemOnEntry;
IGStoryViewerViewModel *_focusedModelItem;
}
- (id)_getMostVisibleSectionController;
- (void)fullscreenSectionController:(id)arg1 didMarkItemAsSeen:(id)arg2;
- (id)currentStoryItem;
@property (nonatomic) UIView *contentViewForSnapshot;
@end

@protocol IGStoryFullScreenControllerTypeDelegate
@end
@interface IGStoryFullscreenSectionController: NSObject
@property (nonatomic) id delegate;
@property (nonatomic, weak, readwrite) id<IGStoryFullScreenControllerTypeDelegate> delegate;
@end


@protocol IGStoryViewerContainerViewDelegate
@end

@interface IGStoryViewerContainerView: UIView
@property UIView *superview;
@property(retain, nonatomic) UIView<IGStoryPlayerMediaViewType> *mediaView;
@property(nonatomic) IGStoryFullscreenOverlayView *overlayView;
@property (nonatomic, weak) id delegate;
@property (nonatomic, weak, readwrite) id<IGStoryViewerContainerViewDelegate> delegate;
@property(nonatomic, retain) UIButton *hDownloadButton; // new property
@property(nonatomic, retain) UIButton *hSeenButton;
@property (nonatomic, strong) JGProgressHUD *hud;
@property (nonatomic, retain) NSString *fileextension;
- (void)hDownloadButtonPressed:(UIButton *)sender;
Expand Down Expand Up @@ -239,6 +275,25 @@
@interface IGInstagramAppDelegate : NSObject <UIApplicationDelegate>
@end

//
@interface IGProfileBioView : UIView {
IGCoreTextView *_infoLabelView;
}
- (void)addHandleLongPress; // new
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender; // new
@end

@interface IGTabBarController : UIViewController
- (void)_superPresentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(id)completion;
@end

@interface IGUFIInteractionCountsView : UIView
@end

@interface IGStoryViewerCollectionView : UIView
@end
//

static BOOL is_iPad() {
if ([(NSString *)[UIDevice currentDevice].model hasPrefix:@"iPad"]) {
return YES;
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TARGET := iphone:clang:13.7
INSTALL_TARGET_PROCESSES = SpringBoard

THEOS_PACKAGE_SCHEME=rootless
THEOS_DEVICE_IP = 192.168.2.232
export SYSROOT = $(THEOS)/sdks/iPhoneOS16.5.sdk

include $(THEOS)/makefiles/common.mk

Expand Down
72 changes: 37 additions & 35 deletions SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (PSSpecifier *)newSectionWithTitle:(NSString *)header footer:(NSString *)foote
}
- (PSSpecifier *)newSwitchCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText key:(NSString *)keyText defaultValue:(BOOL)defValue changeAction:(SEL)changeAction {
PSSpecifier *switchCell = [PSSpecifier preferenceSpecifierNamed:titleText target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:nil cell:PSSwitchCell edit:nil];

[switchCell setProperty:keyText forKey:@"key"];
[switchCell setProperty:keyText forKey:@"id"];
[switchCell setProperty:@YES forKey:@"big"];
Expand All @@ -50,7 +50,7 @@ - (PSSpecifier *)newSwitchCellWithTitle:(NSString *)titleText detailTitle:(NSStr
}
- (PSSpecifier *)newButtonCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText dynamicRule:(NSString *)rule action:(SEL)action {
PSSpecifier *buttonCell = [PSSpecifier preferenceSpecifierNamed:titleText target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:nil cell:PSButtonCell edit:nil];

[buttonCell setButtonAction:action];
[buttonCell setProperty:@YES forKey:@"big"];
[buttonCell setProperty:BHButtonTableViewCell.class forKey:@"cellClass"];
Expand All @@ -65,7 +65,7 @@ - (PSSpecifier *)newButtonCellWithTitle:(NSString *)titleText detailTitle:(NSStr
}
- (PSSpecifier *)newHBLinkCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText url:(NSString *)url {
PSSpecifier *HBLinkCell = [PSSpecifier preferenceSpecifierNamed:titleText target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:nil cell:PSButtonCell edit:nil];

[HBLinkCell setButtonAction:@selector(hb_openURL:)];
[HBLinkCell setProperty:HBLinkTableCell.class forKey:@"cellClass"];
[HBLinkCell setProperty:url forKey:@"url"];
Expand All @@ -76,7 +76,7 @@ - (PSSpecifier *)newHBLinkCellWithTitle:(NSString *)titleText detailTitle:(NSStr
}
- (PSSpecifier *)newHBTwitterCellWithTitle:(NSString *)titleText twitterUsername:(NSString *)user customAvatarURL:(NSString *)avatarURL {
PSSpecifier *TwitterCell = [PSSpecifier preferenceSpecifierNamed:titleText target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:nil cell:1 edit:nil];

[TwitterCell setButtonAction:@selector(hb_openURL:)];
[TwitterCell setProperty:HBTwitterCell.class forKey:@"cellClass"];
[TwitterCell setProperty:user forKey:@"user"];
Expand All @@ -87,13 +87,13 @@ - (PSSpecifier *)newHBTwitterCellWithTitle:(NSString *)titleText twitterUsername
}
- (NSArray *)specifiers {
if (!_specifiers) {

PSSpecifier *feedSection = [self newSectionWithTitle:@"Feed" footer:nil];
PSSpecifier *mediaSection = [self newSectionWithTitle:@"Save media" footer:nil];
PSSpecifier *storySection = [self newSectionWithTitle:@"Story and direct" footer:nil];
PSSpecifier *securitySection = [self newSectionWithTitle:@"Security" footer:nil];
PSSpecifier *developer = [self newSectionWithTitle:@"Developer" footer:nil];

PSSpecifier *hideAds = [self newSwitchCellWithTitle:@"Hide Ads" detailTitle:@"Remove all Ads from Instagram app" key:@"hide_ads" defaultValue:true changeAction:nil];
PSSpecifier *noSuggestedPost = [self newSwitchCellWithTitle:@"No suggested post" detailTitle:@"Remove suggested posts from the feed" key:@"no_suggested_post" defaultValue:false changeAction:nil];
PSSpecifier *showLikeCount = [self newSwitchCellWithTitle:@"Show Like count" detailTitle:@"Show like count in the post" key:@"show_like_count" defaultValue:true changeAction:nil];
Expand All @@ -115,9 +115,9 @@ - (NSArray *)specifiers {
// dvelopers section
PSSpecifier *bandarHL = [self newHBTwitterCellWithTitle:@"BandarHelal" twitterUsername:@"BandarHL" customAvatarURL:@"https://unavatar.io/twitter/BandarHL"];
PSSpecifier *tipJar = [self newHBLinkCellWithTitle:@"Tip Jar" detailTitle:@"Donate Via Paypal" url:@"https://www.paypal.me/BandarHL"];

PSSpecifier *sourcecode = [self newHBLinkCellWithTitle:@"Source Code" detailTitle:@"BHInsta Source Code on Github" url:@"https://github.com/BandarHL/BHInstagram"];
_specifiers = [NSMutableArray arrayWithArray:@[

feedSection, // 1
hideAds,
noSuggestedPost,
Expand All @@ -140,32 +140,34 @@ - (NSArray *)specifiers {

securitySection, // 4
appLock,

developer, // 5
bandarHL,
tipJar,
sourcecode,

]];

[self collectDynamicSpecifiersFromArray:_specifiers];
}

return _specifiers;
}
- (void)reloadSpecifiers {
[super reloadSpecifiers];

[self collectDynamicSpecifiersFromArray:self.specifiers];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.hasDynamicSpecifiers) {
PSSpecifier *dynamicSpecifier = [self specifierAtIndexPath:indexPath];
BOOL __block shouldHide = false;

[self.dynamicSpecifiers enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
NSMutableArray *specifiers = obj;
if ([specifiers containsObject:dynamicSpecifier]) {
shouldHide = [self shouldHideSpecifier:dynamicSpecifier];

UITableViewCell *specifierCell = [dynamicSpecifier propertyForKey:PSTableCellKey];
specifierCell.clipsToBounds = shouldHide;
}
Expand All @@ -174,43 +176,43 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
return 0;
}
}

return UITableViewAutomaticDimension;
}

- (void)collectDynamicSpecifiersFromArray:(NSArray *)array {
if (!self.dynamicSpecifiers) {
self.dynamicSpecifiers = [NSMutableDictionary new];

} else {
[self.dynamicSpecifiers removeAllObjects];
}

for (PSSpecifier *specifier in array) {
NSString *dynamicSpecifierRule = [specifier propertyForKey:@"dynamicRule"];

if (dynamicSpecifierRule.length > 0) {
NSArray *ruleComponents = [dynamicSpecifierRule componentsSeparatedByString:@", "];

if (ruleComponents.count == 3) {
NSString *opposingSpecifierID = [ruleComponents objectAtIndex:0];
if ([self.dynamicSpecifiers objectForKey:opposingSpecifierID]) {
NSMutableArray *specifiers = [[self.dynamicSpecifiers objectForKey:opposingSpecifierID] mutableCopy];
[specifiers addObject:specifier];


[self.dynamicSpecifiers removeObjectForKey:opposingSpecifierID];
[self.dynamicSpecifiers setObject:specifiers forKey:opposingSpecifierID];
} else {
[self.dynamicSpecifiers setObject:[NSMutableArray arrayWithArray:@[specifier]] forKey:opposingSpecifierID];
}

} else {
[NSException raise:NSInternalInconsistencyException format:@"dynamicRule key requires three components (Specifier ID, Comparator, Value To Compare To). You have %ld of 3 (%@) for specifier '%@'.", ruleComponents.count, dynamicSpecifierRule, [specifier propertyForKey:PSTitleKey]];
}
}
}

self.hasDynamicSpecifiers = (self.dynamicSpecifiers.count > 0);
}
- (DynamicSpecifierOperatorType)operatorTypeForString:(NSString *)string {
Expand All @@ -221,53 +223,53 @@ - (BOOL)shouldHideSpecifier:(PSSpecifier *)specifier {
if (specifier) {
NSString *dynamicSpecifierRule = [specifier propertyForKey:@"dynamicRule"];
NSArray *ruleComponents = [dynamicSpecifierRule componentsSeparatedByString:@", "];

PSSpecifier *opposingSpecifier = [self specifierForID:[ruleComponents objectAtIndex:0]];
id opposingValue = [self readPreferenceValue:opposingSpecifier];
id requiredValue = [ruleComponents objectAtIndex:2];

if ([opposingValue isKindOfClass:NSNumber.class]) {
DynamicSpecifierOperatorType operatorType = [self operatorTypeForString:[ruleComponents objectAtIndex:1]];

switch (operatorType) {
case EqualToOperatorType:
return ([opposingValue intValue] == [requiredValue intValue]);
break;

case NotEqualToOperatorType:
return ([opposingValue intValue] != [requiredValue intValue]);
break;

case GreaterThanOperatorType:
return ([opposingValue intValue] > [requiredValue intValue]);
break;

case LessThanOperatorType:
return ([opposingValue intValue] < [requiredValue intValue]);
break;
}
}

if ([opposingValue isKindOfClass:NSString.class]) {
return [opposingValue isEqualToString:requiredValue];
}

if ([opposingValue isKindOfClass:NSArray.class]) {
return [opposingValue containsObject:requiredValue];
}
}

return NO;
}

- (void)setPreferenceValue:(id)value specifier:(PSSpecifier *)specifier {
NSUserDefaults *Prefs = [NSUserDefaults standardUserDefaults];
[Prefs setValue:value forKey:[specifier identifier]];

if (self.hasDynamicSpecifiers) {
NSString *specifierID = [specifier propertyForKey:PSIDKey];
PSSpecifier *dynamicSpecifier = [self.dynamicSpecifiers objectForKey:specifierID];

if (dynamicSpecifier) {
[self.table beginUpdates];
[self.table endUpdates];
Expand Down Expand Up @@ -311,7 +313,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
self.detailTextLabel.text = subTitle;
self.detailTextLabel.numberOfLines = isBig ? 0 : 1;
self.detailTextLabel.textColor = [UIColor secondaryLabelColor];

if (specifier.properties[@"switchAction"]) {
UISwitch *targetSwitch = ((UISwitch *)[self control]);
NSString *strAction = [specifier.properties[@"switchAction"] copy];
Expand Down
Loading

0 comments on commit 7b4bebc

Please sign in to comment.