mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-01-11 22:40:19 +00:00
192 lines
9.9 KiB
Text
192 lines
9.9 KiB
Text
#import "../Tweaks/YouTubeHeader/YTSettingsViewController.h"
|
|
#import "../Tweaks/YouTubeHeader/YTSearchableSettingsViewController.h"
|
|
#import "../Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
|
|
#import "../Tweaks/YouTubeHeader/YTSettingsSectionItemManager.h"
|
|
#import "../Tweaks/YouTubeHeader/YTUIUtils.h"
|
|
#import "../Tweaks/YouTubeHeader/YTSettingsPickerViewController.h"
|
|
#import "uYouPlus.h"
|
|
|
|
#define SECTION_HEADER(s) [sectionItems addObject:[%c(YTSettingsSectionItem) itemWithTitle:nil titleDescription:[s uppercaseString] accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger sectionItemIndex) { return NO; }]]
|
|
|
|
#define SWITCH_ITEM(t, d, k) [sectionItems addObject:[YTSettingsSectionItemClass switchItemWithTitle:t titleDescription:d accessibilityIdentifier:nil switchOn:IS_ENABLED(k) switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:k];return YES;} settingItemId:0]]
|
|
|
|
static const NSInteger uYouPlusSection = 500;
|
|
|
|
@interface YTSettingsSectionItemManager (uYouPlus)
|
|
- (void)updateTweakSectionWithEntry:(id)entry;
|
|
@end
|
|
|
|
extern NSBundle *uYouPlusBundle();
|
|
|
|
// Settings
|
|
%hook YTAppSettingsPresentationData
|
|
+ (NSArray *)settingsCategoryOrder {
|
|
NSArray *order = %orig;
|
|
NSMutableArray *mutableOrder = [order mutableCopy];
|
|
NSUInteger insertIndex = [order indexOfObject:@(1)];
|
|
if (insertIndex != NSNotFound)
|
|
[mutableOrder insertObject:@(uYouPlusSection) atIndex:insertIndex + 1];
|
|
return mutableOrder;
|
|
}
|
|
%end
|
|
|
|
%hook YTSettingsSectionController
|
|
- (void)setSelectedItem:(NSUInteger)selectedItem {
|
|
if (selectedItem != NSNotFound) %orig;
|
|
}
|
|
%end
|
|
|
|
%hook YTSettingsSectionItemManager
|
|
%new(v@:@)
|
|
- (void)updateTweakSectionWithEntry:(id)entry {
|
|
NSMutableArray *sectionItems = [NSMutableArray array];
|
|
NSBundle *tweakBundle = uYouPlusBundle();
|
|
Class YTSettingsSectionItemClass = %c(YTSettingsSectionItem);
|
|
YTSettingsViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"];
|
|
|
|
# pragma mark - App theme
|
|
SECTION_HEADER(@"App theme");
|
|
|
|
YTSettingsSectionItem *themeGroup = [YTSettingsSectionItemClass
|
|
itemWithTitle:LOC(@"THEME_OPTIONS")
|
|
accessibilityIdentifier:nil
|
|
detailTextBlock:^NSString *() {
|
|
switch (APP_THEME_IDX) {
|
|
case 1:
|
|
return LOC(@"OLED_DARK_THEME_2");
|
|
case 2:
|
|
return LOC(@"OLD_DARK_THEME");
|
|
case 0:
|
|
default:
|
|
return LOC(@"DEFAULT_THEME");
|
|
}
|
|
}
|
|
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
|
NSArray <YTSettingsSectionItem *> *rows = @[
|
|
[YTSettingsSectionItemClass checkmarkItemWithTitle:LOC(@"DEFAULT_THEME") titleDescription:LOC(@"DEFAULT_THEME_DESC") selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
|
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"appTheme"];
|
|
[settingsViewController reloadData];
|
|
return YES;
|
|
}],
|
|
[YTSettingsSectionItemClass checkmarkItemWithTitle:LOC(@"OLED_DARK_THEME") titleDescription:LOC(@"OLED_DARK_THEME_DESC") selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
|
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"appTheme"];
|
|
[settingsViewController reloadData];
|
|
return YES;
|
|
}],
|
|
[YTSettingsSectionItemClass checkmarkItemWithTitle:LOC(@"OLD_DARK_THEME") titleDescription:LOC(@"OLD_DARK_THEME_DESC") selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
|
[[NSUserDefaults standardUserDefaults] setInteger:2 forKey:@"appTheme"];
|
|
[settingsViewController reloadData];
|
|
return YES;
|
|
}],
|
|
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"OLED_KEYBOARD")
|
|
titleDescription:LOC(@"OLED_KEYBOARD_DESC")
|
|
accessibilityIdentifier:nil
|
|
switchOn:IS_ENABLED(@"oledKeyBoard_enabled")
|
|
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oledKeyBoard_enabled"];
|
|
return YES;
|
|
}
|
|
settingItemId:0]
|
|
];
|
|
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"THEME_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:APP_THEME_IDX parentResponder:[self parentResponder]];
|
|
[settingsViewController pushViewController:picker];
|
|
return YES;
|
|
}
|
|
];
|
|
[sectionItems addObject:themeGroup];
|
|
|
|
# pragma mark - Video player options
|
|
SECTION_HEADER(LOC(@"VIDEO_PLAYER_OPTIONS"));
|
|
|
|
SWITCH_ITEM(LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK"), LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK_DESC"), @"doubleTapToSeek_disabled");
|
|
SWITCH_ITEM(LOC(@"SNAP_TO_CHAPTER"), LOC(@"SNAP_TO_CHAPTER_DESC"), @"snapToChapter_enabled");
|
|
SWITCH_ITEM(LOC(@"PINCH_TO_ZOOM"), LOC(@"PINCH_TO_ZOOM_DESC"), @"pinchToZoom_enabled");
|
|
SWITCH_ITEM(LOC(@"YT_MINIPLAYER"), LOC(@"YT_MINIPLAYER_DESC"), @"ytMiniPlayer_enabled");
|
|
SWITCH_ITEM(LOC(@"STOCK_VOLUME_HUD"), LOC(@"STOCK_VOLUME_HUD_DESC"), @"stockVolumeHUD_enabled");
|
|
|
|
# pragma mark - Video controls overlay options
|
|
SECTION_HEADER(LOC(@"VIDEO_CONTROLS_OVERLAY_OPTIONS"));
|
|
|
|
SWITCH_ITEM(LOC(@"HIDE_AUTOPLAY_SWITCH"), LOC(@"HIDE_AUTOPLAY_SWITCH_DESC"), @"hideAutoplaySwitch_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_SUBTITLES_BUTTON"), LOC(@"HIDE_SUBTITLES_BUTTON_DESC"), @"hideCC_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_HUD_MESSAGES"), LOC(@"HIDE_HUD_MESSAGES_DESC"), @"hideHUD_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_PAID_PROMOTION_CARDS"), LOC(@"HIDE_PAID_PROMOTION_CARDS_DESC"), @"hidePaidPromotionCard_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_CHANNEL_WATERMARK"), LOC(@"HIDE_CHANNEL_WATERMARK_DESC"), @"hideChannelWatermark_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON"), LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON_DESC"), @"hidePreviousAndNextButton_enabled");
|
|
SWITCH_ITEM(LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON"), LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON_DESC"), @"replacePreviousAndNextButton_enabled");
|
|
SWITCH_ITEM(LOC(@"RED_PROGRESS_BAR"), LOC(@"RED_PROGRESS_BAR_DESC"), @"redProgressBar_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_HOVER_CARD"), LOC(@"HIDE_HOVER_CARD_DESC"), @"hideHoverCards_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_RIGHT_PANEL"), LOC(@"HIDE_RIGHT_PANEL_DESC"), @"hideRightPanel_enabled");
|
|
|
|
# pragma mark - Shorts controls overlay options
|
|
SECTION_HEADER(LOC(@"SHORTS_CONTROLS_OVERLAY_OPTIONS"));
|
|
|
|
SWITCH_ITEM(LOC(@"HIDE_SUPER_THANKS"), LOC(@"HIDE_SUPER_THANKS_DESC"), @"hideBuySuperThanks_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_SUBCRIPTIONS"), LOC(@"HIDE_SUBCRIPTIONS_DESC"), @"hideSubcriptions_enabled");
|
|
SWITCH_ITEM(LOC(@"DISABLE_RESUME_TO_SHORTS"), LOC(@"DISABLE_RESUME_TO_SHORTS_DESC"), @"disableResumeToShorts");
|
|
|
|
# pragma mark - Miscellaneous
|
|
SECTION_HEADER(LOC(@"MISCELLANEOUS"));
|
|
|
|
SWITCH_ITEM(LOC(@"CAST_CONFIRM"), LOC(@"CAST_CONFIRM_DESC"), @"castConfirm_enabled");
|
|
SWITCH_ITEM(LOC(@"DISABLE_HINTS"), LOC(@"DISABLE_HINTS_DESC"), @"disableHints_enabled");
|
|
SWITCH_ITEM(LOC(@"ENABLE_FLEX"), LOC(@"ENABLE_FLEX_DESC"), @"flex_enabled");
|
|
SWITCH_ITEM(LOC(@"ENABLE_YT_STARTUP_ANIMATION"), LOC(@"ENABLE_YT_STARTUP_ANIMATION_DESC"), @"ytStartupAnimation_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_CHIP_BAR"), LOC(@"HIDE_CHIP_BAR_DESC"), @"hideChipBar_enabled");
|
|
SWITCH_ITEM(LOC(@"HIDE_PLAY_NEXT_IN_QUEUE"), LOC(@"HIDE_PLAY_NEXT_IN_QUEUE_DESC"), @"hidePlayNextInQueue_enabled");
|
|
SWITCH_ITEM(LOC(@"IPHONE_LAYOUT"), LOC(@"IPHONE_LAYOUT_DESC"), @"iPhoneLayout_enabled");
|
|
SWITCH_ITEM(LOC(@"NEW_MINIPLAYER_STYLE"), LOC(@"NEW_MINIPLAYER_STYLE_DESC"), @"bigYTMiniPlayer_enabled");
|
|
SWITCH_ITEM(LOC(@"YT_RE_EXPLORE"), LOC(@"YT_RE_EXPLORE_DESC"), @"reExplore_enabled");
|
|
|
|
# pragma mark - About
|
|
SECTION_HEADER(@"About");
|
|
|
|
YTSettingsSectionItem *bug = [%c(YTSettingsSectionItem)
|
|
itemWithTitle:@"Report an issue"
|
|
titleDescription:nil
|
|
accessibilityIdentifier:nil
|
|
detailTextBlock:nil
|
|
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
|
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/therealFoxster/uYouPlus/issues"]];
|
|
}
|
|
];
|
|
[sectionItems addObject:bug];
|
|
|
|
YTSettingsSectionItem *version = [%c(YTSettingsSectionItem)
|
|
itemWithTitle:LOC(@"VERSION")
|
|
titleDescription:nil
|
|
accessibilityIdentifier:nil
|
|
detailTextBlock:^NSString *() {
|
|
return [[NSString stringWithFormat:@"%@", @(OS_STRINGIFY(TWEAK_VERSION))] stringByReplacingOccurrencesOfString:@"\"" withString:@""];
|
|
}
|
|
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
|
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/therealFoxster/uYouPlus/releases"]];
|
|
}
|
|
];
|
|
[sectionItems addObject:version];
|
|
|
|
YTSettingsSectionItem *exitYT = [%c(YTSettingsSectionItem)
|
|
itemWithTitle:@"Exit YouTube"
|
|
titleDescription:nil
|
|
accessibilityIdentifier:nil
|
|
detailTextBlock:nil
|
|
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
|
// https://stackoverflow.com/a/17802404/19227228
|
|
[[UIApplication sharedApplication] performSelector:@selector(suspend)];
|
|
[NSThread sleepForTimeInterval:0.5];
|
|
exit(0);
|
|
}
|
|
];
|
|
[sectionItems addObject:exitYT];
|
|
|
|
[settingsViewController setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:LOC(@"TITLE DESCRIPTION") headerHidden:YES];
|
|
}
|
|
|
|
- (void)updateSectionForCategory:(NSUInteger)category withEntry:(id)entry {
|
|
if (category == uYouPlusSection) {
|
|
[self updateTweakSectionWithEntry:entry];
|
|
return;
|
|
}
|
|
%orig;
|
|
}
|
|
%end
|