mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 08:12:40 +00:00
Merge pull request #1944 from vector-im/riot_1911
Replies: Implement sending
This commit is contained in:
commit
77d65684b5
5 changed files with 96 additions and 7 deletions
|
@ -4,6 +4,7 @@ Changes in 0.6.21 ()
|
|||
Improvements:
|
||||
* Update project structure. Organize UI related files by feature (PR#1932).
|
||||
* Move image files to xcassets (PR#1932).
|
||||
* Replies: Implement sending (#1911).
|
||||
|
||||
Changes in 0.6.20 (2018-07-13)
|
||||
===============================================
|
||||
|
|
|
@ -233,9 +233,12 @@
|
|||
"room_two_users_are_typing" = "%@ & %@ are typing…";
|
||||
"room_many_users_are_typing" = "%@, %@ & others are typing…";
|
||||
"room_message_placeholder" = "Send a message (unencrypted)…";
|
||||
"room_message_reply_to_placeholder" = "Send a reply (unencrypted)…";
|
||||
"room_do_not_have_permission_to_post" = "You do not have permission to post to this room";
|
||||
"encrypted_room_message_placeholder" = "Send an encrypted message…";
|
||||
"encrypted_room_message_reply_to_placeholder" = "Send an encrypted reply…";
|
||||
"room_message_short_placeholder" = "Send a message…";
|
||||
"room_message_reply_to_short_placeholder" = "Send a reply…";
|
||||
"room_offline_notification" = "Connectivity to the server has been lost.";
|
||||
"room_unsent_messages_notification" = "Messages not sent. %@ or %@ now?";
|
||||
"room_unsent_messages_unknown_devices_notification" = "Message not sent due to unknown devices being present. %@ or %@ now?";
|
||||
|
|
|
@ -118,6 +118,7 @@
|
|||
#import "StickerPickerViewController.h"
|
||||
|
||||
#import "EventFormatter.h"
|
||||
#import <MatrixKit/MXKSlashCommands.h>
|
||||
|
||||
#import "Riot-Swift.h"
|
||||
|
||||
|
@ -200,6 +201,9 @@
|
|||
|
||||
// Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change.
|
||||
id kRiotDesignValuesDidChangeThemeNotificationObserver;
|
||||
|
||||
// Tell whether the input text field is in send reply mode. If true typed message will be sent to highlighted event.
|
||||
BOOL isInReplyMode;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -984,15 +988,15 @@
|
|||
{
|
||||
// Override the default behavior for `/join` command in order to open automatically the joined room
|
||||
|
||||
if ([string hasPrefix:kCmdJoinRoom])
|
||||
if ([string hasPrefix:kMXKSlashCmdJoinRoom])
|
||||
{
|
||||
// Join a room
|
||||
NSString *roomAlias;
|
||||
|
||||
// Sanity check
|
||||
if (string.length > kCmdJoinRoom.length)
|
||||
if (string.length > kMXKSlashCmdJoinRoom.length)
|
||||
{
|
||||
roomAlias = [string substringFromIndex:kCmdJoinRoom.length + 1];
|
||||
roomAlias = [string substringFromIndex:kMXKSlashCmdJoinRoom.length + 1];
|
||||
|
||||
// Remove white space from both ends
|
||||
roomAlias = [roomAlias stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
|
@ -1074,6 +1078,28 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)sendTextMessage:(NSString*)msgTxt
|
||||
{
|
||||
if (isInReplyMode && customizedRoomDataSource.selectedEventId)
|
||||
{
|
||||
[self.roomDataSource sendReplyToEventWithId:customizedRoomDataSource.selectedEventId withTextMessage:msgTxt success:nil failure:^(NSError *error) {
|
||||
// Just log the error. The message will be displayed in red in the room history
|
||||
NSLog(@"[MXKRoomViewController] sendTextMessage failed.");
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let the datasource send it and manage the local echo
|
||||
[self.roomDataSource sendTextMessage:msgTxt success:nil failure:^(NSError *error)
|
||||
{
|
||||
// Just log the error. The message will be displayed in red in the room history
|
||||
NSLog(@"[MXKRoomViewController] sendTextMessage failed.");
|
||||
}];
|
||||
}
|
||||
|
||||
[self cancelEventSelection];
|
||||
}
|
||||
|
||||
- (void)destroy
|
||||
{
|
||||
rightBarButtonItems = nil;
|
||||
|
@ -1391,6 +1417,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)enableReplyMode:(BOOL)enable
|
||||
{
|
||||
isInReplyMode = enable;
|
||||
RoomInputToolbarView *roomInputToolbarView = (RoomInputToolbarView*)self.inputToolbarView;
|
||||
roomInputToolbarView.replyToEnabled = enable;
|
||||
}
|
||||
|
||||
- (void)onSwipeGesture:(UISwipeGestureRecognizer*)swipeGestureRecognizer
|
||||
{
|
||||
UIView *view = swipeGestureRecognizer.view;
|
||||
|
@ -1922,7 +1955,7 @@
|
|||
else if (tappedEvent)
|
||||
{
|
||||
// Highlight this event in displayed message
|
||||
customizedRoomDataSource.selectedEventId = tappedEvent.eventId;
|
||||
[self selectEventWithId:tappedEvent.eventId];
|
||||
}
|
||||
|
||||
// Force table refresh
|
||||
|
@ -1965,7 +1998,7 @@
|
|||
else
|
||||
{
|
||||
// Highlight this event in displayed message
|
||||
customizedRoomDataSource.selectedEventId = ((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.eventId;
|
||||
[self selectEventWithId:((MXKRoomBubbleTableViewCell*)cell).bubbleData.attachment.eventId];
|
||||
}
|
||||
|
||||
// Force table refresh
|
||||
|
@ -2717,8 +2750,19 @@
|
|||
return shouldDoAction;
|
||||
}
|
||||
|
||||
- (void)selectEventWithId:(NSString*)eventId
|
||||
{
|
||||
BOOL shouldEnableReplyMode = [self.roomDataSource canReplyToEventWithId:eventId];;
|
||||
|
||||
[self enableReplyMode:shouldEnableReplyMode];
|
||||
|
||||
customizedRoomDataSource.selectedEventId = eventId;
|
||||
}
|
||||
|
||||
- (void)cancelEventSelection
|
||||
{
|
||||
[self enableReplyMode:NO];
|
||||
|
||||
if (currentAlert)
|
||||
{
|
||||
[currentAlert dismissViewControllerAnimated:NO completion:nil];
|
||||
|
@ -2968,7 +3012,8 @@
|
|||
[super roomInputToolbarView:toolbarView isTyping:typing];
|
||||
|
||||
// Cancel potential selected event (to leave edition mode)
|
||||
if (typing && customizedRoomDataSource.selectedEventId)
|
||||
NSString *selectedEventId = customizedRoomDataSource.selectedEventId;
|
||||
if (typing && selectedEventId && ![self.roomDataSource canReplyToEventWithId:selectedEventId])
|
||||
{
|
||||
[self cancelEventSelection];
|
||||
}
|
||||
|
|
|
@ -69,6 +69,11 @@
|
|||
*/
|
||||
@property (nonatomic) BOOL isEncryptionEnabled;
|
||||
|
||||
/**
|
||||
Tell whether the input text will be a reply to a message.
|
||||
*/
|
||||
@property (nonatomic, getter=isReplyToEnabled) BOOL replyToEnabled;
|
||||
|
||||
/**
|
||||
Tell whether a call is active.
|
||||
*/
|
||||
|
|
|
@ -153,6 +153,41 @@
|
|||
self.placeholder = placeholder;
|
||||
}
|
||||
|
||||
- (void)setReplyToEnabled:(BOOL)isReplyToEnabled
|
||||
{
|
||||
_replyToEnabled = isReplyToEnabled;
|
||||
|
||||
[self updatePlaceholder];
|
||||
}
|
||||
|
||||
- (void)updatePlaceholder
|
||||
{
|
||||
// Consider the default placeholder
|
||||
|
||||
NSString *placeholder;
|
||||
|
||||
// Check the device screen size before using large placeholder
|
||||
BOOL shouldDisplayLargePlaceholder = [GBDeviceInfo deviceInfo].family == GBDeviceFamilyiPad || [GBDeviceInfo deviceInfo].displayInfo.display >= GBDeviceDisplay4p7Inch;
|
||||
|
||||
if (!shouldDisplayLargePlaceholder)
|
||||
{
|
||||
placeholder = _replyToEnabled ? NSLocalizedStringFromTable(@"room_message_reply_to_short_placeholder", @"Vector", nil) : NSLocalizedStringFromTable(@"room_message_short_placeholder", @"Vector", nil);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isEncryptionEnabled)
|
||||
{
|
||||
placeholder = _replyToEnabled ? NSLocalizedStringFromTable(@"encrypted_room_message_reply_to_placeholder", @"Vector", nil) : NSLocalizedStringFromTable(@"encrypted_room_message_placeholder", @"Vector", nil);
|
||||
}
|
||||
else
|
||||
{
|
||||
placeholder = _replyToEnabled ? NSLocalizedStringFromTable(@"room_message_reply_to_placeholder", @"Vector", nil) : NSLocalizedStringFromTable(@"room_message_placeholder", @"Vector", nil);
|
||||
}
|
||||
}
|
||||
|
||||
self.placeholder = placeholder;
|
||||
}
|
||||
|
||||
- (void)setActiveCall:(BOOL)activeCall
|
||||
{
|
||||
if (_activeCall != activeCall)
|
||||
|
|
Loading…
Reference in a new issue