Add log display functionality

This commit is contained in:
Christoph Hagen 2019-04-12 13:45:31 +02:00
parent 2806733b71
commit c13dd8b080
15 changed files with 130 additions and 45 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/build/*
/Pods/*
Podfile.lock
build/

View File

@ -15,6 +15,7 @@
59158B1621E37B0200D90CB0 /* GridViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59158B1521E37B0200D90CB0 /* GridViewController.swift */; };
59158B1821E4C9AC00D90CB0 /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59158B1721E4C9AC00D90CB0 /* NavigationController.swift */; };
591832CE21A2A97E00E5987D /* Cap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 591832CD21A2A97E00E5987D /* Cap.swift */; };
5970380D225737F800D21B55 /* LogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5970380C225737F800D21B55 /* LogViewController.swift */; };
598D60E221B6B4D200C7473E /* ImageClassifier.mlmodel in Sources */ = {isa = PBXBuildFile; fileRef = 598D60E121B6B4D200C7473E /* ImageClassifier.mlmodel */; };
59C1BBA92174CBB800EC84BB /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59C1BBA82174CBB800EC84BB /* SettingsController.swift */; };
59C1BBAB21762D9600EC84BB /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59C1BBAA21762D9600EC84BB /* UserDefaults.swift */; };
@ -52,6 +53,7 @@
59158B1521E37B0200D90CB0 /* GridViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridViewController.swift; sourceTree = "<group>"; };
59158B1721E4C9AC00D90CB0 /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = "<group>"; };
591832CD21A2A97E00E5987D /* Cap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cap.swift; sourceTree = "<group>"; };
5970380C225737F800D21B55 /* LogViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogViewController.swift; sourceTree = "<group>"; };
598D60E121B6B4D200C7473E /* ImageClassifier.mlmodel */ = {isa = PBXFileReference; lastKnownFileType = file.mlmodel; name = ImageClassifier.mlmodel; path = ../../../../Dropbox/Models/ImageClassifier.mlmodel; sourceTree = "<group>"; };
59C1BBA82174CBB800EC84BB /* SettingsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; };
59C1BBAA21762D9600EC84BB /* UserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaults.swift; sourceTree = "<group>"; };
@ -221,6 +223,7 @@
59C1BBA82174CBB800EC84BB /* SettingsController.swift */,
5904C3392199C9FA0046A573 /* SortController.swift */,
59158B1521E37B0200D90CB0 /* GridViewController.swift */,
5970380C225737F800D21B55 /* LogViewController.swift */,
);
path = Presentation;
sourceTree = "<group>";
@ -376,6 +379,7 @@
598D60E221B6B4D200C7473E /* ImageClassifier.mlmodel in Sources */,
CE56CEFF209D83B800932C01 /* CameraController.swift in Sources */,
CE56CF05209D83B800932C01 /* ViewControllerExtensions.swift in Sources */,
5970380D225737F800D21B55 /* LogViewController.swift in Sources */,
CE56CF0E209D83B800932C01 /* PhotoCaptureHandler.swift in Sources */,
CE56CEFE209D83B800932C01 /* RoundedButton.swift in Sources */,
CE56CF07209D83B800932C01 /* ImageCell.swift in Sources */,

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<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="qlf-I7-aOI">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="qlf-I7-aOI">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -244,6 +244,31 @@
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="LOG" footerTitle="Show the log entries since the last launch." id="nBk-Vh-WxW">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="ce2-NF-FOB" style="IBUITableViewCellStyleDefault" id="O29-Jn-jJm">
<rect key="frame" x="0.0" y="921" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="O29-Jn-jJm" id="hWH-cq-syr">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="View log file" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ce2-NF-FOB">
<rect key="frame" x="16" y="0.0" width="343" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<color key="backgroundColor" red="0.20027729420000001" green="0.19907802899999999" blue="0.2014765594" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<connections>
<segue destination="1hl-Dr-E8b" kind="show" identifier="showLog" id="LUg-kg-Bez"/>
</connections>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="x62-XO-Rsu" id="vJB-Oo-TFT"/>
@ -506,6 +531,39 @@
</objects>
<point key="canvasLocation" x="4096.8000000000002" y="2261.9190404797605"/>
</scene>
<!--Log View Controller-->
<scene sceneID="wvg-8y-a1q">
<objects>
<viewController id="1hl-Dr-E8b" customClass="LogViewController" customModule="CapCollector" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="LYF-QL-9Gq">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dpl-aG-l9N">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<color key="backgroundColor" red="0.14168914909999999" green="0.14168914909999999" blue="0.14168914909999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="jsL-5U-q61" firstAttribute="bottom" secondItem="Dpl-aG-l9N" secondAttribute="bottom" id="8xr-nv-MgU"/>
<constraint firstItem="jsL-5U-q61" firstAttribute="trailing" secondItem="Dpl-aG-l9N" secondAttribute="trailing" id="JBt-iM-nbl"/>
<constraint firstItem="Dpl-aG-l9N" firstAttribute="top" secondItem="jsL-5U-q61" secondAttribute="top" id="gAq-pR-Nbf"/>
<constraint firstItem="Dpl-aG-l9N" firstAttribute="leading" secondItem="jsL-5U-q61" secondAttribute="leading" id="ikf-xt-kAB"/>
</constraints>
<viewLayoutGuide key="safeArea" id="jsL-5U-q61"/>
</view>
<connections>
<outlet property="textView" destination="Dpl-aG-l9N" id="Jqz-1c-rCN"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="tDo-LK-Wgk" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3409" y="2961"/>
</scene>
<!--Sort Controller-->
<scene sceneID="fFw-OX-Mag">
<objects>

