diff --git a/Application/AppController.h b/Application/AppController.h index 356692583..14675ad30 100644 --- a/Application/AppController.h +++ b/Application/AppController.h @@ -97,6 +97,8 @@ - (IBAction)toggleMiniMode:(id)sender; - (IBAction)toggleToolbarStyle:(id)sender; +- (BOOL)pathSuggesterEmpty; ++ (BOOL)globalPathSuggesterEmpty; - (void)showPathSuggester; + (void)globalShowPathSuggester; diff --git a/Application/AppController.m b/Application/AppController.m index f5d4267fa..3a56f271a 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -715,6 +715,14 @@ static AppController *kAppController = nil; } } +- (BOOL)pathSuggesterEmpty { + return [playlistController pathSuggesterEmpty]; +} + ++ (BOOL)globalPathSuggesterEmpty { + return [kAppController pathSuggesterEmpty]; +} + - (void)showPathSuggester { [preferencesController showPathSuggester:self]; } diff --git a/Playlist/PlaylistController.h b/Playlist/PlaylistController.h index a76806d83..068bc4b42 100644 --- a/Playlist/PlaylistController.h +++ b/Playlist/PlaylistController.h @@ -156,4 +156,6 @@ typedef NS_ENUM(NSInteger, URLOrigin) { - (void)tableView:(NSTableView *)view didClickRow:(NSInteger)clickedRow column:(NSInteger)clickedColumn atPoint:(NSPoint)cellPoint; +- (BOOL)pathSuggesterEmpty; + @end diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index f41efa546..476346071 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -1824,4 +1824,14 @@ static void *playlistControllerContext = &playlistControllerContext; } } +- (BOOL)pathSuggesterEmpty { + NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"SandboxToken"]; + + NSError *error = nil; + NSArray *results = [self.persistentContainer.viewContext executeFetchRequest:request error:&error]; + + if(!results || [results count] < 1) return YES; + else return NO; +} + @end diff --git a/Window/MainWindow.m b/Window/MainWindow.m index 094fca788..799e7ccd6 100644 --- a/Window/MainWindow.m +++ b/Window/MainWindow.m @@ -8,6 +8,8 @@ #import "MainWindow.h" +#import "AppController.h" + void showCrashlyticsConsent(NSWindow *window) { BOOL askedConsent = [[NSUserDefaults standardUserDefaults] boolForKey:@"crashlyticsAskedConsent"]; if(!askedConsent) { @@ -29,6 +31,19 @@ void showCrashlyticsConsent(NSWindow *window) { } } +void showFolderPermissionConsent(NSWindow *window) { + if([AppController globalPathSuggesterEmpty]) { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:NSLocalizedString(@"FolderConsentTitle", @"")]; + [alert setInformativeText:NSLocalizedString(@"FolderConsentText", @"")]; + [alert addButtonWithTitle:NSLocalizedString(@"ConsentOK", @"")]; + + [alert beginSheetModalForWindow:window completionHandler:^(NSModalResponse returnCode) { + [AppController globalShowPathSuggester]; + }]; + } +} + @implementation MainWindow - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation { @@ -51,6 +66,7 @@ void showCrashlyticsConsent(NSWindow *window) { if(![[NSUserDefaults standardUserDefaults] boolForKey:@"miniMode"]) { showCrashlyticsConsent(self); + showFolderPermissionConsent(self); } } diff --git a/Window/MiniWindow.m b/Window/MiniWindow.m index d596e91f3..4d28e5239 100644 --- a/Window/MiniWindow.m +++ b/Window/MiniWindow.m @@ -13,6 +13,7 @@ extern NSString *iTunesDropType; extern void showCrashlyticsConsent(NSWindow *window); +extern void showFolderPermissionConsent(NSWindow *window); @implementation MiniWindow @@ -45,6 +46,7 @@ extern void showCrashlyticsConsent(NSWindow *window); if([[NSUserDefaults standardUserDefaults] boolForKey:@"miniMode"]) { showCrashlyticsConsent(self); + showFolderPermissionConsent(self); } } diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index f833d21df..473af7f07 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -77,5 +77,8 @@ "CrashlyticsConsentTitle" = "Crashlytics crash collection"; "CrashlyticsConsentText" = "Would you like to allow Crashlytics to submit crash reports? You may turn this off again in Preferences. We won't ask you again."; +"FolderConsentTitle" = "Folder permission"; +"FolderConsentText" = "You have not added any folder to the permission dialog. Please add your music folders before adding any documents, then restart the player."; "ConsentYes" = "Yes"; "ConsentNo" = "No"; +"ConsentOK" = "OK"; diff --git a/es.lproj/Localizable.strings b/es.lproj/Localizable.strings index f833d21df..473af7f07 100644 --- a/es.lproj/Localizable.strings +++ b/es.lproj/Localizable.strings @@ -77,5 +77,8 @@ "CrashlyticsConsentTitle" = "Crashlytics crash collection"; "CrashlyticsConsentText" = "Would you like to allow Crashlytics to submit crash reports? You may turn this off again in Preferences. We won't ask you again."; +"FolderConsentTitle" = "Folder permission"; +"FolderConsentText" = "You have not added any folder to the permission dialog. Please add your music folders before adding any documents, then restart the player."; "ConsentYes" = "Yes"; "ConsentNo" = "No"; +"ConsentOK" = "OK";