diff --git a/Clocker.xcodeproj/project.pbxproj b/Clocker.xcodeproj/project.pbxproj index 9aca7fe..df9cbbd 100755 --- a/Clocker.xcodeproj/project.pbxproj +++ b/Clocker.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 9A4379281BEC223900F4E27F /* Crashlytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A4379241BEC223900F4E27F /* Crashlytics.framework */; settings = {ASSET_TAGS = (); }; }; 9A43792A1BEC230A00F4E27F /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A4379291BEC230A00F4E27F /* libc++.tbd */; }; 9A43792C1BEC231100F4E27F /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A43792B1BEC231100F4E27F /* libz.tbd */; }; + 9A43792E1BEC256200F4E27F /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9A43792D1BEC256200F4E27F /* Media.xcassets */; settings = {ASSET_TAGS = (); }; }; 9A8605AE1BEC148400A810A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A8605AD1BEC148400A810A4 /* main.m */; }; 9A8605B31BEC14A600A810A4 /* ColoredButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A8605B21BEC14A600A810A4 /* ColoredButton.m */; }; 9A8605B61BEC14BE00A810A4 /* MenubarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A8605B41BEC14BE00A810A4 /* MenubarController.m */; }; @@ -23,7 +24,6 @@ 9A8605C01BEC14F600A810A4 /* Panel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A8605BD1BEC14F600A810A4 /* Panel.m */; }; 9A8605C11BEC14F600A810A4 /* PreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A8605BE1BEC14F600A810A4 /* PreferencesWindowController.m */; }; 9A8605D41BEC155B00A810A4 /* Clock.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 9A8605C21BEC155B00A810A4 /* Clock.jpeg */; settings = {ASSET_TAGS = (); }; }; - 9A8605D51BEC155B00A810A4 /* Clocker-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9A8605C31BEC155B00A810A4 /* Clocker-Info.plist */; settings = {ASSET_TAGS = (); }; }; 9A8605D61BEC155B00A810A4 /* Panel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A8605CD1BEC155B00A810A4 /* Panel.xib */; settings = {ASSET_TAGS = (); }; }; 9A8605D71BEC155B00A810A4 /* PreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A8605CE1BEC155B00A810A4 /* PreferencesWindow.xib */; settings = {ASSET_TAGS = (); }; }; 9A8605D81BEC155B00A810A4 /* PowerIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 9A8605CF1BEC155B00A810A4 /* PowerIcon.png */; settings = {ASSET_TAGS = (); }; }; @@ -42,6 +42,7 @@ 9A4379241BEC223900F4E27F /* Crashlytics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Crashlytics.framework; sourceTree = ""; }; 9A4379291BEC230A00F4E27F /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; 9A43792B1BEC231100F4E27F /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; + 9A43792D1BEC256200F4E27F /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; 9A8605AD1BEC148400A810A4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Clocker/main.m; sourceTree = ""; }; 9A8605B21BEC14A600A810A4 /* ColoredButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ColoredButton.m; path = Clocker/ColoredButton.m; sourceTree = ""; }; 9A8605B41BEC14BE00A810A4 /* MenubarController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MenubarController.m; path = Clocker/MenubarController.m; sourceTree = ""; }; @@ -168,6 +169,7 @@ DD4F7BF913C30F9F00825C6E = { isa = PBXGroup; children = ( + 9A43792D1BEC256200F4E27F /* Media.xcassets */, 9A8605E01BEC15F400A810A4 /* XIB */, 9A8605E11BEC160700A810A4 /* Images */, 9A8605E41BEC164C00A810A4 /* Main */, @@ -255,11 +257,11 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 9A8605D51BEC155B00A810A4 /* Clocker-Info.plist in Resources */, 9A8605D71BEC155B00A810A4 /* PreferencesWindow.xib in Resources */, 9A8605DF1BEC15C400A810A4 /* MainMenu.xib in Resources */, 9A8605D91BEC155B00A810A4 /* Status.png in Resources */, 9A8605D61BEC155B00A810A4 /* Panel.xib in Resources */, + 9A43792E1BEC256200F4E27F /* Media.xcassets in Resources */, 9A8605D41BEC155B00A810A4 /* Clock.jpeg in Resources */, 9A8605DC1BEC155B00A810A4 /* StatusHighlighted@2x.png in Resources */, 9A8605DA1BEC155B00A810A4 /* Status@2x.png in Resources */, @@ -390,6 +392,7 @@ buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", diff --git a/Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate b/Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate index 2bc2d3d..3b8c60a 100644 Binary files a/Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate and b/Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Clocker/ApplicationDelegate.m b/Clocker/ApplicationDelegate.m index 18deced..dd43055 100755 --- a/Clocker/ApplicationDelegate.m +++ b/Clocker/ApplicationDelegate.m @@ -59,6 +59,34 @@ void *kContextActivePanel = &kContextActivePanel; - (void)applicationDidFinishLaunching:(NSNotification *)notification { + + if ([[NSUserDefaults standardUserDefaults] objectForKey:@"noOfLaunches"] == nil) + { + NSNumber *numberOfLaunches = @1; + [[NSUserDefaults standardUserDefaults] setObject:numberOfLaunches forKey:@"noOfLaunches"]; + } + else + { + //Check the number of times app has been launched. + + NSNumber *numberOfLaunches = [[NSUserDefaults standardUserDefaults] objectForKey:@"noOfLaunches"]; + NSInteger launches = numberOfLaunches.integerValue; + launches++; + numberOfLaunches = [NSNumber numberWithInteger:launches]; + [[NSUserDefaults standardUserDefaults] setObject:numberOfLaunches forKey:@"noOfLaunches"]; + + if (numberOfLaunches.integerValue == 5) + { + NSAlert *reviewAlert = [[NSAlert alloc] init]; + reviewAlert.alertStyle = NSInformationalAlertStyle; + reviewAlert.messageText = @"Spead the word, maybe?"; + reviewAlert.informativeText = @"Clocker is completely open source. If it has helped you in any way, please leave a kind review on the App Store!"; + [reviewAlert addButtonWithTitle:@"Cancel"]; + [reviewAlert runModal]; + + } + } + // Install icon into the menu bar self.menubarController = [[MenubarController alloc] init]; diff --git a/Clocker/ColoredButton.m b/Clocker/ColoredButton.m index b34f95e..1bfd825 100644 --- a/Clocker/ColoredButton.m +++ b/Clocker/ColoredButton.m @@ -36,14 +36,13 @@ - (void)setButtonTitleFor:(NSButton*)button toString:(NSString*)title withColor:(NSColor*)color { - NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; - [style setAlignment:NSLeftTextAlignment]; - NSFont *font = [NSFont fontWithName:@"HelveticaNeue-Light" size:13.0]; - NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:color, NSForegroundColorAttributeName, style, NSParagraphStyleAttributeName, font,NSFontAttributeName, nil]; + + NSFont *font = [NSFont fontWithName:@"HelveticaNeue-Light" size:12.0]; + NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:color, NSForegroundColorAttributeName, font,NSFontAttributeName, nil]; NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc]initWithString:title attributes:attrsDictionary]; - [attrString setAlignment:NSTextAlignmentLeft range:NSMakeRange(0, self.title.length)]; + [button setAttributedTitle:attrString]; @@ -53,6 +52,7 @@ { NSString *title = self.title; NSColor *color = [NSColor blackColor]; + self.imagePosition = NSImageLeft; [self setButtonTitleFor:self toString:title withColor:color]; } diff --git a/Clocker/PanelController.m b/Clocker/PanelController.m index 6838328..e22d5c6 100755 --- a/Clocker/PanelController.m +++ b/Clocker/PanelController.m @@ -98,13 +98,7 @@ } - if (self.defaultPreferences.count <= 10) { - self.scrollViewHeight.constant = self.window.contentView.frame.size.height; - } - else - { - self.scrollViewHeight.constant = 550; - } + self.scrollViewHeight.constant = self.defaultPreferences.count*55 + 30; } #pragma mark - Public accessors @@ -204,14 +198,7 @@ NSRect panelRect = [panel frame]; panelRect.size.width = PANEL_WIDTH; - if (self.defaultPreferences.count <= 10) - { - panelRect.size.height = self.defaultPreferences.count*55 + 30; - } - else - { - panelRect.size.height = 500; - } + panelRect.size.height = self.defaultPreferences.count*55 + 30; panelRect.origin.x = roundf(NSMidX(statusRect) - NSWidth(panelRect) / 2); panelRect.origin.y = NSMaxY(statusRect) - NSHeight(panelRect); diff --git a/Clocker/PreferencesWindow.xib b/Clocker/PreferencesWindow.xib index c05b06a..f1fcd6d 100644 --- a/Clocker/PreferencesWindow.xib +++ b/Clocker/PreferencesWindow.xib @@ -9,6 +9,8 @@ + + @@ -20,15 +22,15 @@ - + - + - + - + - + @@ -108,11 +110,11 @@ - - + + - + + + - - + + - + - + - + + - + diff --git a/Clocker/PreferencesWindowController.m b/Clocker/PreferencesWindowController.m index dc3e510..02e94c6 100644 --- a/Clocker/PreferencesWindowController.m +++ b/Clocker/PreferencesWindowController.m @@ -45,6 +45,8 @@ @property (weak) IBOutlet NSButton *is24HourFormatSelected; @property (weak) IBOutlet NSTextField *messageLabel; +@property (weak) IBOutlet NSTextField *openSourceMessage; +@property (weak) IBOutlet NSButton *reportBug; @end @@ -55,6 +57,17 @@ static PreferencesWindowController *sharedPreferences = nil; - (void)windowDidLoad { [super windowDidLoad]; + [self.openSourceMessage setAllowsEditingTextAttributes: YES]; + [self.openSourceMessage setSelectable:YES]; + NSString *credits = @"Clocker v1.0 is open source. You can find the source code here!"; + [self.openSourceMessage setAttributedStringValue:[self stringFromHTML:credits withFont:[self.openSourceMessage font]]]; + + NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc]initWithString:@"Report Bug!x"]; + [attrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0, attrString.length)]; + [attrString addAttribute:NSForegroundColorAttributeName value:[NSColor blueColor] range:NSMakeRange(0, self.reportBug.title.length)]; + [self.reportBug setAttributedStringValue:attrString]; + + NSMutableArray *defaultTimeZones = [[NSUserDefaults standardUserDefaults] objectForKey:@"defaultPreferences"]; if (!self.timeZoneArray || !self.selectedTimeZones) @@ -77,6 +90,14 @@ static PreferencesWindowController *sharedPreferences = nil; // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. } +-(NSAttributedString *)stringFromHTML:(NSString *)html withFont:(NSFont *)font +{ + html = [NSString stringWithFormat:@"%@", [font fontName], (int)[font pointSize], html]; + NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding]; + NSAttributedString* string = [[NSAttributedString alloc] initWithHTML:data documentAttributes:nil]; + return string; +} + -(id)copyWithZone:(NSZone *)zone { id copy = [[[self class] alloc] initWithWindowNibName:@"PreferencesWindow"]; @@ -409,4 +430,15 @@ static PreferencesWindowController *sharedPreferences = nil; } } +- (IBAction)supportAction:(id)sender +{ + NSAppleScript *mailScript; + NSString *scriptString= @"tell application \"Mail\"\nset theAddress to \"abhishekbanthia@me.com\"\n set msg to make new outgoing message with properties {visible:true, subject:\"Regarding Clocker - We need to talk!\"}\ntell msg to make new to recipient at end of every to recipient with properties {address:theAddress}\n activate\nend tell"; + mailScript = [[NSAppleScript alloc] initWithSource:scriptString]; + NSDictionary *dict = nil; + [mailScript executeAndReturnError:&dict]; +} + + + @end diff --git a/Media.xcassets/AppIcon.appiconset/Contents.json b/Media.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/Media.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Media.xcassets/Contents.json b/Media.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Media.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file