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

v18.2.2 #1409

Merged
merged 19 commits into from
Dec 12, 2018
Merged

v18.2.2 #1409

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Xcode
#

GoogleService-Info.plist

## Build generated
build/
DerivedData
Expand Down
12 changes: 12 additions & 0 deletions AppIdentities/OneBusAway/OBAProperties.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>google_analytics_id</key>
<string>UA-2423527-17</string>
<key>onesignal_api_key</key>
<string>d5d0d28a-6091-46cd-9627-0ce01ffa9f9e</string>
<key>appstore_id</key>
<string>329380089</string>
</dict>
</plist>
40 changes: 0 additions & 40 deletions AppIdentities/OneBusAway/OBA_Firebase.plist

This file was deleted.

2 changes: 2 additions & 0 deletions OBAKit/Application/OBAApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@class OBAForecastManager;
@class OBAMapDataLoader;
@class OBAMapRegionManager;
@class ObacoService;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -40,6 +41,7 @@ extern NSString *const OBAShowTestAlertsDefaultsKey;
@interface OBAApplication : NSObject
@property (nonatomic, strong, readonly) OBAReferencesV2 *references;
@property (nonatomic, strong, readonly) OBAModelDAO *modelDao;
@property (nonatomic, strong, readonly) ObacoService *obacoService;
@property (nonatomic, strong, readonly) OBARegionsService *regionsService;
@property (nonatomic, strong, nullable, readonly) PromisedModelService *modelService;
@property (nonatomic, strong, readonly) OBALocationManager *locationManager;
Expand Down
17 changes: 12 additions & 5 deletions OBAKit/Application/OBAApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ @interface OBAApplication ()
@property (nonatomic, strong, readwrite) OBAApplicationConfiguration *configuration;
@property (nonatomic, strong, readwrite) OBAReferencesV2 *references;
@property (nonatomic, strong, readwrite) OBAModelDAO *modelDao;

// Data Services
@property (nonatomic, strong, readwrite) ObacoService *obacoService;
@property (nonatomic, strong, readwrite) OBARegionsService *regionsService;
@property (nonatomic, strong, nullable, readwrite) PromisedModelService *modelService;

