Skip to content

Commit

Permalink
Updated a lot of uYouEnhanced Code. (v19.40.4-3.0.4)
Browse files Browse the repository at this point in the history
This release also includes all of the new changes from qnblackcat/uYouPlus.
and the App Version Spoofer has finally been updated again!
  • Loading branch information
arichornlover authored Oct 10, 2024
1 parent ae55587 commit 35e97ea
Show file tree
Hide file tree
Showing 15 changed files with 1,523 additions and 977 deletions.
107 changes: 21 additions & 86 deletions Sources/AppIconOptionsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
#import <YouTubeHeader/YTAssetLoader.h>

@interface AppIconOptionsController () <UITableViewDataSource, UITableViewDelegate>

@property (strong, nonatomic) UITableView *tableView;
@property (strong, nonatomic) NSArray<NSString *> *appIcons;
@property (assign, nonatomic) NSInteger selectedIconIndex;

@end

@implementation AppIconOptionsController
Expand All @@ -15,8 +13,6 @@ - (void)viewDidLoad {
[super viewDidLoad];

self.title = @"Change App Icon";
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"YTSans-Bold" size:22], NSForegroundColorAttributeName: [UIColor whiteColor]}];

self.selectedIconIndex = -1;

self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
Expand All @@ -25,28 +21,11 @@ - (void)viewDidLoad {
[self.view addSubview:self.tableView];

self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
NSBundle *backIcon = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"]];
UIImage *backImage = [UIImage imageNamed:@"Back.png" inBundle:backIcon compatibleWithTraitCollection:nil];
backImage = [self resizeImage:backImage newSize:CGSizeMake(24, 24)];
backImage = [backImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.backButton setTintColor:[UIColor whiteColor]];
[self.backButton setImage:backImage forState:UIControlStateNormal];
[self.backButton setImage:[UIImage customBackButtonImage] forState:UIControlStateNormal];
[self.backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[self.backButton setFrame:CGRectMake(0, 0, 24, 24)];
UIBarButtonItem *customBackButton = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
self.navigationItem.leftBarButtonItem = customBackButton;

UIColor *buttonColor = [UIColor colorWithRed:203.0/255.0 green:22.0/255.0 blue:51.0/255.0 alpha:1.0];
UIImage *resetImage = [UIImage systemImageNamed:@"arrow.clockwise.circle.fill"];
UIBarButtonItem *resetButton = [[UIBarButtonItem alloc] initWithImage:resetImage style:UIBarButtonItemStylePlain target:self action:@selector(resetIcon)];
resetButton.tintColor = buttonColor;

UIImage *saveImage = [UIImage systemImageNamed:@"square.and.arrow.up.fill"];
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithImage:saveImage style:UIBarButtonItemStylePlain target:self action:@selector(saveIcon)];
saveButton.tintColor = buttonColor;

self.navigationItem.rightBarButtonItems = @[saveButton, resetButton];

NSString *path = [[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:path];
self.appIcons = [bundle pathsForResourcesOfType:@"png" inDirectory:@"AppIcons"];
Expand Down Expand Up @@ -77,14 +56,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.imageView.image = iconImage;
cell.imageView.layer.cornerRadius = 10.0;
cell.imageView.clipsToBounds = YES;
cell.imageView.frame = CGRectMake(10, 10, 40, 40);
cell.textLabel.frame = CGRectMake(60, 10, self.view.frame.size.width - 70, 40);

if (indexPath.row == self.selectedIconIndex) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.accessoryType = (indexPath.row == self.selectedIconIndex) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

return cell;
}
Expand All @@ -97,82 +70,44 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}

- (void)resetIcon {
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
[infoDict removeObjectForKey:@"ALTAppIcon"];
[infoDict writeToFile:plistPath atomically:YES];

[[UIApplication sharedApplication] setAlternateIconName:nil completionHandler:^(NSError * _Nullable error) {
if (error) {
NSLog(@"Error resetting icon: %@", error.localizedDescription);
[self showAlertWithTitle:@"Error" message:@"Failed to reset icon"];
} else {
NSLog(@"Icon reset successfully");
[self showAlertWithTitle:@"Success" message:@"Icon reset successfully"];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
[self.tableView reloadData];
}
}];
}

