diff --git a/CHANGES.rst b/CHANGES.rst index 7089978eb..54aeba482 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,7 @@ Changes to be released in next version * MXRoomSummary: Adapt room summary changes on MatrixSDK (#4360). * EncryptionKeyManager: Create keys for room last message data type. * Integrated FLEX for debug builds. + * Add dial pad for PSTN capable servers to menu on homescreen 🐛 Bugfix * RoomDirectCallStatusBubbleCell: Fix crash when entering a DM after a call is hung-up/rejected while being answered (#4403). diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index d559f64d0..61f5e9274 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,24 @@ }]]; + if (self.mainSession.callManager.supportsPSTN) + { + [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 +1835,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