Skip to content

Commit

Permalink
Moved from Monkeydev to Theos
Browse files Browse the repository at this point in the history
- Convert all swift files to Objective-c.
- Add new script to build BHTwitter project easily.
- Support JB rootfull and rootless.
- Fix crashing in downloading longer video and freezing using FFmpeg.
- New option to hide bookmark button.
  • Loading branch information
BandarHL committed Dec 14, 2023
1 parent 92ed4dc commit 7099a06
Show file tree
Hide file tree
Showing 457 changed files with 88,417 additions and 1,859 deletions.
70 changes: 1 addition & 69 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,70 +1,2 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
.DS_Store
BHTwitter/Package/Library/MobileSubstrate/DynamicLibraries/BHTwitter.dylib
.theos
18 changes: 18 additions & 0 deletions AppIcon/BHAppIconCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AppIconCell.h
// BHTwitter
//
// Created by Bandar Alruwaili on 10/12/2023.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface BHAppIconCell : UICollectionViewCell
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIImageView *checkIMG;
+ (NSString *)reuseIdentifier;
@end

NS_ASSUME_NONNULL_END
45 changes: 45 additions & 0 deletions AppIcon/BHAppIconCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// AppIconCell.m
// BHTwitter
//
// Created by Bandar Alruwaili on 10/12/2023.
//

#import "BHAppIconCell.h"

@implementation BHAppIconCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.imageView = [[UIImageView alloc] init];
self.imageView.translatesAutoresizingMaskIntoConstraints = false;
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.imageView.clipsToBounds = YES;
self.imageView.layer.cornerRadius = 22;

self.checkIMG = [[UIImageView alloc] init];
self.checkIMG.image = [UIImage systemImageNamed:@"circle"];
self.checkIMG.translatesAutoresizingMaskIntoConstraints = false;

[self addSubview:self.imageView];
[self addSubview:self.checkIMG];

[NSLayoutConstraint activateConstraints:@[
[self.imageView.topAnchor constraintEqualToAnchor:self.topAnchor],
[self.imageView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[self.imageView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor],
[self.imageView.heightAnchor constraintEqualToConstant:98],
[self.imageView.widthAnchor constraintEqualToConstant:98],

[self.checkIMG.topAnchor constraintEqualToAnchor:self.imageView.bottomAnchor constant:12],
[self.checkIMG.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
[self.checkIMG.widthAnchor constraintEqualToConstant:24],
[self.checkIMG.heightAnchor constraintEqualToConstant:24],
]];
}
return self;
}
+ (NSString *)reuseIdentifier {
return @"appicon";
}
@end
16 changes: 16 additions & 0 deletions AppIcon/BHAppIconItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// BHAppIconItem.h
// BHTwitter
//
// Created by Bandar Alruwaili on 10/12/2023.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface BHAppIconItem : NSObject
@property (nonatomic, strong) NSString *imageName;
@property (nonatomic, strong) NSString *settingsImageName;
@property(nonatomic, assign) BOOL isPrimaryIcon;
- (instancetype)initWithImageName:(NSString *)imageName settingsImageName:(NSString *)settingsImageName isPrimaryIcon:(bool)isPrimaryIcon;
@end
20 changes: 20 additions & 0 deletions AppIcon/BHAppIconItem.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// BHAppIconItem.m
// BHTwitter
//
// Created by Bandar Alruwaili on 10/12/2023.
//

#import "BHAppIconItem.h"

@implementation BHAppIconItem
- (instancetype)initWithImageName:(NSString *)imageName settingsImageName:(NSString *)settingsImageName isPrimaryIcon:(bool)isPrimaryIcon {
self = [super init];
if (self) {
_imageName = imageName;
_settingsImageName = settingsImageName;
_isPrimaryIcon = isPrimaryIcon;
}
return self;
}
@end
16 changes: 16 additions & 0 deletions AppIcon/BHAppIconViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// BHAppIconViewController.h
// BHTwitter
//
// Created by Bandar Alruwaili on 10/12/2023.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface BHAppIconViewController : UIViewController

@end

NS_ASSUME_NONNULL_END
142 changes: 142 additions & 0 deletions AppIcon/BHAppIconViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//
// BHAppIconViewController.m
// BHTwitter
//
// Created by Bandar Alruwaili on 10/12/2023.
//

#import "BHAppIconViewController.h"
#import "BHAppIconItem.h"
#import "BHAppIconCell.h"
#import "../BHTBundle/BHTBundle.h"

@interface BHAppIconViewController () <UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (nonatomic, strong) UICollectionView *appIconCollectionView;
@property (nonatomic, strong) UILabel *headerLabel;
@property (nonatomic, strong) NSMutableArray<BHAppIconItem *> *icons;

@end