- (void)saveIcon {
if (![UIApplication sharedApplication].supportsAlternateIcons) {
NSLog(@"Alternate icons are not supported on this device.");
if (self.selectedIconIndex < 0) {
[self showAlertWithTitle:@"Error" message:@"No icon selected"];
return;
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *selectedIcon = self.selectedIconIndex >= 0 ? self.appIcons[self.selectedIconIndex] : nil;
if (selectedIcon) {
NSString *iconName = [selectedIcon.lastPathComponent stringByDeletingPathExtension];

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
[infoDict setObject:iconName forKey:@"ALTAppIcon"];
[infoDict writeToFile:plistPath atomically:YES];

[[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) {
if (error) {
NSLog(@"Error setting alternate icon: %@", error.localizedDescription);
[self showAlertWithTitle:@"Error" message:@"Failed to set alternate icon"];
} else {
NSLog(@"Alternate icon set successfully");
[self showAlertWithTitle:@"Success" message:@"Alternate icon set successfully"];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}
}];
} else {
NSLog(@"Selected icon path is nil");
}
});
}

- (UIImage *)resizeImage:(UIImage *)image toSize:(CGSize)size {
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return resizedImage;
}
NSString *selectedIcon = self.appIcons[self.selectedIconIndex];
NSString *iconName = [selectedIcon.lastPathComponent stringByDeletingPathExtension];

- (UIImage *)resizeImage:(UIImage *)image newSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, NO, [UIScreen mainScreen].scale);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
[[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) {
if (error) {
NSLog(@"Error setting alternate icon: %@", error.localizedDescription);
[self showAlertWithTitle:@"Error" message:@"Failed to set alternate icon"];
} else {
NSLog(@"Alternate icon set successfully");
[self showAlertWithTitle:@"Success" message:@"Alternate icon set successfully"];
[self.tableView reloadData];
}
}];
}

- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:okAction];
[self presentViewController:alert animated:YES completion:nil];
});
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:okAction];
[self presentViewController:alert animated:YES completion:nil];
}

