Browse Source

Block-based enumeration.

v1.2.3
Abhishek Banthia 9 years ago
parent
commit
c068746d51
  1. 12
      Clocker-Helper/Clocker-Helper/AppDelegate.m
  2. 12
      Clocker.xcodeproj/project.pbxproj
  3. BIN
      Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate
  4. 10
      Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  5. 3
      Clocker/AboutUsWindow/CLAboutUsViewController.h
  6. 3
      Clocker/AboutUsWindow/CLAboutUsViewController.m
  7. 3
      Clocker/App Feedback/CLAppFeedbackWindowController.h
  8. 30
      Clocker/App Feedback/CLAppFeedbackWindowController.m
  9. 2
      Clocker/Appearance Tab/CLAppearanceView.xib
  10. 2
      Clocker/Appearance Tab/CLAppearanceViewController.h
  11. 2
      Clocker/Appearance Tab/CLAppearanceViewController.m
  12. 29
      Clocker/ApplicationDelegate.m
  13. 13
      Clocker/CLMainWindowController.h
  14. 30
      Clocker/CLMainWindowController.m
  15. 4
      Clocker/CLOneWindow/CLOneWindowController.h
  16. 4
      Clocker/CLOneWindow/CLOneWindowController.m
  17. 4
      Clocker/Clocker-Info.plist
  18. 2
      Clocker/Custom Table Cell Views/CLTimezoneCellView.h
  19. 25
      Clocker/Custom Table Cell Views/CLTimezoneCellView.m
  20. 31
      Clocker/Model/CLTimezoneData.m
  21. 1
      Clocker/Onboarding/CLOnboardingWindow.xib
  22. 5
      Clocker/Onboarding/CLOnboardingWindowController.h
  23. 9
      Clocker/Onboarding/CLOnboardingWindowController.m
  24. 1
      Clocker/Panel.xib
  25. 8
      Clocker/PanelController.m
  26. 8
      Clocker/Preferences/CLPreferencesViewController.h
  27. 44
      Clocker/Preferences/CLPreferencesViewController.m
  28. 18
      Clocker/Rate App/iRate.m
  29. 2
      Clocker/StatusItemView.m
  30. 3
      Clocker/Utilities/CommonStrings.h
  31. 4
      Clocker/Utilities/CommonStrings.m

12
Clocker-Helper/Clocker-Helper/AppDelegate.m

