From 8ea0f00cf0307a197e1ca5674e4b72fb2629e8e7 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sat, 7 Sep 2013 10:08:49 -0400 Subject: [PATCH] Improved cloud store enumeration. [ADDED] Stores now enumerated in a TVC. --- External/Pearl | 2 +- External/UbiquityStoreManager | 2 +- .../ObjC/iOS/MPLogsViewController.m | 36 ++++++++----------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/External/Pearl b/External/Pearl index 41c3582a..ea7054e3 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit 41c3582a72ddb251b9a3a055ecdad3fa49ec18f2 +Subproject commit ea7054e328bd7162d1f5a56a0f64a3eed6e3fc66 diff --git a/External/UbiquityStoreManager b/External/UbiquityStoreManager index ebc094f4..5a19df08 160000 --- a/External/UbiquityStoreManager +++ b/External/UbiquityStoreManager @@ -1 +1 @@ -Subproject commit ebc094f4c160f8aa3ebbe3f760fbf734b58bc5e6 +Subproject commit 5a19df087f7a694ad6427708f6d23c62ad8999bb diff --git a/MasterPassword/ObjC/iOS/MPLogsViewController.m b/MasterPassword/ObjC/iOS/MPLogsViewController.m index 0d7cc9a8..7a2beb93 100644 --- a/MasterPassword/ObjC/iOS/MPLogsViewController.m +++ b/MasterPassword/ObjC/iOS/MPLogsViewController.m @@ -91,8 +91,8 @@ for (NSURL *content in contents) if ([[NSFileManager defaultManager] fileExistsAtPath:content.path isDirectory:&directory] && directory) { NSString *contentString = [content lastPathComponent]; - NSUInteger lastDash = [contentString rangeOfString:@"-" options:NSBackwardsSearch].location; - NSString *storeDescription = lastDash == NSNotFound? contentString: [contentString substringFromIndex:lastDash + 1]; + NSUInteger firstDash = [contentString rangeOfString:@"-" options:0].location; + NSString *storeDescription = firstDash == NSNotFound? contentString: [contentString substringToIndex:firstDash]; NSPersistentStore *store = nil; @try { NSURL *storeURL = [[cloudStoreDirectory @@ -135,27 +135,21 @@ } NSString *storeUUID = [[MPiOSAppDelegate get].storeManager valueForKey:@"storeUUID_ThreadSafe"]; - NSUInteger lastDash = [storeUUID rangeOfString:@"-" options:NSBackwardsSearch].location; - NSString *title = PearlString( @"Current: %@", lastDash == NSNotFound? storeUUID: [storeUUID substringFromIndex:lastDash + 1] ); + NSUInteger firstDash = [storeUUID rangeOfString:@"-" options:0].location; + PearlArrayTVC *vc = [[PearlArrayTVC alloc] initWithStyle:UITableViewStylePlain]; + vc.title = PearlString( @"Current: %@", firstDash == NSNotFound? storeUUID: [storeUUID substringToIndex:firstDash] ); + [stores enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + [vc addRowWithName:obj style:PearlArrayTVCRowStyleLink toggled:NO toSection:@"Cloud Stores" + activationBlock:^BOOL(BOOL wasToggled) { + [[MPiOSAppDelegate get].storeManager setValue:key forKey:@"storeUUID"]; + [[MPiOSAppDelegate get].storeManager reloadStore]; + [[MPiOSAppDelegate get] signOutAnimated:YES]; + return YES; + }]; + }]; dispatch_async( dispatch_get_main_queue(), ^{ [switchCloudStoreProgress cancelAlertAnimated:YES]; - - NSArray *storeUUIDs = [stores allKeys]; - [PearlSheet showSheetWithTitle:title viewStyle:UIActionSheetStyleAutomatic - initSheet:^(UIActionSheet *sheet) { - for (NSString *contentName in storeUUIDs) - [sheet addButtonWithTitle:[stores objectForKey:contentName]]; - } - tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) { - if (buttonIndex == sheet.cancelButtonIndex) - return; - - [[MPiOSAppDelegate get].storeManager setValue:[storeUUIDs objectAtIndex:(unsigned)buttonIndex] - forKey:@"storeUUID"]; - [[MPiOSAppDelegate get].storeManager reloadStore]; - [[MPiOSAppDelegate get] signOutAnimated:YES]; - } - cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil otherTitles:nil]; + [self.navigationController pushViewController:vc animated:YES]; } ); }