Skip to content

Commit

Permalink
Added a disclaimer popup that has to be accepted for every new versio…
Browse files Browse the repository at this point in the history
…n of nightguad.
  • Loading branch information
dhermanns committed Apr 29, 2019
1 parent cba19db commit 0cd404b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion nightguard WatchKit App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>482</string>
<string>486</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
2 changes: 1 addition & 1 deletion nightguard WatchKit Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>482</string>
<string>486</string>
<key>CLKComplicationPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ComplicationController</string>
<key>CLKComplicationSupportedFamilies</key>
Expand Down
2 changes: 1 addition & 1 deletion nightguard/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>482</string>
<string>486</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
Expand Down
19 changes: 11 additions & 8 deletions nightguard/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,7 @@ class MainViewController: UIViewController, SlideToSnoozeDelegate {

override func viewDidLoad() {
super.viewDidLoad()

//TODO update to slide-to-snooze
//snoozeButton.titleLabel?.numberOfLines = 0
//snoozeButton.titleLabel?.lineBreakMode = .byWordWrapping
//snoozeButton.backgroundColor = UIColor.darkGray.withAlphaComponent(0.3)
//snoozeButton.titleLabel?.font = UIFont.systemFont(ofSize: DeviceSize().isSmall ? 24 : 27)
//snoozeButton.titleLabel?.textAlignment = .center


// Initialize the ChartScene
chartScene = ChartScene(size: CGSize(width: spriteKitView.bounds.width, height: spriteKitView.bounds.height),
newCanvasWidth: self.maximumDeviceTextureWidth())
Expand Down Expand Up @@ -146,6 +139,16 @@ class MainViewController: UIViewController, SlideToSnoozeDelegate {

override func viewDidAppear(_ animated: Bool) {

// Remind the user with every new version, that this is a
// volunteers project without any warranty!
let versionNumber: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
showAcceptDeclineAlert(title: "Disclaimer!", message:
"Don't use this App for medical decisions! " +
"It comes with absolutely NO WARRANTY. " +
"It is maintained by volunteers only. " +
"Use it at your own risk!",
showOnceKey: "showedWarningIn\(versionNumber)")

// Start immediately so that the current time gets displayed at once
// And the alarm can play if needed
doPeriodicUpdate(forceRepaint: true)
Expand Down
17 changes: 17 additions & 0 deletions nightguard/UIViewController+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ extension UIViewController {
}
}

func showAcceptDeclineAlert(title: String, message: String, showOnceKey: String? = nil) {

if let showOnceKey = showOnceKey {
guard !UserDefaults.standard.bool(forKey: showOnceKey) else {
return
}
}

let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
let actionAccept = UIAlertAction(title: "Accept", style: .default, handler: { (alert: UIAlertAction!) in
if let showOnceKey = showOnceKey {
UserDefaults.standard.set(true, forKey: showOnceKey)
}
})
alertController.addAction(actionAccept)
present(alertController, animated: true, completion: nil)
}
}

// snoozing capability from any controller
Expand Down
2 changes: 1 addition & 1 deletion nightguardTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>482</string>
<string>486</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion nightguardUITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>482</string>
<string>486</string>
</dict>
</plist>

0 comments on commit 0cd404b

Please sign in to comment.