Browse Source

Constants!

v1.2.1
Abhishek Banthia 9 years ago
parent
commit
1c7ebce75e
  1. BIN
      Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate
  2. 16
      Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 29
      Clocker/App Feedback/CLAppFeedbackWindowController.m
  4. 1
      Clocker/Appearance Tab/CLAppearanceViewController.h
  5. 27
      Clocker/Appearance Tab/CLAppearanceViewController.m
  6. 13
      Clocker/ApplicationDelegate.m
  7. 3
      Clocker/BackgroundView.m
  8. 10
      Clocker/CLOneWindow/CLOneWindowController.m
  9. 2
      Clocker/CLRatingCellView.h
  10. 41
      Clocker/CLRatingCellView.m
  11. 3
      Clocker/Custom Slider/CLCustomSliderCell.m
  12. 10
      Clocker/Custom Table Cell Views/CLTimezoneCellView.m
  13. 5
      Clocker/Model/CLTimezoneData.m
  14. 9
      Clocker/Panel.xib
  15. 18
      Clocker/PanelController.m
  16. 43
      Clocker/Preferences/CLPreferencesViewController.m
  17. 2
      Clocker/Utilities/CommonStrings.h
  18. 2
      Clocker/Utilities/CommonStrings.m

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

Binary file not shown.

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

@ -13,5 +13,21 @@
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Clocker/ColoredButton.m"
timestampString = "472878895.200904"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "40"
endingLineNumber = "40"
landmarkName = "-setButtonTitleFor:toString:withColor:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

29
Clocker/App Feedback/CLAppFeedbackWindowController.m

