mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-05-14 11:20:54 +00:00
Re-add Paste Settings Confirmation Message(s)
Re-added the Confirmation Message for both Paste Settings & Import Settings. I apologize for not adding it back earlier.
This commit is contained in:
parent
3b1a12b79c
commit
2d7e511e8f
1 changed files with 36 additions and 26 deletions
|
|
@ -246,38 +246,48 @@ extern NSBundle *uYouPlusBundle();
|
||||||
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
||||||
if (IS_ENABLED(@"replaceCopyandPasteButtons_enabled")) {
|
if (IS_ENABLED(@"replaceCopyandPasteButtons_enabled")) {
|
||||||
// Import Settings functionality
|
// Import Settings functionality
|
||||||
NSString *fileName = @"%@.txt";
|
UIAlertController *confirmImportAlert = [UIAlertController alertControllerWithTitle:LOC(@"CONFIRM_IMPORT_TITLE") message:LOC(@"CONFIRM_IMPORT_MESSAGE") preferredStyle:UIAlertControllerStyleAlert];
|
||||||
NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:fileName];
|
[confirmImportAlert addAction:[UIAlertAction actionWithTitle:LOC(@"CANCEL") style:UIAlertActionStyleCancel handler:nil]];
|
||||||
NSString *settingsString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
|
[confirmImportAlert addAction:[UIAlertAction actionWithTitle:LOC(@"CONFIRM") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||||||
if (settingsString.length > 0) {
|
NSString *fileName = @"uyouenhanced_settings.txt";
|
||||||
NSArray *lines = [settingsString componentsSeparatedByString:@"\n"];
|
NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:fileName];
|
||||||
for (NSString *line in lines) {
|
NSString *settingsString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
|
||||||
NSArray *components = [line componentsSeparatedByString:@": "];
|
if (settingsString.length > 0) {
|
||||||
if (components.count == 2) {
|
NSArray *lines = [settingsString componentsSeparatedByString:@"\n"];
|
||||||
NSString *key = components[0];
|
for (NSString *line in lines) {
|
||||||
NSString *value = components[1];
|
NSArray *components = [line componentsSeparatedByString:@": "];
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
|
if (components.count == 2) {
|
||||||
|
NSString *key = components[0];
|
||||||
|
NSString *value = components[1];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
[settingsViewController reloadData];
|
||||||
|
SHOW_RELAUNCH_YT_SNACKBAR;
|
||||||
}
|
}
|
||||||
[settingsViewController reloadData];
|
}];
|
||||||
SHOW_RELAUNCH_YT_SNACKBAR;
|
[settingsViewController presentViewController:confirmImportAlert animated:YES completion:nil];
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Paste Settings functionality (default behavior)
|
// Paste Settings functionality (default behavior)
|
||||||
NSString *settingsString = [[UIPasteboard generalPasteboard] string];
|
UIAlertController *confirmPasteAlert = [UIAlertController alertControllerWithTitle:LOC(@"CONFIRM_PASTE_TITLE") message:LOC(@"CONFIRM_PASTE_MESSAGE") preferredStyle:UIAlertControllerStyleAlert];
|
||||||
if (settingsString.length > 0) {
|
[confirmPasteAlert addAction:[UIAlertAction actionWithTitle:LOC(@"CANCEL") style:UIAlertActionStyleCancel handler:nil]];
|
||||||
NSArray *lines = [settingsString componentsSeparatedByString:@"\n"];
|
[confirmPasteAlert addAction:[UIAlertAction actionWithTitle:LOC(@"CONFIRM") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||||||
for (NSString *line in lines) {
|
NSString *settingsString = [[UIPasteboard generalPasteboard] string];
|
||||||
NSArray *components = [line componentsSeparatedByString:@": "];
|
if (settingsString.length > 0) {
|
||||||
if (components.count == 2) {
|
NSArray *lines = [settingsString componentsSeparatedByString:@"\n"];
|
||||||
NSString *key = components[0];
|
for (NSString *line in lines) {
|
||||||
NSString *value = components[1];
|
NSArray *components = [line componentsSeparatedByString:@": "];
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
|
if (components.count == 2) {
|
||||||
|
NSString *key = components[0];
|
||||||
|
NSString *value = components[1];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
[settingsViewController reloadData];
|
||||||
|
SHOW_RELAUNCH_YT_SNACKBAR;
|
||||||
}
|
}
|
||||||
[settingsViewController reloadData];
|
}];
|
||||||
SHOW_RELAUNCH_YT_SNACKBAR;
|
[settingsViewController presentViewController:confirmPasteAlert animated:YES completion:nil];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue