Skip to content

Commit

Permalink
Fixed Catalina issues
Browse files Browse the repository at this point in the history
  • Loading branch information
obrhoff committed Oct 11, 2019
1 parent 5bccfe1 commit 4661bff
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 63 deletions.
27 changes: 15 additions & 12 deletions MusaicFM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
E1FA39741DDA3FBE00186BE2 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1FA39721DDA3FBE00186BE2 /* MainMenu.xib */; };
E1FA39791DDA3FF300186BE2 /* PreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E129C5321DD900A300F93950 /* PreferencesViewController.xib */; };
E1FA397A1DDA3FF300186BE2 /* PreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E129C5351DD9020300F93950 /* PreferencesViewController.m */; };
E1FF4D9C2350B9BA00B89371 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E13191BA1DE1C4CA005EFA47 /* WebKit.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -119,6 +120,7 @@
files = (
E1472E541DD8D1C70007E945 /* Foundation.framework in Frameworks */,
E1472E521DD8D1C10007E945 /* Cocoa.framework in Frameworks */,
E1FF4D9C2350B9BA00B89371 /* WebKit.framework in Frameworks */,
08413D7CBB6FF19716237235 /* libPods-MusaicFM.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -320,6 +322,7 @@
TargetAttributes = {
E1CF25981DD7D8D500441255 = {
CreatedOnToolsVersion = 8.1;
DevelopmentTeam = YE33ZK7Z99;
ProvisioningStyle = Automatic;
};
E1FA39671DDA3FBE00186BE2 = {
Expand Down Expand Up @@ -496,7 +499,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -538,7 +541,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
Expand All @@ -550,12 +553,12 @@
buildSettings = {
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = YE33ZK7Z99;
INFOPLIST_FILE = MusaicFM/Info.plist;
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 1.1.4;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.obrhoff.MusaicFM;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = saver;
Expand All @@ -568,12 +571,12 @@
buildSettings = {
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_TEAM = YE33ZK7Z99;
INFOPLIST_FILE = MusaicFM/Info.plist;
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 1.1.4;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.obrhoff.MusaicFM;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = saver;
Expand All @@ -591,7 +594,7 @@
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = MusaicFMPreferences/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.1.4;
PRODUCT_BUNDLE_IDENTIFIER = com.obrhoff.MusaicFMPreferences;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -609,7 +612,7 @@
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = MusaicFMPreferences/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.1.4;
PRODUCT_BUNDLE_IDENTIFIER = com.obrhoff.MusaicFMPreferences;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
53 changes: 28 additions & 25 deletions MusaicFM/PreferencesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#import "Constants.h"
#import "Factory.h"

@interface PreferencesViewController () <WebFrameLoadDelegate, WebPolicyDelegate>
@interface PreferencesViewController () <WKNavigationDelegate>

@property (nonatomic, readwrite, weak) IBOutlet NSButton *doneButton;
@property (nonatomic, readwrite, weak) IBOutlet NSPopUpButton *rowButton;
Expand All @@ -36,7 +36,7 @@ @interface PreferencesViewController () <WebFrameLoadDelegate, WebPolicyDelegate

@property (nonatomic, readwrite, weak) IBOutlet NSPopUpButton *lastFmWeeklyButton;

@property (nonatomic, readwrite, weak) IBOutlet WebView *webView;
@property (nonatomic, readwrite, weak) IBOutlet WKWebView *webView;
@property (nonatomic, readwrite, weak) IBOutlet NSView *settingsView;
@property (nonatomic, readwrite, weak) IBOutlet NSView *containerView;

Expand Down Expand Up @@ -122,7 +122,8 @@ - (IBAction)loginSpotify:(NSButton *)sender {
else {
self.webView.hidden = NO;
self.settingsView.hidden = YES;
[self.webView.mainFrame loadRequest:[NSURLRequest requestWithURL:[Factory spotifyAuthentification].URL]];
NSURLRequest *request = [NSURLRequest requestWithURL:[Factory spotifyAuthentification].URL];
[self.webView loadRequest:request];
}
}

Expand Down Expand Up @@ -152,30 +153,32 @@ - (NSString *)windowNibName {
return @"PreferencesViewController";
}

- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request
frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
NSURLComponents *components = [NSURLComponents componentsWithURL:request.URL resolvingAgainstBaseURL:NO];
NSURLComponents *callbackComponents = [NSURLComponents componentsWithString:spotifyRedirectUrl];
-(void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {

if (![components.scheme isEqualToString:callbackComponents.scheme]) {
[listener use];
return;
}
NSURLComponents *components = [NSURLComponents componentsWithURL:webView.URL resolvingAgainstBaseURL:NO];
NSURLComponents *callbackComponents = [NSURLComponents componentsWithString:spotifyRedirectUrl];

if (![components.scheme isEqualToString:callbackComponents.scheme]) {
decisionHandler(WKNavigationActionPolicyAllow);
return;
}

NSPredicate *filter = [NSPredicate predicateWithFormat:@"name == %@", @"code"];
NSString *code = [[components.queryItems filteredArrayUsingPredicate:filter].firstObject value];
typeof(self) weakSelf = self;

dispatch_block_t dismiss = ^{
[weakSelf configure];
decisionHandler(WKNavigationActionPolicyCancel);
};
if (!code.length) {
dismiss();
return;
}
[self.manager performSpotifyToken:code completionHandler:dismiss andFailure:^(NSError *error) {
dismiss();
}];

NSPredicate *filter = [NSPredicate predicateWithFormat:@"name == %@", @"code"];
NSString *code = [[components.queryItems filteredArrayUsingPredicate:filter].firstObject value];
typeof(self) weakSelf = self;
dispatch_block_t dismiss = ^{
[weakSelf configure];
};
if (!code.length) {
dismiss();
return;
}
[self.manager performSpotifyToken:code completionHandler:dismiss andFailure:^(NSError *error) {
dismiss();
}];
}


@end
Loading

0 comments on commit 4661bff

Please sign in to comment.