@@ -293,7 +293,6 @@ -(void)setContainer {
293
293
[containerTVC scrollToLastMessage: NO ];
294
294
}
295
295
296
-
297
296
-(void )setupLabels {
298
297
[self .sendButton setTitle: [ChatLocal translate: @" ChatSend" ] forState: UIControlStateNormal];
299
298
self.messageTextField .placeholder = [ChatLocal translate: @" digit message" ];
@@ -329,44 +328,15 @@ -(void)setupConnectionStatus {
329
328
[self offlineStatus ];
330
329
}
331
330
}];
332
- // self.connectedHandle = [connectionStatusHandler observeEvent:ChatConnectionStatusEventConnected withCallback:^{
333
- // NSLog(@"connected");
334
- // [self connectedStatus];
335
- // }];
336
- // self.disconnectedHandle = [connectionStatusHandler observeEvent:ChatConnectionStatusEventDisconnected withCallback:^{
337
- // NSLog(@"not connected");
338
- // [self offlineStatus];
339
- // }];
340
331
}
341
-
342
- // // initial status UI
343
- // [self offlineStatus];
344
- //
345
- // // ChatManager *chat = [ChatManager getSharedInstance];
346
- // NSString *url = @"/.info/connected";
347
- // FIRDatabaseReference *rootRef = [[FIRDatabase database] reference];
348
- // self.connectedRef = [rootRef child:url];
349
- // self.connectedRefHandle = [self.connectedRef observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
350
- // if([snapshot.value boolValue]) {
351
- // NSLog(@"connected");
352
- // [self connectedStatus];
353
- // } else {
354
- // NSLog(@"not connected");
355
- // [self offlineStatus];
356
- // }
357
- // }];
358
332
}
359
333
360
334
-(void )connectedStatus {
361
335
self.usernameButton .hidden = NO ;
362
336
self.activityIndicator .hidden = YES ;
363
337
self.sendButton .enabled = YES ;
364
338
[self .activityIndicator stopAnimating ];
365
- // if (self.group) {
366
- // self.statusLabel.text = [ChatUtil groupMembersAsStringForUI:self.group.members];
367
- // } else {
368
339
[self onlineStatus ];
369
- // }
370
340
}
371
341
372
342
-(void )offlineStatus {
@@ -375,7 +345,6 @@ -(void)offlineStatus {
375
345
self.sendButton .enabled = NO ;
376
346
[self .activityIndicator startAnimating ];
377
347
[self setSubTitle: [ChatLocal translate: @" ChatDisconnected" ]];
378
- // self.statusLabel.text = NSLocalizedString(@"ChatDisconnected", nil);
379
348
}
380
349
381
350
-(void )onlineStatus {
@@ -391,7 +360,6 @@ -(void)onlineStatus {
391
360
last_online_status = [ChatLocal translate: @" offline" ];
392
361
}
393
362
[self setSubTitle: last_online_status];
394
- // self.statusLabel.text = last_online_status;
395
363
}
396
364
}
397
365
@@ -407,41 +375,8 @@ -(void)setupRecipientOnlineStatus {
407
375
self.lastOnline = lastOnlineDate;
408
376
[self onlineStatus ];
409
377
}];
410
- // [chatm.presenceHandler ]
411
- // // apps/{TENANT}/presence/{USERID}/connections
412
- // self.onlineRef = [ChatPresenceHandler onlineRefForUser:self.recipient.userId];
413
- // self.online_ref_handle = [self.onlineRef observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
414
- // if(snapshot.exists) {
415
- // NSLog(@"ONLINE: %@", snapshot);
416
- // self.online = YES;
417
- // [self onlineStatus];
418
- // } else {
419
- // self.online = NO;
420
- // [self onlineStatus];
421
- // }
422
- // }];
423
-
424
- // LAST ONLINE
425
-
426
- // apps/{TENANT}/presence/{USERID}/lastOnline
427
- // self.lastOnlineRef = [ChatPresenceHandler lastOnlineRefForUser:self.recipient.userId];
428
- // NSLog(@"last online ref: %@", self.lastOnlineRef);
429
- // self.last_online_ref_handle = [self.lastOnlineRef observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
430
- // [self snapshotDate:snapshot];
431
- // [self onlineStatus];
432
- // }];
433
-
434
-
435
378
}
436
379
437
- // -(void)snapshotDate:(FIRDataSnapshot *)snapshot {
438
- // if (!snapshot.exists) {
439
- // return;
440
- // }
441
- // self.lastOnline = [NSDate dateWithTimeIntervalSince1970:[snapshot.value longValue]/1000];
442
- // }
443
-
444
-
445
380
// ************************
446
381
// *** ONLINE / OFFLINE ***
447
382
// ************************
@@ -514,23 +449,12 @@ -(void)chatTitleButtonPressed {
514
449
}
515
450
516
451
-(void )goToProfile : (UIButton*)sender {
517
- // NSLog(@"goToProfile");
518
- // self.profileVC = (SHPHomeProfileTVC *)[self.applicationContext getVariable:@"profileVC"];
519
452
NSLog (@" RECIPIENT FULL NAME: %@ " , self.recipient .fullname );
520
453
if (self.group ) {
521
454
[self performSegueWithIdentifier: @" GroupInfo" sender: self ];
522
455
} else {
523
456
if (![ChatUIManager getInstance ].pushProfileCallback ) {
524
457
NSLog (@" Default profile view not implemented." );
525
- // self.profileSB = [UIStoryboard storyboardWithName:@"Profile" bundle:nil];
526
- // self.profileNC = [self.profileSB instantiateViewControllerWithIdentifier:@"navigationProfile"];
527
- // SHPHomeProfileTVC *profileVC = (SHPHomeProfileTVC *)[[self.profileNC viewControllers] objectAtIndex:0];
528
- // ChatUser *authorProfile = [[ChatUser alloc] init];
529
- // authorProfile.userId = self.recipient.userId;
530
- // authorProfile.fullname = self.recipient.fullname;
531
- // profileVC.otherUser = authorProfile;
532
- // NSLog(@"self.profileVC.otherUser %@ fullname: %@", profileVC.otherUser.userId, profileVC.otherUser.fullname);
533
- // [self.navigationController pushViewController:profileVC animated:YES];
534
458
}
535
459
else {
536
460
ChatUser *user = [[ChatUser alloc ] init ];
@@ -559,7 +483,6 @@ -(void)initConversationHandler {
559
483
[handler connect ];
560
484
[self subscribeForMessages: handler];
561
485
self.conversationHandler = handler;
562
- // [self configureIfImGroupMember];
563
486
}
564
487
565
488
-(void )configureIfImGroupMember {
@@ -574,19 +497,8 @@ -(void)configureIfImGroupMember {
574
497
}
575
498
}
576
499
577
- // -(void)didFinishInitConversationHandler:(ChatConversationHandler *)handler error:(NSError *)error {
578
- // if (!error) {
579
- // NSLog(@"ChatConversationHandler Initialization finished with success.");
580
- // } else {
581
- // NSLog(@"ChatConversationHandler Initialization finished with error: %@", error);
582
- // }
583
- // }
584
- // ---------------------------------------------------//
585
- // START FUNCTIONS
586
- // ---------------------------------------------------//
587
-
588
500
// ---------------------------------------------------//
589
- // INIZIO GESTIONE KEYBOARD
501
+ // KEYBOARD HANDLING
590
502
// ---------------------------------------------------//
591
503
-(void )backgroundTapToDismissKB : (BOOL )activate
592
504
{
@@ -643,42 +555,6 @@ - (IBAction)addContentAction:(id)sender {
643
555
// [self presentViewController:view animated:YES completion:nil];
644
556
}
645
557
646
- // -(void)openDropbox {
647
- // [[DBChooser defaultChooser] openChooserForLinkType:DBChooserLinkTypePreview
648
- // fromViewController:self completion:^(NSArray *results)
649
- // {
650
- // if ([results count]) {
651
- // // Process results from Chooser
652
- // DBChooserResult *r = results[0];
653
- // // NSLog(@"r.name %@", r.name);
654
- // // NSLog(@"r.link %@", r.link);
655
- // // NSLog(@"r.size %lld", r.size);
656
- // // NSLog(@"r.iconURL %@", r.iconURL);
657
- // NSDictionary *thumbs = r.thumbnails;
658
- // // if (thumbs) {
659
- // // NSArray*keys=[thumbs allKeys];
660
- // // for (NSObject *k in keys) {
661
- // // NSLog(@"r.thumb[%@]: %@", k, thumbs[k]);
662
- // // }
663
- // // NSLog(@"r.thumbs.64x64px %@", thumbs[@"64x64"]);
664
- // // NSLog(@"r.thumbs.200x200px %@", thumbs[@"200x200"]);
665
- // // NSLog(@"r.thumbs.640x480px %@", thumbs[@"640x480"]);
666
- // // } else {
667
- // // NSLog(@"No r.thumbs");
668
- // // }
669
- // [self sendDropboxMessage:r.name link:[r.link absoluteString] size:[NSNumber numberWithLongLong:r.size] iconURL:[r.iconURL absoluteString] thumbs:thumbs];
670
- // } else {
671
- // // User canceled the action
672
- // NSLog(@"Action canceled");
673
- // }
674
- // }];
675
- // }
676
-
677
- // -(void)selectedDocument:(AlfrescoNode *)document {
678
- // NSLog(@"Document selected %@ url: %@", document.name, [DocNavigatorTVC documentURLByNode:document]);
679
- // [self sendAlfrescoMessage:document.name link:[DocNavigatorTVC documentURLByNode:document]];
680
- // }
681
-
682
558
-(void )dismissKeyboardFromTableView : (BOOL )activated {
683
559
// NSLog(@"DISMISSING");
684
560
[self backgroundTapToDismissKB: activated];
@@ -752,9 +628,7 @@ -(void)keyboardWasShown:(NSNotification*)aNotification
752
628
[self .view layoutIfNeeded ];
753
629
[containerTVC scrollToLastMessage: YES ];
754
630
}];
755
- // ///
756
631
}
757
-
758
632
}
759
633
760
634
-(void ) keyboardWillHide : (NSNotification *)aNotification
@@ -774,13 +648,11 @@ -(void) keyboardWillHide:(NSNotification*)aNotification
774
648
self.layoutContraintBottomBarMessageBottomView .constant = 0 ;
775
649
[self .view layoutIfNeeded ];
776
650
}];
777
- // ///
778
651
keyboardShow = NO ;
779
652
// END ANIMATION VIEW
780
-
781
653
}
782
654
// ---------------------------------------------------//
783
- // FINE GESTIONE KEYBOARD
655
+ // END KEYBOARD HANDLING
784
656
// ---------------------------------------------------//
785
657
786
658
-(NSString *)formatDateMessage : (int )numberDaysBetweenChats message : (ChatMessage*)message row : (CGFloat)row {
@@ -815,9 +687,6 @@ - (IBAction)sendAction:(id)sender {
815
687
}
816
688
817
689
-(void )sendMessage : (NSString *)text {
818
- // [DocChatUtil firebaseAuth:self.applicationContext.loggedUser.username password:self.applicationContext.loggedUser.password completion:^(NSError *error) {
819
- // NSLog(@"CONNECTED!!!!");
820
- // }];
821
690
[self sendMessage: text attributes: nil ];
822
691
}
823
692
@@ -842,38 +711,38 @@ -(void)sendMessage:(NSString *)text attributes:(NSDictionary *)attributes {
842
711
}
843
712
}
844
713
845
- -(void )sendDropboxMessage : (NSString *)name link : (NSString *)link size : (NSNumber *)size iconURL : (NSString *)iconURL thumbs : (NSDictionary *)thumbs {
846
-
847
- // check: if in a group, are you still a member?
848
- if (self.group ) {
849
- if ([self .group isMember: self .me.userId]) {
850
- } else {
851
- [self hideBottomView: YES ];
852
- [self .messageTextField resignFirstResponder ];
853
- return ;
854
- }
855
- }
856
-
857
- NSMutableDictionary *attributes = [[NSMutableDictionary alloc ] init ];
858
- NSLog (@" dropbox.link: %@ " , link);
859
- NSLog (@" dropbox.size: %@ " , size);
860
- NSLog (@" dropbox.iconurl: %@ " , iconURL);
861
-
862
- [attributes setValue: link forKey: @" link" ];
863
- [attributes setValue: size forKey: @" size" ];
864
- [attributes setValue: iconURL forKey: @" iconURL" ];
865
- if (thumbs) {
866
- NSArray *keys=[thumbs allKeys ];
867
- for (NSString *k in keys) {
868
- NSURL *turl = (NSURL *)thumbs[k];
869
- [attributes setValue: [turl absoluteString ] forKey: k];
870
- }
871
- }
872
- NSString *text = [NSString stringWithFormat: @" %@ %@ " , name, link];
873
- [self .conversationHandler sendTextMessage: text attributes: attributes completion: ^(ChatMessage *message, NSError *error) {
874
- NSLog (@" Dropbox message %@ successfully sent. ID: %@ " , message.text , message.messageId );
875
- }];
876
- }
714
+ // -(void)sendDropboxMessage:(NSString *)name link:(NSString *)link size:(NSNumber *)size iconURL:(NSString *)iconURL thumbs:(NSDictionary *)thumbs {
715
+ //
716
+ // // check: if in a group, are you still a member?
717
+ // if (self.group) {
718
+ // if ([self.group isMember:self.me.userId]) {
719
+ // } else {
720
+ // [self hideBottomView:YES];
721
+ // [self.messageTextField resignFirstResponder];
722
+ // return;
723
+ // }
724
+ // }
725
+ //
726
+ // NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
727
+ // NSLog(@"dropbox.link: %@", link);
728
+ // NSLog(@"dropbox.size: %@", size);
729
+ // NSLog(@"dropbox.iconurl: %@", iconURL);
730
+ //
731
+ // [attributes setValue:link forKey:@"link"];
732
+ // [attributes setValue:size forKey:@"size"];
733
+ // [attributes setValue:iconURL forKey:@"iconURL"];
734
+ // if (thumbs) {
735
+ // NSArray*keys=[thumbs allKeys];
736
+ // for (NSString *k in keys) {
737
+ // NSURL *turl = (NSURL *)thumbs[k];
738
+ // [attributes setValue:[turl absoluteString] forKey:k];
739
+ // }
740
+ // }
741
+ // NSString *text = [NSString stringWithFormat:@"%@ %@", name, link];
742
+ // [self.conversationHandler sendTextMessage:text attributes:attributes completion:^(ChatMessage *message, NSError *error) {
743
+ // NSLog(@"Dropbox message %@ successfully sent. ID: %@", message.text, message.messageId);
744
+ // }];
745
+ // }
877
746
878
747
-(void )messageUpdated : (ChatMessage *)message {
879
748
[containerTVC reloadDataTableView ];
@@ -884,17 +753,12 @@ -(void)messageDeleted:(ChatMessage *)message {
884
753
}
885
754
886
755
-(void )messageReceived : (ChatMessage *)message {
887
- // SE MESSAGGIO.TIMESTAMP < "1 SEC FA" MOSTRA SUBITO. SE MESSAGGIO >= 1 SEC FA IMPOSTA UN TIMER. SE ARRIVA UN ALTRO MESSAGGIO DURANTE IL TIMER FAI RIPARTIRE IL TIMER. AFTER THE TIMER ENDS, RELOAD TABLE.
888
-
889
- // double now = [[NSDate alloc] init].timeIntervalSince1970;
890
- // self.lastMessageArrivedTime = now;
891
-
892
- if (!self.messagesArriving ) {
893
- NSLog (@" MESSAGE ARRIVED. RENDERING." );
756
+ if (!self.messagesArriving ) { // self.messagesArriving = YES => bulk messages update
894
757
[self startNewMessageTimer ];
895
758
self.messagesArriving = YES ;
896
759
// fist message always shown
897
760
[self renderMessages ];
761
+ [self playSound ];
898
762
}
899
763
else {
900
764
NSLog (@" MESSAGES STILL ARRIVING, NOT RENDERING!" );
@@ -921,7 +785,6 @@ -(void)endNewMessageTimer {
921
785
922
786
-(void )renderMessages {
923
787
dispatch_async (dispatch_get_main_queue (), ^{
924
- [self playSound ];
925
788
[containerTVC reloadDataTableViewOnIndex: self .conversationHandler.messages.count - 1 ];
926
789
[containerTVC scrollToLastMessage: NO ];
927
790
// [self scrollTo];
0 commit comments