From effcae4bd9ed24920b5ff98d55e3003200e55407 Mon Sep 17 00:00:00 2001 From: Simon Wiedmer Date: Mon, 7 Jun 2021 11:21:34 +0200 Subject: [PATCH 1/3] Add 'Dial pad' option to plus menu on homescreen --- .../Common/Recents/RecentsViewController.m | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index d559f64d0..8c83d3706 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -72,6 +72,8 @@ @property (nonatomic, strong) SpaceFeatureUnavailablePresenter *spaceFeatureUnavailablePresenter; +@property (nonatomic, strong) CustomSizedPresentationController *customSizedPresentationController; + @end @implementation RecentsViewController @@ -1796,6 +1798,21 @@ }]]; + [currentAlert addAction:[UIAlertAction + actionWithTitle:NSLocalizedStringFromTable(@"room_open_dialpad", @"Vector", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + + if (weakSelf) + { + typeof(self) self = weakSelf; + self->currentAlert = nil; + + [self openDialpad]; + } + + }]]; + [currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { @@ -1815,6 +1832,46 @@ [self presentViewController:currentAlert animated:YES completion:nil]; } +- (void)openDialpad +{ + DialpadViewController *controller = [DialpadViewController instantiateWithConfiguration:[DialpadConfiguration default]]; + controller.delegate = self; + self.customSizedPresentationController = [[CustomSizedPresentationController alloc] initWithPresentedViewController:controller presentingViewController:self]; + self.customSizedPresentationController.dismissOnBackgroundTap = NO; + self.customSizedPresentationController.cornerRadius = 16; + + controller.transitioningDelegate = self.customSizedPresentationController; + [self presentViewController:controller animated:YES completion:nil]; +} + +- (void)dialpadViewControllerDidTapCall:(DialpadViewController *)viewController withPhoneNumber:(NSString *)phoneNumber +{ + if (self.mainSession.callManager && phoneNumber.length > 0) + { + [self startActivityIndicator]; + + [viewController dismissViewControllerAnimated:YES completion:^{ + MXWeakify(self); + [self.mainSession.callManager placeCallAgainst:phoneNumber withVideo:NO success:^(MXCall * _Nonnull call) { + MXStrongifyAndReturnIfNil(self); + [self stopActivityIndicator]; + self.customSizedPresentationController = nil; + + // do nothing extra here. UI will be handled automatically by the CallService. + } failure:^(NSError * _Nullable error) { + MXStrongifyAndReturnIfNil(self); + [self stopActivityIndicator]; + }]; + }]; + } +} + +- (void)dialpadViewControllerDidTapClose:(DialpadViewController *)viewController +{ + [viewController dismissViewControllerAnimated:YES completion:nil]; + self.customSizedPresentationController = nil; +} + - (void)createNewRoom { // Sanity check From 6f59a8f1be7eff0ebfaa168b89be5187907f9d3d Mon Sep 17 00:00:00 2001 From: Simon Wiedmer Date: Tue, 8 Jun 2021 13:39:28 +0200 Subject: [PATCH 2/3] Add check for PSTN support to dialpad --- Riot/Modules/Common/Recents/RecentsViewController.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 8c83d3706..61f5e9274 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -1798,8 +1798,10 @@ }]]; - [currentAlert addAction:[UIAlertAction - actionWithTitle:NSLocalizedStringFromTable(@"room_open_dialpad", @"Vector", nil) + if (self.mainSession.callManager.supportsPSTN) + { + [currentAlert addAction:[UIAlertAction + actionWithTitle:NSLocalizedStringFromTable(@"room_open_dialpad", @"Vector", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { @@ -1812,6 +1814,7 @@ } }]]; + } [currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:UIAlertActionStyleCancel From cc2bda940fa00d9a0b5e49537a09d95f112c8bf5 Mon Sep 17 00:00:00 2001 From: Simon Wiedmer Date: Wed, 9 Jun 2021 11:15:00 +0200 Subject: [PATCH 3/3] Added improvement to CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 2500123b5..20ab74020 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,7 @@ Changes to be released in next version 🙌 Improvements * MXRoomSummary: Adapt room summary changes on MatrixSDK (#4360). * EncryptionKeyManager: Create keys for room last message data type. + * Add dial pad for PSTN capable servers to menu on homescreen 🐛 Bugfix * SettingsViewController: Fix crash when changing the app language (#4377).