@ -26,17 +26,15 @@
object:mainAppBundleIdentifier];
BOOL alreadyRunning = NO;
BOOL isActive = NO;
__block BOOL alreadyRunning = NO;
__block BOOL isActive = NO;
NSArray *running = [[NSWorkspace sharedWorkspace] runningApplications];
for (NSRunningApplication *app in running) {
[[NSWorkspace sharedWorkspace].runningApplications enumerateObjectsUsingBlock:^(NSRunningApplication * _Nonnull app, NSUInteger idx, BOOL * _Nonnull stop) {
if ([[app bundleIdentifier] isEqualToString:@"com.abhishek.Clocker"]) {
alreadyRunning = YES;
isActive = [app isActive];
break;
isActive = [app isActive];
}
}
}];
if (!alreadyRunning || !isActive) {
NSString *path = [[[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent];

12
Clocker.xcodeproj/project.pbxproj

@ -38,7 +38,6 @@
9A5951FD1C1D592D009C17AA /* iVersion.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 9A5951FC1C1D592D009C17AA /* iVersion.bundle */; };
9A63620A1C432F68004AD010 /* CLAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A6362091C432F68004AD010 /* CLAPI.m */; };
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 */; };
9A8605B71BEC14BE00A810A4 /* ApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A8605B51BEC14BE00A810A4 /* ApplicationDelegate.m */; };
9A8605BA1BEC14DC00A810A4 /* StatusItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A8605B81BEC14DC00A810A4 /* StatusItemView.m */; };
@ -64,6 +63,7 @@
9A9E876E1C1FEE1800A7A2DF /* Bolts.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9A9E87571C1FED1A00A7A2DF /* Bolts.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9A9E876F1C1FEE1A00A7A2DF /* Parse.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9A9E87581C1FED1A00A7A2DF /* Parse.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9AB9357B1C1AD8F7001285A0 /* CLRatingCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AB9357A1C1AD8F7001285A0 /* CLRatingCellView.m */; };
9ABA2B031C671D49009DC0EF /* CLMainWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABA2B021C671D49009DC0EF /* CLMainWindowController.m */; };
9ABF58721C29A80600BD0187 /* CLTimezoneData.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABF58711C29A80600BD0187 /* CLTimezoneData.m */; };
9AC678E41C1ABAB9003B4F6B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AC678E31C1ABAB9003B4F6B /* QuartzCore.framework */; };
9AF9A16B1C250AB300EE7C2A /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AF9A16A1C250AB300EE7C2A /* Reachability.m */; };
@ -150,7 +150,6 @@
9A6362081C432F68004AD010 /* CLAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLAPI.h; path = Clocker/API/CLAPI.h; sourceTree = "<group>"; };
9A6362091C432F68004AD010 /* CLAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLAPI.m; path = Clocker/API/CLAPI.m; sourceTree = "<group>"; };
9A8605AD1BEC148400A810A4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Clocker/main.m; sourceTree = "<group>"; };
9A8605B21BEC14A600A810A4 /* ColoredButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ColoredButton.m; path = Clocker/ColoredButton.m; sourceTree = "<group>"; };
9A8605B41BEC14BE00A810A4 /* MenubarController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MenubarController.m; path = Clocker/MenubarController.m; sourceTree = "<group>"; };
9A8605B51BEC14BE00A810A4 /* ApplicationDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ApplicationDelegate.m; path = Clocker/ApplicationDelegate.m; sourceTree = "<group>"; };
9A8605B81BEC14DC00A810A4 /* StatusItemView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = StatusItemView.m; path = Clocker/StatusItemView.m; sourceTree = "<group>"; };
@ -164,7 +163,6 @@
9A8605C81BEC155B00A810A4 /* PanelController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PanelController.h; path = Clocker/PanelController.h; sourceTree = "<group>"; };
9A8605C91BEC155B00A810A4 /* MenubarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MenubarController.h; path = Clocker/MenubarController.h; sourceTree = "<group>"; };
9A8605CA1BEC155B00A810A4 /* ApplicationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ApplicationDelegate.h; path = Clocker/ApplicationDelegate.h; sourceTree = "<group>"; };
9A8605CB1BEC155B00A810A4 /* ColoredButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ColoredButton.h; path = Clocker/ColoredButton.h; sourceTree = "<group>"; };
9A8605CC1BEC155B00A810A4 /* Clocker-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Clocker-Prefix.pch"; path = "Clocker/Clocker-Prefix.pch"; sourceTree = "<group>"; };
9A87DAB41C358FA800A8CF3B /* DateTools.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = DateTools.bundle; path = "Clocker/Date Tools/DateTools-master/DateTools/DateTools.bundle"; sourceTree = "<group>"; };
9A87DAB51C358FA800A8CF3B /* DateTools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DateTools.h; path = "Clocker/Date Tools/DateTools-master/DateTools/DateTools.h"; sourceTree = "<group>"; };
@ -195,6 +193,8 @@
9A9E876B1C1FEDE700A7A2DF /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
9AB935791C1AD8F7001285A0 /* CLRatingCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLRatingCellView.h; path = Clocker/CLRatingCellView.h; sourceTree = "<group>"; };
9AB9357A1C1AD8F7001285A0 /* CLRatingCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLRatingCellView.m; path = Clocker/CLRatingCellView.m; sourceTree = "<group>"; };
9ABA2B011C671D49009DC0EF /* CLMainWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLMainWindowController.h; path = Clocker/CLMainWindowController.h; sourceTree = "<group>"; };
9ABA2B021C671D49009DC0EF /* CLMainWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLMainWindowController.m; path = Clocker/CLMainWindowController.m; sourceTree = "<group>"; };
9ABF58701C29A80600BD0187 /* CLTimezoneData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLTimezoneData.h; path = Clocker/Model/CLTimezoneData.h; sourceTree = "<group>"; };
9ABF58711C29A80600BD0187 /* CLTimezoneData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLTimezoneData.m; path = Clocker/Model/CLTimezoneData.m; sourceTree = "<group>"; };
9AC678E31C1ABAB9003B4F6B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
@ -314,10 +314,10 @@
children = (
9A8605C61BEC155B00A810A4 /* Panel.h */,
9A8605BD1BEC14F600A810A4 /* Panel.m */,
9A8605CB1BEC155B00A810A4 /* ColoredButton.h */,
9A8605B21BEC14A600A810A4 /* ColoredButton.m */,
9A3247301C25FD3A00CF6B6E /* CLCustomSliderCell.h */,
9A3247311C25FD3A00CF6B6E /* CLCustomSliderCell.m */,
9ABA2B011C671D49009DC0EF /* CLMainWindowController.h */,
9ABA2B021C671D49009DC0EF /* CLMainWindowController.m */,
);
name = Superclass;
sourceTree = "<group>";
@ -608,6 +608,7 @@
9A8605BA1BEC14DC00A810A4 /* StatusItemView.m in Sources */,
9A87DAC91C358FA800A8CF3B /* DTTimePeriodCollection.m in Sources */,
9A3247391C263F4F00CF6B6E /* CLAppearanceViewController.m in Sources */,
9ABA2B031C671D49009DC0EF /* CLMainWindowController.m in Sources */,
9A9E63861C2C673E009A299B /* CLAppFeedbackWindowController.m in Sources */,
9A8605BB1BEC14DC00A810A4 /* PanelController.m in Sources */,
9A8605B61BEC14BE00A810A4 /* MenubarController.m in Sources */,
@ -616,7 +617,6 @@
9A8605B71BEC14BE00A810A4 /* ApplicationDelegate.m in Sources */,
9A5951F51C1D3D81009C17AA /* CLTimezoneCellView.m in Sources */,
9ABF58721C29A80600BD0187 /* CLTimezoneData.m in Sources */,
9A8605B31BEC14A600A810A4 /* ColoredButton.m in Sources */,
9A8605AE1BEC148400A810A4 /* main.m in Sources */,
9A392EE81C1CDD530072C10A /* CLAboutUsViewController.m in Sources */,
9A87DACB1C358FA800A8CF3B /* NSDate+DateTools.m in Sources */,

