diff --git a/.gitignore b/.gitignore index 665af98..2a7c969 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,12 @@ -*.DS_Store - -Pods/ - +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore +.DS_Store +## Build generated build/ DerivedData/ +## Various settings *.pbxuser !default.pbxuser *.mode1v3 @@ -15,20 +17,62 @@ DerivedData/ !default.perspectivev3 xcuserdata/ +## Other *.moved-aside *.xccheckout *.xcscmblueprint +## Obj-C/Swift specific *.hmap *.ipa *.dSYM.zip *.dSYM +## Playgrounds timeline.xctimeline playground.xcworkspace -*.xcodeproj/* -!*.xcodeproj/project.pbxproj -!*.xcodeproj/xcshareddata/ -!*.xcworkspace/contents.xcworkspacedata -/*.gcno \ No newline at end of file +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ \ No newline at end of file diff --git a/Numu Tracker.xcodeproj/project.pbxproj b/Numu Tracker.xcodeproj/project.pbxproj index 8c99101..f025294 100644 --- a/Numu Tracker.xcodeproj/project.pbxproj +++ b/Numu Tracker.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ 447FED45217BB68D0084530E /* SearchYouTubeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 447FED43217BB68D0084530E /* SearchYouTubeTableViewCell.swift */; }; 447FED46217BB68D0084530E /* SearchYouTubeTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 447FED44217BB68D0084530E /* SearchYouTubeTableViewCell.xib */; }; 447FED48217BC17C0084530E /* NumuModalButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 447FED47217BC17C0084530E /* NumuModalButton.swift */; }; + 448C68EB21CB092B00ECEC61 /* AlertModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 448C68EA21CB092B00ECEC61 /* AlertModal.swift */; }; 449F5A7B2176B99900B9C919 /* MoreReleasesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 449F5A792176B99900B9C919 /* MoreReleasesTableViewCell.swift */; }; 449F5A7C2176B99900B9C919 /* MoreReleasesTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 449F5A7A2176B99900B9C919 /* MoreReleasesTableViewCell.xib */; }; 44D3917021691D5000CFB9A3 /* NumuSortView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44D3916E21691D5000CFB9A3 /* NumuSortView.swift */; }; @@ -98,6 +99,7 @@ 447FED43217BB68D0084530E /* SearchYouTubeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchYouTubeTableViewCell.swift; sourceTree = ""; }; 447FED44217BB68D0084530E /* SearchYouTubeTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SearchYouTubeTableViewCell.xib; sourceTree = ""; }; 447FED47217BC17C0084530E /* NumuModalButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumuModalButton.swift; sourceTree = ""; }; + 448C68EA21CB092B00ECEC61 /* AlertModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertModal.swift; sourceTree = ""; }; 449F5A792176B99900B9C919 /* MoreReleasesTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoreReleasesTableViewCell.swift; sourceTree = ""; }; 449F5A7A2176B99900B9C919 /* MoreReleasesTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MoreReleasesTableViewCell.xib; sourceTree = ""; }; 44D3916E21691D5000CFB9A3 /* NumuSortView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumuSortView.swift; sourceTree = ""; }; @@ -232,6 +234,7 @@ 4461CB7A2158470C001939F0 /* FetchJSONOperation.swift */, 446DBDE7215AF82400AE2AA7 /* ImportAppleMusicOperation.swift */, 4406A0022173A674002900E8 /* ImportSpotifyOperation.swift */, + 448C68EA21CB092B00ECEC61 /* AlertModal.swift */, ); path = Operations; sourceTree = ""; @@ -568,7 +571,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\"\n"; }; B48D5FE01F6CE6D70045961A /* Fabric */ = { isa = PBXShellScriptBuildPhase; @@ -624,6 +627,7 @@ B4F1E3AB2058C6C100F2544A /* NumuReviewHelper.swift in Sources */, B46754581F6DA66F00C80544 /* InstructionsViewController.swift in Sources */, 4461CB7F21585488001939F0 /* NumuAPI.swift in Sources */, + 448C68EB21CB092B00ECEC61 /* AlertModal.swift in Sources */, B4B940AE1E6131B800F52027 /* NotificationsViewController.swift in Sources */, 447FED3E217B839F0084530E /* MusicServicesViewController.swift in Sources */, B4283A851D8548F300467CE6 /* AppDelegate.swift in Sources */, diff --git a/Numu Tracker/AppDelegate.swift b/Numu Tracker/AppDelegate.swift index 605ddff..098bdcf 100644 --- a/Numu Tracker/AppDelegate.swift +++ b/Numu Tracker/AppDelegate.swift @@ -22,6 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Production let pusher = Pusher(key: "") + let oldPusher = Pusher(key: "") // Development //let pusher = Pusher(key: "") @@ -64,7 +65,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { pusher.nativePusher.register(deviceToken: deviceToken) + oldPusher.nativePusher.register(deviceToken: deviceToken) if let username = NumuCredential.shared.getUsername() { + oldPusher.nativePusher.unsubscribe(interestName: "newReleased_" + username) + oldPusher.nativePusher.unsubscribe(interestName: "newAnnouncements_" + username) + oldPusher.nativePusher.unsubscribe(interestName: "moreReleases_" + username) if defaults.newReleased { pusher.nativePusher.subscribe(interestName: "newReleased_" + username) print("Turned on new notifications") diff --git a/Numu Tracker/Info.plist b/Numu Tracker/Info.plist index be9c038..09f80d1 100644 --- a/Numu Tracker/Info.plist +++ b/Numu Tracker/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.3.1 + 1.3.2 CFBundleURLTypes @@ -32,7 +32,7 @@ CFBundleVersion - 858 + 948 Fabric APIKey @@ -52,6 +52,7 @@ LSApplicationQueriesSchemes spotify-action + twitter LSRequiresIPhoneOS diff --git a/Numu Tracker/Operations/AlertModal.swift b/Numu Tracker/Operations/AlertModal.swift new file mode 100644 index 0000000..a9b6cf6 --- /dev/null +++ b/Numu Tracker/Operations/AlertModal.swift @@ -0,0 +1,46 @@ +// +// AlertModal.swift +// Numu Tracker +// +// Created by Brad Root on 12/19/18. +// Copyright © 2018 Numu Tracker. All rights reserved. +// + +import UIKit + +class AlertModal: AsyncOperation { + let title: String! + let button: String! + let message: String! + + init(title: String, button: String, message: String) { + self.title = title + self.button = button + self.message = message + } + + override func main() { + let alertView = NumuAlertView() + alertView.providesPresentationContextTransitionStyle = true + alertView.definesPresentationContext = true + alertView.modalPresentationStyle = UIModalPresentationStyle.overFullScreen + alertView.modalTransitionStyle = UIModalTransitionStyle.crossDissolve + alertView.modalPresentationCapturesStatusBarAppearance = true + DispatchQueue.main.async { + if let appDelegate = UIApplication.shared.delegate, + let appWindow = appDelegate.window!, + let rootViewController = appWindow.rootViewController { + rootViewController.present(alertView, animated: true, completion: nil) + alertView.titleText = self.title + alertView.buttonText = self.button + alertView.messageText = self.message + } + } + self.state = .isFinished + } + + func present() { + self.qualityOfService = .userInitiated + OperationQueue.main.addOperation(self) + } +} diff --git a/Numu Tracker/Operations/ImportAppleMusicOperation.swift b/Numu Tracker/Operations/ImportAppleMusicOperation.swift index 620d3fc..6525fd2 100644 --- a/Numu Tracker/Operations/ImportAppleMusicOperation.swift +++ b/Numu Tracker/Operations/ImportAppleMusicOperation.swift @@ -69,8 +69,8 @@ class ImportAppleMusicOperation: AsyncOperation { if let success = returnedJSON["success"] as? Int { self.artistsImported = success NumuReviewHelper.incrementAndAskForReview() - self.displaySuccessMessage() DispatchQueue.main.async(execute: { + self.displaySuccessMessage() NotificationCenter.default.post(name: .UpdatedArtists, object: nil) NotificationCenter.default.post(name: .LoggedIn, object: nil) Answers.logCustomEvent(withName: "AM Artist Import") @@ -94,19 +94,13 @@ class ImportAppleMusicOperation: AsyncOperation { } func displaySuccessMessage() { - DispatchQueue.main.async { - let alertView = NumuAlertView() - alertView.providesPresentationContextTransitionStyle = true - alertView.definesPresentationContext = true - alertView.modalPresentationStyle = UIModalPresentationStyle.overFullScreen - alertView.modalTransitionStyle = UIModalTransitionStyle.crossDissolve - alertView.modalPresentationCapturesStatusBarAppearance = true - if let appDelegate = UIApplication.shared.delegate, - let appWindow = appDelegate.window!, - let rootViewController = appWindow.rootViewController { - rootViewController.present(alertView, animated: true, completion: nil) - } - } + AlertModal( + title: "Success", + button: "Groovy", + message: "Your artists have been imported. " + + "Please wait several minutes for all artists " + + "to appear in your collection." + ).present() } func displayAMError() { @@ -121,20 +115,12 @@ class ImportAppleMusicOperation: AsyncOperation { error = "Unknown error" } DispatchQueue.main.async { - let alertView = NumuAlertView() - alertView.providesPresentationContextTransitionStyle = true - alertView.definesPresentationContext = true - alertView.modalPresentationStyle = UIModalPresentationStyle.overFullScreen - alertView.modalTransitionStyle = UIModalTransitionStyle.crossDissolve - alertView.modalPresentationCapturesStatusBarAppearance = true - alertView.titleText = "Error" - alertView.messageText = error - alertView.buttonText = "Oh no" - if let appDelegate = UIApplication.shared.delegate, - let appWindow = appDelegate.window!, - let rootViewController = appWindow.rootViewController { - rootViewController.present(alertView, animated: true, completion: nil) - } + AlertModal( + title: "Error", + button: "Oh no", + message: error + ).present() } + self.state = .isFinished } } diff --git a/Numu Tracker/Operations/ImportSpotifyOperation.swift b/Numu Tracker/Operations/ImportSpotifyOperation.swift index f6a0329..0451dca 100644 --- a/Numu Tracker/Operations/ImportSpotifyOperation.swift +++ b/Numu Tracker/Operations/ImportSpotifyOperation.swift @@ -170,36 +170,23 @@ class ImportSpotifyOperation: AsyncOperation { func displaySuccessMessage() { DispatchQueue.main.async { - let alertView = NumuAlertView() - alertView.providesPresentationContextTransitionStyle = true - alertView.definesPresentationContext = true - alertView.modalPresentationStyle = UIModalPresentationStyle.overFullScreen - alertView.modalTransitionStyle = UIModalTransitionStyle.crossDissolve - alertView.modalPresentationCapturesStatusBarAppearance = true - if let appDelegate = UIApplication.shared.delegate, - let appWindow = appDelegate.window!, - let rootViewController = appWindow.rootViewController { - rootViewController.present(alertView, animated: true, completion: nil) - } + AlertModal( + title: "Success", + button: "Groovy", + message: "Your artists have been imported. " + + "Please wait several minutes for all artists " + + "to appear in your collection." + ).present() } } func displaySpotifyError(error: String) { DispatchQueue.main.async { - let alertView = NumuAlertView() - alertView.providesPresentationContextTransitionStyle = true - alertView.definesPresentationContext = true - alertView.modalPresentationStyle = UIModalPresentationStyle.overFullScreen - alertView.modalTransitionStyle = UIModalTransitionStyle.crossDissolve - alertView.modalPresentationCapturesStatusBarAppearance = true - alertView.titleText = "Error" - alertView.messageText = error - alertView.buttonText = "Oh no" - if let appDelegate = UIApplication.shared.delegate, - let appWindow = appDelegate.window!, - let rootViewController = appWindow.rootViewController { - rootViewController.present(alertView, animated: true, completion: nil) - } + AlertModal( + title: "Error", + button: "Oh no", + message: error + ).present() self.state = .isFinished } } diff --git a/Numu Tracker/Views/Base.lproj/Main.storyboard b/Numu Tracker/Views/Base.lproj/Main.storyboard index edbeda9..1c9ea25 100644 --- a/Numu Tracker/Views/Base.lproj/Main.storyboard +++ b/Numu Tracker/Views/Base.lproj/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -627,7 +627,7 @@ Any imported artists you've unfollowed will not be re-imported. - + @@ -655,21 +655,21 @@ Any imported artists you've unfollowed will not be re-imported. -