diff --git a/Clocker.xcodeproj/project.pbxproj b/Clocker.xcodeproj/project.pbxproj index e8314ff..9effbc0 100755 --- a/Clocker.xcodeproj/project.pbxproj +++ b/Clocker.xcodeproj/project.pbxproj @@ -10,6 +10,10 @@ 9A20A04B1C4DEED200FB45AB /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A20A04A1C4DEED200FB45AB /* IOKit.framework */; }; 9A20A0701C4E804D00FB45AB /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A20A06F1C4E804D00FB45AB /* ServiceManagement.framework */; }; 9A20A0721C4E80A800FB45AB /* Clocker-Helper.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9A20A06E1C4E801600FB45AB /* Clocker-Helper.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 9A20A0781C4EA53600FB45AB /* CLOnboardingWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A20A0761C4EA53600FB45AB /* CLOnboardingWindowController.m */; }; + 9A20A0791C4EA53600FB45AB /* CLOnboardingWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A20A0771C4EA53600FB45AB /* CLOnboardingWindow.xib */; }; + 9A20A07E1C4EAAEB00FB45AB /* CLIntroViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A20A07C1C4EAAEB00FB45AB /* CLIntroViewController.m */; }; + 9A20A07F1C4EAAEB00FB45AB /* CLIntroView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A20A07D1C4EAAEB00FB45AB /* CLIntroView.xib */; }; 9A25F7471C1A5E17007D369B /* iRate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A25F7441C1A5E17007D369B /* iRate.m */; }; 9A3247321C25FD3A00CF6B6E /* CLCustomSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A3247311C25FD3A00CF6B6E /* CLCustomSliderCell.m */; }; 9A3247391C263F4F00CF6B6E /* CLAppearanceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A3247371C263F4F00CF6B6E /* CLAppearanceViewController.m */; }; @@ -104,6 +108,12 @@ 9A20A04A1C4DEED200FB45AB /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; 9A20A0691C4E801500FB45AB /* Clocker-Helper.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Clocker-Helper.xcodeproj"; path = "Clocker-Helper/Clocker-Helper.xcodeproj"; sourceTree = ""; }; 9A20A06F1C4E804D00FB45AB /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; }; + 9A20A0751C4EA53600FB45AB /* CLOnboardingWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLOnboardingWindowController.h; path = Clocker/Onboarding/CLOnboardingWindowController.h; sourceTree = ""; }; + 9A20A0761C4EA53600FB45AB /* CLOnboardingWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLOnboardingWindowController.m; path = Clocker/Onboarding/CLOnboardingWindowController.m; sourceTree = ""; }; + 9A20A0771C4EA53600FB45AB /* CLOnboardingWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CLOnboardingWindow.xib; path = Clocker/Onboarding/CLOnboardingWindow.xib; sourceTree = ""; }; + 9A20A07B1C4EAAEB00FB45AB /* CLIntroViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLIntroViewController.h; path = Clocker/Onboarding/CLIntroViewController.h; sourceTree = ""; }; + 9A20A07C1C4EAAEB00FB45AB /* CLIntroViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLIntroViewController.m; path = Clocker/Onboarding/CLIntroViewController.m; sourceTree = ""; }; + 9A20A07D1C4EAAEB00FB45AB /* CLIntroView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CLIntroView.xib; path = Clocker/Onboarding/CLIntroView.xib; sourceTree = ""; }; 9A25F7411C1A5E17007D369B /* iRate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = iRate.h; path = "Clocker/Rate App/iRate.h"; sourceTree = ""; }; 9A25F7441C1A5E17007D369B /* iRate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = iRate.m; path = "Clocker/Rate App/iRate.m"; sourceTree = ""; }; 9A3247301C25FD3A00CF6B6E /* CLCustomSliderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLCustomSliderCell.h; path = "Clocker/Custom Slider/CLCustomSliderCell.h"; sourceTree = ""; }; @@ -258,6 +268,9 @@ 9A392EE61C1CDD530072C10A /* CLAboutUsViewController.m */, 9A392EEA1C1CE9950072C10A /* CLPreferencesViewController.h */, 9A392EEB1C1CE9950072C10A /* CLPreferencesViewController.m */, + 9A20A07B1C4EAAEB00FB45AB /* CLIntroViewController.h */, + 9A20A07C1C4EAAEB00FB45AB /* CLIntroViewController.m */, + 9A20A07D1C4EAAEB00FB45AB /* CLIntroView.xib */, ); name = "View Controllers"; sourceTree = ""; @@ -291,6 +304,7 @@ 9A392EEC1C1CE9950072C10A /* CLPreferencesView.xib */, 9A3247381C263F4F00CF6B6E /* CLAppearanceView.xib */, 9A9E63851C2C673E009A299B /* CLAppFeedbackWindow.xib */, + 9A20A0771C4EA53600FB45AB /* CLOnboardingWindow.xib */, ); name = XIB; sourceTree = ""; @@ -334,6 +348,8 @@ 9A8605E51BEC165400A810A4 /* Controllers */ = { isa = PBXGroup; children = ( + 9A20A0751C4EA53600FB45AB /* CLOnboardingWindowController.h */, + 9A20A0761C4EA53600FB45AB /* CLOnboardingWindowController.m */, 9A9E63831C2C673E009A299B /* CLAppFeedbackWindowController.h */, 9A9E63841C2C673E009A299B /* CLAppFeedbackWindowController.m */, 9A5951BE1C1D0AA0009C17AA /* CLOneWindowController.m */, @@ -535,9 +551,11 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9A20A0791C4EA53600FB45AB /* CLOnboardingWindow.xib in Resources */, 9A9E63871C2C673E009A299B /* CLAppFeedbackWindow.xib in Resources */, 9A5951FD1C1D592D009C17AA /* iVersion.bundle in Resources */, 9A392EEE1C1CE9950072C10A /* CLPreferencesView.xib in Resources */, + 9A20A07F1C4EAAEB00FB45AB /* CLIntroView.xib in Resources */, 9A56DB811C1CFB73004CE6AF /* Panel.xib in Resources */, 9A43792E1BEC256200F4E27F /* Media.xcassets in Resources */, 9A392EE91C1CDD530072C10A /* CLAboutUsView.xib in Resources */, @@ -583,6 +601,7 @@ 9A5951BD1C1D0A8D009C17AA /* CommonStrings.m in Sources */, 9A5951FA1C1D5214009C17AA /* iVersion.m in Sources */, 9A87DAC61C358FA800A8CF3B /* DTError.m in Sources */, + 9A20A0781C4EA53600FB45AB /* CLOnboardingWindowController.m in Sources */, 9A87DACA1C358FA800A8CF3B /* DTTimePeriodGroup.m in Sources */, 9A25F7471C1A5E17007D369B /* iRate.m in Sources */, 9A8605C01BEC14F600A810A4 /* Panel.m in Sources */, @@ -593,6 +612,7 @@ 9A8605BB1BEC14DC00A810A4 /* PanelController.m in Sources */, 9A8605B61BEC14BE00A810A4 /* MenubarController.m in Sources */, 9A5951C01C1D0AA0009C17AA /* CLOneWindowController.m in Sources */, + 9A20A07E1C4EAAEB00FB45AB /* CLIntroViewController.m in Sources */, 9A8605B71BEC14BE00A810A4 /* ApplicationDelegate.m in Sources */, 9A5951F51C1D3D81009C17AA /* CLTimezoneCellView.m in Sources */, 9ABF58721C29A80600BD0187 /* CLTimezoneData.m in Sources */, @@ -658,7 +678,7 @@ GCC_PREFIX_HEADER = "Clocker/Clocker-Prefix.pch"; INFOPLIST_FILE = "Clocker/Clocker-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.abhishek.Clocker; PRODUCT_NAME = Clocker; @@ -759,7 +779,7 @@ GCC_PREFIX_HEADER = "Clocker/Clocker-Prefix.pch"; INFOPLIST_FILE = "Clocker/Clocker-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.abhishek.Clocker; @@ -788,7 +808,7 @@ GCC_PREFIX_HEADER = "Clocker/Clocker-Prefix.pch"; INFOPLIST_FILE = "Clocker/Clocker-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.abhishek.Clocker; PRODUCT_NAME = Clocker; diff --git a/Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate b/Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate index 568bc8b..74b5296 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.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 5f7580a..bf78821 100644 --- a/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -29,5 +29,37 @@ landmarkType = "5"> + + + + + + + + diff --git a/Clocker/AboutUsWindow/CLAboutUsView.xib b/Clocker/AboutUsWindow/CLAboutUsView.xib index 9372ba4..b77c3fa 100644 --- a/Clocker/AboutUsWindow/CLAboutUsView.xib +++ b/Clocker/AboutUsWindow/CLAboutUsView.xib @@ -52,7 +52,7 @@ - + diff --git a/Clocker/App Feedback/CLAppFeedbackWindow.xib b/Clocker/App Feedback/CLAppFeedbackWindow.xib index 24c6214..b11e1b9 100644 --- a/Clocker/App Feedback/CLAppFeedbackWindow.xib +++ b/Clocker/App Feedback/CLAppFeedbackWindow.xib @@ -82,9 +82,9 @@ - + - + @@ -97,8 +97,8 @@ - - + + @@ -182,7 +182,7 @@ DQ - + diff --git a/Clocker/Appearance Tab/CLAppearanceView.xib b/Clocker/Appearance Tab/CLAppearanceView.xib index b82b7c7..04e5a60 100644 --- a/Clocker/Appearance Tab/CLAppearanceView.xib +++ b/Clocker/Appearance Tab/CLAppearanceView.xib @@ -7,6 +7,7 @@ + @@ -60,12 +61,12 @@ - + - + - + @@ -110,6 +111,9 @@ + + + @@ -125,6 +129,7 @@ + @@ -139,6 +144,9 @@ + + + @@ -154,6 +162,7 @@ + @@ -201,6 +210,9 @@ + + + @@ -216,6 +228,7 @@ + @@ -232,15 +245,15 @@ - + - + - - + + @@ -248,6 +261,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -257,14 +301,17 @@ + + + @@ -277,7 +324,7 @@ - + diff --git a/Clocker/Appearance Tab/CLAppearanceViewController.h b/Clocker/Appearance Tab/CLAppearanceViewController.h index e74a0bd..cdca795 100644 --- a/Clocker/Appearance Tab/CLAppearanceViewController.h +++ b/Clocker/Appearance Tab/CLAppearanceViewController.h @@ -11,4 +11,6 @@ @interface CLAppearanceViewController : NSViewController +@property (assign, nonatomic) BOOL enableOptions; + @end diff --git a/Clocker/Appearance Tab/CLAppearanceViewController.m b/Clocker/Appearance Tab/CLAppearanceViewController.m index 01ee7d8..de92a76 100644 --- a/Clocker/Appearance Tab/CLAppearanceViewController.m +++ b/Clocker/Appearance Tab/CLAppearanceViewController.m @@ -16,6 +16,7 @@ @property (weak) IBOutlet NSSegmentedControl *timeFormat; @property (weak) IBOutlet NSSegmentedControl *theme; @property (weak) IBOutlet NSSegmentedControl *menuOptions; +@property (weak) IBOutlet NSTextField *informationLabel; @end @@ -29,13 +30,10 @@ [self.view setWantsLayer:YES]; // view's backing store is using a Core Animation Layer [self.view setLayer:viewLayer]; - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - NSNumber *shouldCityBeShown = [userDefaults objectForKey:@"shouldCityBeShown"]; - NSNumber *shouldDayBeShown = [userDefaults objectForKey:@"shouldDayBeShown"]; - - [self.menuOptions setSelected:shouldDayBeShown.boolValue forSegment:0]; - [self.menuOptions setSelected:shouldCityBeShown.boolValue forSegment:1]; + self.informationLabel.stringValue = @"Select a favourite timezone to enable menubar display options."; + self.informationLabel.textColor = [NSColor secondaryLabelColor]; + self.enableOptions = [[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteTimezone"] == nil ? NO : YES; } - (IBAction)timeFormatSelectionChanged:(id)sender diff --git a/Clocker/ApplicationDelegate.m b/Clocker/ApplicationDelegate.m index 39d72ac..3b08656 100755 --- a/Clocker/ApplicationDelegate.m +++ b/Clocker/ApplicationDelegate.m @@ -32,6 +32,7 @@ #import "CommonStrings.h" #import "iVersion.h" #import +#import "CLOnboardingWindowController.h" NSString *const CLParseApplicationID = @"F2ahd8J6sfjQMCc5z3xSy9kVK94PmKmH6hV2UsUK"; NSString *const CLParseClientID = @"vfnqDtinvmwUBkcifznYHzYTetxN5iMvt8Ey8StD"; @@ -118,12 +119,23 @@ void *kContextActivePanel = &kContextActivePanel; [[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"startAtLogin"]; } - - + NSString *onboarding = [[NSUserDefaults standardUserDefaults] objectForKey:@"initalLaunch"]; // Install icon into the menu bar self.menubarController = [[MenubarController alloc] init]; + if (onboarding == nil) + { + + [[NSUserDefaults standardUserDefaults] setObject:@"OnboardingDone" forKey:@"initalLaunch"]; + [self.menubarController setInitialTimezoneData]; + } + + CLOnboardingWindowController *windowController = [CLOnboardingWindowController sharedWindow]; + [windowController showWindow:nil]; + [NSApp activateIgnoringOtherApps:YES]; + + [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions": @YES }]; [[Crashlytics sharedInstance] setDebugMode:NO]; diff --git a/Clocker/BackgroundView.m b/Clocker/BackgroundView.m index 08c1778..37b0a4d 100755 --- a/Clocker/BackgroundView.m +++ b/Clocker/BackgroundView.m @@ -136,7 +136,10 @@ [self addTrackingArea:self.trackingArea]; } - +-(BOOL)allowsVibrancy +{ + return YES; +} #pragma mark - #pragma mark Public accessors diff --git a/Clocker/CLOneWindow/CLOneWindow.xib b/Clocker/CLOneWindow/CLOneWindow.xib index 8723e33..f2e080f 100644 --- a/Clocker/CLOneWindow/CLOneWindow.xib +++ b/Clocker/CLOneWindow/CLOneWindow.xib @@ -1,6 +1,7 @@ + diff --git a/Clocker/CLOneWindow/CLOneWindowController.m b/Clocker/CLOneWindow/CLOneWindowController.m index 07ce6a6..101b04b 100644 --- a/Clocker/CLOneWindow/CLOneWindowController.m +++ b/Clocker/CLOneWindow/CLOneWindowController.m @@ -35,6 +35,7 @@ static CLOneWindowController *sharedWindow = nil; // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. } + + (instancetype)sharedWindow { if (sharedWindow == nil) @@ -63,6 +64,9 @@ static CLOneWindowController *sharedWindow = nil; { [self.window setContentSize:contentView.frame.size]; [self.window setContentView:contentView]; + CGFloat xPos = NSWidth([[self.window screen] frame])/2 - NSWidth([self.window frame])/2; + CGFloat yPos = NSHeight([[self.window screen] frame])/2 - NSHeight([self.window frame])/2; + [self.window setFrame:NSMakeRect(xPos, yPos, NSWidth([self.window frame]), NSHeight([self.window frame])) display:YES]; } - (IBAction)openAboutUsView:(id)sender diff --git a/Clocker/Custom Table Cell Views/CLTimezoneCellView.m b/Clocker/Custom Table Cell Views/CLTimezoneCellView.m index 85ecfc2..c9dc88b 100644 --- a/Clocker/Custom Table Cell Views/CLTimezoneCellView.m +++ b/Clocker/Custom Table Cell Views/CLTimezoneCellView.m @@ -40,8 +40,7 @@ if ([[sender superview] isKindOfClass:[self class]]) { CLTimezoneCellView *cellView = (CLTimezoneCellView *)[sender superview]; NSData *dataObject = panelController.defaultPreferences[cellView.rowNumber]; - NSData *newDataObject = [dataObject mutableCopy]; - CLTimezoneData *timezoneObject = [CLTimezoneData getCustomObject:newDataObject]; + CLTimezoneData *timezoneObject = [CLTimezoneData getCustomObject:dataObject]; for (NSData *object in panelController.defaultPreferences) { @@ -50,14 +49,18 @@ return; } } + timezoneObject.customLabel = (customLabelValue.length > 0) ? customLabelValue : CLEmptyString; - [panelController.defaultPreferences replaceObjectAtIndex:cellView.rowNumber withObject:newDataObject]; + NSData *newObject = [NSKeyedArchiver archivedDataWithRootObject:timezoneObject]; + [panelController.defaultPreferences replaceObjectAtIndex:cellView.rowNumber withObject:newObject]; [[NSUserDefaults standardUserDefaults] setObject:panelController.defaultPreferences forKey:CLDefaultPreferenceKey]; [panelController updateDefaultPreferences]; [panelController.mainTableview reloadData]; - [[NSNotificationCenter defaultCenter] postNotificationName:CLCustomLabelChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] + postNotificationName:CLCustomLabelChangedNotification + object:nil]; } } diff --git a/Clocker/MenubarController.h b/Clocker/MenubarController.h index aec5db5..dd82b2e 100755 --- a/Clocker/MenubarController.h +++ b/Clocker/MenubarController.h @@ -41,4 +41,6 @@ @property (nonatomic, strong, readonly) NSStatusItem *statusItem; @property (nonatomic, strong, readonly) StatusItemView *statusItemView; +- (void)setInitialTimezoneData; + @end diff --git a/Clocker/MenubarController.m b/Clocker/MenubarController.m index a6e809e..c1648d8 100755 --- a/Clocker/MenubarController.m +++ b/Clocker/MenubarController.m @@ -47,6 +47,11 @@ return self; } +- (void)setInitialTimezoneData +{ + [CLTimezoneData setInitialTimezoneData]; +} + - (void)updateIconDisplay { [self.statusItemView setNeedsDisplay:YES]; diff --git a/Clocker/Model/CLTimezoneData.h b/Clocker/Model/CLTimezoneData.h index 6e7db2b..581dd4b 100644 --- a/Clocker/Model/CLTimezoneData.h +++ b/Clocker/Model/CLTimezoneData.h @@ -9,6 +9,11 @@ #import #import "CLTimezoneCellView.h" +typedef enum : NSUInteger { + CLPanelDisplay, + CLMenuDisplay +} CLDateDisplayType; + @interface CLTimezoneData : NSObject @property (strong, nonatomic) NSString *customLabel; @@ -21,14 +26,16 @@ @property (strong, nonatomic) NSNumber *isFavourite; + (instancetype)getCustomObject:(NSData *)encodedData; -- (void)sendAnalyticsData; ++ (void)setInitialTimezoneData; + +- (void)sendAnalyticsData; - (instancetype)initWithDictionary:(NSDictionary *)dictionary; -- (BOOL)saveObjectToPreferences:(CLTimezoneData *)object; +- (BOOL)saveObjectToPreferences; - (NSString *)getTimeForTimeZoneWithFutureSliderValue:(NSInteger)futureSliderValue; - (NSString *)getLocalCurrentDate; - (NSString *)compareSystemDate:(NSString *)systemDate toTimezoneDate:(NSString *)date; -- (NSString *)getDateForTimeZoneWithFutureSliderValue:(NSInteger)futureSliderValue; +- (NSString *)getDateForTimeZoneWithFutureSliderValue:(NSInteger)futureSliderValue andDisplayType:(CLDateDisplayType)type; - (void)getTimeZoneForLatitude:(NSString *)latitude andLongitude:(NSString *)longitude andDataObject:(CLTimezoneData *)dataObject; - (NSString *)formatStringShouldContainCity:(BOOL)value; - (NSString *)getMenuTitle; diff --git a/Clocker/Model/CLTimezoneData.m b/Clocker/Model/CLTimezoneData.m index d73332e..6a24ecd 100644 --- a/Clocker/Model/CLTimezoneData.m +++ b/Clocker/Model/CLTimezoneData.m @@ -33,10 +33,19 @@ return self; } -- (BOOL)saveObjectToPreferences:(CLTimezoneData *)object ++ (void)setInitialTimezoneData { + CLTimezoneData *newData = [[self alloc] init]; + newData.timezoneID = [[NSTimeZone systemTimeZone] name]; + newData.formattedAddress = newData.timezoneID; - NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:object]; + [newData saveObjectToPreferences]; +} + +- (BOOL)saveObjectToPreferences +{ + + NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:self]; NSMutableArray *array = [NSMutableArray new]; [array addObject:encodedObject]; @@ -241,19 +250,10 @@ panelController = window.windowController; } } - - [panelController.defaultPreferences replaceObjectAtIndex:[panelController.defaultPreferences indexOfObject:self] withObject:newDataObject]; [[NSUserDefaults standardUserDefaults] setObject:panelController.defaultPreferences forKey:CLDefaultPreferenceKey]; } - else if ([self.nextUpdate isKindOfClass:[NSDate class]] && - [self.nextUpdate isEarlierThanOrEqualTo:timezoneDate]) - { - [self getTimeZoneForLatitude:self.latitude - andLongitude:self.longitude - andDataObject:self]; - } NSInteger daysApart = [timezoneDate daysFrom:localDate]; @@ -274,7 +274,7 @@ } } -- (NSString *)getDateForTimeZoneWithFutureSliderValue:(NSInteger)futureSliderValue +- (NSString *)getDateForTimeZoneWithFutureSliderValue:(NSInteger)futureSliderValue andDisplayType:(CLDateDisplayType)type { NSCalendar *currentCalendar = [NSCalendar autoupdatingCurrentCalendar]; NSDate *newDate = [currentCalendar dateByAddingUnit:NSCalendarUnitHour @@ -288,7 +288,7 @@ dateFormatter.timeZone = [NSTimeZone timeZoneWithName:self.timezoneID]; NSNumber *relativeDayPreference = [[NSUserDefaults standardUserDefaults] objectForKey:CLRelativeDateKey]; - if (relativeDayPreference.integerValue == 0) { + if (relativeDayPreference.integerValue == 0 && type == CLPanelDisplay) { return [self compareSystemDate:[self getLocalCurrentDate] toTimezoneDate:[dateFormatter stringFromDate:newDate]]; } @@ -305,88 +305,6 @@ } } -- (void)getTimeZoneForLatitude:(NSString *)latitude andLongitude:(NSString *)longitude andDataObject:(CLTimezoneData *)dataObject -{ - - if (![CLAPI isUserConnectedToInternet]) - { - //Could not fetch data - return; - } - - NSString *urlString = [NSString stringWithFormat:@"http://api.geonames.org/timezoneJSON?lat=%@&lng=%@&username=abhishaker17", latitude, longitude]; - - - [CLAPI dataTaskWithServicePath:urlString - bySender:self - withCompletionBlock:^(NSError *error, NSDictionary *json) { - dispatch_async(dispatch_get_main_queue(), ^{ - - if (json.count == 0) { - //No results found - return; - } - - if ([json[@"status"][@"message"] - isEqualToString:@"the hourly limit of 2000 credits for abhishaker17 has been exceeded. Please throttle your requests or use the commercial service."]) - { - return; - } - - CLTimezoneData *newDataObject = [dataObject mutableCopy]; - - /* - if (json[@"sunrise"] && json[@"sunset"]) { - newDataObject.sunriseTime = json[@"sunrise"]; - newDataObject.sunsetTime = json[@"sunset"]; - }*/ - - NSUInteger units = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; - NSDateComponents *comps = [[NSCalendar currentCalendar] components:units fromDate:newDataObject.nextUpdate]; - comps.day = comps.day + 1; - NSDate *tomorrowMidnight = [[NSCalendar currentCalendar] dateFromComponents:comps]; - - dataObject.nextUpdate = tomorrowMidnight; - - - NSArray *defaultPreference = [[NSUserDefaults standardUserDefaults] objectForKey:CLDefaultPreferenceKey]; - - if (defaultPreference == nil) - { - defaultPreference = [[NSMutableArray alloc] init]; - } - - - PanelController *panelController; - - for (NSWindow *window in [[NSApplication sharedApplication] windows]) - { - if ([window.windowController isMemberOfClass:[PanelController class]]) - { - panelController = window.windowController; - } - } - - - NSMutableArray *newArray = [[NSMutableArray alloc] initWithArray:defaultPreference]; - - for (NSMutableDictionary *timeDictionary in panelController.defaultPreferences) { - if ([dataObject.place_id isEqualToString:timeDictionary[CLPlaceIdentifier]]) { - [newArray replaceObjectAtIndex:[panelController.defaultPreferences indexOfObject:dataObject] withObject:newDataObject]; - } - } - - [[NSUserDefaults standardUserDefaults] setObject:newArray forKey:CLDefaultPreferenceKey]; - - [panelController.mainTableview reloadData]; - - }); - - - }]; - -} - - (NSString *)getWeekdayFromInteger:(NSInteger)weekdayInteger { if (weekdayInteger > 7) { @@ -443,7 +361,7 @@ if (shouldDayBeShown.boolValue == 0) { - NSString *substring = [self getDateForTimeZoneWithFutureSliderValue:0]; + NSString *substring = [self getDateForTimeZoneWithFutureSliderValue:0 andDisplayType:CLMenuDisplay]; substring = [substring substringToIndex:3]; if (menuTitle.length > 0) diff --git a/Clocker/Onboarding/CLIntroView.xib b/Clocker/Onboarding/CLIntroView.xib new file mode 100644 index 0000000..9bc460c --- /dev/null +++ b/Clocker/Onboarding/CLIntroView.xib @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Clocker/Onboarding/CLIntroViewController.h b/Clocker/Onboarding/CLIntroViewController.h new file mode 100644 index 0000000..3685bbb --- /dev/null +++ b/Clocker/Onboarding/CLIntroViewController.h @@ -0,0 +1,13 @@ +// +// CLIntroViewController.h +// Clocker +// +// Created by Abhishek Banthia on 1/19/16. +// +// + +#import + +@interface CLIntroViewController : NSViewController + +@end diff --git a/Clocker/Onboarding/CLIntroViewController.m b/Clocker/Onboarding/CLIntroViewController.m new file mode 100644 index 0000000..9bfe96b --- /dev/null +++ b/Clocker/Onboarding/CLIntroViewController.m @@ -0,0 +1,59 @@ +// +// CLIntroViewController.m +// Clocker +// +// Created by Abhishek Banthia on 1/19/16. +// +// + +#import "CLIntroViewController.h" +#import +#import "ApplicationDelegate.h" + + +@interface CLIntroViewController () +@property (weak) IBOutlet NSImageView *onboardingImageView; + +@end + +@implementation CLIntroViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do view setup here. + +// self.view.window.titleVisibility = NSWindowTitleHidden; + + CALayer *viewLayer = [CALayer layer]; + [viewLayer setBackgroundColor:CGColorCreateGenericRGB(255.0, 255.0, 255.0, 0.8)]; //RGB plus Alpha Channel + [self.view setWantsLayer:YES]; // view's backing store is using a Core Animation Layer + [self.view setLayer:viewLayer]; + + self.view.window.styleMask = NSFullSizeContentViewWindowMask; +} + +- (IBAction)continueOnboarding:(NSButton *)sender +{ + if ([sender.title isEqualToString:@"Get Started"]) + { + [self.view.window close]; + ApplicationDelegate *delegate = (ApplicationDelegate*)[NSApplication sharedApplication].delegate; + [delegate togglePanel:nil]; + return; + } + + self.onboardingImageView.image = [NSImage imageNamed:@"FinalOnboarding"]; + [sender setTitle:@"Get Started"]; + + CATransition *transition = [CATransition animation]; + transition.duration = 1.0f; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; + transition.type = kCATransitionMoveIn; + [self.view setWantsLayer:YES]; + + [self.onboardingImageView.layer addAnimation:transition forKey:nil]; + +} + + +@end diff --git a/Clocker/Onboarding/CLOnboardingWindow.xib b/Clocker/Onboarding/CLOnboardingWindow.xib new file mode 100644 index 0000000..d9f5664 --- /dev/null +++ b/Clocker/Onboarding/CLOnboardingWindow.xib @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Clocker/Onboarding/CLOnboardingWindowController.h b/Clocker/Onboarding/CLOnboardingWindowController.h new file mode 100644 index 0000000..c20b237 --- /dev/null +++ b/Clocker/Onboarding/CLOnboardingWindowController.h @@ -0,0 +1,18 @@ +// +// CLOnboardingWindowController.h +// Clocker +// +// Created by Abhishek Banthia on 1/19/16. +// +// + +#import +#import "CLIntroViewController.h" + +@interface CLOnboardingWindowController : NSWindowController + +@property (strong, nonatomic) CLIntroViewController *introViewController; + ++ (instancetype)sharedWindow; + +@end diff --git a/Clocker/Onboarding/CLOnboardingWindowController.m b/Clocker/Onboarding/CLOnboardingWindowController.m new file mode 100644 index 0000000..2118e7e --- /dev/null +++ b/Clocker/Onboarding/CLOnboardingWindowController.m @@ -0,0 +1,63 @@ +// +// CLOnboardingWindowController.m +// Clocker +// +// Created by Abhishek Banthia on 1/19/16. +// +// + +#import "CLOnboardingWindowController.h" +#import + +@interface CLOnboardingWindowController () + +@end + +static CLOnboardingWindowController *sharedOnboardingWindow; + +@implementation CLOnboardingWindowController + +- (void)windowDidLoad { + [super windowDidLoad]; + + CALayer *viewLayer = [CALayer layer]; + [viewLayer setBackgroundColor:CGColorCreateGenericRGB(255.0, 255.0, 255.0, 0.8)]; //RGB plus Alpha Channel + [self.window.contentView setWantsLayer:YES]; // view's backing store is using a Core Animation Layer + [self.window.contentView setLayer:viewLayer]; + self.window.titlebarAppearsTransparent = YES; + + self.window.backgroundColor = [NSColor whiteColor]; + + self.window.titleVisibility = NSWindowTitleHidden; + + // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. +} + ++ (instancetype)sharedWindow +{ + if (sharedOnboardingWindow == nil) + { + /*Using a thread safe pattern*/ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedOnboardingWindow = [[self alloc] initWithWindowNibName:@"CLOnboardingWindow"]; + + }); + } + return sharedOnboardingWindow; +} + +- (IBAction)continueButtonPressed:(id)sender +{ + + self.introViewController = [[CLIntroViewController alloc] initWithNibName:@"CLIntroView" bundle:nil]; + [[self.window animator] setContentSize:self.introViewController.view.frame.size]; + [[self.window animator] setContentView:self.introViewController.view]; + + CGFloat xPos = NSWidth([[self.window screen] frame])/2 - NSWidth([self.window frame])/2; + CGFloat yPos = NSHeight([[self.window screen] frame])/2 - NSHeight([self.window frame])/2; + [self.window setFrame:NSMakeRect(xPos, yPos, NSWidth([self.window frame]), NSHeight([self.window frame])) display:YES]; +} + + +@end diff --git a/Clocker/Panel.xib b/Clocker/Panel.xib index c1c33b3..4bd5385 100755 --- a/Clocker/Panel.xib +++ b/Clocker/Panel.xib @@ -60,9 +60,9 @@ - + - + @@ -87,13 +87,13 @@ - + - + - + @@ -203,7 +203,7 @@ - + @@ -215,9 +215,9 @@ - + - + @@ -262,7 +262,7 @@ - + diff --git a/Clocker/PanelController.m b/Clocker/PanelController.m index 68c316f..80a6406 100755 --- a/Clocker/PanelController.m +++ b/Clocker/PanelController.m @@ -84,8 +84,6 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell"; { self.dateFormatter = [[NSDateFormatter alloc] init]; } - - [self updateDefaultPreferences]; if ([[[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey] isEqualToString:@"Black"]) { self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon-White"]; @@ -307,8 +305,9 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell"; CLTimezoneData *dataObject = [CLTimezoneData getCustomObject:self.defaultPreferences[row]]; - NSTextView *customLabel = (NSTextView*)[cell.relativeDate.window fieldEditor:YES - forObject:cell.relativeDate]; + NSTextView *customLabel = (NSTextView*)[cell.relativeDate.window + fieldEditor:YES + forObject:cell.relativeDate]; NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey]; if (theme.length > 0 && ![theme isEqualToString:@"Default"]) @@ -330,7 +329,7 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell"; customLabel.insertionPointColor = [NSColor blackColor]; } - cell.relativeDate.stringValue = [dataObject getDateForTimeZoneWithFutureSliderValue:self.futureSliderValue]; + cell.relativeDate.stringValue = [dataObject getDateForTimeZoneWithFutureSliderValue:self.futureSliderValue andDisplayType:CLPanelDisplay]; cell.time.stringValue = [dataObject getTimeForTimeZoneWithFutureSliderValue:self.futureSliderValue]; @@ -379,9 +378,8 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell"; return; } - CLTimezoneData *mutableTimeZoneData = [dataObject mutableCopy]; - mutableTimeZoneData.customLabel = object; - [self.defaultPreferences replaceObjectAtIndex:row withObject:mutableTimeZoneData]; + dataObject.customLabel = object; + [self.defaultPreferences replaceObjectAtIndex:row withObject:dataObject]; [[NSUserDefaults standardUserDefaults] setObject:self.defaultPreferences forKey:CLDefaultPreferenceKey]; [self.mainTableview reloadData]; } @@ -522,8 +520,6 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell"; [self.mainTableview setBackgroundColor:[NSColor whiteColor]]; self.window.alphaValue = 1; } - - } @end diff --git a/Clocker/Preferences/CLPreferencesView.xib b/Clocker/Preferences/CLPreferencesView.xib index f8671e7..957b639 100644 --- a/Clocker/Preferences/CLPreferencesView.xib +++ b/Clocker/Preferences/CLPreferencesView.xib @@ -179,11 +179,6 @@ CA - - - NSNegateBoolean - - @@ -198,22 +193,15 @@ CA - + - + - - + + - - - - NSNegateBoolean - - - diff --git a/Clocker/Preferences/CLPreferencesViewController.m b/Clocker/Preferences/CLPreferencesViewController.m index ef95426..128d52c 100644 --- a/Clocker/Preferences/CLPreferencesViewController.m +++ b/Clocker/Preferences/CLPreferencesViewController.m @@ -164,9 +164,7 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?"; } return self.timeZoneArray[row]; - } - return nil; } else if([[tableColumn identifier] isEqualToString:CLPreferencesCustomLabelIdentifier]) @@ -229,8 +227,7 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?"; dataObject.isFavourite = object; NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:dataObject]; [newArray replaceObjectAtIndex:row withObject:encodedObject]; - self.selectedTimeZones = [NSMutableArray arrayWithArray:newArray]; - [[NSUserDefaults standardUserDefaults] setObject:self.selectedTimeZones forKey:CLDefaultPreferenceKey]; + [[NSUserDefaults standardUserDefaults] setObject:newArray forKey:CLDefaultPreferenceKey]; (dataObject.isFavourite.integerValue == 1) ? @@ -239,7 +236,9 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?"; [[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"favouriteTimezone"]; - [self.timezoneTableView reloadData]; + [self refereshTimezoneTableView]; + + [self refreshMainTableview]; } } @@ -412,7 +411,7 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?"; [itemsToRemove addObject:self.selectedTimeZones[idx]]; }]; - + [self.selectedTimeZones removeObjectsInArray:itemsToRemove]; NSMutableArray *newDefaults = [[NSMutableArray alloc] initWithArray:self.selectedTimeZones]; @@ -422,6 +421,7 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?"; [self.timezoneTableView reloadData]; [self refreshMainTableview]; + } - (IBAction)filterTimezoneArray:(id)sender diff --git a/Clocker/StatusItemView.m b/Clocker/StatusItemView.m index b065bdf..a64c201 100755 --- a/Clocker/StatusItemView.m +++ b/Clocker/StatusItemView.m @@ -29,6 +29,7 @@ #import "StatusItemView.h" #import "CommonStrings.h" #import "CLTimezoneData.h" +#import "DateTools.h" @implementation StatusItemView @@ -78,7 +79,9 @@ } else { - textField.stringValue = @"Icon"; + textField.stringValue = [[NSDate date] formattedDateWithFormat:@"MMM dd HH:mm" + timeZone:[NSTimeZone systemTimeZone] + locale:[NSLocale currentLocale]]; } diff --git a/Media.xcassets/EmptyPanel.imageset/Contents.json b/Media.xcassets/EmptyPanel.imageset/Contents.json new file mode 100644 index 0000000..73cf709 --- /dev/null +++ b/Media.xcassets/EmptyPanel.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "EmptyPanel.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Media.xcassets/EmptyPanel.imageset/EmptyPanel.png b/Media.xcassets/EmptyPanel.imageset/EmptyPanel.png new file mode 100644 index 0000000..7805351 Binary files /dev/null and b/Media.xcassets/EmptyPanel.imageset/EmptyPanel.png differ diff --git a/Media.xcassets/FinalOnboarding.imageset/Contents.json b/Media.xcassets/FinalOnboarding.imageset/Contents.json new file mode 100644 index 0000000..3d4971e --- /dev/null +++ b/Media.xcassets/FinalOnboarding.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "FinalOnboarding.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Media.xcassets/FinalOnboarding.imageset/FinalOnboarding.png b/Media.xcassets/FinalOnboarding.imageset/FinalOnboarding.png new file mode 100644 index 0000000..143e89a Binary files /dev/null and b/Media.xcassets/FinalOnboarding.imageset/FinalOnboarding.png differ diff --git a/Media.xcassets/Future Slider.imageset/Contents.json b/Media.xcassets/Future Slider.imageset/Contents.json new file mode 100644 index 0000000..8d7b68e --- /dev/null +++ b/Media.xcassets/Future Slider.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Future Slider.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Media.xcassets/Future Slider.imageset/Future Slider.png b/Media.xcassets/Future Slider.imageset/Future Slider.png new file mode 100644 index 0000000..4bbd6a4 Binary files /dev/null and b/Media.xcassets/Future Slider.imageset/Future Slider.png differ diff --git a/Media.xcassets/Main Panel.imageset/Contents.json b/Media.xcassets/Main Panel.imageset/Contents.json new file mode 100644 index 0000000..067d880 --- /dev/null +++ b/Media.xcassets/Main Panel.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Main Panel.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Media.xcassets/Main Panel.imageset/Main Panel.png b/Media.xcassets/Main Panel.imageset/Main Panel.png new file mode 100644 index 0000000..694473f Binary files /dev/null and b/Media.xcassets/Main Panel.imageset/Main Panel.png differ diff --git a/Media.xcassets/Onboarding.imageset/Contents.json b/Media.xcassets/Onboarding.imageset/Contents.json new file mode 100644 index 0000000..86ed9fd --- /dev/null +++ b/Media.xcassets/Onboarding.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Onboarding.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Media.xcassets/Onboarding.imageset/Onboarding.png b/Media.xcassets/Onboarding.imageset/Onboarding.png new file mode 100644 index 0000000..7b7a02a Binary files /dev/null and b/Media.xcassets/Onboarding.imageset/Onboarding.png differ