From 9b377f3305acf3c34fa570f87dfea3681d0233d8 Mon Sep 17 00:00:00 2001 From: Jared Sinclair Date: Tue, 7 Jan 2014 16:22:23 -0500 Subject: [PATCH 1/2] Fixed bugs that cause the kb to change appearance/type/return keys when the attachment removal UIMenuController popover is visible. --- Overshare Kit/OSKTextView.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Overshare Kit/OSKTextView.m b/Overshare Kit/OSKTextView.m index 0844253..d704cf2 100644 --- a/Overshare Kit/OSKTextView.m +++ b/Overshare Kit/OSKTextView.m @@ -147,6 +147,9 @@ - (void)attachmentViewDidTapRemove:(OSKTextViewAttachmentView *)view; - (BOOL)attachmentViewShouldReportHasText:(OSKTextViewAttachmentView *)view; - (void)attachmentView:(OSKTextViewAttachmentView *)view didInsertText:(NSString *)text; - (void)attachmentViewDidDeleteBackward:(OSKTextViewAttachmentView *)view; +- (UIKeyboardAppearance)attachmentViewKeyboardAppearance:(OSKTextViewAttachmentView *)view; +- (UIKeyboardType)attachmentViewKeyboardType:(OSKTextViewAttachmentView *)view; +- (UIReturnKeyType)attachmentViewReturnKeyType:(OSKTextViewAttachmentView *)view; @end @@ -224,6 +227,18 @@ - (void)deleteBackward { [self.delegate attachmentViewDidDeleteBackward:self]; } +- (UIKeyboardAppearance)keyboardAppearance { + return [self.delegate attachmentViewKeyboardAppearance:self]; +} + +- (UIKeyboardType)keyboardType { + return [self.delegate attachmentViewKeyboardType:self]; +} + +- (UIReturnKeyType)returnKeyType { + return [self.delegate attachmentViewReturnKeyType:self]; +} + #pragma mark - KVO - (void)addObservationsToAttachment:(OSKTextViewAttachment *)attachment { @@ -1195,6 +1210,18 @@ - (void)attachmentViewDidDeleteBackward:(OSKTextViewAttachmentView *)view { [self.textView deleteBackward]; } +- (UIKeyboardAppearance)attachmentViewKeyboardAppearance:(OSKTextViewAttachmentView *)view { + return self.textView.keyboardAppearance; +} + +- (UIKeyboardType)attachmentViewKeyboardType:(OSKTextViewAttachmentView *)view { + return self.textView.keyboardType; +} + +- (UIReturnKeyType)attachmentViewReturnKeyType:(OSKTextViewAttachmentView *)view { + return self.textView.returnKeyType; +} + #pragma mark - Removing Attachments - (void)removeAttachment { From bf1bc5a136e9df2c453d12f6be5210518d33dd9b Mon Sep 17 00:00:00 2001 From: Jared Sinclair Date: Tue, 7 Jan 2014 23:48:03 -0500 Subject: [PATCH 2/2] Fix dumb errors with remaining character counts. --- .../OSKMicroblogPublishingViewController.m | 6 +++++- Overshare Kit/OSKTwitterActivity.m | 18 ++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Overshare Kit/OSKMicroblogPublishingViewController.m b/Overshare Kit/OSKMicroblogPublishingViewController.m index 75db892..2444f06 100644 --- a/Overshare Kit/OSKMicroblogPublishingViewController.m +++ b/Overshare Kit/OSKMicroblogPublishingViewController.m @@ -511,7 +511,11 @@ - (void)showSystemAccountChooser { - (void)updateRemainingCharacterCountLabel { NSInteger countAdjustingForEmoji = [self.textView.attributedText.string lengthOfBytesUsingEncoding:NSUTF32StringEncoding]/4; - NSInteger remaining = [self.activity maximumCharacterCount] - countAdjustingForEmoji - _reservedLengthForAttachmentURL; + NSInteger remaining = [self.activity maximumCharacterCount] - countAdjustingForEmoji; + if (self.contentItem.images.count) { + NSUInteger numberToBeAttached = MIN([self.activity maximumImageCount], self.contentItem.images.count); + remaining -= numberToBeAttached * _reservedLengthForAttachmentURL; + } self.characterCountLabel.text = @(remaining).stringValue; if (_characterCount_normalColor == nil) { OSKPresentationManager *presManager = [OSKPresentationManager sharedInstance]; diff --git a/Overshare Kit/OSKTwitterActivity.m b/Overshare Kit/OSKTwitterActivity.m index 49e70de..dd4dc77 100644 --- a/Overshare Kit/OSKTwitterActivity.m +++ b/Overshare Kit/OSKTwitterActivity.m @@ -90,10 +90,14 @@ + (OSKPublishingViewControllerType)publishingViewControllerType { - (BOOL)isReadyToPerform { BOOL accountPresent = (self.activeSystemAccount != nil); - + + NSInteger totalAvailableCharacters = [self maximumCharacterCount]; OSKMicroblogPostContentItem *contentItem = (OSKMicroblogPostContentItem *)self.contentItem; - NSInteger maxCharacterCount = [self maximumCharacterCount]; - BOOL textIsValid = (contentItem.text.length > 0 && contentItem.text.length <= maxCharacterCount); + if (contentItem.images.count) { + NSUInteger attachmentLength = (_estimatedLengthOfAttachmentURL.integerValue) ? _estimatedLengthOfAttachmentURL.integerValue : 24; + totalAvailableCharacters -= attachmentLength; // We only ever send the first image in the array, due to API limits. + } + BOOL textIsValid = (contentItem.text.length > 0 && contentItem.text.length <= totalAvailableCharacters); return (accountPresent && textIsValid); } @@ -127,13 +131,7 @@ - (OSKActivityOperation *)operationForActivityWithCompletion:(OSKActivityComplet #pragma mark - Microblogging Activity Protocol - (NSInteger)maximumCharacterCount { - NSInteger count = OSKTwitterActivity_MaxCharacterCount; - OSKMicroblogPostContentItem *contentItem = (OSKMicroblogPostContentItem *)self.contentItem; - if (contentItem.images.count) { - NSUInteger attachmentLength = (_estimatedLengthOfAttachmentURL.integerValue) ? _estimatedLengthOfAttachmentURL.integerValue : 24; - count -= attachmentLength; // We only ever send the first image in the array, due to API limits. - } - return count; + return OSKTwitterActivity_MaxCharacterCount; } - (NSInteger)maximumImageCount {