Merge branch 'charlesmchen/homeViewBlockIndicator'
This commit is contained in:
commit
195d721aa6
|
@ -1,5 +1,6 @@
|
|||
// Created by Dylan Bourgeois on 27/10/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TSThread.h"
|
||||
|
@ -12,17 +13,20 @@ typedef enum : NSUInteger { kArchiveState = 0, kInboxState = 1 } CellState;
|
|||
|
||||
@interface InboxTableViewCell : UITableViewCell <UIScrollViewDelegate>
|
||||
|
||||
@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
|
||||
@property (nonatomic, strong) IBOutlet UILabel *snippetLabel;
|
||||
@property (nonatomic, strong) IBOutlet UIImageView *contactPictureView;
|
||||
@property (nonatomic, strong) IBOutlet UILabel *timeLabel;
|
||||
@property (nonatomic, strong) IBOutlet UIView *contentContainerView;
|
||||
@property (nonatomic, retain) IBOutlet UIView *messageCounter;
|
||||
@property (nonatomic, retain) NSString *threadId;
|
||||
@property (nonatomic) IBOutlet UILabel *nameLabel;
|
||||
@property (nonatomic) IBOutlet UILabel *snippetLabel;
|
||||
@property (nonatomic) IBOutlet UIImageView *contactPictureView;
|
||||
@property (nonatomic) IBOutlet UILabel *timeLabel;
|
||||
@property (nonatomic) IBOutlet UIView *contentContainerView;
|
||||
@property (nonatomic) IBOutlet UIView *messageCounter;
|
||||
@property (nonatomic) NSString *threadId;
|
||||
|
||||
+ (instancetype)inboxTableViewCell;
|
||||
|
||||
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager;
|
||||
- (void)configureWithThread:(TSThread *)thread
|
||||
contactsManager:(OWSContactsManager *)contactsManager
|
||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet;
|
||||
|
||||
- (void)animateDisappear;
|
||||
|
||||
@end
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
#import "Environment.h"
|
||||
#import "OWSAvatarBuilder.h"
|
||||
#import "PropertyListPreferences.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import "TSContactThread.h"
|
||||
#import "TSGroupThread.h"
|
||||
#import "TSMessagesManager.h"
|
||||
#import "Util.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import <JSQMessagesViewController/JSQMessagesAvatarImageFactory.h>
|
||||
#import <JSQMessagesViewController/UIImage+JSQMessages.h>
|
||||
#import <SignalServiceKit/OWSBlockingManager.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -49,30 +50,37 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return NSStringFromClass(self.class);
|
||||
}
|
||||
|
||||
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager
|
||||
- (void)configureWithThread:(TSThread *)thread
|
||||
contactsManager:(OWSContactsManager *)contactsManager
|
||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
||||
{
|
||||
if (!_threadId || ![_threadId isEqualToString:thread.uniqueId]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.hidden = YES;
|
||||
});
|
||||
OWSAssert([NSThread isMainThread]);
|
||||
OWSAssert(thread);
|
||||
OWSAssert(contactsManager);
|
||||
OWSAssert(blockedPhoneNumberSet);
|
||||
|
||||
BOOL isBlocked = NO;
|
||||
if (!thread.isGroupThread) {
|
||||
NSString *contactIdentifier = thread.contactIdentifier;
|
||||
isBlocked = [blockedPhoneNumberSet containsObject:contactIdentifier];
|
||||
}
|
||||
|
||||
NSString *name = thread.name;
|
||||
if (name.length == 0 && [thread isKindOfClass:[TSGroupThread class]]) {
|
||||
name = NSLocalizedString(@"NEW_GROUP_DEFAULT_TITLE", @"");
|
||||
}
|
||||
UIImage *avatar = [OWSAvatarBuilder buildImageForThread:thread contactsManager:contactsManager];
|
||||
self.threadId = thread.uniqueId;
|
||||
NSString *snippetLabel = [[DisplayableTextFilter new] displayableText:thread.lastMessageLabel];
|
||||
NSString *snippetLabel = (isBlocked ? NSLocalizedString(@"HOME_VIEW_BLOCKED_CONTACT_CONVERSATION",
|
||||
@"A label for conversations with blocked users.")
|
||||
: [[DisplayableTextFilter new] displayableText:thread.lastMessageLabel]);
|
||||
|
||||
NSAttributedString *attributedDate = [self dateAttributedString:thread.lastMessageDate];
|
||||
NSUInteger unreadCount = [[TSMessagesManager sharedManager] unreadMessagesInThread:thread];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.nameLabel.text = name;
|
||||
self.snippetLabel.text = snippetLabel;
|
||||
self.timeLabel.attributedText = attributedDate;
|
||||
self.contactPictureView.image = avatar;
|
||||
self.contactPictureView.image = nil;
|
||||
[UIUtil applyRoundedBorderToImageView:_contactPictureView];
|
||||
|
||||
self.separatorInset = UIEdgeInsetsMake(0, _contactPictureView.frame.size.width * 1.5f, 0, 0);
|
||||
|
@ -83,7 +91,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self updateCellForReadMessage];
|
||||
}
|
||||
[self setUnreadMsgCount:unreadCount];
|
||||
self.hidden = NO;
|
||||
|
||||
NSString *threadIdCopy = thread.uniqueId;
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
UIImage *avatar = [OWSAvatarBuilder buildImageForThread:thread contactsManager:contactsManager];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if ([_threadId isEqualToString:threadIdCopy]) {
|
||||
self.contactPictureView.image = avatar;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#import "TSStorageManager.h"
|
||||
#import "UIUtil.h"
|
||||
#import "VersionMigrations.h"
|
||||
#import <SignalServiceKit/OWSBlockingManager.h>
|
||||
#import <SignalServiceKit/OWSMessageSender.h>
|
||||
#import <SignalServiceKit/TSMessagesManager.h>
|
||||
#import <SignalServiceKit/TSOutgoingMessage.h>
|
||||
|
@ -30,21 +31,24 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
|
|||
|
||||
@interface SignalsViewController ()
|
||||
|
||||
@property (nonatomic, strong) YapDatabaseConnection *editingDbConnection;
|
||||
@property (nonatomic, strong) YapDatabaseConnection *uiDatabaseConnection;
|
||||
@property (nonatomic, strong) YapDatabaseViewMappings *threadMappings;
|
||||
@property (nonatomic) YapDatabaseConnection *editingDbConnection;
|
||||
@property (nonatomic) YapDatabaseConnection *uiDatabaseConnection;
|
||||
@property (nonatomic) YapDatabaseViewMappings *threadMappings;
|
||||
@property (nonatomic) CellState viewingThreadsIn;
|
||||
@property (nonatomic) long inboxCount;
|
||||
@property (nonatomic, retain) UISegmentedControl *segmentedControl;
|
||||
@property (nonatomic, strong) id previewingContext;
|
||||
@property (nonatomic) UISegmentedControl *segmentedControl;
|
||||
@property (nonatomic) id previewingContext;
|
||||
|
||||
// Dependencies
|
||||
|
||||
@property (nonatomic, readonly, strong) AccountManager *accountManager;
|
||||
@property (nonatomic, readonly) AccountManager *accountManager;
|
||||
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
|
||||
@property (nonatomic, readonly) ExperienceUpgradeFinder *experienceUpgradeFinder;
|
||||
@property (nonatomic, readonly) TSMessagesManager *messagesManager;
|
||||
@property (nonatomic, readonly, strong) OWSMessageSender *messageSender;
|
||||
@property (nonatomic, readonly) OWSMessageSender *messageSender;
|
||||
@property (nonatomic, readonly) OWSBlockingManager *blockingManager;
|
||||
|
||||
@property (nonatomic) NSSet<NSString *> *blockedPhoneNumberSet;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -80,7 +84,29 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
|
|||
_contactsManager = [Environment getCurrent].contactsManager;
|
||||
_messagesManager = [TSMessagesManager sharedManager];
|
||||
_messageSender = [Environment getCurrent].messageSender;
|
||||
_blockingManager = [OWSBlockingManager sharedManager];
|
||||
_blockedPhoneNumberSet = [NSSet setWithArray:[_blockingManager blockedPhoneNumbers]];
|
||||
|
||||
_experienceUpgradeFinder = [ExperienceUpgradeFinder new];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(blockedPhoneNumbersDidChange:)
|
||||
name:kNSNotificationName_BlockedPhoneNumbersDidChange
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)blockedPhoneNumbersDidChange:(id)notification
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
_blockedPhoneNumberSet = [NSSet setWithArray:[_blockingManager blockedPhoneNumbers]];
|
||||
|
||||
[self.tableView reloadData];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
|
@ -350,9 +376,7 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
|
|||
cell = [InboxTableViewCell inboxTableViewCell];
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[cell configureWithThread:thread contactsManager:self.contactsManager];
|
||||
});
|
||||
[cell configureWithThread:thread contactsManager:self.contactsManager blockedPhoneNumberSet:_blockedPhoneNumberSet];
|
||||
|
||||
if ((unsigned long)indexPath.row == [self.threadMappings numberOfItemsInSection:0] - 1) {
|
||||
cell.separatorInset = UIEdgeInsetsMake(0.f, cell.bounds.size.width, 0.f, 0.f);
|
||||
|
|
|
@ -445,6 +445,9 @@
|
|||
/* No comment provided by engineer. */
|
||||
"GROUP_YOU_LEFT" = "You have left the group.";
|
||||
|
||||
/* A label for conversations with blocked users. */
|
||||
"HOME_VIEW_BLOCKED_CONTACT_CONVERSATION" = "Blocked";
|
||||
|
||||
/* {{number of hours}} embedded in strings, e.g. 'Alice updated disappearing messages expiration to {{5 hours}}'. See other *_TIME_AMOUNT strings */
|
||||
"HOURS_TIME_AMOUNT" = "%u hours";
|
||||
|
||||
|
|
Loading…
Reference in New Issue