diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.h b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.h index 802d31d02a..3f7ee27b80 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // NS_ASSUME_NONNULL_BEGIN @@ -48,8 +48,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)messageText; - (void)setMessageText:(NSString *_Nullable)value; - (void)clearTextMessage; - -- (nullable NSString *)textInputPrimaryLanguage; +- (void)toggleDefaultKeyboard; - (void)updateFontSizes; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index c5ddb7be1a..baa9d95c80 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -199,6 +199,26 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; [self.inputTextView.undoManager removeAllActions]; } +- (void)toggleDefaultKeyboard +{ + // Primary language is nil for the emoji keyboard. + if (!self.inputTextView.textInputMode.primaryLanguage) { + // Stay on emoji keyboard after sending + return; + } + + // Otherwise, we want to toggle back to default keyboard if the user had the numeric keyboard present. + + // Momentarily switch to a non-default keyboard, else reloadInputViews + // will not affect the displayed keyboard. In practice this isn't perceptable to the user. + // The alternative would be to dismiss-and-pop the keyboard, but that can cause a more pronounced animation. + self.inputTextView.keyboardType = UIKeyboardTypeNumbersAndPunctuation; + [self.inputTextView reloadInputViews]; + + self.inputTextView.keyboardType = UIKeyboardTypeDefault; + [self.inputTextView reloadInputViews]; +} + - (void)setShouldShowVoiceMemoButton:(BOOL)shouldShowVoiceMemoButton { if (_shouldShowVoiceMemoButton == shouldShowVoiceMemoButton) { @@ -827,11 +847,6 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; [self.attachmentView viewWillDisappear:animated]; } -- (nullable NSString *)textInputPrimaryLanguage -{ - return self.inputTextView.textInputMode.primaryLanguage; -} - @end NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index a7d1a071f4..4e9aa5d535 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1394,17 +1394,6 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) { #pragma mark - JSQMessagesViewController method overrides -- (void)toggleDefaultKeyboard -{ - // Primary language is nil for the emoji keyboard & we want to stay on it after sending - if (!self.inputToolbar.textInputPrimaryLanguage) { - return; - } - - [self dismissKeyBoard]; - [self popKeyBoard]; -} - #pragma mark - Dynamic Text /** @@ -3902,10 +3891,10 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) { [self messageWasSent:message]; if (updateKeyboardState) { - [self toggleDefaultKeyboard]; + [self.inputToolbar toggleDefaultKeyboard]; } - [self clearDraft]; [self.inputToolbar clearTextMessage]; + [self clearDraft]; if (didAddToProfileWhitelist) { [self ensureDynamicInteractions]; }