Update uYouPlusSettings.xm (Experimental)
Settings.xm but includes the experimental Copy Settings and Paste Settings buttons.
This commit is contained in:
parent
813603b214
commit
a28dd2dcec
1 changed files with 9 additions and 10 deletions
|
|
@ -181,7 +181,7 @@ extern NSBundle *uYouPlusBundle();
|
|||
|
||||
YTSettingsSectionItem *copySettings = [%c(YTSettingsSectionItem)
|
||||
itemWithTitle:IS_ENABLED(@"replaceCopyandPasteButtons_enabled") ? LOC(@"EXPORT_SETTINGS") : LOC(@"COPY_SETTINGS")
|
||||
titleDescription:IS_ENABLED(@"replaceCopyandPasteButtons_enabled") ? LOC(@"EXPORT_SETTINGS_DESC") : LOC(@"COPY_SETTINGS_DESC")
|
||||
titleDescription:LOC(@"COPY_SETTINGS_DESC")
|
||||
accessibilityIdentifier:nil
|
||||
detailTextBlock:nil
|
||||
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
||||
|
|
@ -204,12 +204,11 @@ extern NSBundle *uYouPlusBundle();
|
|||
NSString *value = [userDefaults objectForKey:key];
|
||||
[settingsString appendFormat:@"%@: %@\n", key, value];
|
||||
}
|
||||
}
|
||||
NSString *fileName = @"uyouenhanced_settings.txt";
|
||||
NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:fileName];
|
||||
if (![settingsString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil]) {
|
||||
NSLog(@"Failed to export settings to file.");
|
||||
}
|
||||
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.text"] inMode:UIDocumentPickerModeExportToService];
|
||||
documentPicker.delegate = (id<UIDocumentPickerDelegate>)self;
|
||||
documentPicker.allowsMultipleSelection = NO;
|
||||
[settingsViewController presentViewController:documentPicker animated:YES completion:nil];
|
||||
} else {
|
||||
// Copy Settings functionality (default behavior)
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
|
@ -252,9 +251,9 @@ extern NSBundle *uYouPlusBundle();
|
|||
[settingsViewController presentViewController:documentPicker animated:YES completion:nil];
|
||||
} else {
|
||||
// Paste Settings functionality (default behavior)
|
||||
UIAlertController *confirmPasteAlert = [UIAlertController alertControllerWithTitle:LOC(@"Are you sure you want to paste the settings?") 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) {
|
||||
UIAlertController *confirmPasteAlert = [UIAlertController alertControllerWithTitle:LOC(@"CONFIRM_PASTE_TITLE") message:LOC(@"CONFIRM_PASTE_MESSAGE") 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"];
|
||||
|
|
@ -277,7 +276,7 @@ extern NSBundle *uYouPlusBundle();
|
|||
];
|
||||
[sectionItems addObject:pasteSettings];
|
||||
|
||||
// SWITCH_ITEM(LOC(@"REPLACE_COPY_AND_PASTE_BUTTONS"), LOC(@"REPLACE_COPY_AND_PASTE_BUTTONS"), @"replaceCopyandPasteButtons_enabled");
|
||||
SWITCH_ITEM(LOC(@"REPLACE_COPY_AND_PASTE_BUTTONS"), LOC(@"REPLACE_COPY_AND_PASTE_BUTTONS"), @"replaceCopyandPasteButtons_enabled");
|
||||
|
||||
YTSettingsSectionItem *exitYT = [%c(YTSettingsSectionItem)
|
||||
itemWithTitle:LOC(@"QUIT_YOUTUBE")
|
||||
|
|
|
|||
Loading…
Reference in a new issue