Move uYouPlus settings to new setting category

This commit is contained in:
BandarHelal 2022-05-07 20:04:36 +03:00
parent 3e4264e3c7
commit 34e34a4fef

View file

@ -1,4 +1,12 @@
#import "Tweaks/YouTubeHeader/YTSettingsViewController.h"
#import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h" #import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
#import "Tweaks/YouTubeHeader/YTSettingsSectionItemManager.h"
@interface YTSettingsSectionItemManager (YouPiP)
- (void)updateuYouPlusSectionWithEntry:(id)entry;
@end
static const NSInteger uYouPlusSection = 500;
extern BOOL hideHUD(); extern BOOL hideHUD();
extern BOOL oled(); extern BOOL oled();
@ -11,105 +19,112 @@ extern BOOL hideAutoplaySwitch();
extern BOOL castConfirm(); extern BOOL castConfirm();
// Settings // Settings
%hook YTSettingsViewController %hook YTAppSettingsPresentationData
- (void)setSectionItems:(NSMutableArray <YTSettingsSectionItem *>*)sectionItems forCategory:(NSInteger)category title:(NSString *)title titleDescription:(NSString *)titleDescription headerHidden:(BOOL)headerHidden { + (NSArray *)settingsCategoryOrder {
if (category == 1) { NSArray *order = %orig;
NSUInteger statsForNerdsIndex = [sectionItems indexOfObjectPassingTest:^BOOL (YTSettingsSectionItem *item, NSUInteger idx, BOOL *stop) { NSMutableArray *mutableOrder = [order mutableCopy];
return item.settingItemId == 265; NSUInteger insertIndex = [order indexOfObject:@(1)];
}]; if (insertIndex != NSNotFound)
if (statsForNerdsIndex != NSNotFound) { [mutableOrder insertObject:@(uYouPlusSection) atIndex:insertIndex + 1];
// return mutableOrder;
YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking TV."]; }
castConfirm.hasSwitch = YES;
castConfirm.switchVisible = YES; %end
castConfirm.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"castConfirm_enabled"];
castConfirm.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { %hook YTSettingsSectionItemManager
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"castConfirm_enabled"]; %new - (void)updateuYouPlusSectionWithEntry:(id)entry {
return YES; YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"];
};
[sectionItems insertObject:castConfirm atIndex:statsForNerdsIndex + 1]; YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking TV."];
// castConfirm.hasSwitch = YES;
YTSettingsSectionItem *hoverCardItem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Show End screens hover cards (YTNoHoverCards)" titleDescription:@"Allows creator End screens (thumbnails) to appear at the end of videos."]; castConfirm.switchVisible = YES;
hoverCardItem.hasSwitch = YES; castConfirm.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"castConfirm_enabled"];
hoverCardItem.switchVisible = YES; castConfirm.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
hoverCardItem.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hover_cards_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"castConfirm_enabled"];
hoverCardItem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { return YES;
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hover_cards_enabled"]; };
return YES;
}; YTSettingsSectionItem *hoverCardItem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Show End screens hover cards (YTNoHoverCards)" titleDescription:@"Allows creator End screens (thumbnails) to appear at the end of videos."];
[sectionItems insertObject:hoverCardItem atIndex:statsForNerdsIndex + 1]; hoverCardItem.hasSwitch = YES;
// hoverCardItem.switchVisible = YES;
YTSettingsSectionItem *bigYTMiniPlayer = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"New miniplayer bar style (BigYTMiniPlayer)" titleDescription:@"App restart is required."]; hoverCardItem.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hover_cards_enabled"];
bigYTMiniPlayer.hasSwitch = YES; hoverCardItem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
bigYTMiniPlayer.switchVisible = YES; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hover_cards_enabled"];
bigYTMiniPlayer.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"bigYTMiniPlayer_enabled"]; return YES;
bigYTMiniPlayer.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { };
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"bigYTMiniPlayer_enabled"];
return YES; YTSettingsSectionItem *bigYTMiniPlayer = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"New miniplayer bar style (BigYTMiniPlayer)" titleDescription:@"App restart is required."];
}; bigYTMiniPlayer.hasSwitch = YES;
[sectionItems insertObject:bigYTMiniPlayer atIndex:statsForNerdsIndex + 2]; bigYTMiniPlayer.switchVisible = YES;
// bigYTMiniPlayer.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"bigYTMiniPlayer_enabled"];
YTSettingsSectionItem *reExplore = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Replace Shorts tab with Explore tab (YTReExplore)" titleDescription:@"App restart is required."]; bigYTMiniPlayer.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
reExplore.hasSwitch = YES; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"bigYTMiniPlayer_enabled"];
reExplore.switchVisible = YES; return YES;
reExplore.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"reExplore_enabled"]; };
reExplore.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"reExplore_enabled"]; YTSettingsSectionItem *reExplore = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Replace Shorts tab with Explore tab (YTReExplore)" titleDescription:@"App restart is required."];
return YES; reExplore.hasSwitch = YES;
}; reExplore.switchVisible = YES;
[sectionItems insertObject:reExplore atIndex:statsForNerdsIndex + 2]; reExplore.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"reExplore_enabled"];
// reExplore.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
YTSettingsSectionItem *hideCC = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide Subtitles button" titleDescription:@"Hide the Subtitles button in video controls overlay. "]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"reExplore_enabled"];
hideCC.hasSwitch = YES; return YES;
hideCC.switchVisible = YES; };
hideCC.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideCC_enabled"];
hideCC.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { YTSettingsSectionItem *hideCC = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide Subtitles button" titleDescription:@"Hide the Subtitles button in video controls overlay. "];
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideCC_enabled"]; hideCC.hasSwitch = YES;
return YES; hideCC.switchVisible = YES;
}; hideCC.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideCC_enabled"];
[sectionItems insertObject:hideCC atIndex:statsForNerdsIndex + 1]; hideCC.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
// [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideCC_enabled"];
YTSettingsSectionItem *hideAutoplaySwitch = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide Autoplay switch" titleDescription:@"Hide the Autoplay switch button in video controls overlay."]; return YES;
hideAutoplaySwitch.hasSwitch = YES; };
hideAutoplaySwitch.switchVisible = YES;
hideAutoplaySwitch.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideAutoplaySwitch_enabled"]; YTSettingsSectionItem *hideAutoplaySwitch = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide Autoplay switch" titleDescription:@"Hide the Autoplay switch button in video controls overlay."];
hideAutoplaySwitch.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { hideAutoplaySwitch.hasSwitch = YES;
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideAutoplaySwitch_enabled"]; hideAutoplaySwitch.switchVisible = YES;
return YES; hideAutoplaySwitch.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideAutoplaySwitch_enabled"];
}; hideAutoplaySwitch.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
[sectionItems insertObject:hideAutoplaySwitch atIndex:statsForNerdsIndex + 1]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideAutoplaySwitch_enabled"];
// return YES;
YTSettingsSectionItem *autoFUll = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Auto Full Screen (YTAutoFullScreen)" titleDescription:@"Autoplay videos at full screen."]; };
autoFUll.hasSwitch = YES;
autoFUll.switchVisible = YES; YTSettingsSectionItem *autoFUll = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Auto Full Screen (YTAutoFullScreen)" titleDescription:@"Autoplay videos at full screen."];
autoFUll.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"autofull_enabled"]; autoFUll.hasSwitch = YES;
autoFUll.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { autoFUll.switchVisible = YES;
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"autofull_enabled"]; autoFUll.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"autofull_enabled"];
return YES; autoFUll.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
}; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"autofull_enabled"];
[sectionItems insertObject:autoFUll atIndex:statsForNerdsIndex + 3]; return YES;
// };
YTSettingsSectionItem *hideHUD = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide HUD Messages" titleDescription:@"Example: CC is turned on/off, Video loop is on,..."];
hideHUD.hasSwitch = YES; YTSettingsSectionItem *hideHUD = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide HUD Messages" titleDescription:@"Example: CC is turned on/off, Video loop is on,..."];
hideHUD.switchVisible = YES; hideHUD.hasSwitch = YES;
hideHUD.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"]; hideHUD.switchVisible = YES;
hideHUD.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { hideHUD.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"];
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHUD_enabled"]; hideHUD.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
return YES; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHUD_enabled"];
}; return YES;
[sectionItems insertObject:hideHUD atIndex:statsForNerdsIndex + 1]; };
//
YTSettingsSectionItem *Oleditem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"OLED Dark mode (Experimental)" titleDescription:@"WARNING: OLED Dark mode only works when YouTube is in Dark theme. App restart is required (In case OLED dark mode doesn't work: just switch between Light/Dark theme, then restart the app)."]; YTSettingsSectionItem *Oleditem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"OLED Dark mode (Experimental)" titleDescription:@"WARNING: OLED Dark mode only works when YouTube is in Dark theme. App restart is required (In case OLED dark mode doesn't work: just switch between Light/Dark theme, then restart the app)."];
Oleditem.hasSwitch = YES; Oleditem.hasSwitch = YES;
Oleditem.switchVisible = YES; Oleditem.switchVisible = YES;
Oleditem.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"oled_enabled"]; Oleditem.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"oled_enabled"];
Oleditem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { Oleditem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oled_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oled_enabled"];
return YES; return YES;
}; };
[sectionItems insertObject:Oleditem atIndex:statsForNerdsIndex + 1];
} NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[castConfirm, hoverCardItem, bigYTMiniPlayer, reExplore, hideCC, hideAutoplaySwitch, autoFUll, hideHUD, Oleditem]];
[delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO];
}
- (void)updateSectionForCategory:(NSUInteger)category withEntry:(id)entry {
if (category == uYouPlusSection) {
[self updateuYouPlusSectionWithEntry:entry];
return;
} }
%orig; %orig;
} }
%end %end