diff --git a/Cartfile b/Cartfile index d1e89f97..18e65441 100644 --- a/Cartfile +++ b/Cartfile @@ -1,4 +1,4 @@ github "sparkle-project/Sparkle" ~> 1.22 github "mattt/TransformerKit" ~> 1.1.1 -github "MacPass/KeePassKit" "defc62b0cb01cf0aafdb7f50cac3cae15b09d289" +github "MacPass/KeePassKit" "5a57e2e90e8b96e7aa76f573ed8d48e8d584dc4a" github "mstarke/HNHUi" ~> 4.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index d33ac232..6d15564c 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "MacPass/KeePassKit" "defc62b0cb01cf0aafdb7f50cac3cae15b09d289" +github "MacPass/KeePassKit" "5a57e2e90e8b96e7aa76f573ed8d48e8d584dc4a" github "mattt/TransformerKit" "1.1.1" github "mstarke/HNHUi" "4.0.2" github "robbiehanson/KissXML" "5.3.2" diff --git a/MacPass/MPTOTPViewController.h b/MacPass/MPTOTPViewController.h index 021445f1..ca0e82e7 100644 --- a/MacPass/MPTOTPViewController.h +++ b/MacPass/MPTOTPViewController.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MPTOTPViewController : NSViewController @property (strong) IBOutlet HNHUITextField *toptValueTextField; -@property (strong) IBOutlet NSProgressIndicator *remainingTimeProgressIndicator; +@property (strong) IBOutlet NSButton *remainingTimeButton; @end diff --git a/MacPass/MPTOTPViewController.m b/MacPass/MPTOTPViewController.m index ae3807b9..4a764392 100644 --- a/MacPass/MPTOTPViewController.m +++ b/MacPass/MPTOTPViewController.m @@ -12,13 +12,14 @@ @interface MPTOTPViewController () +@property (strong) KPKTimeOTPGenerator *generator; + @end @implementation MPTOTPViewController - (void)viewDidLoad { - self.remainingTimeProgressIndicator.minValue = 0; - self.remainingTimeProgressIndicator.maxValue = 30; + self.remainingTimeButton.title = @""; } - (void)setRepresentedObject:(id)representedObject { @@ -46,13 +47,18 @@ BOOL showTOTP = entry.hasTimeOTP; self.view.hidden = !showTOTP; if(showTOTP) { - self.remainingTimeProgressIndicator.indeterminate = YES; - self.toptValueTextField.stringValue = entry.timeOTP; - self.remainingTimeProgressIndicator.doubleValue = 0; + self.generator = [[KPKTimeOTPGenerator alloc] initWithEntry:entry]; + self.generator.time = NSDate.date.timeIntervalSince1970; + self.toptValueTextField.stringValue = self.generator.string; + + NSString *template = NSLocalizedString(@"TOTP_REMAINING_TIME_%ld_SECONDS", @"Time in seconds remaining for a valid TOTP string, format should be %ld"); + template = @"%ld s"; + + self.remainingTimeButton.title = [NSString stringWithFormat:template, (NSUInteger)self.generator.remainingTime]; [self performSelector:@selector(_updateDisplay) withObject:nil afterDelay:0.5]; } else { - self.remainingTimeProgressIndicator.indeterminate = NO; + self.remainingTimeButton.title = @""; self.toptValueTextField.stringValue = @""; } } diff --git a/MacPass/MPTOTPViewController.xib b/MacPass/MPTOTPViewController.xib index d7fe1627..6f3a90a7 100644 --- a/MacPass/MPTOTPViewController.xib +++ b/MacPass/MPTOTPViewController.xib @@ -8,7 +8,7 @@ - + @@ -16,41 +16,56 @@ - + - + - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - -