From 28178722a274d9f1056be1ba70babb32d2b06444 Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Mon, 29 Apr 2024 21:54:47 -0500 Subject: [PATCH] Limit `Fake Premium` Option to v18.35.4 and higher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Won’t work on older versions, this was implemented to prevent the app from crashing. --- Sources/uYouPlusSettings.xm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Sources/uYouPlusSettings.xm b/Sources/uYouPlusSettings.xm index a937ad2..0b40954 100644 --- a/Sources/uYouPlusSettings.xm +++ b/Sources/uYouPlusSettings.xm @@ -1003,7 +1003,31 @@ YTSettingsSectionItem *lowContrastModeButton = [%c(YTSettingsSectionItem) SECTION_HEADER(LOC(@"MISCELLANEOUS")); SWITCH_ITEM2(LOC(@"Adblock Workaround"), LOC(@"Uses stronger adblocking code. Can cause blank spots on homepage"), @"uYouAdBlockingWorkaround_enabled"); - SWITCH_ITEM2(LOC(@"Fake Premium"), LOC(@"Uses Premium logo and creates fake buttons in the You tab"), @"youTabFakePremium_enabled"); + + YTSettingsSectionItem *fakePremium = [YTSettingsSectionItemClass + switchItemWithTitle:LOC(@"Fake Premium") + titleDescription:LOC(@"Uses Premium logo and creates fake buttons in the You tab") + accessibilityIdentifier:nil + switchOn:IS_ENABLED(@"youTabFakePremium_enabled") + switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { + NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; + NSComparisonResult result = [appVersion compare:@"18.35.4" options:NSNumericSearch]; + if (result == NSOrderedAscending) { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Incompatible" message:[NSString stringWithFormat:@"Error: The \"You\" Tab doesn't exist in v%@. \nFake Premium is only available for app versions v18.35.4 and higher.", appVersion] preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; + [alert addAction:okAction]; + [settingsViewController presentViewController:alert animated:YES completion:nil]; + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"youTabFakePremium_enabled"]; + return NO; + } + [settingsViewController reloadData]; + SHOW_RELAUNCH_YT_SNACKBAR; + return YES; + } + settingItemId:0 +]; +[sectionItems addObject:fakePremium]; + // SWITCH_ITEM(LOC(@"Center YouTube Logo"), LOC(@"Toggle this to move the official YouTube Logo to the Center. App restart is required."), @"centerYouTubeLogo_enabled"); SWITCH_ITEM(LOC(@"Hide YouTube Logo"), LOC(@"Toggle this to hide the YouTube Logo in the YouTube App."), @"hideYouTubeLogo_enabled"); SWITCH_ITEM2(LOC(@"ENABLE_YT_STARTUP_ANIMATION"), LOC(@"ENABLE_YT_STARTUP_ANIMATION_DESC"), @"ytStartupAnimation_enabled");