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

Commit

Permalink
Merge pull request #1129 from OneBusAway/v1741
Browse files Browse the repository at this point in the history
v17.4.1
  • Loading branch information
aaronbrethorst authored May 9, 2017
2 parents d0af221 + 3f41d25 commit b2cb5fd
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 34 deletions.
1 change: 1 addition & 0 deletions OBAKit/Helpers/OBACommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ typedef NS_ENUM(NSInteger, OBANavigationTargetType) {
typedef NS_ENUM(NSUInteger, OBAErrorCode) {
OBAErrorCodeLocationAuthorizationFailed = 1002,
OBAErrorCodePushNotificationAuthorizationDenied,
OABErrorCodeMissingMethodParameters,
};

NSString * _Nullable NSStringFromOBASearchType(OBASearchType searchType);
Expand Down
6 changes: 5 additions & 1 deletion OBAKit/Helpers/OBAReachability.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ + (nullable NSString*)wifiNetworkName {

NSString *SSID = nil;
if (networkInfo) {
SSID = [NSString stringWithString:networkInfo[(NSString*)kCNNetworkInfoKeySSID]];
NSString *SSIDTheirs = networkInfo[(NSString*)kCNNetworkInfoKeySSID];

if (SSIDTheirs) {
SSID = [NSString stringWithString:SSIDTheirs];
}
}

CFRelease(supportedInterfaces);
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>17.4.0</string>
<string>17.4.1</string>
<key>CFBundleVersion</key>
<string>20170503.23</string>
<string>20170507.19</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
6 changes: 5 additions & 1 deletion OBAKit/Models/mantle/OBARegionalAlert.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
@import Foundation;
@import Mantle;

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, OBARegionalAlertPriority) {
OBARegionalAlertPriorityNormal=0,
OBARegionalAlertPriorityHigh
Expand All @@ -23,6 +25,8 @@ typedef NS_ENUM(NSUInteger, OBARegionalAlertPriority) {
@property(nonatomic,copy) NSString *summary;
@property(nonatomic,copy) NSURL *URL;
@property(nonatomic,assign) NSUInteger alertFeedID;
@property(nonatomic,copy) NSDate *publishedAt;
@property(nonatomic,copy,nullable) NSDate *publishedAt;
@property(nonatomic,copy) NSString *externalID;
@end

NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion OBAKit/Services/OBAModelService.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern NSString * const OBAAgenciesWithCoverageAPIPath;

#pragma mark - Alarms

- (id<OBAModelServiceRequest>)requestAlarm:(OBAAlarm*)alarm userPushNotificationID:(NSString*)userPushNotificationID completionBlock:(OBADataSourceCompletion)completion;
- (nullable id<OBAModelServiceRequest>)requestAlarm:(OBAAlarm*)alarm userPushNotificationID:(NSString*)userPushNotificationID completionBlock:(OBADataSourceCompletion)completion;

- (AnyPromise*)requestAlarm:(OBAAlarm*)alarm userPushNotificationID:(NSString*)userPushNotificationID;

Expand Down
33 changes: 31 additions & 2 deletions OBAKit/Services/OBAModelService.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,47 @@ - (AnyPromise*)requestRegionalAlerts:(OBARegionV2*)region sinceDate:(NSDate*)sin

- (AnyPromise*)requestAlarm:(OBAAlarm*)alarm userPushNotificationID:(NSString*)userPushNotificationID {
return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
[self requestAlarm:alarm userPushNotificationID:userPushNotificationID completionBlock:^(id responseData, NSUInteger responseCode, NSError *error) {

id request = [self requestAlarm:alarm userPushNotificationID:userPushNotificationID completionBlock:^(id responseData, NSUInteger responseCode, NSError *error) {
if (responseData) {
resolve(responseData);
}
else {
resolve(error);
}
}];

if (!request) {
resolve([NSError errorWithDomain:OBAErrorDomain code:OABErrorCodeMissingMethodParameters userInfo:@{NSLocalizedDescriptionKey: OBALocalized(@"model_service.cant_register_alarm_missing_parameters", @"An error displayed to the user when their alarm can't be created.")}]);
}
}];
}

- (id<OBAModelServiceRequest>)requestAlarm:(OBAAlarm*)alarm userPushNotificationID:(NSString*)userPushNotificationID completionBlock:(OBADataSourceCompletion)completion {
- (nullable id<OBAModelServiceRequest>)requestAlarm:(OBAAlarm*)alarm userPushNotificationID:(NSString*)userPushNotificationID completionBlock:(OBADataSourceCompletion)completion {

OBAGuard(alarm.timeIntervalBeforeDeparture > 0) else {
return nil;
}

OBAGuard(alarm.stopID) else {
return nil;
}

OBAGuard(alarm.tripID) else {
return nil;
}

OBAGuard(alarm.serviceDate != 0) else {
return nil;
}

OBAGuard(alarm.vehicleID) else {
return nil;
}

OBAGuard(userPushNotificationID) else {
return nil;
}

NSDictionary *params = @{
@"seconds_before": @(alarm.timeIntervalBeforeDeparture),
Expand Down
3 changes: 3 additions & 0 deletions OBAKit/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,6 @@

/* The text 'Read More…' (note that is an ellipsis, not three dots…) */
"strings.read_more" = "Read More…";

/* An error displayed to the user when their alarm can't be created. */
"model_service.cant_register_alarm_missing_parameters" = "Sorry, we can't create an alarm for this upcoming trip. You're welcome to try again, but it probably won't make any difference. Sorry about that :(";
5 changes: 4 additions & 1 deletion OBAKit/regional_alerts/RegionalAlertsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ import CocoaLumberjackSwift
mergedModels.append(contentsOf: modelMap.values)

mergedModels.sort { (alert1, alert2) -> Bool in
return (alert1.publishedAt >= alert2.publishedAt)
let date1 = alert1.publishedAt ?? Date()
let date2 = alert2.publishedAt ?? Date()

return date1 >= date2
}

return mergedModels
Expand Down
4 changes: 2 additions & 2 deletions OneBusAway/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>17.4.0</string>
<string>17.4.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>20170503.23</string>
<string>20170507.19</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
10 changes: 5 additions & 5 deletions OneBusAway/Resources/Launch Screen.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_0" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -18,11 +18,11 @@
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tabBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Qqv-oa-8Ro">
<rect key="frame" x="0.0" y="618" width="375" height="49"/>
<rect key="frame" x="0.0" y="519" width="320" height="49"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<items>
<tabBarItem title="" image="Map" id="ZEy-hw-S0U"/>
Expand Down
17 changes: 8 additions & 9 deletions OneBusAway/externals/GKActionSheetPicker/GKActionSheetPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,14 @@ - (void)datePickerDidChangeValue:(UIDatePicker *)datePicker
- (void)updateSelection
{
if (self.pickerType == GKActionSheetPickerTypeString) {

NSUInteger index = [self.pickerView selectedRowInComponent:0];
GKActionSheetPickerItem *item = [self.items objectAtIndex:index];
self.selection = item.value;

} else if (self.pickerType == GKActionSheetPickerTypeMultiColumnString) {

if (self.items.count > index) {
GKActionSheetPickerItem *item = self.items[index];
self.selection = item.value;
}
}
else if (self.pickerType == GKActionSheetPickerTypeMultiColumnString) {
NSMutableArray *selections = [NSMutableArray new];

for (NSUInteger i=0; i<self.components.count; i++) {
Expand All @@ -670,11 +671,9 @@ - (void)updateSelection
}

self.selections = selections;

} else if (self.pickerType == GKActionSheetPickerTypeDate) {

}
else if (self.pickerType == GKActionSheetPickerTypeDate) {
self.selectedDate = self.datePicker.date;

}
}

Expand Down
27 changes: 18 additions & 9 deletions OneBusAway/ui/static_table/cells/OBAMessageCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,7 @@ - (void)setTableRow:(OBABaseRow *)tableRow {
self.senderLabel.text = [self messageRow].sender;
self.subjectLabel.text = [self messageRow].subject;

if ([self messageRow].date.isToday) {
self.dateLabel.text = [OBADateHelpers formatShortTimeNoDate:[self messageRow].date];
}
else if ([self messageRow].date.isYesterday) {
self.dateLabel.text = OBAStrings.yesterday;
}
else {
self.dateLabel.text = [OBADateHelpers formatNoTimeShortDate:self.messageRow.date];
}
[self configureDateLabelForDate:self.messageRow.date];

self.unreadImageView.alpha = [self messageRow].unread ? 1.f : 0.f;

Expand All @@ -135,6 +127,23 @@ - (void)setTableRow:(OBABaseRow *)tableRow {
}
}

- (void)configureDateLabelForDate:(nullable NSDate*)date {
if (![self messageRow].date) {
self.dateLabel.text = nil;
return;
}

if ([self messageRow].date.isToday) {
self.dateLabel.text = [OBADateHelpers formatShortTimeNoDate:[self messageRow].date];
}
else if ([self messageRow].date.isYesterday) {
self.dateLabel.text = OBAStrings.yesterday;
}
else {
self.dateLabel.text = [OBADateHelpers formatNoTimeShortDate:self.messageRow.date];
}
}

- (OBAMessageRow*)messageRow {
return (OBAMessageRow*)self.tableRow;
}
Expand Down
2 changes: 1 addition & 1 deletion OneBusAway/ui/static_table/viewmodels/OBAMessageRow.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OBAMessageRow : OBABaseRow
@property(nonatomic,copy) NSString *sender;
@property(nonatomic,copy) NSString *subject;
@property(nonatomic,copy) NSDate *date;
@property(nonatomic,copy,nullable) NSDate *date;
@property(nonatomic,assign) BOOL unread;
@property(nonatomic,assign) BOOL highPriority;
@end
Expand Down

0 comments on commit b2cb5fd

Please sign in to comment.