Skip to content

Commit bfb7c12

Browse files
committed
Release Authenticator 2.0.2
2 parents 3627633 + d06df88 commit bfb7c12

29 files changed

+262
-207
lines changed

Authenticator.xcodeproj/project.pbxproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
C9CC09551BA91D1C008C54FE /* TableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CC09541BA91D1C008C54FE /* TableViewModel.swift */; };
5252
C9D6C83F1906BD68004F0E08 /* SegmentedControlRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D6C83E1906BD68004F0E08 /* SegmentedControlRow.swift */; };
5353
C9D6C8461906CD54004F0E08 /* TextFieldRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D6C8451906CD54004F0E08 /* TextFieldRow.swift */; };
54-
C9D6C84C19075044004F0E08 /* OTPProgressRing.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D6C84B19075044004F0E08 /* OTPProgressRing.swift */; };
54+
C9D6C84C19075044004F0E08 /* ProgressRingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D6C84B19075044004F0E08 /* ProgressRingView.swift */; };
5555
C9DE02E71ED2234D00D7E01C /* InfoList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DE02E61ED2234D00D7E01C /* InfoList.swift */; };
5656
C9DE02E91ED227D600D7E01C /* InfoListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DE02E81ED227D600D7E01C /* InfoListViewController.swift */; };
5757
C9E3FB9A1E281CBC00EFA8BB /* TokenScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9E3FB991E281CBC00EFA8BB /* TokenScanner.swift */; };
@@ -172,7 +172,7 @@
172172
C9CC09541BA91D1C008C54FE /* TableViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewModel.swift; sourceTree = "<group>"; };
173173
C9D6C83E1906BD68004F0E08 /* SegmentedControlRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegmentedControlRow.swift; sourceTree = "<group>"; };
174174
C9D6C8451906CD54004F0E08 /* TextFieldRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldRow.swift; sourceTree = "<group>"; };
175-
C9D6C84B19075044004F0E08 /* OTPProgressRing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTPProgressRing.swift; sourceTree = "<group>"; };
175+
C9D6C84B19075044004F0E08 /* ProgressRingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressRingView.swift; sourceTree = "<group>"; };
176176
C9D844341D4C576B00D5E343 /* CONTRIBUTING.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CONTRIBUTING.md; sourceTree = "<group>"; };
177177
C9D844361D4C59D600D5E343 /* CONDUCT.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CONDUCT.md; sourceTree = "<group>"; };
178178
C9DE02E61ED2234D00D7E01C /* InfoList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InfoList.swift; sourceTree = "<group>"; };
@@ -400,7 +400,7 @@
400400
C9B7328E1C0A8AE60076F77E /* TokenListViewModel.swift */,
401401
C92708AB19CFB0750033128B /* TokenListViewController.swift */,
402402
C98C1C4517D2EDF500A07D3F /* Cells */,
403-
C9D6C84B19075044004F0E08 /* OTPProgressRing.swift */,
403+
C9D6C84B19075044004F0E08 /* ProgressRingView.swift */,
404404
CC46C4701DB3007D00EB4605 /* SearchField.swift */,
405405
);
406406
name = "Token List";
@@ -669,7 +669,7 @@
669669
C93BD6231C167CD100FFFB8F /* Root.swift in Sources */,
670670
C97CDF2C1BEEC90100D64406 /* QRScanner.swift in Sources */,
671671
C9AAB07F1B917EC3000CE547 /* TokenEditForm.swift in Sources */,
672-
C9D6C84C19075044004F0E08 /* OTPProgressRing.swift in Sources */,
672+
C9D6C84C19075044004F0E08 /* ProgressRingView.swift in Sources */,
673673
C9A1C1A91E501D8B009E65D6 /* Info.swift in Sources */,
674674
C9CC09531BA9133B008C54FE /* FocusCell.swift in Sources */,
675675
C99069D1180CBAC900BAEF53 /* TokenScannerViewController.swift in Sources */,
@@ -745,6 +745,7 @@
745745
INFOPLIST_FILE = Authenticator/Resources/Info.plist;
746746
PRODUCT_BUNDLE_IDENTIFIER = me.mattrubin.authenticator.dev;
747747
PRODUCT_NAME = Authenticator;
748+
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
748749
TARGETED_DEVICE_FAMILY = 1;
749750
VERSIONING_SYSTEM = "apple-generic";
750751
};

Authenticator/Resources/Acknowledgements.html

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,10 @@ <h2><a href="https://github.com/mattrubin/OneTimePassword">
5353
<h2><a href="https://github.com/SVProgressHUD/SVProgressHUD">
5454
SVProgressHUD
5555
</a></h2>
56-
<p>Copyright (c) 2011-2016 Sam Vermette, Tobias Tiemerding and contributors.</p>
57-
<p>Permission is hereby granted, free of charge, to any person
58-
obtaining a copy of this software and associated documentation
59-
files (the "Software"), to deal in the Software without
60-
restriction, including without limitation the rights to use,
61-
copy, modify, merge, publish, distribute, sublicense, and/or sell
62-
copies of the Software, and to permit persons to whom the
63-
Software is furnished to do so, subject to the following
64-
conditions:</p>
65-
<p>The above copyright notice and this permission notice shall be
66-
included in all copies or substantial portions of the Software.</p>
67-
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
68-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
69-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
70-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
71-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
72-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
73-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
74-
OTHER DEALINGS IN THE SOFTWARE.</p>
56+
<p>Copyright (c) 2011-2017 Sam Vermette, Tobias Tiemerding and contributors.</p>
57+
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
58+
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
59+
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
7560

