Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
Fix a few bugs that are blocking beta release
Browse files Browse the repository at this point in the history
* Fix a crasher with quick actions when you have fewer than four dynamic shortcuts to pick from.
* Assert and return nil rather than crash when there's no API server registered to build a URL from.
* Suppress the "Error Connecting" issue at app launch
* Fix some wonky formatting
* Rev bundle version
  • Loading branch information
aaronbrethorst committed Feb 17, 2016
1 parent 03c42f8 commit 3a06e96
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>20151218.16</string>
<string>20160216.20</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fb</string>
Expand Down
3 changes: 2 additions & 1 deletion OBAApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#import "OBAReleaseNotesManager.h"

#import "OBAAnalytics.h"
#import "NSArray+OBAAdditions.h"

static NSString *kOBASelectedTabIndexDefaultsKey = @"OBASelectedTabIndexDefaultsKey";
static NSString *kOBAShowExperimentalRegionsDefaultsKey = @"kOBAShowExperimentalRegionsDefaultsKey";
Expand Down Expand Up @@ -287,7 +288,7 @@ - (void)updateShortcutItemsForRecentStops {
[dynamicShortcuts addObject:shortcutItem];
}

[UIApplication sharedApplication].shortcutItems = [dynamicShortcuts subarrayWithRange:NSMakeRange(0, 4)];
[UIApplication sharedApplication].shortcutItems = [dynamicShortcuts oba_pickFirst:4];
}

#pragma mark - UITabBarControllerDelegate
Expand Down
15 changes: 15 additions & 0 deletions categories/NSArray+OBAAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// NSArray+OBAAdditions.h
// org.onebusaway.iphone
//
// Created by Aaron Brethorst on 2/16/16.
// Copyright © 2016 OneBusAway. All rights reserved.
//

#import <Foundation/NSArray.h>

@interface NSArray (OBAAdditions)

- (NSArray*)oba_pickFirst:(NSUInteger)count;

@end
28 changes: 28 additions & 0 deletions categories/NSArray+OBAAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// NSArray+OBAAdditions.m
// org.onebusaway.iphone
//
// Created by Aaron Brethorst on 2/16/16.
// Copyright © 2016 OneBusAway. All rights reserved.
//

#import "NSArray+OBAAdditions.h"

@implementation NSArray (OBAAdditions)

- (NSArray*)oba_pickFirst:(NSUInteger)count
{
if (self.count == 0)
{
return self;
}

if (self.count < count)
{
count = self.count;
}

return [self subarrayWithRange:NSMakeRange(0, count)];
}

@end
1 change: 1 addition & 0 deletions location/OBARegionHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "OBAApplicationDelegate.h"
#import "OBAAnalytics.h"
#import "OBAApplication.h"
#import "OBAMacros.h"