@ -12,6 +12,15 @@
#import "CommonStrings.h"
NSString *const CLAppFeedbackNibIdentifier = @"CLAppFeedbackWindow";
NSString *const CLParseAppFeedbackClassIdentifier = @"CLAppFeedback";
NSString *const CLParseAppFeedbackNoResponseString = @"Not Provided";
NSString *const CLParseAppFeedbackNameProperty = @"name";
NSString *const CLParseAppFeedbackEmailProperty = @"email";
NSString *const CLParseAppFeedbackFeedbackProperty = @"feedback";
NSString *const CLFeedbackAlertTitle = @"Thank you for helping make Clocker even better!";
NSString *const CLFeedbackAlertInformativeText = @"We owe you a candy. 😇";
NSString *const CLFeedbackAlertButtonTitle = @"Close";
NSString *const CLFeedbackNotEnteredErrorMessage = @"Please enter some feedback.";
static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
@ -64,7 +73,7 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
if (self.feedbackTextView.string.length == 0)
{
self.informativeText.stringValue = @"Yo, enter some feedback!";
self.informativeText.stringValue = CLFeedbackNotEnteredErrorMessage;
[NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(cleanUp)
@ -74,12 +83,12 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
return;
}
PFObject *feedbackObject = [PFObject objectWithClassName:@"CLAppFeedback"];
feedbackObject[@"name"] = (self.nameField.stringValue.length > 0) ?
self.nameField.stringValue : @"Not Provided";
feedbackObject[@"email"] = (self.emailField.stringValue.length > 0) ?
self.emailField.stringValue : @"Not Provided";
feedbackObject[@"feedback"] = self.feedbackTextView.string;
PFObject *feedbackObject = [PFObject objectWithClassName:CLParseAppFeedbackClassIdentifier];
feedbackObject[CLParseAppFeedbackNameProperty] = (self.nameField.stringValue.length > 0) ?
self.nameField.stringValue : CLParseAppFeedbackNoResponseString;
feedbackObject[CLParseAppFeedbackEmailProperty] = (self.emailField.stringValue.length > 0) ?
self.emailField.stringValue : CLParseAppFeedbackNoResponseString;
feedbackObject[CLParseAppFeedbackFeedbackProperty] = self.feedbackTextView.string;
[feedbackObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
self.activityInProgress = NO;
if (!succeeded) {
@ -94,9 +103,9 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
else
{
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"Thank you for helping make Clocker even better!";
alert.informativeText = @"We owe you a candy. 😇";
[alert addButtonWithTitle:@"Close"];
alert.messageText = CLFeedbackAlertTitle;
alert.informativeText = CLFeedbackAlertInformativeText;
[alert addButtonWithTitle:CLFeedbackAlertButtonTitle];
[alert beginSheetModalForWindow:self.window
completionHandler:^(NSModalResponse returnCode) {
[self.window close];

1
Clocker/Appearance Tab/CLAppearanceViewController.h

@ -10,6 +10,5 @@
@interface CLAppearanceViewController : NSViewController
@property (atomic, strong) NSArray *fontFamilies;
@end

27
Clocker/Appearance Tab/CLAppearanceViewController.m

@ -27,31 +27,6 @@
[self.view setWantsLayer:YES]; // view's backing store is using a Core Animation Layer
[self.view setLayer:viewLayer];
//Certain fonts don't look good with constraints set
NSMutableArray *availableFonts = [[NSMutableArray alloc] init];
NSFontCollection *fontCollection = [NSFontCollection fontCollectionWithName:@"com.apple.UserFonts"];
for (NSFontDescriptor *descriptor in fontCollection.matchingDescriptors) {
if ([descriptor objectForKey:@"NSFontFamilyAttribute"]) {
if (![availableFonts containsObject:[descriptor objectForKey:@"NSFontFamilyAttribute"]]) {
[availableFonts addObject:[descriptor objectForKey:@"NSFontFamilyAttribute"]];
}
}
}
NSArray *fontsToRemove = [NSArray arrayWithObjects:@"Apple Chancery", @"Zapfino",
@"Trattatello", @"Noteworthy", @"Arial Black", @"Chalkduster",@"Monoid", @"Andale Mono", @"Courier" ,@"Courier New",@"Geneva",@"Menlo", @"Monaco",@"PT Mono", @"Verdana", nil];
for (NSString *font in fontsToRemove) {
if([availableFonts containsObject:font])
{
[availableFonts removeObject:font];
}
}
[availableFonts insertObject:@"Default" atIndex:0];
self.fontFamilies = [[NSArray alloc] initWithArray:availableFonts];
// Do view setup here.
}
- (IBAction)timeFormatSelectionChanged:(id)sender
@ -88,7 +63,7 @@
{
NSSegmentedControl *relativeDayControl = (NSSegmentedControl*) sender;
NSNumber *selectedIndex = [NSNumber numberWithInteger:relativeDayControl.selectedSegment];
[[NSUserDefaults standardUserDefaults] setObject:selectedIndex forKey:@"relativeDate"];
[[NSUserDefaults standardUserDefaults] setObject:selectedIndex forKey:CLRelativeDateKey];
[self refreshMainTableview];
}

13
Clocker/ApplicationDelegate.m

@ -33,6 +33,9 @@
#import "iVersion.h"
#import <Parse/Parse.h>
NSString *const CLParseApplicationID = @"F2ahd8J6sfjQMCc5z3xSy9kVK94PmKmH6hV2UsUK";
NSString *const CLParseClientID = @"vfnqDtinvmwUBkcifznYHzYTetxN5iMvt8Ey8StD";
@implementation ApplicationDelegate
@synthesize panelController = _panelController;
@ -66,7 +69,7 @@ void *kContextActivePanel = &kContextActivePanel;
[iVersion sharedInstance].appStoreID = 1056643111;
[iRate sharedInstance].useAllAvailableLanguages = NO;
[iVersion sharedInstance].useAllAvailableLanguages = NO;
[[iRate sharedInstance] setVerboseLogging:NO];
[[iRate sharedInstance] setVerboseLogging:YES];
[[iVersion sharedInstance] setVerboseLogging:NO];
}
@ -91,9 +94,9 @@ void *kContextActivePanel = &kContextActivePanel;
[[NSUserDefaults standardUserDefaults] setObject:newDefaults forKey:CLDefaultPreferenceKey];
}
NSString *defaultTheme = [[NSUserDefaults standardUserDefaults] objectForKey:@"defaultTheme"];
NSString *defaultTheme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (defaultTheme == nil) {
[[NSUserDefaults standardUserDefaults] setObject:@"Default" forKey:@"defaultTheme"];
[[NSUserDefaults standardUserDefaults] setObject:@"Default" forKey:CLThemeKey];
}
NSNumber *defaultTimeFormat = [[NSUserDefaults standardUserDefaults] objectForKey:CL24hourFormatSelectedKey];
@ -111,8 +114,8 @@ void *kContextActivePanel = &kContextActivePanel;
//Setting up Parse
[Parse setApplicationId:@"F2ahd8J6sfjQMCc5z3xSy9kVK94PmKmH6hV2UsUK"
clientKey:@"vfnqDtinvmwUBkcifznYHzYTetxN5iMvt8Ey8StD"];
[Parse setApplicationId:CLParseApplicationID
clientKey:CLParseClientID];
// [Optional] Track statistics around application opens.
[PFAnalytics trackAppOpenedWithLaunchOptions:nil];

3
Clocker/BackgroundView.m

@ -37,6 +37,7 @@
#define SEARCH_INSET 10.0f
#import "ApplicationDelegate.h"
#import "PanelController.h"
#import "CommonStrings.h"
#pragma mark -
@ -80,7 +81,7 @@
[path lineToPoint:NSMakePoint(_arrowX - ARROW_WIDTH / 2, NSMaxY(contentRect) - ARROW_HEIGHT)];
[path closePath];
NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:@"defaultTheme"];
NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
[theme isEqualToString:@"Default"] ?
[[NSColor colorWithDeviceRed:255.0f green:255.0f blue:255.0f alpha:FILL_OPACITY] setFill]:
[[NSColor colorWithDeviceRed:0.0f green:0.0f blue:0.0f alpha:FILL_OPACITY] setFill];

10
Clocker/CLOneWindow/CLOneWindowController.m

@ -9,6 +9,10 @@
#import "CLOneWindowController.h"
NSString *const CLOneWindowNibIdentifier = @"CLOneWindow";
NSString *const CLPreferenceViewNibIdentifier = @"CLPreferencesView";
NSString *const CLAboutUsViewNibIdentifier = @"CLAboutUsView";
NSString *const CLAppearenceViewNibIdentifier = @"CLAppearanceView";
@interface CLOneWindowController ()
@ -47,7 +51,7 @@ static CLOneWindowController *sharedWindow = nil;
- (IBAction)openPreferences:(id)sender
{
self.preferencesView = [[CLPreferencesViewController alloc] initWithNibName:@"CLPreferencesView" bundle:nil];
self.preferencesView = [[CLPreferencesViewController alloc] initWithNibName:CLPreferenceViewNibIdentifier bundle:nil];
[self setWindowWithContentView:self.preferencesView.view];
[self.aboutUsView.view removeFromSuperview];
self.aboutUsView = nil;
@ -63,7 +67,7 @@ static CLOneWindowController *sharedWindow = nil;
- (IBAction)openAboutUsView:(id)sender
{
self.aboutUsView = [[CLAboutUsViewController alloc] initWithNibName:@"CLAboutUsView" bundle:nil];
self.aboutUsView = [[CLAboutUsViewController alloc] initWithNibName:CLAboutUsViewNibIdentifier bundle:nil];
[self setWindowWithContentView:self.aboutUsView.view];
[self.preferencesView.view removeFromSuperview];
self.preferencesView = nil;
@ -73,7 +77,7 @@ static CLOneWindowController *sharedWindow = nil;
- (IBAction)openAppearanceView:(id)sender
{
self.appearanceView = [[CLAppearanceViewController alloc] initWithNibName:@"CLAppearanceView" bundle:nil];
self.appearanceView = [[CLAppearanceViewController alloc] initWithNibName:CLAppearenceViewNibIdentifier bundle:nil];
[self setWindowWithContentView:self.appearanceView.view];
[self.preferencesView.view removeFromSuperview];
self.preferencesView = nil;

2
Clocker/CLRatingCellView.h

@ -7,11 +7,13 @@
//
#import <Cocoa/Cocoa.h>
#import "CLAppFeedbackWindowController.h"
@interface CLRatingCellView : NSTableCellView
@property (weak, nonatomic) IBOutlet NSTextField *leftField;
@property (weak, nonatomic) IBOutlet NSButton *leftButton;
@property (weak, nonatomic) IBOutlet NSButton *rightButton;
@property (strong, nonatomic) CLAppFeedbackWindowController *feedbackWindow;
@end

41
Clocker/CLRatingCellView.m

@ -10,10 +10,17 @@
#import "iRate.h"
#import <QuartzCore/QuartzCore.h>
#import "PanelController.h"
#import "CLAppFeedbackWindowController.h"
@implementation CLRatingCellView
NSString *const CLGitHubIssueURL =@"https://github.com/Abhishaker17/Clocker/issues";
NSString *const CLNotReallyButtonTitle = @"Not Really";
NSString *const CLFeedbackString = @"Mind giving feedback?";
NSString *const CLNoThanksTitle = @"No, thanks";
NSString *const CLYesWithQuestionMark = @"Yes?";
NSString *const CLYesWithExclamation = @"Yes!";
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
@ -25,8 +32,11 @@ NSString *const CLGitHubIssueURL =@"https://github.com/Abhishaker17/Clocker/issu
{
NSButton *leftButton = (NSButton *)sender;
if ([leftButton.title isEqualToString:@"Not Really"]) {
[self setAnimatedStringValue:@"Mind giving us feedback?" andTextField:self.leftField withLeftButtonTitle:@"No, thanks" andRightButtonTitle:@"Yes?"];
if ([leftButton.title isEqualToString:CLNotReallyButtonTitle]) {
[self setAnimatedStringValue:CLFeedbackString
andTextField:self.leftField
withLeftButtonTitle:CLNoThanksTitle
andRightButtonTitle:CLYesWithQuestionMark];
}
else
{
@ -43,19 +53,21 @@ NSString *const CLGitHubIssueURL =@"https://github.com/Abhishaker17/Clocker/issu
{
NSButton *rightButton = (NSButton *)sender;
if ([rightButton.title isEqualToString:@"Yes!"]) {
[self setAnimatedStringValue:@"Would you mind rating Clocker?" andTextField:self.leftField withLeftButtonTitle:@"No, thanks" andRightButtonTitle:@"Yes"];
if ([rightButton.title isEqualToString:CLYesWithExclamation]) {
[self setAnimatedStringValue:@"Mind rating us?"
andTextField:self.leftField
withLeftButtonTitle:CLNoThanksTitle
andRightButtonTitle:@"Yes"];
}
else if ([rightButton.title isEqualToString:@"Yes?"])
else if ([rightButton.title isEqualToString:CLYesWithQuestionMark])
{
[self updateMainTableView];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:CLGitHubIssueURL]];
self.feedbackWindow = [CLAppFeedbackWindowController sharedWindow];
[self.feedbackWindow showWindow:nil];
[NSApp activateIgnoringOtherApps:YES];
}
else
{
//Make the row disappear and call rate
[[iRate sharedInstance] rate];
[self updateMainTableView];
}
@ -68,7 +80,10 @@ NSString *const CLGitHubIssueURL =@"https://github.com/Abhishaker17/Clocker/issu
[panelRef updateDefaultPreferences];
}
- (void) setAnimatedStringValue:(NSString *)aString andTextField:(NSTextField *)textfield withLeftButtonTitle:(NSString *)leftTitle andRightButtonTitle:(NSString *)rightTitle
- (void) setAnimatedStringValue:(NSString *)aString
andTextField:(NSTextField *)textfield
withLeftButtonTitle:(NSString *)leftTitle
andRightButtonTitle:(NSString *)rightTitle
{
if ([[textfield stringValue] isEqual: aString])
{
@ -93,9 +108,9 @@ NSString *const CLGitHubIssueURL =@"https://github.com/Abhishaker17/Clocker/issu
[self.leftButton.animator setAlphaValue:1.0];
[self.rightButton.animator setAlphaValue:1.0];
if ([self.leftButton.title isEqualToString:@"Not Really"]) {
[self.leftButton.animator setTitle:@"No, thanks"];
[self.leftButton.animator setTitle:CLNoThanksTitle];
}
if ([self.rightButton.title isEqualToString:@"Yes!"]) {
if ([self.rightButton.title isEqualToString:CLYesWithExclamation]) {
[self.rightButton.animator setTitle:@"Yes, sure"];
}

3
Clocker/Custom Slider/CLCustomSliderCell.m

@ -7,6 +7,7 @@
//
#import "CLCustomSliderCell.h"
#import "CommonStrings.h"
@implementation CLCustomSliderCell
@ -28,7 +29,7 @@
leftRect.size.width = finalWidth;
NSBezierPath* bg = [NSBezierPath bezierPathWithRoundedRect: rect xRadius: barRadius yRadius: barRadius];
NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:@"defaultTheme"];
NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
[theme isEqualToString:@"Black"] ? [NSColor.whiteColor setFill] : [[NSColor colorWithCalibratedRed:67.0/255.0 green:138.0/255.0 blue:250.0/255.0 alpha:1.0] setFill];
[bg fill];

10
Clocker/Custom Table Cell Views/CLTimezoneCellView.m

@ -21,7 +21,15 @@
- (IBAction)labelDidChange:(id)sender
{
NSTextField *customLabelCell = (NSTextField*) sender;
PanelController *panelController = (PanelController *)[[[NSApplication sharedApplication] mainWindow] windowController];
PanelController *panelController;
for (NSWindow *window in [[NSApplication sharedApplication] windows])
{
if ([window.windowController isMemberOfClass:[PanelController class]])
{
panelController = window.windowController;
}
}
NSString *originalValue = customLabelCell.stringValue;
NSString *customLabelValue = [originalValue stringByTrimmingCharactersInSet:

5
Clocker/Model/CLTimezoneData.m

@ -10,4 +10,9 @@
@implementation CLTimezoneData
-(void)initWithDictionary:(NSDictionary *)dictionary
{
}
@end

9
Clocker/Panel.xib

@ -118,15 +118,16 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="gRN-xJ-bfq">
<rect key="frame" x="62" y="30" width="16" height="16"/>
<rect key="frame" x="75" y="30" width="16" height="16"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="ClockerIcon-16" id="8gl-Vi-0VF"/>
</imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsExpansionToolTips="YES" preferredMaxLayoutWidth="110" translatesAutoresizingMaskIntoConstraints="NO" id="JNw-ld-oz9">
<rect key="frame" x="83" y="28" width="114" height="20"/>
<rect key="frame" x="96" y="28" width="154" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="150" id="dBn-va-BvP"/>
<constraint firstAttribute="height" constant="20" id="kOH-Lb-7sB"/>
</constraints>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Enjoy Using Clocker?" id="iM2-CB-CE2">
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Enjoy using Clocker?" id="iM2-CB-CE2">
<font key="font" size="12" name="SFUIDisplay-Regular"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@ -167,7 +168,7 @@
<constraint firstAttribute="bottom" secondItem="gf6-2O-DZv" secondAttribute="bottom" constant="5" id="iqG-ta-N68"/>
<constraint firstAttribute="bottom" secondItem="Kfq-0p-Oqf" secondAttribute="bottom" constant="5" id="k43-mW-Z3z"/>
<constraint firstItem="JNw-ld-oz9" firstAttribute="leading" secondItem="gRN-xJ-bfq" secondAttribute="trailing" constant="7" id="opd-fc-Q5o"/>
<constraint firstItem="JNw-ld-oz9" firstAttribute="centerX" secondItem="wWn-9q-AYl" secondAttribute="centerX" id="yYL-61-BgS"/>
<constraint firstItem="JNw-ld-oz9" firstAttribute="centerX" secondItem="wWn-9q-AYl" secondAttribute="centerX" constant="33.5" id="yYL-61-BgS"/>
</constraints>
<connections>
<outlet property="imageView" destination="gRN-xJ-bfq" id="eNP-AX-syJ"/>

18
Clocker/PanelController.m

@ -56,7 +56,6 @@ NSString *const CLPanelNibIdentifier = @"Panel";
NSString *const CLRatingCellViewIdentifier = @"ratingCellView";
NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
@implementation PanelController
#pragma mark -
@ -85,7 +84,7 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
[self updateDefaultPreferences];
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"defaultTheme"] isEqualToString:@"Black"]) {
if ([[[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey] isEqualToString:@"Black"]) {
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon-White"];
self.preferencesButton.image = [NSImage imageNamed:@"Settings-White"];
}
@ -250,9 +249,6 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
{
openDuration *= 5;
if (shiftOptionPressed)
NSLog(@"Icon is at %@\n\tMenu is on screen %@\n\tWill be animated to %@",
NSStringFromRect(statusRect), NSStringFromRect(screenRect), NSStringFromRect(panelRect));
}
}
@ -302,7 +298,7 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
CLTimezoneCellView *cell = [tableView makeViewWithIdentifier:CLTimezoneCellViewIdentifier owner:self];
NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:@"defaultTheme"];
NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (theme.length > 0 && ![theme isEqualToString:@"Default"])
{
[cell updateTextColorWithColor:[NSColor whiteColor] andCell:cell];
@ -346,13 +342,13 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
}
}
if ([timeZoneDictionary[@"formattedAddress"] length] > 0)
if ([timeZoneDictionary[CLTimezoneName] length] > 0)
{
return timeZoneDictionary[@"formattedAddress"];
return timeZoneDictionary[CLTimezoneName];
}
else if (timeZoneDictionary[@"timezoneID"])
else if (timeZoneDictionary[CLTimezoneID])
{
NSString *timezoneID = timeZoneDictionary[@"timezoneID"];
NSString *timezoneID = timeZoneDictionary[CLTimezoneID];
NSRange range = [timezoneID rangeOfString:@"/"];
if (range.location != NSNotFound)
@ -457,7 +453,7 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
dateFormatter.timeZone = [NSTimeZone timeZoneWithName:timezoneID];
NSNumber *relativeDayPreference = [[NSUserDefaults standardUserDefaults] objectForKey:@"relativeDate"];
NSNumber *relativeDayPreference = [[NSUserDefaults standardUserDefaults] objectForKey:CLRelativeDateKey];
if (relativeDayPreference.integerValue == 0) {
return [self compareSystemDate:[self getLocalCurrentDate] toTimezoneDate:[dateFormatter stringFromDate:newDate]];;
}

43
Clocker/Preferences/CLPreferencesViewController.m

@ -21,6 +21,15 @@ NSString *const CLPreferencesTimezoneNameIdentifier = @"formattedAddress";
NSString *const CLPreferencesAbbreviationIdentifier = @"abbreviation";
NSString *const CLPreferencesCustomLabelIdentifier = @"label";
NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones";
NSString *const CLNoTimezoneSelectedErrorMessage = @"Please select a timezone!";
NSString *const CLMaxTimezonesErrorMessage = @"Maximum 10 timezones allowed!";
NSString *const CLTimezoneAlreadySelectedError = @"Timezone has already been selected!";
NSString *const CLParseTimezoneSelectionClassIdentifier = @"CLTimezoneSelection";
NSString *const CLParseTimezoneNameProperty = @"areaName";
NSString *const CLMaxCharactersReachedError = @"Only 50 characters allowed!";
NSString *const CLNoInternetConnectivityError = @"You're offline, maybe?";
NSString *const CLLocationSearchURL = @"https://maps.googleapis.com/maps/api/geocode/json?address=%@&key=AIzaSyCyf2knCi6KiKuDJLYDBD3Odq5dt4c-_KI";
NSString *const CLTryAgainMessage = @"Try again, maybe?";
@interface CLPreferencesViewController ()
@property (weak) IBOutlet NSTextField *placeholderLabel;
@ -153,7 +162,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
if (self.availableTimezoneTableView.selectedRow == -1)
{
self.messageLabel.stringValue = @"Please select a timezone!";
self.messageLabel.stringValue = CLNoTimezoneSelectedErrorMessage;
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(clearLabel) userInfo:nil repeats:NO];
self.activityInProgress = NO;
return;
@ -163,7 +172,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
if (self.selectedTimeZones.count >= 10)
{
self.messageLabel.stringValue = @"Maximum 10 timezones allowed!";
self.messageLabel.stringValue = CLMaxTimezonesErrorMessage;
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(clearLabel) userInfo:nil repeats:NO];
self.activityInProgress = NO;
return;
@ -171,14 +180,14 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
for (NSDictionary *timezoneDictionary in self.selectedTimeZones)
{
NSString *name = timezoneDictionary[@"place_id"];
NSString *selectedPlaceID = [self.filteredArray[self.availableTimezoneTableView.selectedRow] objectForKey:@"place_id"];
NSString *name = timezoneDictionary[CLPlaceIdentifier];
NSString *selectedPlaceID = [self.filteredArray[self.availableTimezoneTableView.selectedRow] objectForKey:CLPlaceIdentifier];
if (self.searchField.stringValue.length > 0) {
if ([name isKindOfClass:[NSString class]] &&
[name isEqualToString:selectedPlaceID])
{
self.messageLabel.stringValue = @"Timezone has already been selected!";
self.messageLabel.stringValue = CLTimezoneAlreadySelectedError;
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(clearLabel) userInfo:nil repeats:NO];
self.activityInProgress = NO;
return;
@ -193,8 +202,8 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
[self getTimeZoneForLatitude:[self.filteredArray[self.availableTimezoneTableView
.selectedRow] objectForKey:@"latitude"]andLongitude:[self.filteredArray[self.availableTimezoneTableView.selectedRow] objectForKey:@"longitude"]];
PFObject *feedbackObject = [PFObject objectWithClassName:@"CLTimezoneSelection"];
feedbackObject[@"areaName"] = [self.filteredArray[self.availableTimezoneTableView.selectedRow] objectForKey:@"formattedAddress"];
PFObject *feedbackObject = [PFObject objectWithClassName:CLParseTimezoneSelectionClassIdentifier];
feedbackObject[CLParseTimezoneNameProperty] = [self.filteredArray[self.availableTimezoneTableView.selectedRow] objectForKey:CLTimezoneName];
[feedbackObject saveEventually];
@ -266,7 +275,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
if (self.searchField.stringValue.length > 50)
{
self.activityInProgress = NO;
self.messageLabel.stringValue = @"Only 50 characters allowed!";
self.messageLabel.stringValue = CLMaxCharactersReachedError;
[NSTimer scheduledTimerWithTimeInterval:10
target:self
selector:@selector(clearLabel)
@ -373,7 +382,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
if (networkStatus == NotReachable)
{
self.placeholderLabel.placeholderString = @"You're offline, maybe?";
self.placeholderLabel.placeholderString = CLNoInternetConnectivityError;
return;
}
@ -382,9 +391,9 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
self.placeholderLabel.placeholderString = [NSString stringWithFormat:@"Searching for '%@'", searchString];
NSArray* words = [searchString componentsSeparatedByCharactersInSet :[NSCharacterSet whitespaceAndNewlineCharacterSet]];
searchString = [words componentsJoinedByString:@""];
searchString = [words componentsJoinedByString:CLEmptyString];
NSString *urlString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/geocode/json?address=%@&key=AIzaSyCyf2knCi6KiKuDJLYDBD3Odq5dt4c-_KI", searchString];
NSString *urlString = [NSString stringWithFormat:CLLocationSearchURL, searchString];
NSURL *url = [NSURL URLWithString:urlString];
@ -432,9 +441,9 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
NSDictionary *totalPackage = @{@"latitude":latitude,
@"longitude" : longitude,
CLTimezoneName:formattedAddress,
@"customLabel" : @"",
@"timezoneID" : @"",
CLPlaceIdentifier : dictionary[@"place_id"]};
CLCustomLabel: CLEmptyString,
CLTimezoneID : CLEmptyString,
CLPlaceIdentifier : dictionary[CLPlaceIdentifier]};
[self.filteredArray addObject:totalPackage];
}
@ -449,7 +458,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
{
dispatch_async(dispatch_get_main_queue(), ^{
self.placeholderLabel.placeholderString = [error.localizedDescription isEqualToString:@"The Internet connection appears to be offline."] ?
@"You're offline, maybe?" : @"Try again, maybe?";
CLNoInternetConnectivityError : CLTryAgainMessage;
self.activityInProgress = NO;
});
@ -470,7 +479,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
if (networkStatus == NotReachable)
{
dispatch_async(dispatch_get_main_queue(), ^{
self.placeholderLabel.placeholderString = @"You're offline, maybe?";
self.placeholderLabel.placeholderString = CLNoInternetConnectivityError;
self.activityInProgress = NO;
self.filteredArray = [NSMutableArray array];
[self.availableTimezoneTableView reloadData];
@ -570,7 +579,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
else
{
self.placeholderLabel.placeholderString = [error.localizedDescription isEqualToString:@"The Internet connection appears to be offline."] ?
@"You're offline, maybe?" : @"Try again, maybe?";
CLNoInternetConnectivityError : CLTryAgainMessage;
self.activityInProgress = NO;
}

2
Clocker/Utilities/CommonStrings.h

@ -19,5 +19,7 @@ extern NSString *const CLDragSessionKey;
extern NSString *const CLCustomLabelChangedNotification;
extern NSString *const CLTimezoneID;
extern NSString *const CLPlaceIdentifier;
extern NSString *const CLRelativeDateKey;
extern NSString *const CLThemeKey;
@end

2
Clocker/Utilities/CommonStrings.m

@ -19,5 +19,7 @@ NSString *const CLCustomLabel = @"customLabel";
NSString *const CL24hourFormatSelectedKey = @"is24HourFormatSelected";
NSString *const CLDragSessionKey = @"public.text";
NSString *const CLCustomLabelChangedNotification = @"CLCustomLabelChangedNotification";
NSString *const CLRelativeDateKey = @"relativeDate";
NSString *const CLThemeKey = @"defaultTheme";
@end

Loading…
Cancel
Save