Incoming call when app closed: updates contact label when available.

This commit is contained in:
Frederic Jacobs 2014-12-29 23:55:57 +01:00
parent 0266621ceb
commit 5cf96b2b05
7 changed files with 39 additions and 26 deletions

View File

@ -81,7 +81,7 @@ EXTERNAL SOURCES:
CHECKOUT OPTIONS:
JSQMessagesViewController:
:commit: 9dffc05aa72ad701ecb038a2833cdf53df4b16d7
:commit: ed9858bd6df609bba83b21a029701cbf13682981
:git: https://github.com/dtsbourg/JSQMessagesViewController
SocketRocket:
:commit: d0585af165

2
Pods

@ -1 +1 @@
Subproject commit 4104112c445b2a0fa19fd15f2b97d7be7d46d3c4
Subproject commit 94599a4564daeec5315e99bfae427f798925b0b2

View File

@ -64,7 +64,7 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
BOOL loggingIsEnabled;
#ifdef DEBUG
// Specified at Product -> Scheme -> Edit Scheme -> Test -> Arguments -> Environment to avoid things like
// the phone directory being looked up during tests.
@ -78,7 +78,7 @@
#elif RELEASE
loggingIsEnabled = Environment.preferences.loggingIsEnabled;
#endif
if (loggingIsEnabled) {
[DebugLogger.sharedInstance enableFileLogging];
}
@ -100,7 +100,7 @@
NSDictionary *remoteNotif = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if (remoteNotif) {
DDLogInfo(@"Application was launched by tapping a push notification.");
[self application:application didReceiveRemoteNotification:remoteNotif];
[self application:application didReceiveRemoteNotification:remoteNotif ];
}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:[NSBundle mainBundle]];
@ -117,10 +117,10 @@
if (latestCall == nil){
return;
}
InCallViewController *callViewController = [InCallViewController inCallViewControllerWithCallState:latestCall
andOptionallyKnownContact:latestCall.potentiallySpecifiedContact];
if (latestCall.initiatedLocally == false){
[self.callPickUpFuture.future thenDo:^(NSNumber *accept) {
if ([accept isEqualToNumber:@YES]) {
@ -177,9 +177,15 @@
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
ResponderSessionDescriptor* call;
if (![self.notificationTracker shouldProcessNotification:userInfo]){
return;
}
@try {
call = [ResponderSessionDescriptor responderSessionDescriptorFromEncryptedRemoteNotification:userInfo];
DDLogDebug(@"Received remote notification. Parsed session descriptor: %@.", call);
self.callPickUpFuture = [TOCFutureSource new];
} @catch (OperationFailed* ex) {
DDLogError(@"Error parsing remote notification. Error: %@.", ex);
return;
@ -189,26 +195,21 @@
DDLogError(@"Decryption of session descriptor failed");
return;
}
self.callPickUpFuture = [TOCFutureSource new];
[Environment.phoneManager incomingCallWithSession:call];
}
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
if ([self isRedPhonePush:userInfo]) {
if ([self.notificationTracker shouldProcessNotification:userInfo]){
[self application:application didReceiveRemoteNotification:userInfo];
} else{
DDLogDebug(@"Push already processed. Skipping.");
completionHandler(UIBackgroundFetchResultNewData);
}
[self application:application didReceiveRemoteNotification:userInfo];
} else {
[TSSocketManager becomeActive];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC),
dispatch_get_main_queue(), ^{
completionHandler(UIBackgroundFetchResultNewData);
});
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC),
dispatch_get_main_queue(), ^{
completionHandler(UIBackgroundFetchResultNewData);
});
}
- (BOOL)isRedPhonePush:(NSDictionary*)pushDict {
@ -243,15 +244,23 @@
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler{
[self application:application didReceiveRemoteNotification:userInfo];
if ([identifier isEqualToString:Signal_Call_Accept_Identifier]) {
[self.callPickUpFuture trySetResult:@YES];
completionHandler();
} else if ([identifier isEqualToString:Signal_Call_Decline_Identifier]){
[self.callPickUpFuture trySetResult:@NO];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC),
dispatch_get_main_queue(), ^{
completionHandler();
});
} else if ([identifier isEqualToString:Signal_Message_MarkAsRead_Identifier]){
//TODO
} else if ([identifier isEqualToString:Signal_Message_View_Identifier]){
//TODO
}
completionHandler();
}

View File

@ -112,11 +112,11 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
#pragma mark - Observables
-(ObservableValue *) getObservableContacts {
-(ObservableValue *)getObservableContacts {
return observableContactsController;
}
-(ObservableValue *) getObservableRedPhoneUsers {
-(ObservableValue *)getObservableRedPhoneUsers {
return observableRedPhoneUsersController;
}

View File

@ -36,7 +36,7 @@
}
-(bool) isHangupForSession:(int64_t)targetSessionId {
return [self.method isEqualToString:@"DELETE"] && [@(targetSessionId) isEqualToNumber:self.tryGetSessionId];
return [self.method isEqualToString:@"DELETE"] && self.tryGetSessionId?[@(targetSessionId) isEqualToNumber:self.tryGetSessionId]:YES;
}
-(bool) isBusyForSession:(int64_t)targetSessionId {

View File

@ -50,9 +50,12 @@ static NSInteger connectingFlashCounter = 0;
- (void)viewDidLoad {
[super viewDidLoad];
[self showCallState];
[self setupButtonBorders];
[self setPotentiallyKnownContact:_potentiallyKnownContact];
[self localizeButtons];
[self linkActions];
[[[[Environment getCurrent] contactsManager] getObservableContacts] watchLatestValue:^(NSArray *latestContacts) {
[self setPotentiallyKnownContact:[[[Environment getCurrent] contactsManager] latestContactForPhoneNumber:_callState.remoteNumber]];
} onThread:[NSThread mainThread] untilCancelled:nil];
[UIDevice.currentDevice setProximityMonitoringEnabled:YES];
}
@ -172,7 +175,8 @@ static NSInteger connectingFlashCounter = 0;
[_rejectButton setTitle:REJECT_CALL_BUTTON_TITLE forState:UIControlStateNormal];
}
- (void)setupButtonBorders {
- (void)setPotentiallyKnownContact:(Contact *)potentiallyKnownContact {
_potentiallyKnownContact = potentiallyKnownContact;
if (_potentiallyKnownContact) {

View File

@ -498,7 +498,7 @@ typedef enum : NSUInteger {
return 16.0f;
}
}
else if ([self shouldShowMessageStatusAtIndexPath:indexPath]) {
else if (msg.messageType == TSOutgoingMessageAdapter) {
return 16.0f;
}