Skip to content

Commit

Permalink
First pass at iOS 7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
tallerthenyou committed Sep 13, 2013
1 parent 300f2b4 commit 5d7218f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 39 deletions.
16 changes: 2 additions & 14 deletions MiniKeePass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@
689DFFCC13A4273F005EBD36 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
LastUpgradeCheck = 0500;
ORGANIZATIONNAME = Self;
};
buildConfigurationList = 689DFFCF13A4273F005EBD36 /* Build configuration list for PBXProject "MiniKeePass" */;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion MiniKeePass/EntryViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#import "StringFieldViewController.h"
#import "AutorotatingTableViewController.h"

@interface EntryViewController : AutorotatingTableViewController <UIGestureRecognizerDelegate, ImageSelectionViewDelegate, TextFieldCellDelegate, PasswordGeneratorDelegate, StringFieldViewDelegate>
@interface EntryViewController : AutorotatingTableViewController <UIGestureRecognizerDelegate, ImageSelectionViewDelegate, TextFieldCellDelegate, PasswordGeneratorDelegate, StringFieldViewDelegate, TitleFieldCellDelegate>

@property (nonatomic, assign) NSUInteger selectedImageIndex;
@property (nonatomic, strong) KdbEntry *entry;
Expand Down
5 changes: 5 additions & 0 deletions MiniKeePass/EntryViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];

Expand Down
3 changes: 1 addition & 2 deletions MiniKeePass/PasswordFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 11 additions & 10 deletions MiniKeePass/TextFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#import "TextFieldCell.h"
#import <UIKit/UIPasteboard.h>

#define INSET 83

@interface TextFieldCell()
@property (nonatomic, strong) UIView *grayBar;
@end
Expand All @@ -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;
Expand All @@ -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];
Expand All @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions MiniKeePass/TextViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion MiniKeePass/TitleFieldCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@

#import "TextFieldCell.h"

@protocol TitleFieldCellDelegate;

@interface TitleFieldCell : TextFieldCell

@property (nonatomic, readonly) UIButton *imageButton;
@property (nonatomic, unsafe_unretained) id<TitleFieldCellDelegate> delegate;

@end

@end
@protocol TitleFieldCellDelegate <NSObject>
- (void)titleFieldCell:(TitleFieldCell*)cell updatedTitle:(NSString*)title;
@end
8 changes: 4 additions & 4 deletions MiniKeePass/TitleFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

@implementation TitleFieldCell

@synthesize delegate;

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
Expand All @@ -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

0 comments on commit 5d7218f

Please sign in to comment.