Skip to content

Commit

Permalink
Merge pull request #59 from GetToSet/ethanwong/icon-style
Browse files Browse the repository at this point in the history
Allow choosing the app’s icon style in preferences.
  • Loading branch information
dyerc authored Mar 11, 2022
2 parents 3584c53 + e70397d commit 64e1050
Show file tree
Hide file tree
Showing 36 changed files with 227 additions and 75 deletions.
Binary file modified Assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/icon.sketch
Binary file not shown.
28 changes: 28 additions & 0 deletions Doughnut.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
6B3A75F8278F44F500F25578 /* NSView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B3A75F7278F44F500F25578 /* NSView+Extensions.swift */; };
6B94DF4C278968F500BCB149 /* NSTableView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B94DF4B278968F500BCB149 /* NSTableView+Extensions.swift */; };
6B9C30BB27B5708300D462BE /* BaseTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B9C30BA27B5708300D462BE /* BaseTableView.swift */; };
6B9E154727C9EA5F00C919D5 /* AppIcon_Big_Sur.icns in Resources */ = {isa = PBXBuildFile; fileRef = 6B9E154627C9EA5F00C919D5 /* AppIcon_Big_Sur.icns */; };
6BA21C4F279D690700CD3672 /* WindowController+Toolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BA21C4E279D690700CD3672 /* WindowController+Toolbar.swift */; };
6BB5771E278602B400DFF99F /* MainMenu.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6BB5771C278602B400DFF99F /* MainMenu.storyboard */; };
6BC6395F27A6800500535897 /* Player+RemoteCommandCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6BC6395E27A6800500535897 /* Player+RemoteCommandCenter.swift */; };
Expand Down Expand Up @@ -105,6 +106,7 @@
6B730B732767A90900FB5F84 /* Doughnut-Release.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Doughnut-Release.entitlements"; sourceTree = "<group>"; };
6B94DF4B278968F500BCB149 /* NSTableView+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSTableView+Extensions.swift"; sourceTree = "<group>"; };
6B9C30BA27B5708300D462BE /* BaseTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTableView.swift; sourceTree = "<group>"; };
6B9E154627C9EA5F00C919D5 /* AppIcon_Big_Sur.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon_Big_Sur.icns; sourceTree = "<group>"; };
6BA21C4E279D690700CD3672 /* WindowController+Toolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WindowController+Toolbar.swift"; sourceTree = "<group>"; };
6BB5771D278602B400DFF99F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainMenu.storyboard; sourceTree = "<group>"; };
6BC6395E27A6800500535897 /* Player+RemoteCommandCenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Player+RemoteCommandCenter.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -306,6 +308,8 @@
83235C0A200947F200BC356F /* Resources */ = {
isa = PBXGroup;
children = (
6B9E154627C9EA5F00C919D5 /* AppIcon_Big_Sur.icns */,
83235C0B2009481200BC356F /* dsa_pub.pem */,
);
path = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -478,6 +482,7 @@
838257C71F759F6F00DB4FD1 /* Frameworks */,
83D454AE200BFDD50078CA3D /* Bump Build Number */,
838257C81F759F6F00DB4FD1 /* Resources */,
6B339CC727C9F1BD00181204 /* Remove Custom Bundle Icon */,
4811B8B252A5287D2295B6A8 /* [CP] Embed Pods Frameworks */,
433D2BC19A40DB2041D544F1 /* [CP] Copy Pods Resources */,
6B3ACC992773569D00CF1EF1 /* Run SwiftLint */,
Expand Down Expand Up @@ -598,6 +603,8 @@
6BB5771E278602B400DFF99F /* MainMenu.storyboard in Resources */,
6BF126D12780727100D840A4 /* EpisodeInfo.storyboard in Resources */,
831EBADA27CC120000F212B4 /* Credits.rtf in Resources */,
6B9E154727C9EA5F00C919D5 /* AppIcon_Big_Sur.icns in Resources */,
83235C0C2009481400BC356F /* dsa_pub.pem in Resources */,
838257D51F759F6F00DB4FD1 /* Main.storyboard in Resources */,
83235C0D2009502D00BC356F /* Preferences.storyboard in Resources */,
6BF126D32780742600D840A4 /* PodcastInfo.storyboard in Resources */,
Expand Down Expand Up @@ -678,6 +685,24 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
6B339CC727C9F1BD00181204 /* Remove Custom Bundle Icon */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Remove Custom Bundle Icon";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -x\n\nPRODUCT_PATH=${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\n\nxattr -d 'com.apple.FinderInfo' \"${PRODUCT_PATH}\"\nfind \"${PRODUCT_PATH}\" -maxdepth 1 -type f -name 'Icon?' -print -delete\n";
};
6B3ACC992773569D00CF1EF1 /* Run SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -923,6 +948,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F42DD5B957A39D2CA878BEA8 /* Pods-Doughnut.test.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Doughnut/Doughnut-Debug.entitlements";
COMBINE_HIDPI_IMAGES = YES;
Expand Down Expand Up @@ -1106,6 +1132,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 5E1DC050EEE121FD033C44DF /* Pods-Doughnut.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Doughnut/Doughnut-Debug.entitlements";
COMBINE_HIDPI_IMAGES = YES;
Expand All @@ -1128,6 +1155,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BA7A57F62DAF0A2C3DA2C7AF /* Pods-Doughnut.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Doughnut/Doughnut-Release.entitlements";
COMBINE_HIDPI_IMAGES = YES;
Expand Down
31 changes: 31 additions & 0 deletions Doughnut/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

UserDefaults.standard.register(defaults: Preference.defaultPreference)

UserDefaults.standard.addObserver(self, forKeyPath: Preference.Key.appIconStyle.rawValue, options: [], context: nil)

/*do {
try Player.audioOutputDevices()
} catch {}*/
Expand Down Expand Up @@ -81,13 +83,42 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
return menu
}

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
switch keyPath {
case Preference.Key.appIconStyle.rawValue?:
updateAppIcon()
default:
return
}
}

