diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 3567d0b..d6e91cf 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -1332,8 +1332,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 98; - SHARED_VERSION = 2.9.1; + SHARED_BUILD = 99; + SHARED_VERSION = 2.10; STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1395,8 +1395,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 98; - SHARED_VERSION = 2.9.1; + SHARED_BUILD = 99; + SHARED_VERSION = 2.10; STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/QuickDrop/AppDelegate.swift b/QuickDrop/AppDelegate.swift index be548e8..064fc99 100644 --- a/QuickDrop/AppDelegate.swift +++ b/QuickDrop/AppDelegate.swift @@ -102,24 +102,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele } BezelNotification.show(messageText: "ReadyToReceive".localized(), icon: .receiveIcon) + + // only start receiving immediately for existing user, for new users we want to delay the permission prompt + startReceiving() } UNUserNotificationCenter.current().delegate = self - receiveModel = ReceiveModel(controlPlusScreen: { shouldOpen in - if shouldOpen { - self.openPlusScreen() - } - else { - if let window = self.plusWindow { - log("[AppDelegate] Closing plus screen because of error") - window.close() - self.plusWindow = nil - } - } - }) - - NearbyConnectionManager.shared.connectionUpdateCallback = { isConnected in if isConnected { self.statusItem?.button?.image = NSImage(named: "MenuBarIcon") @@ -139,6 +128,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele } + func startReceiving() { + receiveModel = ReceiveModel(controlPlusScreen: { shouldOpen in + if shouldOpen { + self.openPlusScreen() + } + else { + if let window = self.plusWindow { + log("[AppDelegate] Closing plus screen because of error") + window.close() + self.plusWindow = nil + } + } + }) + } + + func windowWillClose(_ notification: Notification) { if let window = notification.object as? NSWindow, window == welcomeWindow { log("Welcome window closed") @@ -221,6 +226,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele let welcomeView = WelcomeScreen( openIntroduction: openIntroduction, + startReceiving: startReceiving, openPlusScreen: openPlusScreen, openAppAdvertisementView: { self.openSheetView(type: .downloadAndroidApp) }, openCableTransmissionView: { self.openSheetView(type: .downloadCableConnectionApp) }, diff --git a/QuickDrop/View/Introduction/IntroductionSplashView.swift b/QuickDrop/View/Introduction/IntroductionSplashView.swift index d94bf2a..fc27bff 100644 --- a/QuickDrop/View/Introduction/IntroductionSplashView.swift +++ b/QuickDrop/View/Introduction/IntroductionSplashView.swift @@ -16,6 +16,7 @@ struct IntroductionSplashView: View { @State private var pollingPage: IntroductionPage? = nil @State private var skipAction: IntroductionPage.SkipAction? = nil + let startReceiving: (() -> Void) let onFinish: (() -> Void) var body: some View { @@ -177,8 +178,22 @@ struct IntroductionSplashView: View { } } } + + private func triggerLocalNetworkPermission() { + self.startReceiving() + + // just to be sure it is triggered + runAfter(seconds: 1) { + DeviceToDeviceHeuristicScanner.shared.scan(completion: { _ in }) + } + } private func advance() { + + if currentPage == .localNetworkAccess { + triggerLocalNetworkPermission() + } + if let nextPage = currentPage.presentNextPage() { currentPage = nextPage } else { @@ -262,7 +277,6 @@ enum IntroductionPage: CaseIterable { case .noWifi: return .localNetworkAccess case .localNetworkAccess: - DeviceToDeviceHeuristicScanner.shared.scan(completion: { _ in }) return .enableShareExtension case .enableShareExtension: return .finished @@ -325,6 +339,6 @@ enum IntroductionPage: CaseIterable { #Preview { - IntroductionSplashView{} + IntroductionSplashView(startReceiving: {}){} .frame(width: 600, height: 500) } diff --git a/QuickDrop/View/TutorialView.swift b/QuickDrop/View/TutorialView.swift index 20d852f..1c2d528 100644 --- a/QuickDrop/View/TutorialView.swift +++ b/QuickDrop/View/TutorialView.swift @@ -99,5 +99,5 @@ struct LargeAppIconView: View { #Preview { - WelcomeScreen(openIntroduction: false, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {}) + WelcomeScreen(openIntroduction: false, startReceiving: {}, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {}) } diff --git a/QuickDrop/View/WelcomeScreen.swift b/QuickDrop/View/WelcomeScreen.swift index 9fd7e45..df217c1 100644 --- a/QuickDrop/View/WelcomeScreen.swift +++ b/QuickDrop/View/WelcomeScreen.swift @@ -12,12 +12,14 @@ struct WelcomeScreen: View { internal init( openIntroduction: Bool, + startReceiving: @escaping () -> Void, openPlusScreen: @escaping () -> Void, openAppAdvertisementView: @escaping () -> Void, openCableTransmissionView: @escaping () -> Void, checkForNetworkIssues: @escaping () -> Void ) { self._openedIntroduction = State(initialValue: openIntroduction) + self.startReceiving = startReceiving self.openPlusScreen = openPlusScreen self.openAppAdvertisementView = openAppAdvertisementView self.openCableTransmissionView = openCableTransmissionView @@ -28,6 +30,7 @@ struct WelcomeScreen: View { @Environment(\.colorScheme) var colorScheme let openPlusScreen: () -> Void + let startReceiving: () -> Void let openAppAdvertisementView: () -> Void let openCableTransmissionView: () -> Void let checkForNetworkIssues: () -> Void @@ -45,7 +48,7 @@ struct WelcomeScreen: View { .resizable() .ignoresSafeArea(.all) - IntroductionSplashView { + IntroductionSplashView(startReceiving: startReceiving) { openedIntroduction = false } .background(Color(NSColor.windowBackgroundColor)) @@ -239,5 +242,5 @@ enum Tabs: CaseIterable { #Preview { - WelcomeScreen(openIntroduction: true, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {}) + WelcomeScreen(openIntroduction: true, startReceiving: {}, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {}) }