Commits

Tim Hibbard committed 305f73d

Removed dash from name displayed on home screen
Remove link to native maps app because new maps do not support all the needed query strings
Added ability to set location based reminders if running iOS 6
Twitter link launches in Tweetbot if installed
Replaced Facebook icon with something less ugly

Comments (0)

Files changed (9)

Christian FM.xcodeproj/project.xcworkspace/xcuserdata/timhibbard.xcuserdatad/UserInterfaceState.xcuserstate

Binary file modified.

Christian Radio Finder/Christian FM-Info.plist

 	<key>CFBundleDevelopmentRegion</key>
 	<string>en</string>
 	<key>CFBundleDisplayName</key>
-	<string>Christian-FM</string>
+	<string>${PRODUCT_NAME}</string>
 	<key>CFBundleExecutable</key>
 	<string>${EXECUTABLE_NAME}</string>
 	<key>CFBundleIdentifier</key>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
 	<key>CFBundleName</key>
-	<string>Christian-FM</string>
+	<string>${PRODUCT_NAME}</string>
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>

Christian Radio Finder/MapDetailViewController.m

             NSString *mapsQuery =
             [NSString stringWithFormat:@"http://maps.google.com/maps?z=6&t=h&ll=%lf,%lf",
              station.lat.doubleValue, station.lng.doubleValue];
+            BOOL atLeastIOS6 = [[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0;
+            if (atLeastIOS6) {
+                mapsQuery = [NSString stringWithFormat:@"http://maps.apple.com/maps?q=%lf,%lf&ll=%lf,%lf&z=8",
+                 station.lat.doubleValue, station.lng.doubleValue,(station.lat.doubleValue + map.userLocation.location.coordinate.latitude)/2,(station.lng.doubleValue + map.userLocation.location.coordinate.longitude)/2];
+            }
             [[UIApplication sharedApplication] openURL:[NSURL URLWithString:mapsQuery]];
         } break;
         default:

Christian Radio Finder/StationDetailTableViewController.h

 @property (nonatomic, retain) IBOutlet UITableViewCell *geoCell;
 @property (nonatomic, retain) IBOutlet UITableViewCell *reminderCell;
 @property (nonatomic) NSString *eventId;
+@property (nonatomic) BOOL providedStoreAccess;
+@property (nonatomic) EKEventStore *eventStore;
 
 
 

Christian Radio Finder/StationDetailTableViewController.m

 @synthesize geoCell;
 @synthesize reminderCell;
 @synthesize eventId;
+@synthesize eventStore;
+@synthesize providedStoreAccess;
 
 - (void) shareButtonClicked:(id)sender{
     UIActionSheet *sheet =
                        cancelButtonTitle:NSLocalizedString(@"Cancel", @"Cancel")
                   destructiveButtonTitle:nil
                        otherButtonTitles:NSLocalizedString(@"Email", @"Email"),NSLocalizedString(@"SMS", @"SMS"),
-     NSLocalizedString(@"Show Location in Maps", @"Show Location in Maps"),
      nil];
     [sheet showInView:self.view];
 }
                 
             }
         } break;
-        case 2: {
-            NSString *mapsQuery =
-            [NSString stringWithFormat:@"http://maps.google.com/maps?z=6&t=h&ll=%lf,%lf",
-             station.lat.doubleValue, station.lng.doubleValue];
-            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:mapsQuery]];
-        } break;
+
         default:
             break;
     }
         [twitterCell setAccessoryType:UITableViewCellAccessoryNone];
     }
     