BIN
Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate generated

Binary file not shown.

10
Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@ -51,13 +51,13 @@
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Clocker/Model/CLTimezoneData.m"
timestampString = "474941219.735933"
filePath = "Clocker/ColoredButton.m"
timestampString = "475337911.265892"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "229"
endingLineNumber = "229"
landmarkName = "-compareSystemDate:toTimezoneDate:"
startingLineNumber = "53"
endingLineNumber = "53"
landmarkName = "-awakeFromNib"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>

3
Clocker/AboutUsWindow/CLAboutUsViewController.h

@ -11,7 +11,6 @@
@interface CLAboutUsViewController : NSViewController
@property (strong, nonatomic) CLAppFeedbackWindowController *feedbackWindow;
@property (weak) IBOutlet NSTextField *versionField;
@end

3
Clocker/AboutUsWindow/CLAboutUsViewController.m

@ -11,6 +11,9 @@
@interface CLAboutUsViewController ()
@property (strong, nonatomic) CLAppFeedbackWindowController *feedbackWindow;
@property (weak) IBOutlet NSTextField *versionField;
@end
static CLAboutUsViewController *sharedAboutUs = nil;

3
Clocker/App Feedback/CLAppFeedbackWindowController.h

@ -7,8 +7,9 @@
//
#import <Cocoa/Cocoa.h>
#import "CLMainWindowController.h"
@interface CLAppFeedbackWindowController : NSWindowController<NSWindowDelegate>
@interface CLAppFeedbackWindowController : CLMainWindowController
+ (instancetype)sharedWindow;

30
Clocker/App Feedback/CLAppFeedbackWindowController.m

@ -24,7 +24,7 @@ NSString *const CLFeedbackNotEnteredErrorMessage = @"Please enter some feedback.
static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
@interface CLAppFeedbackWindowController ()
@interface CLAppFeedbackWindowController ()<NSWindowDelegate>
@property (weak) IBOutlet NSTextField *nameField;
@property (weak) IBOutlet NSTextField *emailField;
@property (unsafe_unretained) IBOutlet NSTextView *feedbackTextView;
@ -38,12 +38,6 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
- (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;
@ -85,9 +79,9 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
PFObject *feedbackObject = [PFObject objectWithClassName:CLParseAppFeedbackClassIdentifier];
feedbackObject[CLParseAppFeedbackNameProperty] = (self.nameField.stringValue.length > 0) ?
self.nameField.stringValue : CLParseAppFeedbackNoResponseString;
self.nameField.stringValue : CLParseAppFeedbackNoResponseString;
feedbackObject[CLParseAppFeedbackEmailProperty] = (self.emailField.stringValue.length > 0) ?
self.emailField.stringValue : CLParseAppFeedbackNoResponseString;
self.emailField.stringValue : CLParseAppFeedbackNoResponseString;
feedbackObject[CLParseAppFeedbackFeedbackProperty] = self.feedbackTextView.string;
[feedbackObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
self.activityInProgress = NO;
@ -102,19 +96,19 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
}
else
{
NSAlert *alert = [[NSAlert alloc] init];
NSAlert *alert = [NSAlert new];
alert.messageText = CLFeedbackAlertTitle;
alert.informativeText = CLFeedbackAlertInformativeText;
[alert addButtonWithTitle:CLFeedbackAlertButtonTitle];
[alert beginSheetModalForWindow:self.window
completionHandler:^(NSModalResponse returnCode) {
[self.window close];
}];
completionHandler:^(NSModalResponse returnCode) {
[self.window close];
}];
}
}];
}
- (void)cleanUp
@ -134,14 +128,14 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
self.emailField.stringValue = CLEmptyString;
self.feedbackTextView.string = CLEmptyString;
self.activityInProgress = NO;
for (NSWindow *window in [NSApplication sharedApplication].windows)
{
[[NSApplication sharedApplication].windows enumerateObjectsUsingBlock:^(NSWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) {
if ([window.windowController isMemberOfClass:[CLOneWindowController class]]) {
[window makeKeyAndOrderFront:self];
[NSApp activateIgnoringOtherApps:YES];
}
}
}];
}
@end

