Fix keyboard animation glitch after sending

// FREEBIE
This commit is contained in:
Michael Kirk 2018-01-08 17:48:26 -05:00 committed by Matthew Chen
parent e11ac51e31
commit 74019b2ae4
3 changed files with 24 additions and 21 deletions

View File

@ -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;

View File

@ -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

View File

@ -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];
}