@interface OBARegionHelper ()
@property (nonatomic) NSMutableArray *regions;
Expand Down
6 changes: 6 additions & 0 deletions org.onebusaway.iphone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
934446D91AB12C5D005B3333 /* OBAModalActivityIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 934446D61AB12C5D005B3333 /* OBAModalActivityIndicator.m */; };
934446DA1AB12C5D005B3333 /* OBAProgressIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 934446D81AB12C5D005B3333 /* OBAProgressIndicatorView.m */; };
934522601C1BA976006F75BC /* OBATheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 9345225F1C1BA976006F75BC /* OBATheme.m */; };
93481B831C74173C007CCCC5 /* NSArray+OBAAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 93481B821C74173C007CCCC5 /* NSArray+OBAAdditions.m */; };
93631E4C1604F96800CB7209 /* OBAApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93631E4B1604F96800CB7209 /* OBAApplicationDelegate.m */; };
936D3EBA1C14E74600091DC9 /* OBATableSection.m in Sources */ = {isa = PBXBuildFile; fileRef = 936D3EB91C14E74600091DC9 /* OBATableSection.m */; };
936D3EBD1C14E83200091DC9 /* OBATableRow.m in Sources */ = {isa = PBXBuildFile; fileRef = 936D3EBC1C14E83200091DC9 /* OBATableRow.m */; };
Expand Down Expand Up @@ -230,6 +231,8 @@
934446D81AB12C5D005B3333 /* OBAProgressIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBAProgressIndicatorView.m; sourceTree = "<group>"; };
9345225E1C1BA976006F75BC /* OBATheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBATheme.h; sourceTree = "<group>"; };
9345225F1C1BA976006F75BC /* OBATheme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBATheme.m; sourceTree = "<group>"; };
93481B811C74173C007CCCC5 /* NSArray+OBAAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+OBAAdditions.h"; sourceTree = "<group>"; };
93481B821C74173C007CCCC5 /* NSArray+OBAAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+OBAAdditions.m"; sourceTree = "<group>"; };
93631E4A1604F96800CB7209 /* OBAApplicationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBAApplicationDelegate.h; sourceTree = "<group>"; };
93631E4B1604F96800CB7209 /* OBAApplicationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = OBAApplicationDelegate.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
936D3EB81C14E74600091DC9 /* OBATableSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBATableSection.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -404,6 +407,8 @@
934446B71AB10ECA005B3333 /* UITableViewCell+oba_Additions.m */,
93B32FF11AC4912F001DC177 /* UIViewController+OBAAnalytics.h */,
93B32FF21AC4912F001DC177 /* UIViewController+OBAAnalytics.m */,
93481B811C74173C007CCCC5 /* NSArray+OBAAdditions.h */,
93481B821C74173C007CCCC5 /* NSArray+OBAAdditions.m */,
);
path = categories;
sourceTree = "<group>";
Expand Down Expand Up @@ -980,6 +985,7 @@
93AD369D1604027E00BDF03F /* OBAProgressIndicatorImpl.m in Sources */,
93B32FF31AC4912F001DC177 /* UIViewController+OBAAnalytics.m in Sources */,
932BE49F1AB66D320011F2FB /* OBAInfoViewController.m in Sources */,
93481B831C74173C007CCCC5 /* NSArray+OBAAdditions.m in Sources */,
934446DA1AB12C5D005B3333 /* OBAProgressIndicatorView.m in Sources */,
93631E4C1604F96800CB7209 /* OBAApplicationDelegate.m in Sources */,
934446BD1AB11033005B3333 /* OBALabelAndSwitchTableViewCell.m in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions org_onebusaway_iphone_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#import "GAITracker.h"
#import "GAIDictionaryBuilder.h"
#import "OBATheme.h"
#import "OBAMacros.h"

#define TFLog NSLog
#define NSLog(__FORMAT__, ...) TFLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

Expand Down
2 changes: 2 additions & 0 deletions sdk/OneBusAwaySDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
669B2F601AEBEBAF00CF2367 /* OBAPresentation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OBAPresentation.m; path = Helpers/OBAPresentation.m; sourceTree = "<group>"; };
669B2F631AEBEBAF00CF2367 /* OBAStopIconFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OBAStopIconFactory.h; path = Helpers/OBAStopIconFactory.h; sourceTree = "<group>"; };
669B2F641AEBEBAF00CF2367 /* OBAStopIconFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OBAStopIconFactory.m; path = Helpers/OBAStopIconFactory.m; sourceTree = "<group>"; };
93481B801C74158A007CCCC5 /* OBAMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OBAMacros.h; path = Helpers/OBAMacros.h; sourceTree = "<group>"; };
93A923AB1C21EF6A00A657C8 /* JsonUrlFetcherImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JsonUrlFetcherImpl.h; path = Services/JsonUrlFetcherImpl.h; sourceTree = "<group>"; };
93A923AC1C21EF6A00A657C8 /* JsonUrlFetcherImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JsonUrlFetcherImpl.m; path = Services/JsonUrlFetcherImpl.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -603,6 +604,7 @@
669B2F551AEBEB4E00CF2367 /* OBALogger.m */,
669B2F501AEBEB2F00CF2367 /* OBAURLHelpers.h */,
669B2F511AEBEB2F00CF2367 /* OBAURLHelpers.m */,
93481B801C74158A007CCCC5 /* OBAMacros.h */,
);
name = Helpers;
sourceTree = "<group>";
Expand Down
17 changes: 1 addition & 16 deletions sdk/sdk/Helpers/OBACommonV1.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,4 @@ typedef NS_ENUM(NSInteger, OBASearchViewType) {
OBASearchViewTypeByStop = 0,
OBASearchViewTypeByRoute,
OBASearchViewTypeByAddress,
};


