2017-04-05 20:56:22 +00:00
|
|
|
//==============================================================================
|
|
|
|
// This file is part of Master Password.
|
|
|
|
// Copyright (c) 2011-2017, Maarten Billemont.
|
2012-02-02 13:56:09 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// Master Password is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2012-02-02 13:56:09 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// Master Password is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2012-02-02 13:56:09 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// You can find a copy of the GNU General Public License in the
|
|
|
|
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
|
|
|
//==============================================================================
|
2012-02-02 13:56:09 +00:00
|
|
|
|
2012-02-05 21:18:38 +00:00
|
|
|
#import "MPGuideViewController.h"
|
2014-09-29 02:15:55 +00:00
|
|
|
#import "NSString+MPMarkDown.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 = @[
|
2014-09-29 02:15:55 +00:00
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"initial"] caption:
|
|
|
|
@"To begin, tap the *New User* icon and add yourself as a user to the application."],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"name_new"] caption:
|
|
|
|
@"Enter your full name. \n"
|
|
|
|
@"**Double-check** that you have spelled your name correctly and capitalized it appropriately. \n"
|
|
|
|
@"Your passwords will depend on it."],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"mpw_new"] caption:
|
|
|
|
@"Choose a master password: Make it *new* and *long*. \n"
|
|
|
|
@"A short phrase makes a great password. \n"
|
|
|
|
@"**DO NOT FORGET THIS ONE PASSWORD**."],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"login_new"] caption:
|
|
|
|
@"After logging in, you'll see an empty screen with a search box. \n"
|
|
|
|
@"Tap the search box to begin adding sites."],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"site_new"] caption:
|
|
|
|
@"To add a site, just enter its name and tap the result. \n"
|
|
|
|
@"*We recommend* always using a site's **bare** domain name: eg. *apple.com*. \n"
|
|
|
|
@"(NOT *www.*apple.com or *store.*apple.com)"],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"copy_pw"] caption:
|
|
|
|
@"Tap any site to copy its password. \n"
|
|
|
|
@"The first time, change your site's old password into this new one."],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"settings"] 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-09-29 02:15:55 +00:00
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"login_name"] caption:
|
|
|
|
@"You can save the login name for the site. \n"
|
|
|
|
@"This is useful if you find it hard to remember your user name for this site."],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"counter"] caption:
|
|
|
|
@"If you ever need a new password for the site, just tap the plus icon to increment its counter. \n"
|
|
|
|
@"You can hold down to reset it back to 1."],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"choose_type"] caption:
|
|
|
|
@"Use the list icon to upgrade or downgrade your password's complexity. \n"
|
|
|
|
@"Some sites won't let you use complex passwords."],
|
|
|
|
|
|
|
|
[MPGuideStep stepWithImage:[UIImage imageNamed:@"personal_pw"] 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."],
|
2014-06-22 01:59:14 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
|
|
|
[self.pageControl observeKeyPath:@"currentPage"
|
|
|
|
withBlock:^(id from, id to, NSKeyValueChange cause, UIPageControl *pageControl) {
|
2014-09-29 02:15:55 +00:00
|
|
|
MPGuideStep *activeStep = self.steps[pageControl.currentPage];
|
|
|
|
self.captionLabel.attributedText =
|
|
|
|
[activeStep.caption attributedMarkdownStringWithFontSize:self.captionLabel.font.pointSize];
|
|
|
|
}];
|
2014-06-22 01:59:14 +00:00
|
|
|
|
|
|
|
[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
|
|
|
|
2018-10-15 22:09:46 +00:00
|
|
|
MPGuideStepCell *cell = [MPGuideStepCell dequeueFromCollectionView:collectionView indexPath:indexPath];
|
2014-06-22 01:59:14 +00:00
|
|
|
cell.imageView.image = ((MPGuideStep *)self.steps[indexPath.item]).image;
|
2014-09-29 02:15:55 +00:00
|
|
|
cell.contentView.frame = cell.bounds;
|
2014-06-22 01:59:14 +00:00
|
|
|
|
|
|
|
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
|