Unverified Commit fa006df2 authored by Zach Knox's avatar Zach Knox
Browse files

starting on notifications, among other things I forgot

parent 275c15da
......@@ -19,5 +19,8 @@
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="DGD-49-9Ue">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="DGD-49-9Ue">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
......@@ -733,61 +733,47 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mbm-hc-vWv">
<rect key="frame" x="16" y="596" width="275" height="51"/>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mbm-hc-vWv">
<rect key="frame" x="16" y="596" width="104" height="51"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="51" id="0LG-d5-1dD"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="19"/>
<state key="normal" title="Button">
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" image="heart_empty">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="setFavButton:" destination="NAf-lT-JCD" eventType="touchUpInside" id="QKk-0C-GDD"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rd0-fz-V4r" userLabel="Directions Button">
<rect key="frame" x="16" y="537" width="275" height="51"/>
<color key="backgroundColor" red="0.0" green="0.4793452024" blue="0.99908632040000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="19"/>
<state key="normal" title="Button">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="getDirections:" destination="NAf-lT-JCD" eventType="touchUpInside" id="hNO-dV-uVE"/>
</connections>
</button>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1VL-kk-arL">
<rect key="frame" x="0.0" y="20" width="375" height="509"/>
<rect key="frame" x="0.0" y="20" width="375" height="572"/>
<connections>
<segue destination="1kS-1Q-PtR" kind="embed" id="lAt-8Z-xSi"/>
</connections>
</containerView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tPh-uh-8zb" userLabel="Share Button">
<rect key="frame" x="299" y="537" width="60" height="51"/>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tPh-uh-8zb" userLabel="Share Button">
<rect key="frame" x="245" y="596" width="114" height="51"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="GQk-nH-8Xz"/>
<constraint firstAttribute="height" constant="51" id="Yzq-3h-3o2"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="19"/>
<state key="normal" title="Button">
<state key="normal" title="Share">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="shareFacility:" destination="NAf-lT-JCD" eventType="touchUpInside" id="mdd-wn-v6b"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uBr-jZ-W8U" userLabel="Siri Button">
<rect key="frame" x="299" y="596" width="60" height="51"/>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uBr-jZ-W8U" userLabel="Siri Button">
<rect key="frame" x="128" y="596" width="109" height="51"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="TDB-m2-H2C"/>
<constraint firstAttribute="height" constant="51" id="kvz-hJ-x9x"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="19"/>
<state key="normal" title="Siri"/>
<state key="normal" image="addshortcut"/>
<connections>
<action selector="addToSiri:" destination="NAf-lT-JCD" eventType="touchUpInside" id="am3-3Y-AGJ"/>
</connections>
......@@ -795,29 +781,27 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Rd0-fz-V4r" firstAttribute="top" secondItem="1VL-kk-arL" secondAttribute="bottom" constant="8" id="1wo-Gz-1kd"/>
<constraint firstItem="tPh-uh-8zb" firstAttribute="baseline" secondItem="Rd0-fz-V4r" secondAttribute="firstBaseline" id="94e-aV-Mjr"/>
<constraint firstItem="uBr-jZ-W8U" firstAttribute="baseline" secondItem="Mbm-hc-vWv" secondAttribute="baseline" id="7QM-Oo-Otm"/>
<constraint firstItem="uBr-jZ-W8U" firstAttribute="baseline" secondItem="tPh-uh-8zb" secondAttribute="baseline" id="DE2-sM-euW"/>
<constraint firstItem="uBr-jZ-W8U" firstAttribute="centerX" secondItem="fo3-mS-Mxq" secondAttribute="centerX" id="Gnx-Ni-Em0"/>
<constraint firstItem="uBr-jZ-W8U" firstAttribute="width" secondItem="tPh-uh-8zb" secondAttribute="width" id="InP-bs-Agf"/>
<constraint firstItem="1VL-kk-arL" firstAttribute="leading" secondItem="fo3-mS-Mxq" secondAttribute="leading" id="KPT-Uu-PmZ"/>
<constraint firstItem="Mbm-hc-vWv" firstAttribute="centerX" secondItem="fo3-mS-Mxq" secondAttribute="centerX" constant="-34" id="KcF-YS-Tws"/>
<constraint firstItem="tPh-uh-8zb" firstAttribute="top" secondItem="1VL-kk-arL" secondAttribute="bottom" constant="8" symbolic="YES" id="QfV-0N-meh"/>
<constraint firstItem="uBr-jZ-W8U" firstAttribute="leading" secondItem="Mbm-hc-vWv" secondAttribute="trailing" constant="8" id="RtF-F9-P1Y"/>
<constraint firstItem="tPh-uh-8zb" firstAttribute="leading" secondItem="uBr-jZ-W8U" secondAttribute="trailing" constant="8" id="SVQ-mW-mxL"/>
<constraint firstItem="Mbm-hc-vWv" firstAttribute="width" secondItem="uBr-jZ-W8U" secondAttribute="width" id="ZWN-n7-W7a"/>
<constraint firstItem="fo3-mS-Mxq" firstAttribute="trailing" secondItem="1VL-kk-arL" secondAttribute="trailing" id="ZlT-eF-6pp"/>
<constraint firstItem="Mbm-hc-vWv" firstAttribute="top" secondItem="Rd0-fz-V4r" secondAttribute="bottom" constant="8" id="bu2-dc-0M3"/>
<constraint firstItem="uBr-jZ-W8U" firstAttribute="baseline" secondItem="Mbm-hc-vWv" secondAttribute="baseline" id="iuv-u1-9sA"/>
<constraint firstItem="fo3-mS-Mxq" firstAttribute="bottom" secondItem="Mbm-hc-vWv" secondAttribute="bottom" constant="20" id="kWd-aJ-Tk2"/>
<constraint firstItem="tPh-uh-8zb" firstAttribute="trailing" secondItem="Mbm-hc-vWv" secondAttribute="trailing" constant="68" id="ne6-b2-0Of"/>
<constraint firstItem="uBr-jZ-W8U" firstAttribute="leading" secondItem="tPh-uh-8zb" secondAttribute="leading" id="ov1-gk-biP"/>
<constraint firstItem="fo3-mS-Mxq" firstAttribute="trailing" secondItem="Mbm-hc-vWv" secondAttribute="trailing" constant="84" id="qvu-Jk-9lw"/>
<constraint firstItem="uBr-jZ-W8U" firstAttribute="bottom" secondItem="tPh-uh-8zb" secondAttribute="bottom" id="bDp-0k-ykn"/>
<constraint firstItem="tPh-uh-8zb" firstAttribute="trailing" secondItem="fo3-mS-Mxq" secondAttribute="trailing" constant="-16" id="eAW-QJ-UXp"/>
<constraint firstItem="Mbm-hc-vWv" firstAttribute="leading" secondItem="fo3-mS-Mxq" secondAttribute="leading" constant="16" id="k7T-K8-yQ7"/>
<constraint firstItem="fo3-mS-Mxq" firstAttribute="bottom" secondItem="Mbm-hc-vWv" secondAttribute="bottom" constant="16" id="kWd-aJ-Tk2"/>
<constraint firstItem="Mbm-hc-vWv" firstAttribute="bottom" secondItem="uBr-jZ-W8U" secondAttribute="bottom" id="nbc-6k-cB3"/>
<constraint firstItem="1VL-kk-arL" firstAttribute="top" secondItem="fo3-mS-Mxq" secondAttribute="top" id="sH0-Pb-3f8"/>
<constraint firstItem="tPh-uh-8zb" firstAttribute="top" secondItem="1VL-kk-arL" secondAttribute="bottom" constant="8" id="scv-dq-6Ri"/>
<constraint firstItem="tPh-uh-8zb" firstAttribute="leading" secondItem="Rd0-fz-V4r" secondAttribute="trailing" constant="8" symbolic="YES" id="tRn-21-tqE"/>
<constraint firstItem="Rd0-fz-V4r" firstAttribute="leading" secondItem="fo3-mS-Mxq" secondAttribute="leading" constant="16" id="xn4-32-G07"/>
<constraint firstItem="Mbm-hc-vWv" firstAttribute="leading" secondItem="fo3-mS-Mxq" secondAttribute="leading" constant="16" id="zdZ-4g-IFY"/>
<constraint firstItem="Mbm-hc-vWv" firstAttribute="top" secondItem="1VL-kk-arL" secondAttribute="bottom" constant="8" id="uio-Yr-bYX"/>
</constraints>
<viewLayoutGuide key="safeArea" id="fo3-mS-Mxq"/>
</view>
<connections>
<outlet property="addToSiriButton" destination="uBr-jZ-W8U" id="Am3-u0-j5Y"/>
<outlet property="directionsButton" destination="Rd0-fz-V4r" id="4Eg-BB-g2o"/>
<outlet property="facilityDetailView" destination="1VL-kk-arL" id="Un1-Pm-5gH"/>
<outlet property="favoritesButton" destination="Mbm-hc-vWv" id="CLZ-N6-AGv"/>
<outlet property="shareButton" destination="tPh-uh-8zb" id="12i-ow-Mdb"/>
......@@ -847,7 +831,7 @@
<objects>
<viewController id="1kS-1Q-PtR" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="uus-pO-zaY">
<rect key="frame" x="0.0" y="0.0" width="375" height="509"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="572"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="gRZ-TI-P5X"/>
......@@ -861,8 +845,10 @@
<resources>
<image name="Gear" width="12" height="12"/>
<image name="WO_Black_TextLight" width="2355" height="692"/>
<image name="addshortcut" width="27" height="27"/>
<image name="detailIndicator" width="6" height="9.8400001525878906"/>
<image name="downPull" width="108" height="32"/>
<image name="heart_empty" width="27" height="27"/>
<image name="info" width="63.840000152587891" height="63.840000152587891"/>
<image name="major" width="63.840000152587891" height="63.840000152587891"/>
</resources>
......
......@@ -21,7 +21,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>${SHARED_VERSION_NUMBER}</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
......@@ -36,7 +36,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>45</string>
<string>${SHARED_BUILD_NUMBER}</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
......
......@@ -20,7 +20,6 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
var facility: WOPFacility!
@IBOutlet var favoritesButton: UIButton!
@IBOutlet var directionsButton: UIButton!
@IBOutlet var shareButton: UIButton!
@IBOutlet var addToSiriButton: UIButton!
......@@ -42,7 +41,7 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
setFavoriteButtonText()
}
@IBAction func getDirections(_ sender: Any) {
func getDirections(_ sender: Any) {
let appToUse = WOPDatabaseController.getDefaults().value(forKey: "mapsApp") as? String
if appToUse == "Google Maps" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
......@@ -73,8 +72,10 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
@IBAction func shareFacility(_ sender: Any) {
let str = "\(facility.facilityName) is \(WOPUtilities.openOrClosedUntil(facility)!.lowercased())"
let shareSheet = UIActivityViewController(activityItems: ["\(str) https://whatsopen.gmu.edu/"], applicationActivities: nil)
// TODO in future: add URL based on facility once web supports it
let shareSheet = UIActivityViewController(activityItems: [str, (URL(string: "https://whatsopen.gmu.edu") ?? nil), facility], applicationActivities: [ViewInMapsActionActivity()])
shareSheet.excludedActivityTypes = [.print, .openInIBooks, .addToReadingList] // Sorry you can't print a Facility
present(shareSheet, animated: true, completion: nil)
}
......@@ -84,12 +85,14 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
*/
func setFavoriteButtonText() {
if(WOPUtilities.isFavoriteFacility(facility)) {
favoritesButton.setTitle("Remove from Favorites", for: .normal)
favoritesButton.titleLabel?.text = "Remove from Favorites"
favoritesButton.accessibilityLabel = "Remove from Favorites"
favoritesButton.titleLabel?.text = ""
favoritesButton.setImage(UIImage(named: "heart_filled"), for: .normal)
}
else {
favoritesButton.setTitle("Add to Favorites", for: .normal)
favoritesButton.titleLabel?.text = "Add to Favorites"
favoritesButton.accessibilityLabel = "Add to Favorites"
favoritesButton.titleLabel?.text = ""
favoritesButton.setImage(UIImage(named: "heart_empty"), for: .normal)
}
}
......@@ -105,33 +108,20 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
favoritesButton.tintColor = UIColor.white
favoritesButton.backgroundColor = UIColor(red:0.00, green:0.40, blue:0.20, alpha:1.0)
favoritesButton.layer.cornerRadius = 10
directionsButton.tintColor = UIColor.white
directionsButton.backgroundColor = #colorLiteral(red: 0, green: 0.4793452024, blue: 0.9990863204, alpha: 1)
directionsButton.layer.cornerRadius = 10
let appToUse = WOPDatabaseController.getDefaults().value(forKey: "mapsApp") as? String
if appToUse == "Google Maps" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
directionsButton.setTitle("View in Google Maps", for: .normal)
}
else if appToUse == "Waze" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
directionsButton.setTitle("View in Waze", for: .normal)
}
else {
directionsButton.setTitle("View in Maps", for: .normal)
}
shareButton.tintColor = UIColor.white
shareButton.backgroundColor = UIColor.orange
shareButton.layer.cornerRadius = 10
shareButton.setImage(#imageLiteral(resourceName: "shareIcon"), for: .normal)
shareButton.setTitle("", for: .normal)
shareButton.accessibilityLabel = "Share"
setActivityUp()
addToSiriButton.tintColor = UIColor.black
addToSiriButton.backgroundColor = UIColor.white
addToSiriButton.layer.borderWidth = 3
addToSiriButton.layer.borderColor = UIColor.black.cgColor
addToSiriButton.tintColor = UIColor.white
addToSiriButton.backgroundColor = UIColor.black
addToSiriButton.layer.cornerRadius = 10
addToSiriButton.accessibilityLabel = "Add to Siri"
let interaction = INInteraction(intent: facility.createIntent(), response: WOPViewFacilityIntentUtils.getIntentResponse(facility, userActivity: activity))
interaction.donate(completion: nil)
......
......@@ -35,11 +35,16 @@ class FilterSelectionTableViewController: UITableViewController {
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
if navigationItem.title = "Alert Notifications" {
return 2
}
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section != 0 {
return 1
}
if canSelectAll {
return 1 + getFunc().count
}
......@@ -48,7 +53,14 @@ class FilterSelectionTableViewController: UITableViewController {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "filterSelection", for: indexPath)
if indexPath.section != 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "filterSelection", for: indexPath)
cell.accessoryType = .detailButton
cell.textLabel?.text = "Open Notifications Settings"
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "filterSelection", for: indexPath)
let values = getFunc()
// Configure the cell...
......@@ -83,6 +95,10 @@ class FilterSelectionTableViewController: UITableViewController {
}
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
if section != 0 {
return "The above settings will only apply if you have notifications enabled for What's Open in Settings."
}
if navigationItem.title == "Show Alerts" {
return "Emergency Alerts are always enabled in the app for your safety. We will never send a notification to your device without your consent."
}
......@@ -93,6 +109,11 @@ class FilterSelectionTableViewController: UITableViewController {
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section != 0 {
UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!, completionHandler: nil)
return
}
if(indexPath.row == 0) {
_ = selectAllFunc()
tableView.reloadData()
......
......@@ -263,21 +263,29 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
trueDest = destination
}
if(self.view.traitCollection.horizontalSizeClass == .regular && self.view.traitCollection.verticalSizeClass == .regular) {
//do a popover here for the iPad
//iPads are cool right?
trueDest.modalPresentationStyle = .popover
let popoverController = trueDest.popoverPresentationController
popoverController?.permittedArrowDirections = .any
popoverController?.sourceView = tapped.contentView
popoverController?.sourceRect = tapped.bounds
// present the detail view over the search controller if we're searching
if searchController.isActive {
searchController.present(trueDest, animated: true, completion: nil)
}
else {
present(trueDest, animated: true, completion: nil)
}
let external = UIScreen.screens
if external.count > 1 {
var window = UIWindow(frame: external[1].bounds)
window.screen = external[1]
window.rootViewController = trueDest
window.isHidden = false
} else {
//do a popover here for the iPad
//iPads are cool right?
trueDest.modalPresentationStyle = .popover
let popoverController = trueDest.popoverPresentationController
popoverController?.permittedArrowDirections = .any
popoverController?.sourceView = tapped.contentView
popoverController?.sourceRect = tapped.bounds
// present the detail view over the search controller if we're searching
if searchController.isActive {
searchController.present(trueDest, animated: true, completion: nil)
}
else {
present(trueDest, animated: true, completion: nil)
}
}
}
else {
let finalDestination = self.storyboard?.instantiateViewController(withIdentifier: "pulling") as? PullingViewController // Fox only, no items
......
......@@ -285,6 +285,14 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
destination.selectAllFunc = WOPUtilities.setAllAlertDefaults
destination.updateFacilities = updateFacilities
}
else if (sender as! UITableViewCell).textLabel?.text == "Alert Notifications" {
let destination = segue.destination as! FilterSelectionTableViewController
destination.navigationItem.title = "Alert Notifications"
destination.getFunc = WOPUtilities.getCampusDefaults
destination.selectFunc = WOPUtilities.setCampusDefaults
destination.selectAllFunc = WOPUtilities.setAllCampusDefaults
destination.updateFacilities = updateFacilities
}
else if (sender as! UITableViewCell).textLabel?.text == "Show Campuses" {
let destination = segue.destination as! FilterSelectionTableViewController
destination.navigationItem.title = "Show Campuses"
......
//
// ViewInMapsActionActivity.swift
// WhatsOpen
//
// Created by Zach Knox on 12/22/18.
// Copyright © 2018 SRCT. All rights reserved.
//
import UIKit
import MapKit
import WhatsOpenKit
class ViewInMapsActionActivity: UIActivity {
override var activityType: UIActivity.ActivityType? {
return UIActivity.ActivityType(rawValue: "maps")
}
override var activityTitle: String? {
let appToUse = WOPDatabaseController.getDefaults().value(forKey: "mapsApp") as? String
if appToUse == "Google Maps" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
return "View in Google Maps"
}
else if appToUse == "Waze" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
return "View in Waze"
}
else {
return "View in Maps"
}
}
override var activityImage: UIImage? {
return UIImage(named: "map")
}
var facility: WOPFacility? = nil
override func canPerform(withActivityItems activityItems: [Any]) -> Bool {
for i in activityItems {
if i as? WOPFacility != nil {
return true
}
}
return false
}
override func prepare(withActivityItems activityItems: [Any]) {
for i in activityItems {
if i as? WOPFacility != nil {
facility = i as? WOPFacility
}
}
}
override func perform() {
let appToUse = WOPDatabaseController.getDefaults().value(forKey: "mapsApp") as? String
if appToUse == "Google Maps" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
if let url = URL(string: "comgooglemaps://?q=\((facility!.facilityLocation?.coordinates?.coords?.last)!)),\((facility!.facilityLocation?.coordinates?.coords?.first)!)") {
UIApplication.shared.open(url, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
}
}
else if appToUse == "Waze" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
if let url = URL(string: "https://waze.com/ul?ll=\((facility!.facilityLocation?.coordinates?.coords?.last)!)),\((facility!.facilityLocation?.coordinates?.coords?.first)!))") {
UIApplication.shared.open(url, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
}
}
else {
let regionDistance:CLLocationDistance = 100
let coordinates = CLLocationCoordinate2DMake((facility!.facilityLocation?.coordinates?.coords?.last)!, (facility!.facilityLocation?.coordinates?.coords?.first)!)
dump(coordinates)
let regionSpan = MKCoordinateRegion.init(center: coordinates, latitudinalMeters: regionDistance, longitudinalMeters: regionDistance)
let options = [
MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center),
MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span)
]
let placemark = MKPlacemark(coordinate: coordinates, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = facility!.facilityName
mapItem.openInMaps(launchOptions: options)
}
}
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}
......@@ -89,6 +89,7 @@ public class WOPFacilityDetailViewController: UIViewController, UITableViewDeleg
}
// Creating an NSUserActivity for this facility
func setActivityUp() {
activity.isEligibleForHandoff = true
activity.isEligibleForSearch = true
......
......@@ -15,8 +15,8 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>${SHARED_VERSION_NUMBER}</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<string>$(SHARED_BUILD_NUMBER)</string>
</dict>
</plist>
......@@ -7,6 +7,7 @@
//
import Foundation
import UserNotifications
public class WOPUtilities: NSObject {
......@@ -466,6 +467,101 @@ public class WOPUtilities: NSObject {
}
}
// MARK - Alert Notifications
/**
Sets alert notification settings in User Defaults
- returns:
true if the option was changed correctly.
*/
public static func setAlertNotificationDefaults(_ key: String, value: Bool) -> Bool {
if value == true {
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.getNotificationSettings { (settings) in
if settings.authorizationStatus == .notDetermined {
notificationCenter.requestAuthorization(options: [.alert, .sound, .badge], completionHandler: {state, error in
if state == true {
let defaults = WOPDatabaseController.getDefaults()
var alerts = defaults.dictionary(forKey: "notificationDefaults") as! [String: Bool]?
if alerts != nil {
alerts!.updateValue(value, forKey: key)
defaults.set(alerts, forKey: "alerts")
return true
}
else {
return false
}
} else {
return
}
})
} else {
// Do not schedule notifications if not authorized.
guard settings.authorizationStatus == .authorized else {return}
let defaults = WOPDatabaseController.getDefaults()
var alerts = defaults.dictionary(forKey: "notificationDefaults") as! [String: Bool]?
if alerts != nil {
alerts!.updateValue(value, forKey: key)
defaults.set(alerts, forKey: "alerts")
return true
}
else {
return false
}
}
}
}
}
/**
Sets all alert notification settings in User Defaults to true
- returns:
true if the alerts was changed correctly, false if nil was retrieved from User Defaults.
*/
public static func setAllAlertNotificationDefaults() -> Bool {
let defaults = WOPDatabaseController.getDefaults()
var alerts = defaults.dictionary(forKey: "notificationDefaults") as! [String: Bool]?
if alerts != nil {
var foundFalse = false
for a in alerts! {
if a.value == false {