From f8d00ccc9abbe8513fae5dd381c6a47ddd58340e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Fri, 28 Jul 2023 17:27:56 +0200 Subject: [PATCH 1/3] Show notification if the call is running for 1h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/CallViewController.m | 25 ++++++++++++++++++++++ NextcloudTalk/en.lproj/Localizable.strings | 3 +++ 2 files changed, 28 insertions(+) diff --git a/NextcloudTalk/CallViewController.m b/NextcloudTalk/CallViewController.m index 7a9e347fc..15efcc7e2 100644 --- a/NextcloudTalk/CallViewController.m +++ b/NextcloudTalk/CallViewController.m @@ -105,6 +105,7 @@ @interface CallViewController () )coordinator @@ -1123,6 +1129,23 @@ - (void)localVideoDragged:(UIPanGestureRecognizer *)gesture } } +- (void)callDurationTimerUpdate +{ + // In case we are the ones who start the call, we don't have the server-side callStartTime, so we set it locally + if (self.room.callStartTime == 0) { + self.room.callStartTime = [[NSDate date] timeIntervalSince1970]; + } + + NSTimeInterval currentTimestamp = [[NSDate date] timeIntervalSince1970]; + int callDuration = (int)(currentTimestamp - self.room.callStartTime); + int oneHourInSeconds = 60 * 60; + + if (callDuration == oneHourInSeconds) { + NSString *callRunningFor1h = NSLocalizedString(@"Note the call is running since 1 hour already", nil); + [[JDStatusBarNotificationPresenter sharedPresenter] presentWithText:callRunningFor1h dismissAfterDelay:7.0 includedStyle:JDStatusBarNotificationIncludedStyleDark]; + } +} + #pragma mark - Call actions -(void)handlePushToTalk:(UILongPressGestureRecognizer *)gestureRecognizer @@ -1353,6 +1376,8 @@ - (void)hangupForAll:(BOOL)allParticipants [[peerConnection.remoteStream.videoTracks firstObject] removeRenderer:screenRenderer]; }]; } + + [self->_callDurationTimer invalidate]; }); if (_callController) { diff --git a/NextcloudTalk/en.lproj/Localizable.strings b/NextcloudTalk/en.lproj/Localizable.strings index 290b88cf3..041bc2f26 100644 --- a/NextcloudTalk/en.lproj/Localizable.strings +++ b/NextcloudTalk/en.lproj/Localizable.strings @@ -1087,6 +1087,9 @@ /* No comment provided by engineer. */ "Not supported" = "Not supported"; +/* No comment provided by engineer. */ +"Note the call is running since 1 hour already" = "Note the call is running since 1 hour already"; + /* No comment provided by engineer. */ "Notifications" = "Notifications"; From 469a816c6cb36fb4dc326def41ade4956f8eddcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Fri, 28 Jul 2023 21:20:37 +0200 Subject: [PATCH 2/3] Add call duration to topbar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/CallViewController.h | 1 + NextcloudTalk/CallViewController.m | 28 ++++++++++++++++++++++++++-- NextcloudTalk/CallViewController.xib | 27 +++++++++++++++++---------- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/NextcloudTalk/CallViewController.h b/NextcloudTalk/CallViewController.h index 8013446ea..2f8ed0448 100644 --- a/NextcloudTalk/CallViewController.h +++ b/NextcloudTalk/CallViewController.h @@ -55,6 +55,7 @@ @property (nonatomic, strong) IBOutlet AvatarBackgroundImageView *avatarBackgroundImageView; @property (nonatomic, strong) IBOutlet UILabel *waitingLabel; @property (nonatomic, strong) IBOutlet NCChatTitleView *titleView; +@property (nonatomic, strong) IBOutlet UILabel *callTimeLabel; - (instancetype)initCallInRoom:(NCRoom *)room asUser:(NSString*)displayName audioOnly:(BOOL)audioOnly; - (void)toggleChatView; diff --git a/NextcloudTalk/CallViewController.m b/NextcloudTalk/CallViewController.m index 15efcc7e2..8b1f4bfd4 100644 --- a/NextcloudTalk/CallViewController.m +++ b/NextcloudTalk/CallViewController.m @@ -772,6 +772,9 @@ - (void)adjustTopBar self->_lowerHandButton.hidden = !self->_isHandRaised; + // Only when the server supports recording-v1 we have access to callStartTime, otherwise hide the label + self->_callTimeLabel.hidden = ![[NCDatabaseManager sharedInstance] serverHasTalkCapability:kCapabilityRecordingV1]; + NCAudioController *audioController = [NCAudioController sharedInstance]; self->_speakerButton.hidden = ![audioController isAudioRouteChangeable]; @@ -818,6 +821,13 @@ - (void)adjustTopBar self->_speakerButton.hidden = YES; } + [self->_topBarView setNeedsLayout]; + [self->_topBarView layoutIfNeeded]; + + if (self->_topBarButtonStackView.frame.origin.x < 0) { + self->_callTimeLabel.hidden = YES; + } + [self adjustMoreButtonMenu]; if ([self->_room canModerate] && [[NCDatabaseManager sharedInstance] serverHasTalkCapability:kCapabilityPublishingPermissions]) { @@ -1137,8 +1147,22 @@ - (void)callDurationTimerUpdate } NSTimeInterval currentTimestamp = [[NSDate date] timeIntervalSince1970]; - int callDuration = (int)(currentTimestamp - self.room.callStartTime); - int oneHourInSeconds = 60 * 60; + long callDuration = currentTimestamp - self.room.callStartTime; + long oneHourInSeconds = 60 * 60; + + long hours = callDuration / 3600; + long minutes = (callDuration / 60) % 60; + long seconds = callDuration % 60; + + if (hours > 0) { + [self.callTimeLabel setText:[NSString stringWithFormat:@"%lu:%02lu:%02lu", hours, minutes, seconds]]; + } else { + [self.callTimeLabel setText:[NSString stringWithFormat:@"%02lu:%02lu", minutes, seconds]]; + } + + if (self->_topBarButtonStackView.frame.origin.x < 0) { + [self adjustTopBar]; + } if (callDuration == oneHourInSeconds) { NSString *callRunningFor1h = NSLocalizedString(@"Note the call is running since 1 hour already", nil); diff --git a/NextcloudTalk/CallViewController.xib b/NextcloudTalk/CallViewController.xib index f7098fea0..f66c94d86 100644 --- a/NextcloudTalk/CallViewController.xib +++ b/NextcloudTalk/CallViewController.xib @@ -3,7 +3,7 @@ - + @@ -13,6 +13,7 @@ + @@ -93,10 +94,16 @@ - + +