diff --git a/NearbyShare/Util/Helpers.swift b/NearbyShare/Util/Helpers.swift index 2dcc8b1..71028d1 100644 --- a/NearbyShare/Util/Helpers.swift +++ b/NearbyShare/Util/Helpers.swift @@ -5,8 +5,9 @@ // Created by Leon Böttger on 04.04.25. // -import Foundation import CryptoKit +import Foundation +import LUI extension Data { func urlSafeBase64EncodedString() -> String { @@ -111,7 +112,11 @@ extension String { public func fullVersion() -> Bool { - return Settings.sharedInstance.gotPlus + #if GITHUB + return true + #else + return IAPManager.sharedInstance.plusVersionState + #endif } diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 2d9078f..8a3b13a 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -1739,8 +1739,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 126; - SHARED_VERSION = 2.13.1; + SHARED_BUILD = 128; + SHARED_VERSION = 2.13.2; STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1802,8 +1802,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 126; - SHARED_VERSION = 2.13.1; + SHARED_BUILD = 128; + SHARED_VERSION = 2.13.2; STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 26e93bf..080d3a0 100644 --- a/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -52,7 +52,7 @@ "location" : "https://github.com/leonboe1/LUI.git", "state" : { "branch" : "main", - "revision" : "24e35e2829f478d4219e82921302321dae6c1e78" + "revision" : "b1be835c12befddc3c5f678837a766d51db1bdc5" } }, { @@ -87,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "9bbb079b69af9d66470ced85461bf13bb40becac", - "version" : "1.35.0" + "revision" : "5596511fce902e649c403cd4d6d5da1254f142b7", + "version" : "1.35.1" } }, { diff --git a/QuickDrop/AppDelegate.swift b/QuickDrop/AppDelegate.swift index 900a8a1..ec8c82b 100644 --- a/QuickDrop/AppDelegate.swift +++ b/QuickDrop/AppDelegate.swift @@ -26,7 +26,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele private var sheetAttachedWindow: NSWindow? = nil private var errorAlertHandler = ErrorAlertHandler.shared - private var iapManager: IAPManager? private var receiveModel: ReceiveModel? var showsFirewallAlert = false @@ -35,11 +34,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele // MARK: NSApplicationDelegate functions - func applicationWillFinishLaunching(_: Notification) { - LUIInit(configuration: configuration) - } - - func applicationDidFinishLaunching(_: Notification) { let menu = NSMenu() @@ -72,27 +66,26 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele statusItem?.button?.image = NSImage(named: "MenuBarIcon") statusItem?.menu = menu statusItem?.behavior = .removalAllowed - - iapManager = IAPManager.sharedInstance - + // app did not lauch before if !Settings.sharedInstance.appLaunchedBefore { log("[AppDelegate] Opening Welcome Screen") - // open welcome screen - openMainWindow() + + DispatchQueue.main.async { + // open welcome screen in next cycle (await LUIInit) + self.openMainWindow() + } // user installed the app after the IAP was implemented, set the user as eligible for IAP Settings.sharedInstance.isEligibleForIap = true } else { // app launched before - #if GITHUB log("[AppDelegate] Downloaded from GitHub.") #else // user installed the app before the IAP was implemented, grant the plus version if !Settings.sharedInstance.isEligibleForIap { log("[AppDelegate] Granting QuickDrop+ for old user") - Settings.sharedInstance.gotPlus = true UserDefaults.standard.set(true, forKey: Settings.UserDefaultsKeys.plusVersionLegacy.rawValue) } else { if !fullVersion() { @@ -109,6 +102,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele // only start receiving immediately for existing user, for new users we want to delay the permission prompt startReceiving() } + + LUIInit(configuration: configuration) UNUserNotificationCenter.current().delegate = self diff --git a/QuickDrop/Configuration.swift b/QuickDrop/Configuration.swift index 713c816..7f1b8a5 100644 --- a/QuickDrop/Configuration.swift +++ b/QuickDrop/Configuration.swift @@ -13,14 +13,6 @@ let configuration = LUIConfiguration( plusVersionInfo: GetPlusViewInformation(lifetimeID: "plusversion", monthlyID: "quickdrop.monthly", yearlyID: "quickdrop.yearly", plusViewHeader: isMac() ? "plusview_title" : nil, description: isMac() ? "plusview_description" : "plusview_description_phone", onBoughtPlusVersionAlertMessage: "plusview_success_description", plusVersionFeatures: [], settingsLabelColor: .orange, settingsFooter: "plusview_footer_phone"), - setPlusVersion: { result in - #if !GITHUB - DispatchQueue.main.async { - Settings.sharedInstance.gotPlus = result - } - #endif - }, - hasRoundedFont: false, switchedToIAPafterBundleVersion: AppVersionBundle(appVersion: "1.2", buildVersion: 0, legacyUserDefaultsKey: Settings.UserDefaultsKeys.plusVersionLegacy.rawValue), diff --git a/QuickDrop/InfoPlist.xcstrings b/QuickDrop/InfoPlist.xcstrings index f08ce56..28ad665 100644 --- a/QuickDrop/InfoPlist.xcstrings +++ b/QuickDrop/InfoPlist.xcstrings @@ -21,7 +21,7 @@ "en" : { "stringUnit" : { "state" : "new", - "value" : "QuickDropGitHub" + "value" : "QuickDrop" } } }, diff --git a/QuickDrop/Settings.swift b/QuickDrop/Settings.swift index 132faa2..0d7e91f 100644 --- a/QuickDrop/Settings.swift +++ b/QuickDrop/Settings.swift @@ -17,14 +17,6 @@ final class Settings: SharedInstance { // MARK: - Published UserDefaults Backed Properties - #if GITHUB - let gotPlus = true - #else - @Published var gotPlus = UserDefaults.standard.bool(forKey: UserDefaultsKeys.plusVersion.rawValue) - { didSet { UserDefaults.standard.set(gotPlus, forKey: UserDefaultsKeys.plusVersion.rawValue) }} - #endif - - @Published var automaticallyAcceptFiles: Bool = UserDefaults.standard.bool(forKey: UserDefaultsKeys.automaticallyAcceptFiles.rawValue) { didSet { UserDefaults.standard.set(automaticallyAcceptFiles, forKey: UserDefaultsKeys.automaticallyAcceptFiles.rawValue) }} @@ -76,7 +68,6 @@ final class Settings: SharedInstance { public enum UserDefaultsKeys: String, CaseIterable, RawRepresentable { case isEligibleForIap = "isEligibleForIap" case appLaunchedBefore = "ShowedWelcomeScreen" - case plusVersion = "plusVersion" case transmissionCount = "reviewRequestCountKey" case automaticallyAcceptFiles = "automaticallyAcceptFiles" case saveFolderBookmark = "saveFolderBookmark" diff --git a/QuickDrop/View/UserManual/TutorialView.swift b/QuickDrop/View/UserManual/TutorialView.swift index 5170e91..1310150 100644 --- a/QuickDrop/View/UserManual/TutorialView.swift +++ b/QuickDrop/View/UserManual/TutorialView.swift @@ -15,7 +15,7 @@ struct TutorialView: View { let openPlus: () -> Void @State private var licenseWindow: NSWindow? - @ObservedObject var settings = Settings.sharedInstance + @ObservedObject var iapManager = IAPManager.sharedInstance var body: some View { @@ -54,8 +54,9 @@ struct TutorialView: View { .opacity(0.5) } .buttonStyle(.plain) - - if !settings.gotPlus { + + #if !GITHUB + if !iapManager.plusVersionState { Button { openPlus() } label: { @@ -66,8 +67,9 @@ struct TutorialView: View { } .buttonStyle(.plain) } + #endif -#if DEBUG + #if DEBUG Button { Settings.sharedInstance.deleteAllUserDefaults() } label: { @@ -77,7 +79,7 @@ struct TutorialView: View { .opacity(0.5) } .buttonStyle(.plain) -#endif + #endif } .padding() } diff --git a/QuickDropiOS/View/ContentView.swift b/QuickDropiOS/View/ContentView.swift index 0f64f42..0b76469 100644 --- a/QuickDropiOS/View/ContentView.swift +++ b/QuickDropiOS/View/ContentView.swift @@ -12,14 +12,14 @@ import StoreKit struct ContentView: View { @ObservedObject var luiSettings = LUISettings.sharedInstance - @ObservedObject var settings = Settings.sharedInstance + @ObservedObject var iapManager = IAPManager.sharedInstance var body: some View { - AppRootView(isPlus: $settings.gotPlus, phoneView: { + AppRootView(phoneView: { DeviceListView() .environment(\.sheetActive, isShareExtension()) }, settingsView: { - CustomSection(header: settings.gotPlus ? "" : "General", footer: "TrustedDevicesFooterShort") { + CustomSection(header: iapManager.plusVersionState ? "" : "General", footer: "TrustedDevicesFooterShort") { LUIButton { FileManager.default.openDocumentFolder() } label: { @@ -46,13 +46,10 @@ struct DeviceListView: View { #if !EXTENSION @StateObject var receiveModel = ReceiveModel(controlPlusScreen: { show in log("[DeviceListView] Setting showPlusScreen to \(show)") - errorVibration() - DeviceListViewModel.sharedInstance.showPlusScreen = show + presentPaywall() }) #endif - @ObservedObject var model = DeviceListViewModel.sharedInstance - @Environment(\.scenePhase) var scenePhase @Environment(\.sheetActive) var sheetActive @ObservedObject var nearbyConnectionManager = NearbyConnectionManager.shared @@ -219,9 +216,6 @@ struct DeviceListView: View { NearbyConnectionManager.shared.stopDeviceDiscovery() } } - #if !EXTENSION - .modifier(PlusVersionSheetModifier(sheetActive: $model.showPlusScreen, isPlusVersion: $settings.gotPlus)) - #endif .animation(.smooth, value: nearbyConnectionManager.hasLocalNetworkPermission) .animation(.smooth, value: nearbyConnectionManager.isConnectedToLocalNetwork) .navigationBarItems(trailing: ZStack { @@ -236,13 +230,6 @@ struct DeviceListView: View { } -final class DeviceListViewModel: SharedInstance { - static var sharedInstance = DeviceListViewModel() - - @Published var showPlusScreen = false -} - - struct DeviceFilePickerButton: View { let device: RemoteDeviceInfo diff --git a/QuickDropiOS/View/LocalNetworkPermissionView.swift b/QuickDropiOS/View/LocalNetworkPermissionView.swift index 10930c1..8d6aad4 100644 --- a/QuickDropiOS/View/LocalNetworkPermissionView.swift +++ b/QuickDropiOS/View/LocalNetworkPermissionView.swift @@ -15,7 +15,7 @@ public struct LocalNetworkPermissionView: View { public var body: some View { - PermissionView(title: "introduction_local_network_access", symbol: "", subtitle: "introduction_local_network_access_description".localized(with: "introduction_continue".localized()), permissionAction: { + PermissionView(title: "introduction_local_network_access", watchSymbol: "", subtitle: "introduction_local_network_access_description".localized(with: "introduction_continue".localized()), permissionAction: { if requestedLocalNetworkAccess { // Something went wrong, user pressed again on continue. In this case, just continue with setup