YTLitePlus/Source/Settings.xm
Balackburn 61a90d0712 Squashed commit of the following:
commit 2ece340746
Merge: f652976 ca84635
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Tue Aug 20 00:52:28 2024 -0700

    Merge pull request #358 from bhackel/gestures

    Gestures and Loop

commit ca84635cf4
Merge: 5066716 87d7b57
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Tue Aug 20 00:31:16 2024 -0700

    Merge branch 'main' into gestures

commit 5066716f7f
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 19 23:53:21 2024 -0700

    Localizations for Gestures

commit bed87298f6
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Sun Aug 18 22:25:52 2024 -0700

    Update Submodule

commit 87d7b576dd
Author: GitHub Actions <actions@github.com>
Date:   Tue Aug 20 00:53:21 2024 +0000

    updated submodules

commit f652976a53
Author: GitHub Actions <actions@github.com>
Date:   Tue Aug 20 00:44:56 2024 +0000

    updated submodules

commit 44d6ffe781
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 19 14:08:08 2024 -0700

    Create LICENSE

commit 023fafae15
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Sun Aug 18 18:17:32 2024 -0700

    Added YouLoop submodule to Tweaks/ folder

commit 4c5e2ee0e8
Author: GitHub Actions <actions@github.com>
Date:   Sun Aug 18 00:49:27 2024 +0000

    updated submodules

commit de89f7aca8
Author: GitHub Actions <actions@github.com>
Date:   Sat Aug 17 00:43:19 2024 +0000

    updated submodules

commit 36f9da844b
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 09:27:09 2024 -0700

    Add disable option

commit e63bc374cf
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 01:13:22 2024 -0700

    Fix defaults and text descriptions

commit 067ad5a373
Merge: b081d5b 6e8bbcb
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 01:40:45 2024 -0700

    Merge pull request #345 from bhackel/video-player

    Basic Video player

commit 6e8bbcb49e
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 01:01:33 2024 -0700

    Add localization

commit e21e026c30
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 00:32:22 2024 -0700

    Fix compile

commit 1647358a9e
Merge: feaaa07 2d82e0b
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 00:35:06 2024 -0700

    Merge branch 'main' into video-player

commit feaaa07e9e
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 00:33:37 2024 -0700

    Revert "Prototype 2"

    This reverts commit 8f578bb741.

commit f434239419
Merge: e626997 2d82e0b
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 00:26:24 2024 -0700

    Merge branch 'main' into gestures

commit e62699749d
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 16 00:25:24 2024 -0700

    Sensitivity and Deadzone settings

commit 4602b74e6f
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Thu Aug 15 23:15:18 2024 -0700

    Add deadzone

commit 6854f91c1e
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Thu Aug 15 10:45:27 2024 -0700

    Implement gesture selection

commit b081d5b52e
Author: GitHub Actions <actions@github.com>
Date:   Fri Aug 16 00:44:28 2024 +0000

    updated submodules

commit 8ed3d97d2d
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Wed Aug 14 23:56:27 2024 -0700

    Gesture refactor for settings

commit e92ada8427
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Wed Aug 14 22:20:36 2024 -0700

    Gesture settings

commit 8f578bb741
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Wed Aug 14 18:28:42 2024 -0700

    Prototype 2

commit 2d82e0b532
Author: GitHub Actions <actions@github.com>
Date:   Thu Aug 15 00:43:33 2024 +0000

    updated submodules

commit b963c807bb
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Wed Aug 14 09:15:43 2024 -0700

    Video player prototype

commit 10882e5d61
Merge: 4ed8e94 76f48a2
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Wed Aug 14 09:00:51 2024 -0700

    Merge branch 'main' into gestures

commit 4ed8e94880
Merge: b588b7f 9aa33a6
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Tue Aug 13 23:41:37 2024 -0700

    Merge branch 'main' into gestures

commit b588b7f6d0
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Tue Aug 13 22:02:23 2024 -0700

    Attempt seek gesture

commit 9aa33a676d
Author: GitHub Actions <actions@github.com>
Date:   Wed Aug 14 00:53:53 2024 +0000

    updated submodules

commit 76f48a2700
Author: GitHub Actions <actions@github.com>
Date:   Wed Aug 14 00:45:08 2024 +0000

    updated submodules

