mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-17 12:29:35 +00:00
Enabled display of prettified passwords ind password generator and entry inspector
This commit is contained in:
@@ -469,6 +469,8 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
|||||||
|
|
||||||
/* general */
|
/* general */
|
||||||
NSDictionary *nullPlaceholderBindingOptionsDict = @{ NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "Placeholder text for input fields if no entry or group is selected")};
|
NSDictionary *nullPlaceholderBindingOptionsDict = @{ NSNullPlaceholderBindingOption: NSLocalizedString(@"NONE", "Placeholder text for input fields if no entry or group is selected")};
|
||||||
|
NSDictionary *prettyPasswordBindingOptionsDict = @{ NSNullPlaceholderBindingOption: nullPlaceholderBindingOptionsDict[NSNullPlaceholderBindingOption], NSValueTransformerNameBindingOption : MPPrettyPasswordTransformerName };
|
||||||
|
|
||||||
[self.titleTextField bind:NSValueBinding
|
[self.titleTextField bind:NSValueBinding
|
||||||
toObject:self
|
toObject:self
|
||||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(title))]
|
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(title))]
|
||||||
@@ -476,7 +478,8 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
|||||||
[self.passwordTextField bind:NSValueBinding
|
[self.passwordTextField bind:NSValueBinding
|
||||||
toObject:self
|
toObject:self
|
||||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(password))]
|
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(password))]
|
||||||
options:nullPlaceholderBindingOptionsDict];
|
options:prettyPasswordBindingOptionsDict];
|
||||||
|
|
||||||
[self.usernameTextField bind:NSValueBinding
|
[self.usernameTextField bind:NSValueBinding
|
||||||
toObject:self
|
toObject:self
|
||||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(username))]
|
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(username))]
|
||||||
@@ -636,7 +639,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)toggleExpire:(NSButton*)sender {
|
- (IBAction)toggleExpire:(NSButton*)sender {
|
||||||
if([sender state] == NSOnState && [self.representedEntry.timeInfo.expirationDate isEqualToDate:[NSDate distantFuture]]) {
|
if([sender state] == NSOnState && [self.representedEntry.timeInfo.expirationDate isEqualToDate:NSDate.distantFuture]) {
|
||||||
[NSApp sendAction:self.pickExpireDateButton.action to:nil from:self.pickExpireDateButton];
|
[NSApp sendAction:self.pickExpireDateButton.action to:nil from:self.pickExpireDateButton];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -651,7 +654,6 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
|||||||
|
|
||||||
- (void)_didChangeCurrentItem:(NSNotification *)notificiation {
|
- (void)_didChangeCurrentItem:(NSNotification *)notificiation {
|
||||||
self.showPassword = NO;
|
self.showPassword = NO;
|
||||||
//self.customFieldsTableView.needsDisplay = YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#import "MPSettingsHelper.h"
|
#import "MPSettingsHelper.h"
|
||||||
#import "MPDocument.h"
|
#import "MPDocument.h"
|
||||||
#import "MPModelChangeObserving.h"
|
#import "MPModelChangeObserving.h"
|
||||||
|
#import "MPPrettyPasswordTransformer.h"
|
||||||
|
|
||||||
|
|
||||||
#import "MPFlagsHelper.h"
|
#import "MPFlagsHelper.h"
|
||||||
|
|
||||||
@@ -56,7 +58,6 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
@interface MPPasswordCreatorViewController ()
|
@interface MPPasswordCreatorViewController ()
|
||||||
|
|
||||||
@property (nonatomic, copy) NSString *password;
|
@property (nonatomic, copy) NSString *password;
|
||||||
@property (copy) NSString *generatedPassword;
|
|
||||||
|
|
||||||
@property (strong) IBOutlet NSTextField *passwordTextField;
|
@property (strong) IBOutlet NSTextField *passwordTextField;
|
||||||
@property (strong) IBOutlet NSTextField *passwordLengthTextField;
|
@property (strong) IBOutlet NSTextField *passwordLengthTextField;
|
||||||
@@ -120,7 +121,7 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
|
|
||||||
[self.passwordLengthSlider bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(passwordLength)) options:nil];
|
[self.passwordLengthSlider bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(passwordLength)) options:nil];
|
||||||
[self.passwordLengthTextField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(passwordLength)) options:nil];
|
[self.passwordLengthTextField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(passwordLength)) options:nil];
|
||||||
[self.passwordTextField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(password)) options:nil];
|
[self.passwordTextField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(password)) options:@{ NSValueTransformerNameBindingOption: MPPrettyPasswordTransformerName }];
|
||||||
|
|
||||||
[self.entropyIndicator bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(entropy)) options:nil];
|
[self.entropyIndicator bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(entropy)) options:nil];
|
||||||
[self.entropyTextField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(entropy)) options:nil];
|
[self.entropyTextField bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(entropy)) options:nil];
|
||||||
|
|||||||
@@ -41,6 +41,16 @@ NSString *const MPPrettyPasswordTransformerName = @"com.hicknhack.macpass.MPPret
|
|||||||
forName:MPPrettyPasswordTransformerName];
|
forName:MPPrettyPasswordTransformerName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id)reverseTransformedValue:(id)value {
|
||||||
|
if([value isKindOfClass:NSString.class]) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
if([value isKindOfClass:NSAttributedString.class]) {
|
||||||
|
return ((NSAttributedString *)value).string;
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (id)transformedValue:(id)value {
|
- (id)transformedValue:(id)value {
|
||||||
if([value isKindOfClass:NSString.class]) {
|
if([value isKindOfClass:NSString.class]) {
|
||||||
return ((NSString *)value).passwordPrettified;
|
return ((NSString *)value).passwordPrettified;
|
||||||
|
|||||||
@@ -42,9 +42,9 @@
|
|||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
blueColor = [NSColor colorWithRed:0.3 green:0.7 blue:1 alpha:1];
|
blueColor = [NSColor colorWithRed:0.3 green:0.7 blue:1 alpha:1];
|
||||||
orangeColor = [NSColor colorWithRed:0.3 green:0.7 blue:1 alpha:1];
|
orangeColor = [NSColor colorWithRed:1 green:0.7 blue:0.3 alpha:1];
|
||||||
greenColor = [NSColor colorWithRed:0.3 green:0.7 blue:1 alpha:1];
|
greenColor = [NSColor colorWithRed:0.7 green:1 blue:0.3 alpha:1];
|
||||||
yellowColor = [NSColor colorWithRed:0.3 green:0.7 blue:1 alpha:1];
|
yellowColor = [NSColor colorWithRed:1 green:0.7 blue:0.3 alpha:1];
|
||||||
});
|
});
|
||||||
|
|
||||||
/* digits */
|
/* digits */
|
||||||
@@ -52,14 +52,11 @@
|
|||||||
for(NSValue *rangeValue in digitRanges) {
|
for(NSValue *rangeValue in digitRanges) {
|
||||||
[string addAttribute:NSForegroundColorAttributeName value:blueColor range:rangeValue.rangeValue];
|
[string addAttribute:NSForegroundColorAttributeName value:blueColor range:rangeValue.rangeValue];
|
||||||
}
|
}
|
||||||
/* symbols */
|
/* symbols and punctuation */
|
||||||
NSArray <NSValue *> *symbolRanges = [self rangesOfCharactersInSet:NSCharacterSet.symbolCharacterSet];
|
NSMutableCharacterSet *symbolAndPunctuationSet = [NSCharacterSet.symbolCharacterSet mutableCopy];
|
||||||
|
[symbolAndPunctuationSet formUnionWithCharacterSet:NSCharacterSet.punctuationCharacterSet];
|
||||||
|
NSArray <NSValue *> *symbolRanges = [self rangesOfCharactersInSet:symbolAndPunctuationSet];
|
||||||
for(NSValue *rangeValue in symbolRanges) {
|
for(NSValue *rangeValue in symbolRanges) {
|
||||||
[string addAttribute:NSForegroundColorAttributeName value:greenColor range:rangeValue.rangeValue];
|
|
||||||
}
|
|
||||||
/* punctuation */
|
|
||||||
NSArray <NSValue *> *punctiationRanges = [self rangesOfCharactersInSet:NSCharacterSet.punctuationCharacterSet];
|
|
||||||
for(NSValue *rangeValue in punctiationRanges) {
|
|
||||||
[string addAttribute:NSForegroundColorAttributeName value:orangeColor range:rangeValue.rangeValue];
|
[string addAttribute:NSForegroundColorAttributeName value:orangeColor range:rangeValue.rangeValue];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user