Unverified Commit 26317b78 authored by Zach Knox's avatar Zach Knox
Browse files

added API endpoint URL support and fixed a couple bugs

If the URL is not HTTPS, you'll need to set the Allow Arbitrary Loads item in Info.plist to YES. DO NOT SET IT TO YES WHEN SUBMITTING TO THE STORE
parent b0de008f
...@@ -846,7 +846,7 @@ ...@@ -846,7 +846,7 @@
}; };
CD81F5181DC0334600009FBD = { CD81F5181DC0334600009FBD = {
CreatedOnToolsVersion = 8.0; CreatedOnToolsVersion = 8.0;
DevelopmentTeam = HQSN7HX89U; DevelopmentTeam = N5GM564QWL;
LastSwiftMigration = 0910; LastSwiftMigration = 0910;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
...@@ -1870,7 +1870,7 @@ ...@@ -1870,7 +1870,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SHARED_BUILD_NUMBER = 51; SHARED_BUILD_NUMBER = 52;
SHARED_VERSION_NUMBER = 1.2; SHARED_VERSION_NUMBER = 1.2;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
...@@ -1888,7 +1888,7 @@ ...@@ -1888,7 +1888,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4; CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = HQSN7HX89U; DEVELOPMENT_TEAM = N5GM564QWL;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)", "$(PROJECT_DIR)",
...@@ -1898,7 +1898,7 @@ ...@@ -1898,7 +1898,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -D APPSTORE"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -D APPSTORE";
PRIMARYICON = appicon; PRIMARYICON = appicon;
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen; PRODUCT_BUNDLE_IDENTIFIER = srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
...@@ -2172,7 +2172,7 @@ ...@@ -2172,7 +2172,7 @@
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SHARED_BUILD_NUMBER = 51; SHARED_BUILD_NUMBER = 52;
SHARED_VERSION_NUMBER = 1.2; SHARED_VERSION_NUMBER = 1.2;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
...@@ -2224,7 +2224,7 @@ ...@@ -2224,7 +2224,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SHARED_BUILD_NUMBER = 51; SHARED_BUILD_NUMBER = 52;
SHARED_VERSION_NUMBER = 1.2; SHARED_VERSION_NUMBER = 1.2;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
...@@ -2242,7 +2242,7 @@ ...@@ -2242,7 +2242,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4; CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = HQSN7HX89U; DEVELOPMENT_TEAM = N5GM564QWL;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)", "$(PROJECT_DIR)",
...@@ -2251,7 +2251,7 @@ ...@@ -2251,7 +2251,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRIMARYICON = "appicon-dev"; PRIMARYICON = "appicon-dev";
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen; PRODUCT_BUNDLE_IDENTIFIER = srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_SWIFT3_OBJC_INFERENCE = Default;
...@@ -2272,7 +2272,7 @@ ...@@ -2272,7 +2272,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4; CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = HQSN7HX89U; DEVELOPMENT_TEAM = N5GM564QWL;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)", "$(PROJECT_DIR)",
...@@ -2281,7 +2281,7 @@ ...@@ -2281,7 +2281,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 12.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRIMARYICON = "appicon-dev"; PRIMARYICON = "appicon-dev";
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen; PRODUCT_BUNDLE_IDENTIFIER = srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
......
...@@ -42,6 +42,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -42,6 +42,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
if defaults.value(forKey: "mapsApp") == nil { if defaults.value(forKey: "mapsApp") == nil {
defaults.set("Apple Maps", forKey: "mapsApp") defaults.set("Apple Maps", forKey: "mapsApp")
} }
if defaults.value(forKey: "apiURL") == nil {
defaults.set("https://api.srct.gmu.edu/whatsopen/v2/", forKey: "apiURL")
}
application.setMinimumBackgroundFetchInterval(3600) application.setMinimumBackgroundFetchInterval(3600)
......
...@@ -501,6 +501,7 @@ ...@@ -501,6 +501,7 @@
</view> </view>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<connections> <connections>
<outlet property="aboutLogo" destination="tzw-Ro-L8p" id="0FY-37-64r"/>
<outlet property="versionLabel" destination="WT6-Th-cbL" id="AAg-iN-BqQ"/> <outlet property="versionLabel" destination="WT6-Th-cbL" id="AAg-iN-BqQ"/>
</connections> </connections>
</viewController> </viewController>
......
...@@ -58,6 +58,11 @@ ...@@ -58,6 +58,11 @@
</array> </array>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
</dict>
<key>NSUserActivityTypes</key> <key>NSUserActivityTypes</key>
<array> <array>
<string>WOPViewFacilityIntent</string> <string>WOPViewFacilityIntent</string>
......
...@@ -8,15 +8,37 @@ ...@@ -8,15 +8,37 @@
import UIKit import UIKit
import SafariServices import SafariServices
import WhatsOpenKit
class AboutScreenViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { class AboutScreenViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var versionLabel: UILabel! @IBOutlet var versionLabel: UILabel!
@IBOutlet var aboutLogo: UIImageView!
override var preferredStatusBarStyle: UIStatusBarStyle { override var preferredStatusBarStyle: UIStatusBarStyle {
return .default return .default
} }
@objc func pickAPIURL(_ sender: Any?) {
let alert = UIAlertController(title: "Set API Endpoint URL?", message: "", preferredStyle: .alert)
alert.addTextField { textField in
textField.text = WOPDatabaseController.getDefaults().string(forKey: "apiURL") ?? ""
}
alert.addAction(UIAlertAction(title: "Reset", style: .destructive, handler: { (action) in
WOPDatabaseController.getDefaults().set("https://api.srct.gmu.edu/whatsopen/v2/", forKey: "apiURL")
alert.dismiss(animated: true, completion: nil)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) in
alert.dismiss(animated: true, completion: nil)
}))
alert.addAction(UIAlertAction(title: "Set", style: .default, handler: { (action) in
WOPDatabaseController.getDefaults().set(alert.textFields![0].text, forKey: "apiURL")
}))
present(alert, animated: true, completion: nil)
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -27,7 +49,9 @@ class AboutScreenViewController: UIViewController, UITableViewDelegate, UITableV ...@@ -27,7 +49,9 @@ class AboutScreenViewController: UIViewController, UITableViewDelegate, UITableV
versionLabel.text = versionstring versionLabel.text = versionstring
let longPress = UILongPressGestureRecognizer(target: self, action: #selector(pickAPIURL(_:)))
aboutLogo.isUserInteractionEnabled = true
aboutLogo.addGestureRecognizer(longPress)
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
} }
......
...@@ -11,9 +11,11 @@ import MapKit ...@@ -11,9 +11,11 @@ import MapKit
import WhatsOpenKit import WhatsOpenKit
import Intents import Intents
import IntentsUI import IntentsUI
import DeckTransition
class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutViewControllerDelegate { class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutViewControllerDelegate, DeckTransitionViewControllerProtocol {
var childViewControllerForDeck: UIViewController?
@IBOutlet var facilityDetailView: UIView! @IBOutlet var facilityDetailView: UIView!
var detailViewController: WOPFacilityDetailViewController? var detailViewController: WOPFacilityDetailViewController?
...@@ -106,6 +108,7 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie ...@@ -106,6 +108,7 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
self.detailViewController!.view.translatesAutoresizingMaskIntoConstraints = false self.detailViewController!.view.translatesAutoresizingMaskIntoConstraints = false
self.addChild(self.detailViewController!) self.addChild(self.detailViewController!)
self.addSubview(self.detailViewController!.view, toView: self.facilityDetailView) self.addSubview(self.detailViewController!.view, toView: self.facilityDetailView)
childViewControllerForDeck = self.detailViewController
super.viewDidLoad() super.viewDidLoad()
setFavoriteButtonText() setFavoriteButtonText()
......
...@@ -7,9 +7,12 @@ ...@@ -7,9 +7,12 @@
// //
import UIKit import UIKit
import DeckTransition
class PullingViewController: UIViewController { class PullingViewController: UIViewController, DeckTransitionViewControllerProtocol {
var childViewControllerForDeck: UIViewController?
@IBOutlet var containerView: UIView! @IBOutlet var containerView: UIView!
weak var currentViewController: UIViewController? weak var currentViewController: UIViewController?
...@@ -45,6 +48,7 @@ class PullingViewController: UIViewController { ...@@ -45,6 +48,7 @@ class PullingViewController: UIViewController {
self.accessibilityCustomActions = [ self.accessibilityCustomActions = [
UIAccessibilityCustomAction(name: "Dismiss Detail View", target: self, selector: #selector(PullingViewController.willDismiss)) UIAccessibilityCustomAction(name: "Dismiss Detail View", target: self, selector: #selector(PullingViewController.willDismiss))
] ]
childViewControllerForDeck = self.currentViewController
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
......
...@@ -14,8 +14,9 @@ import ObjectMapper ...@@ -14,8 +14,9 @@ import ObjectMapper
public class WOPDownloadController: NSObject { public class WOPDownloadController: NSObject {
//https://api.srct.gmu.edu/whatsopen/v2/facilities/?format=json //https://api.srct.gmu.edu/whatsopen/v2/facilities/?format=json
public static func performDownload(completion: @escaping (_ result: List<WOPFacility>?) -> Void) { public static func performDownload(completion: @escaping (_ result: List<WOPFacility>?) -> Void) {
let apiURL = WOPDatabaseController.getDefaults().string(forKey: "apiURL") ?? "https://api.srct.gmu.edu/whatsopen/v2/"
let requestURL: NSURL = NSURL(string: "https://api.srct.gmu.edu/whatsopen/v2/facilities/?format=json")!
let requestURL: NSURL = NSURL(string: "\(apiURL)facilities/?format=json")!
let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL) let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL)
let session = URLSession.shared let session = URLSession.shared
...@@ -23,6 +24,7 @@ public class WOPDownloadController: NSObject { ...@@ -23,6 +24,7 @@ public class WOPDownloadController: NSObject {
(data, response, error) -> Void in (data, response, error) -> Void in
if(error != nil) { if(error != nil) {
dump(error)
completion(nil) completion(nil)
return return
} }
...@@ -56,8 +58,9 @@ public class WOPDownloadController: NSObject { ...@@ -56,8 +58,9 @@ public class WOPDownloadController: NSObject {
} }
public static func performAlertsDownload(completion: @escaping (_ result: List<WOPAlert>?) -> Void) { public static func performAlertsDownload(completion: @escaping (_ result: List<WOPAlert>?) -> Void) {
let apiURL = WOPDatabaseController.getDefaults().string(forKey: "apiURL") ?? "https://api.srct.gmu.edu/whatsopen/v2/"
let requestURL: NSURL = NSURL(string: "https://api.srct.gmu.edu/whatsopen/v2/alerts/?format=json")! let requestURL: NSURL = NSURL(string: "\(apiURL)alerts/?format=json")!
let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL) let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL)
let session = URLSession.shared let session = URLSession.shared
......
...@@ -71,7 +71,7 @@ public class WOPFacilityDetailViewController: UIViewController, UITableViewDeleg ...@@ -71,7 +71,7 @@ public class WOPFacilityDetailViewController: UIViewController, UITableViewDeleg
OpenLabel.backgroundColor = UIColor(red:0.17, green:0.17, blue: 0.17, alpha: 1.0) OpenLabel.backgroundColor = UIColor(red:0.17, green:0.17, blue: 0.17, alpha: 1.0)
} }
OpenTimesList.bounces = false OpenTimesList.bounces = true
if #available(iOS 11.0, *) { if #available(iOS 11.0, *) {
navigationItem.largeTitleDisplayMode = .never navigationItem.largeTitleDisplayMode = .never
......
...@@ -273,7 +273,7 @@ public class WOPAlert: Object, MapContext, Mappable { ...@@ -273,7 +273,7 @@ public class WOPAlert: Object, MapContext, Mappable {
urgency <- map["urgency_tag"] urgency <- map["urgency_tag"]
subject <- map["subject"] subject <- map["subject"]
body <- map["body"] body <- map["body"]
message <- map["url"] url <- map["url"]
message <- map["message"] message <- map["message"]
startDate <- map["start_datetime"] startDate <- map["start_datetime"]
endDate <- map["end_datetime"] endDate <- map["end_datetime"]
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" usesAttributedText="YES" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RN8-f7-qjd"> <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" usesAttributedText="YES" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RN8-f7-qjd">
<rect key="frame" x="16" y="94" width="343" height="553"/> <rect key="frame" x="16" y="94" width="343" height="573"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<attributedString key="attributedText"> <attributedString key="attributedText">
<fragment> <fragment>
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints> <constraints>
<constraint firstItem="KTh-gG-Ygq" firstAttribute="bottom" secondItem="RN8-f7-qjd" secondAttribute="bottom" constant="20" id="9Q1-0E-LoL"/> <constraint firstItem="KTh-gG-Ygq" firstAttribute="bottom" secondItem="RN8-f7-qjd" secondAttribute="bottom" id="9Q1-0E-LoL"/>
<constraint firstItem="RN8-f7-qjd" firstAttribute="leading" secondItem="KTh-gG-Ygq" secondAttribute="leading" constant="16" id="BTq-qf-AKg"/> <constraint firstItem="RN8-f7-qjd" firstAttribute="leading" secondItem="KTh-gG-Ygq" secondAttribute="leading" constant="16" id="BTq-qf-AKg"/>
<constraint firstItem="7p3-a2-wz4" firstAttribute="leading" secondItem="KTh-gG-Ygq" secondAttribute="leading" constant="16" id="BXV-c8-S4r"/> <constraint firstItem="7p3-a2-wz4" firstAttribute="leading" secondItem="KTh-gG-Ygq" secondAttribute="leading" constant="16" id="BXV-c8-S4r"/>
<constraint firstItem="lSK-qc-Uis" firstAttribute="centerY" secondItem="7p3-a2-wz4" secondAttribute="centerY" id="Dyn-aP-deC"/> <constraint firstItem="lSK-qc-Uis" firstAttribute="centerY" secondItem="7p3-a2-wz4" secondAttribute="centerY" id="Dyn-aP-deC"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment