Skip to content

Commit

Permalink
ShareKit disabled the auto cap and correction for all text fields. Th…
Browse files Browse the repository at this point in the history
…is isn't helping for things like captions... but is for username and password fields. Add a new form field type that disables auto cap and correction. Use this in all the right places. Between this and the password type field, all the right fields disable auto correct and cap.
  • Loading branch information
steve committed Aug 8, 2011
1 parent 166be4c commit 1319600
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Classes/ShareKit/Core/Base Sharer Classes/SHKSharer.m
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ - (NSArray *)authorizationFormFields
+ (NSArray *)authorizationFormFields
{
return [NSArray arrayWithObjects:
[SHKFormFieldSettings label:SHKLocalizedString(@"Username") key:@"username" type:SHKFormFieldTypeText start:nil],
[SHKFormFieldSettings label:SHKLocalizedString(@"Username") key:@"username" type:SHKFormFieldTypeTextNoCorrect start:nil],
[SHKFormFieldSettings label:SHKLocalizedString(@"Password") key:@"password" type:SHKFormFieldTypePassword start:nil],
nil];
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/ShareKit/Sharers/Services/Evernote/SHKEvernote.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ + (BOOL)canShare { return YES; }
+ (NSArray *)authorizationFormFields
{
return [NSArray arrayWithObjects:
[SHKFormFieldSettings label:@"Username" key:@"username" type:SHKFormFieldTypeText start:nil],
[SHKFormFieldSettings label:@"Username" key:@"username" type:SHKFormFieldTypeTextNoCorrect start:nil],
[SHKFormFieldSettings label:@"Password" key:@"password" type:SHKFormFieldTypePassword start:nil],
nil];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ + (NSString *)authorizationFormCaption
+ (NSArray *)authorizationFormFields
{
return [NSArray arrayWithObjects:
[SHKFormFieldSettings label:SHKLocalizedString(@"Email") key:@"email" type:SHKFormFieldTypeText start:nil],
[SHKFormFieldSettings label:SHKLocalizedString(@"Email") key:@"email" type:SHKFormFieldTypeTextNoCorrect start:nil],
[SHKFormFieldSettings label:SHKLocalizedString(@"Password") key:@"password" type:SHKFormFieldTypePassword start:nil],
nil];
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/ShareKit/Sharers/Services/Tumblr/SHKTumblr.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ - (NSArray *)authorizationFormFields{
return [NSArray arrayWithObjects:
[SHKFormFieldSettings label:SHKLocalizedString(@"Email")
key:@"email"
type:SHKFormFieldTypeText
type:SHKFormFieldTypeTextNoCorrect
start:nil],
[SHKFormFieldSettings label:SHKLocalizedString(@"Password")
key:@"password"
Expand Down
2 changes: 1 addition & 1 deletion Classes/ShareKit/Sharers/Services/Twitter/SHKTwitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ + (NSArray *)authorizationFormFields
return [super authorizationFormFields];

return [NSArray arrayWithObjects:
[SHKFormFieldSettings label:SHKLocalizedString(@"Username") key:@"username" type:SHKFormFieldTypeText start:nil],
[SHKFormFieldSettings label:SHKLocalizedString(@"Username") key:@"username" type:SHKFormFieldTypeTextNoCorrect start:nil],
[SHKFormFieldSettings label:SHKLocalizedString(@"Password") key:@"password" type:SHKFormFieldTypePassword start:nil],
[SHKFormFieldSettings label:SHKLocalizedString(@"Follow %@", SHKCONFIG(twitterUsername)) key:@"followMe" type:SHKFormFieldTypeSwitch start:SHKFormFieldSwitchOn],
nil];
Expand Down
4 changes: 3 additions & 1 deletion Classes/ShareKit/UI/SHKFormController.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ - (void)addSection:(NSArray *)fields header:(NSString *)header footer:(NSString
for (SHKFormFieldSettings *field in fields)
{
// only use text field rows
if (field.type != SHKFormFieldTypeText && field.type != SHKFormFieldTypePassword)
if (field.type != SHKFormFieldTypeText &&
field.type != SHKFormFieldTypeTextNoCorrect &&
field.type != SHKFormFieldTypePassword)
continue;

size = [field.label sizeWithFont:[UIFont boldSystemFontOfSize:17]];
Expand Down
10 changes: 7 additions & 3 deletions Classes/ShareKit/UI/SHKFormFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ - (UITextField *)getTextField
textField.returnKeyType = UIReturnKeyDone;
textField.font = [UIFont systemFontOfSize:17];
textField.textColor = [UIColor darkGrayColor];
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.delegate = form;
[self.contentView addSubview:textField];
[textField release];
Expand All @@ -72,10 +70,15 @@ - (void)layoutSubviews
{
[super layoutSubviews];

if (settings.type == SHKFormFieldTypeText || settings.type == SHKFormFieldTypePassword)
if (settings.type == SHKFormFieldTypeText || settings.type == SHKFormFieldTypeTextNoCorrect || settings.type == SHKFormFieldTypePassword)
{
self.textField.secureTextEntry = settings.type == SHKFormFieldTypePassword;

if(settings.type == SHKFormFieldTypePassword || settings.type == SHKFormFieldTypeTextNoCorrect){
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
}

textField.frame = CGRectMake(labelWidth + SHK_FORM_CELL_PAD_LEFT,
2 + round(self.contentView.bounds.size.height/2 - textField.bounds.size.height/2),
self.contentView.bounds.size.width - SHK_FORM_CELL_PAD_RIGHT - SHK_FORM_CELL_PAD_LEFT - labelWidth,
Expand Down Expand Up @@ -140,6 +143,7 @@ - (void)setValue:(NSString *)value
break;

case SHKFormFieldTypeText:
case SHKFormFieldTypeTextNoCorrect:
case SHKFormFieldTypePassword:
textField.text = value;
break;
Expand Down
1 change: 1 addition & 0 deletions Classes/ShareKit/UI/SHKFormFieldSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
typedef enum
{
SHKFormFieldTypeText,
SHKFormFieldTypeTextNoCorrect,
SHKFormFieldTypePassword,
SHKFormFieldTypeSwitch
} SHKFormFieldType;
Expand Down

0 comments on commit 1319600

Please sign in to comment.