[Sandbox] Show grant dialog on launch if empty
If there are no configured paths, show the grant page on every startup. Signed-off-by: Christopher Snowhill <kode54@gmail.com>lastfm
parent
de7afad3d4
commit
22085d94f1
|
@ -97,6 +97,8 @@
|
|||
- (IBAction)toggleMiniMode:(id)sender;
|
||||
- (IBAction)toggleToolbarStyle:(id)sender;
|
||||
|
||||
- (BOOL)pathSuggesterEmpty;
|
||||
+ (BOOL)globalPathSuggesterEmpty;
|
||||
- (void)showPathSuggester;
|
||||
+ (void)globalShowPathSuggester;
|
||||
|
||||
|
|
|
@ -715,6 +715,14 @@ static AppController *kAppController = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (BOOL)pathSuggesterEmpty {
|
||||
return [playlistController pathSuggesterEmpty];
|
||||
}
|
||||
|
||||
+ (BOOL)globalPathSuggesterEmpty {
|
||||
return [kAppController pathSuggesterEmpty];
|
||||
}
|
||||
|
||||
- (void)showPathSuggester {
|
||||
[preferencesController showPathSuggester:self];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue