Fix long press on quoted reply.

pull/1/head
Matthew Chen 7 years ago
parent 30943a1c17
commit ea82419a40

@ -511,9 +511,11 @@ NS_ASSUME_NONNULL_BEGIN
[self showMediaMenuController:location]; [self showMediaMenuController:location];
break; break;
} }
case OWSMessageGestureLocation_QuotedReply: case OWSMessageGestureLocation_QuotedReply: {
// TODO: CGPoint location = [sender locationInView:self];
[self showDefaultMenuController:location];
break; break;
}
} }
} }
@ -528,28 +530,26 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showTextMenuController:(CGPoint)fromLocation - (void)showTextMenuController:(CGPoint)fromLocation
{ {
// We don't want taps on messages to hide the keyboard, [self showMenuController:fromLocation menuItems:self.viewItem.textMenuControllerItems];
// 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) { - (void)showMediaMenuController:(CGPoint)fromLocation
[[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO]; {
} [self showMenuController:fromLocation menuItems:self.viewItem.mediaMenuControllerItems];
}
// We use custom action selectors so that we can control - (void)showDefaultMenuController:(CGPoint)fromLocation
// the ordering of the actions in the menu. {
NSArray *menuItems = self.viewItem.textMenuControllerItems; [self showMenuController:fromLocation menuItems:self.viewItem.defaultMenuControllerItems];
[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];
} }
- (void)showMediaMenuController:(CGPoint)fromLocation - (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, // We don't want taps on messages to hide the keyboard,
// so we only let messages become first responder // so we only let messages become first responder
// while they are trying to present the menu controller. // 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 // We use custom action selectors so that we can control
// the ordering of the actions in the menu. // the ordering of the actions in the menu.
NSArray *menuItems = self.viewItem.mediaMenuControllerItems;
[UIMenuController sharedMenuController].menuItems = menuItems; [UIMenuController sharedMenuController].menuItems = menuItems;
CGRect targetRect = CGRectMake(fromLocation.x, fromLocation.y, 1, 1); CGRect targetRect = CGRectMake(fromLocation.x, fromLocation.y, 1, 1);
[[UIMenuController sharedMenuController] setTargetRect:targetRect inView:self]; [[UIMenuController sharedMenuController] setTargetRect:targetRect inView:self];

@ -105,6 +105,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
- (NSArray<UIMenuItem *> *)textMenuControllerItems; - (NSArray<UIMenuItem *> *)textMenuControllerItems;
- (NSArray<UIMenuItem *> *)mediaMenuControllerItems; - (NSArray<UIMenuItem *> *)mediaMenuControllerItems;
- (NSArray<UIMenuItem *> *)defaultMenuControllerItems;
- (BOOL)canPerformAction:(SEL)action; - (BOOL)canPerformAction:(SEL)action;
- (void)copyMediaAction; - (void)copyMediaAction;

@ -565,6 +565,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
action:self.deleteActionSelector] action:self.deleteActionSelector]
]; ];
} }
- (NSArray<UIMenuItem *> *)mediaMenuControllerItems - (NSArray<UIMenuItem *> *)mediaMenuControllerItems
{ {
return @[ 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 - (SEL)copyTextActionSelector
{ {
return NSSelectorFromString(@"copyTextAction:"); return NSSelectorFromString(@"copyTextAction:");

Loading…
Cancel
Save