-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
5,592 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.theos/ | ||
packages/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// BHDownload.h | ||
// DIYTableView | ||
// | ||
// Created by BandarHelal on 12/01/1442 AH. | ||
// Copyright © 1442 BandarHelal. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@protocol BHDownloadDelegate <NSObject> | ||
@optional | ||
- (void)downloadProgress:(float)progress; | ||
- (void)downloadDidFinish:(NSURL *)filePath Filename:(NSString *)fileName; | ||
- (void)downloadDidFailureWithError:(NSError *)error; | ||
@end | ||
|
||
@interface BHDownload : NSObject | ||
{ | ||
id delegate; | ||
} | ||
- (void)setDelegate:(id)newDelegate; | ||
- (instancetype)init; | ||
- (void)downloadFileWithURL:(NSURL *)url; | ||
@property (nonatomic, strong) NSString *fileName; | ||
@end | ||
|
||
@interface BHDownload () <NSURLSessionDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSURLSessionStreamDelegate> | ||
@property (nonatomic, strong) NSURLSession *Session; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// BHDownload.m | ||
// DIYTableView | ||
// | ||
// Created by BandarHelal on 12/01/1442 AH. | ||
// Copyright © 1442 BandarHelal. All rights reserved. | ||
// | ||
|
||
#import "BHDownload.h" | ||
|
||
@implementation BHDownload | ||
- (instancetype)init { | ||
self = [super init]; | ||
if (self) { | ||
self.Session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)downloadFileWithURL:(NSURL *)url { | ||
if (url) { | ||
self.fileName = url.absoluteString.lastPathComponent; | ||
NSURLSessionDownloadTask *downloadTask = [self.Session downloadTaskWithURL:url]; | ||
[downloadTask resume]; | ||
} | ||
} | ||
- (void)setDelegate:(id)newDelegate { | ||
if (newDelegate) { | ||
delegate = newDelegate; | ||
} | ||
} | ||
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite { | ||
float prog = (float)totalBytesWritten / (float)totalBytesExpectedToWrite; | ||
[delegate downloadProgress:prog]; | ||
} | ||
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(nonnull NSURL *)location { | ||
[delegate downloadDidFinish:location Filename:self.fileName]; | ||
} | ||
- (void)URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error { | ||
[delegate downloadDidFailureWithError:error]; | ||
} | ||
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error { | ||
[delegate downloadDidFailureWithError:error]; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface BHIManager: NSObject | ||
+ (BOOL)hideAds; | ||
+ (BOOL)downloadVideos; | ||
+ (BOOL)downloadMusics; | ||
+ (BOOL)hideElementButton; | ||
+ (BOOL)copyVideoDecription; | ||
+ (BOOL)copyMusicLink; | ||
+ (BOOL)copyVideoLink; | ||
+ (BOOL)autoPlay; | ||
+ (BOOL)progressBar; | ||
+ (BOOL)likeConfirmation; | ||
+ (BOOL)likeCommentConfirmation; | ||
+ (BOOL)dislikeCommentConfirmation; | ||
+ (BOOL)followConfirmation; | ||
+ (BOOL)profileSave; | ||
+ (BOOL)profileCopy; | ||
+ (BOOL)alwaysOpenSafari; | ||
+ (BOOL)regionChangingEnabled; | ||
+ (NSDictionary *)selectedRegion; | ||
+ (BOOL)fakeChangesEnabled; | ||
+ (BOOL)fakeVerified; | ||
+ (BOOL)extendedBio; | ||
+ (BOOL)extendedComment; | ||
+ (BOOL)appLock; | ||
+ (void)showSaveVC:(id)item; | ||
+ (void)cleanCache; | ||
+ (BOOL)isEmpty:(NSURL *)url; | ||
+ (NSString *)getDownloadingPersent:(float)per; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#import "BHIManager.h" | ||
#import "TikTokHeaders.h" | ||
|
||
@implementation BHIManager | ||
+ (BOOL)hideAds { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_ads"]; | ||
} | ||
+ (BOOL)downloadVideos { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"dw_videos"]; | ||
} | ||
+ (BOOL)downloadMusics { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"dw_musics"]; | ||
} | ||
+ (BOOL)hideElementButton { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"remove_elements_button"]; | ||
} | ||
+ (BOOL)copyVideoDecription { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"copy_decription"]; | ||
} | ||
+ (BOOL)copyMusicLink { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"copy_music_link"]; | ||
} | ||
+ (BOOL)copyVideoLink { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"copy_video_link"]; | ||
} | ||
+ (BOOL)autoPlay { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"auto_play"]; | ||
} | ||
+ (BOOL)progressBar { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"show_porgress_bar"]; | ||
} | ||
+ (BOOL)likeConfirmation { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"like_confirm"]; | ||
} | ||
+ (BOOL)likeCommentConfirmation { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"like_comment_confirm"]; | ||
} | ||
+ (BOOL)dislikeCommentConfirmation { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"dislike_comment_confirm"]; | ||
} | ||
+ (BOOL)followConfirmation { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"follow_confirm"]; | ||
} | ||
+ (BOOL)profileSave { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"save_profile"]; | ||
} | ||
+ (BOOL)profileCopy { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"copy_profile_information"]; | ||
} | ||
+ (BOOL)alwaysOpenSafari { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"openInBrowser"]; | ||
} | ||
+ (BOOL)regionChangingEnabled { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"en_region"]; | ||
} | ||
+ (NSDictionary *)selectedRegion { | ||
return [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"region"]; | ||
} | ||
+ (BOOL)fakeChangesEnabled { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"en_fake"]; | ||
} | ||
+ (BOOL)fakeVerified { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"fake_verify"]; | ||
} | ||
+ (BOOL)extendedBio { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"extended_bio"]; | ||
} | ||
+ (BOOL)extendedComment { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"extendedComment"]; | ||
} | ||
+ (BOOL)appLock { | ||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"padlock"]; | ||
} | ||
+ (void)cleanCache { | ||
NSArray <NSURL *> *DocumentFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true).firstObject] includingPropertiesForKeys:@[] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil]; | ||
|
||
for (NSURL *file in DocumentFiles) { | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"mp4"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"png"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"jpeg"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"mp3"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"m4a"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
} | ||
|
||
NSArray <NSURL *> *TempFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] includingPropertiesForKeys:@[] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil]; | ||
|
||
for (NSURL *file in TempFiles) { | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"mp4"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"mov"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"tmp"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"png"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"jpeg"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"mp3"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file.pathExtension.lowercaseString isEqualToString:@"m4a"]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
if ([file hasDirectoryPath]) { | ||
if ([BHIManager isEmpty:file]) { | ||
[[NSFileManager defaultManager] removeItemAtURL:file error:nil]; | ||
} | ||
} | ||
} | ||
} | ||
+ (BOOL)isEmpty:(NSURL *)url { | ||
NSArray *FolderFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:url includingPropertiesForKeys:@[] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil]; | ||
if (FolderFiles.count == 0) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
+ (void)showSaveVC:(id)item { | ||
UIActivityViewController *acVC = [[UIActivityViewController alloc] initWithActivityItems:item applicationActivities:nil]; | ||
if (is_iPad()) { | ||
acVC.popoverPresentationController.sourceView = topMostController().view; | ||
acVC.popoverPresentationController.sourceRect = CGRectMake(topMostController().view.bounds.size.width / 2.0, topMostController().view.bounds.size.height / 2.0, 1.0, 1.0); | ||
} | ||
[topMostController() presentViewController:acVC animated:true completion:nil]; | ||
} | ||
|
||
+ (NSString *)getDownloadingPersent:(float)per { | ||
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; | ||
[numberFormatter setNumberStyle:NSNumberFormatterPercentStyle]; | ||
NSNumber *number = [NSNumber numberWithFloat:per]; | ||
return [numberFormatter stringFromNumber:number]; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@protocol BHMultipleDownloadDelegate <NSObject> | ||
- (void)downloaderProgress:(float)progress; | ||
- (void)downloaderDidFinishDownloadingAllFiles:(NSMutableArray<NSURL *> *)downloadedFilePaths; | ||
- (void)downloaderDidFailureWithError:(NSError *)error; | ||
@end | ||
|
||
@interface BHMultipleDownload : NSObject <NSURLSessionDownloadDelegate> | ||
@property (nonatomic, strong) NSURLSession *session; | ||
@property (nonatomic, weak) id<BHMultipleDownloadDelegate> delegate; | ||
- (void)downloadFiles:(NSArray<NSURL *> *)fileURLs; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#import "BHMultipleDownload.h" | ||
|
||
@implementation BHMultipleDownload { | ||
NSMutableArray<NSURL *> *_downloadedFilePaths; | ||
NSInteger _completedDownloads; | ||
NSInteger _totalDownloads; | ||
} | ||
|
||
- (instancetype)init { | ||
self = [super init]; | ||
if (self) { | ||
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; | ||
self.session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:[NSOperationQueue mainQueue]]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)downloadFiles:(NSArray<NSURL *> *)fileURLs { | ||
_downloadedFilePaths = [NSMutableArray array]; | ||
_completedDownloads = 0; | ||
_totalDownloads = fileURLs.count; | ||
|
||
for (NSURL *fileURL in fileURLs) { | ||
NSURLSessionDownloadTask *downloadTask = [self.session downloadTaskWithURL:fileURL]; | ||
[downloadTask resume]; | ||
} | ||
|
||
if (fileURLs.count == 0) { | ||
[self URLSession:self.session didBecomeInvalidWithError:[NSError errorWithDomain:NSURLErrorDomain code:99 userInfo:nil]]; | ||
} | ||
} | ||
|
||
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite { | ||
float prog = (float)totalBytesWritten / (float)totalBytesExpectedToWrite; | ||
if ([self.delegate respondsToSelector:@selector(downloaderProgress:)]) { | ||
[self.delegate downloaderProgress:prog]; | ||
} | ||
} | ||
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask | ||
didFinishDownloadingToURL:(NSURL *)location { | ||
NSString *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; | ||
NSString *destinationPath = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@-%@", NSUUID.UUID.UUIDString, downloadTask.response.suggestedFilename]]; | ||
|
||
NSError *error; | ||
[[NSFileManager defaultManager] moveItemAtURL:location toURL:[NSURL fileURLWithPath:destinationPath] error:&error]; | ||
|
||
if (error == nil) { | ||
[_downloadedFilePaths addObject:[NSURL fileURLWithPath:destinationPath]]; | ||
} | ||
|
||
_completedDownloads++; | ||
|
||
if (_completedDownloads == _totalDownloads) { | ||
if ([self.delegate respondsToSelector:@selector(downloaderDidFinishDownloadingAllFiles:)]) { | ||
[self.delegate downloaderDidFinishDownloadingAllFiles:_downloadedFilePaths]; | ||
} | ||
} | ||
} | ||
|
||
- (void)URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error { | ||
if ([self.delegate respondsToSelector:@selector(downloaderDidFailureWithError:)]) { | ||
[self.delegate downloaderDidFailureWithError:error]; | ||
} | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ Filter = { Bundles = ( "com.zhiliaoapp.musically" ); }; } |
Oops, something went wrong.