Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:/overshare/overshare-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsinclair committed Jan 8, 2014
2 parents b1af8a4 + bf1bc5a commit 2bc9c45
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
6 changes: 5 additions & 1 deletion Overshare Kit/OSKMicroblogPublishingViewController.m
Expand Up @@ -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];
Expand Down
27 changes: 27 additions & 0 deletions Overshare Kit/OSKTextView.m
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 8 additions & 10 deletions Overshare Kit/OSKTwitterActivity.m
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2bc9c45

Please sign in to comment.