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

View File

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

View File

@ -36,7 +36,7 @@
} }
-(bool) isHangupForSession:(int64_t)targetSessionId { -(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 { -(bool) isBusyForSession:(int64_t)targetSessionId {

View File

@ -50,9 +50,12 @@ static NSInteger connectingFlashCounter = 0;
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self showCallState]; [self showCallState];
[self setupButtonBorders]; [self setPotentiallyKnownContact:_potentiallyKnownContact];
[self localizeButtons]; [self localizeButtons];
[self linkActions]; [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]; [UIDevice.currentDevice setProximityMonitoringEnabled:YES];
} }
@ -172,7 +175,8 @@ static NSInteger connectingFlashCounter = 0;
[_rejectButton setTitle:REJECT_CALL_BUTTON_TITLE forState:UIControlStateNormal]; [_rejectButton setTitle:REJECT_CALL_BUTTON_TITLE forState:UIControlStateNormal];
} }
- (void)setupButtonBorders { - (void)setPotentiallyKnownContact:(Contact *)potentiallyKnownContact {
_potentiallyKnownContact = potentiallyKnownContact;
if (_potentiallyKnownContact) { if (_potentiallyKnownContact) {

View File

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