Merge branch 'charlesmchen/longPressQuotedReply'
This commit is contained in:
commit
fb27d496e6
@ -511,9 +511,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[self showMediaMenuController:location];
|
||||
break;
|
||||
}
|
||||
case OWSMessageGestureLocation_QuotedReply:
|
||||
// TODO:
|
||||
case OWSMessageGestureLocation_QuotedReply: {
|
||||
CGPoint location = [sender locationInView:self];
|
||||
[self showDefaultMenuController:location];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -528,28 +530,26 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)showTextMenuController:(CGPoint)fromLocation
|
||||
{
|
||||
// We don't want taps on messages to hide the keyboard,
|
||||
// so we only let messages become first responder
|
||||
// while they are trying to present the menu controller.
|
||||
self.isPresentingMenuController = YES;
|
||||
|
||||
[self becomeFirstResponder];
|
||||
|
||||
if ([UIMenuController sharedMenuController].isMenuVisible) {
|
||||
[[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
|
||||
}
|
||||
|
||||
// We use custom action selectors so that we can control
|
||||
// the ordering of the actions in the menu.
|
||||
NSArray *menuItems = self.viewItem.textMenuControllerItems;
|
||||
[UIMenuController sharedMenuController].menuItems = menuItems;
|
||||
CGRect targetRect = CGRectMake(fromLocation.x, fromLocation.y, 1, 1);
|
||||
[[UIMenuController sharedMenuController] setTargetRect:targetRect inView:self];
|
||||
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
|
||||
[self showMenuController:fromLocation menuItems:self.viewItem.textMenuControllerItems];
|
||||
}
|
||||
|
||||
- (void)showMediaMenuController:(CGPoint)fromLocation
|
||||
{
|
||||
[self showMenuController:fromLocation menuItems:self.viewItem.mediaMenuControllerItems];
|
||||
}
|
||||
|
||||
- (void)showDefaultMenuController:(CGPoint)fromLocation
|
||||
{
|
||||
[self showMenuController:fromLocation menuItems:self.viewItem.defaultMenuControllerItems];
|
||||
}
|
||||
|
||||
- (void)showMenuController:(CGPoint)fromLocation menuItems:(NSArray *)menuItems
|
||||
{
|
||||
if (menuItems.count < 1) {
|
||||
OWSFail(@"%@ No menu items to present.", self.logTag);
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't want taps on messages to hide the keyboard,
|
||||
// so we only let messages become first responder
|
||||
// while they are trying to present the menu controller.
|
||||
@ -563,7 +563,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// We use custom action selectors so that we can control
|
||||
// the ordering of the actions in the menu.
|
||||
NSArray *menuItems = self.viewItem.mediaMenuControllerItems;
|
||||
[UIMenuController sharedMenuController].menuItems = menuItems;
|
||||
CGRect targetRect = CGRectMake(fromLocation.x, fromLocation.y, 1, 1);
|
||||
[[UIMenuController sharedMenuController] setTargetRect:targetRect inView:self];
|
||||
|
||||
@ -105,6 +105,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
|
||||
|
||||
- (NSArray<UIMenuItem *> *)textMenuControllerItems;
|
||||
- (NSArray<UIMenuItem *> *)mediaMenuControllerItems;
|
||||
- (NSArray<UIMenuItem *> *)defaultMenuControllerItems;
|
||||
|
||||
- (BOOL)canPerformAction:(SEL)action;
|
||||
- (void)copyMediaAction;
|
||||
|
||||
@ -565,6 +565,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
||||
action:self.deleteActionSelector]
|
||||
];
|
||||
}
|
||||
|
||||
- (NSArray<UIMenuItem *> *)mediaMenuControllerItems
|
||||
{
|
||||
return @[
|
||||
@ -586,6 +587,21 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
||||
];
|
||||
}
|
||||
|
||||
- (NSArray<UIMenuItem *> *)defaultMenuControllerItems
|
||||
{
|
||||
return @[
|
||||
[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_MESSAGE_METADATA_ACTION",
|
||||
@"Short name for edit menu item to show message metadata.")
|
||||
action:self.metadataActionSelector],
|
||||
[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"REPLY_ITEM_ACTION",
|
||||
@"Short name for edit menu item to reply to a message.")
|
||||
action:self.replyActionSelector],
|
||||
[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_DELETE_ACTION",
|
||||
@"Short name for edit menu item to delete contents of media message.")
|
||||
action:self.deleteActionSelector],
|
||||
];
|
||||
}
|
||||
|
||||
- (SEL)copyTextActionSelector
|
||||
{
|
||||
return NSSelectorFromString(@"copyTextAction:");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user