diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 7ba7c07..7d3d62c 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -166,7 +166,7 @@ 69DA9A0E29E0BF5100A442DA /* QuickDrop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuickDrop.app; sourceTree = BUILT_PRODUCTS_DIR; }; 69DA9A1129E0BF5100A442DA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 69DA9A1329E0BF5200A442DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 69DA9A1829E0BF5200A442DA /* NearDrop.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NearDrop.entitlements; sourceTree = ""; }; + 69DA9A1829E0BF5200A442DA /* QuickDrop.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = QuickDrop.entitlements; sourceTree = ""; }; 69DA9A1E29E0C0B300A442DA /* NearbyConnectionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearbyConnectionManager.swift; sourceTree = ""; }; 69DA9A2029E0CC4E00A442DA /* Data+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Extensions.swift"; sourceTree = ""; }; 69DA9A2229E17F0400A442DA /* InboundNearbyConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboundNearbyConnection.swift; sourceTree = ""; }; @@ -330,7 +330,7 @@ 69DA9A1329E0BF5200A442DA /* Assets.xcassets */, 69D2C33629E78DF400EC7E30 /* Localizable.stringsdict */, 69D2C32B29E77F2200EC7E30 /* Localizable.strings */, - 69DA9A1829E0BF5200A442DA /* NearDrop.entitlements */, + 69DA9A1829E0BF5200A442DA /* QuickDrop.entitlements */, 69D2C32E29E7898C00EC7E30 /* MainMenu.xib */, ); path = QuickDrop; @@ -825,8 +825,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 36; - SHARED_VERSION = 1.8; + SHARED_BUILD = 37; + SHARED_VERSION = 1.9; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; @@ -884,8 +884,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 36; - SHARED_VERSION = 1.8; + SHARED_BUILD = 37; + SHARED_VERSION = 1.9; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; }; @@ -897,7 +897,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = NearDrop/NearDrop.entitlements; + CODE_SIGN_ENTITLEMENTS = QuickDrop/QuickDrop.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; @@ -907,7 +907,7 @@ DEVELOPMENT_TEAM = 92SDAWLN76; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = NearDrop/Info.plist; + INFOPLIST_FILE = QuickDrop/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = QuickDrop; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; INFOPLIST_KEY_LSUIElement = YES; @@ -936,7 +936,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = NearDrop/NearDrop.entitlements; + CODE_SIGN_ENTITLEMENTS = QuickDrop/QuickDrop.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; @@ -946,7 +946,7 @@ DEVELOPMENT_TEAM = 92SDAWLN76; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = NearDrop/Info.plist; + INFOPLIST_FILE = QuickDrop/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = QuickDrop; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; INFOPLIST_KEY_LSUIElement = YES; diff --git a/QuickDrop/AppDelegate.swift b/QuickDrop/AppDelegate.swift index 67c798c..fbaf989 100644 --- a/QuickDrop/AppDelegate.swift +++ b/QuickDrop/AppDelegate.swift @@ -28,11 +28,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele private var iapManager: IAPManager? var showsFirewallAlert = false + var visibleItem: NSMenuItem? = nil + let hasConnectionMonitor = NWPathMonitor() func applicationDidFinishLaunching(_: Notification) { let menu = NSMenu() - menu.addItem(withTitle: NSLocalizedString("VisibleToEveryone", value: "Visible to everyone", comment: ""), action: nil, keyEquivalent: "") + let visibleItem = NSMenuItem( + title: "VisibleToEveryone".localized(), + action: nil, + keyEquivalent: "" + ) + self.visibleItem = visibleItem + menu.addItem(visibleItem) + menu.addItem(withTitle: String(format: NSLocalizedString("DeviceName", value: "Device name: %@", comment: ""), arguments: [Host.current().localizedName ?? "Mac"]), action: nil, keyEquivalent: "") menu.addItem(NSMenuItem.separator()) @@ -108,6 +117,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele let queue = DispatchQueue(label: "NetworkMonitor") monitor.start(queue: queue) + + hasConnectionMonitor.pathUpdateHandler = { path in + DispatchQueue.main.async { + if path.status == .satisfied { + self.statusItem?.button?.image = NSImage(named: "MenuBarIcon") + self.visibleItem?.title = "VisibleToEveryone".localized() + } else { + self.statusItem?.button?.image = NSImage(named: "MenuBarIconSlash") + self.visibleItem?.title = "NoNetworkConnection".localized() + } + } + } + + let queue2 = DispatchQueue(label: "NetworkConnectionMonitor") + hasConnectionMonitor.start(queue: queue2) } func performDeviceToDeviceCheck() { diff --git a/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/Contents.json b/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/Contents.json new file mode 100644 index 0000000..5d0b42b --- /dev/null +++ b/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "filename" : "menubar1x.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "menubar2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/menubar1x.png b/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/menubar1x.png new file mode 100644 index 0000000..a69261e Binary files /dev/null and b/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/menubar1x.png differ diff --git a/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/menubar2x.png b/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/menubar2x.png new file mode 100644 index 0000000..63a99e4 Binary files /dev/null and b/QuickDrop/Assets.xcassets/MenuBarIconSlash.imageset/menubar2x.png differ diff --git a/QuickDrop/Base.lproj/Localizable.strings b/QuickDrop/Base.lproj/Localizable.strings index 67aaff4..42d1b5e 100644 --- a/QuickDrop/Base.lproj/Localizable.strings +++ b/QuickDrop/Base.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Visible to everyone"; +"NoNetworkConnection" = "No Network Connection"; "WelcomeToQuickDrop" = "Welcome to QuickDrop"; diff --git a/QuickDrop/NearDrop.entitlements b/QuickDrop/QuickDrop.entitlements similarity index 100% rename from QuickDrop/NearDrop.entitlements rename to QuickDrop/QuickDrop.entitlements diff --git a/QuickDrop/ar.lproj/Localizable.strings b/QuickDrop/ar.lproj/Localizable.strings index 81cae06..78e6198 100644 --- a/QuickDrop/ar.lproj/Localizable.strings +++ b/QuickDrop/ar.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "مرئي للجميع"; +"NoNetworkConnection" = "لا يوجد اتصال بالشبكة"; "RecommendedApps" = "التطبيقات الموصى بها"; "GetSupport" = "الدعم"; diff --git a/QuickDrop/de.lproj/Localizable.strings b/QuickDrop/de.lproj/Localizable.strings index 8735759..9a481fa 100644 --- a/QuickDrop/de.lproj/Localizable.strings +++ b/QuickDrop/de.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Für alle sichtbar"; +"NoNetworkConnection" = "Keine Netzwerkverbindung"; "RecommendedApps" = "Empfohlene Apps"; "GetSupport" = "Support"; diff --git a/QuickDrop/es.lproj/Localizable.strings b/QuickDrop/es.lproj/Localizable.strings index 4077a44..41b8d2d 100644 --- a/QuickDrop/es.lproj/Localizable.strings +++ b/QuickDrop/es.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Visible para todos"; +"NoNetworkConnection" = "Sin conexión de red"; "RecommendedApps" = "Apps recomendadas"; "GetSupport" = "Soporte"; diff --git a/QuickDrop/fr.lproj/Localizable.strings b/QuickDrop/fr.lproj/Localizable.strings index 42b9a06..d7ff2f2 100644 --- a/QuickDrop/fr.lproj/Localizable.strings +++ b/QuickDrop/fr.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Visible par tout le monde"; +"NoNetworkConnection" = "Pas de connexion réseau"; "RecommendedApps" = "Applications recommandées"; "GetSupport" = "Support"; diff --git a/QuickDrop/hu.lproj/Localizable.strings b/QuickDrop/hu.lproj/Localizable.strings index 7472694..277e74a 100644 --- a/QuickDrop/hu.lproj/Localizable.strings +++ b/QuickDrop/hu.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Mindenki számára felfedezhető"; +"NoNetworkConnection" = "Nincs hálózati kapcsolat"; "RecommendedApps" = "Ajánlott alkalmazások"; "GetSupport" = "Támogatás"; diff --git a/QuickDrop/it.lproj/Localizable.strings b/QuickDrop/it.lproj/Localizable.strings index a5c2df7..13eabed 100644 --- a/QuickDrop/it.lproj/Localizable.strings +++ b/QuickDrop/it.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Visibile a tutti"; +"NoNetworkConnection" = "Nessuna connessione di rete"; "RecommendedApps" = "App consigliate"; "GetSupport" = "Supporto"; diff --git a/QuickDrop/ja.lproj/Localizable.strings b/QuickDrop/ja.lproj/Localizable.strings index 91380ab..2416ee4 100644 --- a/QuickDrop/ja.lproj/Localizable.strings +++ b/QuickDrop/ja.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "すべてのユーザーに公開"; +"NoNetworkConnection" = "ネットワークに接続されていません"; "RecommendedApps" = "おすすめアプリ"; "GetSupport" = "サポート"; diff --git a/QuickDrop/ko.lproj/Localizable.strings b/QuickDrop/ko.lproj/Localizable.strings index ee29292..a45cef4 100644 --- a/QuickDrop/ko.lproj/Localizable.strings +++ b/QuickDrop/ko.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "모든 사용자에게 공개"; +"NoNetworkConnection" = "네트워크에 연결되어 있지 않습니다"; "RecommendedApps" = "추천 앱"; "GetSupport" = "지원"; diff --git a/QuickDrop/nl.lproj/Localizable.strings b/QuickDrop/nl.lproj/Localizable.strings index 998e69d..682836c 100644 --- a/QuickDrop/nl.lproj/Localizable.strings +++ b/QuickDrop/nl.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Zichtbaar voor iedereen"; +"NoNetworkConnection" = "Geen netwerkverbinding"; "RecommendedApps" = "Aanbevolen apps"; "GetSupport" = "Ondersteuning"; diff --git a/QuickDrop/pt-BR.lproj/Localizable.strings b/QuickDrop/pt-BR.lproj/Localizable.strings index 1239c23..4762aa3 100644 --- a/QuickDrop/pt-BR.lproj/Localizable.strings +++ b/QuickDrop/pt-BR.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Visível para todos"; +"NoNetworkConnection" = "Sem conexão com a rede"; "RecommendedApps" = "Apps recomendados"; "GetSupport" = "Suporte"; diff --git a/QuickDrop/pt-PT.lproj/Localizable.strings b/QuickDrop/pt-PT.lproj/Localizable.strings index 8bedd9d..44489cf 100644 --- a/QuickDrop/pt-PT.lproj/Localizable.strings +++ b/QuickDrop/pt-PT.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Visível para todos"; +"NoNetworkConnection" = "Sem ligação de rede"; "RecommendedApps" = "Aplicativos recomendados"; "GetSupport" = "Suporte"; diff --git a/QuickDrop/ro.lproj/Localizable.strings b/QuickDrop/ro.lproj/Localizable.strings index 36af03e..585326b 100644 --- a/QuickDrop/ro.lproj/Localizable.strings +++ b/QuickDrop/ro.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Vizibil pentru toată lumea"; +"NoNetworkConnection" = "Nicio conexiune la rețea"; "RecommendedApps" = "Aplicații recomandate"; "GetSupport" = "Suport"; diff --git a/QuickDrop/ru.lproj/Localizable.strings b/QuickDrop/ru.lproj/Localizable.strings index 58e6f8b..0e3983d 100644 --- a/QuickDrop/ru.lproj/Localizable.strings +++ b/QuickDrop/ru.lproj/Localizable.strings @@ -38,6 +38,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Видимость: все"; +"NoNetworkConnection" = "Нет сетевого подключения"; /* No comment provided by engineer. */ "NotificationsDenied.Message" = "QuickDrop необходима возможность показывать уведомления о входящих файлах. Пожалуйста, разрешите уведомления в Системных настройках."; diff --git a/QuickDrop/th.lproj/Localizable.strings b/QuickDrop/th.lproj/Localizable.strings index 7ba1aae..e68bae8 100644 --- a/QuickDrop/th.lproj/Localizable.strings +++ b/QuickDrop/th.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "เปิดเผยต่อทุกคน"; +"NoNetworkConnection" = "ไม่มีการเชื่อมต่อเครือข่าย"; "RecommendedApps" = "แอปแนะนำ"; "GetSupport" = "การสนับสนุน"; diff --git a/QuickDrop/uk.lproj/Localizable.strings b/QuickDrop/uk.lproj/Localizable.strings index 8970e03..a571957 100644 --- a/QuickDrop/uk.lproj/Localizable.strings +++ b/QuickDrop/uk.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "Видимість: для всіх"; +"NoNetworkConnection" = "Немає мережевого підключення"; "RecommendedApps" = "Рекомендовані додатки"; "GetSupport" = "Підтримка"; diff --git a/QuickDrop/zh-Hans.lproj/Localizable.strings b/QuickDrop/zh-Hans.lproj/Localizable.strings index 216b7d2..fbf9e99 100644 --- a/QuickDrop/zh-Hans.lproj/Localizable.strings +++ b/QuickDrop/zh-Hans.lproj/Localizable.strings @@ -47,6 +47,7 @@ /* No comment provided by engineer. */ "VisibleToEveryone" = "对所有人可见"; +"NoNetworkConnection" = "无网络连接"; "RecommendedApps" = "推荐应用"; "GetSupport" = "支持";