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

Commit

Permalink
Remove all traces of UIAlertView and UIActionSheet from codebase
Browse files Browse the repository at this point in the history
Fixes #499

* Replace all UIAlertViews with UIAlertControllers
* Remove all other traces of UIAlertView and UIActionSheet
* Code hygiene
* Stop initializin the app delegate when testing in order to speed up tests
  • Loading branch information
aaronbrethorst committed Dec 17, 2015
1 parent 7a12fa4 commit 08a60ca
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 321 deletions.
28 changes: 0 additions & 28 deletions controls/alerts/OBANetworkErrorAlertViewDelegate.h

This file was deleted.

35 changes: 0 additions & 35 deletions controls/alerts/OBANetworkErrorAlertViewDelegate.m

This file was deleted.

17 changes: 14 additions & 3 deletions main.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@

#import <UIKit/UIKit.h>

BOOL executingTests;

@interface OBATestAppDelegate : UIResponder <UIApplicationDelegate>
@end
@implementation OBATestAppDelegate
@end

int main(int argc, char *argv[]) {
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, @"OBAApplicationDelegate");

executingTests = [[[NSProcessInfo processInfo].environment[@"XCInjectBundle"] pathExtension] isEqual:@"xctest"];

NSString *appDelegateClass = executingTests ? @"OBATestAppDelegate" : @"OBAApplicationDelegate";

int retVal = UIApplicationMain(argc, argv, nil, appDelegateClass);
return retVal;
}
}

}
14 changes: 0 additions & 14 deletions org.onebusaway.iphone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
934446DA1AB12C5D005B3333 /* OBAProgressIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 934446D81AB12C5D005B3333 /* OBAProgressIndicatorView.m */; };
934522601C1BA976006F75BC /* OBATheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 9345225F1C1BA976006F75BC /* OBATheme.m */; };
93631E4C1604F96800CB7209 /* OBAApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93631E4B1604F96800CB7209 /* OBAApplicationDelegate.m */; };
93631E801604F9A300CB7209 /* OBANetworkErrorAlertViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93631E7C1604F9A200CB7209 /* OBANetworkErrorAlertViewDelegate.m */; };
93631E811604F9A300CB7209 /* OBASearchResultsMapFilterToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = 93631E7F1604F9A200CB7209 /* OBASearchResultsMapFilterToolbar.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 @@ -242,8 +241,6 @@
9345225F1C1BA976006F75BC /* OBATheme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBATheme.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; };
93631E7B1604F9A200CB7209 /* OBANetworkErrorAlertViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBANetworkErrorAlertViewDelegate.h; sourceTree = "<group>"; };
93631E7C1604F9A200CB7209 /* OBANetworkErrorAlertViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OBANetworkErrorAlertViewDelegate.m; sourceTree = "<group>"; };
93631E7E1604F9A200CB7209 /* OBASearchResultsMapFilterToolbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OBASearchResultsMapFilterToolbar.h; sourceTree = "<group>"; };
93631E7F1604F9A200CB7209 /* OBASearchResultsMapFilterToolbar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = OBASearchResultsMapFilterToolbar.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 @@ -604,15 +601,6 @@
path = themes;
sourceTree = "<group>";
};
93631E7A1604F9A200CB7209 /* alerts */ = {
isa = PBXGroup;
children = (
93631E7B1604F9A200CB7209 /* OBANetworkErrorAlertViewDelegate.h */,
93631E7C1604F9A200CB7209 /* OBANetworkErrorAlertViewDelegate.m */,
);
path = alerts;
sourceTree = "<group>";
};
93631E7D1604F9A200CB7209 /* toolbars */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -640,7 +628,6 @@
children = (
934446C81AB12B29005B3333 /* view_controllers */,
9330DF251606404100E14AF4 /* containers */,
93631E7A1604F9A200CB7209 /* alerts */,
93631E7D1604F9A200CB7209 /* toolbars */,
93AD36991604027E00BDF03F /* progress */,
93AD36381603FE7E00BDF03F /* table_cells */,
Expand Down Expand Up @@ -1027,7 +1014,6 @@
932BE4E91AB66E3C0011F2FB /* OBAEditBookmarkGroupViewController.m in Sources */,
932BE4A11AB66D320011F2FB /* OBARegionListViewController.m in Sources */,
932BE4EA1AB66E3C0011F2FB /* OBAEditStopBookmarkGroupViewController.m in Sources */,
93631E801604F9A300CB7209 /* OBANetworkErrorAlertViewDelegate.m in Sources */,
93631E811604F9A300CB7209 /* OBASearchResultsMapFilterToolbar.m in Sources */,
932BE4BC1AB66D5C0011F2FB /* OBAGenericStopViewController.m in Sources */,
932BE4C11AB66D5C0011F2FB /* OBAStopWebViewController.m in Sources */,
Expand Down
7 changes: 0 additions & 7 deletions org_onebusaway_iphone_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
#define TFLog NSLog
#define NSLog(__FORMAT__, ...) TFLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

// useful UI alert for debugging, idea from http://stackoverflow.com/a/7017711
#ifdef DEBUG
#define ULog(fmt, ...) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }
#else
#define ULog(...)
#endif

#endif

#define LOG NO
12 changes: 5 additions & 7 deletions ui/info/OBAContactUsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#define kEmailRow 0
#define kTwitterRow 1
#define kFacebookRow 2

#define kRowCount 3 //including Facebook which is optional

static NSString *kOBADefaultContactEmail = @"contact@onebusaway.org";
Expand Down Expand Up @@ -56,13 +55,12 @@ - (void)mailComposeController:(MFMailComposeViewController *)controller
}

