From 0156f8c3c8ea30a17ad7e12f3e4ca77b7d98cc3a Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Wed, 17 Sep 2014 20:50:27 -0400 Subject: [PATCH] More store work. [FIXED] A strange issue with reloading password cells. [FIXED] Product identifiers and showing the first product in the store. [ADDED] Restoring purchases made from other devices. [REMOVED] iCloud entitlements. --- External/Pearl | 2 +- MasterPassword/ObjC/MPTypes.h | 2 +- .../ObjC/iOS/MPPasswordsViewController.m | 6 +- .../ObjC/iOS/MPStoreViewController.m | 20 ++++- MasterPassword/ObjC/iOS/MPiOSAppDelegate.m | 5 ++ .../project.pbxproj | 9 +- .../ObjC/iOS/MasterPassword.entitlements | 14 +-- MasterPassword/ObjC/iOS/Storyboard.storyboard | 85 ++++++++++++++++--- 8 files changed, 109 insertions(+), 34 deletions(-) diff --git a/External/Pearl b/External/Pearl index baba3dbd..be82c9b4 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit baba3dbddc87937b176f27f643085180f206207e +Subproject commit be82c9b4bfe8a58c72d1cc10d1a02e2d419edb38 diff --git a/MasterPassword/ObjC/MPTypes.h b/MasterPassword/ObjC/MPTypes.h index 1954b71c..ef7c086f 100644 --- a/MasterPassword/ObjC/MPTypes.h +++ b/MasterPassword/ObjC/MPTypes.h @@ -84,7 +84,7 @@ typedef NS_ENUM(NSUInteger, MPElementType) { #define MPSitesImportedNotificationUserKey @"MPSitesImportedNotificationUserKey" #define MPInconsistenciesFixResultUserKey @"MPInconsistenciesFixResultUserKey" -#define MPProductGenerateLogins @"MPProductGenerateLogins" +#define MPProductGenerateLogins @"com.lyndir.masterpassword.products.generatelogins" static void MPCheckpoint(NSString *checkpoint, NSDictionary *attributes) { diff --git a/MasterPassword/ObjC/iOS/MPPasswordsViewController.m b/MasterPassword/ObjC/iOS/MPPasswordsViewController.m index 3f7a574e..aea3e588 100644 --- a/MasterPassword/ObjC/iOS/MPPasswordsViewController.m +++ b/MasterPassword/ObjC/iOS/MPPasswordsViewController.m @@ -389,17 +389,19 @@ referenceSizeForHeaderInSection:(NSInteger)section { [self.passwordCollectionView performBatchUpdates:^{ [self fetchedItemsDidUpdate]; - NSInteger fromSections = [oldSections count]; + NSInteger fromSections = self.passwordCollectionView.numberOfSections; NSInteger toSections = [self numberOfSectionsInCollectionView:self.passwordCollectionView]; for (NSInteger section = 0; section < MAX( toSections, fromSections ); ++section) { if (section >= fromSections) [self.passwordCollectionView insertSections:[NSIndexSet indexSetWithIndex:section]]; else if (section >= toSections) [self.passwordCollectionView deleteSections:[NSIndexSet indexSetWithIndex:section]]; - else + else if (section < [oldSections count]) [self.passwordCollectionView reloadItemsFromArray:oldSections[section] toArray:[[self.fetchedResultsController sections][section] objects] inSection:section]; + else + [self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:section]]; } } completion:^(BOOL finished) { if (finished) diff --git a/MasterPassword/ObjC/iOS/MPStoreViewController.m b/MasterPassword/ObjC/iOS/MPStoreViewController.m index c3f10482..ee87f15d 100644 --- a/MasterPassword/ObjC/iOS/MPStoreViewController.m +++ b/MasterPassword/ObjC/iOS/MPStoreViewController.m @@ -102,6 +102,21 @@ [tableView deselectRowAtIndexPath:indexPath animated:YES]; } +#pragma mark - Actions + +- (IBAction)restorePurchases:(id)sender { + + [PearlAlert showAlertWithTitle:@"Restore Previous Purchases" message: + @"This will check with Apple to find and activate any purchases you made from other devices." + viewStyle:UIAlertViewStyleDefault initAlert:nil + tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) { + if (buttonIndex == [alert cancelButtonIndex]) + return; + + [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; + } cancelTitle:@"Cancel" otherTitles:@"Find Purchases", nil]; +} + #pragma mark - Private - (SKProduct *)productForCell:(MPStoreProductCell *)cell { @@ -144,8 +159,9 @@ [showCells addObject:cell]; self.currencyFormatter.locale = product.priceLocale; - cell.priceLabel.text = [self.currencyFormatter stringFromNumber:product.price]; - cell.purchasedIndicator.alpha = [[MPiOSAppDelegate get] isPurchased:productIdentifier]? 1: 0; + BOOL purchased = [[MPiOSAppDelegate get] isPurchased:productIdentifier]; + cell.priceLabel.text = purchased? @"": [self.currencyFormatter stringFromNumber:product.price]; + cell.purchasedIndicator.alpha = purchased? 1: 0; } - (void)updateWithTransactions:(NSArray *)transactions { diff --git a/MasterPassword/ObjC/iOS/MPiOSAppDelegate.m b/MasterPassword/ObjC/iOS/MPiOSAppDelegate.m index 5e78b338..70e15b4b 100644 --- a/MasterPassword/ObjC/iOS/MPiOSAppDelegate.m +++ b/MasterPassword/ObjC/iOS/MPiOSAppDelegate.m @@ -295,6 +295,11 @@ err( @"StoreKit request (%@) failed: %@", request, error ); } +- (void)requestDidFinish:(SKRequest *)request { + + dbg( @"StoreKit request (%@) finished.", request ); +} + #pragma mark - SKPaymentTransactionObserver - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { diff --git a/MasterPassword/ObjC/iOS/MasterPassword-iOS.xcodeproj/project.pbxproj b/MasterPassword/ObjC/iOS/MasterPassword-iOS.xcodeproj/project.pbxproj index 69083e0b..5bc11516 100644 --- a/MasterPassword/ObjC/iOS/MasterPassword-iOS.xcodeproj/project.pbxproj +++ b/MasterPassword/ObjC/iOS/MasterPassword-iOS.xcodeproj/project.pbxproj @@ -2878,6 +2878,12 @@ com.apple.DataProtection = { enabled = 1; }; + com.apple.Keychain = { + enabled = 0; + }; + com.apple.iCloud = { + enabled = 0; + }; }; }; }; @@ -3533,7 +3539,6 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_ENTITLEMENTS = MasterPassword.entitlements; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../../../External/iOS\"", @@ -3563,7 +3568,6 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_ENTITLEMENTS = MasterPassword.entitlements; COPY_PHASE_STRIP = YES; EXCLUDED_SOURCE_FILE_NAMES = libDCIntrospect.a; FRAMEWORK_SEARCH_PATHS = ( @@ -3671,7 +3675,6 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_ENTITLEMENTS = MasterPassword.entitlements; COPY_PHASE_STRIP = YES; EXCLUDED_SOURCE_FILE_NAMES = libDCIntrospect.a; FRAMEWORK_SEARCH_PATHS = ( diff --git a/MasterPassword/ObjC/iOS/MasterPassword.entitlements b/MasterPassword/ObjC/iOS/MasterPassword.entitlements index be82f27a..0c67376e 100644 --- a/MasterPassword/ObjC/iOS/MasterPassword.entitlements +++ b/MasterPassword/ObjC/iOS/MasterPassword.entitlements @@ -1,17 +1,5 @@ - - com.apple.developer.ubiquity-container-identifiers - - $(TeamIdentifierPrefix)com.lyndir.lhunath.MasterPassword - $(TeamIdentifierPrefix)com.lyndir.lhunath.MasterPassword.shared - - com.apple.developer.ubiquity-kvstore-identifier - $(TeamIdentifierPrefix)com.lyndir.lhunath.MasterPassword.shared - keychain-access-groups - - $(AppIdentifierPrefix)com.lyndir.lhunath.MasterPassword - - + diff --git a/MasterPassword/ObjC/iOS/Storyboard.storyboard b/MasterPassword/ObjC/iOS/Storyboard.storyboard index 7135cfb8..61b4c41f 100644 --- a/MasterPassword/ObjC/iOS/Storyboard.storyboard +++ b/MasterPassword/ObjC/iOS/Storyboard.storyboard @@ -63,6 +63,7 @@ Exo2.0-Regular Exo2.0-Regular Exo2.0-Regular + Exo2.0-Regular Exo2.0-Thin @@ -1019,6 +1020,7 @@ + @@ -2486,8 +2488,11 @@ See + + @@ -2507,6 +2513,7 @@ See + @@ -2517,6 +2524,11 @@ See + + + + + @@ -2541,8 +2553,11 @@ See + @@ -2596,8 +2618,11 @@ See + @@ -2651,8 +2683,11 @@ See + - + + + + + - + - - - - - + + + + + + + @@ -2716,6 +2776,7 @@ See +