@implementation BHAppIconViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.headerLabel = [[UILabel alloc] init];
self.headerLabel.text = [[BHTBundle sharedBundle] localizedStringForKey:@"APP_ICON_HEADER_TITLE"];
self.headerLabel.textColor = [UIColor secondaryLabelColor];
self.headerLabel.numberOfLines = 0;
self.headerLabel.font = [UIFont systemFontOfSize:15];
self.headerLabel.textAlignment = NSTextAlignmentJustified;
self.headerLabel.translatesAutoresizingMaskIntoConstraints = NO;

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
self.appIconCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
self.appIconCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways;
[self.appIconCollectionView registerClass:[BHAppIconCell class] forCellWithReuseIdentifier:[BHAppIconCell reuseIdentifier]];
self.appIconCollectionView.delegate = self;
self.appIconCollectionView.dataSource = self;
self.appIconCollectionView.translatesAutoresizingMaskIntoConstraints = NO;

self.icons = [NSMutableArray new];

[self setupAppIcons];

self.navigationController.navigationBar.prefersLargeTitles = NO;
self.view.backgroundColor = [UIColor systemBackgroundColor];
[self.view addSubview:self.headerLabel];
[self.view addSubview:self.appIconCollectionView];

[NSLayoutConstraint activateConstraints:@[
[self.headerLabel.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],
[self.headerLabel.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor constant:16],
[self.headerLabel.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor constant:-16],

[self.appIconCollectionView.topAnchor constraintEqualToAnchor:self.headerLabel.bottomAnchor],
[self.appIconCollectionView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
[self.appIconCollectionView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
[self.appIconCollectionView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
]];
}

- (void)setupAppIcons {
NSBundle *appBundle = [NSBundle mainBundle];
NSDictionary *CFBundleIcons = [appBundle objectForInfoDictionaryKey:@"CFBundleIcons"];
NSDictionary *CFBundlePrimaryIcon = CFBundleIcons[@"CFBundlePrimaryIcon"];
NSString *primaryIcon = CFBundlePrimaryIcon[@"CFBundleIconName"];

NSDictionary *CFBundleAlternateIcons = CFBundleIcons[@"CFBundleAlternateIcons"];

[self.icons addObject:[[BHAppIconItem alloc] initWithImageName:primaryIcon
settingsImageName:@"Icon-Production-settings"
isPrimaryIcon:YES]];

[CFBundleAlternateIcons enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
[self.icons addObject:[[BHAppIconItem alloc] initWithImageName:key
settingsImageName:[NSString stringWithFormat:@"%@-settings", key]
isPrimaryIcon:NO]];
}];

[self.appIconCollectionView reloadData];
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.icons.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
BHAppIconCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[BHAppIconCell reuseIdentifier] forIndexPath:indexPath];
BHAppIconItem *currCell = self.icons[indexPath.row];
cell.imageView.image = [UIImage imageNamed:currCell.settingsImageName];

NSString *alternateIconName = [UIApplication sharedApplication].alternateIconName;
if (alternateIconName) {
if ([currCell.imageName isEqualToString:alternateIconName]) {
[collectionView.visibleCells enumerateObjectsUsingBlock:^(__kindof UICollectionViewCell * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
BHAppIconCell *iconCell = (BHAppIconCell *)obj;
iconCell.checkIMG.image = [UIImage systemImageNamed:@"circle"];
}];
cell.checkIMG.image = [UIImage systemImageNamed:@"checkmark.circle"];
}
} else if (currCell.isPrimaryIcon) {
[collectionView.visibleCells enumerateObjectsUsingBlock:^(__kindof UICollectionViewCell * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
BHAppIconCell *iconCell = (BHAppIconCell *)obj;
iconCell.checkIMG.image = [UIImage systemImageNamed:@"circle"];
}];
cell.checkIMG.image = [UIImage systemImageNamed:@"checkmark.circle"];
}

return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
BHAppIconItem *iconItem = self.icons[indexPath.row];
[collectionView.visibleCells enumerateObjectsUsingBlock:^(__kindof UICollectionViewCell * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
BHAppIconCell *iconCell = (BHAppIconCell *)obj;
iconCell.checkIMG.image = [UIImage systemImageNamed:@"circle"];
}];
BHAppIconCell *currCell = (BHAppIconCell *)[collectionView cellForItemAtIndexPath:indexPath];
[[UIApplication sharedApplication] setAlternateIconName:(iconItem.isPrimaryIcon ? nil : iconItem.imageName) completionHandler:^(NSError * _Nullable error) {
if (!error) {
currCell.checkIMG.image = [UIImage systemImageNamed:@"checkmark.circle"];
}
}];
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(16, 16, 16, 16);
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
return 10;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
return 10;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(98, 136);
}

@end
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7099a06

Please sign in to comment.