From 5d7218fec27979eca24661a0d16f5c9cb2904978 Mon Sep 17 00:00:00 2001 From: John Flanagan Date: Thu, 12 Sep 2013 22:45:23 -0500 Subject: [PATCH] First pass at iOS 7 support --- MiniKeePass.xcodeproj/project.pbxproj | 16 ++-------------- MiniKeePass/EntryViewController.h | 2 +- MiniKeePass/EntryViewController.m | 5 +++++ MiniKeePass/PasswordFieldCell.m | 3 +-- MiniKeePass/TextFieldCell.m | 21 +++++++++++---------- MiniKeePass/TextViewCell.m | 7 ------- MiniKeePass/TitleFieldCell.h | 9 ++++++++- MiniKeePass/TitleFieldCell.m | 8 ++++---- 8 files changed, 32 insertions(+), 39 deletions(-) diff --git a/MiniKeePass.xcodeproj/project.pbxproj b/MiniKeePass.xcodeproj/project.pbxproj index 784d2958..4afb2ec6 100644 --- a/MiniKeePass.xcodeproj/project.pbxproj +++ b/MiniKeePass.xcodeproj/project.pbxproj @@ -1353,7 +1353,7 @@ 689DFFCC13A4273F005EBD36 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastUpgradeCheck = 0500; ORGANIZATIONNAME = Self; }; buildConfigurationList = 689DFFCF13A4273F005EBD36 /* Build configuration list for PBXProject "MiniKeePass" */; @@ -1727,10 +1727,6 @@ 5200281913D7D95900B77DD8 /* Distribution */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - armv6, - armv7, - ); CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -1783,10 +1779,6 @@ 689D000413A42740005EBD36 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - armv6, - armv7, - ); CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -1799,7 +1791,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = /usr/include/libxml2; IPHONEOS_DEPLOYMENT_TARGET = 4.3; - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; @@ -1809,10 +1801,6 @@ 689D000513A42740005EBD36 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - armv6, - armv7, - ); CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = gnu99; diff --git a/MiniKeePass/EntryViewController.h b/MiniKeePass/EntryViewController.h index 2a104ae9..b4d1ab44 100644 --- a/MiniKeePass/EntryViewController.h +++ b/MiniKeePass/EntryViewController.h @@ -29,7 +29,7 @@ #import "StringFieldViewController.h" #import "AutorotatingTableViewController.h" -@interface EntryViewController : AutorotatingTableViewController +@interface EntryViewController : AutorotatingTableViewController @property (nonatomic, assign) NSUInteger selectedImageIndex; @property (nonatomic, strong) KdbEntry *entry; diff --git a/MiniKeePass/EntryViewController.m b/MiniKeePass/EntryViewController.m index 11bbc9a9..5fd069e7 100644 --- a/MiniKeePass/EntryViewController.m +++ b/MiniKeePass/EntryViewController.m @@ -61,6 +61,7 @@ - (id)initWithStyle:(UITableViewStyle)style { appDelegate = (MiniKeePassAppDelegate*)[[UIApplication sharedApplication] delegate]; titleCell = [[TitleFieldCell alloc] init]; + titleCell.delegate = self; titleCell.textLabel.text = NSLocalizedString(@"Title", nil); titleCell.textField.placeholder = NSLocalizedString(@"Title", nil); titleCell.textField.enabled = NO; @@ -340,6 +341,10 @@ - (void)setEditing:(BOOL)editing animated:(BOOL)animated { [self.tableView endUpdates]; } +- (void)titleFieldCell:(TitleFieldCell *)cell updatedTitle:(NSString *)title { + self.title = title; +} + - (void)textFieldCellWillReturn:(TextFieldCell *)textFieldCell { NSIndexPath *indexPath = [self.tableView indexPathForCell:textFieldCell]; diff --git a/MiniKeePass/PasswordFieldCell.m b/MiniKeePass/PasswordFieldCell.m index 0296b46c..46a80f1d 100644 --- a/MiniKeePass/PasswordFieldCell.m +++ b/MiniKeePass/PasswordFieldCell.m @@ -46,12 +46,11 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus - (void)textFieldDidBeginEditing:(UITextField *)field { [super textFieldDidBeginEditing:field]; - + self.textField.secureTextEntry = NO; self.textField.autocorrectionType = UITextAutocorrectionTypeNo; self.textField.autocapitalizationType = UITextAutocapitalizationTypeNone; self.textField.returnKeyType = UIReturnKeyNext; - } - (void)textFieldDidEndEditing:(UITextField *)field { diff --git a/MiniKeePass/TextFieldCell.m b/MiniKeePass/TextFieldCell.m index 41b081e6..3df9e1cb 100644 --- a/MiniKeePass/TextFieldCell.m +++ b/MiniKeePass/TextFieldCell.m @@ -18,8 +18,6 @@ #import "TextFieldCell.h" #import -#define INSET 83 - @interface TextFieldCell() @property (nonatomic, strong) UIView *grayBar; @end @@ -29,10 +27,15 @@ @implementation TextFieldCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:reuseIdentifier]; if (self) { - + int inset = 83; + + if ([[UIDevice currentDevice].systemVersion hasPrefix:@"7"]) { + inset = 115; + } + CGRect frame = self.contentView.frame; - frame.origin.x = INSET; - frame.size.width -= INSET; + frame.origin.x = inset; + frame.size.width -= inset; _textField = [[UITextField alloc] initWithFrame:frame]; _textField.delegate = self; @@ -50,7 +53,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus CGFloat grayIntensity = 202.0 / 255.0; UIColor *color = [UIColor colorWithRed:grayIntensity green:grayIntensity blue:grayIntensity alpha:1]; - _grayBar = [[UIView alloc] initWithFrame:CGRectMake(79, -1, 1, self.contentView.frame.size.height - 4)]; + _grayBar = [[UIView alloc] initWithFrame:CGRectMake(inset - 4, -1, 1, self.contentView.frame.size.height - 4)]; _grayBar.backgroundColor = color; _grayBar.hidden = YES; [self.contentView addSubview:_grayBar]; @@ -76,10 +79,8 @@ - (void)setEditAccessoryButton:(UIButton *)editAccessoryButton { self.editingAccessoryView = editAccessoryButton; } -- (void)textFieldDidBeginEditing:(UITextField *)field { - // Keep cell visable - UITableView *tableView = (UITableView*)self.superview; - [tableView scrollRectToVisible:self.frame animated:YES]; +- (void)textFieldDidBeginEditing:(UITextField *)textField { + // No-op } - (void)textFieldDidEndEditing:(UITextField *)textField { diff --git a/MiniKeePass/TextViewCell.m b/MiniKeePass/TextViewCell.m index 3f8575e1..f3c4fe47 100644 --- a/MiniKeePass/TextViewCell.m +++ b/MiniKeePass/TextViewCell.m @@ -43,11 +43,4 @@ - (void)layoutSubviews { textView.frame = CGRectMake(rect.origin.x + 3, rect.origin.y + 3, rect.size.width - 6, rect.size.height - 6); } -- (void)textViewDidBeginEditing:(UITextView *)view { - UITableView *tableView = (UITableView*)self.superview; - - NSIndexPath *indexPath = [tableView indexPathForCell:self]; - [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; -} - @end diff --git a/MiniKeePass/TitleFieldCell.h b/MiniKeePass/TitleFieldCell.h index 79dc38df..54a21f78 100644 --- a/MiniKeePass/TitleFieldCell.h +++ b/MiniKeePass/TitleFieldCell.h @@ -17,8 +17,15 @@ #import "TextFieldCell.h" +@protocol TitleFieldCellDelegate; + @interface TitleFieldCell : TextFieldCell @property (nonatomic, readonly) UIButton *imageButton; +@property (nonatomic, unsafe_unretained) id delegate; + +@end -@end \ No newline at end of file +@protocol TitleFieldCellDelegate +- (void)titleFieldCell:(TitleFieldCell*)cell updatedTitle:(NSString*)title; +@end diff --git a/MiniKeePass/TitleFieldCell.m b/MiniKeePass/TitleFieldCell.m index ce6ad950..10879dd9 100644 --- a/MiniKeePass/TitleFieldCell.m +++ b/MiniKeePass/TitleFieldCell.m @@ -20,6 +20,8 @@ @implementation TitleFieldCell +@synthesize delegate; + - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { @@ -33,10 +35,8 @@ - (id)initWithFrame:(CGRect)frame { - (void)textFieldDidEndEditing:(UITextField *)inTextField { [super textFieldDidEndEditing:inTextField]; - - UITableView *tableView = (UITableView*)self.superview; - UITableViewController *tableViewController = (UITableViewController*)tableView.delegate; - tableViewController.title = self.textField.text; + + [delegate titleFieldCell:self updatedTitle:self.textField.text]; } @end