diff --git a/Source/Settings.xm b/Source/Settings.xm index 94bccaf..7861547 100644 --- a/Source/Settings.xm +++ b/Source/Settings.xm @@ -108,13 +108,13 @@ static const NSInteger YTLiteSection = 789; # pragma mark - Copy and Paste Settings YTSettingsSectionItem *copySettings = [%c(YTSettingsSectionItem) itemWithTitle:LOC(@"COPY_SETTINGS") - titleDescription:IS_ENABLED(@"switchCopyandPasteFunctionality_enabled") ? LOC(@"COPY_SETTINGS_DESC_2") : LOC(@"COPY_SETTINGS_DESC") + titleDescription:IS_ENABLED(@"switchCopyandPasteFunctionality_enabled") ? LOC(@"EXPORT_SETTINGS_DESC") : 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"]]; + NSURL *tempFileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"YTLitePlusSettings.txt"]]; NSMutableString *settingsString = [NSMutableString string]; for (NSString *key in NSUserDefaultsCopyKeys) { id value = [[NSUserDefaults standardUserDefaults] objectForKey:key]; @@ -146,7 +146,7 @@ static const NSInteger YTLiteSection = 789; [[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Settings copied"]]; } // Prompt to export YouTube Plus settings - UIAlertController *exportAlert = [UIAlertController alertControllerWithTitle:@"Export Settings" message:@"Note: This cannot save iSponsorBlock and most YouTube settings.\nWould you like to also export your YouTube Plus Settings?" preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *exportAlert = [UIAlertController alertControllerWithTitle:@"Export Settings" message:@"Note: This feature cannot save iSponsorBlock and most YouTube settings.\n\nWould you like to also export your YouTube Plus Settings?" preferredStyle:UIAlertControllerStyleAlert]; [exportAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [exportAlert addAction:[UIAlertAction actionWithTitle:@"Export" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { // Export YouTube Plus Settings functionality @@ -160,7 +160,7 @@ static const NSInteger YTLiteSection = 789; YTSettingsSectionItem *pasteSettings = [%c(YTSettingsSectionItem) itemWithTitle:LOC(@"PASTE_SETTINGS") - titleDescription:IS_ENABLED(@"switchCopyandPasteFunctionality_enabled") ? LOC(@"PASTE_SETTINGS_DESC_2") : LOC(@"PASTE_SETTINGS_DESC") + titleDescription:IS_ENABLED(@"switchCopyandPasteFunctionality_enabled") ? LOC(@"IMPORT_SETTINGS_DESC") : LOC(@"PASTE_SETTINGS_DESC") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { @@ -170,7 +170,6 @@ static const NSInteger YTLiteSection = 789; documentPicker.delegate = (id)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]; @@ -194,6 +193,8 @@ static const NSInteger YTLiteSection = 789; }]]; [settingsViewController presentViewController:confirmPasteAlert animated:YES completion:nil]; } + // Show a toast message to confirm the action + [[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Settings pasted"]]; // Reminder to import YouTube Plus settings UIAlertController *reminderAlert = [UIAlertController alertControllerWithTitle:@"Reminder" message:@"Remember to import your YouTube Plus settings as well." @@ -689,23 +690,45 @@ static const NSInteger YTLiteSection = 789; // Implement the delegate method for document picker %new - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray *)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; - + if (urls.count > 0) { + NSURL *pickedURL = [urls firstObject]; + NSError *error; + NSString *fileType = [pickedURL resourceValuesForKeys:@[NSURLTypeIdentifierKey] error:&error][NSURLTypeIdentifierKey]; + UIViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"]; - if (settingsViewController) { - [settingsViewController presentViewController:playerViewController animated:YES completion:^{ - [player play]; - }]; + + if (UTTypeConformsTo((__bridge CFStringRef)fileType, kUTTypePlainText)) { + // This block handles the import of settings from a text file. + NSString *fileContents = [NSString stringWithContentsOfURL:pickedURL encoding:NSUTF8StringEncoding error:nil]; + NSArray *lines = [fileContents 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]; + } + } + if ([settingsViewController respondsToSelector:@selector(reloadData)]) { + // Call a custom reloadData method if it exists + [settingsViewController performSelector:@selector(reloadData)]; + } + } else if (UTTypeConformsTo((__bridge CFStringRef)fileType, kUTTypeMovie)) { + // This block handles video playback using AVPlayer and AVPlayerViewController. + AVPlayer *player = [AVPlayer playerWithURL:pickedURL]; + AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init]; + playerViewController.player = player; + + if (settingsViewController) { + [settingsViewController presentViewController:playerViewController animated:YES completion:^{ + [player play]; + }]; + } } } } + %new - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller { // Handle cancellation if needed diff --git a/lang/YTLitePlus.bundle/ar.lproj/Localizable.strings b/lang/YTLitePlus.bundle/ar.lproj/Localizable.strings index a577d98..bbca947 100644 --- a/lang/YTLitePlus.bundle/ar.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/ar.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/bg.lproj/Localizable.strings b/lang/YTLitePlus.bundle/bg.lproj/Localizable.strings index 4689437..1bf547f 100644 --- a/lang/YTLitePlus.bundle/bg.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/bg.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Копиране на всички текущи настройки в клипборда"; "PASTE_SETTINGS" = "Поставяне на настройки"; "PASTE_SETTINGS_DESC" = "Поставяне на настройки от клипборда и прилагане"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Експортиране на настройки"; "EXPORT_SETTINGS_DESC" = "Експортиране на всички текущи настройки в .txt файл"; "IMPORT_SETTINGS" = "Импортиране на настройки"; diff --git a/lang/YTLitePlus.bundle/de.lproj/Localizable.strings b/lang/YTLitePlus.bundle/de.lproj/Localizable.strings index 76a63fe..18e8820 100644 --- a/lang/YTLitePlus.bundle/de.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/de.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/en.lproj/Localizable.strings b/lang/YTLitePlus.bundle/en.lproj/Localizable.strings index 9801761..a892a2f 100644 --- a/lang/YTLitePlus.bundle/en.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/en.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/es.lproj/Localizable.strings b/lang/YTLitePlus.bundle/es.lproj/Localizable.strings index 1cf7433..739f5dd 100644 --- a/lang/YTLitePlus.bundle/es.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/es.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/fr.lproj/Localizable.strings b/lang/YTLitePlus.bundle/fr.lproj/Localizable.strings index e788b97..b493803 100644 --- a/lang/YTLitePlus.bundle/fr.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/fr.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/ja.lproj/Localizable.strings b/lang/YTLitePlus.bundle/ja.lproj/Localizable.strings index 2749ff2..ea2c349 100644 --- a/lang/YTLitePlus.bundle/ja.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/ja.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "現在のすべての設定をクリップボードにコピーします"; "PASTE_SETTINGS" = "設定を貼り付け"; "PASTE_SETTINGS_DESC" = "クリップボードから設定を貼り付けて適用します"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/pt.lproj/Localizable.strings b/lang/YTLitePlus.bundle/pt.lproj/Localizable.strings index df987ed..db9ffcb 100644 --- a/lang/YTLitePlus.bundle/pt.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/pt.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copia todas as configurações atuais para a área de transferência"; "PASTE_SETTINGS" = "Colar Configurações"; "PASTE_SETTINGS_DESC" = "Cola as configurações da área de transferência e aplica"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Exportar Configurações"; "EXPORT_SETTINGS_DESC" = "Exporta todas as configurações atuais para um arquivo .txt"; "IMPORT_SETTINGS" = "Importar Configurações"; diff --git a/lang/YTLitePlus.bundle/ro.lproj/Localizable.strings b/lang/YTLitePlus.bundle/ro.lproj/Localizable.strings index 343c226..86905e3 100644 --- a/lang/YTLitePlus.bundle/ro.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/ro.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/ru.lproj/Localizable.strings b/lang/YTLitePlus.bundle/ru.lproj/Localizable.strings index 5e6bb59..b09cc70 100644 --- a/lang/YTLitePlus.bundle/ru.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/ru.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/template.lproj/Localizable.strings b/lang/YTLitePlus.bundle/template.lproj/Localizable.strings index 413a20a..308b84c 100644 --- a/lang/YTLitePlus.bundle/template.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/template.lproj/Localizable.strings @@ -21,6 +21,8 @@ https://github.com/PoomSmart/Return-YouTube-Dislikes/tree/main/layout/Library/Ap "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; + "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/tr.lproj/Localizable.strings b/lang/YTLitePlus.bundle/tr.lproj/Localizable.strings index a9b0ea3..a845fe7 100644 --- a/lang/YTLitePlus.bundle/tr.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/tr.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Tüm mevcut ayarları panoya kopyala"; "PASTE_SETTINGS" = "Ayarları Yapıştır"; "PASTE_SETTINGS_DESC" = "Panodaki ayarları yapıştır ve uygula"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Ayarları Dışa Aktar"; "EXPORT_SETTINGS_DESC" = "Tüm mevcut ayarları bir .txt dosyasına dışa aktarır"; "IMPORT_SETTINGS" = "Ayarları İçe Aktar"; diff --git a/lang/YTLitePlus.bundle/vi.lproj/Localizable.strings b/lang/YTLitePlus.bundle/vi.lproj/Localizable.strings index dd3fdb0..d2c81b3 100644 --- a/lang/YTLitePlus.bundle/vi.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/vi.lproj/Localizable.strings @@ -6,6 +6,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings"; diff --git a/lang/YTLitePlus.bundle/zh_TW.lproj/Localizable.strings b/lang/YTLitePlus.bundle/zh_TW.lproj/Localizable.strings index aef5cf3..e48afb9 100644 --- a/lang/YTLitePlus.bundle/zh_TW.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/zh_TW.lproj/Localizable.strings @@ -7,6 +7,7 @@ "COPY_SETTINGS_DESC" = "Copy all current settings to the clipboard"; "PASTE_SETTINGS" = "Paste Settings"; "PASTE_SETTINGS_DESC" = "Paste settings from clipboard and apply"; +"PASTE_SETTINGS_ALERT" = "Apply settings from clipboard?"; "EXPORT_SETTINGS" = "Export Settings"; "EXPORT_SETTINGS_DESC" = "Exports all current settings into a .txt file"; "IMPORT_SETTINGS" = "Import Settings";