private func createAndShowMainWindow() {
if mainWindowController == nil {
mainWindowController = NSStoryboard(name: "Main", bundle: nil).instantiateInitialController()
}
mainWindowController?.showWindow(self)
}

private func updateAppIcon() {
guard let iconStyle = Preference.AppIconStyle(rawValue: Preference.integer(for: Preference.Key.appIconStyle)) else {
return
}

let bundlePath = Bundle.main.bundlePath

switch iconStyle {
case .catalina:
// Setting applicationIconImage to nil won't clear the icon if custom icon is set
let iconImage = NSImage(named: "AppIcon")
NSApp.applicationIconImage = iconImage
NSWorkspace.shared.setIcon(nil, forFile: bundlePath, options: [])
case .bigSur:
let iconImage = NSImage(named: "AppIcon_Big_Sur")
NSApp.applicationIconImage = iconImage
NSWorkspace.shared.setIcon(iconImage, forFile: bundlePath, options: [])
}
}

@IBAction func showPreferences(_ sender: AnyObject) {
preferencesWindowController.showWindow(self)
}
Expand Down
68 changes: 68 additions & 0 deletions Doughnut/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "Icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "Icon_32x32-1.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "Icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "Icon_64x64.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "Icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "Icon_256x256-1.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "Icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "Icon_512x512-1.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "Icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "Icon_1024x1024.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 0 additions & 68 deletions Doughnut/Assets.xcassets/AppIcon.iconset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file removed Doughnut/Assets.xcassets/AppIcon.iconset/icon_16x16.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions Doughnut/Assets.xcassets/PrefAppIcon/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"provides-namespace" : true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "Icon_Big_Sur.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "Icon_Catalina.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Doughnut/Preference/Preference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Preference {
static let episodeSortDirection = Key("episodeSortDirection")

// General
static let appIconStyle = Key("appIconStyle")
static let showDockBadge = Key("showDockBadge")

// Library
Expand All @@ -51,6 +52,11 @@ class Preference {
static let replayAfterPause = Key("replayAfterPause")
}

enum AppIconStyle: Int {
case catalina = 0
case bigSur = 1
}

static let kLibraryPath = "LibraryPath"
static let kVolume = "Volume"

Expand Down
Loading

0 comments on commit 64e1050

Please sign in to comment.