- (void)cantSendEmail {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Setup Mail", @"view.title")
message:NSLocalizedString(@"Please setup your Mail app before trying to send an email.", @"view.message")
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:NSLocalizedString(@"OK", @"OK button"), nil];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Please setup your Mail app before trying to send an email.", @"view.message")
message:nil
preferredStyle:UIAlertControllerStyleAlert];

[alert show];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Dismiss", @"Dismiss button for alert.") style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}

#pragma mark - UIViewController
Expand Down
51 changes: 21 additions & 30 deletions ui/info/OBARegionListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -476,44 +476,34 @@ - (UITableViewCell *)customAPICellForRowAtIndexPath:(NSIndexPath *)indexPath tab
}

- (void)didSwitchStateOfToggle:(UISwitch *)toggleSwitch {

UIAlertController *alert = nil;

if (toggleSwitch.on) {
UIAlertView *unstableRegionAlert = [[UIAlertView alloc] initWithTitle:@"Enable Regions in Beta?"
message:@"Experimental regions may be unstable and without real-time info!"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:NSLocalizedString(@"OK", @"OK button"), nil];
[unstableRegionAlert show];
alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Enable Regions in Beta?", @"") message:@"Experimental regions may be unstable and without real-time info!" preferredStyle:UIAlertControllerStyleAlert];
}
else {
//if current region is beta, show alert; otherwise, just update list
// If current region is beta, show alert; otherwise, just update list.
if ([OBAApplication sharedApplication].modelDao.region.experimental) {
UIAlertView *currentRegionUnavailableAlert = [[UIAlertView alloc] initWithTitle:@"Discard Current Region?"
message:@"Your current experimental region won't be available! Proceed anyway?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:NSLocalizedString(@"OK", @"OK button"), nil];

[currentRegionUnavailableAlert show];
alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Discard Current Region?", @"") message:@"Your current experimental region won't be available! Proceed anyway?" preferredStyle:UIAlertControllerStyleAlert];
}
else {
[self doNeedToUpdateRegionsList];
}
}
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if (alert) {
// The code that this replaces ended up performing the same actions for Cancel and OK
// on both alerts that it could present. This sounds like a bug to me...

if ([title isEqualToString:NSLocalizedString(@"OK", @"OK button")]) {
[self doNeedToUpdateRegionsList];
}
else if ([title isEqualToString:@"Cancel"]) {
if (_showExperimentalRegions) {
[_toggleSwitch setOn:YES animated:NO];
}
else {
[_toggleSwitch setOn:NO animated:NO];
}
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
[self.toggleSwitch setOn:self.showExperimentalRegions animated:NO];
}]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self doNeedToUpdateRegionsList];
}]];

[self presentViewController:alert animated:YES completion:nil];
}
}

Expand All @@ -537,13 +527,14 @@ - (void)doNeedToUpdateRegionsList {
//Otherwise, set region to first in list
else if (![self isLoading] && _regions.count > 0) {
[self.appDelegate writeSetRegionAutomatically:NO];
[[OBAApplication sharedApplication].modelDao setOBARegion:[_regions objectAtIndex:0]];
[[OBAApplication sharedApplication].modelDao setOBARegion:self.regions[0]];
}
//Set region to nil if list is empty
else if (![self isLoading]) {
UIAlertView *noAvailableRegionsAlert = [[UIAlertView alloc] initWithTitle:@"No Regions Found" message:@"No available regions were found, recheck your connection and try again" delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"OK button") otherButtonTitles:nil];
[[OBAApplication sharedApplication].modelDao setOBARegion:nil];
[noAvailableRegionsAlert show];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"No Regions Found", @"") message:NSLocalizedString(@"No available regions were found, recheck your connection and try again.", @"") preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Dismiss", @"") style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}
}

Expand Down
3 changes: 1 addition & 2 deletions ui/search/OBASearchResultsMapViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#import "OBASearchController.h"
#import "OBALocationManager.h"
#import "OBAGenericAnnotation.h"
#import "OBANetworkErrorAlertViewDelegate.h"
#import "OBASearchResultsMapFilterToolbar.h"
#import "OBAMapRegionManager.h"
#import "OBAScopeView.h"
Expand All @@ -29,7 +28,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface OBASearchResultsMapViewController : UIViewController <OBANavigationTargetAware, OBASearchControllerDelegate, MKMapViewDelegate,UIActionSheetDelegate,UIAlertViewDelegate,OBALocationManagerDelegate,OBAProgressIndicatorDelegate, UISearchBarDelegate>
@interface OBASearchResultsMapViewController : UIViewController <OBANavigationTargetAware, OBASearchControllerDelegate, MKMapViewDelegate,OBALocationManagerDelegate,OBAProgressIndicatorDelegate, UISearchBarDelegate>
@property(nonatomic,strong) OBAApplicationDelegate * appDelegate;
@property(nonatomic,strong) IBOutlet OBAScopeView *scopeView;
@property(nonatomic,strong) IBOutlet UISegmentedControl *searchTypeSegmentedControl;
Expand Down
Loading

0 comments on commit 08a60ca

Please sign in to comment.