From 7f636820cb87e4752b3d77b423ec0ab06fb720b2 Mon Sep 17 00:00:00 2001 From: Anders Fischer Date: Thu, 8 Aug 2019 16:26:39 +0200 Subject: [PATCH] Migrated localization. --- .../project.pbxproj | 3 +-- .../DragDropViewController.swift | 2 +- Traktor Transition Finder/Info.plist | 2 +- .../SongToSongViewController.swift | 2 +- Traktor Transition Finder/StateController.swift | 14 +++++--------- .../Traktor_Transition_Finder.entitlements | 8 ++++---- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Traktor Transition Finder.xcodeproj/project.pbxproj b/Traktor Transition Finder.xcodeproj/project.pbxproj index f39ab4e..6eecde3 100644 --- a/Traktor Transition Finder.xcodeproj/project.pbxproj +++ b/Traktor Transition Finder.xcodeproj/project.pbxproj @@ -151,10 +151,9 @@ }; buildConfigurationList = CD6B9487BAC72AB0154CB3BF /* Build configuration list for PBXProject "Traktor Transition Finder" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); diff --git a/Traktor Transition Finder/DragDropViewController.swift b/Traktor Transition Finder/DragDropViewController.swift index d107516..1995f3b 100644 --- a/Traktor Transition Finder/DragDropViewController.swift +++ b/Traktor Transition Finder/DragDropViewController.swift @@ -82,7 +82,7 @@ class DragDropViewController: NSViewController { } func selectSong(audioID: String) { - stateController?.incrementSelectedSongs() + stateController?.checkDonationStatus() transitions = (graph?[audioID]?.1.map { edge in return edge }) if (transitions != nil) { diff --git a/Traktor Transition Finder/Info.plist b/Traktor Transition Finder/Info.plist index e1f6408..f4ee603 100644 --- a/Traktor Transition Finder/Info.plist +++ b/Traktor Transition Finder/Info.plist @@ -17,7 +17,7 @@ CFBundleShortVersionString 1.6.6 CFBundleVersion - 1 + 2 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion diff --git a/Traktor Transition Finder/SongToSongViewController.swift b/Traktor Transition Finder/SongToSongViewController.swift index 48a7349..ca382e5 100644 --- a/Traktor Transition Finder/SongToSongViewController.swift +++ b/Traktor Transition Finder/SongToSongViewController.swift @@ -47,7 +47,7 @@ class SongToSongViewController: NSViewController { } func selectSong(audioID: String, index: Int) { - stateController?.incrementSelectedSongs() + stateController?.checkDonationStatus() guard index < 2 else { return } if let song = graph?[audioID]?.0 { if index == 0 { firstSong = song } diff --git a/Traktor Transition Finder/StateController.swift b/Traktor Transition Finder/StateController.swift index 40b6aad..b3fda50 100644 --- a/Traktor Transition Finder/StateController.swift +++ b/Traktor Transition Finder/StateController.swift @@ -32,6 +32,7 @@ class StateController { } } var graph: [String: (Song, [Edge])]? + private var openedDialogLast = Date() private var listeners: [StateSubscriber] init() { @@ -43,21 +44,15 @@ class StateController { listeners.append(listener) } - func incrementSelectedSongs() { - let before = UserDefaults.standard.integer(forKey: "selectedSongs") - UserDefaults.standard.set(before + 1, forKey: "selectedSongs") - checkDonationStatus() - } - - private func checkDonationStatus() { + func checkDonationStatus() { func openDonateURL() { let url = URL(string: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ME8E22EZTC5G4&source=url") NSWorkspace.shared.open(url!) } - let songCount = UserDefaults.standard.integer(forKey: "selectedSongs") let donated = UserDefaults.standard.bool(forKey: "alreadyDonated") - if (songCount % 10 == 0 && !donated) { + let interval = DateInterval(start: self.openedDialogLast, end: Date()) + if (!donated && interval.duration/60 > 5) { let alert = NSAlert() alert.messageText = "Please consider supporting the development of Traktor Transition Finder" alert.informativeText = "Developing software takes time and ressources. \nPlease consider donating to support the development and improvement of Traktor Transition Finder." @@ -79,6 +74,7 @@ class StateController { else { UserDefaults.standard.set(false, forKey: "alreadyDonated") } + self.openedDialogLast = Date() } } } diff --git a/Traktor Transition Finder/Traktor_Transition_Finder.entitlements b/Traktor Transition Finder/Traktor_Transition_Finder.entitlements index f2ef3ae..18aff0c 100644 --- a/Traktor Transition Finder/Traktor_Transition_Finder.entitlements +++ b/Traktor Transition Finder/Traktor_Transition_Finder.entitlements @@ -2,9 +2,9 @@ - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-only - + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only +