Improve the call status messages in conversation view.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-02-08 15:52:48 -05:00
parent 8e2ac368a0
commit 06a775b41a
9 changed files with 107 additions and 22 deletions

View File

@ -5,8 +5,8 @@ target 'Signal' do
pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git'
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git'
#pod 'AxolotlKit', path: '../SignalProtocolKit'
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
#pod 'SignalServiceKit', path: '../SignalServiceKit'
#pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
pod 'SignalServiceKit', path: '../SignalServiceKit'
pod 'OpenSSL'
pod 'PastelogKit', '~> 1.3'
pod 'FFCircularProgressView', '~> 0.5'

View File

@ -123,7 +123,7 @@ DEPENDENCIES:
- PastelogKit (~> 1.3)
- PureLayout
- SCWaveformView (~> 1.0)
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`)
- SignalServiceKit (from `../SignalServiceKit`)
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`)
- ZXingObjC
@ -131,7 +131,7 @@ EXTERNAL SOURCES:
AxolotlKit:
:git: https://github.com/WhisperSystems/SignalProtocolKit.git
SignalServiceKit:
:git: https://github.com/WhisperSystems/SignalServiceKit.git
:path: ../SignalServiceKit
SocketRocket:
:git: https://github.com/facebook/SocketRocket.git
@ -139,9 +139,6 @@ CHECKOUT OPTIONS:
AxolotlKit:
:commit: 919d541d6b8a8802a94f943026b8f68394e2c0b8
:git: https://github.com/WhisperSystems/SignalProtocolKit.git
SignalServiceKit:
:commit: 4d055757de63762648471951bef4bc3d2b9476ed
:git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket:
:commit: 41b57bb2fc292a814f758441a05243eb38457027
:git: https://github.com/facebook/SocketRocket.git
@ -172,6 +169,6 @@ SPEC CHECKSUMS:
YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f
ZXingObjC: bf15b3814f7a105b6d99f47da2333c93a063650a
PODFILE CHECKSUM: 48dbf2fb380d626bb799a782dd41b6bf1e466506
PODFILE CHECKSUM: bc79f89ae559d9f61d1471a89fd44471609af69d
COCOAPODS: 1.0.1

View File

@ -1,5 +1,6 @@
// Created by Dylan Bourgeois on 20/11/14.
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageData.h"
@ -12,9 +13,11 @@ typedef enum : NSUInteger {
kCallOutgoing = 1,
kCallIncoming = 2,
kCallMissed = 3,
kGroupUpdateJoin = 4,
kGroupUpdateLeft = 5,
kGroupUpdate = 6
kCallOutgoingIncomplete = 4,
kCallIncomingIncomplete = 5,
kGroupUpdateJoin = 6,
kGroupUpdateLeft = 7,
kGroupUpdate = 8,
} CallStatus;
@interface OWSCall : NSObject <OWSMessageData>

View File

@ -1,5 +1,6 @@
// Created by Dylan Bourgeois on 20/11/14.
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSCall.h"
#import "TSCall.h"
@ -41,12 +42,18 @@ NS_ASSUME_NONNULL_BEGIN
case RPRecentCallTypeOutgoing:
status = kCallOutgoing;
break;
case RPRecentCallTypeOutgoingIncomplete:
status = kCallOutgoingIncomplete;
break;
case RPRecentCallTypeMissed:
status = kCallMissed;
break;
case RPRecentCallTypeIncoming:
status = kCallIncoming;
break;
case RPRecentCallTypeIncomingIncomplete:
status = kCallIncomingIncomplete;
break;
default:
status = kCallIncoming;
break;
@ -61,9 +68,15 @@ NS_ASSUME_NONNULL_BEGIN
case kCallIncoming:
detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_RECEIVED_CALL", nil), name];
break;
case kCallIncomingIncomplete:
detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_THEY_TRIED_TO_CALL_YOU", nil), name];
break;
case kCallOutgoing:
detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_YOU_CALLED", nil), name];
break;
case kCallOutgoingIncomplete:
detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_YOU_TRIED_TO_CALL", nil), name];
break;
default:
detailString = @"";
break;

View File