@property (nonatomic, strong, readwrite) OBALocationManager *locationManager;
@property (nonatomic, strong, readwrite) OBAReachability *reachability;
@property (nonatomic, strong, readwrite) OBARegionHelper *regionHelper;
Expand Down Expand Up @@ -78,6 +82,7 @@ - (void)startWithConfiguration:(OBAApplicationConfiguration *)configuration {
self.locationManager = [[OBALocationManager alloc] initWithModelDAO:self.modelDao];

self.regionsService = [[OBARegionsService alloc] initWithRegionsDataSource:OBAJsonDataSource.regionsDataSource];
self.obacoService = [[ObacoService alloc] initWithDataSource:OBAJsonDataSource.obacoJSONDataSource];

self.regionHelper = [[OBARegionHelper alloc] initWithLocationManager:self.locationManager modelService:self.regionsService];

Expand Down Expand Up @@ -148,8 +153,10 @@ - (NSData*)exportUserDefaultsAsXML {

- (void)applicationDidEnterBackground {
[self.locationManager stopUpdatingLocation];

[self.modelService cancelOpenConnections];
[self.obacoService cancelOpenConnections];
[self.regionsService cancelOpenConnections];
}

#pragma mark - Reachability
Expand Down Expand Up @@ -196,19 +203,19 @@ - (NSString*)fullAppVersionString {
#pragma mark - App Keys

- (NSString*)firebaseAnalyticsConfigFilePath {
return [NSBundle.mainBundle pathForResource:@"OBA_Firebase" ofType:@"plist"];
return [NSBundle.mainBundle pathForResource:@"GoogleService-Info" ofType:@"plist"];
}

- (NSString*)googleAnalyticsID {
return @"UA-2423527-17";
return self.configuration.appProperties[OBAAppConfigPropertyGoogleAnalyticsKey];
}

- (NSString*)oneSignalAPIKey {
return @"d5d0d28a-6091-46cd-9627-0ce01ffa9f9e";
return self.configuration.appProperties[OBAAppConfigPropertyOneSignalKey];
}

- (NSString*)appStoreAppID {
return @"329380089";
return self.configuration.appProperties[OBAAppConfigPropertyAppStoreKey];
}

#pragma mark - App/Region/API State
Expand Down
6 changes: 6 additions & 0 deletions OBAKit/Application/OBAApplicationConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@

NS_ASSUME_NONNULL_BEGIN

extern NSString * const OBAAppConfigPropertyGoogleAnalyticsKey;
extern NSString * const OBAAppConfigPropertyOneSignalKey;
extern NSString * const OBAAppConfigPropertyAppStoreKey;

@interface OBAApplicationConfiguration : NSObject
@property(nonatomic,assign) BOOL extensionMode;
@property(nonatomic,copy,nullable) NSArray<DDAbstractLogger*> *loggers;
@property(nonatomic,copy) NSString *appPropertiesFilePath;
@property(nonatomic,copy,readonly) NSDictionary *appProperties;
@end

NS_ASSUME_NONNULL_END
15 changes: 15 additions & 0 deletions OBAKit/Application/OBAApplicationConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@

#import "OBAApplicationConfiguration.h"

NSString * const OBAAppConfigPropertyGoogleAnalyticsKey = @"google_analytics_id";
NSString * const OBAAppConfigPropertyOneSignalKey = @"onesignal_api_key";
NSString * const OBAAppConfigPropertyAppStoreKey = @"appstore_id";

@interface OBAApplicationConfiguration ()
@property(nonatomic,copy,readwrite) NSDictionary *appProperties;
@end

@implementation OBAApplicationConfiguration

- (NSDictionary*)appProperties {
if (!_appProperties) {
_appProperties = [[NSDictionary alloc] initWithContentsOfFile:_appPropertiesFilePath];
}
return _appProperties;
}

@end
6 changes: 4 additions & 2 deletions OBAKit/Helpers/OBAHandoff.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
//

import Foundation
import Intents

@objc public class OBAHandoff: NSObject {
@objc static let activityTypeStop = "org.onebusaway.iphone.handoff.stop"
@objc static let activityTypeTripURL = "org.onebusaway.iphone.handoff.tripurl"
@objc static let stopIDKey = "stopID"
@objc static let regionIDKey = "regionID"

@objc
public class func createUserActivity(name: String, stopID: String, regionID: Int) -> NSUserActivity {
@objc public class func createUserActivity(name: String, stopID: String, regionID: Int) -> NSUserActivity {
let activity = NSUserActivity(activityType: OBAHandoff.activityTypeStop)
activity.title = name
activity.isEligibleForHandoff = true
Expand All @@ -26,6 +26,8 @@ import Foundation

if #available(iOS 12.0, *) {
activity.isEligibleForPrediction = true
activity.suggestedInvocationPhrase = NSLocalizedString("handoff.show_me_my_bus", comment: "Suggested invocation phrase for Siri Shortcut")
activity.persistentIdentifier = "region_\(regionID)_stop_\(stopID)"
}

activity.requiredUserInfoKeys = [OBAHandoff.stopIDKey, OBAHandoff.regionIDKey]
Expand Down
4 changes: 2 additions & 2 deletions OBAKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>18.2.1</string>
<string>18.2.2</string>
<key>CFBundleVersion</key>
<string>20180926.23</string>
<string>20181210.18</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
2 changes: 2 additions & 0 deletions OBAKit/Location/OBALocationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ extern NSString * const OBAHeadingUserInfoKey;
@property(nonatomic,copy,nullable,readonly) CLLocation *currentLocation;
@property(nonatomic,copy,nullable,readonly) CLHeading *currentHeading;

@property(nonatomic,assign,readonly) BOOL shouldForceRegionSelection;

/**
Informs the caller whether or not location services are enabled for the app.

Expand Down
4 changes: 4 additions & 0 deletions OBAKit/Location/OBALocationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ - (void)stopUpdatingHeading {
}
}

- (BOOL)shouldForceRegionSelection {
return self.hasRequestedInUseAuthorization && self.modelDao.currentRegion == nil;
}

#pragma mark - Notifications

- (void)applicationDidEnterBackground:(NSNotification*)note {
Expand Down
15 changes: 8 additions & 7 deletions OBAKit/OBAKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
9388C2D32001567F0068041F /* OBAStackedMarqueeLabels.h in Headers */ = {isa = PBXBuildFile; fileRef = 9388C2D12001567F0068041F /* OBAStackedMarqueeLabels.h */; settings = {ATTRIBUTES = (Public, ); }; };
9388C2D42001567F0068041F /* OBAStackedMarqueeLabels.m in Sources */ = {isa = PBXBuildFile; fileRef = 9388C2D22001567F0068041F /* OBAStackedMarqueeLabels.m */; };
938956FD215C3F03008AB975 /* RegionsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 938956FC215C3F03008AB975 /* RegionsService.swift */; };
93895708215D88C4008AB975 /* ObacoService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93895707215D88C4008AB975 /* ObacoService.swift */; };
939A1A8421165989001D5654 /* OBAButtonRow.h in Headers */ = {isa = PBXBuildFile; fileRef = 939A1A8221165989001D5654 /* OBAButtonRow.h */; settings = {ATTRIBUTES = (Public, ); }; };
939A1A8521165989001D5654 /* OBAButtonRow.m in Sources */ = {isa = PBXBuildFile; fileRef = 939A1A8321165989001D5654 /* OBAButtonRow.m */; };
93A6E9E21F5BC18B00AFA61C /* AppInterop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A6E9E11F5BC18B00AFA61C /* AppInterop.swift */; };
Expand Down Expand Up @@ -597,6 +598,7 @@
9388C2D12001567F0068041F /* OBAStackedMarqueeLabels.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OBAStackedMarqueeLabels.h; sourceTree = "<group>"; };
9388C2D22001567F0068041F /* OBAStackedMarqueeLabels.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OBAStackedMarqueeLabels.m; sourceTree = "<group>"; };
938956FC215C3F03008AB975 /* RegionsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegionsService.swift; sourceTree = "<group>"; };
93895707215D88C4008AB975 /* ObacoService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObacoService.swift; sourceTree = "<group>"; };
939A1A8221165989001D5654 /* OBAButtonRow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OBAButtonRow.h; sourceTree = "<group>"; };
939A1A8321165989001D5654 /* OBAButtonRow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OBAButtonRow.m; sourceTree = "<group>"; };
93A6E9E11F5BC18B00AFA61C /* AppInterop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInterop.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1056,6 +1058,7 @@
93D5F3661FF1900700800132 /* OBAURLRequest.swift */,
93113205214D9D450063D400 /* ForecastManager.swift */,
938956FC215C3F03008AB975 /* RegionsService.swift */,
93895707215D88C4008AB975 /* ObacoService.swift */,
);
path = Services;
sourceTree = "<group>";
Expand Down Expand Up @@ -1435,7 +1438,7 @@
TargetAttributes = {
934195381DB0B013004BBBB7 = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual;
};
934195411DB0B013004BBBB7 = {
Expand Down Expand Up @@ -1488,6 +1491,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
93895708215D88C4008AB975 /* ObacoService.swift in Sources */,
939A1A8521165989001D5654 /* OBAButtonRow.m in Sources */,
934196251DB0B099004BBBB7 /* OBASphericalGeometryLibrary.m in Sources */,
931C60D41EC3974E0086EC37 /* OBAApplication.m in Sources */,
Expand Down Expand Up @@ -1832,9 +1836,8 @@
PRODUCT_BUNDLE_IDENTIFIER = org.onebusaway.iphone.OBAKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1858,9 +1861,8 @@
PRODUCT_BUNDLE_IDENTIFIER = org.onebusaway.iphone.OBAKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down Expand Up @@ -1966,9 +1968,8 @@
PRODUCT_BUNDLE_IDENTIFIER = org.onebusaway.iphone.OBAKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = AppStoreDistribution;
};
Expand Down
11 changes: 4 additions & 7 deletions OBAKit/Services/ForecastManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,17 @@ public class ForecastManager: NSObject {

super.init()

NotificationCenter.default.addObserver(self, selector: #selector(applicationWillResignActive(_:)), name: Notification.Name.UIApplicationWillResignActive, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(applicationWillResignActive(_:)), name: UIApplication.willResignActiveNotification, object: nil)

NotificationCenter.default.addObserver(self, selector: #selector(applicationWillBecomeActive(_:)), name: Notification.Name.UIApplicationWillEnterForeground, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(applicationWillBecomeActive(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)

if dueForUpdate {
loadForecast()
}
}

@objc private func loadForecast() {
guard
let region = application.modelDao.currentRegion,
let modelService = application.modelService
else {
guard let region = application.modelDao.currentRegion else {
return
}

Expand All @@ -70,7 +67,7 @@ public class ForecastManager: NSObject {
timer = nil

let loc = application.locationManager.currentLocation
let wrapper = modelService.requestWeather(in: region, location: loc)
let wrapper = application.obacoService.requestWeather(in: region, location: loc)
wrapper.promise.then { [weak self] networkResponse -> Void in
// swiftlint:disable force_cast
let forecast = networkResponse.object as! WeatherForecast
Expand Down
Loading