diff --git a/Podfile b/Podfile index 0cb651d7a..a91634b28 100644 --- a/Podfile +++ b/Podfile @@ -56,7 +56,6 @@ abstract_target 'RiotPods' do # Remove warnings from "bad" pods pod 'OLMKit', :inhibit_warnings => true pod 'zxcvbn-ios', :inhibit_warnings => true - pod 'HPGrowingTextView', :inhibit_warnings => true # Tools pod 'SwiftGen', '~> 6.3' @@ -74,6 +73,7 @@ abstract_target 'RiotPods' do pod 'SideMenu', '~> 6.5' pod 'DSWaveformImage', '~> 6.1.1' pod 'ffmpeg-kit-ios-audio', '~> 4.5' + pod 'GrowingTextView', '~> 0.7.2' pod 'FLEX', '~> 4.5.0', :configurations => ['Debug'] diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 2052c6a6a..c86695012 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -1843,13 +1843,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [self checkLocalPrivateKeysInSession:mxSession]; [self.pushNotificationService checkPushKitPushersInSession:mxSession]; - - // Validate the availability of local contact sync for any changes to the - // authorization of contacts access that may have occurred since the last launch. - if (BuildSettings.allowLocalContactsAccess) - { - [MXKContactManager.sharedManager validateSyncLocalContactsState]; - } } else if (mxSession.state == MXSessionStateClosed) { diff --git a/Riot/Modules/Room/Views/InputToolbar/KeyboardGrowingTextView.m b/Riot/Modules/Room/Views/InputToolbar/KeyboardGrowingTextView.m deleted file mode 100644 index 9fe8d69f1..000000000 --- a/Riot/Modules/Room/Views/InputToolbar/KeyboardGrowingTextView.m +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright 2015 OpenMarket Ltd - Copyright 2017 Vector Creations Ltd - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#import -#import -#import "RoomInputToolbarView.h" - -@interface KeyboardGrowingTextView: HPGrowingTextView -- (NSArray *)keyCommands; -@end - -@implementation KeyboardGrowingTextView - -- (NSArray *)keyCommands { - return @[ - [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(keyCommandSelector:)] - ]; -} - -- (void)keyCommandSelector:(UIKeyCommand *)sender { - if ([sender.input isEqualToString:@"\r"] && [self.delegate isKindOfClass: RoomInputToolbarView.class]){ - RoomInputToolbarView *ritv = (RoomInputToolbarView *)self.delegate; - [ritv onTouchUpInside:ritv.rightInputToolbarButton]; // touch the Send button. - } -} - -@end diff --git a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarTextView.swift b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarTextView.swift new file mode 100644 index 000000000..ad769b52e --- /dev/null +++ b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarTextView.swift @@ -0,0 +1,32 @@ +// +// Copyright 2021 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import GrowingTextView + +class RoomInputToolbarTextView: GrowingTextView { + + override var keyCommands: [UIKeyCommand]? { + return [UIKeyCommand(input: "\r", modifierFlags: [], action: #selector(keyCommandSelector(_:)))] + } + + @objc private func keyCommandSelector(_ keyCommand: UIKeyCommand) { + guard keyCommand.input == "\r", let delegate = (self.delegate as? RoomInputToolbarView) else { + return + } + + delegate.onTouchUp(inside: delegate.rightInputToolbarButton) + } +} diff --git a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.h b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.h index 430daa2bf..8e5057db0 100644 --- a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.h +++ b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.h @@ -46,7 +46,7 @@ typedef enum : NSUInteger `RoomInputToolbarView` instance is a view used to handle all kinds of available inputs for a room (message composer, attachments selection...). */ -@interface RoomInputToolbarView : MXKRoomInputToolbarViewWithHPGrowingText +@interface RoomInputToolbarView : MXKRoomInputToolbarView /** The delegate notified when inputs are ready. diff --git a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.m b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.m index a0ab6b833..5c8fab5ec 100644 --- a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.m +++ b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.m @@ -27,6 +27,8 @@ #import "WidgetManager.h" #import "IntegrationManagerViewController.h" +@import GrowingTextView; + const double kContextBarHeight = 24; const NSTimeInterval kSendModeAnimationDuration = .15; const NSTimeInterval kActionMenuAttachButtonAnimationDuration = .4; @@ -36,12 +38,15 @@ const NSTimeInterval kActionMenuContentAlphaAnimationDuration = .2; const NSTimeInterval kActionMenuComposerHeightAnimationDuration = .3; const CGFloat kComposerContainerTrailingPadding = 12; -@interface RoomInputToolbarView() +@interface RoomInputToolbarView() { // The intermediate action sheet UIAlertController *actionSheet; } +@property (nonatomic, weak) IBOutlet RoomInputToolbarTextView *textView; +@property (nonatomic, assign) CGFloat expandedMainToolbarHeight; + @end @implementation RoomInputToolbarView @@ -102,21 +107,21 @@ const CGFloat kComposerContainerTrailingPadding = 12; self.backgroundColor = [UIColor clearColor]; // Custom the growingTextView display - growingTextView.layer.cornerRadius = 0; - growingTextView.layer.borderWidth = 0; - growingTextView.backgroundColor = [UIColor clearColor]; + self.textView.layer.cornerRadius = 0; + self.textView.layer.borderWidth = 0; + self.textView.backgroundColor = [UIColor clearColor]; + + self.textView.font = [UIFont systemFontOfSize:15]; + self.textView.textColor = ThemeService.shared.theme.textPrimaryColor; + self.textView.tintColor = ThemeService.shared.theme.tintColor; + self.textView.placeholderColor = ThemeService.shared.theme.textTertiaryColor; + self.textView.showsVerticalScrollIndicator = NO; - growingTextView.font = [UIFont systemFontOfSize:15]; - growingTextView.textColor = ThemeService.shared.theme.textPrimaryColor; - growingTextView.tintColor = ThemeService.shared.theme.tintColor; - growingTextView.placeholderColor = ThemeService.shared.theme.textTertiaryColor; - growingTextView.internalTextView.showsVerticalScrollIndicator = NO; - - growingTextView.internalTextView.keyboardAppearance = ThemeService.shared.theme.keyboardAppearance; - if (growingTextView.isFirstResponder) + self.textView.keyboardAppearance = ThemeService.shared.theme.keyboardAppearance; + if (self.textView.isFirstResponder) { - [growingTextView resignFirstResponder]; - [growingTextView becomeFirstResponder]; + [self.textView resignFirstResponder]; + [self.textView becomeFirstResponder]; } self.attachMediaButton.accessibilityLabel = [VectorL10n roomAccessibilityUpload]; @@ -148,8 +153,15 @@ const CGFloat kComposerContainerTrailingPadding = 12; - (void)setTextMessage:(NSString *)textMessage { - [self updateUIWithTextMessage:textMessage animated:YES]; [super setTextMessage:textMessage]; + + self.textView.text = textMessage; + [self updateUIWithTextMessage:textMessage animated:YES]; +} + +- (NSString *)textMessage +{ + return self.textView.text; } - (void)setIsEncryptionEnabled:(BOOL)isEncryptionEnabled @@ -184,7 +196,7 @@ const CGFloat kComposerContainerTrailingPadding = 12; self.inputContextViewHeightConstraint.constant = kContextBarHeight; updatedHeight += kContextBarHeight; - self->growingTextView.maxHeight -= kContextBarHeight; + self.textView.maxHeight -= kContextBarHeight; break; case RoomInputToolbarViewSendModeEdit: buttonImage = [UIImage imageNamed:@"save_icon"]; @@ -193,7 +205,7 @@ const CGFloat kComposerContainerTrailingPadding = 12; self.inputContextViewHeightConstraint.constant = kContextBarHeight; updatedHeight += kContextBarHeight; - self->growingTextView.maxHeight -= kContextBarHeight; + self.textView.maxHeight -= kContextBarHeight; break; default: buttonImage = [UIImage imageNamed:@"send_icon"]; @@ -201,7 +213,7 @@ const CGFloat kComposerContainerTrailingPadding = 12; if (previousMode != _sendMode) { updatedHeight -= kContextBarHeight; - self->growingTextView.maxHeight += kContextBarHeight; + self.textView.maxHeight += kContextBarHeight; } self.inputContextViewHeightConstraint.constant = 0; break; @@ -211,7 +223,7 @@ const CGFloat kComposerContainerTrailingPadding = 12; if (self.maxHeight && updatedHeight > self.maxHeight) { - growingTextView.maxHeight -= updatedHeight - self.maxHeight; + self.textView.maxHeight -= updatedHeight - self.maxHeight; updatedHeight = self.maxHeight; } @@ -290,6 +302,12 @@ const CGFloat kComposerContainerTrailingPadding = 12; self.placeholder = placeholder; } +- (void)setPlaceholder:(NSString *)inPlaceholder +{ + [super setPlaceholder:inPlaceholder]; + self.textView.placeholder = inPlaceholder; +} + #pragma mark - Actions - (IBAction)cancelAction:(id)sender @@ -300,17 +318,17 @@ const CGFloat kComposerContainerTrailingPadding = 12; } } -#pragma mark - HPGrowingTextView delegate +#pragma mark - GrowingTextViewDelegate -- (BOOL)growingTextView:(HPGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text +- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { - NSString *newText = [growingTextView.text stringByReplacingCharactersInRange:range withString:text]; + NSString *newText = [textView.text stringByReplacingCharactersInRange:range withString:text]; [self updateUIWithTextMessage:newText animated:YES]; - + return YES; } -- (void)growingTextViewDidChange:(HPGrowingTextView *)hpGrowingTextView +- (void)textViewDidChange:(UITextView *)textView { // Clean the carriage return added on return press if ([self.textMessage isEqualToString:@"\n"]) @@ -318,17 +336,20 @@ const CGFloat kComposerContainerTrailingPadding = 12; self.textMessage = nil; } - [super growingTextViewDidChange:hpGrowingTextView]; + if ([self.delegate respondsToSelector:@selector(roomInputToolbarView:isTyping:)]) + { + [self.delegate roomInputToolbarView:self isTyping:(self.textMessage.length > 0 ? YES : NO)]; + } } -- (void)growingTextView:(HPGrowingTextView *)hpGrowingTextView willChangeHeight:(float)height +- (void)textViewDidChangeHeight:(GrowingTextView *)textView height:(CGFloat)height { // Update height of the main toolbar (message composer) CGFloat updatedHeight = height + (self.messageComposerContainerTopConstraint.constant + self.messageComposerContainerBottomConstraint.constant) + self.inputContextViewHeightConstraint.constant; - + if (self.maxHeight && updatedHeight > self.maxHeight) { - hpGrowingTextView.maxHeight -= updatedHeight - self.maxHeight; + textView.maxHeight -= updatedHeight - self.maxHeight; updatedHeight = self.maxHeight; } @@ -336,9 +357,9 @@ const CGFloat kComposerContainerTrailingPadding = 12; { updatedHeight = self.mainToolbarMinHeightConstraint.constant; } - + self.mainToolbarHeightConstraint.constant = updatedHeight; - + // Update toolbar superview if ([self.delegate respondsToSelector:@selector(roomInputToolbarView:heightDidChanged:completion:)]) { @@ -377,12 +398,12 @@ const CGFloat kComposerContainerTrailingPadding = 12; { _actionMenuOpened = actionMenuOpened; - if (self->growingTextView.internalTextView.selectedRange.length > 0) + if (self.textView.selectedRange.length > 0) { - NSRange range = self->growingTextView.internalTextView.selectedRange; + NSRange range = self.textView.selectedRange; range.location = range.location + range.length; range.length = 0; - self->growingTextView.internalTextView.selectedRange = range; + self.textView.selectedRange = range; } if (_actionMenuOpened) { @@ -402,18 +423,19 @@ const CGFloat kComposerContainerTrailingPadding = 12; [UIView animateWithDuration:kActionMenuContentAlphaAnimationDuration delay:_actionMenuOpened ? 0 : .1 options:UIViewAnimationOptionCurveEaseIn animations:^{ self->messageComposerContainer.alpha = actionMenuOpened ? 0 : 1; - self.rightInputToolbarButton.alpha = self->growingTextView.text.length == 0 || actionMenuOpened ? 0 : 1; - self.voiceMessageToolbarView.alpha = self->growingTextView.text.length > 0 || actionMenuOpened ? 0 : 1; + self.rightInputToolbarButton.alpha = self.textView.text.length == 0 || actionMenuOpened ? 0 : 1; + self.voiceMessageToolbarView.alpha = self.textView.text.length > 0 || actionMenuOpened ? 0 : 1; } completion:nil]; [UIView animateWithDuration:kActionMenuComposerHeightAnimationDuration animations:^{ if (actionMenuOpened) { + self.expandedMainToolbarHeight = self.mainToolbarHeightConstraint.constant; self.mainToolbarHeightConstraint.constant = self.mainToolbarMinHeightConstraint.constant; } else { - [self->growingTextView refreshHeight]; + self.mainToolbarHeightConstraint.constant = self.expandedMainToolbarHeight; } [self layoutIfNeeded]; [self.delegate roomInputToolbarView:self heightDidChanged:self.mainToolbarHeightConstraint.constant completion:nil]; @@ -438,6 +460,8 @@ const CGFloat kComposerContainerTrailingPadding = 12; [UIView animateWithDuration:(animated ? 0.15f : 0.0f) animations:^{ self.rightInputToolbarButton.alpha = textMessage.length ? 1.0f : 0.0f; + self.rightInputToolbarButton.enabled = textMessage.length; + self.voiceMessageToolbarView.alpha = textMessage.length ? 0.0f : 1.0; }]; } diff --git a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.xib b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.xib index f0f0c35b3..ff1cee7be 100644 --- a/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.xib +++ b/Riot/Modules/Room/Views/InputToolbar/RoomInputToolbarView.xib @@ -1,9 +1,9 @@ - + - + @@ -77,10 +77,13 @@ - + + + + @@ -138,7 +141,6 @@ - @@ -152,6 +154,7 @@ + diff --git a/Riot/SupportingFiles/Riot-Bridging-Header.h b/Riot/SupportingFiles/Riot-Bridging-Header.h index 3659fe244..68dff2986 100644 --- a/Riot/SupportingFiles/Riot-Bridging-Header.h +++ b/Riot/SupportingFiles/Riot-Bridging-Header.h @@ -43,4 +43,5 @@ #import "RoomViewController.h" #import "ContactDetailsViewController.h" #import "GroupDetailsViewController.h" +#import "RoomInputToolbarView.h" #import "NSArray+Element.h" diff --git a/changelog.d/4976.misc b/changelog.d/4976.misc new file mode 100644 index 000000000..882070b8d --- /dev/null +++ b/changelog.d/4976.misc @@ -0,0 +1 @@ +Replaced deprecated HPGrowingTextView with GrowingTextView. \ No newline at end of file diff --git a/changelog.d/4989.bugfix b/changelog.d/4989.bugfix new file mode 100644 index 000000000..bc127643a --- /dev/null +++ b/changelog.d/4989.bugfix @@ -0,0 +1 @@ +Contacts Sync: Move call to validateSyncLocalContactsState into MatrixKit. \ No newline at end of file