Skip to content

Commit

Permalink
Track info shown in two lines. Different icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosefonseca committed Mar 26, 2020
1 parent 95746d6 commit 6812826
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 20 deletions.
18 changes: 14 additions & 4 deletions Statusfy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@
LastUpgradeCheck = 1130;
ORGANIZATIONNAME = "Paul Young";
TargetAttributes = {
2C87974B18FF06E600AE2A45 = {
DevelopmentTeam = VF8BTMF3F4;
ProvisioningStyle = Automatic;
};
2C87976C18FF06E600AE2A45 = {
TestTargetID = 2C87974B18FF06E600AE2A45;
};
Expand Down Expand Up @@ -434,14 +438,17 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = VF8BTMF3F4;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Statusfy/Statusfy-Prefix.pch";
INFOPLIST_FILE = "Statusfy/Statusfy-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_BUNDLE_IDENTIFIER = "me.paulyoung.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_BUNDLE_IDENTIFIER = com.carlosefonseca.Statusfy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand All @@ -450,14 +457,17 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = VF8BTMF3F4;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Statusfy/Statusfy-Prefix.pch";
INFOPLIST_FILE = "Statusfy/Statusfy-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_BUNDLE_IDENTIFIER = "me.paulyoung.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_BUNDLE_IDENTIFIER = com.carlosefonseca.Statusfy;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
6 changes: 6 additions & 0 deletions Statusfy/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
16 changes: 16 additions & 0 deletions Statusfy/Images.xcassets/Pause.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "Pause.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file added Statusfy/Images.xcassets/Pause.imageset/Pause.pdf
Binary file not shown.
16 changes: 16 additions & 0 deletions Statusfy/Images.xcassets/Play.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "Play_1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file added Statusfy/Images.xcassets/Play.imageset/Play_1.pdf
Binary file not shown.
28 changes: 13 additions & 15 deletions Statusfy/SFYAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ - (void)setStatusItemTitle
NSString *artistName = [[self executeAppleScript:@"get artist of current track"] stringValue];

if (trackName && artistName) {
NSString *titleText = [NSString stringWithFormat:@"%@ - %@", trackName, artistName];
NSString *titleText = [NSString stringWithFormat:@"%@\n%@", trackName, artistName];

NSAttributedString * attributtedTitleText = [[NSAttributedString alloc] initWithString:titleText
attributes:@{
NSFontAttributeName:[NSFont systemFontOfSize:10],
}];

if ([self getPlayerStateVisibility]) {
NSString *playerState = [self determinePlayerStateText];
titleText = [NSString stringWithFormat:@"%@ %@", playerState, titleText];
self.statusItem.image = [self determinePlayerStateImage];
}

self.statusItem.image = nil;
self.statusItem.title = titleText;

self.statusItem.attributedTitle = attributtedTitleText;
}
else {
NSImage *image = [NSImage imageNamed:@"status_icon"];
Expand Down Expand Up @@ -108,22 +111,17 @@ - (NSString *)determinePlayerStateMenuItemTitle
return [self getPlayerStateVisibility] ? NSLocalizedString(@"Hide Player State", nil) : NSLocalizedString(@"Show Player State", nil);
}

- (NSString *)determinePlayerStateText
{
NSString *playerStateText = nil;
- (NSImage *)determinePlayerStateImage {
NSString *playerStateConstant = [[self executeAppleScript:@"get player state"] stringValue];

if ([playerStateConstant isEqualToString:@"kPSP"]) {
playerStateText = NSLocalizedString(@"\u25B6", nil);
return [NSImage imageNamed:@"Play"];
}
else if ([playerStateConstant isEqualToString:@"kPSp"]) {
playerStateText = NSLocalizedString(@"❙ ❙", nil);
return [NSImage imageNamed:@"Pause"];
}
else {
playerStateText = NSLocalizedString(@"\u25FB\uFE0F", nil);
return nil;
}

return playerStateText;
}

#pragma mark - Toggle Dock Icon
Expand Down
2 changes: 1 addition & 1 deletion Statusfy/Statusfy-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>me.paulyoung.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down

0 comments on commit 6812826

Please sign in to comment.