Skip to content

Commit

Permalink
Merge pull request #4673 from vector-im/ismail/4642_additions
Browse files Browse the repository at this point in the history
Additional fixes for Call Tiles
  • Loading branch information
ismailgulek authored Aug 6, 2021
2 parents 8f64404 + d0fd365 commit b5b5584
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Changes to be released in next version
* Voice messages: Improve audio recording quality
* Voice messages: Remove labs setting and enable them by default
* Room: Remove the green border from direct message room avatars (#4520).
* VoIP: Additional changes on call tiles (#4642).

🐛 Bugfix
*
Expand Down
3 changes: 2 additions & 1 deletion Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,8 @@ Tap the + to start adding people.";
"event_formatter_message_edited_mention" = "(edited)";
"event_formatter_call_connecting" = "Connecting…";
"event_formatter_call_ringing" = "Ringing…";
"event_formatter_call_has_ended" = "Call ended %@";
"event_formatter_call_has_ended" = "Call ended";
"event_formatter_call_has_ended_with_time" = "Call ended • %@";
"event_formatter_call_incoming_voice" = "Incoming voice call";
"event_formatter_call_incoming_video" = "Incoming video call";
"event_formatter_call_active_voice" = "Active voice call";
Expand Down
10 changes: 7 additions & 3 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,13 @@ internal enum VectorL10n {
internal static var eventFormatterCallEndCall: String {
return VectorL10n.tr("Vector", "event_formatter_call_end_call")
}
/// Call ended %@
internal static func eventFormatterCallHasEnded(_ p1: String) -> String {
return VectorL10n.tr("Vector", "event_formatter_call_has_ended", p1)
/// Call ended
internal static var eventFormatterCallHasEnded: String {
return VectorL10n.tr("Vector", "event_formatter_call_has_ended")
}
/// Call ended • %@
internal static func eventFormatterCallHasEndedWithTime(_ p1: String) -> String {
return VectorL10n.tr("Vector", "event_formatter_call_has_ended_with_time", p1)
}
/// Incoming video call
internal static var eventFormatterCallIncomingVideo: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,27 @@ class RoomDirectCallStatusBubbleCell: RoomBaseCallBubbleCell {
.remoteHangup,
.answeredElseWhere:
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
case .missed:
if call.isIncoming {
viewState = .missed
statusText = isVideoCall ? VectorL10n.eventFormatterCallMissedVideo : VectorL10n.eventFormatterCallMissedVoice
} else {
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
}
case .busy:
configureForRejectedCall(call: call)
@unknown default:
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
}
case .inviteExpired,
.answeredElseWhere:
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
@unknown default:
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
}
}

Expand All @@ -261,21 +261,21 @@ class RoomDirectCallStatusBubbleCell: RoomBaseCallBubbleCell {
statusText = VectorL10n.eventFormatterCallYouDeclined
} else {
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
}
}

private func configureForHangupCall(withEvent event: MXEvent) {
guard let hangupEventContent = MXCallHangupEventContent(fromJSON: event.content) else {
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
return
}

switch hangupEventContent.reasonType {
case .userHangup:
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
default:
viewState = .failed
statusText = VectorL10n.eventFormatterCallConnectionFailed
Expand All @@ -290,7 +290,15 @@ class RoomDirectCallStatusBubbleCell: RoomBaseCallBubbleCell {
} else {
// outgoing unanswered call
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
}
}

private func updateStatusTextForEndedCall() {
if callDurationString.count > 0 {
statusText = VectorL10n.eventFormatterCallHasEndedWithTime(callDurationString)
} else {
statusText = VectorL10n.eventFormatterCallHasEnded
}
}

Expand Down Expand Up @@ -404,7 +412,7 @@ class RoomDirectCallStatusBubbleCell: RoomBaseCallBubbleCell {

// there is no reject or hangup event, we can just say this call has ended
viewState = .ended
statusText = VectorL10n.eventFormatterCallHasEnded(callDurationString)
updateStatusTextForEndedCall()
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {
}
}

private func updateStatusTextForEndedCall() {
if callDurationString.count > 0 {
statusText = VectorL10n.eventFormatterCallHasEndedWithTime(callDurationString)
} else {
statusText = VectorL10n.eventFormatterCallHasEnded
}
}

// MARK: - Actions

@objc
Expand Down Expand Up @@ -265,7 +273,7 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {
in: room,
with: roomState) else {
self.viewState = .ended
self.statusText = VectorL10n.eventFormatterCallHasEnded(self.callDurationString)
self.updateStatusTextForEndedCall()
return
}

Expand All @@ -277,7 +285,7 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {

guard let widget = widgets.first(where: { $0.widgetId == widgetId }) else {
self.viewState = .ended
self.statusText = VectorL10n.eventFormatterCallHasEnded(self.callDurationString)
self.updateStatusTextForEndedCall()
return
}

Expand All @@ -301,7 +309,7 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {
}
} else {
self.viewState = .ended
self.statusText = VectorL10n.eventFormatterCallHasEnded(self.callDurationString)
self.updateStatusTextForEndedCall()
}
}
}
Expand Down

0 comments on commit b5b5584

Please sign in to comment.