From f659c0936ecb67976812f4e5f6b6e15f4ab4b491 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Wed, 26 Feb 2020 23:01:44 -0500 Subject: [PATCH] Volto migration alerts. --- .../Source/iOS/MPCombinedViewController.m | 2 - .../Source/iOS/MPSitesViewController.h | 3 + .../Source/iOS/MPSitesViewController.m | 52 ++++++++++- platform-darwin/Source/iOS/MPiOSAppDelegate.m | 2 +- .../Source/iOS/MasterPassword-Info.plist | 15 ++- .../Source/iOS/Storyboard.storyboard | 91 +++++++++++++++++-- 6 files changed, 147 insertions(+), 18 deletions(-) diff --git a/platform-darwin/Source/iOS/MPCombinedViewController.m b/platform-darwin/Source/iOS/MPCombinedViewController.m index 31c9bc32..38ab53e8 100644 --- a/platform-darwin/Source/iOS/MPCombinedViewController.m +++ b/platform-darwin/Source/iOS/MPCombinedViewController.m @@ -145,6 +145,4 @@ } } -#pragma mark - Private - @end diff --git a/platform-darwin/Source/iOS/MPSitesViewController.h b/platform-darwin/Source/iOS/MPSitesViewController.h index 6bfa83d8..e770101b 100644 --- a/platform-darwin/Source/iOS/MPSitesViewController.h +++ b/platform-darwin/Source/iOS/MPSitesViewController.h @@ -30,6 +30,8 @@ @property(nonatomic, strong) IBOutlet UIView *badNameTipContainer; @property(nonatomic, strong) IBOutlet UIView *popdownView; @property(nonatomic, strong) IBOutlet UIView *popdownContainer; +@property(nonatomic, strong) IBOutlet UIView *voltoInstallAlert; +@property(nonatomic, strong) IBOutlet UIView *voltoMigrateAlert; @property(assign, nonatomic) BOOL active; @@ -37,5 +39,6 @@ - (void)reloadSites; - (IBAction)dismissPopdown:(id)sender; +- (IBAction)upgradeVolto:(UIButton *)sender; @end diff --git a/platform-darwin/Source/iOS/MPSitesViewController.m b/platform-darwin/Source/iOS/MPSitesViewController.m index a0e2df95..0c146dd6 100644 --- a/platform-darwin/Source/iOS/MPSitesViewController.m +++ b/platform-darwin/Source/iOS/MPSitesViewController.m @@ -16,6 +16,8 @@ // LICENSE file. Alternatively, see . //============================================================================== +#import + #import "MPSitesViewController.h" #import "MPiOSAppDelegate.h" #import "MPAppDelegate_Store.h" @@ -31,8 +33,9 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) { MPPasswordsBadNameTip = 1 << 0, }; -@interface MPSitesViewController() +@interface MPSitesViewController() +@property(nonatomic, strong) SKStoreProductViewController *voltoViewController; @property(nonatomic, strong) NSFetchedResultsController *fetchedResultsController; @property(nonatomic, strong) NSArray *fuzzyGroups; @property(nonatomic, strong) NSCharacterSet *siteNameAcceptableCharactersSet; @@ -76,6 +79,7 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) { [self registerObservers]; [self updateConfigKey:nil]; + [self updateVoltoAlerts]; static NSRegularExpression *bareHostRE = nil; static dispatch_once_t once = 0; @@ -327,6 +331,7 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) { PearlAddNotificationObserver( UIApplicationWillEnterForegroundNotification, nil, [NSOperationQueue mainQueue], ^(MPSitesViewController *self, NSNotification *note) { [self viewWillAppear:YES]; + [self updateVoltoAlerts]; } ); PearlAddNotificationObserver( MPSignedOutNotification, nil, nil, ^(MPSitesViewController *self, NSNotification *note) { @@ -455,6 +460,13 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) { } completion:completion]; } +#pragma mark - SKStoreProductViewControllerDelegate + +- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController { + + [viewController dismissViewControllerAnimated:YES completion:nil]; +} + #pragma mark - Actions - (IBAction)dismissPopdown:(id)sender { @@ -465,4 +477,42 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) { self.popdownToTopConstraint.priority = UILayoutPriorityDefaultHigh; } +- (IBAction)upgradeVolto:(UIButton *)sender { + + if ([UIApp canOpenURL:[[NSURL alloc] initWithString:@"volto://"]]) + [UIApp openURL:[[NSURL alloc] initWithString:@"volto://"]]; + else if (self.voltoViewController) + [self presentViewController:self.voltoViewController animated:YES completion:nil]; +} + +#pragma mark - Private + +- (void)updateVoltoAlerts { + + BOOL voltoInstalled = [UIApp canOpenURL:[[NSURL alloc] initWithString:@"volto://"]]; + if (voltoInstalled) { + self.voltoInstallAlert.visible = NO; + self.voltoMigrateAlert.visible = YES; + } + else { + self.voltoInstallAlert.visible = NO; + self.voltoMigrateAlert.visible = NO; + self.voltoViewController = [SKStoreProductViewController new]; + self.voltoViewController.delegate = self; + [self.voltoViewController loadProductWithParameters:@{ + SKStoreProductParameterCampaignToken : @"app-masterpassword.ios", /* Campaign: From MasterPassword iOS */ + SKStoreProductParameterProviderToken : @153897, /* Provider: Maarten Billemont */ + SKStoreProductParameterITunesItemIdentifier: @510296984, /* Application: MasterPassword iOS */ + //SKStoreProductParameterITunesItemIdentifier: @1500430196, /* Application: Volto iOS */ + } completionBlock:^(BOOL result, NSError *error) { + if (error) + err( @"Failed loading Volto product information: %@", error ); + + [UIView animateWithDuration:0.3f animations:^{ + self.voltoInstallAlert.visible = result; + }]; + }]; + } +} + @end diff --git a/platform-darwin/Source/iOS/MPiOSAppDelegate.m b/platform-darwin/Source/iOS/MPiOSAppDelegate.m index 1001ca51..00778505 100644 --- a/platform-darwin/Source/iOS/MPiOSAppDelegate.m +++ b/platform-darwin/Source/iOS/MPiOSAppDelegate.m @@ -102,7 +102,7 @@ // Countly CountlyConfig *countlyConfig = [CountlyConfig new]; - countlyConfig.host = @"https://countly.lyndir.app"; + countlyConfig.host = @"https://countly.lyndir.com"; countlyConfig.appKey = decrypt( countlyKey ); countlyConfig.features = @[ CLYPushNotifications, CLYAutoViewTracking ]; countlyConfig.requiresConsent = YES; diff --git a/platform-darwin/Source/iOS/MasterPassword-Info.plist b/platform-darwin/Source/iOS/MasterPassword-Info.plist index f92bca72..dd768bed 100644 --- a/platform-darwin/Source/iOS/MasterPassword-Info.plist +++ b/platform-darwin/Source/iOS/MasterPassword-Info.plist @@ -41,10 +41,14 @@ [auto] CFBundleVersion [auto] + LSApplicationQueriesSchemes + + volto + LSRequiresIPhoneOS NSHumanReadableCopyright - © 2011-2018 + © 2011-2020 UIAppFonts Exo2.0-Bold.otf @@ -102,12 +106,13 @@ UTTypeDescription Master Password sites + UTTypeIconFiles + + Icon-320.png + Icon-64.png + UTTypeIdentifier com.lyndir.masterpassword.sites - UTTypeSize320IconFile - Icon-320.png - UTTypeSize64IconFile - Icon-64.png UTTypeTagSpecification public.filename-extension diff --git a/platform-darwin/Source/iOS/Storyboard.storyboard b/platform-darwin/Source/iOS/Storyboard.storyboard index 6aecd3a9..9b722a54 100644 --- a/platform-darwin/Source/iOS/Storyboard.storyboard +++ b/platform-darwin/Source/iOS/Storyboard.storyboard @@ -69,7 +69,7 @@ - + @@ -1667,6 +1667,70 @@ eg. apple.com, rmitchell@twitter.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1710,8 +1774,13 @@ eg. apple.com, rmitchell@twitter.com + + + + + @@ -1723,6 +1792,7 @@ eg. apple.com, rmitchell@twitter.com + @@ -1741,6 +1811,8 @@ eg. apple.com, rmitchell@twitter.com + + @@ -2273,10 +2345,10 @@ Suspendisse potenti. Etiam ut nisi id augue tempor ultrices et sit amet sapien. - + - + @@ -2309,7 +2381,7 @@ Suspendisse potenti. Etiam ut nisi id augue tempor ultrices et sit amet sapien. - + @@ -2321,7 +2393,7 @@ Suspendisse potenti. Etiam ut nisi id augue tempor ultrices et sit amet sapien. - + - + @@ -2579,7 +2651,7 @@ See - + - + @@ -3039,7 +3111,7 @@ Invested: 3.7 work hours - +