@ -52,6 +52,12 @@ import Foundation
ensureIsEnabled(call: call)
}
internal func callRecordDidChange(call: SignalCall, callRecord: TSCall?) {
AssertIsOnMainThread()
// Do nothing.
}
private func ensureIsEnabled(call: SignalCall) {
// Auto-enable speakerphone when local video is enabled.
if call.hasLocalVideo {

View File

@ -285,8 +285,9 @@ protocol CallServiceObserver: class {
sendIceUpdatesImmediately = false
pendingIceUpdateMessages = []
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeOutgoing, in: thread)
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeOutgoingIncomplete, in: thread)
callRecord.save()
call.callRecord = callRecord
guard self.peerConnectionClient == nil else {
let errorDescription = "\(TAG) peerconnection was unexpectedly already set."
@ -388,11 +389,17 @@ protocol CallServiceObserver: class {
public func handleMissedCall(_ call: SignalCall, thread: TSContactThread) {
AssertIsOnMainThread()
// Insert missed call record
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(),
withCallNumber: thread.contactIdentifier(),
callType: RPRecentCallTypeMissed,
in: thread)
callRecord.save()
if call.callRecord == nil {
call.callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(),
withCallNumber: thread.contactIdentifier(),
callType: RPRecentCallTypeMissed,
in: thread)
} else if (call.callRecord!.callType == RPRecentCallTypeIncoming) {
call.callRecord!.updateCallType(RPRecentCallTypeMissed)
}
assert(call.callRecord != nil)
call.callRecord?.save()
self.callUIAdapter.reportMissedCall(call)
}
@ -715,8 +722,9 @@ protocol CallServiceObserver: class {
return
}
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeIncoming, in: thread)
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), withCallNumber: call.remotePhoneNumber, callType: RPRecentCallTypeIncomingIncomplete, in: thread)
callRecord.save()
call.callRecord = callRecord
let message = DataChannelMessage.forConnected(callId: call.signalingId)
peerConnectionClient.sendDataChannelMessage(data: message.asData())
@ -1142,6 +1150,7 @@ protocol CallServiceObserver: class {
AssertIsOnMainThread()
Logger.info("\(self.TAG) \(#function): \(state)")
updateIsVideoEnabled()
updateCallRecordType(call: call)
}
internal func hasLocalVideoDidChange(call: SignalCall, hasLocalVideo: Bool) {
@ -1160,6 +1169,33 @@ protocol CallServiceObserver: class {
// Do nothing
}
internal func callRecordDidChange(call: SignalCall, callRecord: TSCall?) {
AssertIsOnMainThread()
updateCallRecordType(call: call)
}
internal func updateCallRecordType(call: SignalCall?) {
AssertIsOnMainThread()
guard call != nil else {
return
}
guard call!.callRecord != nil else {
return
}
// Mark incomplete calls as completed if call has connected.
if call!.state == .connected &&
call!.callRecord!.callType == RPRecentCallTypeOutgoingIncomplete {
call!.callRecord!.updateCallType(RPRecentCallTypeOutgoing)
}
if call!.state == .connected &&
call!.callRecord!.callType == RPRecentCallTypeIncomingIncomplete {
call!.callRecord!.updateCallType(RPRecentCallTypeIncoming)
}
}
// MARK: - Video
private func shouldHaveLocalVideoTrack() -> Bool {

View File

@ -27,6 +27,7 @@ protocol CallObserver: class {
func hasLocalVideoDidChange(call: SignalCall, hasLocalVideo: Bool)
func muteDidChange(call: SignalCall, isMuted: Bool)
func speakerphoneDidChange(call: SignalCall, isEnabled: Bool)
func callRecordDidChange(call: SignalCall, callRecord: TSCall?)
}
/**
@ -49,6 +50,17 @@ protocol CallObserver: class {
// Distinguishes between calls locally, e.g. in CallKit
let localId: UUID
var callRecord: TSCall? {
didSet {
AssertIsOnMainThread()
assert(oldValue == nil)
for observer in observers {
observer.value?.callRecordDidChange(call: self, callRecord: callRecord)
}
}
}
var hasLocalVideo = false {
didSet {
AssertIsOnMainThread()

View File

@ -733,6 +733,12 @@ class CallViewController: UIViewController, CallObserver, CallServiceObserver, R
self.updateCallUI(callState: call.state)
}
internal func callRecordDidChange(call: SignalCall, callRecord: TSCall?) {
AssertIsOnMainThread()
// Do nothing.
}
// MARK: - Video
internal func updateLocalVideoTrack(localVideoTrack: RTCVideoTrack?) {

View File

@ -376,6 +376,9 @@
/* notification body */
"INCOMING_CALL_FROM" = "Incoming call from %@";
/* No comment provided by engineer. */
"INCOMING_INCOMPLETE_CALL" = "Incomplete incoming call from";
/* Text for button at the top of the contact picker */
"INVITE_FRIENDS_CONTACT_TABLE_BUTTON" = "Invite Friends to Signal";
@ -471,9 +474,15 @@
/* No comment provided by engineer. */
"MSGVIEW_RECEIVED_CALL" = "You received a call from %@.";
/* No comment provided by engineer. */
"MSGVIEW_THEY_TRIED_TO_CALL_YOU" = "%@ tried to call you.";
/* No comment provided by engineer. */
"MSGVIEW_YOU_CALLED" = "You called %@.";
/* No comment provided by engineer. */
"MSGVIEW_YOU_TRIED_TO_CALL" = "You tried to call %@.";
/* No comment provided by engineer. */
"MULTIDEVICE_PAIRING_MAX_DESC" = "You can not pair any more devices.";
@ -558,6 +567,9 @@
/* No comment provided by engineer. */
"OUTGOING_CALL" = "Outgoing call";
/* No comment provided by engineer. */
"OUTGOING_INCOMPLETE_CALL" = "Incomplete outgoing call";
/* Alert body when verifying with {{contact name}} */
"PRIVACY_VERIFICATION_FAILED_I_HAVE_WRONG_KEY_FOR_THEM" = "This doesn't look like your safety number with %@. Are you verifying the correct contact?";