Skip to content

Commit

Permalink
Make CUU Start Screen Smarter
Browse files Browse the repository at this point in the history
- Add safety check and fix bug where notes and behavior were incorrectly displayed
- Refactor Enabling of EmotionKit
- Bump Version to 2.1.0
- Check for ARKit availability
  • Loading branch information
Lara Marie Reimer authored and jpbernius committed Nov 25, 2018
1 parent 39fc899 commit 88a4feb
Show file tree
Hide file tree
Showing 29 changed files with 1,549 additions and 1,596 deletions.
2 changes: 1 addition & 1 deletion CUU.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'CUU'
s.version = '2.0.4'
s.version = '2.1.0'
s.summary = 'CUU is a framework to help analyzing the usage of your applications.'

# This description is used to generate tags and improve search results.
Expand Down
8 changes: 0 additions & 8 deletions CUU/Classes/CUU.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,6 @@ public class CUU {
featureKit.handleAdditionalCrumbActionsForFeatures(with: actionCrumb)
}

static func isActivated(for kit: CUUStartOption) -> Bool {
if let options = UserDefaults.standard.array(forKey: CUUConstants.CUUUserDefaultsKeys.optionsKey) as? [Int] {
let values = options.map({ CUUStartOption(rawValue: $0) })
return values.contains(kit)
}
return false
}

static func isCUUAllowed() -> Bool {
if let branchName = CUUConstants.branchName {
if branchName != "master" && branchName != "develop" && branchName != "development" {
Expand Down
55 changes: 51 additions & 4 deletions CUU/Classes/CUUCore/CUUConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ struct CUUConstants {
}

static let projectId: String? = {
if let plist = CUUPlistDictionary {if let projectId = plist.object(forKey: "CUUProjectID") as? String {
return projectId
} else {
return nil
if let plist = CUUPlistDictionary {
if let projectId = plist.object(forKey: "CUUProjectID") as? String {
return projectId
} else {
return nil
}
} else {
return nil
Expand Down Expand Up @@ -89,6 +90,42 @@ struct CUUConstants {
}
}()

static let cameraDescription: String? = {
if let plist = InfoPlistDictionary {
if let value = plist.object(forKey: "NSCameraUsageDescription") as? String {
return value
} else {
return nil
}
} else {
return nil
}
}()

static let speechRecognitionDescription: String? = {
if let plist = InfoPlistDictionary {
if let value = plist.object(forKey: "NSSpeechRecognitionUsageDescription") as? String {
return value
} else {
return nil
}
} else {
return nil
}
}()

static let microphoneDescription: String? = {
if let plist = InfoPlistDictionary {
if let value = plist.object(forKey: "NSMicrophoneUsageDescription") as? String {
return value
} else {
return nil
}
} else {
return nil
}
}()

static var CUUPlistDictionary: NSDictionary? {
get {
if let path = Bundle.main.path(forResource: "CUU", ofType: "plist") {
Expand All @@ -98,4 +135,14 @@ struct CUUConstants {
}
}
}

static var InfoPlistDictionary: NSDictionary? {
get {
if let path = Bundle.main.path(forResource: "Info", ofType: "plist") {
return NSDictionary(contentsOfFile: path)
} else {
return nil
}
}
}
}
7 changes: 3 additions & 4 deletions CUU/Classes/CUUCore/CUUStartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import UIKit
import ARKit

protocol CUUStartViewDelegate : class {
func didPressContinueButton(with selection: [CUUStartOption]) -> Void
Expand Down Expand Up @@ -43,8 +44,6 @@ class CUUStartView: UIView, CUUStartViewOptionDelegate {

self.kitStackView.addArrangedSubview(self.featureKitView)
self.kitStackView.addArrangedSubview(self.interactionKitView)
self.kitStackView.addArrangedSubview(self.behaviorKitView)
self.kitStackView.addArrangedSubview(self.noteKitView)

self.featureKitView.delegate = self
self.interactionKitView.delegate = self
Expand All @@ -63,13 +62,13 @@ class CUUStartView: UIView, CUUStartViewOptionDelegate {
self.allowedOptions.append(.Behavior)
}

if options.contains(.ThinkingAloud) {
if options.contains(.ThinkingAloud) && ThinkingAloudKit.isSupported {
self.kitStackView.addArrangedSubview(self.thinkingAloudKitView)
self.thinkingAloudKitView.delegate = self
self.allowedOptions.append(.ThinkingAloud)
}

if options.contains(.Emotions) {
if options.contains(.Emotions) && EmotionKit.isSupported {
self.kitStackView.addArrangedSubview(self.emotionKitView)
self.emotionKitView.delegate = self
self.allowedOptions.append(.Emotions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUActivityViewController: UIActivityViewController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUActivityViewController: UIActivityViewController {
extension CUUActivityViewController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUCloudSharingController: UICloudSharingController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUCloudSharingController: UICloudSharingController {
extension CUUCloudSharingController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUCollectionViewController: UICollectionViewController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUCollectionViewController: UICollectionViewController {
extension CUUCollectionViewController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUDocumentBrowserViewController: UIDocumentBrowserViewController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUDocumentBrowserViewController: UIDocumentBrowserViewController {
extension CUUDocumentBrowserViewController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUDocumentPickerViewController: UIDocumentPickerViewController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUDocumentPickerViewController: UIDocumentPickerViewController {
extension CUUDocumentPickerViewController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUImagePickerController: UIImagePickerController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUImagePickerController: UIImagePickerController {
extension CUUImagePickerController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUNavigationController: UINavigationController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUNavigationController: UINavigationController {
extension CUUNavigationController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUPageViewController: UIPageViewController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUPageViewController: UIPageViewController {
extension CUUPageViewController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class CUUReferenceLibraryViewController: UIReferenceLibraryViewController {
override open func viewDidLoad() {
super.viewDidLoad()

if CUU.isActivated(for: .Emotions) {
emotionsKitSetupTracking()
}
emotionsKitSetupTracking()
}

override open func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -53,13 +51,15 @@ open class CUUReferenceLibraryViewController: UIReferenceLibraryViewController {
extension CUUReferenceLibraryViewController {

private func emotionsKitSetupTracking() {
guard EmotionKit.isActive else { return }

emotionsKitArSession.delegate = self
emotionsKitResetTracking()
emotionsKitFaceDetector = EKFaceDetectorFactory.instance
}

private func emotionsKitResetTracking() {
guard ARFaceTrackingConfiguration.isSupported else { return }
guard EmotionKit.isSupported else { return }
let configuration = ARFaceTrackingConfiguration()
emotionsKitArSession.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}
Expand Down
Loading

0 comments on commit 88a4feb

Please sign in to comment.