+    EKEventStore *store = [self getEventStore];
+    if (!store) {
+        return;
+    }
+    if (!providedStoreAccess) {
+        return;
+    }
+    
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     NSDictionary *reminders = [defaults objectForKey:@"reminders"];
+    NSMutableArray *remindersToRemove = [[NSMutableArray alloc] init];
     for (NSString *key in reminders) {
-        if ([[NSString stringWithFormat:@"%@%@",station.lat,station.lng] isEqualToString:key]) {
+        //making sure that no events have been removed outside of this application
+        //if so, we are going to remove it from the collection and not mark the reminder cell
+        BOOL skip = NO;
+        NSString *eventIdFromReminders = [reminders valueForKey:key];
+        EKReminder *reminder = (EKReminder *)[store calendarItemWithIdentifier:eventIdFromReminders];
+        if (!reminder || reminder.completed) {
+            [remindersToRemove addObject:eventIdFromReminders];
+            skip = YES;
+            NSLog(@"Need to remove:%@",eventIdFromReminders);
+        }
+        if ([[NSString stringWithFormat:@"%@%@",station.lat,station.lng] isEqualToString:key] && !skip) {
             [reminderCell setAccessoryType:UITableViewCellAccessoryCheckmark];
-            [self setEventId:[reminders valueForKey:key]];
+            [self setEventId:eventIdFromReminders];
         }
     }
+    //nothing to remove...carry on
+    if (remindersToRemove.count == 0) {
+        return;
+    }
+    
+    NSMutableArray *latlng = [NSMutableArray arrayWithArray:reminders.allKeys];
+    NSMutableArray *itemIds = [NSMutableArray arrayWithArray:reminders.allValues];
+    
+    for (NSString *eventIdToRemove in remindersToRemove) {
+        NSUInteger index = [itemIds indexOfObject:eventIdToRemove];
+        [latlng removeObjectAtIndex:index];
+        [itemIds removeObjectAtIndex:index];
+        NSLog(@"Removed:%@",eventIdToRemove);
+    }
+    
+    NSDictionary *newReminders = [NSDictionary dictionaryWithObjects:itemIds forKeys:latlng];
+    [defaults setObject:newReminders forKey:@"reminders"];
+    [defaults synchronize];
+    
     
 
 }
 {
     [super viewDidLoad];
     
-    
+    providedStoreAccess = YES;
 
     
     //[defaults setObject:helpText forKey:@"helpText"];
 
 #pragma mark - reminders
 
-- (BOOL) addReminder{
+- (EKEventStore*) getEventStore{
+    if (eventStore) {
+        return eventStore;
+    }
+    
     EKEventStore *store = [[EKEventStore alloc] init];
     __block BOOL providedAccess = YES;
     BOOL atLeastIOS6 = [[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0;
     if (!atLeastIOS6) {
-        return NO;
+        providedStoreAccess = NO;
+        return nil;
     }
     [store requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
         providedAccess = granted;
     }];
+    [self setProvidedStoreAccess:providedAccess];
+    [self setEventStore:store];
+    return store;
+}
+
+- (BOOL) addReminder{
+    EKEventStore *store = [self getEventStore];
+    if (!store) {
+        return NO;
+    }
+    if (!providedStoreAccess) {
+        return NO;
+    }
     EKReminder *reminder = [EKReminder reminderWithEventStore:store];
     [reminder setTitle:[NSString stringWithFormat:@"Listen to %@ (%@)",station.ownedBy,station.frequency]];
     [reminder setNotes:[NSString stringWithFormat:@"%@ %i mile range",station.city, (int)[station.range doubleValue]]];
     [enterAlarm setStructuredLocation:enterLocation];
     [reminder addAlarm:enterAlarm];
     [reminder setCalendar:[store defaultCalendarForNewReminders]];
-    if (!providedAccess) {
-        return NO;
-    }
+
     NSError *err;
     [store saveReminder:reminder commit:YES error:&err];
     [self setEventId:reminder.calendarItemIdentifier];
     if (eventId.length == 0) {
         return NO;
     }
-    EKEventStore *store = [[EKEventStore alloc] init];
-    __block BOOL providedAccess = YES;
-    BOOL atLeastIOS6 = [[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0;
-    if (!atLeastIOS6) {
+    EKEventStore *store = [self getEventStore];
+    if (!store) {
         return NO;
     }
-    [store requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
-        providedAccess = granted;
-    }];
-    
-    EKReminder *reminder = (EKReminder *)[store calendarItemWithIdentifier:eventId];
-    if (!providedAccess) {
+    if (!providedStoreAccess) {
         return NO;
     }
+    
+    EKReminder *reminder = (EKReminder *)[store calendarItemWithIdentifier:eventId];
+
     NSError *err;
     [store removeReminder:reminder commit:YES error:&err];
     

Christian Radio Finder/en.lproj/MainStoryboard_iPhone.storyboard

                     <toolbarItems/>
                     <navigationItem key="navigationItem" title="Detail" id="XZ4-sl-kpl">
                         <barButtonItem key="backBarButtonItem" title="Stations" id="Tjk-ur-sNG"/>
-                        <barButtonItem key="rightBarButtonItem" systemItem="action" id="zO7-Zl-rY3">
-                            <connections>
-                                <action selector="shareButtonClicked:" destination="eX2-ZJ-yyp" id="phq-VI-EDw"/>
-                            </connections>
-                        </barButtonItem>
                     </navigationItem>
                     <connections>
                         <outlet property="displayView" destination="e0h-cH-3r4" id="aKh-tn-1qg"/>
         <image name="drawingpin1_blue.png" width="256" height="256"/>
         <image name="twitter-bird-light-bgs.png" width="300" height="300"/>
     </resources>
+    <classes>
+        <class className="AddNewStationViewController" superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/AddNewStationViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="backgroundTouched:"/>
+                <relationship kind="action" name="submitButtonClicked:"/>
+                <relationship kind="outlet" name="callsignText" candidateClass="UITextField"/>
+                <relationship kind="outlet" name="facebookText" candidateClass="UITextField"/>
+                <relationship kind="outlet" name="freqText" candidateClass="UITextField"/>
+                <relationship kind="outlet" name="locationLabel" candidateClass="UILabel"/>
+                <relationship kind="outlet" name="stationNameText" candidateClass="UITextField"/>
+                <relationship kind="outlet" name="twitterText" candidateClass="UITextField"/>
+                <relationship kind="outlet" name="websiteText" candidateClass="UITextField"/>
+            </relationships>
+        </class>
+        <class className="CLLocationManager" superclassName="NSObject">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/CLLocationManager.h"/>
+        </class>
+        <class className="MapDetailViewController" superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/MapDetailViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="shareButtonClicked:"/>
+                <relationship kind="outlet" name="displayView" candidateClass="UIView"/>
+                <relationship kind="outlet" name="distanceLabel" candidateClass="UILabel"/>
+                <relationship kind="outlet" name="map" candidateClass="MKMapView"/>
+            </relationships>
+        </class>
+        <class className="PullTableView" superclassName="UITableView">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/PullTableView.h"/>
+            <relationships>
+                <relationship kind="outlet" name="pullDelegate"/>
+            </relationships>
+        </class>
+        <class className="StationCell" superclassName="UITableViewCell">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/StationCell.h"/>
+            <relationships>
+                <relationship kind="outlet" name="callSignLabel" candidateClass="UILabel"/>
+                <relationship kind="outlet" name="cityLabel" candidateClass="UILabel"/>
+                <relationship kind="outlet" name="distanceLabel" candidateClass="UILabel"/>
+                <relationship kind="outlet" name="frequencyLabel" candidateClass="UILabel"/>
+            </relationships>
+        </class>
+        <class className="StationDetailTableViewController" superclassName="UITableViewController">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/StationDetailTableViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="shareButtonClicked:"/>
+                <relationship kind="outlet" name="facebookCell" candidateClass="UITableViewCell"/>
+                <relationship kind="outlet" name="freqCell" candidateClass="UITableViewCell"/>
+                <relationship kind="outlet" name="geoCell" candidateClass="UITableViewCell"/>
+                <relationship kind="outlet" name="ownedByCell" candidateClass="UITableViewCell"/>
+                <relationship kind="outlet" name="reminderCell" candidateClass="UITableViewCell"/>
+                <relationship kind="outlet" name="streamingCell" candidateClass="UITableViewCell"/>
+                <relationship kind="outlet" name="twitterCell" candidateClass="UITableViewCell"/>
+            </relationships>
+        </class>
+        <class className="StationMapViewController" superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/StationMapViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="longPress:" candidateClass="UILongPressGestureRecognizer"/>
+                <relationship kind="action" name="searchBarCancelButtonClicked:" candidateClass="UISearchBar"/>
+                <relationship kind="action" name="searchBarSearchButtonClicked:" candidateClass="UISearchBar"/>
+                <relationship kind="action" name="shareButtonClicked:"/>
+                <relationship kind="outlet" name="infoLabel" candidateClass="UILabel"/>
+                <relationship kind="outlet" name="map" candidateClass="MKMapView"/>
+            </relationships>
+        </class>
+        <class className="StationTableViewController" superclassName="UITableViewController">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/StationTableViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="longPress:" candidateClass="UILongPressGestureRecognizer"/>
+                <relationship kind="action" name="shareButtonClicked:"/>
+                <relationship kind="action" name="swipeLeft:" candidateClass="UISwipeGestureRecognizer"/>
+                <relationship kind="action" name="swipeRight:" candidateClass="UISwipeGestureRecognizer"/>
+                <relationship kind="outlet" name="locationManager" candidateClass="CLLocationManager"/>
+                <relationship kind="outlet" name="pullTableView" candidateClass="PullTableView"/>
+            </relationships>
+        </class>
+        <class className="WebViewController" superclassName="UIViewController">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/WebViewController.h"/>
+            <relationships>
+                <relationship kind="action" name="shareButtonClicked:"/>
+                <relationship kind="outlet" name="webView" candidateClass="UIWebView"/>
+            </relationships>
+        </class>
+    </classes>
     <simulatedMetricsContainer key="defaultSimulatedMetrics">
         <simulatedStatusBarMetrics key="statusBar"/>
         <simulatedOrientationMetrics key="orientation"/>

Christian Radio Finder/images/Facebook-Icon.png

Added
New image

Christian Radio Finder/images/drawingpin1_blue.png

Added
New image
+.DS_Store
+
+*.swp
+*~.nib
+
+build/
+
+*.pbxuser
+*.perspective
+*.perspectivev3
+
+*.mode1v3
+*.mode2v3
+
+xcuserdata