2012-02-02 13:56:09 +00:00
|
|
|
//
|
2012-02-05 21:18:38 +00:00
|
|
|
// MPGuideViewController.m
|
2012-02-03 07:45:09 +00:00
|
|
|
// MasterPassword
|
2012-02-02 13:56:09 +00:00
|
|
|
//
|
|
|
|
// Created by Maarten Billemont on 30/01/12.
|
|
|
|
// Copyright (c) 2012 Lyndir. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2012-02-05 21:18:38 +00:00
|
|
|
#import "MPGuideViewController.h"
|
2012-05-11 20:45:05 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
@interface MPGuideStep : NSObject
|
|
|
|
|
|
|
|
@property(nonatomic) UIImage *image;
|
|
|
|
@property(nonatomic) NSString *caption;
|
|
|
|
|
|
|
|
+ (instancetype)stepWithImage:(UIImage *)image caption:(NSString *)caption;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface MPGuideStepCell : UICollectionViewCell
|
|
|
|
|
|
|
|
@property(nonatomic) IBOutlet UIImageView *imageView;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2013-04-14 14:24:24 +00:00
|
|
|
@interface MPGuideViewController()
|
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
@property(nonatomic, strong) NSArray *steps;
|
2013-04-14 14:24:24 +00:00
|
|
|
@end
|
2012-02-02 13:56:09 +00:00
|
|
|
|
2012-02-05 21:18:38 +00:00
|
|
|
@implementation MPGuideViewController
|
2012-02-02 13:56:09 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
#pragma mark - Life
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
self.steps = @[
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-0"] caption:
|
|
|
|
@"To begin, tap the \"New User\" icon and add yourself as a user to the application."],
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-1"] caption:
|
|
|
|
@"Enter your full name. Double-check that you have spelled your name correctly and capitalized it appropriately. Your passwords will depend on it."],
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-2"] caption:
|
|
|
|
@"Choose a master password: Use something new and long. A short sentence is ideal.\nDO NOT FORGET THIS ONE PASSWORD."],
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-3"] caption:
|
|
|
|
@"After logging in, you'll see an empty screen with a search box.\nTap the search box to begin adding sites."],
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-4"] caption:
|
|
|
|
@"To add a site, just enter its name fully and tap the result. Names can be anything, but we recommend using a site's bare domain name."],
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-5"] caption:
|
|
|
|
@"Your sites are easy to find and sorted by recency.\nTap any site to copy its password.\nYou can now switch and paste it in another app."],
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-6"] caption:
|
2014-08-22 04:51:36 +00:00
|
|
|
@"The user icon lets you save your site's login.\nThis is useful if you find it hard to remember the user name for this site."],
|
2014-06-22 01:59:14 +00:00
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-7"] caption:
|
2014-08-22 04:51:36 +00:00
|
|
|
@"To make changes to the site password, tap the settings icon or swipe left to reveal extra buttons."],
|
2014-06-22 01:59:14 +00:00
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-8"] caption:
|
2014-08-22 04:51:36 +00:00
|
|
|
@"If you ever need a new password for the site, just tap the plus icon to increment its counter.\nYou can hold down to reset it back to 1."],
|
2014-06-22 01:59:14 +00:00
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-9"] caption:
|
2014-08-22 04:51:36 +00:00
|
|
|
@"Use the list icon to upgrade or downgrade your password's complexity.\nSome sites won't let you use complex passwords."],
|
2014-06-22 01:59:14 +00:00
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"image-10"] caption:
|
|
|
|
@"If you have a password that you cannot change, you can save it as a Personal password. Device Private means the site will not be backed up."],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
|
|
|
[self.pageControl observeKeyPath:@"currentPage"
|
|
|
|
withBlock:^(id from, id to, NSKeyValueChange cause, UIPageControl *pageControl) {
|
|
|
|
MPGuideStep *activeStep = self.steps[pageControl.currentPage];
|
|
|
|
self.captionLabel.text = activeStep.caption;
|
|
|
|
}];
|
|
|
|
|
|
|
|
[self.collectionView setContentOffset:CGPointZero];
|
|
|
|
self.pageControl.currentPage = 0;
|
|
|
|
|
|
|
|
if (self.navigationController)
|
|
|
|
[self.navigationBar removeFromSuperview];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
|
|
|
[self.pageControl removeKeyPathObservers];
|
|
|
|
}
|
|
|
|
|
2013-01-31 05:42:32 +00:00
|
|
|
- (BOOL)shouldAutorotate {
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2013-01-31 05:42:32 +00:00
|
|
|
return NO;
|
|
|
|
}
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2013-09-18 04:21:52 +00:00
|
|
|
- (BOOL)prefersStatusBarHidden {
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2013-09-18 04:21:52 +00:00
|
|
|
return NO;
|
2012-02-02 13:56:09 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 04:21:52 +00:00
|
|
|
- (UIStatusBarStyle)preferredStatusBarStyle {
|
2013-09-14 03:58:00 +00:00
|
|
|
|
2013-09-18 04:21:52 +00:00
|
|
|
return UIStatusBarStyleLightContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
|
|
|
|
|
|
|
|
return UIInterfaceOrientationPortrait;
|
2013-09-14 03:58:00 +00:00
|
|
|
}
|
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
#pragma mark - UICollectionViewDataSource
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
|
|
|
|
|
|
return self.pageControl.numberOfPages = [self.steps count];
|
|
|
|
}
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
2013-04-18 02:00:15 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
MPGuideStepCell *cell = [MPGuideStepCell dequeueCellFromCollectionView:collectionView indexPath:indexPath];
|
|
|
|
cell.imageView.image = ((MPGuideStep *)self.steps[indexPath.item]).image;
|
|
|
|
|
|
|
|
return cell;
|
2013-04-14 14:24:24 +00:00
|
|
|
}
|
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
#pragma mark - UICollectionViewDelegateFlowLayout
|
2012-06-14 19:56:54 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout
|
|
|
|
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
|
2013-09-14 03:58:00 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
return collectionView.bounds.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - UIScrollViewDelegate
|
|
|
|
|
|
|
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
if (scrollView == self.collectionView)
|
|
|
|
self.pageControl.currentPage = [self.collectionView indexPathForItemAtPoint:CGRectGetCenter( self.collectionView.bounds )].item;
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
#pragma mark - Actions
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
- (IBAction)close:(id)sender {
|
|
|
|
|
|
|
|
[MPiOSConfig get].showSetup = @NO;
|
|
|
|
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
2012-02-02 13:56:09 +00:00
|
|
|
}
|
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
#pragma mark - Private
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MPGuideStep
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
+ (instancetype)stepWithImage:(UIImage *)image caption:(NSString *)caption {
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
MPGuideStep *step = [self new];
|
|
|
|
step.image = image;
|
|
|
|
step.caption = caption;
|
2013-04-14 14:24:24 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
return step;
|
2013-04-14 14:24:24 +00:00
|
|
|
}
|
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MPGuideStepCell
|
2012-02-02 13:56:09 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
- (void)awakeFromNib {
|
|
|
|
|
|
|
|
[super awakeFromNib];
|
2012-02-02 13:56:09 +00:00
|
|
|
|
2014-06-22 01:59:14 +00:00
|
|
|
self.imageView.layer.shadowColor = [UIColor grayColor].CGColor;
|
|
|
|
self.imageView.layer.shadowOffset = CGSizeZero;
|
|
|
|
self.imageView.layer.shadowOpacity = 0.5f;
|
2013-04-14 14:24:24 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 13:56:09 +00:00
|
|
|
@end
|