Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add calltime #1314

Merged
merged 3 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NextcloudTalk/CallViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
49 changes: 49 additions & 0 deletions NextcloudTalk/CallViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ @interface CallViewController () <NCCallControllerDelegate, UICollectionViewDele
NSTimer *_batchUpdateTimer;
UIImageSymbolConfiguration *_barButtonsConfiguration;
CGFloat _lastScheduledReaction;
NSTimer *_callDurationTimer;
}

@property (nonatomic, strong) IBOutlet UIButton *audioMuteButton;
Expand Down Expand Up @@ -281,6 +282,11 @@ - (void)viewDidLoad

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sensorStateChange:)
name:UIDeviceProximityStateDidChangeNotification object:nil];

// callStartTime is only available if we have the "recording-v1" capability
if ([[NCDatabaseManager sharedInstance] serverHasTalkCapability:kCapabilityRecordingV1]) {
_callDurationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(callDurationTimerUpdate) userInfo:nil repeats:YES];
}
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
Expand Down Expand Up @@ -766,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];

Expand Down Expand Up @@ -812,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]) {
Expand Down Expand Up @@ -1123,6 +1139,37 @@ - (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];
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(@"The call has been running for one hour", nil);
[[JDStatusBarNotificationPresenter sharedPresenter] presentWithText:callRunningFor1h dismissAfterDelay:7.0 includedStyle:JDStatusBarNotificationIncludedStyleDark];
}
}

#pragma mark - Call actions

-(void)handlePushToTalk:(UILongPressGestureRecognizer *)gestureRecognizer
Expand Down Expand Up @@ -1353,6 +1400,8 @@ - (void)hangupForAll:(BOOL)allParticipants
[[peerConnection.remoteStream.videoTracks firstObject] removeRenderer:screenRenderer];
}];
}

[self->_callDurationTimer invalidate];
});

if (_callController) {
Expand Down
27 changes: 17 additions & 10 deletions NextcloudTalk/CallViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<device id="ipad12_9rounded" orientation="portrait" layout="fullscreen" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -13,6 +13,7 @@
<connections>
<outlet property="audioMuteButton" destination="kDR-Ds-I7B" id="9NJ-iO-JMY"/>
<outlet property="avatarBackgroundImageView" destination="H1v-6g-V21" id="ASI-wy-zPa"/>
<outlet property="callTimeLabel" destination="0Nb-8F-OJ2" id="uzu-FJ-A0H"/>
<outlet property="closeScreensharingButton" destination="N0N-Ny-Aeg" id="NrD-JV-Hec"/>
<outlet property="collectionView" destination="aUh-Z0-hO6" id="jmc-BV-dTa"/>
<outlet property="collectionViewBottomConstraint" destination="TOU-Pk-3pi" id="R4U-x4-psd"/>
Expand Down Expand Up @@ -93,10 +94,16 @@
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="FHx-ks-wEy">
<rect key="frame" x="551" y="28" width="356" height="56"/>
<rect key="frame" x="496.5" y="28" width="410.5" height="56"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="00:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Nb-8F-OJ2" userLabel="CallTimeLabel">
<rect key="frame" x="0.0" y="0.0" width="46.5" height="56"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aQX-QQ-eLT" userLabel="RecordingButton">
<rect key="frame" x="0.0" y="0.0" width="44" height="56"/>
<rect key="frame" x="54.5" y="0.0" width="44" height="56"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="q2u-LZ-1pc"/>
Expand All @@ -110,7 +117,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kDR-Ds-I7B" userLabel="AudioButton">
<rect key="frame" x="52" y="0.0" width="44" height="56"/>
<rect key="frame" x="106.5" y="0.0" width="44" height="56"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="Ar2-um-gQl"/>
Expand All @@ -124,7 +131,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5zQ-it-ujU" userLabel="VideoDisableButton">
<rect key="frame" x="104" y="0.0" width="44" height="56"/>
<rect key="frame" x="158.5" y="0.0" width="44" height="56"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="sGL-hj-uAT"/>
Expand All @@ -138,7 +145,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YDj-MO-jIc" userLabel="VideoCallButton">
<rect key="frame" x="156" y="0.0" width="44" height="56"/>
<rect key="frame" x="210.5" y="0.0" width="44" height="56"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="350-WN-M1a"/>
Expand All @@ -152,7 +159,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dgz-bL-PRr" userLabel="SpeakerButton">
<rect key="frame" x="208" y="0.0" width="44" height="56"/>
<rect key="frame" x="262.5" y="0.0" width="44" height="56"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="tg2-YD-INe"/>
Expand All @@ -166,7 +173,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RpQ-sH-1qf" userLabel="LowerHandButton">
<rect key="frame" x="260" y="0.0" width="44" height="56"/>
<rect key="frame" x="314.5" y="0.0" width="44" height="56"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="77m-11-7t8"/>
Expand All @@ -180,7 +187,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Gjp-FF-fc2" userLabel="MoreButton">
<rect key="frame" x="312" y="0.0" width="44" height="56"/>
<rect key="frame" x="366.5" y="0.0" width="44" height="56"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="yxW-nz-Toe"/>
Expand All @@ -193,7 +200,7 @@
</subviews>
</stackView>
<view contentMode="left" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="NY0-IT-mMr" userLabel="TitleView" customClass="NCChatTitleView">
<rect key="frame" x="8" y="32" width="535" height="48"/>
<rect key="frame" x="8" y="32" width="480.5" height="48"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="TeG-Qy-adB"/>
Expand Down
3 changes: 3 additions & 0 deletions NextcloudTalk/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,9 @@
/* No comment provided by engineer. */
"The app is too old and no longer supported by this server." = "The app is too old and no longer supported by this server.";

/* No comment provided by engineer. */
"The call has been running for one hour" = "The call has been running for one hour";

/* No comment provided by engineer. */
"The password is wrong" = "The password is wrong";

Expand Down
Loading