2
Clocker/Appearance Tab/CLAppearanceView.xib

@ -227,8 +227,8 @@
</segments>
</segmentedCell>
<connections>
<binding destination="WGI-5h-l6M" name="selectedIndex" keyPath="values.showPlaceName" id="374-hG-giL"/>
<binding destination="-2" name="enabled" keyPath="self.enableOptions" id="g8k-2L-2XR"/>
<binding destination="WGI-5h-l6M" name="selectedIndex" keyPath="values.showCityName" id="FYy-NU-cIr"/>
</connections>
</segmentedControl>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="X5s-Mc-Yfo">

2
Clocker/Appearance Tab/CLAppearanceViewController.h

@ -11,6 +11,4 @@
@interface CLAppearanceViewController : NSViewController
@property (assign, nonatomic) BOOL enableOptions;
@end

2
Clocker/Appearance Tab/CLAppearanceViewController.m

@ -15,8 +15,8 @@
@interface CLAppearanceViewController ()
@property (weak) IBOutlet NSSegmentedControl *timeFormat;
@property (weak) IBOutlet NSSegmentedControl *theme;
@property (weak) IBOutlet NSSegmentedControl *menuOptions;
@property (weak) IBOutlet NSTextField *informationLabel;
@property (assign, nonatomic) BOOL enableOptions;
@end

29
Clocker/ApplicationDelegate.m