commit 45b7cd948e
Author: schweppes <schweppes0x@gmail.com>
Date:   Wed Aug 14 01:33:23 2024 +0200

    Bulgarian translations (#332)

    Co-authored-by: tonydalov <t.dalov@dictu.nl>

commit 4c24c0c336
Author: gototheskinny <51786709+gototheskinny@users.noreply.github.com>
Date:   Wed Aug 14 02:33:12 2024 +0300

    Turkish loc updated (#336)

commit dd88efc631
Merge: 6e609d5 e067e8d
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 12 23:05:35 2024 -0700

    Merge pull request #331 from bhackel/fix-oled-live-chat

    Fix OLED live chat

commit e067e8dec5
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 12 21:50:33 2024 -0700

    Fix OLED live chat

commit 6e609d56e7
Merge: 916bcf3 11faee3
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 12 22:43:28 2024 -0700

    Merge pull request #330 from bhackel/remove-speed-popup

    Remove speed popup

commit 11faee3f1e
Merge: 82e4f21 916bcf3
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 12 22:42:56 2024 -0700

    Merge branch 'main' into remove-speed-popup

    I used a translator, hopefully it is fine

commit 82e4f21d24
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 12 21:33:53 2024 -0700

    Add Hide Speed Toast

commit 916bcf33ff
Author: GitHub Actions <actions@github.com>
Date:   Tue Aug 13 00:46:14 2024 +0000

    updated submodules

commit 9d0fb16075
Author: Victor Alves <victoralves05@gmail.com>
Date:   Mon Aug 12 17:12:18 2024 -0300

    Update Portuguese localization (#326)

    * Update Portuguese Localization

commit 21df218f2f
Author: Balackburn <93828569+Balackburn@users.noreply.github.com>
Date:   Mon Aug 12 10:42:23 2024 +0200

    Updated Credits

commit f384a00e04
Author: GitHub Actions <actions@github.com>
Date:   Mon Aug 12 00:46:59 2024 +0000

    updated submodules

commit 10a536880b
Merge: 818005d 08c263f
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Sat Aug 10 05:28:47 2024 -0700

    Merge pull request #320 from bhackel/hud-and-collapse

    Copy Hide HUD and Hide Collapse Button

commit 08c263fdf0
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Sat Aug 10 04:07:47 2024 -0700

    Copy Hide HUD and Hide Collapse Button

commit 818005d73c
Merge: 37582ec 1a97587
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Sat Aug 10 03:48:54 2024 -0700

    Merge pull request #319 from bhackel/misc-features

    Misc features

commit 1a9758770d
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Sat Aug 10 02:34:42 2024 -0700

    Fix bugs

commit f64aab1b58
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Sat Aug 10 02:19:23 2024 -0700

    Fix build error

commit 762cd8f618
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Sat Aug 10 00:47:05 2024 -0700

    Remove YTLitePlus OLED Theme

commit ba13d1b987
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 9 22:44:51 2024 -0700

    Live Chat OLED dark mode

commit 753d690b78
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 9 22:38:19 2024 -0700

    Hide autoplay mini preview

commit c9875ec8b7
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 9 17:26:19 2024 -0700

    Fix localization, fix copy/paste switch

commit 11a3e75b0d
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 9 16:44:59 2024 -0700

    Default disable big mini player

commit 794fb561c9
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 9 16:29:34 2024 -0700

    Fix import export settings localization

commit 4f2b55a897
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 9 16:34:57 2024 -0700

    Hide comment previews by @arichornlover

commit 948ea5ff29
Author: GitHub Actions <actions@github.com>
Date:   Sat Aug 10 00:53:31 2024 +0000

    updated submodules

commit 37582ecbf8
Author: GitHub Actions <actions@github.com>
Date:   Sat Aug 10 00:44:53 2024 +0000

    updated submodules

commit 64c712d630
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Fri Aug 9 16:51:12 2024 -0700

    Attempt brightness and volume gestures

commit 91290efdfe
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Wed Aug 7 13:24:51 2024 -0700

    Allow other gestures

commit f2e7c234eb
Author: GitHub Actions <actions@github.com>
Date:   Fri Aug 9 00:45:23 2024 +0000

    updated submodules

commit e7523dc08d
Author: GitHub Actions <actions@github.com>
Date:   Thu Aug 8 00:44:57 2024 +0000

    updated submodules

commit 09ddc42e32
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Wed Aug 7 12:11:03 2024 -0700

    Add reporting option

commit d4679b8414
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Tue Aug 6 23:49:31 2024 -0700

    Attempt Volume Sliding

commit df3d09e81d
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Tue Aug 6 22:36:59 2024 -0700

    Gesture test using YTHFS code

commit d731dbddec
Author: arichornlover <78001398+arichornlover@users.noreply.github.com>
Date:   Tue Aug 6 21:06:02 2024 -0500

    Fix LowContrastMode description

    also added Version compatibility, LowContrastMode will not work once v17.38.10 is gone in the future.

commit 00bb15a868
Author: GitHub Actions <actions@github.com>
Date:   Wed Aug 7 00:45:08 2024 +0000

    updated submodules

commit 8a717e763a
Author: GitHub Actions <actions@github.com>
Date:   Tue Aug 6 00:44:29 2024 +0000

    updated submodules

commit 47562c543b
Author: ChuDucManh <89825108+manhchuduc@users.noreply.github.com>
Date:   Tue Aug 6 01:52:29 2024 +0700

    Update Localizable.strings (#305)

commit d27150b11d
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 5 03:16:34 2024 -0700

    Fix delete workflows

commit 46d6b163b9
Author: Bryce Hackel <34104885+bhackel@users.noreply.github.com>
Date:   Mon Aug 5 03:09:41 2024 -0700

    Fix YouTube Extensions bug
2024-08-20 10:58:28 +02:00

702 lines
41 KiB
Text

#import "../YTLitePlus.h"
#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 "AppIconOptionsController.h"
// Basic switch item
#define BASIC_SWITCH(title, description, key) \
[YTSettingsSectionItemClass switchItemWithTitle:title \
titleDescription:description \
accessibilityIdentifier:nil \
switchOn:IsEnabled(key) \
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { \
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:key]; \
return YES; \
} \
settingItemId:0]
/*
// Custom switch item that has customizable code
#define CUSTOM_SWITCH(title, description, key, code) \
[YTSettingsSectionItemClass switchItemWithTitle:title \
titleDescription:description \
accessibilityIdentifier:nil \
switchOn:IsEnabled(key) \
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enable) { \
code \
} \
settingItemId:0]
*/
static int contrastMode() {
return [[NSUserDefaults standardUserDefaults] integerForKey:@"lcm"];
}
static int appVersionSpoofer() {
return [[NSUserDefaults standardUserDefaults] integerForKey:@"versionSpoofer"];
}
@interface YTSettingsSectionItemManager (YTLitePlus)
- (void)updateYTLitePlusSectionWithEntry:(id)entry;
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls;
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller;
@end
extern NSBundle *YTLitePlusBundle();
// Keys for "Copy Settings" button (for: YTLitePlus)
NSArray *copyKeys = @[
/* MAIN Controls Keys 1/2 */ @"enableShareButton_enabled", @"enableSaveToButton_enabled", @"hideVideoPlayerShadowOverlayButtons_enabled", @"hideRightPanel_enabled", @"hideHeatwaves_enabled", @"disableAmbientModePortrait_enabled",
/* MAIN Controls Keys 2/2 */ @"disableAmbientModeFullscreen_enabled", @"fullscreenToTheRight_enabled", @"seekAnywhere_enabled", @"YTTapToSeek_enabled", @"disablePullToFull_enabled", @"alwaysShowRemainingTime_enabled", @"disableRemainingTime_enabled", @"disableEngagementOverlay_enabled",
/* MAIN App Overlay Keys 1/2 */ @"disableAccountSection_enabled", @"disableAutoplaySection_enabled", @"disableTryNewFeaturesSection_enabled", @"disableVideoQualityPreferencesSection_enabled", @"disableNotificationsSection_enabled",
/* MAIN App Overlay Keys 2/2 */ @"disableManageAllHistorySection_enabled", @"disableYourDataInYouTubeSection_enabled", @"disablePrivacySection_enabled", @"disableLiveChatSection_enabled",
/* MAIN Playback Keys */ @"inline_muted_playback_enabled",
/* MAIN Misc Keys */ @"newSettingsUI_enabled", @"ytStartupAnimation_enabled", @"ytNoModernUI_enabled", @"iPadLayout_enabled", @"iPhoneLayout_enabled", @"castConfirm_enabled", @"bigYTMiniPlayer_enabled", @"hideCastButton_enabled", @"hideSponsorBlockButton_enabled", @"hideHomeTab_enabled", @"fixCasting_enabled", @"flex_enabled", @"enableVersionSpoofer_enabled",
/* TWEAK YTUHD Keys */ @"EnableVP9", @"AllVP9"
];
// Add both YTLite and YTLitePlus to YouGroupSettings
static const NSInteger YTLitePlusSection = 788;
static const NSInteger YTLiteSection = 789;
%hook YTSettingsGroupData
+ (NSMutableArray <NSNumber *> *)tweaks {
NSMutableArray <NSNumber *> *originalTweaks = %orig;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[originalTweaks addObject:@(YTLitePlusSection)];
[originalTweaks addObject:@(YTLiteSection)];
});
return originalTweaks;
}
%end
// Add YTLitePlus to the settings list
%hook YTAppSettingsPresentationData
+ (NSArray *)settingsCategoryOrder {
NSArray *order = %orig;
NSMutableArray *mutableOrder = [order mutableCopy];
NSUInteger insertIndex = [order indexOfObject:@(1)];
if (insertIndex != NSNotFound)
[mutableOrder insertObject:@(YTLitePlusSection) atIndex:insertIndex + 1];
return mutableOrder;
}
%end
%hook YTSettingsSectionController
- (void)setSelectedItem:(NSUInteger)selectedItem {
if (selectedItem != NSNotFound) %orig;
}
%end
%hook YTSettingsSectionItemManager
%new(v@:@)
- (void)updateYTLitePlusSectionWithEntry:(id)entry {
NSMutableArray *sectionItems = [NSMutableArray array];
NSBundle *tweakBundle = YTLitePlusBundle();
Class YTSettingsSectionItemClass = %c(YTSettingsSectionItem);
YTSettingsViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"];
// Add item for going to the YTLitePlus GitHub page
YTSettingsSectionItem *main = [%c(YTSettingsSectionItem)
itemWithTitle:[NSString stringWithFormat:LOC(@"VERSION"), @(OS_STRINGIFY(TWEAK_VERSION))]
titleDescription:LOC(@"VERSION_CHECK")
accessibilityIdentifier:nil
detailTextBlock:nil
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
return [%c(YTUIUtils) openURL:[NSURL URLWithString:@"https://github.com/YTLitePlus/YTLitePlus/releases/latest"]];
}];
[sectionItems addObject:main];
YTSettingsSectionItem *copySettings = [%c(YTSettingsSectionItem)
itemWithTitle:LOC(@"COPY_SETTINGS")
titleDescription:IS_ENABLED(@"switchCopyandPasteFunctionality_enabled") ? LOC(@"COPY_SETTINGS_DESC_2") : LOC(@"COPY_SETTINGS_DESC")
accessibilityIdentifier:nil
detailTextBlock:nil
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
if (IS_ENABLED(@"switchCopyandPasteFunctionality_enabled")) {
// Export Settings functionality
NSURL *tempFileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"exported_settings.txt"]];
NSMutableString *settingsString = [NSMutableString string];
for (NSString *key in copyKeys) {
id value = [[NSUserDefaults standardUserDefaults] objectForKey:key];
if (value) {
[settingsString appendFormat:@"%@: %@\n", key, value];
}
}
[settingsString writeToURL:tempFileURL atomically:YES encoding:NSUTF8StringEncoding error:nil];
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithURL:tempFileURL inMode:UIDocumentPickerModeExportToService];
documentPicker.delegate = (id<UIDocumentPickerDelegate>)self;
documentPicker.allowsMultipleSelection = NO;
[settingsViewController presentViewController:documentPicker animated:YES completion:nil];
} else {
// Copy Settings functionality (DEFAULT - Copies to Clipboard)
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSMutableString *settingsString = [NSMutableString string];
for (NSString *key in copyKeys) {
if ([userDefaults objectForKey:key]) {
NSString *value = [userDefaults objectForKey:key];
[settingsString appendFormat:@"%@: %@\n", key, value];
}
}
[[UIPasteboard generalPasteboard] setString:settingsString];
// Show a confirmation message or perform some other action here
}
return YES;
}
];
[sectionItems addObject:copySettings];
YTSettingsSectionItem *pasteSettings = [%c(YTSettingsSectionItem)
itemWithTitle:LOC(@"PASTE_SETTINGS")
titleDescription:IS_ENABLED(@"switchCopyandPasteFunctionality_enabled") ? LOC(@"PASTE_SETTINGS_DESC_2") : LOC(@"PASTE_SETTINGS_DESC")
accessibilityIdentifier:nil
detailTextBlock:nil
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
if (IS_ENABLED(@"switchCopyandPasteFunctionality_enabled")) {
// Paste Settings functionality (ALTERNATE - Pastes from ".txt")
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.text"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = (id<UIDocumentPickerDelegate>)self;
documentPicker.allowsMultipleSelection = NO;
[settingsViewController presentViewController:documentPicker animated:YES completion:nil];
return YES;
} else {
// Paste Settings functionality (DEFAULT - Pastes from Clipboard)
UIAlertController *confirmPasteAlert = [UIAlertController alertControllerWithTitle:LOC(@"PASTE_SETTINGS_ALERT") message:nil preferredStyle:UIAlertControllerStyleAlert];
[confirmPasteAlert addAction:[UIAlertAction actionWithTitle:LOC(@"Cancel") style:UIAlertActionStyleCancel handler:nil]];
[confirmPasteAlert addAction:[UIAlertAction actionWithTitle:LOC(@"Confirm") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *settingsString = [[UIPasteboard generalPasteboard] string];
if (settingsString.length > 0) {
NSArray *lines = [settingsString componentsSeparatedByString:@"\n"];
for (NSString *line in lines) {
NSArray *components = [line componentsSeparatedByString:@": "];
if (components.count == 2) {
NSString *key = components[0];
NSString *value = components[1];
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
}
}
[settingsViewController reloadData];
// Show a confirmation message or perform some other action here
}
}]];
[settingsViewController presentViewController:confirmPasteAlert animated:YES completion:nil];
}
return YES;
}
];
[sectionItems addObject:pasteSettings];
YTSettingsSectionItem *videoPlayer = [%c(YTSettingsSectionItem)
itemWithTitle:LOC(@"VIDEO_PLAYER")
titleDescription:LOC(@"VIDEO_PLAYER_DESC")
accessibilityIdentifier:nil
detailTextBlock:nil
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
// Access the current view controller
UIViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"];
if (settingsViewController) {
// Present the video picker
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[(NSString *)kUTTypeMovie, (NSString *)kUTTypeVideo] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = (id<UIDocumentPickerDelegate>)self;
documentPicker.allowsMultipleSelection = NO;
[settingsViewController presentViewController:documentPicker animated:YES completion:nil];
} else {
NSLog(@"settingsViewController is nil");
}
return YES; // Return YES to indicate that the action was handled
}
];
[sectionItems addObject:videoPlayer];
/*
YTSettingsSectionItem *appIcon = [%c(YTSettingsSectionItem)
itemWithTitle:LOC(@"CHANGE_APP_ICON")
titleDescription:nil
accessibilityIdentifier:nil
detailTextBlock:nil
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
AppIconOptionsController *appIconController = [[AppIconOptionsController alloc] init];
[settingsViewController.navigationController pushViewController:appIconController animated:YES];
return YES;
}
];
[sectionItems addObject:appIcon];
*/
# pragma mark - Player Gestures - @bhackel
// Helper to get the selected gesture mode
static NSString* (^sectionGestureSelectedModeToString)(GestureMode) = ^(GestureMode sectionIndex) {
switch (sectionIndex) {
case GestureModeVolume:
return LOC(@"VOLUME");
case GestureModeBrightness:
return LOC(@"BRIGHTNESS");
case GestureModeSeek:
return LOC(@"SEEK");
case GestureModeDisabled:
return LOC(@"DISABLED");
default:
return @"Invalid index - Report bug";
}
};
// Helper to generate checkmark setting items for selecting gesture modes
static YTSettingsSectionItem* (^gestureCheckmarkSettingItem)(NSInteger, NSString *) = ^(NSInteger idx, NSString *key) {
return [YTSettingsSectionItemClass
checkmarkItemWithTitle:sectionGestureSelectedModeToString(idx)
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:idx forKey:key];
[settingsViewController reloadData];
return YES;
}
];
};
// Helper to generate a section item for selecting a gesture mode
YTSettingsSectionItem *(^createSectionGestureSelector)(NSString *, NSString *) = ^YTSettingsSectionItem *(NSString *sectionLabel, NSString *sectionKey) {
return [YTSettingsSectionItemClass itemWithTitle:LOC(sectionLabel)
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
return sectionGestureSelectedModeToString(GetSelection(sectionKey));
}
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
gestureCheckmarkSettingItem(0, sectionKey), // Volume
gestureCheckmarkSettingItem(1, sectionKey), // Brightness
gestureCheckmarkSettingItem(2, sectionKey), // Seek
gestureCheckmarkSettingItem(3, sectionKey) // Disabled
];
// Present picker when selecting this settings item
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc]
initWithNavTitle:LOC(sectionLabel)
pickerSectionTitle:nil
rows:rows
selectedItemIndex:GetSelection(sectionKey)
parentResponder:[self parentResponder]
];
[settingsViewController pushViewController:picker];
return YES;
}
];
};
// Configuration picker for deadzone to pick from 0 to 100 pixels with interval of 10
NSMutableArray<NSNumber *> *deadzoneValues = [NSMutableArray array];
for (CGFloat value = 0; value <= 100; value += 10) {
[deadzoneValues addObject:@(value)];
}
YTSettingsSectionItem *deadzonePicker = [YTSettingsSectionItemClass
itemWithTitle:LOC(@"DEADZONE")
titleDescription:LOC(@"DEADZONE_DESC")
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
return [NSString stringWithFormat:@"%ld px", (long)GetFloat(@"playerGesturesDeadzone")];
}
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
// Generate rows for deadzone picker using the predefined array
NSMutableArray <YTSettingsSectionItem *> *deadzoneRows = [NSMutableArray array];
for (NSNumber *deadzoneValue in deadzoneValues) {
CGFloat deadzone = [deadzoneValue floatValue];
[deadzoneRows addObject:[YTSettingsSectionItemClass
checkmarkItemWithTitle:[NSString stringWithFormat:@"%ld px", (long)deadzone]
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setFloat:deadzone forKey:@"playerGesturesDeadzone"];
[settingsViewController reloadData];
return YES;
}
]];
}
// Determine the index of the currently selected deadzone
CGFloat currentDeadzone = GetFloat(@"playerGesturesDeadzone");
NSUInteger selectedIndex = [deadzoneValues indexOfObject:@(currentDeadzone)];
if (selectedIndex == NSNotFound) {
selectedIndex = 0; // Default to the first item if the current deadzone is not found
}
// Present deadzone picker when selecting this settings item
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc]
initWithNavTitle:LOC(@"DEADZONE")
pickerSectionTitle:nil
rows:deadzoneRows
selectedItemIndex:selectedIndex
parentResponder:[self parentResponder]
];
[settingsViewController pushViewController:picker];
return YES;
}
];
// Configuration picker for sensitivity to pick from 0.5 to 2.0 with interval of 0.1
NSMutableArray<NSNumber *> *sensitivityValues = [NSMutableArray array];
for (CGFloat value = 0.5; value <= 2.0; value += 0.1) {
[sensitivityValues addObject:@(value)];
}
YTSettingsSectionItem *sensitivityPicker = [YTSettingsSectionItemClass
itemWithTitle:LOC(@"SENSITIVITY")
titleDescription:LOC(@"SENSITIVITY_DESC")
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
return [NSString stringWithFormat:@"%.1f", GetFloat(@"playerGesturesSensitivity")];
}
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
// Generate rows for sensitivity picker using the predefined array
NSMutableArray <YTSettingsSectionItem *> *sensitivityRows = [NSMutableArray array];
for (NSNumber *sensitivityValue in sensitivityValues) {
CGFloat sensitivity = [sensitivityValue floatValue];
[sensitivityRows addObject:[YTSettingsSectionItemClass
checkmarkItemWithTitle:[NSString stringWithFormat:@"%.1f", sensitivity]
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setFloat:sensitivity forKey:@"playerGesturesSensitivity"];
[settingsViewController reloadData];
return YES;
}
]];
}
// Determine the index of the currently selected sensitivity
CGFloat currentSensitivity = GetFloat(@"playerGesturesSensitivity");
NSUInteger selectedIndex = [sensitivityValues indexOfObject:@(currentSensitivity)];
if (selectedIndex == NSNotFound) {
selectedIndex = 0; // Default to the first item if the current sensitivity is not found
}
// Present sensitivity picker
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc]
initWithNavTitle:LOC(@"SENSITIVITY")
pickerSectionTitle:nil
rows:sensitivityRows
selectedItemIndex:selectedIndex
parentResponder:[self parentResponder]
];
[settingsViewController pushViewController:picker];
return YES;
}
];
// Create and add items to the high level gestures menu
YTSettingsSectionItem *playerGesturesGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"PLAYER_GESTURES_TITLE") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
// Description header item
[YTSettingsSectionItemClass
itemWithTitle:nil
titleDescription:LOC(@"PLAYER_GESTURES_DESC")
accessibilityIdentifier:nil
detailTextBlock:nil
selectBlock:nil
],
// Toggle for enabling gestures
BASIC_SWITCH(LOC(@"PLAYER_GESTURES_TOGGLE"), nil, @"playerGestures_enabled"),
// Pickers for each gesture section
createSectionGestureSelector(@"TOP_SECTION", @"playerGestureTopSelection"),
createSectionGestureSelector(@"MIDDLE_SECTION", @"playerGestureMiddleSelection"),
createSectionGestureSelector(@"BOTTOM_SECTION", @"playerGestureBottomSelection"),
// Pickers for configuration settings
deadzonePicker,
sensitivityPicker
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"Player Gestures (Beta)") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}];
[sectionItems addObject:playerGesturesGroup];
# pragma mark - Video Controls Overlay Options
YTSettingsSectionItem *videoControlOverlayGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"VIDEO_CONTROLS_OVERLAY_OPTIONS") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
BASIC_SWITCH(LOC(@"ENABLE_SHARE_BUTTON"), LOC(@"ENABLE_SHARE_BUTTON_DESC"), @"enableShareButton_enabled"),
BASIC_SWITCH(LOC(@"ENABLE_SAVE_TO_PLAYLIST_BUTTON"), LOC(@"ENABLE_SAVE_TO_PLAYLIST_BUTTON_DESC"), @"enableSaveToButton_enabled"),
BASIC_SWITCH(LOC(@"HIDE_SHADOW_OVERLAY_BUTTONS"), LOC(@"HIDE_SHADOW_OVERLAY_BUTTONS_DESC"), @"hideVideoPlayerShadowOverlayButtons_enabled"),
BASIC_SWITCH(LOC(@"HIDE_RIGHT_PANEL"), LOC(@"HIDE_RIGHT_PANEL_DESC"), @"hideRightPanel_enabled"),
BASIC_SWITCH(LOC(@"HIDE_HEATWAVES"), LOC(@"HIDE_HEATWAVES_DESC"), @"hideHeatwaves_enabled"),
BASIC_SWITCH(LOC(@"DISABLE_AMBIENT_PORTRAIT"), LOC(@"DISABLE_AMBIENT_PORTRAIT_DESC"), @"disableAmbientModePortrait_enabled"),
BASIC_SWITCH(LOC(@"DISABLE_AMBIENT_FULLSCREEN"), LOC(@"DISABLE_AMBIENT_FULLSCREEN_DESC"), @"disableAmbientModeFullscreen_enabled"),
BASIC_SWITCH(LOC(@"FULLSCREEN_TO_THE_RIGHT"), LOC(@"FULLSCREEN_TO_THE_RIGHT_DESC"), @"fullscreenToTheRight_enabled"),
BASIC_SWITCH(LOC(@"SEEK_ANYWHERE"), LOC(@"SEEK_ANYWHERE_DESC"), @"seekAnywhere_enabled"),
BASIC_SWITCH(LOC(@"ENABLE_TAP_TO_SEEK"), LOC(@"ENABLE_TAP_TO_SEEK_DESC"), @"YTTapToSeek_enabled"),
BASIC_SWITCH(LOC(@"DISABLE_PULL_TO_FULLSCREEN_GESTURE"), LOC(@"DISABLE_PULL_TO_FULLSCREEN_GESTURE_DESC"), @"disablePullToFull_enabled"),
BASIC_SWITCH(LOC(@"ALWAYS_USE_REMAINING_TIME"), LOC(@"ALWAYS_USE_REMAINING_TIME_DESC"), @"alwaysShowRemainingTime_enabled"),
BASIC_SWITCH(LOC(@"DISABLE_TOGGLE_TIME_REMAINING"), LOC(@"DISABLE_TOGGLE_TIME_REMAINING_DESC"), @"disableRemainingTime_enabled"),
BASIC_SWITCH(LOC(@"DISABLE_ENGAGEMENT_OVERLAY"), LOC(@"DISABLE_ENGAGEMENT_OVERLAY_DESC"), @"disableEngagementOverlay_enabled"),
BASIC_SWITCH(LOC(@"HIDE_COMMENT_PREVIEWS_UNDER_PLAYER"), LOC(@"HIDE_COMMENT_PREVIEWS_UNDER_PLAYER_DESC"), @"hidePreviewCommentSection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_AUTOPLAY_MINI_PREVIEW"), LOC(@"HIDE_AUTOPLAY_MINI_PREVIEW_DESC"), @"hideAutoplayMiniPreview_enabled"),
BASIC_SWITCH(LOC(@"HIDE_HUD_MESSAGES"), LOC(@"HIDE_HUD_MESSAGES_DESC"), @"hideHUD_enabled"),
BASIC_SWITCH(LOC(@"HIDE_COLLAPSE_BUTTON"), LOC(@"HIDE_COLLAPSE_BUTTON_DESC"), @"disableCollapseButton_enabled"),
BASIC_SWITCH(LOC(@"HIDE_SPEED_TOAST"), LOC(@"HIDE_SPEED_TOAST_DESC"), @"hideSpeedToast_enabled"),
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"VIDEO_CONTROLS_OVERLAY_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}];
[sectionItems addObject:videoControlOverlayGroup];
# pragma mark - App Settings Overlay Options
YTSettingsSectionItem *appSettingsOverlayGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"APP_SETTINGS_OVERLAY_OPTIONS") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
BASIC_SWITCH(LOC(@"HIDE_ACCOUNT_SECTION"), LOC(@"APP_RESTART_DESC"), @"disableAccountSection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_AUTOPLAY_SECTION"), LOC(@"APP_RESTART_DESC"), @"disableAutoplaySection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_TRYNEWFEATURES_SECTION"), LOC(@"APP_RESTART_DESC"), @"disableTryNewFeaturesSection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_VIDEOQUALITYPREFERENCES_SECTION"), LOC(@"APP_RESTART_DESC"), @"disableVideoQualityPreferencesSection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_NOTIFICATIONS_SECTION"), LOC(@"APP_RESTART_DESC"), @"disableNotificationsSection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_MANAGEALLHISTORY_SECTION"), LOC(@"APP_RESTART_DESC"), @"disableManageAllHistorySection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_YOURDATAINYOUTUBE_SECTION"), LOC(@"APP_RESTART_DESC"), @"disableYourDataInYouTubeSection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_PRIVACY_SECTION"), LOC(@"APP_RESTART_DESC"), @"disablePrivacySection_enabled"),
BASIC_SWITCH(LOC(@"HIDE_LIVECHAT_SECTION"), LOC(@"APP_RESTART_DESC"), @"disableLiveChatSection_enabled")
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"APP_SETTINGS_OVERLAY_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}];
[sectionItems addObject:appSettingsOverlayGroup];
# pragma mark - LowContrastMode
YTSettingsSectionItem *lowContrastModeSection = [YTSettingsSectionItemClass itemWithTitle:LOC(@"LOW_CONTRAST_MODE")
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
switch (contrastMode()) {
case 1:
return LOC(@"Hex Color");
case 0:
default:
return LOC(@"Default");
}
}
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
[YTSettingsSectionItemClass checkmarkItemWithTitle:LOC(@"Default") titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"lcm"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:LOC(@"Hex Color") titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"lcm"];
[settingsViewController reloadData];
return YES;
}]
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"LOW_CONTRAST_MODE") pickerSectionTitle:nil rows:rows selectedItemIndex:contrastMode() parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}];
# pragma mark - VersionSpooferLite
YTSettingsSectionItem *versionSpooferSection = [YTSettingsSectionItemClass itemWithTitle:LOC(@"VERSION_SPOOFER_TITLE")
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
switch (appVersionSpoofer()) {
case 1:
return @"v18.34.5 (Enable Library Tab)";
case 2:
return @"v18.33.3 (Removes Playables)";
case 3:
return @"v18.18.2 (Fixes YTClassicVideoQuality & YTSpeed)";
case 4:
return @"v18.01.2 (First v18 Version)";
case 5:
return @"v17.49.6 (Removes Rounded Miniplayer)";
case 6:
return @"v17.38.10 (Fixes LowContrastMode)";
case 7:
return @"v17.33.2 (Oldest Supported Version)";
case 0:
default:
return @"v18.49.3 (Last v18 Version)";
}
}
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
[YTSettingsSectionItemClass checkmarkItemWithTitle:@"v18.49.3 (Last v18 Version)" titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"versionSpoofer"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:@"v18.34.5 (Enable Library Tab)" titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"versionSpoofer"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:@"v18.33.3 (Removes Playables)" titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:2 forKey:@"versionSpoofer"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:@"v18.18.2 (Fixes YTClassicVideoQuality & YTSpeed)" titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:3 forKey:@"versionSpoofer"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:@"v18.01.2 (First v18 Version)" titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:4 forKey:@"versionSpoofer"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:@"v17.49.6 (Removes Rounded Miniplayer)" titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:5 forKey:@"versionSpoofer"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:@"v17.38.10 (Fixes LowContrastMode)" titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:6 forKey:@"versionSpoofer"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:@"v17.33.2 (Oldest Supported Version)" titleDescription:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:7 forKey:@"versionSpoofer"];
[settingsViewController reloadData];
return YES;
}]
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:@"VERSION_SPOOFER_TITLE" pickerSectionTitle:nil rows:rows selectedItemIndex:appVersionSpoofer() parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}];
# pragma mark - Theme
YTSettingsSectionItem *themeGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"THEME_OPTIONS")
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
switch (GetSelection(@"appTheme")) {
case 1:
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(@"OLD_DARK_THEME") titleDescription:LOC(@"OLD_DARK_THEME_DESC") selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"appTheme"];
[settingsViewController reloadData];
return YES;
}],
BASIC_SWITCH(LOC(@"OLED_KEYBOARD"), LOC(@"OLED_KEYBOARD_DESC"), @"oledKeyBoard_enabled"),
BASIC_SWITCH(LOC(@"LOW_CONTRAST_MODE"), LOC(@"LOW_CONTRAST_MODE_DESC"), @"lowContrastMode_enabled"),
lowContrastModeSection
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"THEME_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:GetSelection(@"appTheme") parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}];
[sectionItems addObject:themeGroup];
# pragma mark - Copy of Playback in feeds section - @bhackel
// This section is hidden in vanilla YouTube when using the new settings UI, so
// we can recreate it here
YTSettingsSectionItem *playbackInFeedsGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"PLAYBACK_IN_FEEDS")
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
switch (GetSelection(@"inline_muted_playback_enabled")) {
case 3:
return LOC(@"PLAYBACK_IN_FEEDS_WIFI_ONLY");
case 1:
return LOC(@"PLAYBACK_IN_FEEDS_OFF");
case 2:
default:
return LOC(@"PLAYBACK_IN_FEEDS_ALWAYS_ON");
}
}
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
[YTSettingsSectionItemClass checkmarkItemWithTitle:LOC(@"PLAYBACK_IN_FEEDS_OFF") selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"inline_muted_playback_enabled"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:LOC(@"PLAYBACK_IN_FEEDS_ALWAYS_ON") selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:2 forKey:@"inline_muted_playback_enabled"];
[settingsViewController reloadData];
return YES;
}],
[YTSettingsSectionItemClass checkmarkItemWithTitle:LOC(@"PLAYBACK_IN_FEEDS_WIFI_ONLY") selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
[[NSUserDefaults standardUserDefaults] setInteger:3 forKey:@"inline_muted_playback_enabled"];
[settingsViewController reloadData];
return YES;
}],
];
// It seems values greater than 3 act the same as Always On (Index 1)
int (^getInlineSelection)() = ^int() {
int selection = GetSelection(@"inline_muted_playback_enabled") - 1;
return selection > 3 ? 1 : selection;
};
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"PLAYBACK_IN_FEEDS") pickerSectionTitle:nil rows:rows selectedItemIndex:getInlineSelection() parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}
];
# pragma mark - Miscellaneous
YTSettingsSectionItem *miscellaneousGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"MISCELLANEOUS") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
playbackInFeedsGroup,
// BASIC_SWITCH(LOC(@"NEW_SETTINGS_UI"), LOC(@"NEW_SETTINGS_UI_DESC"), @"newSettingsUI_enabled"), // disabled because YTLite is probably forcing it to NO
BASIC_SWITCH(LOC(@"ENABLE_YT_STARTUP_ANIMATION"), LOC(@"ENABLE_YT_STARTUP_ANIMATION_DESC"), @"ytStartupAnimation_enabled"),
BASIC_SWITCH(LOC(@"HIDE_MODERN_INTERFACE"), LOC(@"HIDE_MODERN_INTERFACE_DESC"), @"ytNoModernUI_enabled"),
BASIC_SWITCH(LOC(@"IPAD_LAYOUT"), LOC(@"IPAD_LAYOUT_DESC"), @"iPadLayout_enabled"),
BASIC_SWITCH(LOC(@"IPHONE_LAYOUT"), LOC(@"IPHONE_LAYOUT_DESC"), @"iPhoneLayout_enabled"),
BASIC_SWITCH(LOC(@"CAST_CONFIRM"), LOC(@"CAST_CONFIRM_DESC"), @"castConfirm_enabled"),
BASIC_SWITCH(LOC(@"NEW_MINIPLAYER_STYLE"), LOC(@"NEW_MINIPLAYER_STYLE_DESC"), @"bigYTMiniPlayer_enabled"),
BASIC_SWITCH(LOC(@"HIDE_CAST_BUTTON"), LOC(@"HIDE_CAST_BUTTON_DESC"), @"hideCastButton_enabled"),
BASIC_SWITCH(LOC(@"HIDE_SPONSORBLOCK_BUTTON"), LOC(@"HIDE_SPONSORBLOCK_BUTTON_DESC"), @"hideSponsorBlockButton_enabled"),
BASIC_SWITCH(LOC(@"HIDE_HOME_TAB"), LOC(@"HIDE_HOME_TAB_DESC"), @"hideHomeTab_enabled"),
BASIC_SWITCH(LOC(@"FIX_CASTING"), LOC(@"FIX_CASTING_DESC"), @"fixCasting_enabled"),
BASIC_SWITCH(LOC(@"REPLACE_COPY_AND_PASTE_BUTTONS"), LOC(@"REPLACE_COPY_AND_PASTE_BUTTONS_DESC"), @"switchCopyandPasteFunctionality_enabled"),
BASIC_SWITCH(LOC(@"ENABLE_FLEX"), LOC(@"ENABLE_FLEX_DESC"), @"flex_enabled"),
BASIC_SWITCH(LOC(@"APP_VERSION_SPOOFER_LITE"), LOC(@"APP_VERSION_SPOOFER_LITE_DESC"), @"enableVersionSpoofer_enabled"),
versionSpooferSection
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"MISCELLANEOUS") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}];
[sectionItems addObject:miscellaneousGroup];
if ([settingsViewController respondsToSelector:@selector(setSectionItems:forCategory:title:icon:titleDescription:headerHidden:)])
[settingsViewController setSectionItems:sectionItems forCategory:YTLitePlusSection title:@"YTLitePlus" icon:nil titleDescription:LOC(@"TITLE DESCRIPTION") headerHidden:YES];
else
[settingsViewController setSectionItems:sectionItems forCategory:YTLitePlusSection title:@"YTLitePlus" titleDescription:LOC(@"TITLE DESCRIPTION") headerHidden:YES];}
- (void)updateSectionForCategory:(NSUInteger)category withEntry:(id)entry {
if (category == YTLitePlusSection) {
[self updateYTLitePlusSectionWithEntry:entry];
return;
}
%orig;
}
// Implement the delegate method for document picker
%new
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
NSURL *pickedURL = [urls firstObject];
if (pickedURL) {
// Use AVPlayerViewController to play the video
AVPlayer *player = [AVPlayer playerWithURL:pickedURL];
AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
playerViewController.player = player;
UIViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"];
if (settingsViewController) {
[settingsViewController presentViewController:playerViewController animated:YES completion:^{
[player play];
}];
}
}
}
%new
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
// Handle cancellation if needed
NSLog(@"Document picker was cancelled");
}
%end