7661
<h2><a href="https://github.com/jspahrsummers/xcconfigs">
7762
xcconfigs
@@ -80,6 +65,6 @@ <h2><a href="https://github.com/jspahrsummers/xcconfigs">
8065
<p>Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.</p>
8166
<p>In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.</p>
8267
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
83-
<p>For more information, please refer to unlicense.org.</p>
68+
<p>For more information, please refer to <a href="https://unlicense.org">unlicense.org</a>.</p>
8469
</body>
8570
</html>

Authenticator/Resources/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>2.0.1</string>
20+
<string>2.0.2</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleURLTypes</key>

Authenticator/Source/AppController.swift

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,24 @@ class AppController {
3333
private let store: TokenStore
3434
private var component: Root {
3535
didSet {
36-
let viewModel = currentViewModel()
37-
// TODO: Fix the excessive updates of bar button items so that the tick can run while they are on screen.
38-
if case .none = viewModel.modal {
39-
if displayLink == nil {
40-
startTick()
41-
}
42-
} else {
43-
if displayLink != nil {
44-
stopTick()
45-
}
46-
}
47-
view.updateWithViewModel(viewModel)
36+
updateView()
4837
}
4938
}
5039
private lazy var view: RootViewController = {
40+
let (currentViewModel, nextRefreshTime) = self.component.viewModel(for: self.store.persistentTokens,
41+
at: .currentDisplayTime())
42+
self.setTimer(withNextRefreshTime: nextRefreshTime)
5143
return RootViewController(
52-
viewModel: self.currentViewModel(),
44+
viewModel: currentViewModel,
5345
dispatchAction: self.handleAction
5446
)
5547
}()
48+
private var refreshTimer: Timer? {
49+
willSet {
50+
// Invalidate the old timer
51+
refreshTimer?.invalidate()
52+
}
53+
}
5654

5755
init() {
5856
do {
@@ -73,33 +71,26 @@ class AppController {
7371
// If this is a demo, show the scanner even in the simulator.
7472
let deviceCanScan = QRScanner.deviceCanScan || CommandLine.isDemo
7573
component = Root(deviceCanScan: deviceCanScan)
76-
77-
startTick()
78-
}
79-
80-
private func currentViewModel() -> Root.ViewModel {
81-
return component.viewModel(for: store.persistentTokens, at: .currentDisplayTime())
8274
}
8375

84-
// MARK: - Tick
85-
86-
private var displayLink: CADisplayLink?
87-
88-
private func startTick() {
89-
let selector = #selector(tick)
90-
self.displayLink = CADisplayLink(target: self, selector: selector)
91-
self.displayLink?.add(to: RunLoop.main, forMode: .commonModes)
92-
}
93-
94-
private func stopTick() {
95-
self.displayLink?.invalidate()
96-
self.displayLink = nil
76+
@objc
77+
func updateView() {
78+
let (currentViewModel, nextRefreshTime) = component.viewModel(for: store.persistentTokens,
79+
at: .currentDisplayTime())
80+
setTimer(withNextRefreshTime: nextRefreshTime)
81+
view.updateWithViewModel(currentViewModel)
9782
}
9883

99-
@objc
100-
func tick() {
101-
// Update the view with a new view model for the current display time.
102-
view.updateWithViewModel(currentViewModel())
84+
private func setTimer(withNextRefreshTime nextRefreshTime: Date) {
85+
let timer = Timer(fireAt: nextRefreshTime,
86+
interval: 0,
87+
target: self,
88+
selector: #selector(updateView),
89+
userInfo: nil,
90+
repeats: false)
91+
// Add the new timer to the main run loop
92+
RunLoop.main.add(timer, forMode: .commonModes)
93+
refreshTimer = timer
10394
}
10495

10596
// MARK: - Update
@@ -143,23 +134,23 @@ class AppController {
143134
case let .updatePersistentToken(persistentToken, failure):
144135
do {
145136
try store.updatePersistentToken(persistentToken)
146-
view.updateWithViewModel(currentViewModel())
137+
updateView()
147138
} catch {
148139
handleEvent(failure(error))
149140
}
150141

151142
case let .moveToken(fromIndex, toIndex, failure):
152143
do {
153144
try store.moveTokenFromIndex(fromIndex, toIndex: toIndex)
154-
view.updateWithViewModel(currentViewModel())
145+
updateView()
155146
} catch {
156147
handleEvent(failure(error))
157148
}
158149

159150
case let .deletePersistentToken(persistentToken, failure):
160151
do {
161152
try store.deletePersistentToken(persistentToken)
162-
view.updateWithViewModel(currentViewModel())
153+
updateView()
163154
} catch {
164155
handleEvent(failure(error))
165156
}

Authenticator/Source/OTPAppDelegate.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class OTPAppDelegate: UIResponder, UIApplicationDelegate {
3838
let fontAttributes = [NSFontAttributeName: barButtonItemFont]
3939
UIBarButtonItem.appearance().setTitleTextAttributes(fontAttributes, for: .normal)
4040
UIBarButtonItem.appearance().setTitleTextAttributes(fontAttributes, for: .highlighted)
41-
UIBarButtonItem.appearance().setTitleTextAttributes(fontAttributes, for: .selected)
4241

4342
let disabledAttributes = [
4443
NSFontAttributeName: barButtonItemFont,
@@ -57,6 +56,11 @@ class OTPAppDelegate: UIResponder, UIApplicationDelegate {
5756
return true
5857
}
5958

59+
func applicationWillEnterForeground(_ application: UIApplication) {
60+
// Ensure the UI is updated with the latest view model whenever the app returns from the background.
61+
app.updateView()
62+
}
63+
6064
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
6165
if let token = Token(url: url) {
6266
let message = "Do you want to add a token for “\(token.name)”?"

Authenticator/Source/OTPProgressRing.swift

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)