From 5c3b876c04fc76d8ff57e9e6462b580bb35ec294 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 23 Jul 2022 18:04:13 -0700 Subject: [PATCH] [File Permissions] Add warning dialog Added a warning dialog to notify the user of the purpose of the add folder dialog that will pop up after it. Otherwise, they may get the idea that the dialog is a glitch and should be cancelled. Signed-off-by: Christopher Snowhill --- Utils/SandboxBroker.m | 16 +++++++++++++++- en.lproj/Localizable.strings | 5 +++++ es.lproj/Localizable.strings | 5 +++++ pl.lproj/Localizable.strings | 5 +++++ ru.lproj/Localizable.strings | 4 ++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Utils/SandboxBroker.m b/Utils/SandboxBroker.m index f9dc52587..c9e417066 100644 --- a/Utils/SandboxBroker.m +++ b/Utils/SandboxBroker.m @@ -332,13 +332,27 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc if(!_entry) { dispatch_sync_reentrant(dispatch_get_main_queue(), ^{ + static BOOL warnedYet = NO; + + if(!warnedYet) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:NSLocalizedString(@"GrantPathTitle", @"Title of file dialog for granting folder access")]; + [alert setInformativeText:NSLocalizedString(@"GrantPathMessage", @"Message to new users regarding file permissions")]; + [alert addButtonWithTitle:NSLocalizedString(@"GrantPathOK", @"OK button text")]; + [alert addButtonWithTitle:NSLocalizedString(@"GrantPathStopWarning", @"Button to stop warnings for session")]; + + if([alert runModal] == NSAlertSecondButtonReturn) { + warnedYet = YES; + } + } + NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setAllowsMultipleSelection:NO]; [panel setCanChooseDirectories:YES]; [panel setCanChooseFiles:NO]; [panel setFloatingPanel:YES]; [panel setDirectoryURL:folderUrl]; - [panel setTitle:@"Open to grant access to container folder"]; + [panel setTitle:NSLocalizedString(@"GrantPathTitle", @"Title of file dialog for granting folder access")]; NSInteger result = [panel runModal]; if(result == NSModalResponseOK) { NSURL *folderUrl = [panel URL]; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index 12499766e..1ffb85e1b 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -78,3 +78,8 @@ "wdhms" = "%@, %@, %@, %@ and %@"; "PrivacyPolicyURL" = "https://www.iubenda.com/privacy-policy/59859310"; + +"GrantPathTitle" = "Open to grant access to container folder"; +"GrantPathMessage" = "Click OK on the following folder open dialog to grant access to the specified folder. Navigate the dialog further up the folder hierarchy to grant broader access to your files. Press 'Stop warning me' to hide any further warnings for the rest of the session."; +"GrantPathOK" = "OK"; +"GrantPathStopWarning" = "Stop warning me"; diff --git a/es.lproj/Localizable.strings b/es.lproj/Localizable.strings index d35e50462..0af93b6b9 100644 --- a/es.lproj/Localizable.strings +++ b/es.lproj/Localizable.strings @@ -81,3 +81,8 @@ "wdhms" = "%@, %@, %@, %@ y %@"; "PrivacyPolicyURL" = "https://www.iubenda.com/privacy-policy/57237510"; + +"GrantPathTitle" = "Open to grant access to container folder"; +"GrantPathMessage" = "Click OK on the following folder open dialog to grant access to the specified folder. Navigate the dialog further up the folder hierarchy to grant broader access to your files. Press 'Stop warning me' to hide any further warnings for the rest of the session."; +"GrantPathOK" = "OK"; +"GrantPathStopWarning" = "Stop warning me"; diff --git a/pl.lproj/Localizable.strings b/pl.lproj/Localizable.strings index 612b9e725..1c81efe86 100644 --- a/pl.lproj/Localizable.strings +++ b/pl.lproj/Localizable.strings @@ -100,3 +100,8 @@ "wdhms" = "%@, %@, %@, %@ i %@"; "PrivacyPolicyURL" = "https://www.iubenda.com/privacy-policy/59859310"; + +"GrantPathTitle" = "Open to grant access to container folder"; +"GrantPathMessage" = "Click OK on the following folder open dialog to grant access to the specified folder. Navigate the dialog further up the folder hierarchy to grant broader access to your files. Press 'Stop warning me' to hide any further warnings for the rest of the session."; +"GrantPathOK" = "OK"; +"GrantPathStopWarning" = "Stop warning me"; diff --git a/ru.lproj/Localizable.strings b/ru.lproj/Localizable.strings index 55b08e43b..a3623ca90 100644 --- a/ru.lproj/Localizable.strings +++ b/ru.lproj/Localizable.strings @@ -132,3 +132,7 @@ "PrivacyPolicyURL" = "https://www.iubenda.com/privacy-policy/59859310"; +"GrantPathTitle" = "Open to grant access to container folder"; +"GrantPathMessage" = "Click OK on the following folder open dialog to grant access to the specified folder. Navigate the dialog further up the folder hierarchy to grant broader access to your files. Press 'Stop warning me' to hide any further warnings for the rest of the session."; +"GrantPathOK" = "OK"; +"GrantPathStopWarning" = "Stop warning me";