From bb73628484a1f6de1ca49d3617de17fab6430d10 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 11 Dec 2020 17:51:09 +0100 Subject: [PATCH] Enabled Time OTP display. --- Cartfile | 2 +- Cartfile.resolved | 2 +- MacPass/MPTOTPViewController.m | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cartfile b/Cartfile index 044c163b..d1e89f97 100644 --- a/Cartfile +++ b/Cartfile @@ -1,4 +1,4 @@ github "sparkle-project/Sparkle" ~> 1.22 github "mattt/TransformerKit" ~> 1.1.1 -github "MacPass/KeePassKit" "b3e637a95ede748990fef84481ba108d49be7336" +github "MacPass/KeePassKit" "defc62b0cb01cf0aafdb7f50cac3cae15b09d289" github "mstarke/HNHUi" ~> 4.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 8ee93715..d33ac232 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "MacPass/KeePassKit" "b3e637a95ede748990fef84481ba108d49be7336" +github "MacPass/KeePassKit" "defc62b0cb01cf0aafdb7f50cac3cae15b09d289" github "mattt/TransformerKit" "1.1.1" github "mstarke/HNHUi" "4.0.2" github "robbiehanson/KissXML" "5.3.2" diff --git a/MacPass/MPTOTPViewController.m b/MacPass/MPTOTPViewController.m index 1619063a..e98b83e5 100644 --- a/MacPass/MPTOTPViewController.m +++ b/MacPass/MPTOTPViewController.m @@ -14,15 +14,13 @@ @interface MPTOTPViewController () -@property (strong) KPKOTPGenerator *otpGenerator; - @end @implementation MPTOTPViewController - (void)viewDidLoad { - self.otpGenerator = [[KPKOTPGenerator alloc] init]; - [super viewDidLoad]; + self.remainingTimeProgressIndicator.minValue = 0; + self.remainingTimeProgressIndicator.maxValue = 30; } - (void)setRepresentedObject:(id)representedObject { @@ -42,15 +40,22 @@ } - (void)_didChangeAttribute:(NSNotification *)notification { + [self _updateDisplay]; +} + +- (void)_updateDisplay { KPKEntry *entry = (KPKEntry *)self.representedObject; BOOL showTOTP = entry.hasTOTP; self.view.hidden = !showTOTP; if(showTOTP) { self.remainingTimeProgressIndicator.indeterminate = YES; + self.toptValueTextField.stringValue = entry.timeOTP; + self.remainingTimeProgressIndicator.doubleValue = 0; + [self performSelector:@selector(_updateDisplay) withObject:nil afterDelay:0.5]; } else { self.remainingTimeProgressIndicator.indeterminate = NO; + self.toptValueTextField.stringValue = @""; } } - @end