#define APP_DELEGATE ((OBAApplicationDelegate*)[UIApplication sharedApplication].delegate)

#define OBARGBCOLOR(__r, __g, __b) [UIColor colorWithRed:(__r / 255.f) green:(__g / 255.f) blue:(__b / 255.f) alpha:1.f]
#define OBARGBACOLOR(__r, __g, __b, __a) [UIColor colorWithRed:(__r / 255.f) green:(__g / 255.f) blue:(__b / 255.f) alpha:__a]
#define OBAGREENWITHALPHA(__a) [UIColor colorWithHue:(86.f/360.f) saturation:0.68f brightness:0.67f alpha:__a]
#define OBAGREEN [UIColor colorWithHue:(86.f/360.f) saturation:0.68f brightness:0.67f alpha:1.f]
#define OBAGREENBACKGROUND [UIColor colorWithRed:0.92f green:0.95f blue:0.88f alpha:.67f]
#define OBADARKGREEN [UIColor colorWithRed:0.2f green:.4f blue:0.f alpha:1.f]

#define OBAViewedArrivalsAndDeparturesForStopNotification @"OBAViewedArrivalsAndDeparturesForStopNotification"
#define OBAMostRecentStopsChangedNotification @"OBAMostRecentStopsChangedNotification"

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
};
30 changes: 30 additions & 0 deletions sdk/sdk/Helpers/OBAMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// OBAMacros.h
// OneBusAwaySDK
//
// Created by Aaron Brethorst on 2/16/16.
// Copyright © 2016 One Bus Away. All rights reserved.
//

#ifndef OBAMacros_h
#define OBAMacros_h

#define APP_DELEGATE ((OBAApplicationDelegate*)[UIApplication sharedApplication].delegate)

#define OBARGBCOLOR(__r, __g, __b) [UIColor colorWithRed:(__r / 255.f) green:(__g / 255.f) blue:(__b / 255.f) alpha:1.f]
#define OBARGBACOLOR(__r, __g, __b, __a) [UIColor colorWithRed:(__r / 255.f) green:(__g / 255.f) blue:(__b / 255.f) alpha:__a]
#define OBAGREENWITHALPHA(__a) [UIColor colorWithHue:(86.f/360.f) saturation:0.68f brightness:0.67f alpha:__a]
#define OBAGREEN [UIColor colorWithHue:(86.f/360.f) saturation:0.68f brightness:0.67f alpha:1.f]
#define OBAGREENBACKGROUND [UIColor colorWithRed:0.92f green:0.95f blue:0.88f alpha:.67f]
#define OBADARKGREEN [UIColor colorWithRed:0.2f green:.4f blue:0.f alpha:1.f]

#define OBAViewedArrivalsAndDeparturesForStopNotification @"OBAViewedArrivalsAndDeparturesForStopNotification"
#define OBAMostRecentStopsChangedNotification @"OBAMostRecentStopsChangedNotification"

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define OBAGuard(CONDITION) \
if (!CONDITION) { NSParameterAssert(CONDITION); } \
if (CONDITION) {}

#endif /* OBAMacros_h */
1 change: 1 addition & 0 deletions sdk/sdk/Models/dao/OBAModelDAO.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "OBALogger.h"
#import "OBACommon.h"
#import "OBACommonV1.h"
#import "OBAMacros.h"
#import "OBAStopAccessEventV2.h"
#import "OBASituationV2.h"
#import "OBAModelDAOUserPreferencesImpl.h"
Expand Down
5 changes: 5 additions & 0 deletions sdk/sdk/Services/OBADataSourceConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#import "OBADataSourceConfig.h"
#import "OBAMacros.h"