@ -68,8 +68,6 @@ void *kContextActivePanel = &kContextActivePanel;
+ (void)initialize
{
//Configure iRate
[iRate sharedInstance].appStoreID = 1056643111;
[iVersion sharedInstance].appStoreID = 1056643111;
[iRate sharedInstance].useAllAvailableLanguages = NO;
[iVersion sharedInstance].useAllAvailableLanguages = NO;
[[iRate sharedInstance] setVerboseLogging:YES];
@ -81,17 +79,18 @@ void *kContextActivePanel = &kContextActivePanel;
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
BOOL startedAtLogin = NO;
NSArray *apps = [[NSWorkspace sharedWorkspace] runningApplications];
for (NSRunningApplication *app in apps) {
__block BOOL startedAtLogin = NO;
[[NSWorkspace sharedWorkspace].runningApplications enumerateObjectsUsingBlock:^(NSRunningApplication * _Nonnull app, NSUInteger idx, BOOL * _Nonnull stop) {
if ([app.bundleIdentifier isEqualToString:helperAppBundleIdentifier]) startedAtLogin = YES;
}
}];
if (startedAtLogin) {
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:terminateNotification
object:[[NSBundle mainBundle] bundleIdentifier]];
object:[[NSBundle mainBundle] bundleIdentifier]];
}
@ -125,20 +124,20 @@ void *kContextActivePanel = &kContextActivePanel;
[[NSUserDefaults standardUserDefaults] setObject:@1 forKey:CLShowDateInMenu];
}
NSNumber *showCityInMenu = [[NSUserDefaults standardUserDefaults] objectForKey:CLShowCityInMenu];
NSNumber *showCityInMenu = [[NSUserDefaults standardUserDefaults] objectForKey:CLShowPlaceInMenu];
if (showCityInMenu == nil) {
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:CLShowCityInMenu];
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:CLShowPlaceInMenu];
}
NSNumber *startClockerAtLogin = [[NSUserDefaults standardUserDefaults] objectForKey:@"startAtLogin"];
NSNumber *startClockerAtLogin = [[NSUserDefaults standardUserDefaults] objectForKey:CLStartAtLogin];
if (startClockerAtLogin == nil) {
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"startAtLogin"];
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:CLStartAtLogin];
}
NSString *onboarding = [[NSUserDefaults standardUserDefaults] objectForKey:@"initialLaunch"];
// Install icon into the menu bar
self.menubarController = [[MenubarController alloc] init];
self.menubarController = [MenubarController new];
if (onboarding == nil)
{
@ -164,6 +163,8 @@ void *kContextActivePanel = &kContextActivePanel;
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
// Explicitly remove the icon from the menu bar

13
Clocker/CLMainWindowController.h

@ -0,0 +1,13 @@
//
// CLMainWindowController.h
// Clocker
//
// Created by Abhishek Banthia on 2/7/16.
//
//
#import <Cocoa/Cocoa.h>
@interface CLMainWindowController : NSWindowController
@end

30
Clocker/CLMainWindowController.m

@ -0,0 +1,30 @@
//
// CLMainWindowController.m
// Clocker
//
// Created by Abhishek Banthia on 2/7/16.
//
//
#import "CLMainWindowController.h"
@interface CLMainWindowController ()
@end
@implementation CLMainWindowController
- (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;
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}
@end

4
Clocker/CLOneWindow/CLOneWindowController.h

@ -12,11 +12,7 @@
#import "CLAppearanceViewController.h"
@interface CLOneWindowController : NSWindowController
@property (strong, nonatomic) CLPreferencesViewController *preferencesView;
@property (strong, nonatomic) CLAboutUsViewController *aboutUsView;
@property (strong, nonatomic) CLAppearanceViewController *appearanceView;
+ (instancetype)sharedWindow;
@end

4
Clocker/CLOneWindow/CLOneWindowController.m

@ -16,6 +16,10 @@ NSString *const CLAppearenceViewNibIdentifier = @"CLAppearanceView";
@interface CLOneWindowController ()
@property (strong, nonatomic) CLAboutUsViewController *aboutUsView;
@property (strong, nonatomic) CLAppearanceViewController *appearanceView;
@end
@implementation CLOneWindowController

4
Clocker/Clocker-Info.plist

@ -13,11 +13,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.2</string>
<string>1.2.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>19</string>
<string>20</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>

2
Clocker/Custom Table Cell Views/CLTimezoneCellView.h

@ -13,7 +13,7 @@
@property (weak) IBOutlet NSTextField *customName;
@property (weak) IBOutlet NSTextField *relativeDate;
@property (weak) IBOutlet NSTextField *time;
@property (nonatomic) NSInteger rowNumber;
@property (nonatomic, assign) NSInteger rowNumber;
- (void)updateTextColorWithColor:(NSColor *)color andCell:(CLTimezoneCellView*)cell;
- (void)setUpAutoLayoutWithCell:(CLTimezoneCellView *)cell;

25
Clocker/Custom Table Cell Views/CLTimezoneCellView.m

@ -22,15 +22,14 @@
- (IBAction)labelDidChange:(id)sender
{
NSTextField *customLabelCell = (NSTextField*) sender;
PanelController *panelController;
__block PanelController *panelController;
for (NSWindow *window in [[NSApplication sharedApplication] windows])
{
[[[NSApplication sharedApplication] windows] enumerateObjectsUsingBlock:^(NSWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) {
if ([window.windowController isMemberOfClass:[PanelController class]])
{
panelController = window.windowController;
}
}
}];
NSString *originalValue = customLabelCell.stringValue;
NSString *customLabelValue = [originalValue stringByTrimmingCharactersInSet:
@ -41,14 +40,16 @@
CLTimezoneCellView *cellView = (CLTimezoneCellView *)[sender superview];
NSData *dataObject = panelController.defaultPreferences[cellView.rowNumber];
CLTimezoneData *timezoneObject = [CLTimezoneData getCustomObject:dataObject];
for (NSData *object in panelController.defaultPreferences)
{
[panelController.defaultPreferences enumerateObjectsUsingBlock:^(id _Nonnull object, NSUInteger idx, BOOL * _Nonnull stop) {
CLTimezoneData *timeObject = [CLTimezoneData getCustomObject:object];
if ([timeObject.formattedAddress isEqualToString:customLabelValue]) {
timeObject.customLabel = CLEmptyString;
}
}
}];
timezoneObject.customLabel = (customLabelValue.length > 0) ? customLabelValue : CLEmptyString;
NSData *newObject = [NSKeyedArchiver archivedDataWithRootObject:timezoneObject];
@ -77,13 +78,15 @@
CGFloat width = [cell.relativeDate.stringValue
sizeWithAttributes: @{NSFontAttributeName:cell.relativeDate.font}].width;
for (NSLayoutConstraint *constraint in cell.relativeDate.constraints)
{
[cell.relativeDate.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint * _Nonnull constraint, NSUInteger idx, BOOL * _Nonnull stop) {
if (constraint.constant > 20)
{
constraint.constant = width+8;
}
}
}];
}
@end

31
Clocker/Model/CLTimezoneData.m

@ -19,7 +19,9 @@
-(instancetype)initWithDictionary:(NSDictionary *)dictionary
{
if (self == [super init])
self = [super init];
if (self)
{
self.customLabel = dictionary[CLCustomLabel];
self.timezoneID = dictionary[CLTimezoneID];
@ -35,7 +37,7 @@
+ (void)setInitialTimezoneData
{
CLTimezoneData *newData = [[self alloc] init];
CLTimezoneData *newData = [self new];
newData.timezoneID = [[NSTimeZone systemTimeZone] name];
newData.formattedAddress = newData.timezoneID;
@ -78,7 +80,9 @@
- (instancetype)initWithCoder:(NSCoder *)coder
{
if (self == [super init])
self = [super init];
if (self)
{
self.place_id = [coder decodeObjectForKey:@"place_id"];
self.formattedAddress = [coder decodeObjectForKey:@"formattedAddress"];
@ -179,7 +183,7 @@
value:futureSliderValue
toDate:[NSDate date]
options:kNilOptions];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.dateStyle = kCFDateFormatterNoStyle;
NSNumber *is24HourFormatSelected = [[NSUserDefaults standardUserDefaults] objectForKey:CL24hourFormatSelectedKey];
@ -194,7 +198,7 @@
- (NSString *)getLocalCurrentDate
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.dateStyle = kCFDateFormatterShortStyle;
dateFormatter.timeStyle = kCFDateFormatterNoStyle;
dateFormatter.timeZone = [NSTimeZone systemTimeZone];
@ -207,7 +211,7 @@
- (NSString *)compareSystemDate:(NSString *)systemDate toTimezoneDate:(NSString *)date
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
NSDateFormatter *formatter = [NSDateFormatter new];
formatter.dateFormat = [NSDateFormatter dateFormatFromTemplate:@"MM/dd/yyyy"
options:0
locale:[NSLocale currentLocale]];
@ -231,7 +235,7 @@
comps.day = comps.day + 1;
NSDate *tomorrowMidnight = [[NSCalendar currentCalendar] dateFromComponents:comps];
CLTimezoneData *newDataObject = [[CLTimezoneData alloc] init];
CLTimezoneData *newDataObject = [CLTimezoneData new];
newDataObject.timezoneID = self.timezoneID;
newDataObject.formattedAddress = self.formattedAddress;
newDataObject.latitude = self.latitude;
@ -241,15 +245,14 @@
newDataObject.nextUpdate = tomorrowMidnight;
newDataObject.isFavourite = [NSNumber numberWithInt:NSOffState];
PanelController *panelController;
__block PanelController *panelController;
for (NSWindow *window in [[NSApplication sharedApplication] windows])
{
[[NSApplication sharedApplication].windows enumerateObjectsUsingBlock:^(NSWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) {
if ([window.windowController isMemberOfClass:[PanelController class]])
{
panelController = window.windowController;
}
}
}];
[panelController.defaultPreferences replaceObjectAtIndex:[panelController.defaultPreferences indexOfObject:self] withObject:newDataObject];
[[NSUserDefaults standardUserDefaults] setObject:panelController.defaultPreferences forKey:CLDefaultPreferenceKey];
@ -281,7 +284,7 @@
value:futureSliderValue
toDate:[NSDate date]
options:kNilOptions];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.dateStyle = kCFDateFormatterShortStyle;
dateFormatter.timeStyle = kCFDateFormatterNoStyle;
@ -294,7 +297,7 @@
}
else
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
NSDateFormatter *formatter = [NSDateFormatter new];
formatter.dateFormat = [NSDateFormatter dateFormatFromTemplate:@"MM/dd/yyyy" options:0 locale:[NSLocale currentLocale]];
NSDate *convertedDate = [formatter dateFromString:[dateFormatter stringFromDate:newDate]];
@ -350,7 +353,7 @@
{
NSMutableString *menuTitle = [NSMutableString new];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSNumber *shouldCityBeShown = [userDefaults objectForKey:CLShowCityInMenu];
NSNumber *shouldCityBeShown = [userDefaults objectForKey:CLShowPlaceInMenu];
NSNumber *shouldDayBeShown = [userDefaults objectForKey:CLShowDayInMenu];
NSNumber *shouldDateBeShown = [userDefaults objectForKey:CLShowDateInMenu];

1
Clocker/Onboarding/CLOnboardingWindow.xib

@ -6,6 +6,7 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="CLOnboardingWindowController">
<connections>
<outlet property="titleLabel" destination="oiI-iN-JcW" id="QZa-pU-xDz"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
</connections>
</customObject>

5
Clocker/Onboarding/CLOnboardingWindowController.h

@ -8,10 +8,9 @@
#import <Cocoa/Cocoa.h>
#import "CLIntroViewController.h"
#import "CLMainWindowController.h"
@interface CLOnboardingWindowController : NSWindowController
@property (strong, nonatomic) CLIntroViewController *introViewController;
@interface CLOnboardingWindowController : CLMainWindowController
+ (instancetype)sharedWindow;

9
Clocker/Onboarding/CLOnboardingWindowController.m

@ -11,6 +11,8 @@
@interface CLOnboardingWindowController ()
@property (strong, nonatomic) CLIntroViewController *introViewController;
@end
static CLOnboardingWindowController *sharedOnboardingWindow;
@ -19,12 +21,7 @@ static CLOnboardingWindowController *sharedOnboardingWindow;
- (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];

1
Clocker/Panel.xib

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>

8
Clocker/PanelController.m

@ -82,7 +82,7 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
if (!self.dateFormatter)
{
self.dateFormatter = [[NSDateFormatter alloc] init];
self.dateFormatter = [NSDateFormatter new];
}
if ([[[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey] isEqualToString:@"Black"]) {
@ -400,12 +400,14 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
[[NSUserDefaults standardUserDefaults] setObject:self.defaultPreferences
forKey:CLDefaultPreferenceKey];
for (NSWindow *window in [NSApplication sharedApplication].windows) {
[[NSApplication sharedApplication].windows enumerateObjectsUsingBlock:^(NSWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) {
if ([window.windowController isMemberOfClass:[CLOneWindowController class]]) {
CLOneWindowController *ref = (CLOneWindowController *) window.windowController;
[ref.preferencesView refereshTimezoneTableView];
}
}
}];
[self.mainTableview reloadData];

8
Clocker/Preferences/CLPreferencesViewController.h

@ -15,15 +15,7 @@ typedef enum : NSUInteger {
@interface CLPreferencesViewController : NSViewController
@property (strong, nonatomic) NSMutableArray *selectedTimeZones;
@property (strong, nonatomic) NSMutableArray *filteredArray;
@property (atomic, assign) BOOL launchOnLogin;
@property (nonatomic, strong) NSMutableArray *timeZoneArray;
@property (nonatomic, strong) NSMutableArray *timeZoneFilteredArray;
@property (nonatomic, strong) NSString *columnName;
@property (atomic, strong) NSArray *themes;
@property (nonatomic, strong) NSURLSessionDataTask *dataTask;
- (void)refereshTimezoneTableView;

44
Clocker/Preferences/CLPreferencesViewController.m

@ -38,6 +38,14 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
@interface CLPreferencesViewController ()
@property (weak) IBOutlet NSTextField *placeholderLabel;
@property (assign) BOOL activityInProgress;
@property (strong, nonatomic) NSMutableArray *selectedTimeZones;
@property (strong, nonatomic) NSMutableArray *filteredArray;
@property (atomic, assign) BOOL launchOnLogin;
@property (nonatomic, strong) NSMutableArray *timeZoneArray;
@property (nonatomic, strong) NSMutableArray *timeZoneFilteredArray;
@property (nonatomic, copy) NSString *columnName;
@property (atomic, copy) NSArray *themes;
@property (nonatomic, strong) NSURLSessionDataTask *dataTask;
@property (weak) IBOutlet NSTableView *timezoneTableView;
@property (strong) IBOutlet Panel *timezonePanel;
@ -220,13 +228,14 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
{
NSMutableArray *newArray = [NSMutableArray new];
for (NSData *object in self.selectedTimeZones)
[self.selectedTimeZones enumerateObjectsUsingBlock:^(NSData * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop)
{
CLTimezoneData *timezone = [CLTimezoneData getCustomObject:object];
timezone.isFavourite = [NSNumber numberWithInt:0];
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:timezone];
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:timezone];
[newArray addObject:encodedObject];
}
}];
CLTimezoneData *dataObject = [CLTimezoneData getCustomObject:newArray[row]];
dataObject.isFavourite = object;
@ -290,8 +299,8 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
{
CLTimezoneData *dataObject = self.filteredArray[self.availableTimezoneTableView.selectedRow];
for (NSData *encodedData in self.selectedTimeZones)
{
[self.selectedTimeZones enumerateObjectsUsingBlock:^(NSData * _Nonnull encodedData, NSUInteger idx, BOOL * _Nonnull stop) {
CLTimezoneData *timezoneObject = [CLTimezoneData getCustomObject:encodedData];
NSString *name = timezoneObject.place_id;
@ -310,7 +319,9 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
return;
}
}
}
}];
self.searchField.stringValue = CLEmptyString;
@ -338,7 +349,7 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
if (defaultPreference == nil)
{
defaultPreference = [[NSMutableArray alloc] init];
defaultPreference = [NSMutableArray new];
}
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:data];
@ -559,6 +570,10 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
[self.dataTask cancel];
}
NSString *preferredLanguage = [[[NSBundle mainBundle]preferredLocalizations][0] substringToIndex:2];
NSLog(@"Preferred Language:%@", preferredLanguage);
dispatch_async(dispatch_get_main_queue(), ^{
if (self.availableTimezoneTableView.isHidden)
@ -609,8 +624,8 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
return;
}
for (NSDictionary *dictionary in json[@"results"])
{
[json[@"results"] enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull dictionary, NSUInteger idx, BOOL * _Nonnull stop) {
NSDictionary *latLang = [[dictionary objectForKey:@"geometry"] objectForKey:@"location"];
NSString *latitude = latLang[@"lat"];
NSString *longitude = latLang[@"lng"];
@ -626,8 +641,8 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
CLTimezoneData *newObject = [[CLTimezoneData alloc] initWithDictionary:totalPackage];
[self.filteredArray addObject:newObject];
}
}];
self.activityInProgress = NO;
[self.availableTimezoneTableView reloadData];
@ -655,7 +670,6 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
return;
}
self.searchField.placeholderString = @"Fetching data might take some time!";
self.placeholderLabel.placeholderString = @"Retrieving timezone data";
@ -718,17 +732,13 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
[newTimezone setObject:CLEmptyString forKey:@"nextUpdate"];
[newTimezone setObject:CLEmptyString forKey:CLCustomLabel];
CLTimezoneData *timezoneObject = [[CLTimezoneData alloc] initWithDictionary:newTimezone];
NSArray *defaultPreference = [[NSUserDefaults standardUserDefaults] objectForKey:CLDefaultPreferenceKey];
if (defaultPreference == nil)
{
defaultPreference = [[NSMutableArray alloc] init];
defaultPreference = [NSMutableArray new];
}
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:timezoneObject];

