From a59f49ceacdf57ad7923434d0807f62d5a2162c3 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 21 Apr 2017 14:58:51 -0400 Subject: [PATCH 1/2] Resolve the menu item conflicts between message view and media view. // FREEBIE --- .../ViewControllers/FullImageViewController.m | 10 ++++++++ .../ViewControllers/MessagesViewController.m | 25 ++++++++++++------- .../translations/en.lproj/Localizable.strings | 3 +++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Signal/src/ViewControllers/FullImageViewController.m b/Signal/src/ViewControllers/FullImageViewController.m index 5bf3b60a4..33e4e5020 100644 --- a/Signal/src/ViewControllers/FullImageViewController.m +++ b/Signal/src/ViewControllers/FullImageViewController.m @@ -60,6 +60,7 @@ @property (nonatomic) id messageItem; @property (nonatomic) UIToolbar *footerBar; +@property (nonatomic) NSArray *oldMenuItems; @end @@ -257,6 +258,9 @@ [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_SHARE_ACTION", @"Short name for edit menu item to share contents of media message.") action:@selector(shareAttachment:)], ]; + if (!self.oldMenuItems) { + self.oldMenuItems = [UIMenuController sharedMenuController].menuItems; + } [UIMenuController sharedMenuController].menuItems = menuItems; CGPoint location = [sender locationInView:self.view]; CGRect targetRect = CGRectMake(location.x, @@ -342,6 +346,12 @@ } - (void)dismiss { + + // Restore the edit menu items if necessary. + if (self.oldMenuItems) { + [UIMenuController sharedMenuController].menuItems = self.oldMenuItems; + } + self.view.userInteractionEnabled = NO; [UIView animateWithDuration:0.25f delay:0 diff --git a/Signal/src/ViewControllers/MessagesViewController.m b/Signal/src/ViewControllers/MessagesViewController.m index a84002d96..40bdfd1f3 100644 --- a/Signal/src/ViewControllers/MessagesViewController.m +++ b/Signal/src/ViewControllers/MessagesViewController.m @@ -556,13 +556,20 @@ typedef enum : NSUInteger { // need to set them every time we enter this view. SEL saveSelector = NSSelectorFromString(@"save:"); SEL shareSelector = NSSelectorFromString(@"share:"); - [UIMenuController sharedMenuController].menuItems = @[ [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_SAVE_ACTION", - @"Short name for edit menu item to save contents of media message.") - action:saveSelector], - [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_SHARE_ACTION", - @"Short name for edit menu item to share contents of media message.") - action:shareSelector], - ]; + [UIMenuController sharedMenuController].menuItems = @[ + [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_SAVE_ACTION", + @"Short name for edit menu item to save contents of media message.") + action:saveSelector], + [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_SHARE_ACTION", + @"Short name for edit menu item to share contents of media message.") + action:shareSelector], + [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_COPY_ACTION", + @"Short name for edit menu item to copy contents of media message.") + action:@selector(copy:)], + [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"EDIT_ITEM_DELETE_ACTION", + @"Short name for edit menu item to delete contents of media message.") + action:@selector(delete:)], + ]; [self ensureBlockStateIndicator]; @@ -1720,7 +1727,7 @@ typedef enum : NSUInteger { messageItem:messageItem isAnimated:NO]; - [vc presentFromViewController:self.navigationController]; + [vc presentFromViewController:self]; } } } else if ([[messageItem media] isKindOfClass:[TSAnimatedAdapter class]]) { @@ -1749,7 +1756,7 @@ typedef enum : NSUInteger { forInteraction:interaction messageItem:messageItem isAnimated:YES]; - [vc presentFromViewController:self.navigationController]; + [vc presentFromViewController:self]; } } } else if ([[messageItem media] isKindOfClass:[TSVideoAttachmentAdapter class]]) { diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 0cdff1500..d6dd162d6 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -325,6 +325,9 @@ /* Short name for edit menu item to share contents of media message. */ "EDIT_ITEM_SHARE_ACTION" = "Share"; +/* Short name for edit menu item to share contents of media message. */ +"EDIT_ITEM_DELETE_ACTION" = "Delete"; + /* body of email sent to contacts when inviting to install Signal. Embeds {{link to install Signal}} and {{link to WhisperSystems home page}} */ "EMAIL_INVITE_BODY" = "Hey,\n\nLately I've been using Signal to keep the conversations on my iPhone private. I'd like you to install it too, so we can be confident that only you and I can read our messages or hear our calls.\n\nSignal is available for iPhones and Android. Get it here: %@\n\nSignal works like your existing messaging app. We can send pictures and video, make calls, and start group chats. The best part is, no one else can see any of it, not even the people who make Signal!\n\nYou can read more about Open Whisper Systems, the people who make Signal, here: %@"; From 5cbbf500596d735872b81f81469ba63301ce9029 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 21 Apr 2017 15:39:29 -0400 Subject: [PATCH 2/2] Respond to CR. // FREEBIE --- Signal/translations/en.lproj/Localizable.strings | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index d6dd162d6..65c1d1d4f 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -319,15 +319,15 @@ /* Short name for edit menu item to copy contents of media message. */ "EDIT_ITEM_COPY_ACTION" = "Copy"; +/* Short name for edit menu item to delete contents of media message. */ +"EDIT_ITEM_DELETE_ACTION" = "Delete"; + /* Short name for edit menu item to save contents of media message. */ "EDIT_ITEM_SAVE_ACTION" = "Save"; /* Short name for edit menu item to share contents of media message. */ "EDIT_ITEM_SHARE_ACTION" = "Share"; -/* Short name for edit menu item to share contents of media message. */ -"EDIT_ITEM_DELETE_ACTION" = "Delete"; - /* body of email sent to contacts when inviting to install Signal. Embeds {{link to install Signal}} and {{link to WhisperSystems home page}} */ "EMAIL_INVITE_BODY" = "Hey,\n\nLately I've been using Signal to keep the conversations on my iPhone private. I'd like you to install it too, so we can be confident that only you and I can read our messages or hear our calls.\n\nSignal is available for iPhones and Android. Get it here: %@\n\nSignal works like your existing messaging app. We can send pictures and video, make calls, and start group chats. The best part is, no one else can see any of it, not even the people who make Signal!\n\nYou can read more about Open Whisper Systems, the people who make Signal, here: %@";