@interface OBADataSourceConfig ()
@property(nonatomic,copy) NSURL* baseURL;
Expand Down Expand Up @@ -56,6 +57,10 @@ - (NSURL*)constructURL:(NSString*)path withArgs:(NSDictionary*)args {

NSURL *URLWithPath = [self.baseURL URLByAppendingPathComponent:path];

OBAGuard(URLWithPath) else {
return nil;
}

NSURLComponents *components = [[NSURLComponents alloc] initWithURL:URLWithPath resolvingAgainstBaseURL:NO];

if (queryItems.count > 0) {
Expand Down
14 changes: 12 additions & 2 deletions ui/search/OBASearchController.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,21 @@ - (void)request:(id<OBAModelServiceRequest>)request withProgress:(float)progress
}

- (void)processError:(NSError *)error responseCode:(NSUInteger)responseCode {
if (error) {

if (responseCode == 0 && error.code == NSURLErrorCancelled) {
// This shouldn't be happening, and frankly I'm not entirely sure why it's happening.
// But, I do know that it doesn't have any appreciable user impact outside of this
// error alert being really annoying. So we'll just log it and eat it.

NSLog(@"Errored out at launch: %@", error);
}
else if (error) {
[self.progress setMessage:NSLocalizedString(@"Error connecting", @"requestDidFail") inProgress:NO progress:0];
[self fireError:error];
}
else if (responseCode == 404) [self.progress setMessage:NSLocalizedString(@"Not found", @"code == 404") inProgress:NO progress:0];
else if (responseCode == 404) {
[self.progress setMessage:NSLocalizedString(@"Not found", @"code == 404") inProgress:NO progress:0];
}
else {
[self.progress setMessage:NSLocalizedString(@"Server error", @"code # 404") inProgress:NO progress:0];
}
Expand Down
2 changes: 1 addition & 1 deletion ui/search/OBASearchResultsMapViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ - (void)handleSearchControllerError:(NSError *)error {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error connecting", @"self.navigationItem.title") message:NSLocalizedString(@"There was a problem with your Internet connection.\r\n\r\nPlease check your network connection or contact us if you think the problem is on our end.", @"view.message") preferredStyle:UIAlertControllerStyleAlert];

[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Dismiss", @"") style:UIAlertActionStyleCancel handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Contact Us", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Contact Us", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[APP_DELEGATE navigateToTarget:[OBANavigationTarget target:OBANavigationTargetTypeContactUs]];
}]];
[self presentViewController:alert animated:YES completion:nil];
Expand Down
57 changes: 22 additions & 35 deletions ui/trip_details/OBATripScheduleListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,42 +82,29 @@ - (void)dealloc {
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

if (_tripDetails == nil && _tripInstance != nil) {
if (_tripInstance && !_tripDetails) {

[self.tableView reloadData];
_request = [[OBAApplication sharedApplication].modelService
requestTripDetailsForTripInstance:_tripInstance
completionBlock:^(id responseData, NSUInteger responseCode, NSError *error) {
if (responseCode == 404) {
[self->_progressView
setMessage:NSLocalizedString(@"Trip not found", @"message")
inProgress:NO
progress:0];
}
else if (responseCode >= 300) {
[self->_progressView
setMessage:NSLocalizedString(@"Unknown error", @"message")
inProgress:NO
progress:0];
}
else if (error) {
OBALogWarningWithError(error, @"Error");
[self->_progressView
setMessage:NSLocalizedString(@"Error connecting", @"message")
inProgress:NO
progress:0];
}
else {
OBAEntryWithReferencesV2 *entry = responseData;
self->_tripDetails = entry.entry;
[self handleTripDetails];
}
}

progressBlock:^(CGFloat progress) {
[self->_progressView
setInProgress:YES
progress:progress];
}];

_request = [[OBAApplication sharedApplication].modelService requestTripDetailsForTripInstance:_tripInstance completionBlock:^(id responseData, NSUInteger responseCode, NSError *error) {
if (responseCode == 404) {
[self->_progressView setMessage:NSLocalizedString(@"Trip not found", @"message") inProgress:NO progress:0];
}
else if (responseCode >= 300) {
[self->_progressView setMessage:NSLocalizedString(@"Unknown error", @"message") inProgress:NO progress:0];
}
else if (error) {
OBALogWarningWithError(error, @"Error");
[self->_progressView setMessage:NSLocalizedString(@"Error connecting", @"message") inProgress:NO progress:0];
}
else {
OBAEntryWithReferencesV2 *entry = responseData;
self->_tripDetails = entry.entry;
[self handleTripDetails];
}
} progressBlock:^(CGFloat progress) {
[self->_progressView setInProgress:YES progress:progress];
}];
}
else {
[self handleTripDetails];
Expand Down

0 comments on commit 3a06e96

Please sign in to comment.