View File

@ -17,19 +17,26 @@ protocol Logger {
extension Logger {
func error(_ message: String) {
print(Self.logToken + " ERROR: " + message)
Self.addToFile(Self.logToken + " ERROR: " + message)
}
func event(_ message: String) {
print(Self.logToken + " " + message)
Self.addToFile(Self.logToken + " " + message)
}
static func error(_ message: String) {
print(logToken + " ERROR: " + message)
addToFile(logToken + " ERROR: " + message)
}
static func event(_ message: String) {
print(logToken + " " + message)
addToFile(logToken + " " + message)
}
private static func addToFile(_ message: String) {
logFile += "\n" + message
print(message)
}
}
private(set) var logFile: String = ""

View File

@ -0,0 +1,32 @@
//
// LogViewController.swift
// CapCollector
//
// Created by Christoph on 05.04.19.
// Copyright © 2019 CH. All rights reserved.
//
import UIKit
class LogViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
textView.text = logFile
}
@IBOutlet weak var textView: UITextView!
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}

View File

@ -116,6 +116,8 @@ class SettingsController: UITableViewController {
}
case 4: // Dropbox account
return true
case 5: // Log file
return true
default: return false
}
}
@ -136,6 +138,8 @@ class SettingsController: UITableViewController {
}
case 4: // Dropbox account
return indexPath
case 5: // Log file
return indexPath
default: return nil
}
}
@ -218,10 +222,18 @@ class SettingsController: UITableViewController {
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let id = segue.identifier, id == "showMosaic" else {
guard let id = segue.identifier else {
return
}
switch id {
case "showMosaic":
(navigationController as! NavigationController).allowLandscape = true
case "showLog":
return
default:
return
}
}
}

View File

@ -514,11 +514,13 @@ extension TableView: Logger {
extension TableView: CapsDelegate {
func capHasUpdates(_ cap: Cap) {
if let cell = table.visibleCells.first(where: { ($0 as! CapCell).cap == cap }) {
DispatchQueue.main.async {
if let cell = self.table.visibleCells.first(where: { ($0 as! CapCell).cap == cap }) {
(cell as! CapCell).updateCell()
} else if !caps.contains(cap) {
} else if !self.caps.contains(cap) {
// Reload the table when new cap is added
showAllCapsAndScrollToTop()
self.showAllCapsAndScrollToTop()
}
}
}

View File

@ -1,30 +0,0 @@
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/SettingsController.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/Classifier.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/SortController.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/Logger.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/DropBoxController.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/UIViewExtensions.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/NavigationController.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/Cap.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/DiskManager.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/UIImageExtensions.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/TableView.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/GridViewController.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/NameFile.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/UserDefaults.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/AppDelegate.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/ImageSelector.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/CameraController.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/ViewControllerExtensions.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/PhotoCaptureHandler.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/RoundedButton.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/ImageCell.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/UIAlertControllerExtensions.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/CameraView.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/CropView.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/AlwaysShowPopup.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/RoundedImageView.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/CapCell.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/Squeezenet.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/ImageClassifier.o
/Users/christoph/Documents/GitHub/CapCollector/build/CapCollector/Build/Intermediates.noindex/CapCollector.build/Debug-iphoneos/CapCollector.build/Objects-normal/arm64/Resnet.o