From b165fc4d589ae03b1d6c6b6c7ca17b3191f050ca Mon Sep 17 00:00:00 2001 From: "scotts@microsoft.com" Date: Mon, 12 Sep 2016 17:25:49 -0700 Subject: [PATCH] Pare down to simpler app - Remove Drives view - Remove Drives data model/downloader - Remove userid/deviceid --- LoopTrip.xcodeproj/project.pbxproj | 8 -- LoopTripIOS/Base.lproj/Main.storyboard | 172 +---------------------- LoopTripIOS/DriveRepository.swift | 84 ----------- LoopTripIOS/DriveViewController.swift | 144 ------------------- LoopTripIOS/Info.plist | 4 +- LoopTripIOS/RepositoryManager.swift | 6 - LoopTripIOS/SettingsViewController.swift | 24 ---- 7 files changed, 5 insertions(+), 437 deletions(-) delete mode 100644 LoopTripIOS/DriveRepository.swift delete mode 100644 LoopTripIOS/DriveViewController.swift diff --git a/LoopTrip.xcodeproj/project.pbxproj b/LoopTrip.xcodeproj/project.pbxproj index d8cde24..5b83a38 100644 --- a/LoopTrip.xcodeproj/project.pbxproj +++ b/LoopTrip.xcodeproj/project.pbxproj @@ -27,9 +27,7 @@ F654898E1D76AA760005BB9B /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65489891D76AA760005BB9B /* JSON.swift */; }; F657491A1D74257F00F3398B /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65749191D74257F00F3398B /* SettingsViewController.swift */; }; F657491E1D74D32700F3398B /* TripRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = F657491D1D74D32700F3398B /* TripRepository.swift */; }; - F65749221D75560200F3398B /* DriveRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65749211D75560200F3398B /* DriveRepository.swift */; }; F65749241D75599800F3398B /* KnownLocationRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65749231D75599800F3398B /* KnownLocationRepository.swift */; }; - F65749261D755D3E00F3398B /* DriveViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65749251D755D3E00F3398B /* DriveViewController.swift */; }; F65A89D71D79643C000D1E54 /* MapRouteLineCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65A89D61D79643C000D1E54 /* MapRouteLineCache.swift */; }; F65A89DB1D79E894000D1E54 /* RepositoryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65A89DA1D79E894000D1E54 /* RepositoryManager.swift */; }; F65A938A1D6CCD3C006F5358 /* TripCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F65A93891D6CCD3C006F5358 /* TripCell.xib */; }; @@ -74,9 +72,7 @@ F65489891D76AA760005BB9B /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = ""; }; F65749191D74257F00F3398B /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = ""; }; F657491D1D74D32700F3398B /* TripRepository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TripRepository.swift; sourceTree = ""; }; - F65749211D75560200F3398B /* DriveRepository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DriveRepository.swift; sourceTree = ""; }; F65749231D75599800F3398B /* KnownLocationRepository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KnownLocationRepository.swift; sourceTree = ""; }; - F65749251D755D3E00F3398B /* DriveViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DriveViewController.swift; sourceTree = ""; }; F65A89D61D79643C000D1E54 /* MapRouteLineCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapRouteLineCache.swift; sourceTree = ""; }; F65A89DA1D79E894000D1E54 /* RepositoryManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryManager.swift; sourceTree = ""; }; F65A93891D6CCD3C006F5358 /* TripCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TripCell.xib; sourceTree = ""; }; @@ -155,7 +151,6 @@ isa = PBXGroup; children = ( F65A89DA1D79E894000D1E54 /* RepositoryManager.swift */, - F65749211D75560200F3398B /* DriveRepository.swift */, F657491D1D74D32700F3398B /* TripRepository.swift */, F65749231D75599800F3398B /* KnownLocationRepository.swift */, ); @@ -165,7 +160,6 @@ F65A89D91D79E7ED000D1E54 /* Views */ = { isa = PBXGroup; children = ( - F65749251D755D3E00F3398B /* DriveViewController.swift */, F6825FF11D73DA7B00D6F926 /* TripViewController.swift */, F65A938D1D6CD4A0006F5358 /* TripCell */, F65749191D74257F00F3398B /* SettingsViewController.swift */, @@ -282,8 +276,6 @@ F654898A1D76AA760005BB9B /* Color.swift in Sources */, F60A2FAD1D80D19D00E297B0 /* Text.swift in Sources */, F60A2FAF1D81357500E297B0 /* Alert.swift in Sources */, - F65749261D755D3E00F3398B /* DriveViewController.swift in Sources */, - F65749221D75560200F3398B /* DriveRepository.swift in Sources */, B58887131CF3A6AD00B25BCD /* AppDelegate.swift in Sources */, F654898E1D76AA760005BB9B /* JSON.swift in Sources */, F6825FF21D73DA7B00D6F926 /* TripViewController.swift in Sources */, diff --git a/LoopTripIOS/Base.lproj/Main.storyboard b/LoopTripIOS/Base.lproj/Main.storyboard index 6f5740f..029d0e2 100644 --- a/LoopTripIOS/Base.lproj/Main.storyboard +++ b/LoopTripIOS/Base.lproj/Main.storyboard @@ -22,7 +22,6 @@ - @@ -79,38 +78,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -119,12 +86,6 @@ - @@ -133,7 +94,7 @@ - + @@ -163,83 +124,36 @@ - - - + - - - - - - - - - - - - - - - - - - - - @@ -258,12 +172,10 @@ - - @@ -292,56 +204,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -517,30 +379,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - + @@ -622,14 +461,9 @@ - - - - - diff --git a/LoopTripIOS/DriveRepository.swift b/LoopTripIOS/DriveRepository.swift deleted file mode 100644 index 65e9db9..0000000 --- a/LoopTripIOS/DriveRepository.swift +++ /dev/null @@ -1,84 +0,0 @@ -// -// DrivesModel.swift -// Loop Trips Sample -// -// Copyright (c) Microsoft Corporation -// -// All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the License); you may not -// use this file except in compliance with the License. You may obtain a copy -// of the License at http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS -// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY -// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -// MERCHANTABLITY OR NON-INFRINGEMENT. -// -// See the Apache Version 2.0 License for specific language governing permissions -// and limitations under the License. -// - -import Foundation -import CoreLocation -import LoopSDK - -typealias DriveDataModel = [(isSampleData: Bool, data:LoopTrip?)] -let DriveRepositoryAddedContentNotification = "ms.loop.trip.DriveRepositoryAddedContentNotification" - -public class DriveRepository { - static let sharedInstance = DriveRepository() - private init() {} - private let concurrentDriveQueue = dispatch_queue_create("ms.loop.trip.DriveRepositoryQueue", DISPATCH_QUEUE_CONCURRENT) - private let driveRepositoryDispatchGroup = dispatch_group_create() - private var _tableData: DriveDataModel = [] - var tableData: DriveDataModel { - var tableDataCopy: DriveDataModel! - dispatch_sync(concurrentDriveQueue) { - tableDataCopy = self._tableData - } - return tableDataCopy - } - - func loadData(loadDataCompletion: () -> Void) { - if let dispatchGroupDrive = dispatch_group_create() { - dispatch_group_enter(dispatchGroupDrive) - - LoopSDK.syncManager.getDrives(20, callback: { - (loopDrives:[LoopTrip]) in - - dispatch_barrier_sync(self.concurrentDriveQueue) { - self._tableData.removeAll() - } - - if loopDrives.isEmpty { - let sampleDrives = JSONUtils.loadSampleTripData("SampleDrives") - for drive in sampleDrives { - dispatch_barrier_sync(self.concurrentDriveQueue) { - self._tableData.append((isSampleData: true, data: drive)) - } - } - } else { - NSLog("Loop SDK returned \(loopDrives.count) drives") - for drive in loopDrives { - dispatch_barrier_sync(self.concurrentDriveQueue) { - self._tableData.append((isSampleData: false, data:drive)) - } - } - } - - dispatch_group_leave(dispatchGroupDrive) - }) - - dispatch_group_notify(dispatchGroupDrive, GlobalMainQueue) { - loadDataCompletion() - } - } - } - - func removeData(index: Int) { - dispatch_barrier_sync(self.concurrentDriveQueue) { - self._tableData.removeAtIndex(index) - } - } -} diff --git a/LoopTripIOS/DriveViewController.swift b/LoopTripIOS/DriveViewController.swift deleted file mode 100644 index 0370aca..0000000 --- a/LoopTripIOS/DriveViewController.swift +++ /dev/null @@ -1,144 +0,0 @@ -// -// DriveViewController.swift -// Loop Trips Sample -// -// Copyright (c) Microsoft Corporation -// -// All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the License); you may not -// use this file except in compliance with the License. You may obtain a copy -// of the License at http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS -// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY -// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -// MERCHANTABLITY OR NON-INFRINGEMENT. -// -// See the Apache Version 2.0 License for specific language governing permissions -// and limitations under the License. -// - -import Foundation -import UIKit - -class DriveViewController: UIViewController { - - @IBOutlet weak var driveTableView: UITableView! - - private var repositoryManagerUpdateObserver: NSObjectProtocol! - - let cellViewHeight: CGFloat = 94.0 - let repositoryManager = RepositoryManager.sharedInstance - - lazy var refreshControl: UIRefreshControl = { - let refreshControl = UIRefreshControl() - refreshControl.addTarget(self, action: #selector(DriveViewController.onPullToRefresh(_:)), forControlEvents: UIControlEvents.ValueChanged) - - return refreshControl - }() - - override func viewWillDisappear(animated: Bool) { - if let repositoryManagerUpdateObserver = repositoryManagerUpdateObserver { - NSNotificationCenter.defaultCenter().removeObserver(repositoryManagerUpdateObserver) - } - } - - override func viewDidLoad() { - super.viewDidLoad() - - repositoryManagerUpdateObserver = NSNotificationCenter.defaultCenter() - .addObserverForName(RepositoryManagerAddedContentNotification, - object: nil, - queue: NSOperationQueue.mainQueue()) { - notification in - self.contentChangedNotification(notification) - } - - self.driveTableView.registerNib(UINib(nibName: "TripCell", bundle: nil), forCellReuseIdentifier: "TripCell") - - self.repositoryManager.loadRepositoryDataAsync(true) - - self.driveTableView.addSubview(self.refreshControl) - } - - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { - if segue.identifier == "showMapViewForDrives", let mapView = segue.destinationViewController as? MapViewController { - if let indexPath = sender as? NSIndexPath { - mapView.setData((self.repositoryManager.driveRepository.tableData[indexPath.row].data)!, showTrips: false) - } - } - } -} - - -// MARK - Privates - -extension DriveViewController { - func onPullToRefresh(refreshControl: UIRefreshControl) { - self.repositoryManager.loadRepositoryDataAsync(false) - self.driveTableView.reloadData() - refreshControl.endRefreshing() - } - - private func contentChangedNotification(notification: NSNotification!) { - switch notification.name { - case RepositoryManagerAddedContentNotification: - NSLog("Received update notification in DriveView") - self.driveTableView.reloadData() - default: - NSLog("Unknown notification") - } - } -} - - -// MARK - UITableView Delegate - -extension DriveViewController { - func numberOfSectionsInTableView(tableView: UITableView) -> Int { - return 1 - } - - func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return self.repositoryManager.driveRepository.tableData.count - } - - func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { - if self.repositoryManager.driveRepository.tableData.count > indexPath.row && self.repositoryManager.driveRepository.tableData[indexPath.row].isSampleData { - return cellViewHeight - } - else { - return cellViewHeight - 24.0 - } - } - - func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("TripCell", forIndexPath: indexPath) as! TripCell - let row = self.repositoryManager.driveRepository.tableData[indexPath.row] - cell.setData(row.data!, sampleTrip: row.isSampleData) - - return cell - } - - func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - self.performSegueWithIdentifier("showMapViewForDrives", sender: indexPath) - } - - func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { - let deleteAction = UITableViewRowAction(style: .Default, title: "Delete", handler: { - (action, indexPath) in - - self.repositoryManager.driveRepository.removeData(indexPath.row) - tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) - }) - - deleteAction.backgroundColor = UIColor.tableCellDeleteActionColor - - return [deleteAction] - } - - func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { - return true - } -} diff --git a/LoopTripIOS/Info.plist b/LoopTripIOS/Info.plist index 4876fb0..568ce4f 100644 --- a/LoopTripIOS/Info.plist +++ b/LoopTripIOS/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.8 + 1.0.9 CFBundleSignature ???? CFBundleVersion - 108 + 109 LOOP_APP_ID_PROP $(LOOP_APP_ID_PROP) LOOP_APP_TOKEN_PROP diff --git a/LoopTripIOS/RepositoryManager.swift b/LoopTripIOS/RepositoryManager.swift index b75cd4c..1fb16d6 100644 --- a/LoopTripIOS/RepositoryManager.swift +++ b/LoopTripIOS/RepositoryManager.swift @@ -32,17 +32,11 @@ public class RepositoryManager { static let sharedInstance = RepositoryManager() private init() {} - let driveRepository = DriveRepository.sharedInstance let tripRepository = TripRepository.sharedInstance let knownLocationRepository = KnownLocationRepository.sharedInstance func loadRepositoryDataAsync(sendUpdateNotification: Bool) { if let dispatchGroupRepositoryManager = dispatch_group_create() { - dispatch_group_enter(dispatchGroupRepositoryManager) - self.driveRepository.loadData({ - dispatch_group_leave(dispatchGroupRepositoryManager) - }) - dispatch_group_enter(dispatchGroupRepositoryManager) self.tripRepository.loadData({ dispatch_group_leave(dispatchGroupRepositoryManager) diff --git a/LoopTripIOS/SettingsViewController.swift b/LoopTripIOS/SettingsViewController.swift index 46ab9ad..caa86cb 100644 --- a/LoopTripIOS/SettingsViewController.swift +++ b/LoopTripIOS/SettingsViewController.swift @@ -29,8 +29,6 @@ import LoopSDK class SettingsViewController: UIViewController { @IBOutlet weak var recordingSwitch: UISwitch! - @IBOutlet weak var userIdTextButton: UIButton! - @IBOutlet weak var deviceIdTextButton: UIButton! @IBOutlet weak var learnLoopLink: UITextView! @IBOutlet weak var touLink: UITextView! @IBOutlet weak var privacyLink: UITextView! @@ -43,16 +41,10 @@ class SettingsViewController: UIViewController { versionString.text = "v" + buildVersion! if (LoopSDK.isInitialized()) { - userIdTextButton.setTitle(LoopSDK.getUserID(), forState: .Normal) - deviceIdTextButton.setTitle(LoopSDK.getDeviceID(), forState: .Normal) - recordingSwitch.enabled = true recordingSwitch.setOn(LoopSDK.loopLocationProvider.active, animated: false) } else { - userIdTextButton.setTitle("UNINITIALIZED", forState: .Normal) - deviceIdTextButton.setTitle("UNINITIALIZED", forState: .Normal) - recordingSwitch.enabled = false } @@ -107,19 +99,3 @@ extension SettingsViewController { return NSAttributedString.init(string: linkText, attributes: linkAttributes) } } - - -// MARK - UIButton -extension SettingsViewController { - @IBAction func userIdButton(sender: AnyObject) { - UIPasteboard.generalPasteboard().string = userIdTextButton.titleLabel!.text - - AlertUtils.Alert(self, title: "Copied to Clipboard", message: userIdTextButton.titleLabel!.text!) - } - - @IBAction func deviceIdButton(sender: AnyObject) { - UIPasteboard.generalPasteboard().string = deviceIdTextButton.titleLabel!.text - - AlertUtils.Alert(self, title: "Copied to Clipboard", message: deviceIdTextButton.titleLabel!.text!) - } -}