add interaction for showing missed call tips if the permission is denied
This commit is contained in:
parent
5fa63286da
commit
6cb3e1db22
|
@ -29,7 +29,7 @@ final class CallMissedTipsModal : Modal {
|
||||||
// Title
|
// Title
|
||||||
let titleLabel = UILabel()
|
let titleLabel = UILabel()
|
||||||
titleLabel.textColor = Colors.text
|
titleLabel.textColor = Colors.text
|
||||||
titleLabel.font = .boldSystemFont(ofSize: Values.largeFontSize)
|
titleLabel.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||||
titleLabel.text = NSLocalizedString("modal_call_missed_tips_title", comment: "")
|
titleLabel.text = NSLocalizedString("modal_call_missed_tips_title", comment: "")
|
||||||
titleLabel.textAlignment = .center
|
titleLabel.textAlignment = .center
|
||||||
// Message
|
// Message
|
||||||
|
|
|
@ -539,7 +539,11 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
||||||
modal.modalTransitionStyle = .crossDissolve
|
modal.modalTransitionStyle = .crossDissolve
|
||||||
present(modal, animated: true, completion: nil)
|
present(modal, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
if let message = viewItem.interaction as? TSOutgoingMessage, message.messageState == .failed {
|
if let message = viewItem.interaction as? TSInfoMessage, message.messageType == .call {
|
||||||
|
let caller = (thread as! TSContactThread).name()
|
||||||
|
let callMissedTipsModal = CallMissedTipsModal(caller: caller)
|
||||||
|
present(callMissedTipsModal, animated: true, completion: nil)
|
||||||
|
} else if let message = viewItem.interaction as? TSOutgoingMessage, message.messageState == .failed {
|
||||||
// Show the failed message sheet
|
// Show the failed message sheet
|
||||||
showFailedMessageSheet(for: message)
|
showFailedMessageSheet(for: message)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import SessionMessagingKit
|
||||||
|
|
||||||
final class CallMessageCell : MessageCell {
|
final class CallMessageCell : MessageCell {
|
||||||
private lazy var iconImageViewWidthConstraint = iconImageView.set(.width, to: CallMessageCell.iconSize)
|
private lazy var iconImageViewWidthConstraint = iconImageView.set(.width, to: 0)
|
||||||
private lazy var iconImageViewHeightConstraint = iconImageView.set(.height, to: CallMessageCell.iconSize)
|
private lazy var iconImageViewHeightConstraint = iconImageView.set(.height, to: 0)
|
||||||
|
|
||||||
|
private lazy var infoImageViewWidthConstraint = infoImageView.set(.width, to: 0)
|
||||||
|
private lazy var infoImageViewHeightConstraint = infoImageView.set(.height, to: 0)
|
||||||
|
|
||||||
// MARK: UI Components
|
// MARK: UI Components
|
||||||
private lazy var iconImageView = UIImageView()
|
private lazy var iconImageView = UIImageView()
|
||||||
|
|
||||||
|
private lazy var infoImageView = UIImageView(image: UIImage(named: "ic_info")?.withTint(Colors.text))
|
||||||
|
|
||||||
private lazy var timestampLabel: UILabel = {
|
private lazy var timestampLabel: UILabel = {
|
||||||
let result = UILabel()
|
let result = UILabel()
|
||||||
result.font = .boldSystemFont(ofSize: Values.verySmallFontSize)
|
result.font = .boldSystemFont(ofSize: Values.verySmallFontSize)
|
||||||
|
@ -35,6 +41,9 @@ final class CallMessageCell : MessageCell {
|
||||||
result.addSubview(iconImageView)
|
result.addSubview(iconImageView)
|
||||||
iconImageView.autoVCenterInSuperview()
|
iconImageView.autoVCenterInSuperview()
|
||||||
iconImageView.pin(.left, to: .left, of: result, withInset: CallMessageCell.inset)
|
iconImageView.pin(.left, to: .left, of: result, withInset: CallMessageCell.inset)
|
||||||
|
result.addSubview(infoImageView)
|
||||||
|
infoImageView.autoVCenterInSuperview()
|
||||||
|
infoImageView.pin(.right, to: .right, of: result, withInset: -CallMessageCell.inset)
|
||||||
return result
|
return result
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -66,6 +75,12 @@ final class CallMessageCell : MessageCell {
|
||||||
stackView.pin(.bottom, to: .bottom, of: self, withInset: -CallMessageCell.inset)
|
stackView.pin(.bottom, to: .bottom, of: self, withInset: -CallMessageCell.inset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func setUpGestureRecognizers() {
|
||||||
|
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap))
|
||||||
|
tapGestureRecognizer.numberOfTapsRequired = 1
|
||||||
|
addGestureRecognizer(tapGestureRecognizer)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Updating
|
// MARK: Updating
|
||||||
override func update() {
|
override func update() {
|
||||||
guard let message = viewItem?.interaction as? TSInfoMessage, message.messageType == .call else { return }
|
guard let message = viewItem?.interaction as? TSInfoMessage, message.messageType == .call else { return }
|
||||||
|
@ -73,14 +88,17 @@ final class CallMessageCell : MessageCell {
|
||||||
switch message.callState {
|
switch message.callState {
|
||||||
case .outgoing: icon = UIImage(named: "CallOutgoing")?.withTint(Colors.text)
|
case .outgoing: icon = UIImage(named: "CallOutgoing")?.withTint(Colors.text)
|
||||||
case .incoming: icon = UIImage(named: "CallIncoming")?.withTint(Colors.text)
|
case .incoming: icon = UIImage(named: "CallIncoming")?.withTint(Colors.text)
|
||||||
case .missed: icon = UIImage(named: "CallMissed")?.withTint(Colors.destructive)
|
case .missed, .permissionDenied: icon = UIImage(named: "CallMissed")?.withTint(Colors.destructive)
|
||||||
default: icon = nil
|
default: icon = nil
|
||||||
}
|
}
|
||||||
if let icon = icon {
|
iconImageView.image = icon
|
||||||
iconImageView.image = icon
|
|
||||||
}
|
|
||||||
iconImageViewWidthConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0
|
iconImageViewWidthConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0
|
||||||
iconImageViewHeightConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0
|
iconImageViewHeightConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0
|
||||||
|
|
||||||
|
let shouldShowInfoIcon = message.callState == .permissionDenied && !SSKPreferences.areCallsEnabled
|
||||||
|
infoImageViewWidthConstraint.constant = shouldShowInfoIcon ? CallMessageCell.iconSize : 0
|
||||||
|
infoImageViewHeightConstraint.constant = shouldShowInfoIcon ? CallMessageCell.iconSize : 0
|
||||||
|
|
||||||
Storage.read { transaction in
|
Storage.read { transaction in
|
||||||
self.label.text = message.previewText(with: transaction)
|
self.label.text = message.previewText(with: transaction)
|
||||||
}
|
}
|
||||||
|
@ -89,4 +107,13 @@ final class CallMessageCell : MessageCell {
|
||||||
let description = DateUtil.formatDate(forDisplay: date)
|
let description = DateUtil.formatDate(forDisplay: date)
|
||||||
timestampLabel.text = description
|
timestampLabel.text = description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc private func handleTap(_ gestureRecognizer: UITapGestureRecognizer) {
|
||||||
|
guard let viewItem = viewItem, let message = viewItem.interaction as? TSInfoMessage, message.messageType == .call else { return }
|
||||||
|
let shouldBeTappable = message.callState == .permissionDenied && !SSKPreferences.areCallsEnabled
|
||||||
|
if shouldBeTappable {
|
||||||
|
delegate?.handleViewItemTapped(viewItem, gestureRecognizer: gestureRecognizer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ extension AppDelegate {
|
||||||
}
|
}
|
||||||
guard SSKPreferences.areCallsEnabled else {
|
guard SSKPreferences.areCallsEnabled else {
|
||||||
let infoMessage = self.insertCallInfoMessage(for: message, using: transaction)
|
let infoMessage = self.insertCallInfoMessage(for: message, using: transaction)
|
||||||
infoMessage.updateCallInfoMessage(.missed, using: transaction)
|
infoMessage.updateCallInfoMessage(.permissionDenied, using: transaction)
|
||||||
let contactName = Storage.shared.getContact(with: message.sender!, using: transaction)?.displayName(for: Contact.Context.regular) ?? message.sender!
|
let contactName = Storage.shared.getContact(with: message.sender!, using: transaction)?.displayName(for: Contact.Context.regular) ?? message.sender!
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.showMissedCallTipsIfNeeded(caller: contactName)
|
self.showMissedCallTipsIfNeeded(caller: contactName)
|
||||||
|
|
|
@ -24,6 +24,7 @@ typedef NS_ENUM(NSInteger, TSInfoMessageCallState) {
|
||||||
TSInfoMessageCallStateIncoming,
|
TSInfoMessageCallStateIncoming,
|
||||||
TSInfoMessageCallStateOutgoing,
|
TSInfoMessageCallStateOutgoing,
|
||||||
TSInfoMessageCallStateMissed,
|
TSInfoMessageCallStateMissed,
|
||||||
|
TSInfoMessageCallStatePermissionDenied,
|
||||||
TSInfoMessageCallStateUnknown
|
TSInfoMessageCallStateUnknown
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ NSUInteger TSInfoMessageSchemaVersion = 1;
|
||||||
case TSInfoMessageCallStateOutgoing:
|
case TSInfoMessageCallStateOutgoing:
|
||||||
return [NSString stringWithFormat:NSLocalizedString(@"call_outgoing", @""), name];
|
return [NSString stringWithFormat:NSLocalizedString(@"call_outgoing", @""), name];
|
||||||
case TSInfoMessageCallStateMissed:
|
case TSInfoMessageCallStateMissed:
|
||||||
|
case TSInfoMessageCallStatePermissionDenied:
|
||||||
return [NSString stringWithFormat:NSLocalizedString(@"call_missed", @""), name];
|
return [NSString stringWithFormat:NSLocalizedString(@"call_missed", @""), name];
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -76,7 +76,7 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
|
||||||
if !SSKPreferences.areCallsEnabled {
|
if !SSKPreferences.areCallsEnabled {
|
||||||
if let sender = callMessage.sender, let thread = TSContactThread.fetch(for: sender, using: transaction), thread.hasOutgoingInteraction(with: transaction) {
|
if let sender = callMessage.sender, let thread = TSContactThread.fetch(for: sender, using: transaction), thread.hasOutgoingInteraction(with: transaction) {
|
||||||
let infoMessage = TSInfoMessage.from(callMessage, associatedWith: thread)
|
let infoMessage = TSInfoMessage.from(callMessage, associatedWith: thread)
|
||||||
infoMessage.updateCallInfoMessage(.missed, using: transaction)
|
infoMessage.updateCallInfoMessage(.permissionDenied, using: transaction)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue