Skip to content

Commit

Permalink
Added setActivationPolicy
Browse files Browse the repository at this point in the history
Set to accessory.
  • Loading branch information
boberito committed Sep 19, 2024
1 parent 3aefa55 commit 1a220e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions Air Drop Assistant/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, DataModelDelegate, PrefDataM
let updater = UpdateCheck()
let prefViewController = PreferencesViewController()

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
// Ensure that the app doesn't show the menu bar or Dock icon when reopened
NSApp.setActivationPolicy(.accessory)
return false
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
NSLog("ADA Launched")

NSApp.setActivationPolicy(.accessory)
if isAppAlreadyRunning() {
NSApp.terminate(nil)
}
let appService = SMAppService.agent(plistName: "com.ttinc.Air-Drop-Assistant.plist")
if CommandLine.arguments.count > 1 {
if airDropManagedDisabled() {
Expand Down Expand Up @@ -86,9 +94,6 @@ AirDrop is disabled by an MDM Profile. Please contact your MDM administrator.
alert.runModal()
NSApp.terminate(nil)
}
if isAppAlreadyRunning() {
NSApp.terminate(nil)
}

if UserDefaults.standard.bool(forKey: "afterFirstLaunch") == false && appService.status != .enabled {

Expand Down
6 changes: 3 additions & 3 deletions Air Drop Assistant/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<!--Application-->
<scene sceneID="JPo-4y-FX3">
<objects>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Air_Drop_Assistant" customModuleProvider="target"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
Expand Down Expand Up @@ -674,9 +677,6 @@
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Air_Drop_Assistant" customModuleProvider="target"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="0.0"/>
</scene>
Expand Down

0 comments on commit 1a220e2

Please sign in to comment.