18
Clocker/Rate App/iRate.m

@ -937,10 +937,20 @@ static NSString *const iRateMacAppStoreURLFormat = @"macappstore://itunes.apple.
#endif
{
PanelController *panelRef = (PanelController *)[[[NSApplication sharedApplication]
mainWindow] windowController];
panelRef.showReviewCell = YES;
[panelRef updateDefaultPreferences];
NSArray *currentWindows = [NSApplication sharedApplication].windows;
for (NSWindow *window in currentWindows)
{
if ([window.windowController isKindOfClass:[PanelController class]])
{
PanelController *panelRef = (PanelController *)[[[NSApplication sharedApplication]
mainWindow] windowController];
panelRef.showReviewCell = YES;
[panelRef updateDefaultPreferences];
}
}
}
#endif

2
Clocker/StatusItemView.m

@ -65,9 +65,7 @@
[super drawRect:dirtyRect];
NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, self.frame.size.width, 18)];
textField.bordered = NO;
textField.alignment = NSTextAlignmentCenter;
NSData *dataObject = [[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteTimezone"];

3
Clocker/Utilities/CommonStrings.h

@ -23,7 +23,8 @@ extern NSString *const CLRelativeDateKey;
extern NSString *const CLThemeKey;
extern NSString *const CLShowDayInMenu;
extern NSString *const CLShowDateInMenu;
extern NSString *const CLShowCityInMenu;
extern NSString *const CLShowPlaceInMenu;
extern NSString *const CLDisplayFutureSliderKey;
extern NSString *const CLStartAtLogin;
@end

4
Clocker/Utilities/CommonStrings.m

@ -24,6 +24,8 @@ NSString *const CLThemeKey = @"defaultTheme";
NSString *const CLDisplayFutureSliderKey = @"displayFutureSlider";
NSString *const CLShowDayInMenu = @"showDay";
NSString *const CLShowDateInMenu = @"showDate";
NSString *const CLShowCityInMenu = @"showCityName";
NSString *const CLShowPlaceInMenu = @"showPlaceName";
NSString *const CLStartAtLogin = @"startAtLogin";
@end

Loading…
Cancel
Save