AppCode code formatting.
This commit is contained in:
parent
d59f77720c
commit
a8bf74a925
2
External/Pearl
vendored
2
External/Pearl
vendored
@ -1 +1 @@
|
|||||||
Subproject commit e55ef6876ee26f61a7cd2c075fc1e7a942016de0
|
Subproject commit 009482a08a2a05e9856c2158c1040d01aeedb5ff
|
@ -15,17 +15,17 @@ static NSDictionary *keyQuery(MPUserEntity *user) {
|
|||||||
|
|
||||||
return [PearlKeyChain createQueryForClass:kSecClassGenericPassword
|
return [PearlKeyChain createQueryForClass:kSecClassGenericPassword
|
||||||
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
|
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
@"Saved Master Password", (__bridge id)kSecAttrService,
|
@"Saved Master Password", (__bridge id)kSecAttrService,
|
||||||
user.name, (__bridge id)kSecAttrAccount,
|
user.name, (__bridge id)kSecAttrAccount,
|
||||||
nil]
|
nil]
|
||||||
matches:nil];
|
matches:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSData *)loadSavedKeyFor:(MPUserEntity *)user {
|
- (NSData *)loadSavedKeyFor:(MPUserEntity *)user {
|
||||||
|
|
||||||
NSData *key = [PearlKeyChain dataOfItemForQuery:keyQuery(user)];
|
NSData *key = [PearlKeyChain dataOfItemForQuery:keyQuery(user)];
|
||||||
if (key)
|
if (key)
|
||||||
inf(@"Found key (for: %@) in keychain.", user.name);
|
inf(@"Found key (for: %@) in keychain.", user.name);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
user.saveKey = NO;
|
user.saveKey = NO;
|
||||||
@ -44,11 +44,11 @@ static NSDictionary *keyQuery(MPUserEntity *user) {
|
|||||||
inf(@"Updating key in keychain.");
|
inf(@"Updating key in keychain.");
|
||||||
[PearlKeyChain addOrUpdateItemForQuery:keyQuery(user)
|
[PearlKeyChain addOrUpdateItemForQuery:keyQuery(user)
|
||||||
withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
|
withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
self.key, (__bridge id) kSecValueData,
|
self.key, (__bridge id)kSecValueData,
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
kSecAttrAccessibleWhenUnlockedThisDeviceOnly, (__bridge id) kSecAttrAccessible,
|
kSecAttrAccessibleWhenUnlockedThisDeviceOnly, (__bridge id)kSecAttrAccessible,
|
||||||
#endif
|
#endif
|
||||||
nil]];
|
nil]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ static NSDictionary *keyQuery(MPUserEntity *user) {
|
|||||||
|
|
||||||
- (void)signOut {
|
- (void)signOut {
|
||||||
|
|
||||||
self.key = nil;
|
self.key = nil;
|
||||||
self.activeUser = nil;
|
self.activeUser = nil;
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationSignedOut object:self];
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationSignedOut object:self];
|
||||||
@ -93,22 +93,23 @@ static NSDictionary *keyQuery(MPUserEntity *user) {
|
|||||||
|
|
||||||
// Method 2: Depending on the user's saveKey, load or remove the key from the keychain.
|
// Method 2: Depending on the user's saveKey, load or remove the key from the keychain.
|
||||||
if (!user.saveKey)
|
if (!user.saveKey)
|
||||||
// Key should not be stored in keychain. Delete it.
|
// Key should not be stored in keychain. Delete it.
|
||||||
[self forgetSavedKeyFor:user];
|
[self forgetSavedKeyFor:user];
|
||||||
|
|
||||||
else if (!tryKey) {
|
else
|
||||||
// Key should be saved in keychain. Load it.
|
if (!tryKey) {
|
||||||
if ((tryKey = [self loadSavedKeyFor:user]))
|
// Key should be saved in keychain. Load it.
|
||||||
if (![user.keyID isEqual:keyIDForKey(tryKey)]) {
|
if ((tryKey = [self loadSavedKeyFor:user]))
|
||||||
// Loaded password doesn't match user's keyID. Forget saved password: it is incorrect.
|
if (![user.keyID isEqual:keyIDForKey(tryKey)]) {
|
||||||
tryKey = nil;
|
// Loaded password doesn't match user's keyID. Forget saved password: it is incorrect.
|
||||||
[self forgetSavedKeyFor:user];
|
tryKey = nil;
|
||||||
|
[self forgetSavedKeyFor:user];
|
||||||
|
|
||||||
#ifdef TESTFLIGHT_SDK_VERSION
|
#ifdef TESTFLIGHT_SDK_VERSION
|
||||||
[TestFlight passCheckpoint:MPTestFlightCheckpointMPMismatch];
|
[TestFlight passCheckpoint:MPTestFlightCheckpointMPMismatch];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method 3: Check the given master password string.
|
// Method 3: Check the given master password string.
|
||||||
if (!tryKey) {
|
if (!tryKey) {
|
||||||
@ -117,9 +118,9 @@ static NSDictionary *keyQuery(MPUserEntity *user) {
|
|||||||
if (![user.keyID isEqual:keyIDForKey(tryKey)]) {
|
if (![user.keyID isEqual:keyIDForKey(tryKey)]) {
|
||||||
tryKey = nil;
|
tryKey = nil;
|
||||||
|
|
||||||
#ifdef TESTFLIGHT_SDK_VERSION
|
#ifdef TESTFLIGHT_SDK_VERSION
|
||||||
[TestFlight passCheckpoint:MPTestFlightCheckpointMPMismatch];
|
[TestFlight passCheckpoint:MPTestFlightCheckpointMPMismatch];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ static NSDictionary *keyQuery(MPUserEntity *user) {
|
|||||||
[self storeSavedKeyFor:user];
|
[self storeSavedKeyFor:user];
|
||||||
}
|
}
|
||||||
|
|
||||||
user.lastUsed = [NSDate date];
|
user.lastUsed = [NSDate date];
|
||||||
self.activeUser = user;
|
self.activeUser = user;
|
||||||
[[MPAppDelegate_Shared get] saveContext];
|
[[MPAppDelegate_Shared get] saveContext];
|
||||||
|
|
||||||
|
@ -9,13 +9,14 @@
|
|||||||
#import "MPEntities.h"
|
#import "MPEntities.h"
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
@interface MPAppDelegate_Shared : PearlAppDelegate
|
@interface MPAppDelegate_Shared : PearlAppDelegate
|
||||||
#else
|
#else
|
||||||
@interface MPAppDelegate_Shared : NSObject <PearlConfigDelegate>
|
@interface MPAppDelegate_Shared : NSObject <PearlConfigDelegate>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@property (strong, nonatomic) MPUserEntity *activeUser;
|
@property (strong, nonatomic) MPUserEntity *activeUser;
|
||||||
@property (strong, nonatomic) NSData *key;
|
@property (strong, nonatomic) NSData *key;
|
||||||
|
|
||||||
+ (MPAppDelegate_Shared *)get;
|
+ (MPAppDelegate_Shared *)get;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ typedef enum {
|
|||||||
MPImportResultInternalError,
|
MPImportResultInternalError,
|
||||||
} MPImportResult;
|
} MPImportResult;
|
||||||
|
|
||||||
@interface MPAppDelegate_Shared (Store) <UbiquityStoreManagerDelegate>
|
@interface MPAppDelegate_Shared (Store)<UbiquityStoreManagerDelegate>
|
||||||
|
|
||||||
+ (NSManagedObjectContext *)managedObjectContext;
|
+ (NSManagedObjectContext *)managedObjectContext;
|
||||||
+ (NSManagedObjectModel *)managedObjectModel;
|
+ (NSManagedObjectModel *)managedObjectModel;
|
||||||
|
@ -40,14 +40,14 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
if (managedObjectContext)
|
if (managedObjectContext)
|
||||||
return managedObjectContext;
|
return managedObjectContext;
|
||||||
|
|
||||||
return [PearlLazy lazyObjectLoadedFrom:^id{
|
return [PearlLazy lazyObjectLoadedFrom:^id {
|
||||||
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
|
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
|
||||||
assert(coordinator);
|
assert(coordinator);
|
||||||
|
|
||||||
managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
|
managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
|
||||||
[managedObjectContext performBlockAndWait:^{
|
[managedObjectContext performBlockAndWait:^{
|
||||||
managedObjectContext.persistentStoreCoordinator = coordinator;
|
managedObjectContext.persistentStoreCoordinator = coordinator;
|
||||||
managedObjectContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy;
|
managedObjectContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy;
|
||||||
}];
|
}];
|
||||||
|
|
||||||
return managedObjectContext;
|
return managedObjectContext;
|
||||||
@ -59,9 +59,9 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
// Start loading the store.
|
// Start loading the store.
|
||||||
[self storeManager];
|
[self storeManager];
|
||||||
|
|
||||||
return [PearlLazy lazyObjectLoadedFrom:^id{
|
return [PearlLazy lazyObjectLoadedFrom:^id {
|
||||||
// Wait until the storeManager is ready.
|
// Wait until the storeManager is ready.
|
||||||
for(__block BOOL isReady = [self storeManager].isReady; !isReady;) {
|
for (__block BOOL isReady = [self storeManager].isReady; !isReady;) {
|
||||||
[NSThread sleepForTimeInterval:0.1];
|
[NSThread sleepForTimeInterval:0.1];
|
||||||
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
isReady = [self storeManager].isReady;
|
isReady = [self storeManager].isReady;
|
||||||
@ -80,14 +80,15 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
return storeManager;
|
return storeManager;
|
||||||
|
|
||||||
storeManager = [[UbiquityStoreManager alloc] initWithManagedObjectModel:[self managedObjectModel]
|
storeManager = [[UbiquityStoreManager alloc] initWithManagedObjectModel:[self managedObjectModel]
|
||||||
localStoreURL:[[self applicationFilesDirectory] URLByAppendingPathComponent:@"MasterPassword.sqlite"]
|
localStoreURL:[[self applicationFilesDirectory] URLByAppendingPathComponent:@"MasterPassword.sqlite"]
|
||||||
containerIdentifier:@"HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.shared"
|
containerIdentifier:@"HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.shared"
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
additionalStoreOptions:[NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSPersistentStoreFileProtectionKey]
|
additionalStoreOptions:[NSDictionary dictionaryWithObject:NSFileProtectionComplete
|
||||||
|
forKey:NSPersistentStoreFileProtectionKey]
|
||||||
#else
|
#else
|
||||||
additionalStoreOptions:nil
|
additionalStoreOptions:nil
|
||||||
#endif
|
#endif
|
||||||
];
|
];
|
||||||
storeManager.delegate = self;
|
storeManager.delegate = self;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
storeManager.hardResetEnabled = YES;
|
storeManager.hardResetEnabled = YES;
|
||||||
@ -95,9 +96,9 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification
|
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification
|
||||||
object:[UIApplication sharedApplication] queue:nil
|
object:[UIApplication sharedApplication] queue:nil
|
||||||
usingBlock:^(NSNotification *note) {
|
usingBlock:^(NSNotification *note) {
|
||||||
[storeManager checkiCloudStatus];
|
[storeManager checkiCloudStatus];
|
||||||
}];
|
}];
|
||||||
#else
|
#else
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillBecomeActiveNotification
|
[[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillBecomeActiveNotification
|
||||||
object:[NSApplication sharedApplication] queue:nil
|
object:[NSApplication sharedApplication] queue:nil
|
||||||
@ -108,9 +109,9 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillTerminateNotification
|
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillTerminateNotification
|
||||||
object:[UIApplication sharedApplication] queue:nil
|
object:[UIApplication sharedApplication] queue:nil
|
||||||
usingBlock:^(NSNotification *note) {
|
usingBlock:^(NSNotification *note) {
|
||||||
[self saveContext];
|
[self saveContext];
|
||||||
}];
|
}];
|
||||||
#else
|
#else
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillTerminateNotification
|
[[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillTerminateNotification
|
||||||
object:[NSApplication sharedApplication] queue:nil
|
object:[NSApplication sharedApplication] queue:nil
|
||||||
@ -128,7 +129,7 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
if ([self.managedObjectContext hasChanges])
|
if ([self.managedObjectContext hasChanges])
|
||||||
if (![self.managedObjectContext save:&error])
|
if (![self.managedObjectContext save:&error])
|
||||||
err(@"While saving context: %@", error);
|
err(@"While saving context: %@", error);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +158,8 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
[MPConfig get].iCloud = [NSNumber numberWithBool:iCloudEnabled];
|
[MPConfig get].iCloud = [NSNumber numberWithBool:iCloudEnabled];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause context:(id)context {
|
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause
|
||||||
|
context:(id)context {
|
||||||
|
|
||||||
#ifdef TESTFLIGHT_SDK_VERSION
|
#ifdef TESTFLIGHT_SDK_VERSION
|
||||||
[TestFlight passCheckpoint:PearlString(@"MPTestFlightCheckpointMPErrorUbiquity_%d", cause)];
|
[TestFlight passCheckpoint:PearlString(@"MPTestFlightCheckpointMPErrorUbiquity_%d", cause)];
|
||||||
@ -216,17 +218,17 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
__autoreleasing NSError *error;
|
__autoreleasing NSError *error;
|
||||||
if (!headerPattern) {
|
if (!headerPattern) {
|
||||||
headerPattern = [[NSRegularExpression alloc]
|
headerPattern = [[NSRegularExpression alloc]
|
||||||
initWithPattern:@"^#[[:space:]]*([^:]+): (.*)"
|
initWithPattern:@"^#[[:space:]]*([^:]+): (.*)"
|
||||||
options:0 error:&error];
|
options:0 error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
err(@"Error loading the header pattern: %@", error);
|
err(@"Error loading the header pattern: %@", error);
|
||||||
}
|
}
|
||||||
if (!sitePattern) {
|
if (!sitePattern) {
|
||||||
sitePattern = [[NSRegularExpression alloc]
|
sitePattern = [[NSRegularExpression alloc]
|
||||||
initWithPattern:@"^([^[:space:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([^\t]+)\t(.*)"
|
initWithPattern:@"^([^[:space:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([^\t]+)\t(.*)"
|
||||||
options:0 error:&error];
|
options:0 error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
err(@"Error loading the site pattern: %@", error);
|
err(@"Error loading the site pattern: %@", error);
|
||||||
}
|
}
|
||||||
if (!headerPattern || !sitePattern)
|
if (!headerPattern || !sitePattern)
|
||||||
return MPImportResultInternalError;
|
return MPImportResultInternalError;
|
||||||
@ -234,11 +236,11 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
NSString *keyIDHex = nil, *userName = nil;
|
NSString *keyIDHex = nil, *userName = nil;
|
||||||
MPUserEntity *user = nil;
|
MPUserEntity *user = nil;
|
||||||
BOOL headerStarted = NO, headerEnded = NO;
|
BOOL headerStarted = NO, headerEnded = NO;
|
||||||
NSArray *importedSiteLines = [importedSitesString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
|
NSArray *importedSiteLines = [importedSitesString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
|
||||||
NSMutableSet *elementsToDelete = [NSMutableSet set];
|
NSMutableSet *elementsToDelete = [NSMutableSet set];
|
||||||
NSMutableArray *importedSiteElements = [NSMutableArray arrayWithCapacity:[importedSiteLines count]];
|
NSMutableArray *importedSiteElements = [NSMutableArray arrayWithCapacity:[importedSiteLines count]];
|
||||||
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPElementEntity class])];
|
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPElementEntity class])];
|
||||||
for(NSString *importedSiteLine in importedSiteLines) {
|
for (NSString *importedSiteLine in importedSiteLines) {
|
||||||
if ([importedSiteLine hasPrefix:@"#"]) {
|
if ([importedSiteLine hasPrefix:@"#"]) {
|
||||||
// Comment or header
|
// Comment or header
|
||||||
if (!headerStarted) {
|
if (!headerStarted) {
|
||||||
@ -258,9 +260,10 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
err(@"Invalid header format in line: %@", importedSiteLine);
|
err(@"Invalid header format in line: %@", importedSiteLine);
|
||||||
return MPImportResultMalformedInput;
|
return MPImportResultMalformedInput;
|
||||||
}
|
}
|
||||||
NSTextCheckingResult *headerElements = [[headerPattern matchesInString:importedSiteLine options:0 range:NSMakeRange(0, [importedSiteLine length])] lastObject];
|
NSTextCheckingResult *headerElements = [[headerPattern matchesInString:importedSiteLine options:0
|
||||||
NSString *key = [importedSiteLine substringWithRange:[headerElements rangeAtIndex:1]];
|
range:NSMakeRange(0, [importedSiteLine length])] lastObject];
|
||||||
NSString *value = [importedSiteLine substringWithRange:[headerElements rangeAtIndex:2]];
|
NSString *key = [importedSiteLine substringWithRange:[headerElements rangeAtIndex:1]];
|
||||||
|
NSString *value = [importedSiteLine substringWithRange:[headerElements rangeAtIndex:2]];
|
||||||
if ([key isEqualToString:@"User Name"]) {
|
if ([key isEqualToString:@"User Name"]) {
|
||||||
userName = value;
|
userName = value;
|
||||||
|
|
||||||
@ -287,19 +290,20 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
err(@"Invalid site format in line: %@", importedSiteLine);
|
err(@"Invalid site format in line: %@", importedSiteLine);
|
||||||
return MPImportResultMalformedInput;
|
return MPImportResultMalformedInput;
|
||||||
}
|
}
|
||||||
NSTextCheckingResult *siteElements = [[sitePattern matchesInString:importedSiteLine options:0 range:NSMakeRange(0, [importedSiteLine length])] lastObject];
|
NSTextCheckingResult *siteElements = [[sitePattern matchesInString:importedSiteLine options:0
|
||||||
NSString *lastUsed = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:1]];
|
range:NSMakeRange(0, [importedSiteLine length])] lastObject];
|
||||||
NSString *uses = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:2]];
|
NSString *lastUsed = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:1]];
|
||||||
NSString *type = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:3]];
|
NSString *uses = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:2]];
|
||||||
NSString *name = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:4]];
|
NSString *type = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:3]];
|
||||||
NSString *exportContent = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:5]];
|
NSString *name = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:4]];
|
||||||
|
NSString *exportContent = [importedSiteLine substringWithRange:[siteElements rangeAtIndex:5]];
|
||||||
|
|
||||||
// Find existing site.
|
// Find existing site.
|
||||||
if (user) {
|
if (user) {
|
||||||
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"name == %@ AND user == %@", name, user];
|
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"name == %@ AND user == %@", name, user];
|
||||||
NSArray *existingSites = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
|
NSArray *existingSites = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
err(@"Couldn't search existing sites: %@", error);
|
err(@"Couldn't search existing sites: %@", error);
|
||||||
if (!existingSites)
|
if (!existingSites)
|
||||||
return MPImportResultInternalError;
|
return MPImportResultInternalError;
|
||||||
|
|
||||||
@ -321,24 +325,25 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
|
|
||||||
// Import new sites.
|
// Import new sites.
|
||||||
if (!user) {
|
if (!user) {
|
||||||
user = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([MPUserEntity class]) inManagedObjectContext:self.managedObjectContext];
|
user = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([MPUserEntity class])
|
||||||
user.name = userName;
|
inManagedObjectContext:self.managedObjectContext];
|
||||||
|
user.name = userName;
|
||||||
user.keyID = [keyIDHex decodeHex];
|
user.keyID = [keyIDHex decodeHex];
|
||||||
}
|
}
|
||||||
for (NSArray *siteElements in importedSiteElements) {
|
for (NSArray *siteElements in importedSiteElements) {
|
||||||
NSDate *lastUsed = [rfc3339DateFormatter dateFromString:[siteElements objectAtIndex:0]];
|
NSDate *lastUsed = [rfc3339DateFormatter dateFromString:[siteElements objectAtIndex:0]];
|
||||||
NSUInteger uses = (unsigned)[[siteElements objectAtIndex:1] integerValue];
|
NSUInteger uses = (unsigned)[[siteElements objectAtIndex:1] integerValue];
|
||||||
MPElementType type = (MPElementType)[[siteElements objectAtIndex:2] integerValue];
|
MPElementType type = (MPElementType)[[siteElements objectAtIndex:2] integerValue];
|
||||||
NSString *name = [siteElements objectAtIndex:3];
|
NSString *name = [siteElements objectAtIndex:3];
|
||||||
NSString *exportContent = [siteElements objectAtIndex:4];
|
NSString *exportContent = [siteElements objectAtIndex:4];
|
||||||
|
|
||||||
// Create new site.
|
// Create new site.
|
||||||
MPElementEntity *element = [NSEntityDescription insertNewObjectForEntityForName:ClassNameFromMPElementType(type)
|
MPElementEntity *element = [NSEntityDescription insertNewObjectForEntityForName:ClassNameFromMPElementType(type)
|
||||||
inManagedObjectContext:self.managedObjectContext];
|
inManagedObjectContext:self.managedObjectContext];
|
||||||
element.name = name;
|
element.name = name;
|
||||||
element.user = user;
|
element.user = user;
|
||||||
element.type = type;
|
element.type = type;
|
||||||
element.uses = uses;
|
element.uses = uses;
|
||||||
element.lastUsed = lastUsed;
|
element.lastUsed = lastUsed;
|
||||||
if ([exportContent length])
|
if ([exportContent length])
|
||||||
[element importContent:exportContent];
|
[element importContent:exportContent];
|
||||||
@ -380,22 +385,24 @@ static NSDateFormatter *rfc3339DateFormatter = nil;
|
|||||||
|
|
||||||
// Sites.
|
// Sites.
|
||||||
for (MPElementEntity *element in self.activeUser.elements) {
|
for (MPElementEntity *element in self.activeUser.elements) {
|
||||||
NSDate *lastUsed = element.lastUsed;
|
NSDate *lastUsed = element.lastUsed;
|
||||||
NSUInteger uses = element.uses;
|
NSUInteger uses = element.uses;
|
||||||
MPElementType type = element.type;
|
MPElementType type = element.type;
|
||||||
NSString *name = element.name;
|
NSString *name = element.name;
|
||||||
NSString *content = nil;
|
NSString *content = nil;
|
||||||
|
|
||||||
// Determine the content to export.
|
// Determine the content to export.
|
||||||
if (!(type & MPElementFeatureDevicePrivate)) {
|
if (!(type & MPElementFeatureDevicePrivate)) {
|
||||||
if (showPasswords)
|
if (showPasswords)
|
||||||
content = element.content;
|
content = element.content;
|
||||||
else if (type & MPElementFeatureExportContent)
|
else
|
||||||
content = element.exportContent;
|
if (type & MPElementFeatureExportContent)
|
||||||
|
content = element.exportContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
[export appendFormat:@"%@ %8d %8d %20s\t%@\n",
|
[export appendFormat:@"%@ %8d %8d %20s\t%@\n",
|
||||||
[rfc3339DateFormatter stringFromDate:lastUsed], uses, type, [name cStringUsingEncoding:NSUTF8StringEncoding], content? content: @""];
|
[rfc3339DateFormatter stringFromDate:lastUsed], uses, type, [name cStringUsingEncoding:NSUTF8StringEncoding], content
|
||||||
|
? content: @""];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TESTFLIGHT_SDK_VERSION
|
#ifdef TESTFLIGHT_SDK_VERSION
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
// Copyright (c) 2012 Lyndir. All rights reserved.
|
// Copyright (c) 2012 Lyndir. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "MPConfig.h"
|
|
||||||
#import "MPAppDelegate.h"
|
#import "MPAppDelegate.h"
|
||||||
|
|
||||||
@implementation MPConfig
|
@implementation MPConfig
|
||||||
@ -14,16 +13,16 @@
|
|||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
|
|
||||||
if(!(self = [super init]))
|
if (!(self = [super init]))
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
[self.defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
|
[self.defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithBool:YES], NSStringFromSelector(@selector(askForReviews)),
|
[NSNumber numberWithBool:YES], NSStringFromSelector(@selector(askForReviews)),
|
||||||
|
|
||||||
[NSNumber numberWithBool:NO], NSStringFromSelector(@selector(rememberLogin)),
|
[NSNumber numberWithBool:NO], NSStringFromSelector(@selector(rememberLogin)),
|
||||||
[NSNumber numberWithBool:NO], NSStringFromSelector(@selector(iCloud)),
|
[NSNumber numberWithBool:NO], NSStringFromSelector(@selector(iCloud)),
|
||||||
[NSNumber numberWithBool:NO], NSStringFromSelector(@selector(iCloudDecided)),
|
[NSNumber numberWithBool:NO], NSStringFromSelector(@selector(iCloudDecided)),
|
||||||
nil]];
|
nil]];
|
||||||
|
|
||||||
self.delegate = [MPAppDelegate get];
|
self.delegate = [MPAppDelegate get];
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
@interface MPElementEntity : NSManagedObject
|
@interface MPElementEntity : NSManagedObject
|
||||||
|
|
||||||
@property (nonatomic, retain) id content;
|
@property (nonatomic, retain) id content;
|
||||||
@property (nonatomic, retain) NSDate * lastUsed;
|
@property (nonatomic, retain) NSDate *lastUsed;
|
||||||
@property (nonatomic, retain) NSString * name;
|
@property (nonatomic, retain) NSString *name;
|
||||||
@property (nonatomic, retain) NSNumber * type_;
|
@property (nonatomic, retain) NSNumber *type_;
|
||||||
@property (nonatomic, retain) NSNumber * uses_;
|
@property (nonatomic, retain) NSNumber *uses_;
|
||||||
@property (nonatomic, retain) MPUserEntity *user;
|
@property (nonatomic, retain) MPUserEntity *user;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MPElementEntity.h"
|
#import "MPElementEntity.h"
|
||||||
#import "MPUserEntity.h"
|
|
||||||
|
|
||||||
|
|
||||||
@implementation MPElementEntity
|
@implementation MPElementEntity
|
||||||
|
@ -13,6 +13,6 @@
|
|||||||
|
|
||||||
@interface MPElementGeneratedEntity : MPElementEntity
|
@interface MPElementGeneratedEntity : MPElementEntity
|
||||||
|
|
||||||
@property (nonatomic, retain) NSNumber * counter_;
|
@property (nonatomic, retain) NSNumber *counter_;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
@interface MPElementEntity (MP)
|
@interface MPElementEntity (MP)
|
||||||
|
|
||||||
@property (assign) MPElementType type;
|
@property (assign) MPElementType type;
|
||||||
@property (assign) NSUInteger uses;
|
@property (assign) NSUInteger uses;
|
||||||
|
|
||||||
- (NSUInteger)use;
|
- (NSUInteger)use;
|
||||||
- (NSString *)exportContent;
|
- (NSString *)exportContent;
|
||||||
@ -34,6 +34,6 @@
|
|||||||
@interface MPUserEntity (MP)
|
@interface MPUserEntity (MP)
|
||||||
|
|
||||||
@property (assign) NSUInteger avatar;
|
@property (assign) NSUInteger avatar;
|
||||||
@property (assign) BOOL saveKey;
|
@property (assign) BOOL saveKey;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -98,11 +98,11 @@
|
|||||||
+ (NSDictionary *)queryForDevicePrivateElementNamed:(NSString *)name {
|
+ (NSDictionary *)queryForDevicePrivateElementNamed:(NSString *)name {
|
||||||
|
|
||||||
return [PearlKeyChain createQueryForClass:kSecClassGenericPassword
|
return [PearlKeyChain createQueryForClass:kSecClassGenericPassword
|
||||||
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
|
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
@"DevicePrivate", (__bridge id)kSecAttrService,
|
@"DevicePrivate", (__bridge id)kSecAttrService,
|
||||||
name, (__bridge id)kSecAttrAccount,
|
name, (__bridge id)kSecAttrAccount,
|
||||||
nil]
|
nil]
|
||||||
matches:nil];
|
matches:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)content {
|
- (id)content {
|
||||||
@ -116,23 +116,23 @@
|
|||||||
encryptedContent = self.contentObject;
|
encryptedContent = self.contentObject;
|
||||||
|
|
||||||
NSData *decryptedContent = [encryptedContent decryptWithSymmetricKey:[[MPAppDelegate get] keyWithLength:PearlCryptKeySize]
|
NSData *decryptedContent = [encryptedContent decryptWithSymmetricKey:[[MPAppDelegate get] keyWithLength:PearlCryptKeySize]
|
||||||
padding:YES];
|
padding:YES];
|
||||||
return [[NSString alloc] initWithBytes:decryptedContent.bytes length:decryptedContent.length encoding:NSUTF8StringEncoding];
|
return [[NSString alloc] initWithBytes:decryptedContent.bytes length:decryptedContent.length encoding:NSUTF8StringEncoding];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setContent:(id)content {
|
- (void)setContent:(id)content {
|
||||||
|
|
||||||
NSData *encryptedContent = [[content description] encryptWithSymmetricKey:[[MPAppDelegate get] keyWithLength:PearlCryptKeySize]
|
NSData *encryptedContent = [[content description] encryptWithSymmetricKey:[[MPAppDelegate get] keyWithLength:PearlCryptKeySize]
|
||||||
padding:YES];
|
padding:YES];
|
||||||
|
|
||||||
if (self.type & MPElementFeatureDevicePrivate) {
|
if (self.type & MPElementFeatureDevicePrivate) {
|
||||||
[PearlKeyChain addOrUpdateItemForQuery:[MPElementStoredEntity queryForDevicePrivateElementNamed:self.name]
|
[PearlKeyChain addOrUpdateItemForQuery:[MPElementStoredEntity queryForDevicePrivateElementNamed:self.name]
|
||||||
withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
|
withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
encryptedContent, (__bridge id)kSecValueData,
|
encryptedContent, (__bridge id)kSecValueData,
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
kSecAttrAccessibleWhenUnlockedThisDeviceOnly, (__bridge id)kSecAttrAccessible,
|
kSecAttrAccessibleWhenUnlockedThisDeviceOnly, (__bridge id)kSecAttrAccessible,
|
||||||
#endif
|
#endif
|
||||||
nil]];
|
nil]];
|
||||||
self.contentObject = nil;
|
self.contentObject = nil;
|
||||||
} else
|
} else
|
||||||
self.contentObject = encryptedContent;
|
self.contentObject = encryptedContent;
|
||||||
|
@ -18,28 +18,28 @@ typedef enum {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/** Generate the password. */
|
/** Generate the password. */
|
||||||
MPElementTypeClassGenerated = 1 << 4,
|
MPElementTypeClassGenerated = 1 << 4,
|
||||||
/** Store the password. */
|
/** Store the password. */
|
||||||
MPElementTypeClassStored = 1 << 5,
|
MPElementTypeClassStored = 1 << 5,
|
||||||
} MPElementTypeClass;
|
} MPElementTypeClass;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/** Export the key-protected content data. */
|
/** Export the key-protected content data. */
|
||||||
MPElementFeatureExportContent = 1 << 10,
|
MPElementFeatureExportContent = 1 << 10,
|
||||||
/** Never export content. */
|
/** Never export content. */
|
||||||
MPElementFeatureDevicePrivate = 1 << 11,
|
MPElementFeatureDevicePrivate = 1 << 11,
|
||||||
} MPElementFeature;
|
} MPElementFeature;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MPElementTypeGeneratedSecure = 0x0 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedSecure = 0x0 | MPElementTypeClassGenerated | 0x0,
|
||||||
MPElementTypeGeneratedLong = 0x1 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedLong = 0x1 | MPElementTypeClassGenerated | 0x0,
|
||||||
MPElementTypeGeneratedMedium = 0x2 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedMedium = 0x2 | MPElementTypeClassGenerated | 0x0,
|
||||||
MPElementTypeGeneratedShort = 0x3 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedShort = 0x3 | MPElementTypeClassGenerated | 0x0,
|
||||||
MPElementTypeGeneratedBasic = 0x4 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedBasic = 0x4 | MPElementTypeClassGenerated | 0x0,
|
||||||
MPElementTypeGeneratedPIN = 0x5 | MPElementTypeClassGenerated | 0x0,
|
MPElementTypeGeneratedPIN = 0x5 | MPElementTypeClassGenerated | 0x0,
|
||||||
|
|
||||||
MPElementTypeStoredPersonal = 0x0 | MPElementTypeClassStored | MPElementFeatureExportContent,
|
MPElementTypeStoredPersonal = 0x0 | MPElementTypeClassStored | MPElementFeatureExportContent,
|
||||||
MPElementTypeStoredDevicePrivate = 0x1 | MPElementTypeClassStored | MPElementFeatureDevicePrivate,
|
MPElementTypeStoredDevicePrivate = 0x1 | MPElementTypeClassStored | MPElementFeatureDevicePrivate,
|
||||||
} MPElementType;
|
} MPElementType;
|
||||||
|
|
||||||
#define MPTestFlightCheckpointAction @"MPTestFlightCheckpointAction"
|
#define MPTestFlightCheckpointAction @"MPTestFlightCheckpointAction"
|
||||||
@ -77,9 +77,9 @@ typedef enum {
|
|||||||
#define MPNotificationKeyForgotten @"MPNotificationKeyForgotten"
|
#define MPNotificationKeyForgotten @"MPNotificationKeyForgotten"
|
||||||
#define MPNotificationElementUsed @"MPNotificationElementUsed"
|
#define MPNotificationElementUsed @"MPNotificationElementUsed"
|
||||||
|
|
||||||
NSData *keyForPassword(NSString *password, NSString *username);
|
NSData *keyForPassword(NSString *password, NSString *username);
|
||||||
NSData *keyIDForPassword(NSString *password, NSString *username);
|
NSData *keyIDForPassword(NSString *password, NSString *username);
|
||||||
NSData *keyIDForKey(NSData *key);
|
NSData *keyIDForKey(NSData *key);
|
||||||
NSString *NSStringFromMPElementType(MPElementType type);
|
NSString *NSStringFromMPElementType(MPElementType type);
|
||||||
NSString *ClassNameFromMPElementType(MPElementType type);
|
NSString *ClassNameFromMPElementType(MPElementType type);
|
||||||
Class ClassFromMPElementType(MPElementType type);
|
Class ClassFromMPElementType(MPElementType type);
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MPTypes.h"
|
#import "MPTypes.h"
|
||||||
#import "MPElementGeneratedEntity.h"
|
|
||||||
#import "MPElementStoredEntity.h"
|
#import "MPElementStoredEntity.h"
|
||||||
|
|
||||||
|
|
||||||
@ -21,23 +20,27 @@ NSData *keyForPassword(NSString *password, NSString *username) {
|
|||||||
|
|
||||||
uint32_t nusernameLength = htonl(username.length);
|
uint32_t nusernameLength = htonl(username.length);
|
||||||
NSData *key = [PearlSCrypt deriveKeyWithLength:MP_dkLen fromPassword:[password dataUsingEncoding:NSUTF8StringEncoding]
|
NSData *key = [PearlSCrypt deriveKeyWithLength:MP_dkLen fromPassword:[password dataUsingEncoding:NSUTF8StringEncoding]
|
||||||
usingSalt:[NSData dataByConcatenatingDatas:
|
usingSalt:[NSData dataByConcatenatingDatas:
|
||||||
[@"com.lyndir.masterpassword" dataUsingEncoding:NSUTF8StringEncoding],
|
[@"com.lyndir.masterpassword" dataUsingEncoding:NSUTF8StringEncoding],
|
||||||
[NSData dataWithBytes:&nusernameLength length:sizeof(nusernameLength)],
|
[NSData dataWithBytes:&nusernameLength
|
||||||
[username dataUsingEncoding:NSUTF8StringEncoding],
|
length:sizeof(nusernameLength)],
|
||||||
nil] N:MP_N r:MP_r p:MP_p];
|
[username dataUsingEncoding:NSUTF8StringEncoding],
|
||||||
|
nil] N:MP_N r:MP_r p:MP_p];
|
||||||
|
|
||||||
trc(@"User: %@, password: %@ derives to key ID: %@", username, password, [keyIDForKey(key) encodeHex]);
|
trc(@"User: %@, password: %@ derives to key ID: %@", username, password, [keyIDForKey(key) encodeHex]);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSData *keyIDForPassword(NSString *password, NSString *username) {
|
NSData *keyIDForPassword(NSString *password, NSString *username) {
|
||||||
|
|
||||||
return keyIDForKey(keyForPassword(password, username));
|
return keyIDForKey(keyForPassword(password, username));
|
||||||
}
|
}
|
||||||
|
|
||||||
NSData *keyIDForKey(NSData *key) {
|
NSData *keyIDForKey(NSData *key) {
|
||||||
|
|
||||||
return [key hashWith:MP_hash];
|
return [key hashWith:MP_hash];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *NSStringFromMPElementType(MPElementType type) {
|
NSString *NSStringFromMPElementType(MPElementType type) {
|
||||||
|
|
||||||
if (!type)
|
if (!type)
|
||||||
@ -114,6 +117,7 @@ NSString *ClassNameFromMPElementType(MPElementType type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NSDictionary *MPTypes_ciphers = nil;
|
static NSDictionary *MPTypes_ciphers = nil;
|
||||||
|
|
||||||
NSString *MPCalculateContent(MPElementType type, NSString *name, NSData *key, uint32_t counter) {
|
NSString *MPCalculateContent(MPElementType type, NSString *name, NSData *key, uint32_t counter) {
|
||||||
|
|
||||||
if (!(type & MPElementTypeClassGenerated)) {
|
if (!(type & MPElementTypeClassGenerated)) {
|
||||||
@ -129,8 +133,8 @@ NSString *MPCalculateContent(MPElementType type, NSString *name, NSData *key, ui
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if (!counter)
|
if (!counter)
|
||||||
// Counter unset, go into OTP mode.
|
// Counter unset, go into OTP mode.
|
||||||
// Get the UNIX timestamp of the start of the interval of 5 minutes that the current time is in.
|
// Get the UNIX timestamp of the start of the interval of 5 minutes that the current time is in.
|
||||||
counter = ((uint32_t)([[NSDate date] timeIntervalSince1970] / 300)) * 300;
|
counter = ((uint32_t)([[NSDate date] timeIntervalSince1970] / 300)) * 300;
|
||||||
|
|
||||||
if (MPTypes_ciphers == nil)
|
if (MPTypes_ciphers == nil)
|
||||||
@ -141,20 +145,20 @@ NSString *MPCalculateContent(MPElementType type, NSString *name, NSData *key, ui
|
|||||||
trc(@"seed from: hmac-sha256(key, 'com.lyndir.masterpassword' | %u | %@ | %u)", key, name.length, name, counter);
|
trc(@"seed from: hmac-sha256(key, 'com.lyndir.masterpassword' | %u | %@ | %u)", key, name.length, name, counter);
|
||||||
uint32_t ncounter = htonl(counter), nnameLength = htonl(name.length);
|
uint32_t ncounter = htonl(counter), nnameLength = htonl(name.length);
|
||||||
NSData *seed = [[NSData dataByConcatenatingDatas:
|
NSData *seed = [[NSData dataByConcatenatingDatas:
|
||||||
[@"com.lyndir.masterpassword" dataUsingEncoding:NSUTF8StringEncoding],
|
[@"com.lyndir.masterpassword" dataUsingEncoding:NSUTF8StringEncoding],
|
||||||
[NSData dataWithBytes:&nnameLength length:sizeof(nnameLength)],
|
[NSData dataWithBytes:&nnameLength length:sizeof(nnameLength)],
|
||||||
[name dataUsingEncoding:NSUTF8StringEncoding],
|
[name dataUsingEncoding:NSUTF8StringEncoding],
|
||||||
[NSData dataWithBytes:&ncounter length:sizeof(ncounter)],
|
[NSData dataWithBytes:&ncounter length:sizeof(ncounter)],
|
||||||
nil]
|
nil]
|
||||||
hmacWith:PearlHashSHA256 key:key];
|
hmacWith:PearlHashSHA256 key:key];
|
||||||
trc(@"seed is: %@", seed);
|
trc(@"seed is: %@", seed);
|
||||||
const char *seedBytes = seed.bytes;
|
const char *seedBytes = seed.bytes;
|
||||||
|
|
||||||
// Determine the cipher from the first seed byte.
|
// Determine the cipher from the first seed byte.
|
||||||
assert([seed length]);
|
assert([seed length]);
|
||||||
NSArray *typeCiphers = [[MPTypes_ciphers valueForKey:ClassNameFromMPElementType(type)]
|
NSArray *typeCiphers = [[MPTypes_ciphers valueForKey:ClassNameFromMPElementType(type)]
|
||||||
valueForKey:NSStringFromMPElementType(type)];
|
valueForKey:NSStringFromMPElementType(type)];
|
||||||
NSString *cipher = [typeCiphers objectAtIndex:htons(seedBytes[0]) % [typeCiphers count]];
|
NSString *cipher = [typeCiphers objectAtIndex:htons(seedBytes[0]) % [typeCiphers count]];
|
||||||
trc(@"type %d, ciphers: %@, selected: %@", type, typeCiphers, cipher);
|
trc(@"type %d, ciphers: %@, selected: %@", type, typeCiphers, cipher);
|
||||||
|
|
||||||
// Encode the content, character by character, using subsequent seed bytes and the cipher.
|
// Encode the content, character by character, using subsequent seed bytes and the cipher.
|
||||||
@ -162,9 +166,10 @@ NSString *MPCalculateContent(MPElementType type, NSString *name, NSData *key, ui
|
|||||||
NSMutableString *content = [NSMutableString stringWithCapacity:[cipher length]];
|
NSMutableString *content = [NSMutableString stringWithCapacity:[cipher length]];
|
||||||
for (NSUInteger c = 0; c < [cipher length]; ++c) {
|
for (NSUInteger c = 0; c < [cipher length]; ++c) {
|
||||||
uint16_t keyByte = htons(seedBytes[c + 1]);
|
uint16_t keyByte = htons(seedBytes[c + 1]);
|
||||||
NSString *cipherClass = [cipher substringWithRange:NSMakeRange(c, 1)];
|
NSString *cipherClass = [cipher substringWithRange:NSMakeRange(c, 1)];
|
||||||
NSString *cipherClassCharacters = [[MPTypes_ciphers valueForKey:@"MPCharacterClasses"] valueForKey:cipherClass];
|
NSString *cipherClassCharacters = [[MPTypes_ciphers valueForKey:@"MPCharacterClasses"] valueForKey:cipherClass];
|
||||||
NSString *character = [cipherClassCharacters substringWithRange:NSMakeRange(keyByte % [cipherClassCharacters length], 1)];
|
NSString *character = [cipherClassCharacters substringWithRange:NSMakeRange(keyByte % [cipherClassCharacters length],
|
||||||
|
1)];
|
||||||
|
|
||||||
trc(@"class %@ has characters: %@, selected: %@", cipherClass, cipherClassCharacters, character);
|
trc(@"class %@ has characters: %@, selected: %@", cipherClass, cipherClassCharacters, character);
|
||||||
[content appendString:character];
|
[content appendString:character];
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
|
|
||||||
@interface MPUserEntity : NSManagedObject
|
@interface MPUserEntity : NSManagedObject
|
||||||
|
|
||||||
@property (nonatomic, retain) NSNumber * avatar_;
|
@property (nonatomic, retain) NSNumber *avatar_;
|
||||||
@property (nonatomic, retain) NSData * keyID;
|
@property (nonatomic, retain) NSData *keyID;
|
||||||
@property (nonatomic, retain) NSDate * lastUsed;
|
@property (nonatomic, retain) NSDate *lastUsed;
|
||||||
@property (nonatomic, retain) NSString * name;
|
@property (nonatomic, retain) NSString *name;
|
||||||
@property (nonatomic, retain) NSNumber * saveKey_;
|
@property (nonatomic, retain) NSNumber *saveKey_;
|
||||||
@property (nonatomic, retain) NSSet *elements;
|
@property (nonatomic, retain) NSSet *elements;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MPUserEntity (CoreDataGeneratedAccessors)
|
@interface MPUserEntity (CoreDataGeneratedAccessors)
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MPUserEntity.h"
|
#import "MPUserEntity.h"
|
||||||
#import "MPElementEntity.h"
|
|
||||||
|
|
||||||
|
|
||||||
@implementation MPUserEntity
|
@implementation MPUserEntity
|
||||||
|
@ -10,16 +10,16 @@
|
|||||||
#import "MPAppDelegate_Shared.h"
|
#import "MPAppDelegate_Shared.h"
|
||||||
#import "MPPasswordWindowController.h"
|
#import "MPPasswordWindowController.h"
|
||||||
|
|
||||||
@interface MPAppDelegate : MPAppDelegate_Shared <NSApplicationDelegate>
|
@interface MPAppDelegate : MPAppDelegate_Shared<NSApplicationDelegate>
|
||||||
|
|
||||||
@property (strong) NSStatusItem *statusItem;
|
@property (strong) NSStatusItem *statusItem;
|
||||||
@property (strong) MPPasswordWindowController *passwordWindow;
|
@property (strong) MPPasswordWindowController *passwordWindow;
|
||||||
@property (weak) IBOutlet NSMenuItem *lockItem;
|
@property (weak) IBOutlet NSMenuItem *lockItem;
|
||||||
@property (weak) IBOutlet NSMenuItem *showItem;
|
@property (weak) IBOutlet NSMenuItem *showItem;
|
||||||
@property (strong) IBOutlet NSMenu *statusMenu;
|
@property (strong) IBOutlet NSMenu *statusMenu;
|
||||||
@property (weak) IBOutlet NSMenuItem *useICloudItem;
|
@property (weak) IBOutlet NSMenuItem *useICloudItem;
|
||||||
@property (weak) IBOutlet NSMenuItem *rememberPasswordItem;
|
@property (weak) IBOutlet NSMenuItem *rememberPasswordItem;
|
||||||
@property (weak) IBOutlet NSMenuItem *savePasswordItem;
|
@property (weak) IBOutlet NSMenuItem *savePasswordItem;
|
||||||
|
|
||||||
+ (MPAppDelegate *)get;
|
+ (MPAppDelegate *)get;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
@synthesize keyID;
|
@synthesize keyID;
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wfour-char-constants"
|
#pragma GCC diagnostic ignored "-Wfour-char-constants"
|
||||||
static EventHotKeyID MPShowHotKey = { .signature = 'show', .id = 1 };
|
static EventHotKeyID MPShowHotKey = {.signature = 'show', .id = 1};
|
||||||
|
|
||||||
+ (void)initialize {
|
+ (void)initialize {
|
||||||
|
|
||||||
@ -44,12 +44,12 @@ static EventHotKeyID MPShowHotKey = { .signature = 'show', .id = 1 };
|
|||||||
return (MPAppDelegate *)[super get];
|
return (MPAppDelegate *)[super get];
|
||||||
}
|
}
|
||||||
|
|
||||||
static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData){
|
static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData) {
|
||||||
|
|
||||||
// Extract the hotkey ID.
|
// Extract the hotkey ID.
|
||||||
EventHotKeyID hotKeyID;
|
EventHotKeyID hotKeyID;
|
||||||
GetEventParameter(theEvent,kEventParamDirectObject,typeEventHotKeyID,
|
GetEventParameter(theEvent, kEventParamDirectObject, typeEventHotKeyID,
|
||||||
NULL,sizeof(hotKeyID),NULL,&hotKeyID);
|
NULL, sizeof(hotKeyID), NULL, &hotKeyID);
|
||||||
|
|
||||||
// Check which hotkey this was.
|
// Check which hotkey this was.
|
||||||
if (hotKeyID.signature == MPShowHotKey.signature && hotKeyID.id == MPShowHotKey.id) {
|
if (hotKeyID.signature == MPShowHotKey.signature && hotKeyID.id == MPShowHotKey.id) {
|
||||||
@ -63,8 +63,8 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
- (void)showMenu {
|
- (void)showMenu {
|
||||||
|
|
||||||
self.rememberPasswordItem.state = [[MPConfig get].rememberKey boolValue]? NSOnState: NSOffState;
|
self.rememberPasswordItem.state = [[MPConfig get].rememberKey boolValue]? NSOnState: NSOffState;
|
||||||
self.savePasswordItem.state = [[MPConfig get].saveKey boolValue]? NSOnState: NSOffState;
|
self.savePasswordItem.state = [[MPConfig get].saveKey boolValue]? NSOnState: NSOffState;
|
||||||
self.showItem.enabled = ![self.passwordWindow.window isVisible];
|
self.showItem.enabled = ![self.passwordWindow.window isVisible];
|
||||||
|
|
||||||
[self.statusItem popUpStatusItemMenu:self.statusMenu];
|
[self.statusItem popUpStatusItemMenu:self.statusMenu];
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
if (sender == rememberPasswordItem)
|
if (sender == rememberPasswordItem)
|
||||||
[MPConfig get].rememberKey = [NSNumber numberWithBool:![[MPConfig get].rememberKey boolValue]];
|
[MPConfig get].rememberKey = [NSNumber numberWithBool:![[MPConfig get].rememberKey boolValue]];
|
||||||
if (sender == savePasswordItem)
|
if (sender == savePasswordItem)
|
||||||
[MPConfig get].saveKey = [NSNumber numberWithBool:![[MPConfig get].saveKey boolValue]];
|
[MPConfig get].saveKey = [NSNumber numberWithBool:![[MPConfig get].saveKey boolValue]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didUpdateConfigForKey:(SEL)configKey fromValue:(id)oldValue {
|
- (void)didUpdateConfigForKey:(SEL)configKey fromValue:(id)oldValue {
|
||||||
@ -92,7 +92,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
if (configKey == @selector(rememberKey))
|
if (configKey == @selector(rememberKey))
|
||||||
self.rememberPasswordItem.state = [[MPConfig get].rememberKey boolValue]? NSOnState: NSOffState;
|
self.rememberPasswordItem.state = [[MPConfig get].rememberKey boolValue]? NSOnState: NSOffState;
|
||||||
if (configKey == @selector(saveKey))
|
if (configKey == @selector(saveKey))
|
||||||
self.savePasswordItem.state = [[MPConfig get].saveKey boolValue]? NSOnState: NSOffState;
|
self.savePasswordItem.state = [[MPConfig get].saveKey boolValue]? NSOnState: NSOffState;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
||||||
@ -125,22 +125,23 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
[[self storeManager] useiCloudStore:YES alertUser:YES];
|
[[self storeManager] useiCloudStore:YES alertUser:YES];
|
||||||
|
|
||||||
// Status item.
|
// Status item.
|
||||||
self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
|
self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
|
||||||
self.statusItem.title = @"•••";
|
self.statusItem.title = @"•••";
|
||||||
self.statusItem.highlightMode = YES;
|
self.statusItem.highlightMode = YES;
|
||||||
self.statusItem.target = self;
|
self.statusItem.target = self;
|
||||||
self.statusItem.action = @selector(showMenu);
|
self.statusItem.action = @selector(showMenu);
|
||||||
|
|
||||||
// Global hotkey.
|
// Global hotkey.
|
||||||
EventHotKeyRef hotKeyRef;
|
EventHotKeyRef hotKeyRef;
|
||||||
EventTypeSpec hotKeyEvents[1] = { { .eventClass = kEventClassKeyboard, .eventKind = kEventHotKeyPressed } };
|
EventTypeSpec hotKeyEvents[1] = {{.eventClass = kEventClassKeyboard, .eventKind = kEventHotKeyPressed}};
|
||||||
OSStatus status = InstallApplicationEventHandler(NewEventHandlerUPP(MPHotKeyHander), GetEventTypeCount(hotKeyEvents), hotKeyEvents,
|
OSStatus status = InstallApplicationEventHandler(NewEventHandlerUPP(MPHotKeyHander), GetEventTypeCount(hotKeyEvents),
|
||||||
(__bridge void *)self, NULL);
|
hotKeyEvents,
|
||||||
if(status != noErr)
|
(__bridge void *)self, NULL);
|
||||||
err(@"Error installing application event handler: %d", status);
|
if (status != noErr)
|
||||||
status = RegisterEventHotKey(35 /* p */, controlKey + cmdKey, MPShowHotKey, GetApplicationEventTarget(), 0, &hotKeyRef);
|
err(@"Error installing application event handler: %d", status);
|
||||||
if(status != noErr)
|
status = RegisterEventHotKey(35 /* p */, controlKey + cmdKey, MPShowHotKey, GetApplicationEventTarget(), 0, &hotKeyRef);
|
||||||
err(@"Error registering hotkey: %d", status);
|
if (status != noErr)
|
||||||
|
err(@"Error registering hotkey: %d", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillBecomeActive:(NSNotification *)notification {
|
- (void)applicationWillBecomeActive:(NSNotification *)notification {
|
||||||
@ -164,8 +165,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
self.key = nil;
|
self.key = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
||||||
{
|
|
||||||
// Save changes in the application's managed object context before the application terminates.
|
// Save changes in the application's managed object context before the application terminates.
|
||||||
|
|
||||||
if (![self managedObjectContext]) {
|
if (![self managedObjectContext]) {
|
||||||
@ -190,11 +190,11 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
return NSTerminateCancel;
|
return NSTerminateCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *question = NSLocalizedString(@"Could not save changes while quitting. Quit anyway?", @"Quit without saves error question message");
|
NSString *question = NSLocalizedString(@"Could not save changes while quitting. Quit anyway?", @"Quit without saves error question message");
|
||||||
NSString *info = NSLocalizedString(@"Quitting now will lose any changes you have made since the last successful save", @"Quit without saves error question info");
|
NSString *info = NSLocalizedString(@"Quitting now will lose any changes you have made since the last successful save", @"Quit without saves error question info");
|
||||||
NSString *quitButton = NSLocalizedString(@"Quit anyway", @"Quit anyway button title");
|
NSString *quitButton = NSLocalizedString(@"Quit anyway", @"Quit anyway button title");
|
||||||
NSString *cancelButton = NSLocalizedString(@"Cancel", @"Cancel button title");
|
NSString *cancelButton = NSLocalizedString(@"Cancel", @"Cancel button title");
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert setMessageText:question];
|
[alert setMessageText:question];
|
||||||
[alert setInformativeText:info];
|
[alert setInformativeText:info];
|
||||||
[alert addButtonWithTitle:quitButton];
|
[alert addButtonWithTitle:quitButton];
|
||||||
@ -214,7 +214,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
|
|
||||||
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToiCloud:(BOOL)iCloudEnabled {
|
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToiCloud:(BOOL)iCloudEnabled {
|
||||||
|
|
||||||
self.useICloudItem.state = iCloudEnabled? NSOnState: NSOffState;
|
self.useICloudItem.state = iCloudEnabled? NSOnState: NSOffState;
|
||||||
self.useICloudItem.enabled = !iCloudEnabled;
|
self.useICloudItem.enabled = !iCloudEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface MPPasswordWindowController : NSWindowController <NSTextFieldDelegate> {
|
@interface MPPasswordWindowController : NSWindowController<NSTextFieldDelegate> {
|
||||||
|
|
||||||
NSString *_content;
|
NSString *_content;
|
||||||
}
|
}
|
||||||
|
@ -59,18 +59,18 @@
|
|||||||
- (void)unlock {
|
- (void)unlock {
|
||||||
|
|
||||||
if (![MPAppDelegate get].key)
|
if (![MPAppDelegate get].key)
|
||||||
// Try and load the key from the keychain.
|
// Try and load the key from the keychain.
|
||||||
[[MPAppDelegate get] loadStoredKey];
|
[[MPAppDelegate get] loadStoredKey];
|
||||||
|
|
||||||
if (![MPAppDelegate get].key)
|
if (![MPAppDelegate get].key)
|
||||||
// Ask the user to set the key through his master password.
|
// Ask the user to set the key through his master password.
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if ([MPAppDelegate get].key)
|
if ([MPAppDelegate get].key)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Master Password is locked."
|
NSAlert *alert = [NSAlert alertWithMessageText:@"Master Password is locked."
|
||||||
defaultButton:@"Unlock" alternateButton:@"Change" otherButton:@"Quit"
|
defaultButton:@"Unlock" alternateButton:@"Change" otherButton:@"Quit"
|
||||||
informativeTextWithFormat:@"Your master password is required to unlock the application."];
|
informativeTextWithFormat:@"Your master password is required to unlock the application."];
|
||||||
NSSecureTextField *passwordField = [[NSSecureTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 22)];
|
NSSecureTextField *passwordField = [[NSSecureTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 22)];
|
||||||
[alert setAccessoryView:passwordField];
|
[alert setAccessoryView:passwordField];
|
||||||
[alert layout];
|
[alert layout];
|
||||||
@ -80,19 +80,20 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
|
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
|
||||||
|
|
||||||
switch (returnCode) {
|
switch (returnCode) {
|
||||||
case NSAlertAlternateReturn:
|
case NSAlertAlternateReturn:
|
||||||
// "Change" button.
|
// "Change" button.
|
||||||
if ([[NSAlert alertWithMessageText:@"Changing Master Password"
|
if ([[NSAlert alertWithMessageText:@"Changing Master Password"
|
||||||
defaultButton:nil alternateButton:[PearlStrings get].commonButtonCancel otherButton:nil
|
defaultButton:nil alternateButton:[PearlStrings get].commonButtonCancel otherButton:nil
|
||||||
informativeTextWithFormat:
|
informativeTextWithFormat:
|
||||||
@"This will allow you to log in with a different master password.\n\n"
|
@"This will allow you to log in with a different master password.\n\n"
|
||||||
@"Note that you will only see the sites and passwords for the master password you log in with.\n"
|
@"Note that you will only see the sites and passwords for the master password you log in with.\n"
|
||||||
@"If you log in with a different master password, your current sites will be unavailable.\n\n"
|
@"If you log in with a different master password, your current sites will be unavailable.\n\n"
|
||||||
@"You can always change back to your current master password later.\n"
|
@"You can always change back to your current master password later.\n"
|
||||||
@"Your current sites and passwords will then become available again."] runModal] == 1)
|
@"Your current sites and passwords will then become available again."] runModal]
|
||||||
|
== 1)
|
||||||
[[MPAppDelegate get] forgetKey];
|
[[MPAppDelegate get] forgetKey];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -107,7 +108,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index {
|
- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words
|
||||||
|
forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index {
|
||||||
|
|
||||||
NSString *query = [[control stringValue] substringWithRange:charRange];
|
NSString *query = [[control stringValue] substringWithRange:charRange];
|
||||||
if (![query length] || ![MPAppDelegate get].keyID)
|
if (![query length] || ![MPAppDelegate get].keyID)
|
||||||
@ -115,15 +117,15 @@
|
|||||||
|
|
||||||
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPElementEntity class])];
|
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPElementEntity class])];
|
||||||
fetchRequest.sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"uses_" ascending:NO]];
|
fetchRequest.sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"uses_" ascending:NO]];
|
||||||
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"(%@ == '' OR name BEGINSWITH[cd] %@) AND user == %@",
|
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"(%@ == '' OR name BEGINSWITH[cd] %@) AND user == %@",
|
||||||
query, query, [MPAppDelegate get].activeUser];
|
query, query, [MPAppDelegate get].activeUser];
|
||||||
|
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
self.siteResults = [[MPAppDelegate managedObjectContext] executeFetchRequest:fetchRequest error:&error];
|
self.siteResults = [[MPAppDelegate managedObjectContext] executeFetchRequest:fetchRequest error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
err(@"Couldn't fetch elements: %@", error);
|
err(@"Couldn't fetch elements: %@", error);
|
||||||
|
|
||||||
NSMutableArray *mutableResults = [NSMutableArray arrayWithCapacity:[self.siteResults count] + 1];
|
NSMutableArray *mutableResults = [NSMutableArray arrayWithCapacity:[self.siteResults count] + 1];
|
||||||
if (self.siteResults)
|
if (self.siteResults)
|
||||||
for (MPElementEntity *element in self.siteResults)
|
for (MPElementEntity *element in self.siteResults)
|
||||||
[mutableResults addObject:element.name];
|
[mutableResults addObject:element.name];
|
||||||
@ -153,7 +155,7 @@
|
|||||||
[[self findElement] use];
|
[[self findElement] use];
|
||||||
return YES;
|
return YES;
|
||||||
} else
|
} else
|
||||||
wrn(@"Couldn't copy password to pasteboard.");
|
wrn(@"Couldn't copy password to pasteboard.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
@ -175,19 +177,19 @@
|
|||||||
_content = content;
|
_content = content;
|
||||||
|
|
||||||
NSShadow *shadow = [NSShadow new];
|
NSShadow *shadow = [NSShadow new];
|
||||||
shadow.shadowColor = [NSColor colorWithDeviceWhite:0.0f alpha:0.6f];
|
shadow.shadowColor = [NSColor colorWithDeviceWhite:0.0f alpha:0.6f];
|
||||||
shadow.shadowOffset = NSMakeSize(1.0f, -1.0f);
|
shadow.shadowOffset = NSMakeSize(1.0f, -1.0f);
|
||||||
shadow.shadowBlurRadius = 1.2f;
|
shadow.shadowBlurRadius = 1.2f;
|
||||||
|
|
||||||
NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
|
NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
|
||||||
paragraph.alignment = NSCenterTextAlignment;
|
paragraph.alignment = NSCenterTextAlignment;
|
||||||
|
|
||||||
[self.contentField setAttributedStringValue:
|
[self.contentField setAttributedStringValue:
|
||||||
[[NSAttributedString alloc] initWithString:_content
|
[[NSAttributedString alloc] initWithString:_content
|
||||||
attributes:[[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
attributes:[[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||||
shadow, NSShadowAttributeName,
|
shadow, NSShadowAttributeName,
|
||||||
paragraph, NSParagraphStyleAttributeName,
|
paragraph, NSParagraphStyleAttributeName,
|
||||||
nil]]];
|
nil]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)trySite {
|
- (BOOL)trySite {
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#import "Pearl-Prefix.pch"
|
#import "Pearl-Prefix.pch"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) {
|
||||||
{
|
|
||||||
return NSApplicationMain(argc, (const char **)argv);
|
return NSApplicationMain(argc, (const char **)argv);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#import <MessageUI/MessageUI.h>
|
#import <MessageUI/MessageUI.h>
|
||||||
#import "MPAppDelegate_Shared.h"
|
#import "MPAppDelegate_Shared.h"
|
||||||
|
|
||||||
@interface MPAppDelegate : MPAppDelegate_Shared <MFMailComposeViewControllerDelegate>
|
@interface MPAppDelegate : MPAppDelegate_Shared<MFMailComposeViewControllerDelegate>
|
||||||
|
|
||||||
+ (MPAppDelegate *)get;
|
+ (MPAppDelegate *)get;
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
#import "IASKSettingsReader.h"
|
#import "IASKSettingsReader.h"
|
||||||
#import "LocalyticsSession.h"
|
#import "LocalyticsSession.h"
|
||||||
#import "TestFlight.h"
|
|
||||||
#import <Crashlytics/Crashlytics.h>
|
|
||||||
#import "ATConnect.h"
|
#import "ATConnect.h"
|
||||||
|
|
||||||
@interface MPAppDelegate ()
|
@interface MPAppDelegate ()
|
||||||
@ -66,24 +64,25 @@
|
|||||||
- (void)export {
|
- (void)export {
|
||||||
|
|
||||||
[PearlAlert showNotice:
|
[PearlAlert showNotice:
|
||||||
@"This will export all your site names.\n\n"
|
@"This will export all your site names.\n\n"
|
||||||
@"You can open the export with a text editor to get an overview of all your sites.\n\n"
|
@"You can open the export with a text editor to get an overview of all your sites.\n\n"
|
||||||
@"The file also acts as a personal backup of your site list in case you don't sync with iCloud/iTunes."
|
@"The file also acts as a personal backup of your site list in case you don't sync with iCloud/iTunes."
|
||||||
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
[PearlAlert showAlertWithTitle:@"Reveal Passwords?" message:
|
[PearlAlert showAlertWithTitle:@"Reveal Passwords?" message:
|
||||||
@"Would you like to make all your passwords visible in the export?\n\n"
|
@"Would you like to make all your passwords visible in the export?\n\n"
|
||||||
@"A safe export will only include your stored passwords, in an encrypted manner, "
|
@"A safe export will only include your stored passwords, in an encrypted manner, "
|
||||||
@"making the result safe from falling in the wrong hands.\n\n"
|
@"making the result safe from falling in the wrong hands.\n\n"
|
||||||
@"If all your passwords are shown and somebody else finds the export, "
|
@"If all your passwords are shown and somebody else finds the export, "
|
||||||
@"they could gain access to all your sites!"
|
@"they could gain access to all your sites!"
|
||||||
viewStyle:UIAlertViewStyleDefault initAlert:nil tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
viewStyle:UIAlertViewStyleDefault initAlert:nil
|
||||||
if (buttonIndex_ == [alert_ firstOtherButtonIndex] + 0)
|
tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
||||||
// Safe Export
|
if (buttonIndex_ == [alert_ firstOtherButtonIndex] + 0)
|
||||||
[self exportShowPasswords:NO];
|
// Safe Export
|
||||||
if (buttonIndex_ == [alert_ firstOtherButtonIndex] + 1)
|
[self exportShowPasswords:NO];
|
||||||
// Safe Export
|
if (buttonIndex_ == [alert_ firstOtherButtonIndex] + 1)
|
||||||
[self exportShowPasswords:YES];
|
// Safe Export
|
||||||
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Safe Export", @"Show Passwords", nil];
|
[self exportShowPasswords:YES];
|
||||||
|
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Safe Export", @"Show Passwords", nil];
|
||||||
} otherTitles:nil];
|
} otherTitles:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +103,7 @@
|
|||||||
[composer setSubject:@"Master Password site export"];
|
[composer setSubject:@"Master Password site export"];
|
||||||
[composer setMessageBody:message isHTML:NO];
|
[composer setMessageBody:message isHTML:NO];
|
||||||
[composer addAttachmentData:[exportedSites dataUsingEncoding:NSUTF8StringEncoding] mimeType:@"text/plain"
|
[composer addAttachmentData:[exportedSites dataUsingEncoding:NSUTF8StringEncoding] mimeType:@"text/plain"
|
||||||
fileName:[exportDateFormatter stringFromDate:[NSDate date]]];
|
fileName:[exportDateFormatter stringFromDate:[NSDate date]]];
|
||||||
[self.window.rootViewController presentModalViewController:composer animated:YES];
|
[self.window.rootViewController presentModalViewController:composer animated:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,23 +111,23 @@
|
|||||||
|
|
||||||
[PearlAlert showAlertWithTitle:@"Changing Master Password"
|
[PearlAlert showAlertWithTitle:@"Changing Master Password"
|
||||||
message:
|
message:
|
||||||
@"This will allow you to log in with a different master password.\n\n"
|
@"This will allow you to log in with a different master password.\n\n"
|
||||||
@"Note that you will only see the sites and passwords for the master password you log in with.\n"
|
@"Note that you will only see the sites and passwords for the master password you log in with.\n"
|
||||||
@"If you log in with a different master password, your current sites will be unavailable.\n\n"
|
@"If you log in with a different master password, your current sites will be unavailable.\n\n"
|
||||||
@"You can always change back to your current master password later.\n"
|
@"You can always change back to your current master password later.\n"
|
||||||
@"Your current sites and passwords will then become available again."
|
@"Your current sites and passwords will then become available again."
|
||||||
viewStyle:UIAlertViewStyleDefault
|
viewStyle:UIAlertViewStyleDefault
|
||||||
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
if (buttonIndex == [alert cancelButtonIndex])
|
if (buttonIndex == [alert cancelButtonIndex])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.activeUser.keyID = nil;
|
self.activeUser.keyID = nil;
|
||||||
[self signOut];
|
[self signOut];
|
||||||
|
|
||||||
[TestFlight passCheckpoint:MPTestFlightCheckpointChangeMP];
|
[TestFlight passCheckpoint:MPTestFlightCheckpointChangeMP];
|
||||||
}
|
}
|
||||||
cancelTitle:[PearlStrings get].commonButtonAbort
|
cancelTitle:[PearlStrings get].commonButtonAbort
|
||||||
otherTitles:[PearlStrings get].commonButtonContinue, nil];
|
otherTitles:[PearlStrings get].commonButtonContinue, nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - PearlConfigDelegate
|
#pragma mark - PearlConfigDelegate
|
||||||
@ -221,57 +220,57 @@
|
|||||||
err(@"Apptentive: %@", exception);
|
err(@"Apptentive: %@", exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
UIImage *navBarImage = [[UIImage imageNamed:@"ui_navbar_container"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
|
UIImage *navBarImage = [[UIImage imageNamed:@"ui_navbar_container"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
|
||||||
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
|
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
|
||||||
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsLandscapePhone];
|
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsLandscapePhone];
|
||||||
[[UINavigationBar appearance] setTitleTextAttributes:
|
[[UINavigationBar appearance] setTitleTextAttributes:
|
||||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], UITextAttributeTextColor,
|
[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], UITextAttributeTextColor,
|
||||||
[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f], UITextAttributeTextShadowColor,
|
[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f], UITextAttributeTextShadowColor,
|
||||||
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset,
|
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset,
|
||||||
[UIFont fontWithName:@"Exo-Bold" size:20.0f], UITextAttributeFont,
|
[UIFont fontWithName:@"Exo-Bold" size:20.0f], UITextAttributeFont,
|
||||||
nil]];
|
nil]];
|
||||||
|
|
||||||
UIImage *navBarButton = [[UIImage imageNamed:@"ui_navbar_button"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
|
UIImage *navBarButton = [[UIImage imageNamed:@"ui_navbar_button"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
|
||||||
UIImage *navBarBack = [[UIImage imageNamed:@"ui_navbar_back"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)];
|
UIImage *navBarBack = [[UIImage imageNamed:@"ui_navbar_back"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)];
|
||||||
[[UIBarButtonItem appearance] setBackgroundImage:navBarButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
[[UIBarButtonItem appearance] setBackgroundImage:navBarButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
||||||
[[UIBarButtonItem appearance] setBackgroundImage:nil forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
|
[[UIBarButtonItem appearance] setBackgroundImage:nil forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
|
||||||
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:navBarBack forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:navBarBack forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
||||||
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:nil forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
|
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:nil forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
|
||||||
[[UIBarButtonItem appearance] setTitleTextAttributes:
|
[[UIBarButtonItem appearance] setTitleTextAttributes:
|
||||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], UITextAttributeTextColor,
|
[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], UITextAttributeTextColor,
|
||||||
[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5f], UITextAttributeTextShadowColor,
|
[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5f], UITextAttributeTextShadowColor,
|
||||||
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
|
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
|
||||||
[UIFont fontWithName:@"Helvetica-Neue" size:0.0f], UITextAttributeFont,
|
[UIFont fontWithName:@"Helvetica-Neue" size:0.0f], UITextAttributeFont,
|
||||||
nil]
|
nil]
|
||||||
forState:UIControlStateNormal];
|
forState:UIControlStateNormal];
|
||||||
|
|
||||||
UIImage *toolBarImage = [[UIImage imageNamed:@"ui_toolbar_container"] resizableImageWithCapInsets:UIEdgeInsetsMake(25, 5, 5, 5)];
|
UIImage *toolBarImage = [[UIImage imageNamed:@"ui_toolbar_container"] resizableImageWithCapInsets:UIEdgeInsetsMake(25, 5, 5, 5)];
|
||||||
[[UISearchBar appearance] setBackgroundImage:toolBarImage];
|
[[UISearchBar appearance] setBackgroundImage:toolBarImage];
|
||||||
[[UIToolbar appearance] setBackgroundImage:toolBarImage forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
|
[[UIToolbar appearance] setBackgroundImage:toolBarImage forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
UIImage *minImage = [[UIImage imageNamed:@"slider-minimum.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
|
UIImage *minImage = [[UIImage imageNamed:@"slider-minimum.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
|
||||||
UIImage *maxImage = [[UIImage imageNamed:@"slider-maximum.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
|
UIImage *maxImage = [[UIImage imageNamed:@"slider-maximum.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
|
||||||
UIImage *thumbImage = [UIImage imageNamed:@"slider-handle.png"];
|
UIImage *thumbImage = [UIImage imageNamed:@"slider-handle.png"];
|
||||||
|
|
||||||
[[UISlider appearance] setMaximumTrackImage:maxImage forState:UIControlStateNormal];
|
[[UISlider appearance] setMaximumTrackImage:maxImage forState:UIControlStateNormal];
|
||||||
[[UISlider appearance] setMinimumTrackImage:minImage forState:UIControlStateNormal];
|
[[UISlider appearance] setMinimumTrackImage:minImage forState:UIControlStateNormal];
|
||||||
[[UISlider appearance] setThumbImage:thumbImage forState:UIControlStateNormal];
|
[[UISlider appearance] setThumbImage:thumbImage forState:UIControlStateNormal];
|
||||||
|
|
||||||
UIImage *segmentSelected = [[UIImage imageNamed:@"segcontrol_sel.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
|
UIImage *segmentSelected = [[UIImage imageNamed:@"segcontrol_sel.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
|
||||||
UIImage *segmentUnselected = [[UIImage imageNamed:@"segcontrol_uns.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
|
UIImage *segmentUnselected = [[UIImage imageNamed:@"segcontrol_uns.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
|
||||||
UIImage *segmentSelectedUnselected = [UIImage imageNamed:@"segcontrol_sel-uns.png"];
|
UIImage *segmentSelectedUnselected = [UIImage imageNamed:@"segcontrol_sel-uns.png"];
|
||||||
UIImage *segUnselectedSelected = [UIImage imageNamed:@"segcontrol_uns-sel.png"];
|
UIImage *segUnselectedSelected = [UIImage imageNamed:@"segcontrol_uns-sel.png"];
|
||||||
UIImage *segmentUnselectedUnselected = [UIImage imageNamed:@"segcontrol_uns-uns.png"];
|
UIImage *segmentUnselectedUnselected = [UIImage imageNamed:@"segcontrol_uns-uns.png"];
|
||||||
|
|
||||||
[[UISegmentedControl appearance] setBackgroundImage:segmentUnselected forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
[[UISegmentedControl appearance] setBackgroundImage:segmentUnselected forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
||||||
[[UISegmentedControl appearance] setBackgroundImage:segmentSelected forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
|
[[UISegmentedControl appearance] setBackgroundImage:segmentSelected forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
|
||||||
|
|
||||||
[[UISegmentedControl appearance] setDividerImage:segmentUnselectedUnselected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
[[UISegmentedControl appearance] setDividerImage:segmentUnselectedUnselected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
||||||
[[UISegmentedControl appearance] setDividerImage:segmentSelectedUnselected forLeftSegmentState:UIControlStateSelected rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
[[UISegmentedControl appearance] setDividerImage:segmentSelectedUnselected forLeftSegmentState:UIControlStateSelected rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
||||||
[[UISegmentedControl appearance] setDividerImage:segUnselectedSelected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];*/
|
[[UISegmentedControl appearance] setDividerImage:segUnselectedSelected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];*/
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:MPNotificationSignedOut object:nil queue:nil
|
[[NSNotificationCenter defaultCenter] addObserverForName:MPNotificationSignedOut object:nil queue:nil
|
||||||
usingBlock:^(NSNotification *note) {
|
usingBlock:^(NSNotification *note) {
|
||||||
@ -294,8 +293,7 @@
|
|||||||
cancelTitle:nil otherTitles:[PearlStrings get].commonButtonOkay, nil];
|
cancelTitle:nil otherTitles:[PearlStrings get].commonButtonOkay, nil];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[UIApplication sharedApplication] setStatusBarHidden:NO
|
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
|
||||||
withAnimation:UIStatusBarAnimationSlide];
|
|
||||||
|
|
||||||
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
||||||
}
|
}
|
||||||
@ -303,45 +301,49 @@
|
|||||||
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
|
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
|
||||||
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
|
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
|
||||||
|
|
||||||
__autoreleasing NSError *error;
|
__autoreleasing NSError *error;
|
||||||
__autoreleasing NSURLResponse *response;
|
__autoreleasing NSURLResponse *response;
|
||||||
NSData *importedSitesData = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:url]
|
NSData *importedSitesData = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:url]
|
||||||
returningResponse:&response error:&error];
|
returningResponse:&response error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
err(@"While reading imported sites from %@: %@", url, error);
|
err(@"While reading imported sites from %@: %@", url, error);
|
||||||
if (!importedSitesData)
|
if (!importedSitesData)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
NSString *importedSitesString = [[NSString alloc] initWithData:importedSitesData encoding:NSUTF8StringEncoding];
|
NSString *importedSitesString = [[NSString alloc] initWithData:importedSitesData encoding:NSUTF8StringEncoding];
|
||||||
[PearlAlert showAlertWithTitle:@"Import Password" message:
|
[PearlAlert showAlertWithTitle:@"Import Password" message:
|
||||||
@"Enter the master password for this export:"
|
@"Enter the master password for this export:"
|
||||||
viewStyle:UIAlertViewStyleSecureTextInput initAlert:nil tappedButtonBlock:
|
viewStyle:UIAlertViewStyleSecureTextInput initAlert:nil tappedButtonBlock:
|
||||||
^(UIAlertView *alert, NSInteger buttonIndex) {
|
^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
MPImportResult result = [self importSites:importedSitesString withPassword:[alert textFieldAtIndex:0].text
|
MPImportResult result = [self importSites:importedSitesString withPassword:[alert textFieldAtIndex:0].text
|
||||||
askConfirmation:^BOOL(NSUInteger importCount, NSUInteger deleteCount) {
|
askConfirmation:^BOOL(NSUInteger importCount, NSUInteger deleteCount) {
|
||||||
__block BOOL confirmation = NO;
|
__block BOOL confirmation = NO;
|
||||||
|
|
||||||
dispatch_group_t confirmationGroup = dispatch_group_create();
|
dispatch_group_t confirmationGroup = dispatch_group_create();
|
||||||
dispatch_group_enter(confirmationGroup);
|
dispatch_group_enter(confirmationGroup);
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[PearlAlert showAlertWithTitle:@"Import Sites?"
|
[PearlAlert showAlertWithTitle:@"Import Sites?"
|
||||||
message:PearlString(@"Import %d sites, overwriting %d existing sites?", importCount, deleteCount)
|
message:PearlString(
|
||||||
viewStyle:UIAlertViewStyleDefault
|
@"Import %d sites, overwriting %d existing sites?",
|
||||||
initAlert:nil
|
importCount, deleteCount)
|
||||||
tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
viewStyle:UIAlertViewStyleDefault
|
||||||
if (buttonIndex_ != [alert_ cancelButtonIndex])
|
initAlert:nil
|
||||||
confirmation = YES;
|
tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
||||||
|
if (buttonIndex_
|
||||||
|
!= [alert_ cancelButtonIndex])
|
||||||
|
confirmation = YES;
|
||||||
|
|
||||||
dispatch_group_leave(confirmationGroup);
|
dispatch_group_leave(confirmationGroup);
|
||||||
}
|
}
|
||||||
cancelTitle:[PearlStrings get].commonButtonCancel
|
cancelTitle:[PearlStrings get].commonButtonCancel
|
||||||
otherTitles:@"Import", nil];
|
otherTitles:@"Import", nil];
|
||||||
});
|
});
|
||||||
dispatch_group_wait(confirmationGroup, DISPATCH_TIME_FOREVER);
|
dispatch_group_wait(
|
||||||
|
confirmationGroup, DISPATCH_TIME_FOREVER);
|
||||||
|
|
||||||
return confirmation;
|
return confirmation;
|
||||||
}];
|
}];
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case MPImportResultSuccess:
|
case MPImportResultSuccess:
|
||||||
@ -359,7 +361,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Unlock File", nil];
|
cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Unlock File", nil];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@ -418,7 +420,7 @@
|
|||||||
didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
|
didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
err(@"Error composing mail message: %@", error);
|
err(@"Error composing mail message: %@", error);
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case MFMailComposeResultSaved:
|
case MFMailComposeResultSaved:
|
||||||
@ -426,10 +428,11 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MFMailComposeResultFailed:
|
case MFMailComposeResultFailed:
|
||||||
[PearlAlert showError:@"A problem occurred while sending the message." tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
[PearlAlert showError:@"A problem occurred while sending the message."
|
||||||
if (buttonIndex == [alert firstOtherButtonIndex])
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
return;
|
if (buttonIndex == [alert firstOtherButtonIndex])
|
||||||
} otherTitles:@"Retry", nil];
|
return;
|
||||||
|
} otherTitles:@"Retry", nil];
|
||||||
return;
|
return;
|
||||||
case MFMailComposeResultCancelled:
|
case MFMailComposeResultCancelled:
|
||||||
break;
|
break;
|
||||||
@ -448,38 +451,38 @@
|
|||||||
if (!iCloudEnabled) {
|
if (!iCloudEnabled) {
|
||||||
[PearlAlert showAlertWithTitle:@"iCloud"
|
[PearlAlert showAlertWithTitle:@"iCloud"
|
||||||
message:
|
message:
|
||||||
@"iCloud is now disabled.\n\n"
|
@"iCloud is now disabled.\n\n"
|
||||||
@"It is highly recommended you enable iCloud."
|
@"It is highly recommended you enable iCloud."
|
||||||
viewStyle:UIAlertViewStyleDefault initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
viewStyle:UIAlertViewStyleDefault initAlert:nil
|
||||||
if (buttonIndex == [alert firstOtherButtonIndex] + 0) {
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
[PearlAlert showAlertWithTitle:@"About iCloud"
|
if (buttonIndex == [alert firstOtherButtonIndex] + 0) {
|
||||||
message:
|
[PearlAlert showAlertWithTitle:@"About iCloud"
|
||||||
@"iCloud is Apple's solution for saving your data in \"the cloud\" "
|
message:
|
||||||
@"and making sure your other iPhones, iPads and Macs are in sync.\n\n"
|
@"iCloud is Apple's solution for saving your data in \"the cloud\" "
|
||||||
@"For Master Password, that means your sites are available on all your "
|
@"and making sure your other iPhones, iPads and Macs are in sync.\n\n"
|
||||||
@"Apple devices, and you always have a backup of them in case "
|
@"For Master Password, that means your sites are available on all your "
|
||||||
@"you loose one or need to restore.\n\n"
|
@"Apple devices, and you always have a backup of them in case "
|
||||||
@"Because of the way Master Password works, it doesn't need to send your "
|
@"you loose one or need to restore.\n\n"
|
||||||
@"site's passwords to Apple. Only their names are saved to make it easier "
|
@"Because of the way Master Password works, it doesn't need to send your "
|
||||||
@"for you to find the site you need. For some sites you may have set "
|
@"site's passwords to Apple. Only their names are saved to make it easier "
|
||||||
@"a user-specified password: these are sent to iCloud after being encrypted "
|
@"for you to find the site you need. For some sites you may have set "
|
||||||
@"with your master password.\n\n"
|
@"a user-specified password: these are sent to iCloud after being encrypted "
|
||||||
@"Apple can never see any of your passwords."
|
@"with your master password.\n\n"
|
||||||
viewStyle:UIAlertViewStyleDefault
|
@"Apple can never see any of your passwords."
|
||||||
initAlert:nil
|
viewStyle:UIAlertViewStyleDefault
|
||||||
tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
||||||
[self ubiquityStoreManager:manager didSwitchToiCloud:iCloudEnabled];
|
[self ubiquityStoreManager:manager didSwitchToiCloud:iCloudEnabled];
|
||||||
}
|
}
|
||||||
cancelTitle:[PearlStrings get].commonButtonThanks otherTitles:nil];
|
cancelTitle:[PearlStrings get].commonButtonThanks otherTitles:nil];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MPConfig get].iCloudDecided = [NSNumber numberWithBool:YES];
|
[MPConfig get].iCloudDecided = [NSNumber numberWithBool:YES];
|
||||||
if (buttonIndex == [alert cancelButtonIndex])
|
if (buttonIndex == [alert cancelButtonIndex])
|
||||||
return;
|
return;
|
||||||
if (buttonIndex == [alert firstOtherButtonIndex] + 1)
|
if (buttonIndex == [alert firstOtherButtonIndex] + 1)
|
||||||
[manager useiCloudStore:YES alertUser:NO];
|
[manager useiCloudStore:YES alertUser:NO];
|
||||||
} cancelTitle:@"Leave iCloud Off" otherTitles:@"Explain?", @"Enable iCloud", nil];
|
} cancelTitle:@"Leave iCloud Off" otherTitles:@"Explain?", @"Enable iCloud", nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,7 +495,7 @@
|
|||||||
static NSDictionary *testFlightInfo = nil;
|
static NSDictionary *testFlightInfo = nil;
|
||||||
if (testFlightInfo == nil)
|
if (testFlightInfo == nil)
|
||||||
testFlightInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
testFlightInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
||||||
[[NSBundle mainBundle] URLForResource:@"TestFlight" withExtension:@"plist"]];
|
[[NSBundle mainBundle] URLForResource:@"TestFlight" withExtension:@"plist"]];
|
||||||
|
|
||||||
return testFlightInfo;
|
return testFlightInfo;
|
||||||
}
|
}
|
||||||
@ -511,7 +514,7 @@
|
|||||||
static NSDictionary *crashlyticsInfo = nil;
|
static NSDictionary *crashlyticsInfo = nil;
|
||||||
if (crashlyticsInfo == nil)
|
if (crashlyticsInfo == nil)
|
||||||
crashlyticsInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
crashlyticsInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
||||||
[[NSBundle mainBundle] URLForResource:@"Crashlytics" withExtension:@"plist"]];
|
[[NSBundle mainBundle] URLForResource:@"Crashlytics" withExtension:@"plist"]];
|
||||||
|
|
||||||
return crashlyticsInfo;
|
return crashlyticsInfo;
|
||||||
}
|
}
|
||||||
@ -530,7 +533,7 @@
|
|||||||
static NSDictionary *apptentiveInfo = nil;
|
static NSDictionary *apptentiveInfo = nil;
|
||||||
if (apptentiveInfo == nil)
|
if (apptentiveInfo == nil)
|
||||||
apptentiveInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
apptentiveInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
||||||
[[NSBundle mainBundle] URLForResource:@"Apptentive" withExtension:@"plist"]];
|
[[NSBundle mainBundle] URLForResource:@"Apptentive" withExtension:@"plist"]];
|
||||||
|
|
||||||
return apptentiveInfo;
|
return apptentiveInfo;
|
||||||
}
|
}
|
||||||
@ -549,7 +552,7 @@
|
|||||||
static NSDictionary *localyticsInfo = nil;
|
static NSDictionary *localyticsInfo = nil;
|
||||||
if (localyticsInfo == nil)
|
if (localyticsInfo == nil)
|
||||||
localyticsInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
localyticsInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
||||||
[[NSBundle mainBundle] URLForResource:@"Localytics" withExtension:@"plist"]];
|
[[NSBundle mainBundle] URLForResource:@"Localytics" withExtension:@"plist"]];
|
||||||
|
|
||||||
return localyticsInfo;
|
return localyticsInfo;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MPGuideViewController.h"
|
#import "MPGuideViewController.h"
|
||||||
#import "MPAppDelegate.h"
|
|
||||||
|
|
||||||
|
|
||||||
@implementation MPGuideViewController
|
@implementation MPGuideViewController
|
||||||
|
@ -10,28 +10,28 @@
|
|||||||
#import "MPElementEntity.h"
|
#import "MPElementEntity.h"
|
||||||
#import "MPSearchDelegate.h"
|
#import "MPSearchDelegate.h"
|
||||||
|
|
||||||
@interface MPMainViewController : UIViewController <MPTypeDelegate, UITextFieldDelegate, MPSearchResultsDelegate, UIWebViewDelegate>
|
@interface MPMainViewController : UIViewController<MPTypeDelegate, UITextFieldDelegate, MPSearchResultsDelegate, UIWebViewDelegate>
|
||||||
|
|
||||||
@property (strong, nonatomic) MPElementEntity *activeElement;
|
@property (strong, nonatomic) MPElementEntity *activeElement;
|
||||||
@property (strong, nonatomic) IBOutlet MPSearchDelegate *searchResultsController;
|
@property (strong, nonatomic) IBOutlet MPSearchDelegate *searchResultsController;
|
||||||
@property (weak, nonatomic) IBOutlet UITextField *contentField;
|
@property (weak, nonatomic) IBOutlet UITextField *contentField;
|
||||||
@property (weak, nonatomic) IBOutlet UIButton *typeButton;
|
@property (weak, nonatomic) IBOutlet UIButton *typeButton;
|
||||||
@property (weak, nonatomic) IBOutlet UIWebView *helpView;
|
@property (weak, nonatomic) IBOutlet UIWebView *helpView;
|
||||||
@property (weak, nonatomic) IBOutlet UILabel *siteName;
|
@property (weak, nonatomic) IBOutlet UILabel *siteName;
|
||||||
@property (weak, nonatomic) IBOutlet UILabel *passwordCounter;
|
@property (weak, nonatomic) IBOutlet UILabel *passwordCounter;
|
||||||
@property (weak, nonatomic) IBOutlet UIButton *passwordIncrementer;
|
@property (weak, nonatomic) IBOutlet UIButton *passwordIncrementer;
|
||||||
@property (weak, nonatomic) IBOutlet UIButton *passwordEdit;
|
@property (weak, nonatomic) IBOutlet UIButton *passwordEdit;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *contentContainer;
|
@property (weak, nonatomic) IBOutlet UIView *contentContainer;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *helpContainer;
|
@property (weak, nonatomic) IBOutlet UIView *helpContainer;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *contentTipContainer;
|
@property (weak, nonatomic) IBOutlet UIView *contentTipContainer;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *alertContainer;
|
@property (weak, nonatomic) IBOutlet UIView *alertContainer;
|
||||||
@property (weak, nonatomic) IBOutlet UILabel *alertTitle;
|
@property (weak, nonatomic) IBOutlet UILabel *alertTitle;
|
||||||
@property (weak, nonatomic) IBOutlet UITextView *alertBody;
|
@property (weak, nonatomic) IBOutlet UITextView *alertBody;
|
||||||
@property (weak, nonatomic) IBOutlet UILabel *contentTipBody;
|
@property (weak, nonatomic) IBOutlet UILabel *contentTipBody;
|
||||||
@property (weak, nonatomic) IBOutlet UIImageView *contentTipEditIcon;
|
@property (weak, nonatomic) IBOutlet UIImageView *contentTipEditIcon;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *searchTipContainer;
|
@property (weak, nonatomic) IBOutlet UIView *searchTipContainer;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *actionsTipContainer;
|
@property (weak, nonatomic) IBOutlet UIView *actionsTipContainer;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *typeTipContainer;
|
@property (weak, nonatomic) IBOutlet UIView *typeTipContainer;
|
||||||
|
|
||||||
@property (copy) void (^contentTipCleanup)(BOOL finished);
|
@property (copy) void (^contentTipCleanup)(BOOL finished);
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
#import "MPAppDelegate_Store.h"
|
#import "MPAppDelegate_Store.h"
|
||||||
#import "ATConnect.h"
|
#import "ATConnect.h"
|
||||||
|
|
||||||
#import <MobileCoreServices/MobileCoreServices.h>
|
|
||||||
|
|
||||||
|
|
||||||
@interface MPMainViewController (Private)
|
@interface MPMainViewController (Private)
|
||||||
|
|
||||||
@ -74,12 +72,12 @@
|
|||||||
if (![MPAppDelegate get].activeUser)
|
if (![MPAppDelegate get].activeUser)
|
||||||
[self.navigationController performSegueWithIdentifier:@"MP_Unlock" sender:self];
|
[self.navigationController performSegueWithIdentifier:@"MP_Unlock" sender:self];
|
||||||
if (self.activeElement.user != [MPAppDelegate get].activeUser)
|
if (self.activeElement.user != [MPAppDelegate get].activeUser)
|
||||||
self.activeElement = nil;
|
self.activeElement = nil;
|
||||||
self.searchDisplayController.searchBar.text = nil;
|
self.searchDisplayController.searchBar.text = nil;
|
||||||
|
|
||||||
self.searchTipContainer.alpha = 0;
|
self.searchTipContainer.alpha = 0;
|
||||||
self.actionsTipContainer.alpha = 0;
|
self.actionsTipContainer.alpha = 0;
|
||||||
self.typeTipContainer.alpha = 0;
|
self.typeTipContainer.alpha = 0;
|
||||||
|
|
||||||
[self setHelpHidden:[[MPiOSConfig get].helpHidden boolValue] animated:animated];
|
[self setHelpHidden:[[MPiOSConfig get].helpHidden boolValue] animated:animated];
|
||||||
[self updateAnimated:animated];
|
[self updateAnimated:animated];
|
||||||
@ -90,12 +88,12 @@
|
|||||||
if ([[MPiOSConfig get].firstRun boolValue])
|
if ([[MPiOSConfig get].firstRun boolValue])
|
||||||
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
|
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
|
||||||
self.actionsTipContainer.alpha = 1;
|
self.actionsTipContainer.alpha = 1;
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
[UIView animateWithDuration:0.2f animations:^{
|
[UIView animateWithDuration:0.2f animations:^{
|
||||||
self.actionsTipContainer.alpha = 0;
|
self.actionsTipContainer.alpha = 0;
|
||||||
} completion:^(BOOL finished_) {
|
} completion:^(BOOL finished_) {
|
||||||
if (![self.activeElement.name length])
|
if (![self.activeElement.name length])
|
||||||
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
|
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
|
||||||
self.searchTipContainer.alpha = 1;
|
self.searchTipContainer.alpha = 1;
|
||||||
@ -116,7 +114,7 @@
|
|||||||
|
|
||||||
self.contentField.font = [UIFont fontWithName:@"Exo-Black" size:self.contentField.font.pointSize];
|
self.contentField.font = [UIFont fontWithName:@"Exo-Black" size:self.contentField.font.pointSize];
|
||||||
|
|
||||||
self.alertBody.text = nil;
|
self.alertBody.text = nil;
|
||||||
self.contentTipEditIcon.hidden = YES;
|
self.contentTipEditIcon.hidden = YES;
|
||||||
|
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
@ -158,9 +156,9 @@
|
|||||||
[self setHelpChapter:self.activeElement? @"2": @"1"];
|
[self setHelpChapter:self.activeElement? @"2": @"1"];
|
||||||
self.siteName.text = self.activeElement.name;
|
self.siteName.text = self.activeElement.name;
|
||||||
|
|
||||||
self.passwordCounter.alpha = self.activeElement.type & MPElementTypeClassGenerated? 0.5f: 0;
|
self.passwordCounter.alpha = self.activeElement.type & MPElementTypeClassGenerated? 0.5f: 0;
|
||||||
self.passwordIncrementer.alpha = self.activeElement.type & MPElementTypeClassGenerated? 0.5f: 0;
|
self.passwordIncrementer.alpha = self.activeElement.type & MPElementTypeClassGenerated? 0.5f: 0;
|
||||||
self.passwordEdit.alpha = self.activeElement.type & MPElementTypeClassStored? 0.5f: 0;
|
self.passwordEdit.alpha = self.activeElement.type & MPElementTypeClassStored? 0.5f: 0;
|
||||||
|
|
||||||
[self.typeButton setTitle:NSStringFromMPElementType(self.activeElement.type)
|
[self.typeButton setTitle:NSStringFromMPElementType(self.activeElement.type)
|
||||||
forState:UIControlStateNormal];
|
forState:UIControlStateNormal];
|
||||||
@ -169,7 +167,7 @@
|
|||||||
self.contentField.enabled = NO;
|
self.contentField.enabled = NO;
|
||||||
|
|
||||||
if ([self.activeElement isKindOfClass:[MPElementGeneratedEntity class]])
|
if ([self.activeElement isKindOfClass:[MPElementGeneratedEntity class]])
|
||||||
self.passwordCounter.text = PearlString(@"%u", ((MPElementGeneratedEntity *) self.activeElement).counter);
|
self.passwordCounter.text = PearlString(@"%u", ((MPElementGeneratedEntity *)self.activeElement).counter);
|
||||||
|
|
||||||
self.contentField.text = @"";
|
self.contentField.text = @"";
|
||||||
if (self.activeElement.name && ![self.activeElement isDeleted])
|
if (self.activeElement.name && ![self.activeElement isDeleted])
|
||||||
@ -197,12 +195,12 @@
|
|||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
|
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, self.view.bounds.size.height - 44);
|
self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, self.view.bounds.size.height - 44);
|
||||||
self.helpContainer.frame = CGRectSetY(self.helpContainer.frame, self.view.bounds.size.height);
|
self.helpContainer.frame = CGRectSetY(self.helpContainer.frame, self.view.bounds.size.height);
|
||||||
[MPiOSConfig get].helpHidden = [NSNumber numberWithBool:YES];
|
[MPiOSConfig get].helpHidden = [NSNumber numberWithBool:YES];
|
||||||
} else {
|
} else {
|
||||||
self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, 175);
|
self.contentContainer.frame = CGRectSetHeight(self.contentContainer.frame, 175);
|
||||||
self.helpContainer.frame = CGRectSetY(self.helpContainer.frame, 216);
|
self.helpContainer.frame = CGRectSetY(self.helpContainer.frame, 216);
|
||||||
[MPiOSConfig get].helpHidden = [NSNumber numberWithBool:NO];
|
[MPiOSConfig get].helpHidden = [NSNumber numberWithBool:NO];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
@ -223,9 +221,9 @@
|
|||||||
- (void)webViewDidFinishLoad:(UIWebView *)webView {
|
- (void)webViewDidFinishLoad:(UIWebView *)webView {
|
||||||
|
|
||||||
NSString *error = [self.helpView stringByEvaluatingJavaScriptFromString:
|
NSString *error = [self.helpView stringByEvaluatingJavaScriptFromString:
|
||||||
PearlString(@"setClass('%@');", ClassNameFromMPElementType(self.activeElement.type))];
|
PearlString(@"setClass('%@');", ClassNameFromMPElementType(self.activeElement.type))];
|
||||||
if (error.length)
|
if (error.length)
|
||||||
err(@"helpView.setClass: %@", error);
|
err(@"helpView.setClass: %@", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)showContentTip:(NSString *)message withIcon:(UIImageView *)icon {
|
- (void)showContentTip:(NSString *)message withIcon:(UIImageView *)icon {
|
||||||
@ -235,21 +233,21 @@
|
|||||||
self.contentTipCleanup(NO);
|
self.contentTipCleanup(NO);
|
||||||
|
|
||||||
self.contentTipBody.text = message;
|
self.contentTipBody.text = message;
|
||||||
self.contentTipCleanup = ^(BOOL finished) {
|
self.contentTipCleanup = ^(BOOL finished) {
|
||||||
icon.hidden = YES;
|
icon.hidden = YES;
|
||||||
self.contentTipCleanup = nil;
|
self.contentTipCleanup = nil;
|
||||||
};
|
};
|
||||||
|
|
||||||
icon.hidden = NO;
|
icon.hidden = NO;
|
||||||
[UIView animateWithDuration:0.3f animations:^{
|
[UIView animateWithDuration:0.3f animations:^{
|
||||||
self.contentTipContainer.alpha = 1;
|
self.contentTipContainer.alpha = 1;
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC);
|
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC);
|
||||||
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
|
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
|
||||||
[UIView animateWithDuration:0.2f animations:^{
|
[UIView animateWithDuration:0.2f animations:^{
|
||||||
self.contentTipContainer.alpha = 0;
|
self.contentTipContainer.alpha = 0;
|
||||||
} completion:self.contentTipCleanup];
|
} completion:self.contentTipCleanup];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
@ -290,16 +288,16 @@
|
|||||||
- (IBAction)incrementPasswordCounter {
|
- (IBAction)incrementPasswordCounter {
|
||||||
|
|
||||||
if (![self.activeElement isKindOfClass:[MPElementGeneratedEntity class]])
|
if (![self.activeElement isKindOfClass:[MPElementGeneratedEntity class]])
|
||||||
// Not of a type that supports a password counter.
|
// Not of a type that supports a password counter.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[self changeElementWithWarning:
|
[self changeElementWithWarning:
|
||||||
@"You are incrementing the site's password counter.\n\n"
|
@"You are incrementing the site's password counter.\n\n"
|
||||||
@"If you continue, a new password will be generated for this site. "
|
@"If you continue, a new password will be generated for this site. "
|
||||||
@"You will then need to update your account's old password to this newly generated password.\n\n"
|
@"You will then need to update your account's old password to this newly generated password.\n\n"
|
||||||
@"You can reset the counter by holding down on this button."
|
@"You can reset the counter by holding down on this button."
|
||||||
do:^{
|
do:^{
|
||||||
++((MPElementGeneratedEntity *) self.activeElement).counter;
|
++((MPElementGeneratedEntity *)self.activeElement).counter;
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[TestFlight passCheckpoint:MPTestFlightCheckpointIncrementPasswordCounter];
|
[TestFlight passCheckpoint:MPTestFlightCheckpointIncrementPasswordCounter];
|
||||||
@ -308,21 +306,21 @@
|
|||||||
- (IBAction)resetPasswordCounter:(UILongPressGestureRecognizer *)sender {
|
- (IBAction)resetPasswordCounter:(UILongPressGestureRecognizer *)sender {
|
||||||
|
|
||||||
if (sender.state != UIGestureRecognizerStateBegan)
|
if (sender.state != UIGestureRecognizerStateBegan)
|
||||||
// Only fire when the gesture was first detected.
|
// Only fire when the gesture was first detected.
|
||||||
return;
|
return;
|
||||||
if (![self.activeElement isKindOfClass:[MPElementGeneratedEntity class]])
|
if (![self.activeElement isKindOfClass:[MPElementGeneratedEntity class]])
|
||||||
// Not of a type that supports a password counter.
|
// Not of a type that supports a password counter.
|
||||||
return;
|
return;
|
||||||
if (((MPElementGeneratedEntity *)self.activeElement).counter == 1)
|
if (((MPElementGeneratedEntity *)self.activeElement).counter == 1)
|
||||||
// Counter has initial value, no point resetting.
|
// Counter has initial value, no point resetting.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[self changeElementWithWarning:
|
[self changeElementWithWarning:
|
||||||
@"You are resetting the site's password counter.\n\n"
|
@"You are resetting the site's password counter.\n\n"
|
||||||
@"If you continue, the site's password will change back to its original value. "
|
@"If you continue, the site's password will change back to its original value. "
|
||||||
@"You will then need to update your account's password back to this original value."
|
@"You will then need to update your account's password back to this original value."
|
||||||
do:^{
|
do:^{
|
||||||
((MPElementGeneratedEntity *) self.activeElement).counter = 1;
|
((MPElementGeneratedEntity *)self.activeElement).counter = 1;
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[TestFlight passCheckpoint:MPTestFlightCheckpointResetPasswordCounter];
|
[TestFlight passCheckpoint:MPTestFlightCheckpointResetPasswordCounter];
|
||||||
@ -331,13 +329,12 @@
|
|||||||
- (void)changeElementWithWarning:(NSString *)warning do:(void (^)(void))task; {
|
- (void)changeElementWithWarning:(NSString *)warning do:(void (^)(void))task; {
|
||||||
|
|
||||||
[PearlAlert showAlertWithTitle:@"Password Change" message:warning viewStyle:UIAlertViewStyleDefault
|
[PearlAlert showAlertWithTitle:@"Password Change" message:warning viewStyle:UIAlertViewStyleDefault
|
||||||
initAlert:nil
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
if (buttonIndex == [alert cancelButtonIndex])
|
||||||
if (buttonIndex == [alert cancelButtonIndex])
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
[self changeElementWithoutWarningDo:task];
|
[self changeElementWithoutWarningDo:task];
|
||||||
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonContinue, nil];
|
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonContinue, nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)changeElementWithoutWarningDo:(void (^)(void))task; {
|
- (void)changeElementWithoutWarningDo:(void (^)(void))task; {
|
||||||
@ -353,10 +350,10 @@
|
|||||||
if ([oldPassword length] && ![oldPassword isEqualToString:newPassword])
|
if ([oldPassword length] && ![oldPassword isEqualToString:newPassword])
|
||||||
[self showAlertWithTitle:@"Password Changed!"
|
[self showAlertWithTitle:@"Password Changed!"
|
||||||
message:PearlString(@"The password for %@ has changed.\n\n"
|
message:PearlString(@"The password for %@ has changed.\n\n"
|
||||||
@"IMPORTANT:\n"
|
@"IMPORTANT:\n"
|
||||||
@"Don't forget to update the site with your new password! "
|
@"Don't forget to update the site with your new password! "
|
||||||
@"Your old password was:\n"
|
@"Your old password was:\n"
|
||||||
@"%@", self.activeElement.name, oldPassword)];
|
@"%@", self.activeElement.name, oldPassword)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -374,7 +371,7 @@
|
|||||||
|
|
||||||
[UIView animateWithDuration:0.3f animations:^{
|
[UIView animateWithDuration:0.3f animations:^{
|
||||||
self.alertContainer.alpha = 0;
|
self.alertContainer.alpha = 0;
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
if (finished)
|
if (finished)
|
||||||
self.alertBody.text = nil;
|
self.alertBody.text = nil;
|
||||||
}];
|
}];
|
||||||
@ -430,7 +427,7 @@
|
|||||||
|
|
||||||
[TestFlight passCheckpoint:MPTestFlightCheckpointAction];
|
[TestFlight passCheckpoint:MPTestFlightCheckpointAction];
|
||||||
}
|
}
|
||||||
cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil otherTitles:
|
cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil otherTitles:
|
||||||
[self isHelpVisible]? @"Hide Help": @"Show Help", @"FAQ", @"Tutorial", @"Preferences", @"Feedback", @"Sign Out", nil];
|
[self isHelpVisible]? @"Hide Help": @"Show Help", @"FAQ", @"Tutorial", @"Preferences", @"Feedback", @"Sign Out", nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,19 +439,20 @@
|
|||||||
- (void)didSelectType:(MPElementType)type {
|
- (void)didSelectType:(MPElementType)type {
|
||||||
|
|
||||||
[self changeElementWithWarning:
|
[self changeElementWithWarning:
|
||||||
@"You are about to change the type of this password.\n\n"
|
@"You are about to change the type of this password.\n\n"
|
||||||
@"If you continue, the password for this site will change. "
|
@"If you continue, the password for this site will change. "
|
||||||
@"You will need to update your account's old password to the new one."
|
@"You will need to update your account's old password to the new one."
|
||||||
do:^{
|
do:^{
|
||||||
// Update password type.
|
// Update password type.
|
||||||
if (ClassFromMPElementType(type) != ClassFromMPElementType(self.activeElement.type))
|
if (ClassFromMPElementType(type) != ClassFromMPElementType(self.activeElement.type))
|
||||||
// Type requires a different class of element. Recreate the element.
|
// Type requires a different class of element. Recreate the element.
|
||||||
[[MPAppDelegate managedObjectContext] performBlockAndWait:^{
|
[[MPAppDelegate managedObjectContext] performBlockAndWait:^{
|
||||||
MPElementEntity *newElement = [NSEntityDescription insertNewObjectForEntityForName:ClassNameFromMPElementType(type)
|
MPElementEntity *newElement = [NSEntityDescription insertNewObjectForEntityForName:ClassNameFromMPElementType(
|
||||||
|
type)
|
||||||
inManagedObjectContext:[MPAppDelegate managedObjectContext]];
|
inManagedObjectContext:[MPAppDelegate managedObjectContext]];
|
||||||
newElement.name = self.activeElement.name;
|
newElement.name = self.activeElement.name;
|
||||||
newElement.user = self.activeElement.user;
|
newElement.user = self.activeElement.user;
|
||||||
newElement.uses = self.activeElement.uses;
|
newElement.uses = self.activeElement.uses;
|
||||||
newElement.lastUsed = self.activeElement.lastUsed;
|
newElement.lastUsed = self.activeElement.lastUsed;
|
||||||
|
|
||||||
[[MPAppDelegate managedObjectContext] deleteObject:self.activeElement];
|
[[MPAppDelegate managedObjectContext] deleteObject:self.activeElement];
|
||||||
@ -463,7 +461,8 @@
|
|||||||
|
|
||||||
self.activeElement.type = type;
|
self.activeElement.type = type;
|
||||||
|
|
||||||
[TestFlight passCheckpoint:[NSString stringWithFormat:MPTestFlightCheckpointSelectType, NSStringFromMPElementType(type)]];
|
[TestFlight passCheckpoint:[NSString stringWithFormat:MPTestFlightCheckpointSelectType, NSStringFromMPElementType(
|
||||||
|
type)]];
|
||||||
|
|
||||||
if (type & MPElementTypeClassStored && ![[self.activeElement.content description] length])
|
if (type & MPElementTypeClassStored && ![[self.activeElement.content description] length])
|
||||||
[self showContentTip:@"Tap to set a password." withIcon:self.contentTipEditIcon];
|
[self showContentTip:@"Tap to set a password." withIcon:self.contentTipEditIcon];
|
||||||
@ -478,17 +477,17 @@
|
|||||||
self.activeElement = element;
|
self.activeElement = element;
|
||||||
if ([self.activeElement use] == 1)
|
if ([self.activeElement use] == 1)
|
||||||
[self showAlertWithTitle:@"New Site" message:
|
[self showAlertWithTitle:@"New Site" message:
|
||||||
PearlString(@"You've just created a password for %@.\n\n"
|
PearlString(@"You've just created a password for %@.\n\n"
|
||||||
@"IMPORTANT:\n"
|
@"IMPORTANT:\n"
|
||||||
@"Go to %@ and set or change the password for your account to the password above.\n"
|
@"Go to %@ and set or change the password for your account to the password above.\n"
|
||||||
@"Do this right away: if you forget, you may have trouble remembering which password to use to log into the site later on.",
|
@"Do this right away: if you forget, you may have trouble remembering which password to use to log into the site later on.",
|
||||||
self.activeElement.name, self.activeElement.name)];
|
self.activeElement.name, self.activeElement.name)];
|
||||||
[[MPAppDelegate get] saveContext];
|
[[MPAppDelegate get] saveContext];
|
||||||
|
|
||||||
if ([[MPiOSConfig get].firstRun boolValue])
|
if ([[MPiOSConfig get].firstRun boolValue])
|
||||||
[UIView animateWithDuration:0.5f animations:^{
|
[UIView animateWithDuration:0.5f animations:^{
|
||||||
self.typeTipContainer.alpha = 1;
|
self.typeTipContainer.alpha = 1;
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
[UIView animateWithDuration:0.2f animations:^{
|
[UIView animateWithDuration:0.2f animations:^{
|
||||||
@ -521,15 +520,15 @@
|
|||||||
if (textField == self.contentField) {
|
if (textField == self.contentField) {
|
||||||
self.contentField.enabled = NO;
|
self.contentField.enabled = NO;
|
||||||
if (![self.activeElement isKindOfClass:[MPElementStoredEntity class]])
|
if (![self.activeElement isKindOfClass:[MPElementStoredEntity class]])
|
||||||
// Not of a type whose content can be edited.
|
// Not of a type whose content can be edited.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ([((MPElementStoredEntity *) self.activeElement).content isEqual:self.contentField.text])
|
if ([((MPElementStoredEntity *)self.activeElement).content isEqual:self.contentField.text])
|
||||||
// Content hasn't changed.
|
// Content hasn't changed.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[self changeElementWithoutWarningDo:^{
|
[self changeElementWithoutWarningDo:^{
|
||||||
((MPElementStoredEntity *) self.activeElement).content = self.contentField.text;
|
((MPElementStoredEntity *)self.activeElement).content = self.contentField.text;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import "IASKAppSettingsViewController.h"
|
#import "IASKAppSettingsViewController.h"
|
||||||
|
|
||||||
@interface MPPreferencesViewController : UITableViewController <IASKSettingsDelegate>
|
@interface MPPreferencesViewController : UITableViewController<IASKSettingsDelegate>
|
||||||
|
|
||||||
@property (weak, nonatomic) IBOutlet UIScrollView *avatarsView;
|
@property (weak, nonatomic) IBOutlet UIScrollView *avatarsView;
|
||||||
@property (weak, nonatomic) IBOutlet UIButton *avatarTemplate;
|
@property (weak, nonatomic) IBOutlet UIButton *avatarTemplate;
|
||||||
@property (weak, nonatomic) IBOutlet UISwitch *savePasswordSwitch;
|
@property (weak, nonatomic) IBOutlet UISwitch *savePasswordSwitch;
|
||||||
@property (weak, nonatomic) IBOutlet UITableViewCell *exportCell;
|
@property (weak, nonatomic) IBOutlet UITableViewCell *exportCell;
|
||||||
@property (weak, nonatomic) IBOutlet UITableViewCell *changeMPCell;
|
@property (weak, nonatomic) IBOutlet UITableViewCell *changeMPCell;
|
||||||
|
|
||||||
|
@ -30,19 +30,19 @@
|
|||||||
for (int a = 0; a < MPAvatarCount; ++a) {
|
for (int a = 0; a < MPAvatarCount; ++a) {
|
||||||
UIButton *avatar = [self.avatarTemplate clone];
|
UIButton *avatar = [self.avatarTemplate clone];
|
||||||
avatar.togglesSelectionInSuperview = YES;
|
avatar.togglesSelectionInSuperview = YES;
|
||||||
avatar.tag = a;
|
avatar.tag = a;
|
||||||
avatar.hidden = NO;
|
avatar.hidden = NO;
|
||||||
avatar.center = CGPointMake(
|
avatar.center = CGPointMake(
|
||||||
self.avatarTemplate.center.x * (a + 1) + self.avatarTemplate.bounds.size.width / 2 * a,
|
self.avatarTemplate.center.x * (a + 1) + self.avatarTemplate.bounds.size.width / 2 * a,
|
||||||
self.avatarTemplate.center.y);
|
self.avatarTemplate.center.y);
|
||||||
[avatar setBackgroundImage:[UIImage imageNamed:PearlString(@"avatar-%d", a)]
|
[avatar setBackgroundImage:[UIImage imageNamed:PearlString(@"avatar-%d", a)]
|
||||||
forState:UIControlStateNormal];
|
forState:UIControlStateNormal];
|
||||||
|
|
||||||
avatar.layer.cornerRadius = avatar.bounds.size.height / 2;
|
avatar.layer.cornerRadius = avatar.bounds.size.height / 2;
|
||||||
avatar.layer.shadowColor = [UIColor blackColor].CGColor;
|
avatar.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||||
avatar.layer.shadowOpacity = 1;
|
avatar.layer.shadowOpacity = 1;
|
||||||
avatar.layer.shadowRadius = 5;
|
avatar.layer.shadowRadius = 5;
|
||||||
avatar.backgroundColor = [UIColor clearColor];
|
avatar.backgroundColor = [UIColor clearColor];
|
||||||
|
|
||||||
[avatar onHighlightOrSelect:^(BOOL highlighted, BOOL selected) {
|
[avatar onHighlightOrSelect:^(BOOL highlighted, BOOL selected) {
|
||||||
if (highlighted || selected)
|
if (highlighted || selected)
|
||||||
@ -54,7 +54,7 @@
|
|||||||
if (selected)
|
if (selected)
|
||||||
[MPAppDelegate get].activeUser.avatar = (unsigned)avatar.tag;
|
[MPAppDelegate get].activeUser.avatar = (unsigned)avatar.tag;
|
||||||
} options:0];
|
} options:0];
|
||||||
avatar.selected = (a == [MPAppDelegate get].activeUser.avatar);
|
avatar.selected = (a == [MPAppDelegate get].activeUser.avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
@ -64,7 +64,7 @@
|
|||||||
|
|
||||||
[self.avatarsView autoSizeContent];
|
[self.avatarsView autoSizeContent];
|
||||||
[self.avatarsView enumerateSubviews:^(UIView *subview, BOOL *stop, BOOL *recurse) {
|
[self.avatarsView enumerateSubviews:^(UIView *subview, BOOL *stop, BOOL *recurse) {
|
||||||
if (subview.tag && ((UIControl *) subview).selected) {
|
if (subview.tag && ((UIControl *)subview).selected) {
|
||||||
[self.avatarsView setContentOffset:CGPointMake(subview.center.x - self.avatarsView.bounds.size.width / 2, 0) animated:animated];
|
[self.avatarsView setContentOffset:CGPointMake(subview.center.x - self.avatarsView.bounds.size.width / 2, 0) animated:animated];
|
||||||
}
|
}
|
||||||
} recurse:NO];
|
} recurse:NO];
|
||||||
@ -80,6 +80,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidUnload {
|
- (void)viewDidUnload {
|
||||||
|
|
||||||
[self setAvatarsView:nil];
|
[self setAvatarsView:nil];
|
||||||
[self setAvatarTemplate:nil];
|
[self setAvatarTemplate:nil];
|
||||||
[self setAvatarsView:nil];
|
[self setAvatarsView:nil];
|
||||||
@ -97,8 +98,9 @@
|
|||||||
if (cell == self.exportCell)
|
if (cell == self.exportCell)
|
||||||
[[MPAppDelegate get] export];
|
[[MPAppDelegate get] export];
|
||||||
|
|
||||||
else if (cell == self.changeMPCell)
|
else
|
||||||
[[MPAppDelegate get] changeMP];
|
if (cell == self.changeMPCell)
|
||||||
|
[[MPAppDelegate get] changeMP];
|
||||||
|
|
||||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,21 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "MPElementEntity.h"
|
#import "MPElementEntity.h"
|
||||||
|
|
||||||
@protocol MPSearchResultsDelegate <NSObject>
|
@protocol MPSearchResultsDelegate<NSObject>
|
||||||
|
|
||||||
- (void)didSelectElement:(MPElementEntity *)element;
|
- (void)didSelectElement:(MPElementEntity *)element;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MPSearchDelegate : NSObject <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UISearchDisplayDelegate, NSFetchedResultsControllerDelegate>
|
@interface MPSearchDelegate : NSObject<UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UISearchDisplayDelegate, NSFetchedResultsControllerDelegate>
|
||||||
|
|
||||||
@property (strong, nonatomic) NSDateFormatter *dateFormatter;
|
@property (strong, nonatomic) NSDateFormatter *dateFormatter;
|
||||||
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
|
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
|
||||||
@property (strong, nonatomic) NSString *query;
|
@property (strong, nonatomic) NSString *query;
|
||||||
@property (strong, nonatomic) UILabel *tipView;
|
@property (strong, nonatomic) UILabel *tipView;
|
||||||
|
|
||||||
@property (weak, nonatomic) IBOutlet id<MPSearchResultsDelegate> delegate;
|
@property (weak, nonatomic) IBOutlet id<MPSearchResultsDelegate> delegate;
|
||||||
@property (weak, nonatomic) IBOutlet UISearchDisplayController *searchDisplayController;
|
@property (weak, nonatomic) IBOutlet UISearchDisplayController *searchDisplayController;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *searchTipContainer;
|
@property (weak, nonatomic) IBOutlet UIView *searchTipContainer;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -30,36 +30,37 @@
|
|||||||
if (!([super init]))
|
if (!([super init]))
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
self.dateFormatter = [NSDateFormatter new];
|
self.dateFormatter = [NSDateFormatter new];
|
||||||
self.dateFormatter.dateStyle = NSDateFormatterShortStyle;
|
self.dateFormatter.dateStyle = NSDateFormatterShortStyle;
|
||||||
self.query = @"";
|
self.query = @"";
|
||||||
|
|
||||||
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPElementEntity class])];
|
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPElementEntity class])];
|
||||||
fetchRequest.sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"uses_" ascending:NO]];
|
fetchRequest.sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"uses_" ascending:NO]];
|
||||||
self.fetchedResultsController = [PearlLazy lazyObjectLoadedFrom:^id{
|
self.fetchedResultsController = [PearlLazy lazyObjectLoadedFrom:^id {
|
||||||
NSFetchedResultsController *controller = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
|
NSFetchedResultsController *controller = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
|
||||||
managedObjectContext:[MPAppDelegate managedObjectContext]
|
managedObjectContext:[MPAppDelegate managedObjectContext]
|
||||||
sectionNameKeyPath:nil cacheName:nil];
|
sectionNameKeyPath:nil cacheName:nil];
|
||||||
controller.delegate = self;
|
controller.delegate = self;
|
||||||
|
|
||||||
return controller;
|
return controller;
|
||||||
}];
|
}];
|
||||||
|
|
||||||
self.tipView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 170)];
|
self.tipView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 170)];
|
||||||
self.tipView.textAlignment = UITextAlignmentCenter;
|
self.tipView.textAlignment = UITextAlignmentCenter;
|
||||||
self.tipView.backgroundColor = [UIColor clearColor];
|
self.tipView.backgroundColor = [UIColor clearColor];
|
||||||
self.tipView.textColor = [UIColor lightTextColor];
|
self.tipView.textColor = [UIColor lightTextColor];
|
||||||
self.tipView.shadowColor = [UIColor blackColor];
|
self.tipView.shadowColor = [UIColor blackColor];
|
||||||
self.tipView.shadowOffset = CGSizeMake(0, -1);
|
self.tipView.shadowOffset = CGSizeMake(0, -1);
|
||||||
self.tipView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
|
self.tipView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
|
||||||
self.tipView.numberOfLines = 0;
|
| UIViewAutoresizingFlexibleBottomMargin;
|
||||||
self.tipView.font = [UIFont systemFontOfSize:14];
|
self.tipView.numberOfLines = 0;
|
||||||
|
self.tipView.font = [UIFont systemFontOfSize:14];
|
||||||
self.tipView.text =
|
self.tipView.text =
|
||||||
@"Tip:\n"
|
@"Tip:\n"
|
||||||
@"Name your sites by their domain name:\n"
|
@"Name your sites by their domain name:\n"
|
||||||
@"apple.com, twitter.com\n\n"
|
@"apple.com, twitter.com\n\n"
|
||||||
@"For email accounts, use the address:\n"
|
@"For email accounts, use the address:\n"
|
||||||
@"john@apple.com, john@gmail.com";
|
@"john@apple.com, john@gmail.com";
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@
|
|||||||
if (searchBar.searchResultsButtonSelected && !searchText.length)
|
if (searchBar.searchResultsButtonSelected && !searchText.length)
|
||||||
searchBar.text = @" ";
|
searchBar.text = @" ";
|
||||||
|
|
||||||
self.query = [searchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
self.query = [searchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||||
if (!self.query)
|
if (!self.query)
|
||||||
self.query = @"";
|
self.query = @"";
|
||||||
}
|
}
|
||||||
@ -107,20 +108,20 @@
|
|||||||
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller {
|
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller {
|
||||||
|
|
||||||
controller.searchBar.text = controller.searchBar.searchResultsButtonSelected? @" ": @"";
|
controller.searchBar.text = controller.searchBar.searchResultsButtonSelected? @" ": @"";
|
||||||
self.query = @"";
|
self.query = @"";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller {
|
- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller {
|
||||||
|
|
||||||
controller.searchBar.prompt = nil;
|
controller.searchBar.prompt = nil;
|
||||||
controller.searchBar.searchResultsButtonSelected = NO;
|
controller.searchBar.searchResultsButtonSelected = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView {
|
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView {
|
||||||
|
|
||||||
tableView.backgroundColor = [UIColor blackColor];
|
tableView.backgroundColor = [UIColor blackColor];
|
||||||
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||||
tableView.rowHeight = 48.0f;
|
tableView.rowHeight = 48.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
|
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
|
||||||
@ -131,11 +132,11 @@
|
|||||||
assert(self.query);
|
assert(self.query);
|
||||||
|
|
||||||
self.fetchedResultsController.fetchRequest.predicate = [NSPredicate predicateWithFormat:@"(%@ == '' OR name BEGINSWITH[cd] %@) AND user == %@",
|
self.fetchedResultsController.fetchRequest.predicate = [NSPredicate predicateWithFormat:@"(%@ == '' OR name BEGINSWITH[cd] %@) AND user == %@",
|
||||||
self.query, self.query, NilToNSNull([MPAppDelegate get].activeUser)];
|
self.query, self.query, NilToNSNull([MPAppDelegate get].activeUser)];
|
||||||
|
|
||||||
NSError *error;
|
NSError *error;
|
||||||
if (![self.fetchedResultsController performFetch:&error])
|
if (![self.fetchedResultsController performFetch:&error])
|
||||||
err(@"Couldn't fetch elements: %@", error);
|
err(@"Couldn't fetch elements: %@", error);
|
||||||
|
|
||||||
NSArray *subviews = self.searchDisplayController.searchBar.superview.subviews;
|
NSArray *subviews = self.searchDisplayController.searchBar.superview.subviews;
|
||||||
NSUInteger overlayIndex = [subviews indexOfObject:self.searchDisplayController.searchBar] + 1;
|
NSUInteger overlayIndex = [subviews indexOfObject:self.searchDisplayController.searchBar] + 1;
|
||||||
@ -225,10 +226,10 @@
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
if (hasExactQueryMatch)
|
if (hasExactQueryMatch)
|
||||||
*stop = YES;
|
*stop = YES;
|
||||||
}];
|
}];
|
||||||
if (!hasExactQueryMatch)
|
if (!hasExactQueryMatch)
|
||||||
// Add a section for "new site".
|
// Add a section for "new site".
|
||||||
++sectionCount;
|
++sectionCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,20 +252,20 @@
|
|||||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MPElementSearch"];
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MPElementSearch"];
|
||||||
|
|
||||||
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ui_list_middle"]];
|
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ui_list_middle"]];
|
||||||
backgroundImageView.frame = CGRectMake(-5, 0, 330, 34);
|
backgroundImageView.frame = CGRectMake(-5, 0, 330, 34);
|
||||||
backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||||
backgroundImageView.contentStretch = CGRectMake(0.2f, 0.2f, 0.6f, 0.6f);
|
backgroundImageView.contentStretch = CGRectMake(0.2f, 0.2f, 0.6f, 0.6f);
|
||||||
UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 34)];
|
UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 34)];
|
||||||
[backgroundView addSubview:backgroundImageView];
|
[backgroundView addSubview:backgroundImageView];
|
||||||
backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||||
|
|
||||||
cell.backgroundView = backgroundView;
|
cell.backgroundView = backgroundView;
|
||||||
cell.textLabel.backgroundColor = [UIColor clearColor];
|
cell.textLabel.backgroundColor = [UIColor clearColor];
|
||||||
cell.textLabel.textColor = [UIColor whiteColor];
|
cell.textLabel.textColor = [UIColor whiteColor];
|
||||||
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
|
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
|
||||||
cell.detailTextLabel.textColor = [UIColor lightGrayColor];
|
cell.detailTextLabel.textColor = [UIColor lightGrayColor];
|
||||||
cell.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
cell.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||||
cell.clipsToBounds = YES;
|
cell.clipsToBounds = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self configureCell:cell inTableView:tableView atIndexPath:indexPath];
|
[self configureCell:cell inTableView:tableView atIndexPath:indexPath];
|
||||||
@ -277,12 +278,12 @@
|
|||||||
if (indexPath.section < (NSInteger)[[self.fetchedResultsController sections] count]) {
|
if (indexPath.section < (NSInteger)[[self.fetchedResultsController sections] count]) {
|
||||||
MPElementEntity *element = [self.fetchedResultsController objectAtIndexPath:indexPath];
|
MPElementEntity *element = [self.fetchedResultsController objectAtIndexPath:indexPath];
|
||||||
|
|
||||||
cell.textLabel.text = element.name;
|
cell.textLabel.text = element.name;
|
||||||
cell.detailTextLabel.text = [NSString stringWithFormat:@"Used %d times, last on %@",
|
cell.detailTextLabel.text = [NSString stringWithFormat:@"Used %d times, last on %@",
|
||||||
element.uses, [self.dateFormatter stringFromDate:element.lastUsed]];
|
element.uses, [self.dateFormatter stringFromDate:element.lastUsed]];
|
||||||
} else {
|
} else {
|
||||||
// "New" section
|
// "New" section
|
||||||
cell.textLabel.text = self.query;
|
cell.textLabel.text = self.query;
|
||||||
cell.detailTextLabel.text = @"Create a new site.";
|
cell.detailTextLabel.text = @"Create a new site.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,27 +299,27 @@
|
|||||||
[PearlAlert showAlertWithTitle:@"New Site"
|
[PearlAlert showAlertWithTitle:@"New Site"
|
||||||
message:PearlString(@"Do you want to create a new site named:\n%@", siteName)
|
message:PearlString(@"Do you want to create a new site named:\n%@", siteName)
|
||||||
viewStyle:UIAlertViewStyleDefault
|
viewStyle:UIAlertViewStyleDefault
|
||||||
initAlert:nil
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
||||||
|
|
||||||
if (buttonIndex == [alert cancelButtonIndex])
|
if (buttonIndex == [alert cancelButtonIndex])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[self.fetchedResultsController.managedObjectContext performBlock:^{
|
[self.fetchedResultsController.managedObjectContext performBlock:^{
|
||||||
MPElementGeneratedEntity *element = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([MPElementGeneratedEntity class])
|
MPElementGeneratedEntity *element = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass(
|
||||||
inManagedObjectContext:self.fetchedResultsController.managedObjectContext];
|
[MPElementGeneratedEntity class])
|
||||||
assert([element isKindOfClass:ClassFromMPElementType(element.type)]);
|
inManagedObjectContext:self.fetchedResultsController.managedObjectContext];
|
||||||
assert([MPAppDelegate get].activeUser.keyID);
|
assert([element isKindOfClass:ClassFromMPElementType(element.type)]);
|
||||||
|
assert([MPAppDelegate get].activeUser.keyID);
|
||||||
|
|
||||||
element.name = siteName;
|
element.name = siteName;
|
||||||
element.user = [MPAppDelegate get].activeUser;
|
element.user = [MPAppDelegate get].activeUser;
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self.delegate didSelectElement:element];
|
[self.delegate didSelectElement:element];
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonYes, nil];
|
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonYes, nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +341,8 @@
|
|||||||
return [self.fetchedResultsController sectionForSectionIndexTitle:title atIndex:index];
|
return [self.fetchedResultsController sectionForSectionIndexTitle:title atIndex:index];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
|
||||||
|
forRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
|
|
||||||
if (indexPath.section < (NSInteger)[[self.fetchedResultsController sections] count]) {
|
if (indexPath.section < (NSInteger)[[self.fetchedResultsController sections] count]) {
|
||||||
if (editingStyle == UITableViewCellEditingStyleDelete)
|
if (editingStyle == UITableViewCellEditingStyleDelete)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@protocol MPTypeDelegate <NSObject>
|
@protocol MPTypeDelegate<NSObject>
|
||||||
|
|
||||||
- (void)didSelectType:(MPElementType)type;
|
- (void)didSelectType:(MPElementType)type;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
if ([[MPiOSConfig get].firstRun boolValue])
|
if ([[MPiOSConfig get].firstRun boolValue])
|
||||||
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
|
[UIView animateWithDuration:animated? 0.3f: 0 animations:^{
|
||||||
self.recommendedTipContainer.alpha = 1;
|
self.recommendedTipContainer.alpha = 1;
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
[UIView animateWithDuration:0.2f animations:^{
|
[UIView animateWithDuration:0.2f animations:^{
|
||||||
@ -67,7 +67,7 @@
|
|||||||
UIImageView *imageView = ((UIImageView *)subview);
|
UIImageView *imageView = ((UIImageView *)subview);
|
||||||
if (!imageView.highlightedImage)
|
if (!imageView.highlightedImage)
|
||||||
imageView.highlightedImage = [imageView.image highlightedImage];
|
imageView.highlightedImage = [imageView.image highlightedImage];
|
||||||
imageView.highlighted = YES;
|
imageView.highlighted = YES;
|
||||||
*stop = YES;
|
*stop = YES;
|
||||||
}
|
}
|
||||||
} recurse:NO];
|
} recurse:NO];
|
||||||
@ -130,6 +130,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidUnload {
|
- (void)viewDidUnload {
|
||||||
|
|
||||||
[self setRecommendedTipContainer:nil];
|
[self setRecommendedTipContainer:nil];
|
||||||
[super viewDidUnload];
|
[super viewDidUnload];
|
||||||
}
|
}
|
||||||
|
@ -8,20 +8,20 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@interface MPUnlockViewController : UIViewController <UITextFieldDelegate, UIScrollViewDelegate>
|
@interface MPUnlockViewController : UIViewController<UITextFieldDelegate, UIScrollViewDelegate>
|
||||||
|
|
||||||
@property (weak, nonatomic) IBOutlet UIImageView *spinner;
|
@property (weak, nonatomic) IBOutlet UIImageView *spinner;
|
||||||
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
|
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *passwordView;
|
@property (weak, nonatomic) IBOutlet UIView *passwordView;
|
||||||
@property (weak, nonatomic) IBOutlet UIScrollView *avatarsView;
|
@property (weak, nonatomic) IBOutlet UIScrollView *avatarsView;
|
||||||
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
|
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
|
||||||
@property (weak, nonatomic) IBOutlet UILabel *oldNameLabel;
|
@property (weak, nonatomic) IBOutlet UILabel *oldNameLabel;
|
||||||
@property (weak, nonatomic) IBOutlet UIButton *avatarTemplate;
|
@property (weak, nonatomic) IBOutlet UIButton *avatarTemplate;
|
||||||
@property (weak, nonatomic) IBOutlet UILabel *deleteTip;
|
@property (weak, nonatomic) IBOutlet UILabel *deleteTip;
|
||||||
@property (weak, nonatomic) IBOutlet UIView *passwordTipView;
|
@property (weak, nonatomic) IBOutlet UIView *passwordTipView;
|
||||||
@property (weak, nonatomic) IBOutlet UILabel *passwordTipLabel;
|
@property (weak, nonatomic) IBOutlet UILabel *passwordTipLabel;
|
||||||
|
|
||||||
@property(nonatomic, strong) UIColor *avatarShadowColor;
|
@property (nonatomic, strong) UIColor *avatarShadowColor;
|
||||||
|
|
||||||
- (IBAction)deleteTargetedUser:(UILongPressGestureRecognizer *)sender;
|
- (IBAction)deleteTargetedUser:(UILongPressGestureRecognizer *)sender;
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
@interface MPUnlockViewController ()
|
@interface MPUnlockViewController ()
|
||||||
|
|
||||||
@property(strong, nonatomic) MPUserEntity *selectedUser;
|
@property (strong, nonatomic) MPUserEntity *selectedUser;
|
||||||
@property(strong, nonatomic) NSMutableDictionary *avatarToUser;
|
@property (strong, nonatomic) NSMutableDictionary *avatarToUser;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -48,13 +48,13 @@
|
|||||||
|
|
||||||
self.avatarToUser = [NSMutableDictionary dictionaryWithCapacity:3];
|
self.avatarToUser = [NSMutableDictionary dictionaryWithCapacity:3];
|
||||||
|
|
||||||
self.passwordField.text = nil;
|
self.passwordField.text = nil;
|
||||||
self.avatarsView.decelerationRate = UIScrollViewDecelerationRateFast;
|
self.avatarsView.decelerationRate = UIScrollViewDecelerationRateFast;
|
||||||
self.avatarsView.clipsToBounds = NO;
|
self.avatarsView.clipsToBounds = NO;
|
||||||
self.nameLabel.layer.cornerRadius = 5;
|
self.nameLabel.layer.cornerRadius = 5;
|
||||||
self.avatarTemplate.hidden = YES;
|
self.avatarTemplate.hidden = YES;
|
||||||
self.spinner.alpha = 0;
|
self.spinner.alpha = 0;
|
||||||
self.passwordTipView.alpha = 0;
|
self.passwordTipView.alpha = 0;
|
||||||
|
|
||||||
[self updateLayoutAnimated:NO allowScroll:YES completion:nil];
|
[self updateLayoutAnimated:NO allowScroll:YES completion:nil];
|
||||||
|
|
||||||
@ -85,14 +85,14 @@
|
|||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated {
|
- (void)viewDidAppear:(BOOL)animated {
|
||||||
|
|
||||||
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:animated ? UIStatusBarAnimationSlide : UIStatusBarAnimationNone];
|
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:animated? UIStatusBarAnimationSlide: UIStatusBarAnimationNone];
|
||||||
|
|
||||||
[super viewDidAppear:animated];
|
[super viewDidAppear:animated];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewWillDisappear:(BOOL)animated {
|
- (void)viewWillDisappear:(BOOL)animated {
|
||||||
|
|
||||||
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:animated ? UIStatusBarAnimationSlide : UIStatusBarAnimationNone];
|
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:animated? UIStatusBarAnimationSlide: UIStatusBarAnimationNone];
|
||||||
|
|
||||||
[super viewWillDisappear:animated];
|
[super viewWillDisappear:animated];
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@
|
|||||||
// Clean up avatars.
|
// Clean up avatars.
|
||||||
for (UIView *subview in [self.avatarsView subviews])
|
for (UIView *subview in [self.avatarsView subviews])
|
||||||
if ([[self.avatarToUser allKeys] containsObject:[NSValue valueWithNonretainedObject:subview]])
|
if ([[self.avatarToUser allKeys] containsObject:[NSValue valueWithNonretainedObject:subview]])
|
||||||
// This subview is a former avatar.
|
// This subview is a former avatar.
|
||||||
[subview removeFromSuperview];
|
[subview removeFromSuperview];
|
||||||
[self.avatarToUser removeAllObjects];
|
[self.avatarToUser removeAllObjects];
|
||||||
|
|
||||||
@ -130,26 +130,27 @@
|
|||||||
avatar.backgroundColor = [UIColor clearColor];
|
avatar.backgroundColor = [UIColor clearColor];
|
||||||
} options:0];
|
} options:0];
|
||||||
[avatar onSelect:^(BOOL selected) {
|
[avatar onSelect:^(BOOL selected) {
|
||||||
self.selectedUser = selected ? user : nil;
|
self.selectedUser = selected? user: nil;
|
||||||
if (user)
|
if (user)
|
||||||
[self didToggleUserSelection];
|
[self didToggleUserSelection];
|
||||||
else if (selected)
|
else
|
||||||
[self didSelectNewUserAvatar:avatar];
|
if (selected)
|
||||||
|
[self didSelectNewUserAvatar:avatar];
|
||||||
} options:0];
|
} options:0];
|
||||||
avatar.togglesSelectionInSuperview = YES;
|
avatar.togglesSelectionInSuperview = YES;
|
||||||
avatar.center = CGPointMake(avatar.center.x + [self.avatarToUser count] * 160, avatar.center.y);
|
avatar.center = CGPointMake(avatar.center.x + [self.avatarToUser count] * 160, avatar.center.y);
|
||||||
avatar.hidden = NO;
|
avatar.hidden = NO;
|
||||||
avatar.layer.cornerRadius = avatar.bounds.size.height / 2;
|
avatar.layer.cornerRadius = avatar.bounds.size.height / 2;
|
||||||
avatar.layer.shadowColor = [UIColor blackColor].CGColor;
|
avatar.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||||
avatar.layer.shadowOpacity = 1;
|
avatar.layer.shadowOpacity = 1;
|
||||||
avatar.layer.shadowRadius = 20;
|
avatar.layer.shadowRadius = 20;
|
||||||
avatar.layer.masksToBounds = NO;
|
avatar.layer.masksToBounds = NO;
|
||||||
avatar.backgroundColor = [UIColor clearColor];
|
avatar.backgroundColor = [UIColor clearColor];
|
||||||
|
|
||||||
dbg(@"User: %@, avatar: %d", user.name, user.avatar);
|
dbg(@"User: %@, avatar: %d", user.name, user.avatar);
|
||||||
avatar.tag = user.avatar;
|
avatar.tag = user.avatar;
|
||||||
[avatar setBackgroundImage:[UIImage imageNamed:PearlString(@"avatar-%u", user.avatar)]
|
[avatar setBackgroundImage:[UIImage imageNamed:PearlString(@"avatar-%u", user.avatar)]
|
||||||
forState:UIControlStateNormal];
|
forState:UIControlStateNormal];
|
||||||
|
|
||||||
[self.avatarToUser setObject:NilToNSNull(user) forKey:[NSValue valueWithNonretainedObject:avatar]];
|
[self.avatarToUser setObject:NilToNSNull(user) forKey:[NSValue valueWithNonretainedObject:avatar]];
|
||||||
|
|
||||||
@ -163,10 +164,11 @@
|
|||||||
|
|
||||||
if (!self.selectedUser)
|
if (!self.selectedUser)
|
||||||
[self.passwordField resignFirstResponder];
|
[self.passwordField resignFirstResponder];
|
||||||
else if ([[MPAppDelegate get] signInAsUser:self.selectedUser usingMasterPassword:nil]) {
|
else
|
||||||
[self dismissModalViewControllerAnimated:YES];
|
if ([[MPAppDelegate get] signInAsUser:self.selectedUser usingMasterPassword:nil]) {
|
||||||
return;
|
[self dismissModalViewControllerAnimated:YES];
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[self updateLayoutAnimated:YES allowScroll:YES completion:^(BOOL finished) {
|
[self updateLayoutAnimated:YES allowScroll:YES completion:^(BOOL finished) {
|
||||||
if (finished)
|
if (finished)
|
||||||
@ -181,9 +183,9 @@
|
|||||||
message:@"Enter your name:" viewStyle:UIAlertViewStylePlainTextInput
|
message:@"Enter your name:" viewStyle:UIAlertViewStylePlainTextInput
|
||||||
initAlert:^(UIAlertView *alert, UITextField *firstField) {
|
initAlert:^(UIAlertView *alert, UITextField *firstField) {
|
||||||
firstField.autocapitalizationType = UITextAutocapitalizationTypeWords;
|
firstField.autocapitalizationType = UITextAutocapitalizationTypeWords;
|
||||||
firstField.autocorrectionType = UITextAutocorrectionTypeYes;
|
firstField.autocorrectionType = UITextAutocorrectionTypeYes;
|
||||||
firstField.spellCheckingType = UITextSpellCheckingTypeYes;
|
firstField.spellCheckingType = UITextSpellCheckingTypeYes;
|
||||||
firstField.keyboardType = UIKeyboardTypeAlphabet;
|
firstField.keyboardType = UIKeyboardTypeAlphabet;
|
||||||
}
|
}
|
||||||
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
newUserAvatar.selected = NO;
|
newUserAvatar.selected = NO;
|
||||||
@ -192,27 +194,27 @@
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
MPUserEntity *newUser = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([MPUserEntity class])
|
MPUserEntity *newUser = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([MPUserEntity class])
|
||||||
inManagedObjectContext:[MPAppDelegate managedObjectContext]];
|
inManagedObjectContext:[MPAppDelegate managedObjectContext]];
|
||||||
newUser.name = [alert textFieldAtIndex:0].text;
|
newUser.name = [alert textFieldAtIndex:0].text;
|
||||||
self.selectedUser = newUser;
|
self.selectedUser = newUser;
|
||||||
|
|
||||||
[self updateUsers];
|
[self updateUsers];
|
||||||
}
|
}
|
||||||
cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonSave, nil];
|
cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonSave, nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateLayoutAnimated:(BOOL)animated allowScroll:(BOOL)allowScroll completion:(void (^)(BOOL finished))completion {
|
- (void)updateLayoutAnimated:(BOOL)animated allowScroll:(BOOL)allowScroll completion:(void (^)(BOOL finished))completion {
|
||||||
|
|
||||||
if (animated) {
|
if (animated) {
|
||||||
self.oldNameLabel.text = self.nameLabel.text;
|
self.oldNameLabel.text = self.nameLabel.text;
|
||||||
self.oldNameLabel.alpha = 1;
|
self.oldNameLabel.alpha = 1;
|
||||||
self.nameLabel.alpha = 0;
|
self.nameLabel.alpha = 0;
|
||||||
|
|
||||||
[UIView animateWithDuration:0.5f animations:^{
|
[UIView animateWithDuration:0.5f animations:^{
|
||||||
[self updateLayoutAnimated:NO allowScroll:allowScroll completion:nil];
|
[self updateLayoutAnimated:NO allowScroll:allowScroll completion:nil];
|
||||||
|
|
||||||
self.oldNameLabel.alpha = 0;
|
self.oldNameLabel.alpha = 0;
|
||||||
self.nameLabel.alpha = 1;
|
self.nameLabel.alpha = 1;
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
if (completion)
|
if (completion)
|
||||||
completion(finished);
|
completion(finished);
|
||||||
@ -221,59 +223,60 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self.selectedUser && !self.passwordView.alpha) {
|
if (self.selectedUser && !self.passwordView.alpha) {
|
||||||
self.passwordView.alpha = 1;
|
self.passwordView.alpha = 1;
|
||||||
self.avatarsView.center = CGPointMake(160, 100);
|
self.avatarsView.center = CGPointMake(160, 100);
|
||||||
self.avatarsView.scrollEnabled = NO;
|
self.avatarsView.scrollEnabled = NO;
|
||||||
self.nameLabel.center = CGPointMake(160, 84);
|
self.nameLabel.center = CGPointMake(160, 84);
|
||||||
self.nameLabel.backgroundColor = [UIColor blackColor];
|
self.nameLabel.backgroundColor = [UIColor blackColor];
|
||||||
self.oldNameLabel.center = self.nameLabel.center;
|
self.oldNameLabel.center = self.nameLabel.center;
|
||||||
self.avatarShadowColor = [UIColor whiteColor];
|
self.avatarShadowColor = [UIColor whiteColor];
|
||||||
self.deleteTip.alpha = 0;
|
self.deleteTip.alpha = 0;
|
||||||
} else if (!self.selectedUser && self.passwordView.alpha == 1) {
|
} else
|
||||||
self.passwordView.alpha = 0;
|
if (!self.selectedUser && self.passwordView.alpha == 1) {
|
||||||
self.avatarsView.center = CGPointMake(160, 240);
|
self.passwordView.alpha = 0;
|
||||||
self.avatarsView.scrollEnabled = YES;
|
self.avatarsView.center = CGPointMake(160, 240);
|
||||||
self.nameLabel.center = CGPointMake(160, 296);
|
self.avatarsView.scrollEnabled = YES;
|
||||||
self.nameLabel.backgroundColor = [UIColor clearColor];
|
self.nameLabel.center = CGPointMake(160, 296);
|
||||||
self.oldNameLabel.center = self.nameLabel.center;
|
self.nameLabel.backgroundColor = [UIColor clearColor];
|
||||||
self.avatarShadowColor = [UIColor lightGrayColor];
|
self.oldNameLabel.center = self.nameLabel.center;
|
||||||
self.deleteTip.alpha = [self.avatarToUser count] > 2? 1: 0;
|
self.avatarShadowColor = [UIColor lightGrayColor];
|
||||||
}
|
self.deleteTip.alpha = [self.avatarToUser count] > 2? 1: 0;
|
||||||
|
}
|
||||||
|
|
||||||
MPUserEntity *targetedUser = self.selectedUser;
|
MPUserEntity *targetedUser = self.selectedUser;
|
||||||
UIButton *selectedAvatar = [self avatarForUser:self.selectedUser];
|
UIButton *selectedAvatar = [self avatarForUser:self.selectedUser];
|
||||||
UIButton *targetedAvatar = selectedAvatar;
|
UIButton *targetedAvatar = selectedAvatar;
|
||||||
if (!targetedAvatar) {
|
if (!targetedAvatar) {
|
||||||
targetedAvatar = [self findTargetedAvatar];
|
targetedAvatar = [self findTargetedAvatar];
|
||||||
targetedUser = [self userForAvatar:targetedAvatar];
|
targetedUser = [self userForAvatar:targetedAvatar];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.avatarsView enumerateSubviews:^(UIView *subview, BOOL *stop, BOOL *recurse) {
|
[self.avatarsView enumerateSubviews:^(UIView *subview, BOOL *stop, BOOL *recurse) {
|
||||||
if (![[self.avatarToUser allKeys] containsObject:[NSValue valueWithNonretainedObject:subview]])
|
if (![[self.avatarToUser allKeys] containsObject:[NSValue valueWithNonretainedObject:subview]])
|
||||||
// This subview is not one of the user avatars.
|
// This subview is not one of the user avatars.
|
||||||
return;
|
return;
|
||||||
UIButton *avatar = (UIButton *)subview;
|
UIButton *avatar = (UIButton *)subview;
|
||||||
|
|
||||||
BOOL isTargeted = avatar == targetedAvatar;
|
BOOL isTargeted = avatar == targetedAvatar;
|
||||||
|
|
||||||
avatar.userInteractionEnabled = isTargeted;
|
avatar.userInteractionEnabled = isTargeted;
|
||||||
avatar.alpha = isTargeted ? 1 : self.selectedUser ? 0.1 : 0.4;
|
avatar.alpha = isTargeted? 1: self.selectedUser? 0.1: 0.4;
|
||||||
|
|
||||||
[self updateAvatarShadowColor:avatar isTargeted:isTargeted];
|
[self updateAvatarShadowColor:avatar isTargeted:isTargeted];
|
||||||
} recurse:NO];
|
} recurse:NO];
|
||||||
|
|
||||||
if (allowScroll) {
|
if (allowScroll) {
|
||||||
CGPoint targetContentOffset = CGPointMake(MAX(0, targetedAvatar.center.x - self.avatarsView.bounds.size.width / 2),
|
CGPoint targetContentOffset = CGPointMake(MAX(0, targetedAvatar.center.x - self.avatarsView.bounds.size.width / 2),
|
||||||
self.avatarsView.contentOffset.y);
|
self.avatarsView.contentOffset.y);
|
||||||
if (!CGPointEqualToPoint(self.avatarsView.contentOffset, targetContentOffset))
|
if (!CGPointEqualToPoint(self.avatarsView.contentOffset, targetContentOffset))
|
||||||
[self.avatarsView setContentOffset:targetContentOffset animated:animated];
|
[self.avatarsView setContentOffset:targetContentOffset animated:animated];
|
||||||
}
|
}
|
||||||
|
|
||||||
self.nameLabel.text = targetedUser ? targetedUser.name : @"New User";
|
self.nameLabel.text = targetedUser? targetedUser.name: @"New User";
|
||||||
self.nameLabel.bounds = CGRectSetHeight(self.nameLabel.bounds,
|
self.nameLabel.bounds = CGRectSetHeight(self.nameLabel.bounds,
|
||||||
[self.nameLabel.text sizeWithFont:self.nameLabel.font
|
[self.nameLabel.text sizeWithFont:self.nameLabel.font
|
||||||
constrainedToSize:CGSizeMake(self.nameLabel.bounds.size.width - 10, 100)
|
constrainedToSize:CGSizeMake(self.nameLabel.bounds.size.width - 10, 100)
|
||||||
lineBreakMode:self.nameLabel.lineBreakMode].height);
|
lineBreakMode:self.nameLabel.lineBreakMode].height);
|
||||||
self.oldNameLabel.bounds = self.nameLabel.bounds;
|
self.oldNameLabel.bounds = self.nameLabel.bounds;
|
||||||
if (completion)
|
if (completion)
|
||||||
completion(YES);
|
completion(YES);
|
||||||
@ -298,11 +301,12 @@
|
|||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (unlocked) {
|
if (unlocked) {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (long) (NSEC_PER_SEC * 0.5f)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (long)(NSEC_PER_SEC * 0.5f)), dispatch_get_main_queue(), ^{
|
||||||
[self dismissModalViewControllerAnimated:YES];
|
[self dismissModalViewControllerAnimated:YES];
|
||||||
});
|
});
|
||||||
} else if (self.passwordField.text.length)
|
} else
|
||||||
[self setPasswordTip:@"Incorrect password."];
|
if (self.passwordField.text.length)
|
||||||
|
[self setPasswordTip:@"Incorrect password."];
|
||||||
|
|
||||||
[self setSpinnerActive:NO];
|
[self setSpinnerActive:NO];
|
||||||
});
|
});
|
||||||
@ -312,7 +316,8 @@
|
|||||||
- (UIButton *)findTargetedAvatar {
|
- (UIButton *)findTargetedAvatar {
|
||||||
|
|
||||||
CGFloat xOfMiddle = self.avatarsView.contentOffset.x + self.avatarsView.bounds.size.width / 2;
|
CGFloat xOfMiddle = self.avatarsView.contentOffset.x + self.avatarsView.bounds.size.width / 2;
|
||||||
return (UIButton *) [PearlUIUtils viewClosestTo:CGPointMake(xOfMiddle, self.avatarsView.contentOffset.y) ofArray:self.avatarsView.subviews];
|
return (UIButton *)[PearlUIUtils viewClosestTo:CGPointMake(xOfMiddle, self.avatarsView.contentOffset.y)
|
||||||
|
ofArray:self.avatarsView.subviews];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIButton *)avatarForUser:(MPUserEntity *)user {
|
- (UIButton *)avatarForUser:(MPUserEntity *)user {
|
||||||
@ -336,16 +341,16 @@
|
|||||||
|
|
||||||
PearlMainThread(^{
|
PearlMainThread(^{
|
||||||
CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
|
CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
|
||||||
rotate.toValue = [NSNumber numberWithDouble:2 * M_PI];
|
rotate.toValue = [NSNumber numberWithDouble:2 * M_PI];
|
||||||
rotate.duration = 5.0;
|
rotate.duration = 5.0;
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
rotate.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
|
rotate.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
|
||||||
rotate.fromValue = [NSNumber numberWithFloat:0];
|
rotate.fromValue = [NSNumber numberWithFloat:0];
|
||||||
rotate.repeatCount = MAXFLOAT;
|
rotate.repeatCount = MAXFLOAT;
|
||||||
} else {
|
} else {
|
||||||
rotate.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
|
rotate.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
|
||||||
rotate.repeatCount = 1;
|
rotate.repeatCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.spinner.layer removeAnimationForKey:@"rotation"];
|
[self.spinner.layer removeAnimationForKey:@"rotation"];
|
||||||
@ -367,26 +372,27 @@
|
|||||||
if (targeted) {
|
if (targeted) {
|
||||||
if (![avatar.layer animationForKey:@"targetedShadow"]) {
|
if (![avatar.layer animationForKey:@"targetedShadow"]) {
|
||||||
CABasicAnimation *toShadowColorAnimation = [CABasicAnimation animationWithKeyPath:@"shadowColor"];
|
CABasicAnimation *toShadowColorAnimation = [CABasicAnimation animationWithKeyPath:@"shadowColor"];
|
||||||
toShadowColorAnimation.toValue = (__bridge id) (avatar.selected? self.avatarTemplate.backgroundColor: [UIColor whiteColor]).CGColor;
|
toShadowColorAnimation.toValue = (__bridge id)(avatar.selected? self.avatarTemplate.backgroundColor
|
||||||
|
: [UIColor whiteColor]).CGColor;
|
||||||
toShadowColorAnimation.beginTime = 0.0f;
|
toShadowColorAnimation.beginTime = 0.0f;
|
||||||
toShadowColorAnimation.duration = 0.5f;
|
toShadowColorAnimation.duration = 0.5f;
|
||||||
toShadowColorAnimation.fillMode = kCAFillModeForwards;
|
toShadowColorAnimation.fillMode = kCAFillModeForwards;
|
||||||
|
|
||||||
CABasicAnimation *toShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
|
CABasicAnimation *toShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
|
||||||
toShadowOpacityAnimation.toValue = PearlFloat(0.2);
|
toShadowOpacityAnimation.toValue = PearlFloat(0.2);
|
||||||
toShadowOpacityAnimation.duration = 0.5f;
|
toShadowOpacityAnimation.duration = 0.5f;
|
||||||
|
|
||||||
CABasicAnimation *pulseShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
|
CABasicAnimation *pulseShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
|
||||||
pulseShadowOpacityAnimation.fromValue = PearlFloat(0.2);
|
pulseShadowOpacityAnimation.fromValue = PearlFloat(0.2);
|
||||||
pulseShadowOpacityAnimation.toValue = PearlFloat(0.6);
|
pulseShadowOpacityAnimation.toValue = PearlFloat(0.6);
|
||||||
pulseShadowOpacityAnimation.beginTime = 0.5f;
|
pulseShadowOpacityAnimation.beginTime = 0.5f;
|
||||||
pulseShadowOpacityAnimation.duration = 2.0f;
|
pulseShadowOpacityAnimation.duration = 2.0f;
|
||||||
pulseShadowOpacityAnimation.autoreverses = YES;
|
pulseShadowOpacityAnimation.autoreverses = YES;
|
||||||
pulseShadowOpacityAnimation.repeatCount = MAXFLOAT;
|
pulseShadowOpacityAnimation.repeatCount = MAXFLOAT;
|
||||||
|
|
||||||
CAAnimationGroup *group = [[CAAnimationGroup alloc] init];
|
CAAnimationGroup *group = [[CAAnimationGroup alloc] init];
|
||||||
group.animations = [NSArray arrayWithObjects:toShadowColorAnimation, toShadowOpacityAnimation, pulseShadowOpacityAnimation, nil];
|
group.animations = [NSArray arrayWithObjects:toShadowColorAnimation, toShadowOpacityAnimation, pulseShadowOpacityAnimation, nil];
|
||||||
group.duration = MAXFLOAT;
|
group.duration = MAXFLOAT;
|
||||||
|
|
||||||
[avatar.layer removeAnimationForKey:@"inactiveShadow"];
|
[avatar.layer removeAnimationForKey:@"inactiveShadow"];
|
||||||
[avatar.layer addAnimation:group forKey:@"targetedShadow"];
|
[avatar.layer addAnimation:group forKey:@"targetedShadow"];
|
||||||
@ -394,16 +400,16 @@
|
|||||||
} else {
|
} else {
|
||||||
if ([avatar.layer animationForKey:@"targetedShadow"]) {
|
if ([avatar.layer animationForKey:@"targetedShadow"]) {
|
||||||
CABasicAnimation *toShadowColorAnimation = [CABasicAnimation animationWithKeyPath:@"shadowColor"];
|
CABasicAnimation *toShadowColorAnimation = [CABasicAnimation animationWithKeyPath:@"shadowColor"];
|
||||||
toShadowColorAnimation.toValue = (__bridge id) [UIColor blackColor].CGColor;
|
toShadowColorAnimation.toValue = (__bridge id)[UIColor blackColor].CGColor;
|
||||||
toShadowColorAnimation.duration = 0.5f;
|
toShadowColorAnimation.duration = 0.5f;
|
||||||
|
|
||||||
CABasicAnimation *toShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
|
CABasicAnimation *toShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
|
||||||
toShadowOpacityAnimation.toValue = PearlFloat(1);
|
toShadowOpacityAnimation.toValue = PearlFloat(1);
|
||||||
toShadowOpacityAnimation.duration = 0.5f;
|
toShadowOpacityAnimation.duration = 0.5f;
|
||||||
|
|
||||||
CAAnimationGroup *group = [[CAAnimationGroup alloc] init];
|
CAAnimationGroup *group = [[CAAnimationGroup alloc] init];
|
||||||
group.animations = [NSArray arrayWithObjects:toShadowColorAnimation, toShadowOpacityAnimation, nil];
|
group.animations = [NSArray arrayWithObjects:toShadowColorAnimation, toShadowOpacityAnimation, nil];
|
||||||
group.duration = 0.5f;
|
group.duration = 0.5f;
|
||||||
|
|
||||||
[avatar.layer removeAnimationForKey:@"targetedShadow"];
|
[avatar.layer removeAnimationForKey:@"targetedShadow"];
|
||||||
[avatar.layer addAnimation:group forKey:@"inactiveShadow"];
|
[avatar.layer addAnimation:group forKey:@"inactiveShadow"];
|
||||||
@ -432,25 +438,26 @@
|
|||||||
message:@"Please confirm the spelling of this new master password."
|
message:@"Please confirm the spelling of this new master password."
|
||||||
viewStyle:UIAlertViewStyleSecureTextInput
|
viewStyle:UIAlertViewStyleSecureTextInput
|
||||||
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
[self setSpinnerActive:NO];
|
[self setSpinnerActive:NO];
|
||||||
|
|
||||||
if (buttonIndex == [alert cancelButtonIndex])
|
if (buttonIndex == [alert cancelButtonIndex])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (![[alert textFieldAtIndex:0].text isEqualToString:textField.text]) {
|
if (![[alert textFieldAtIndex:0].text isEqualToString:textField.text]) {
|
||||||
[PearlAlert showAlertWithTitle:@"Incorrect Master Password"
|
[PearlAlert showAlertWithTitle:@"Incorrect Master Password"
|
||||||
message:
|
message:
|
||||||
@"The password you entered doesn't match with the master password you tried to use. "
|
@"The password you entered doesn't match with the master password you tried to use. "
|
||||||
@"You've probably mistyped one of them.\n\n"
|
@"You've probably mistyped one of them.\n\n"
|
||||||
@"Give it another try."
|
@"Give it another try."
|
||||||
viewStyle:UIAlertViewStyleDefault initAlert:nil tappedButtonBlock:nil cancelTitle:[PearlStrings get].commonButtonOkay otherTitles:nil];
|
viewStyle:UIAlertViewStyleDefault initAlert:nil tappedButtonBlock:nil
|
||||||
return;
|
cancelTitle:[PearlStrings get].commonButtonOkay otherTitles:nil];
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[self tryMasterPassword];
|
[self tryMasterPassword];
|
||||||
}
|
}
|
||||||
cancelTitle:[PearlStrings get].commonButtonCancel
|
cancelTitle:[PearlStrings get].commonButtonCancel
|
||||||
otherTitles:[PearlStrings get].commonButtonContinue, nil];
|
otherTitles:[PearlStrings get].commonButtonContinue, nil];
|
||||||
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
@ -458,10 +465,12 @@
|
|||||||
|
|
||||||
#pragma mark - UIScrollViewDelegate
|
#pragma mark - UIScrollViewDelegate
|
||||||
|
|
||||||
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
|
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity
|
||||||
|
targetContentOffset:(inout CGPoint *)targetContentOffset {
|
||||||
|
|
||||||
CGFloat xOfMiddle = targetContentOffset->x + scrollView.bounds.size.width / 2;
|
CGFloat xOfMiddle = targetContentOffset->x + scrollView.bounds.size.width / 2;
|
||||||
UIButton *middleAvatar = (UIButton *) [PearlUIUtils viewClosestTo:CGPointMake(xOfMiddle, targetContentOffset->y) ofArray:scrollView.subviews];
|
UIButton *middleAvatar = (UIButton *)[PearlUIUtils viewClosestTo:CGPointMake(xOfMiddle, targetContentOffset->y)
|
||||||
|
ofArray:scrollView.subviews];
|
||||||
*targetContentOffset = CGPointMake(middleAvatar.center.x - scrollView.bounds.size.width / 2, targetContentOffset->y);
|
*targetContentOffset = CGPointMake(middleAvatar.center.x - scrollView.bounds.size.width / 2, targetContentOffset->y);
|
||||||
|
|
||||||
[self updateLayoutAnimated:NO allowScroll:NO completion:nil];
|
[self updateLayoutAnimated:NO allowScroll:NO completion:nil];
|
||||||
@ -494,16 +503,17 @@
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
[PearlAlert showAlertWithTitle:@"Delete User" message:
|
[PearlAlert showAlertWithTitle:@"Delete User" message:
|
||||||
PearlString(@"Do you want to delete all record of the following user?\n\n%@", targetedUser.name)
|
PearlString(@"Do you want to delete all record of the following user?\n\n%@",
|
||||||
|
targetedUser.name)
|
||||||
viewStyle:UIAlertViewStyleDefault
|
viewStyle:UIAlertViewStyleDefault
|
||||||
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
||||||
if (buttonIndex == [alert cancelButtonIndex])
|
if (buttonIndex == [alert cancelButtonIndex])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[[MPAppDelegate get].managedObjectContext deleteObject:targetedUser];
|
[[MPAppDelegate get].managedObjectContext deleteObject:targetedUser];
|
||||||
[[MPAppDelegate get] saveContext];
|
[[MPAppDelegate get] saveContext];
|
||||||
|
|
||||||
[self updateUsers];
|
[self updateUsers];
|
||||||
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Delete", nil];
|
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Delete", nil];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -6,21 +6,19 @@
|
|||||||
// Copyright (c) 2012 Lyndir. All rights reserved.
|
// Copyright (c) 2012 Lyndir. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "MPiOSConfig.h"
|
|
||||||
|
|
||||||
@implementation MPiOSConfig
|
@implementation MPiOSConfig
|
||||||
@dynamic helpHidden, showQuickStart;
|
@dynamic helpHidden, showQuickStart;
|
||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
|
|
||||||
if(!(self = [super init]))
|
if (!(self = [super init]))
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
[self.defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
|
[self.defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithBool:NO], NSStringFromSelector(@selector(helpHidden)),
|
[NSNumber numberWithBool:NO], NSStringFromSelector(@selector(helpHidden)),
|
||||||
[NSNumber numberWithBool:YES], NSStringFromSelector(@selector(showQuickStart)),
|
[NSNumber numberWithBool:YES], NSStringFromSelector(@selector(showQuickStart)),
|
||||||
@"510296984", NSStringFromSelector(@selector(iTunesID)),
|
@"510296984", NSStringFromSelector(@selector(iTunesID)),
|
||||||
nil]];
|
nil]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,14 @@
|
|||||||
#import "Pearl-Prefix.pch"
|
#import "Pearl-Prefix.pch"
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <CoreData/CoreData.h>
|
|
||||||
|
|
||||||
#import "TestFlight.h"
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <CoreData/CoreData.h>
|
||||||
|
|
||||||
|
#import "TestFlight.h"
|
||||||
|
|
||||||
|
#import "MPTypes.h"
|
||||||
|
#import "MPiOSConfig.h"
|
||||||
|
|
||||||
#import "MPTypes.h"
|
|
||||||
#import "MPiOSConfig.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
#import "MPAppDelegate.h"
|
#import "MPAppDelegate.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) {
|
||||||
{
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MPAppDelegate class]));
|
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MPAppDelegate class]));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user