Add leave action to call tiles

This commit is contained in:
ismailgulek 2021-04-21 14:52:51 +03:00
parent a395c7e51d
commit badbeea0e8
No known key found for this signature in database
GPG key ID: E96336D42D9470A9
7 changed files with 89 additions and 24 deletions

View file

@ -839,6 +839,7 @@ Tap the + to start adding people.";
"event_formatter_call_retry" = "Retry";
"event_formatter_group_call" = "Group call";
"event_formatter_group_call_join" = "Join";
"event_formatter_group_call_leave" = "Leave";
"event_formatter_group_call_incoming" = "%@ in %@";
// Events formatter with you

View file

@ -1302,6 +1302,10 @@ internal enum VectorL10n {
internal static var eventFormatterGroupCallJoin: String {
return VectorL10n.tr("Vector", "event_formatter_group_call_join")
}
/// Leave
internal static var eventFormatterGroupCallLeave: String {
return VectorL10n.tr("Vector", "event_formatter_group_call_leave")
}
/// VoIP conference added by %@
internal static func eventFormatterJitsiWidgetAdded(_ p1: String) -> String {
return VectorL10n.tr("Vector", "event_formatter_jitsi_widget_added", p1)

View file

@ -218,22 +218,25 @@ class CallPresenter: NSObject {
}
func endActiveJitsiCall() {
guard let widget = jitsiVC?.widget else {
guard let jitsiVC = jitsiVC else {
// there is no active Jitsi call
return
}
if let inBarCallVC = inBarCallVC {
dismissCallBar(for: inBarCallVC)
if pipCallVC == jitsiVC {
// this call currently in the PiP mode,
// first present it by exiting PiP mode and then dismiss it
exitPipCallVC(jitsiVC)
}
if let jitsiVC = jitsiVC {
dismissCallVC(jitsiVC)
jitsiVC.hangup()
dismissCallVC(jitsiVC)
jitsiVC.hangup()
self.jitsiVC = nil
guard let widget = jitsiVC.widget else {
return
}
jitsiVC = nil
guard let uuid = self.jitsiCalls.first(where: { $0.value.widgetId == widget.widgetId })?.key else {
// this Jitsi call is not managed by this class
return

View file

@ -2692,6 +2692,11 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
inMatrixSession:customizedRoomDataSource.mxSession];
[[JitsiService shared] resetDeclineForWidgetWithId:widget.widgetId];
}
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusBubbleCell.leaveAction])
{
[[AppDelegate theDelegate].callPresenter endActiveJitsiCall];
[self reloadBubblesTable:YES];
}
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusBubbleCell.declineAction])
{
MXEvent *widgetEvent = userInfo[kMXKRoomBubbleCellEventKey];

View file

@ -40,6 +40,10 @@ class CallTileActionButton: UIButton {
}
}
private var hasImage: Bool {
return image(for: .normal) != nil
}
var style: CallTileActionButtonStyle = .positive {
didSet {
updateStyle()
@ -95,18 +99,27 @@ class CallTileActionButton: UIButton {
override var intrinsicContentSize: CGSize {
var result = super.intrinsicContentSize
guard hasImage else {
return result
}
result.width += Constants.spaceBetweenImageAndTitle
return result
}
override func imageRect(forContentRect contentRect: CGRect) -> CGRect {
var result = super.imageRect(forContentRect: contentRect)
guard hasImage else {
return result
}
result.origin.x -= Constants.spaceBetweenImageAndTitle/2
return result
}
override func titleRect(forContentRect contentRect: CGRect) -> CGRect {
var result = super.titleRect(forContentRect: contentRect)
guard hasImage else {
return result
}
result.origin.x += Constants.spaceBetweenImageAndTitle/2
return result
}

View file

@ -22,17 +22,27 @@ private let MSEC_PER_SEC: TimeInterval = 1000
@objcMembers
class RoomDirectCallStatusBubbleCell: RoomBaseCallBubbleCell {
private static var className: String {
return String(describing: self)
}
/// Action identifier used when the user pressed "Call back" button for a declined call.
/// The `userInfo` dictionary contains an `MXEvent` object under the `kMXKRoomBubbleCellEventKey` key, representing the invite event of the declined call.
static let callBackAction: String = "RoomDirectCallStatusBubbleCell.CallBack"
static var callBackAction: String {
return self.className + ".callBack"
}
/// Action identifier used when the user pressed "Answer" button for an incoming call.
/// The `userInfo` dictionary contains an `MXEvent` object under the `kMXKRoomBubbleCellEventKey` key, representing the invite event of the call.
static let answerAction: String = "RoomDirectCallStatusBubbleCell.Answer"
static var answerAction: String {
return self.className + ".answer"
}
/// Action identifier used when the user pressed "Decline" button for an incoming call.
/// The `userInfo` dictionary contains an `MXEvent` object under the `kMXKRoomBubbleCellEventKey` key, representing the invite event of the call.
static let declineAction: String = "RoomDirectCallStatusBubbleCell.Decline"
static var declineAction: String {
return self.className + ".decline"
}
private var callDurationString: String = ""
private var isVideoCall: Bool = false

View file

@ -22,17 +22,33 @@ private let MSEC_PER_SEC: TimeInterval = 1000
@objcMembers
class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {
private static var className: String {
return String(describing: self)
}
/// Action identifier used when the user pressed "Join" button for an active call.
/// The `userInfo` dictionary contains an `MXEvent` object under the `kMXKRoomBubbleCellEventKey` key, representing the widget event of the call.
static let joinAction: String = "RoomGroupCallStatusBubbleCell.Join"
static var joinAction: String {
return self.className + ".join"
}
/// Action identifier used when the user pressed "Leave" button for an active call.
/// The `userInfo` dictionary contains an `MXEvent` object under the `kMXKRoomBubbleCellEventKey` key, representing the widget event of the call.
static var leaveAction: String {
return self.className + ".leave"
}
/// Action identifier used when the user pressed "Answer" button for an incoming call.
/// The `userInfo` dictionary contains an `MXEvent` object under the `kMXKRoomBubbleCellEventKey` key, representing the widget event of the call.
static let answerAction: String = "RoomGroupCallStatusBubbleCell.Answer"
static var answerAction: String {
return self.className + ".answer"
}
/// Action identifier used when the user pressed "Decline" button for an incoming call.
/// The `userInfo` dictionary contains an `MXEvent` object under the `kMXKRoomBubbleCellEventKey` key, representing the widget event of the call.
static let declineAction: String = "RoomGroupCallStatusBubbleCell.Decline"
static var declineAction: String {
return self.className + ".decline"
}
private var callDurationString: String = ""
private var isIncoming: Bool = false
@ -107,18 +123,24 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {
return view
case .active:
if isJoined {
// user currently in the group call, do not show a join button
return nil
}
let view = HorizontalButtonsContainerView.loadFromNib()
view.secondButton.isHidden = true
view.firstButton.style = .positive
view.firstButton.setTitle(VectorL10n.eventFormatterGroupCallJoin, for: .normal)
view.firstButton.setImage(callTypeIcon, for: .normal)
view.firstButton.removeTarget(nil, action: nil, for: .touchUpInside)
view.firstButton.addTarget(self, action: #selector(joinAction(_:)), for: .touchUpInside)
if isJoined {
// show a "Leave" button
view.firstButton.style = .negative
view.firstButton.setTitle(VectorL10n.eventFormatterGroupCallLeave, for: .normal)
view.firstButton.setImage(nil, for: .normal)
view.firstButton.removeTarget(nil, action: nil, for: .touchUpInside)
view.firstButton.addTarget(self, action: #selector(leaveAction(_:)), for: .touchUpInside)
} else {
// show a "Join" button
view.firstButton.style = .positive
view.firstButton.setTitle(VectorL10n.eventFormatterGroupCallJoin, for: .normal)
view.firstButton.setImage(callTypeIcon, for: .normal)
view.firstButton.removeTarget(nil, action: nil, for: .touchUpInside)
view.firstButton.addTarget(self, action: #selector(joinAction(_:)), for: .touchUpInside)
}
return view
case .declined:
@ -146,6 +168,13 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell {
userInfo: actionUserInfo)
}
@objc
private func leaveAction(_ sender: CallTileActionButton) {
self.delegate?.cell(self,
didRecognizeAction: Self.leaveAction,
userInfo: actionUserInfo)
}
@objc
private func declineCallAction(_ sender: CallTileActionButton) {
self.delegate?.cell(self,