Enabled Time OTP display.

This commit is contained in:
Michael Starke
2020-12-11 17:51:09 +01:00
parent baaf10d6f3
commit bb73628484
3 changed files with 12 additions and 7 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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