mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-20 21:36:00 +00:00
Fix: Delay local network permission prompt to introduction
This commit is contained in:
1 parent
1bd15acaef
commit
8a9bb0bdfe
5 files changed
+46
-23
No files matched your search
@@ -1332,8 +1332,8 @@
|
|||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SHARED_BUILD = 98;
|
SHARED_BUILD = 99;
|
||||||
SHARED_VERSION = 2.9.1;
|
SHARED_VERSION = 2.10;
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -1395,8 +1395,8 @@
|
|||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SHARED_BUILD = 98;
|
SHARED_BUILD = 99;
|
||||||
SHARED_VERSION = 2.9.1;
|
SHARED_VERSION = 2.10;
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
|||||||
+20
-14
@@ -102,24 +102,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
BezelNotification.show(messageText: "ReadyToReceive".localized(), icon: .receiveIcon)
|
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
|
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
|
NearbyConnectionManager.shared.connectionUpdateCallback = { isConnected in
|
||||||
if isConnected {
|
if isConnected {
|
||||||
self.statusItem?.button?.image = NSImage(named: "MenuBarIcon")
|
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) {
|
func windowWillClose(_ notification: Notification) {
|
||||||
if let window = notification.object as? NSWindow, window == welcomeWindow {
|
if let window = notification.object as? NSWindow, window == welcomeWindow {
|
||||||
log("Welcome window closed")
|
log("Welcome window closed")
|
||||||
@@ -221,6 +226,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
|
|
||||||
let welcomeView = WelcomeScreen(
|
let welcomeView = WelcomeScreen(
|
||||||
openIntroduction: openIntroduction,
|
openIntroduction: openIntroduction,
|
||||||
|
startReceiving: startReceiving,
|
||||||
openPlusScreen: openPlusScreen,
|
openPlusScreen: openPlusScreen,
|
||||||
openAppAdvertisementView: { self.openSheetView(type: .downloadAndroidApp) },
|
openAppAdvertisementView: { self.openSheetView(type: .downloadAndroidApp) },
|
||||||
openCableTransmissionView: { self.openSheetView(type: .downloadCableConnectionApp) },
|
openCableTransmissionView: { self.openSheetView(type: .downloadCableConnectionApp) },
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ struct IntroductionSplashView: View {
|
|||||||
@State private var pollingPage: IntroductionPage? = nil
|
@State private var pollingPage: IntroductionPage? = nil
|
||||||
@State private var skipAction: IntroductionPage.SkipAction? = nil
|
@State private var skipAction: IntroductionPage.SkipAction? = nil
|
||||||
|
|
||||||
|
let startReceiving: (() -> Void)
|
||||||
let onFinish: (() -> Void)
|
let onFinish: (() -> Void)
|
||||||
|
|
||||||
var body: some View {
|
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() {
|
private func advance() {
|
||||||
|
|
||||||
|
if currentPage == .localNetworkAccess {
|
||||||
|
triggerLocalNetworkPermission()
|
||||||
|
}
|
||||||
|
|
||||||
if let nextPage = currentPage.presentNextPage() {
|
if let nextPage = currentPage.presentNextPage() {
|
||||||
currentPage = nextPage
|
currentPage = nextPage
|
||||||
} else {
|
} else {
|
||||||
@@ -262,7 +277,6 @@ enum IntroductionPage: CaseIterable {
|
|||||||
case .noWifi:
|
case .noWifi:
|
||||||
return .localNetworkAccess
|
return .localNetworkAccess
|
||||||
case .localNetworkAccess:
|
case .localNetworkAccess:
|
||||||
DeviceToDeviceHeuristicScanner.shared.scan(completion: { _ in })
|
|
||||||
return .enableShareExtension
|
return .enableShareExtension
|
||||||
case .enableShareExtension:
|
case .enableShareExtension:
|
||||||
return .finished
|
return .finished
|
||||||
@@ -325,6 +339,6 @@ enum IntroductionPage: CaseIterable {
|
|||||||
|
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
IntroductionSplashView{}
|
IntroductionSplashView(startReceiving: {}){}
|
||||||
.frame(width: 600, height: 500)
|
.frame(width: 600, height: 500)
|
||||||
}
|
}
|
||||||
@@ -99,5 +99,5 @@ struct LargeAppIconView<Content: View>: View {
|
|||||||
|
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
WelcomeScreen(openIntroduction: false, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {})
|
WelcomeScreen(openIntroduction: false, startReceiving: {}, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {})
|
||||||
}
|
}
|
||||||
@@ -12,12 +12,14 @@ struct WelcomeScreen: View {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
openIntroduction: Bool,
|
openIntroduction: Bool,
|
||||||
|
startReceiving: @escaping () -> Void,
|
||||||
openPlusScreen: @escaping () -> Void,
|
openPlusScreen: @escaping () -> Void,
|
||||||
openAppAdvertisementView: @escaping () -> Void,
|
openAppAdvertisementView: @escaping () -> Void,
|
||||||
openCableTransmissionView: @escaping () -> Void,
|
openCableTransmissionView: @escaping () -> Void,
|
||||||
checkForNetworkIssues: @escaping () -> Void
|
checkForNetworkIssues: @escaping () -> Void
|
||||||
) {
|
) {
|
||||||
self._openedIntroduction = State(initialValue: openIntroduction)
|
self._openedIntroduction = State(initialValue: openIntroduction)
|
||||||
|
self.startReceiving = startReceiving
|
||||||
self.openPlusScreen = openPlusScreen
|
self.openPlusScreen = openPlusScreen
|
||||||
self.openAppAdvertisementView = openAppAdvertisementView
|
self.openAppAdvertisementView = openAppAdvertisementView
|
||||||
self.openCableTransmissionView = openCableTransmissionView
|
self.openCableTransmissionView = openCableTransmissionView
|
||||||
@@ -28,6 +30,7 @@ struct WelcomeScreen: View {
|
|||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
|
|
||||||
let openPlusScreen: () -> Void
|
let openPlusScreen: () -> Void
|
||||||
|
let startReceiving: () -> Void
|
||||||
let openAppAdvertisementView: () -> Void
|
let openAppAdvertisementView: () -> Void
|
||||||
let openCableTransmissionView: () -> Void
|
let openCableTransmissionView: () -> Void
|
||||||
let checkForNetworkIssues: () -> Void
|
let checkForNetworkIssues: () -> Void
|
||||||
@@ -45,7 +48,7 @@ struct WelcomeScreen: View {
|
|||||||
.resizable()
|
.resizable()
|
||||||
.ignoresSafeArea(.all)
|
.ignoresSafeArea(.all)
|
||||||
|
|
||||||
IntroductionSplashView {
|
IntroductionSplashView(startReceiving: startReceiving) {
|
||||||
openedIntroduction = false
|
openedIntroduction = false
|
||||||
}
|
}
|
||||||
.background(Color(NSColor.windowBackgroundColor))
|
.background(Color(NSColor.windowBackgroundColor))
|
||||||
@@ -239,5 +242,5 @@ enum Tabs: CaseIterable {
|
|||||||
|
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
WelcomeScreen(openIntroduction: true, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {})
|
WelcomeScreen(openIntroduction: true, startReceiving: {}, openPlusScreen: {}, openAppAdvertisementView: {}, openCableTransmissionView: {}, checkForNetworkIssues: {})
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user