- (void)back {
Expand Down
2 changes: 1 addition & 1 deletion Sources/BigYTMiniPlayer.xm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%end

%ctor {
if (IS_ENABLED(@"bigYTMiniPlayer_enabled") && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) {
if (IS_ENABLED(kBigYTMiniPlayer) && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) {
%init(BigYTMiniPlayer);
}
}
52 changes: 46 additions & 6 deletions Sources/LowContrastMode.xm
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ static BOOL lowContrastMode() {
static BOOL customContrastMode() {
return IS_ENABLED(@"lowContrastMode_enabled") && contrastMode() == 1;
}
// static UIColor *whiteTextColor() {
// return [UIColor whiteColor];
// }

UIColor *lcmHexColor;

%group gLowContrastMode // Low Contrast Mode v1.5.2 (Compatible with only YouTube v17.33.2-v17.38.10)
%group gLowContrastMode // Low Contrast Mode v1.6.0 BETA (Compatible with only YouTube v17.33.2-v17.38.10)
%hook UIColor
+ (UIColor *)whiteColor { // Dark Theme Color
return [UIColor colorWithRed: 0.56 green: 0.56 blue: 0.56 alpha: 1.00];
Expand Down Expand Up @@ -54,39 +57,51 @@ UIColor *lcmHexColor;
%end
%hook YTCommonColorPalette
- (UIColor *)textPrimary {
NSLog(@"LowContrastMode: textPrimary called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)textSecondary {
NSLog(@"LowContrastMode: textSecondary called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)overlayTextPrimary {
NSLog(@"LowContrastMode: overlayTextPrimary called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)overlayTextSecondary {
NSLog(@"LowContrastMode: overlayTextSecondary called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)iconActive {
NSLog(@"LowContrastMode: iconActive called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)iconActiveOther {
NSLog(@"LowContrastMode: iconActiveOther called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)brandIconActive {
NSLog(@"LowContrastMode: brandIconActive called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)staticBrandWhite {
NSLog(@"LowContrastMode: staticBrandWhite called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)overlayIconActiveOther {
NSLog(@"LowContrastMode: overlayIconActiveOther called");
return self.pageStyle == 1 ? [UIColor whiteColor] : %orig;
}
- (UIColor *)overlayIconInactive {
NSLog(@"LowContrastMode: overlayIconInactive called");
return self.pageStyle == 1 ? [[UIColor whiteColor] colorWithAlphaComponent:0.7] : %orig;
}
- (UIColor *)overlayIconDisabled {
NSLog(@"LowContrastMode: overlayIconDisabled called");
return self.pageStyle == 1 ? [[UIColor whiteColor] colorWithAlphaComponent:0.3] : %orig;
}
- (UIColor *)overlayFilledButtonActive {
NSLog(@"LowContrastMode: overlayFilledButtonActive called");
return self.pageStyle == 1 ? [[UIColor whiteColor] colorWithAlphaComponent:0.2] : %orig;
}
%end
Expand Down Expand Up @@ -246,19 +261,33 @@ UIColor *lcmHexColor;
[modifiedAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
%orig(modifiedAttributes, state);
}
- (void)setCustomTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
NSMutableDictionary *customAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
[customAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
%orig(customAttributes, state);
}
%end
%hook UIButton
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state {
color = [UIColor whiteColor];
%orig(color, state);
}
- (void)setCustomTitleColor:(UIColor *)color forState:(UIControlState)state {
color = [UIColor whiteColor];
%orig(color, state);
}
%end
%hook UIBarButtonItem
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
[modifiedAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
%orig(modifiedAttributes, state);
}
- (void)setCustomTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state {
NSMutableDictionary *customAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
[customAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
%orig(customAttributes, state);
}
%end
%hook NSAttributedString
- (instancetype)initWithString:(NSString *)str attributes:(NSDictionary<NSAttributedStringKey, id> *)attrs {
Expand Down Expand Up @@ -550,7 +579,18 @@ UIColor *lcmHexColor;
%end
%hook CATextLayer
- (void)setTextColor:(CGColorRef)textColor {
%orig([UIColor whiteColor].CGColor);
%orig([[UIColor whiteColor] CGColor]);
}
%end
%hook _ASDisplayView
- (void)setAttributedText:(NSAttributedString *)attributedText {
NSMutableAttributedString *newAttributedString = [attributedText mutableCopy];
[newAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, newAttributedString.length)];
%orig(newAttributedString);
}
- (void)setTextColor:(UIColor *)textColor {
textColor = [UIColor whiteColor];
%orig(textColor);
}
%end
%hook ASTextNode
Expand All @@ -563,20 +603,20 @@ UIColor *lcmHexColor;
%end
%hook ASTextFieldNode
- (void)setTextColor:(UIColor *)textColor {
%orig([UIColor whiteColor]);
%orig([UIColor whiteColor]);
}
%end
%hook ASTextView
- (void)setTextColor:(UIColor *)textColor {
%orig([UIColor whiteColor]);
%orig([UIColor whiteColor]);
}
%end
%hook ASButtonNode
- (void)setTextColor:(UIColor *)textColor {
%orig([UIColor whiteColor]);
%orig([UIColor whiteColor]);
}
%end
%hook UIControl // snackbar fix for lcm
%hook UIControl
- (UIColor *)backgroundColor {
return [UIColor blackColor];
}
Expand Down
9 changes: 2 additions & 7 deletions Sources/SettingsKeys.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#import "uYouPlus.h"
#import "uYouPlusSettings.h"

// Keys for "Copy settings" button (for: uYouEnhanced)
// In alphabetical order for tweaks after uYouEnhanced
NSArray *NSUserDefaultsCopyKeys = @[
// uYouEnhanced - gathered using get_keys.py
@"autoHideHomeBar_enabled", @"bigYTMiniPlayer_enabled", @"centerYouTubeLogo_enabled", @"classicVideoPlayer_enabled", @"disableAmbientMode_enabled", @"disableAnimatedYouTubeLogo_enabled", @"disableChapterSkip_enabled", @"disableCollapseButton_enabled", @"disableFullscreenButton_enabled", @"disableHints_enabled",
@"disableLiveChatSection_enabled", @"disableManageAllHistorySection_enabled", @"disableModernButtons_enabled", @"disableModernFlags_enabled", @"disableNotificationsSection_enabled", @"disablePrivacySection_enabled", @"disablePullToFull_enabled", @"disableRemainingTime_enabled", @"disableResumeToShorts_enabled",@"disableRoundedHints_enabled", @"disableTryNewFeaturesSection_enabled", @"disableVideoQualityPreferencesSection_enabled", @"disableAccountSection_enabled",
@"doubleTapToSeek_disabled", @"enableShareButton_enabled", @"enableSaveToButton_enabled", @"enableVersionSpoofer_enabled", @"fixLowContrastMode_enabled", @"flex_enabled", @"hideAutoplaySwitch_enabled", @"hideBuySuperThanks_enabled", @"hideCC_enabled", @"hideChannelHeaderLinks_enabled", @"hideChannelWatermark_enabled",
@"hideChipBar_enabled", @"hideClipButton_enabled", @"hideCommentSection_enabled", @"hideCommunityPosts_enabled", @"hideConnectButton_enabled", @"hideDownloadButton_enabled", @"hideDoubleTapToSeekOverlay_enabled", @"hideFullscreenActions_enabled", @"hideHeatwaves_enabled", @"hideHomeTab_enabled", @"hideHoverCards_enabled", @"hideHUD_enabled", @"hideModernFlags_enabled", @"hidePaidPromotionCard_enabled", @"hidePlayNextInQueue_enabled",
@"hidePreviewCommentSection_enabled", @"hidePreviousAndNextButton_enabled", @"hideRemixButton_enabled", @"hideReportButton_enabled", @"hideRightPanel_enabled", @"hideShareButton_enabled", @"hideSponsorBlockButton_enabled", @"hideSubcriptions_enabled", @"hideSubscriptionsNotificationBadge_enabled", @"hideThanksButton_enabled", @"hideVideoPlayerShadowOverlayButtons_enabled", @"hideVideoTitle_enabled", @"hideYouTubeLogo_enabled",
@"lowContrastMode_enabled", @"newSettingsUI_enabled", @"noRelatedWatchNexts_enabled", @"noSuggestedVideo_enabled", @"noVideosInFullscreen_enabled",
@"pinchToZoom_enabled", @"portraitFullscreen_enabled", @"redProgressBar_enabled", @"redSubscribeButton_enabled", @"reExplore_enabled", @"shortsQualityPicker_enabled", @"slideToSeek_enabled", @"snapToChapter_enabled", @"stockVolumeHUD_enabled", @"stickNavigationBar_enabled", @"uYouAdBlockingWorkaround_enabled", @"uYouAdBlockingWorkaroundLite_enabled", @"ytMiniPlayer_enabled", @"ytNoModernUI_enabled", @"ytStartupAnimation_enabled",
kReplaceCopyandPasteButtons, kAppTheme, kOLEDKeyboard, kPortraitFullscreen, kFullscreenToTheRight, kSlideToSeek, kYTTapToSeek, kDoubleTapToSeek, kSnapToChapter, kPinchToZoom, kYTMiniPlayer, kStockVolumeHUD, kReplaceYTDownloadWithuYou, kDisablePullToFull, kDisableChapterSkip, kAlwaysShowRemainingTime, kDisableRemainingTime, kEnableShareButton, kEnableSaveToButton, kHideYTMusicButton, kHideAutoplaySwitch, kHideCC, kHideVideoTitle, kDisableCollapseButton, kDisableFullscreenButton, kHideHUD, kHidePaidPromotionCard, kHideChannelWatermark, kHideVideoPlayerShadowOverlayButtons, kHidePreviousAndNextButton, kRedProgressBar, kHideHoverCards, kHideRightPanel, kHideFullscreenActions, kHideSuggestedVideo, kHideHeatwaves, kHideDoubleTapToSeekOverlay, kHideOverlayDarkBackground, kDisableAmbientMode, kHideVideosInFullscreen, kHideRelatedWatchNexts, kHideBuySuperThanks, kHideSubscriptions, kShortsQualityPicker, kRedSubscribeButton, kHideButtonContainers, kHideConnectButton, kHideShareButton, kHideRemixButton, kHideThanksButton, kHideDownloadButton, kHideClipButton, kHideSaveToPlaylistButton, kHideReportButton, kHidePreviewCommentSection, kHideCommentSection, kDisableAccountSection, kDisableAutoplaySection, kDisableTryNewFeaturesSection, kDisableVideoQualityPreferencesSection, kDisableNotificationsSection, kDisableManageAllHistorySection, kDisableYourDataInYouTubeSection, kDisablePrivacySection, kDisableLiveChatSection, kHidePremiumPromos, kHideHomeTab, kLowContrastMode, kClassicVideoPlayer, kFixLowContrastMode, kDisableModernButtons, kDisableRoundedHints, kDisableModernFlags, kYTNoModernUI, kEnableVersionSpoofer, kGoogleSignInPatch, kAdBlockWorkaroundLite, kAdBlockWorkaround, kYouTabFakePremium, kDisableAnimatedYouTubeLogo, kCenterYouTubeLogo, kHideYouTubeLogo, kYTStartupAnimation, kDisableHints, kStickNavigationBar, kHideiSponsorBlockButton, kHideChipBar, kHidePlayNextInQueue, kHideCommunityPosts, kHideChannelHeaderLinks, kiPhoneLayout, kBigYTMiniPlayer, kReExplore, kAutoHideHomeBar, kHideSubscriptionsNotificationBadge, kFixCasting, kNewSettingsUI, kFlex, kGoogleSigninFix,
// uYou - https://github.com/MiRO92/uYou-for-YouTube
@"showedWelcomeVC", @"hideShortsTab", @"hideCreateTab", @"hideCastButton", @"relatedVideosAtTheEndOfYTVideos", @"removeYouTubeAds", @"backgroundPlayback", @"disableAgeRestriction", @"iPadLayout", @"noSuggestedVideoAtEnd", @"shortsProgressBar", @"hideShortsCells", @"removeShortsCell", @"startupPage",
// DEMC - https://github.com/therealFoxster/DontEatMyContent/blob/master/Tweak.h
Expand Down
Loading

0 comments on commit 35e97ea

Please sign in to comment.