Browse Source

Local language search and indentation!

v1.2.3
Abhishek Banthia 9 years ago
parent
commit
c2a154139a
  1. 18
      Clocker/Preferences/CLPreferencesViewController.m

18
Clocker/Preferences/CLPreferencesViewController.m

@ -31,7 +31,7 @@ NSString *const CLParseTimezoneSelectionClassIdentifier = @"CLTimezoneSelection"
NSString *const CLParseTimezoneNameProperty = @"areaName"; NSString *const CLParseTimezoneNameProperty = @"areaName";
NSString *const CLMaxCharactersReachedError = @"Only 50 characters allowed!"; NSString *const CLMaxCharactersReachedError = @"Only 50 characters allowed!";
NSString *const CLNoInternetConnectivityError = @"You're offline, maybe?"; NSString *const CLNoInternetConnectivityError = @"You're offline, maybe?";
NSString *const CLLocationSearchURL = @"https://maps.googleapis.com/maps/api/geocode/json?address=%@&key=AIzaSyCyf2knCi6KiKuDJLYDBD3Odq5dt4c-_KI"; NSString *const CLLocationSearchURL = @"https://maps.googleapis.com/maps/api/geocode/json?address=%@&key=AIzaSyCyf2knCi6KiKuDJLYDBD3Odq5dt4c-_KI&language=%@";
NSString *const CLTimezoneSearchURL = @"https://maps.googleapis.com/maps/api/timezone/json?location=%@&timestamp=%f&key=AIzaSyCyf2knCi6KiKuDJLYDBD3Odq5dt4c-_KI"; NSString *const CLTimezoneSearchURL = @"https://maps.googleapis.com/maps/api/timezone/json?location=%@&timestamp=%f&key=AIzaSyCyf2knCi6KiKuDJLYDBD3Odq5dt4c-_KI";
NSString *const CLTryAgainMessage = @"Try again, maybe?"; NSString *const CLTryAgainMessage = @"Try again, maybe?";
@ -222,6 +222,13 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
[self.selectedTimeZones replaceObjectAtIndex:row withObject:encodedObject]; [self.selectedTimeZones replaceObjectAtIndex:row withObject:encodedObject];
[[NSUserDefaults standardUserDefaults] setObject:self.selectedTimeZones forKey:CLDefaultPreferenceKey]; [[NSUserDefaults standardUserDefaults] setObject:self.selectedTimeZones forKey:CLDefaultPreferenceKey];
if ([dataObject.isFavourite isEqualToNumber:@1])
{
[[NSUserDefaults standardUserDefaults] setObject:encodedObject
forKey:@"favouriteTimezone"];
}
[self refreshMainTableview]; [self refreshMainTableview];
} }
else else
@ -230,7 +237,7 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
[self.selectedTimeZones enumerateObjectsUsingBlock:^(NSData * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) [self.selectedTimeZones enumerateObjectsUsingBlock:^(NSData * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop)
{ {
CLTimezoneData *timezone = [CLTimezoneData getCustomObject:object]; CLTimezoneData *timezone = [CLTimezoneData getCustomObject:obj];
timezone.isFavourite = [NSNumber numberWithInt:0]; timezone.isFavourite = [NSNumber numberWithInt:0];
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:timezone]; NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:timezone];
[newArray addObject:encodedObject]; [newArray addObject:encodedObject];
@ -570,9 +577,7 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
[self.dataTask cancel]; [self.dataTask cancel];
} }
NSString *preferredLanguage = [[[NSBundle mainBundle]preferredLocalizations][0] substringToIndex:2]; NSString *preferredLanguage = [NSLocale preferredLanguages][0];
NSLog(@"Preferred Language:%@", preferredLanguage);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
@ -589,7 +594,6 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
return; return;
} }
}); });
self.activityInProgress = YES; self.activityInProgress = YES;
@ -599,7 +603,7 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
NSArray* words = [searchString componentsSeparatedByCharactersInSet :[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSArray* words = [searchString componentsSeparatedByCharactersInSet :[NSCharacterSet whitespaceAndNewlineCharacterSet]];
searchString = [words componentsJoinedByString:CLEmptyString]; searchString = [words componentsJoinedByString:CLEmptyString];
NSString *urlString = [NSString stringWithFormat:CLLocationSearchURL, searchString]; NSString *urlString = [NSString stringWithFormat:CLLocationSearchURL, searchString, preferredLanguage];
[CLAPI dataTaskWithServicePath:urlString [CLAPI dataTaskWithServicePath:urlString
bySender:self bySender:self

Loading…
Cancel
Save