Merge branch 'charlesmchen/groupsV2designAgain' into release/3.8.0

This commit is contained in:
Matthew Chen 2020-04-23 10:58:20 -03:00
commit 3d790dc633
40 changed files with 346 additions and 90 deletions

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "group-outline-20.pdf",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "group-outline-256.pdf",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,135 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 19.200195 38.400635 cm
0.000000 0.000000 0.000000 scn
166.400009 110.399994 m
177.428848 110.386444 188.002106 105.999245 195.800690 98.200661 c
203.599258 90.402084 207.986450 79.828842 208.000000 68.799995 c
208.000000 64.000000 l
217.600006 64.000000 l
217.600006 68.799995 l
217.586868 80.927238 213.269485 92.656120 205.416824 101.897652 c
197.564163 111.139183 186.686066 117.293320 174.720001 119.263992 c
181.056274 124.853577 185.540268 132.240097 187.575348 140.440735 c
189.610413 148.641357 189.100098 157.267273 186.112259 165.170731 c
183.124420 173.074188 177.800751 179.880463 170.849594 184.683929 c
163.898422 189.487396 155.649368 192.060303 147.199997 192.060303 c
138.750626 192.060303 130.501572 189.487396 123.550415 184.683929 c
116.599258 179.880463 111.275581 173.074188 108.287743 165.170731 c
105.299911 157.267273 104.789589 148.641357 106.824661 140.440735 c
108.859734 132.240097 113.343727 124.853577 119.680008 119.263992 c
113.566147 118.267235 107.686012 116.161140 102.329605 113.049591 c
98.677528 117.500450 94.141319 121.144775 89.008049 123.751945 c
83.874771 126.359116 78.256203 127.872360 72.507889 128.195923 c
66.759575 128.519470 61.006672 127.646294 55.613251 125.631638 c
50.219830 123.616989 45.303318 120.504730 41.174843 116.491814 c
37.046368 112.478897 33.795822 107.652687 31.628906 102.318619 c
29.461992 96.984550 28.425892 91.258759 28.586170 85.503578 c
28.746449 79.748390 30.099613 74.089134 32.560040 68.883934 c
35.020466 63.678726 38.534580 59.040924 42.880001 55.263992 c
30.913935 53.293335 20.035849 47.139191 12.183185 37.897659 c
4.330521 28.656128 0.013142 16.927246 0.000000 4.800003 c
0.000000 0.000000 l
9.600000 0.000000 l
9.600000 4.800003 l
9.613549 15.828842 14.000745 26.402084 21.799322 34.200668 c
29.597900 41.999252 40.171154 46.386444 51.200001 46.399994 c
89.599998 46.399994 l
100.628845 46.386444 111.202095 41.999252 119.000671 34.200668 c
126.799248 26.402084 131.186447 15.828842 131.199997 4.800003 c
131.199997 0.000000 l
140.800003 0.000000 l
140.800003 4.800003 l
140.786865 16.927246 136.469482 28.656128 128.616821 37.897659 c
120.764160 47.139191 109.886063 53.293335 97.919998 55.263992 c
104.809738 61.314346 109.495682 69.481003 111.242432 78.482346 c
112.989189 87.483688 111.697899 96.810249 107.571205 104.998390 c
113.797165 108.540016 120.837204 110.401474 128.000000 110.399994 c
166.400009 110.399994 l
h
70.400002 54.399994 m
64.070999 54.399994 57.884129 56.276764 52.621754 59.792969 c
47.359379 63.309174 43.257858 68.306892 40.835854 74.154121 c
38.413849 80.001358 37.780140 86.435493 39.014870 92.642891 c
40.249596 98.850281 43.297302 104.552132 47.772583 109.027412 c
52.247864 113.502693 57.949718 116.550400 64.157112 117.785126 c
70.364502 119.019852 76.798630 118.386147 82.645866 115.964142 c
88.493103 113.542137 93.490829 109.440613 97.007034 104.178238 c
100.523239 98.915863 102.400002 92.729004 102.400002 86.400002 c
102.400002 77.913071 99.028580 69.773743 93.027420 63.772583 c
87.026253 57.771423 78.886932 54.399994 70.400002 54.399994 c
70.400002 54.399994 l
h
115.200005 150.399994 m
115.200005 156.729004 117.076767 162.915863 120.592972 168.178238 c
124.109177 173.440613 129.106888 177.542130 134.954132 179.964142 c
140.801361 182.386139 147.235504 183.019852 153.442902 181.785126 c
159.650284 180.550400 165.352142 177.502686 169.827423 173.027405 c
174.302704 168.552124 177.350403 162.850281 178.585129 156.642883 c
179.819855 150.435486 179.186157 144.001358 176.764145 138.154129 c
174.342148 132.306885 170.240616 127.309174 164.978256 123.792969 c
159.715881 120.276764 153.529007 118.399994 147.199997 118.399994 c
138.713074 118.399994 130.573746 121.771408 124.572586 127.772575 c
118.571419 133.773743 115.200005 141.913071 115.200005 150.399994 c
h
f
n
Q
endstream
endobj
3 0 obj
3870
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 256.000000 256.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Type /Catalog
/Pages 5 0 R
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000003960 00000 n
0000003983 00000 n
0000004158 00000 n
0000004232 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
4291
%%EOF

View File

@ -33,9 +33,7 @@
self.title = NSLocalizedString(@"SETTINGS_ABOUT", @"Navbar title");
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
[self updateTableContents];

View File

@ -34,9 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
self.title = NSLocalizedString(@"SETTINGS_ADVANCED_TITLE", @"");
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
[self observeNotifications];

View File

@ -11,9 +11,7 @@ class AppearanceSettingsTableViewController: OWSTableViewController {
title = NSLocalizedString("SETTINGS_APPEARANCE_TITLE", comment: "The title for the appearance settings.")
view.backgroundColor = Theme.tableViewBackgroundColor
tableView.backgroundColor = Theme.tableViewBackgroundColor
self.useThemeCellBackgroundColor = true
self.useThemeBackgroundColors = true
updateTableContents()
}

View File

@ -52,8 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
self.tableViewController.tableView.estimatedRowHeight = 60;
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableViewController.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.tableViewController.useThemeCellBackgroundColor = YES;
self.tableViewController.useThemeBackgroundColors = YES;
[self updateTableContents];
}

View File

@ -32,8 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@"CENSORSHIP_CIRCUMVENTION_COUNTRY_VIEW_TITLE", @"Title for the 'censorship circumvention country' view.");
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableViewController.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.tableViewController.useThemeCellBackgroundColor = YES;
self.tableViewController.useThemeBackgroundColors = YES;
[self createViews];
}

View File

@ -13,9 +13,7 @@
{
[super viewDidLoad];
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
[self updateTableContents];
}

View File

@ -20,9 +20,7 @@
[self setTitle:NSLocalizedString(@"SETTINGS_NOTIFICATIONS", nil)];
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
[self updateTableContents];
}

View File

@ -43,9 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
self.title = NSLocalizedString(@"SETTINGS_BACKUP", @"Label for the backup view in app settings.");
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(backupStateDidChange:)

View File

@ -53,6 +53,7 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.separatorColor = Theme.cellSeparatorColor;
self.isExpectingMoreDevices = NO;
self.tableView.rowHeight = UITableViewAutomaticDimension;

View File

@ -30,9 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[super viewDidLoad];
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
[self setTitle:NSLocalizedString(@"SETTINGS_ITEM_NOTIFICATION_SOUND",
@"Label for settings view that allows user to change the notification sound.")];

View File

@ -27,9 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
self.title = NSLocalizedString(@"SETTINGS_PRIVACY_TITLE", @"");
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
[self observeNotifications];

View File

@ -11,13 +11,15 @@ protocol GroupMemberViewDelegate: class {
var groupMemberViewHasUnsavedChanges: Bool { get }
var shouldTryToEnableGroupsV2ForMembers: Bool { get }
func groupMemberViewRemoveRecipient(_ recipient: PickedRecipient)
func groupMemberViewAddRecipient(_ recipient: PickedRecipient)
func groupMemberViewCanAddRecipient(_ recipient: PickedRecipient) -> Bool
func groupMemberViewGroupMemberCount() -> Int
func groupMemberViewGroupMemberCountForDisplay() -> Int
func groupMemberViewIsGroupFull() -> Bool
@ -170,7 +172,7 @@ public class BaseGroupMemberViewController: OWSViewController {
memberCountWrapper.isHidden = false
let format = NSLocalizedString("GROUP_MEMBER_COUNT_FORMAT",
comment: "Format string for the group member count indicator. Embeds {{ %1$@ the number of members in the group, %2$@ the maximum number of members in the group. }}.")
let memberCount = groupMemberViewDelegate?.groupMemberViewGroupMemberCount() ?? 0
let memberCount = groupMemberViewDelegate?.groupMemberViewGroupMemberCountForDisplay() ?? 0
memberCountLabel.text = String(format: format,
OWSFormat.formatInt(memberCount),
@ -415,10 +417,17 @@ extension BaseGroupMemberViewController: RecipientPickerDelegate {
owsFailDebug("Invalid recipient.")
return
}
guard let groupMemberViewDelegate = groupMemberViewDelegate else {
owsFailDebug("Missing delegate.")
return
}
guard RemoteConfig.groupsV2CreateGroups ||
RemoteConfig.groupsV2IncomingMessages else {
return
}
guard groupMemberViewDelegate.shouldTryToEnableGroupsV2ForMembers else {
return
}
DispatchQueue.global().async {
if !self.doesRecipientSupportGroupsV2(recipient) {
self.tryToEnableGroupsV2ForAddress(address,
@ -442,6 +451,9 @@ extension BaseGroupMemberViewController: RecipientPickerDelegate {
RemoteConfig.groupsV2IncomingMessages else {
return AnyPromise(Promise.value(()))
}
guard groupMemberViewDelegate.shouldTryToEnableGroupsV2ForMembers else {
return AnyPromise(Promise.value(()))
}
guard !doesRecipientSupportGroupsV2(recipient) else {
// Recipient already supports groups v2.
return AnyPromise(Promise.value(()))

View File

@ -97,7 +97,7 @@ public class NewGroupConfirmViewController: OWSViewController {
firstSection.preservesSuperviewLayoutMargins = true
view.addSubview(firstSection)
firstSection.autoPinWidthToSuperview()
firstSection.autoPin(toTopLayoutGuideOf: self, withInset: 0)
firstSection.autoPin(toTopLayoutGuideOf: self, withInset: 8)
addChild(recipientTableView)
view.addSubview(recipientTableView.view)

View File

@ -59,6 +59,10 @@ extension NewGroupMembersViewController: GroupMemberViewDelegate {
return newGroupState.hasUnsavedChanges
}
var shouldTryToEnableGroupsV2ForMembers: Bool {
return true
}
func groupMemberViewRemoveRecipient(_ recipient: PickedRecipient) {
newGroupState.recipientSet.remove(recipient)
}
@ -75,13 +79,17 @@ extension NewGroupMembersViewController: GroupMemberViewDelegate {
return true
}
func groupMemberViewGroupMemberCount() -> Int {
// We add one for the local user.
return newGroupState.recipientSet.count + 1
func groupMemberViewGroupMemberCountForDisplay() -> Int {
return groupMemberViewGroupMemberCount(withSelf: false)
}
func groupMemberViewGroupMemberCount(withSelf: Bool) -> Int {
// We sometimes add one for the local user.
return newGroupState.recipientSet.count + (withSelf ? 1 : 0)
}
func groupMemberViewIsGroupFull() -> Bool {
return groupMemberViewGroupMemberCount() >= GroupManager.maxGroupMemberCount
return groupMemberViewGroupMemberCount(withSelf: true) >= GroupManager.maxGroupMemberCount
}
func groupMemberViewIsPreExistingMember(_ recipient: PickedRecipient) -> Bool {

View File

@ -34,8 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
[super viewDidLoad];
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableViewController.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.tableViewController.useThemeCellBackgroundColor = YES;
self.tableViewController.useThemeBackgroundColors = YES;
self.title = NSLocalizedString(@"ENABLE_2FA_VIEW_TITLE", @"Title for the 'enable two factor auth PIN' views.");

View File

@ -153,7 +153,9 @@ const NSUInteger kMinimumSearchLength = 2;
// 2. the scrollable view (tableView in this case) must be at index 0.
[self addChildViewController:self.tableViewController];
[self.view insertSubview:self.tableViewController.view atIndex:0];
// separatorStyle must be set _after_ the table view is added to the view hierarchy.
self.tableViewController.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.tableViewController.view autoPinEdgesToSuperviewEdges];
self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension;

View File

@ -211,6 +211,10 @@ extension AddGroupMembersViewController: GroupMemberViewDelegate {
return !newRecipientSet.isEmpty
}
var shouldTryToEnableGroupsV2ForMembers: Bool {
return groupThread.isGroupV2Thread
}
func groupMemberViewRemoveRecipient(_ recipient: PickedRecipient) {
newRecipientSet.remove(recipient)
updateNavbar()
@ -222,6 +226,9 @@ extension AddGroupMembersViewController: GroupMemberViewDelegate {
}
func groupMemberViewCanAddRecipient(_ recipient: PickedRecipient) -> Bool {
guard groupThread.isGroupV2Thread else {
return true
}
guard let address = recipient.address else {
owsFailDebug("Invalid recipient.")
return false
@ -231,7 +238,7 @@ extension AddGroupMembersViewController: GroupMemberViewDelegate {
}
}
func groupMemberViewGroupMemberCount() -> Int {
func groupMemberViewGroupMemberCountForDisplay() -> Int {
return (oldGroupModel.groupMembership.pendingAndNonPendingMemberCount +
newRecipientSet.count)
}
@ -240,7 +247,7 @@ extension AddGroupMembersViewController: GroupMemberViewDelegate {
guard groupThread.isGroupV2Thread else {
return false
}
return groupMemberViewGroupMemberCount() >= GroupManager.maxGroupMemberCount
return groupMemberViewGroupMemberCountForDisplay() >= GroupManager.maxGroupMemberCount
}
func groupMemberViewMaxMemberCount() -> UInt? {

View File

@ -589,7 +589,7 @@ extension ConversationSettingsViewController {
cell.preservesSuperviewLayoutMargins = true
cell.contentView.preservesSuperviewLayoutMargins = true
let iconView = OWSTableItem.buildIconInCircleView(icon: .settingsAddMembers, innerIconSize: 24)
let iconView = OWSTableItem.buildIconInCircleView(icon: .settingsAddMembers, iconSize: kSmallAvatarSize)
let rowLabel = UILabel()
rowLabel.text = NSLocalizedString("CONVERSATION_SETTINGS_ADD_MEMBERS",
@ -660,18 +660,23 @@ extension ConversationSettingsViewController {
continue
}
let isLocalUser = memberAddress == localAddress
section.add(OWSTableItem(customCellBlock: { [weak self] in
guard let self = self else {
owsFailDebug("Missing self")
return OWSTableItem.newCell()
}
let cell = ContactTableViewCell()
let isLocalUser = memberAddress == localAddress
cell.setUseSmallAvatars()
let isGroupAdmin = groupMembership.isAdministrator(memberAddress)
let isVerified = verificationState == .verified
let isNoLongerVerified = verificationState == .noLongerVerified
let isBlocked = helper.isSignalServiceAddressBlocked(memberAddress)
if isNoLongerVerified {
if isGroupAdmin {
cell.setAccessoryMessage(NSLocalizedString("GROUP_MEMBER_ADMIN_INDICATOR",
comment: "Label indicating that a group member is an admin."))
} else if isNoLongerVerified {
cell.setAccessoryMessage(NSLocalizedString("CONTACT_CELL_IS_NO_LONGER_VERIFIED",
comment: "An indicator that a contact is no longer verified."))
} else if isBlocked {
@ -680,7 +685,7 @@ extension ConversationSettingsViewController {
if isLocalUser {
// Use a custom avatar to avoid using the "note to self" icon.
let customAvatar = OWSProfileManager.shared().localProfileAvatarImage() ?? OWSContactAvatarBuilder(forLocalUserWithDiameter: kStandardAvatarSize).buildDefaultImage()
let customAvatar = OWSProfileManager.shared().localProfileAvatarImage() ?? OWSContactAvatarBuilder(forLocalUserWithDiameter: kSmallAvatarSize).buildDefaultImage()
cell.setCustomAvatar(customAvatar)
cell.setCustomName(NSLocalizedString("GROUP_MEMBER_LOCAL_USER",
comment: "Label indicating the local user."))
@ -692,13 +697,7 @@ extension ConversationSettingsViewController {
cell.configure(withRecipientAddress: memberAddress)
if isGroupAdmin {
let subtitle = NSAttributedString(string: NSLocalizedString("GROUP_MEMBER_ADMIN_INDICATOR",
comment: "Label indicating that a group member is an admin."),
attributes: [
.font: UIFont.ows_dynamicTypeSubheadline.ows_semibold(),
.foregroundColor: Theme.primaryTextColor
])
cell.setAttributedSubtitle(subtitle)
cell.setAttributedSubtitle(nil)
} else if isVerified {
cell.setAttributedSubtitle(cell.verifiedSubtitle())
} else {
@ -711,6 +710,9 @@ extension ConversationSettingsViewController {
return cell
},
customRowHeight: UITableView.automaticDimension) { [weak self] in
guard !isLocalUser else {
return
}
self?.didSelectGroupMember(memberAddress)
})
}
@ -726,7 +728,8 @@ extension ConversationSettingsViewController {
cell.contentView.preservesSuperviewLayoutMargins = true
let iconView = OWSTableItem.buildIconInCircleView(icon: .settingsShowAllMembers,
innerIconSize: 24,
iconSize: kSmallAvatarSize,
innerIconSize: 12,
iconTintColor: Theme.secondaryTextAndIconColor)
let rowLabel = UILabel()

View File

@ -153,9 +153,7 @@ class ConversationSettingsViewController: OWSTableViewController {
"CONVERSATION_SETTINGS_CONTACT_INFO_TITLE", comment: "Navbar title when viewing settings for a 1-on-1 thread")
}
view.backgroundColor = Theme.tableViewBackgroundColor
tableView.backgroundColor = Theme.tableViewBackgroundColor
self.useThemeCellBackgroundColor = true
self.useThemeBackgroundColors = true
tableView.estimatedRowHeight = 45
tableView.rowHeight = UITableView.automaticDimension

View File

@ -249,9 +249,7 @@ const CGFloat kIconViewLength = 24;
{
[super viewDidLoad];
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
self.tableView.estimatedRowHeight = 45;
self.tableView.rowHeight = UITableViewAutomaticDimension;

View File

@ -52,9 +52,7 @@ public class PendingGroupMembersViewController: OWSTableViewController {
title = NSLocalizedString("PENDING_GROUP_MEMBERS_VIEW_TITLE",
comment: "The title for the 'pending group members' view.")
view.backgroundColor = Theme.tableViewBackgroundColor
tableView.backgroundColor = Theme.tableViewBackgroundColor
self.useThemeCellBackgroundColor = true
self.useThemeBackgroundColors = true
updateTableContents()
}

View File

@ -48,10 +48,8 @@ class ReplaceAdminViewController: OWSTableViewController {
title = NSLocalizedString("REPLACE_ADMIN_VIEW_TITLE",
comment: "The title for the 'replace group admin' view.")
view.backgroundColor = Theme.tableViewBackgroundColor
tableView.backgroundColor = Theme.tableViewBackgroundColor
self.useThemeBackgroundColors = true
tableView.separatorColor = .clear
self.useThemeCellBackgroundColor = true
updateTableContents()
}

View File

@ -95,9 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
self.title = _thread.groupModel.groupName;
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 45;

View File

@ -32,9 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
self.shouldUseTheme = NO;
self.interfaceOrientationMask = UIDevice.currentDevice.defaultSupportedOrienations;
self.view.backgroundColor = Theme.tableViewBackgroundColor;
self.tableView.backgroundColor = Theme.tableViewBackgroundColor;
self.useThemeCellBackgroundColor = YES;
self.useThemeBackgroundColors = YES;
self.title = NSLocalizedString(@"COUNTRYCODE_SELECT_TITLE", @"");
self.countryCodes = [PhoneNumberUtil countryCodesForSearchTerm:nil];

View File

@ -171,7 +171,7 @@ typedef BOOL (^OWSTableSwitchBlock)(void);
@property (nonatomic) UITableViewStyle tableViewStyle;
@property (nonatomic) BOOL useThemeCellBackgroundColor;
@property (nonatomic) BOOL useThemeBackgroundColors;
- (instancetype)init NS_DESIGNATED_INITIALIZER;

View File

@ -636,7 +636,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
UITableViewCell *_Nullable customCell = [item customCell];
if (customCell != nil) {
if (self.useThemeCellBackgroundColor) {
if (self.useThemeBackgroundColors) {
customCell.backgroundColor = Theme.tableCellBackgroundColor;
}
return customCell;
@ -648,7 +648,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
cell.textLabel.text = item.title;
if (self.useThemeCellBackgroundColor) {
if (self.useThemeBackgroundColors) {
customCell.backgroundColor = Theme.tableCellBackgroundColor;
}
@ -674,6 +674,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
UITextView *textView = [LinkingTextView new];
textView.textColor = Theme.secondaryTextAndIconColor;
textView.font = UIFont.ows_dynamicTypeCaption1Font;
textView.backgroundColor = self.sectionHeaderAndFooterBackgroundColor;
CGFloat tableEdgeInsets = UIDevice.currentDevice.isPlusSizePhone ? 20 : 16;
textView.textContainerInset = UIEdgeInsetsMake(16, tableEdgeInsets, 6, tableEdgeInsets);
@ -700,6 +701,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
UITextView *textView = [LinkingTextView new];
textView.textColor = UIColor.ows_gray45Color;
textView.font = UIFont.ows_dynamicTypeCaption1Font;
textView.backgroundColor = self.sectionHeaderAndFooterBackgroundColor;
CGFloat tableEdgeInsets = UIDevice.currentDevice.isPlusSizePhone ? 20 : 16;
textView.textContainerInset = UIEdgeInsetsMake(6, tableEdgeInsets, 12, tableEdgeInsets);
@ -851,15 +853,28 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
[self.tableView reloadData];
}
- (void)setUseThemeBackgroundColors:(BOOL)useThemeBackgroundColors
{
_useThemeBackgroundColors = useThemeBackgroundColors;
[self applyTheme];
}
- (void)applyTheme
{
OWSAssertIsOnMainThread();
self.view.backgroundColor = Theme.backgroundColor;
self.tableView.backgroundColor = Theme.backgroundColor;
UIColor *backgroundColor = (self.useThemeBackgroundColors ? Theme.tableViewBackgroundColor : Theme.backgroundColor);
self.view.backgroundColor = backgroundColor;
self.tableView.backgroundColor = backgroundColor;
self.tableView.separatorColor = Theme.cellSeparatorColor;
}
- (nullable UIColor *)sectionHeaderAndFooterBackgroundColor
{
return (self.useThemeBackgroundColors ? Theme.tableViewBackgroundColor : Theme.secondaryBackgroundColor);
}
@end
NS_ASSUME_NONNULL_END

View File

@ -149,15 +149,37 @@ public extension OWSTableItem {
}
static func buildIconInCircleView(icon: ThemeIcon,
innerIconSize: CGFloat = 24) -> UIView {
innerIconSize: CGFloat) -> UIView {
return buildIconInCircleView(icon: icon,
iconSize: nil,
innerIconSize: innerIconSize,
iconTintColor: .ows_accentBlue)
iconTintColor: nil)
}
static func buildIconInCircleView(icon: ThemeIcon,
innerIconSize: CGFloat = 24,
innerIconSize: CGFloat,
iconTintColor: UIColor) -> UIView {
return buildIconInCircleView(icon: icon,
iconSize: nil,
innerIconSize: innerIconSize,
iconTintColor: iconTintColor)
}
}
// MARK: -
public extension OWSTableItem {
static func buildIconInCircleView(icon: ThemeIcon,
iconSize iconSizeParam: UInt? = nil,
innerIconSize innerIconSizeParam: CGFloat? = nil,
iconTintColor: UIColor? = nil) -> UIView {
let iconSize = CGFloat(iconSizeParam ?? kStandardAvatarSize)
let innerIconSize: CGFloat
if let innerIconSizeParam = innerIconSizeParam {
innerIconSize = innerIconSizeParam
} else {
innerIconSize = CGFloat(iconSize) * 0.6
}
let iconView = OWSTableItem.imageView(forIcon: icon, iconSize: innerIconSize)
if let iconTintColor = iconTintColor {
iconView.tintColor = iconTintColor
@ -168,8 +190,8 @@ public extension OWSTableItem {
iconWrapper.addSubview(iconView)
iconView.autoCenterInSuperview()
iconWrapper.backgroundColor = Theme.isDarkThemeEnabled ? UIColor.ows_gray80 : Theme.washColor
iconWrapper.layer.cornerRadius = CGFloat(kStandardAvatarSize) * 0.5
iconWrapper.autoSetDimensions(to: CGSize(square: CGFloat(kStandardAvatarSize)))
iconWrapper.layer.cornerRadius = iconSize * 0.5
iconWrapper.autoSetDimensions(to: CGSize(square: iconSize))
iconWrapper.setCompressionResistanceHigh()
iconWrapper.setContentHuggingHigh()
return iconWrapper

View File

@ -18,6 +18,8 @@ extern const CGFloat kContactCellAvatarTextMargin;
@property (nonatomic, nullable) UIImage *customAvatar;
@property (nonatomic) BOOL useSmallAvatars;
- (void)configureWithRecipientAddress:(SignalServiceAddress *)address;
- (void)configureWithThread:(TSThread *)thread transaction:(SDSAnyReadTransaction *)transaction;

View File

@ -30,6 +30,7 @@ const CGFloat kContactCellAvatarTextMargin = 8;
@property (nonatomic, nullable) TSThread *thread;
@property (nonatomic) SignalServiceAddress *address;
@property (nonatomic, nullable) NSArray<NSLayoutConstraint *> *layoutConstraints;
@end
@ -80,8 +81,6 @@ const CGFloat kContactCellAvatarTextMargin = 8;
self.layoutMargins = UIEdgeInsetsZero;
_avatarView = [AvatarImageView new];
[_avatarView autoSetDimension:ALDimensionWidth toSize:kStandardAvatarSize];
[_avatarView autoSetDimension:ALDimensionHeight toSize:kStandardAvatarSize];
self.nameLabel = [UILabel new];
self.nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
@ -190,7 +189,8 @@ const CGFloat kContactCellAvatarTextMargin = 8;
self.nameLabel.attributedText = attributedText;
}
self.avatarView.image = [OWSAvatarBuilder buildImageForThread:thread diameter:kStandardAvatarSize];
self.layoutConstraints = [self.avatarView autoSetDimensionsToSize:CGSizeMake(self.avatarSize, self.avatarSize)];
self.avatarView.image = [OWSAvatarBuilder buildImageForThread:thread diameter:self.avatarSize];
if (self.accessoryMessage) {
self.accessoryLabel.text = self.accessoryMessage;
@ -203,6 +203,8 @@ const CGFloat kContactCellAvatarTextMargin = 8;
- (void)updateAvatar
{
self.layoutConstraints = [self.avatarView autoSetDimensionsToSize:CGSizeMake(self.avatarSize, self.avatarSize)];
if (self.customAvatar != nil) {
self.avatarView.image = self.customAvatar;
return;
@ -225,11 +227,16 @@ const CGFloat kContactCellAvatarTextMargin = 8;
OWSContactAvatarBuilder *avatarBuilder = [[OWSContactAvatarBuilder alloc] initWithAddress:address
colorName:colorName
diameter:kStandardAvatarSize];
diameter:self.avatarSize];
self.avatarView.image = [avatarBuilder build];
}
- (NSUInteger)avatarSize
{
return self.useSmallAvatars ? kSmallAvatarSize : kStandardAvatarSize;
}
- (void)updateNameLabels
{
BOOL hasCustomName = self.customName.length > 0;
@ -274,6 +281,9 @@ const CGFloat kContactCellAvatarTextMargin = 8;
for (UIView *subview in self.accessoryViewContainer.subviews) {
[subview removeFromSuperview];
}
[NSLayoutConstraint deactivateConstraints:self.layoutConstraints];
self.layoutConstraints = nil;
self.useSmallAvatars = NO;
}
- (void)otherUsersProfileDidChange:(NSNotification *)notification

View File

@ -27,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setCustomAvatar:(nullable UIImage *)customAvatar;
- (void)setUseSmallAvatars;
- (NSAttributedString *)verifiedSubtitle;
- (BOOL)hasAccessoryText;

View File

@ -107,6 +107,11 @@ NS_ASSUME_NONNULL_BEGIN
[self.cellView setCustomAvatar:customAvatar];
}
- (void)setUseSmallAvatars
{
self.cellView.useSmallAvatars = YES;
}
- (void)prepareForReuse
{
[super prepareForReuse];

View File

@ -194,7 +194,7 @@ public extension Theme {
case .info:
return isDarkThemeEnabled ? "info-solid-24" : "ic_info"
case .groupMessage:
return "group-solid-24"
return "group-outline-20"
}
}
}

View File

@ -1265,10 +1265,28 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (NSComparisonResult (^)(SignalServiceAddress *left,
SignalServiceAddress *right))signalServiceAddressComparatorWithTransaction:(SDSAnyReadTransaction *)transaction
{
// We want to sort E164 phone numbers _after_ names.
NSCharacterSet *e164PrefixSet = [NSCharacterSet characterSetWithCharactersInString:@"+"];
BOOL (^hasE164Prefix)(NSString *) = ^(NSString *string) {
if (string.length < 1) {
return NO;
}
unichar firstChar = [string characterAtIndex:0];
return [e164PrefixSet characterIsMember:firstChar];
};
return ^NSComparisonResult(SignalServiceAddress *left, SignalServiceAddress *right) {
NSString *leftName = [self comparableNameForAddress:left transaction:transaction];
NSString *rightName = [self comparableNameForAddress:right transaction:transaction];
BOOL leftHasE164Prefix = hasE164Prefix(leftName);
BOOL rightHasE164Prefix = hasE164Prefix(rightName);
if (leftHasE164Prefix && !rightHasE164Prefix) {
return NSOrderedDescending;
} else if (!leftHasE164Prefix && rightHasE164Prefix) {
return NSOrderedAscending;
}
NSComparisonResult nameComparison = [leftName caseInsensitiveCompare:rightName];
if (nameComparison == NSOrderedSame) {
return [left.stringForDisplay compare:right.stringForDisplay];

View File

@ -4,6 +4,7 @@
NS_ASSUME_NONNULL_BEGIN
extern const NSUInteger kSmallAvatarSize;
extern const NSUInteger kStandardAvatarSize;
extern const NSUInteger kMediumAvatarSize;
extern const NSUInteger kLargeAvatarSize;

View File

@ -15,7 +15,8 @@
NS_ASSUME_NONNULL_BEGIN
const NSUInteger kStandardAvatarSize = 40;
const NSUInteger kSmallAvatarSize = 40;
const NSUInteger kStandardAvatarSize = 48;
const NSUInteger kMediumAvatarSize = 68;
const NSUInteger kLargeAvatarSize = 96;

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
//
#import "OWSGroupAvatarBuilder.h"
@ -58,7 +58,8 @@ NS_ASSUME_NONNULL_BEGIN
conversationColorName:(NSString *)conversationColorName
diameter:(NSUInteger)diameter
{
NSString *cacheKey = [NSString stringWithFormat:@"%@-%d", groupId.hexadecimalString, Theme.isDarkThemeEnabled];
NSString *cacheKey = [NSString
stringWithFormat:@"%@-%d-%lu", groupId.hexadecimalString, Theme.isDarkThemeEnabled, (unsigned long)diameter];
UIImage *_Nullable cachedAvatar =
[OWSGroupAvatarBuilder.contactsManager.avatarCache imageForKey:cacheKey diameter:(CGFloat)diameter];
@ -85,9 +86,9 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable UIImage *)groupAvatarImageWithBackgroundColor:(UIColor *)backgroundColor diameter:(NSUInteger)diameter
{
UIImage *icon = [UIImage imageNamed:@"group-outline-40"];
UIImage *icon = [UIImage imageNamed:@"group-outline-256"];
// Adjust asset size to reflect the output diameter.
CGFloat scaling = diameter / (CGFloat)52;
CGFloat scaling = diameter * 0.003f;
CGSize iconSize = CGSizeScale(icon.size, scaling);
return [OWSAvatarBuilder avatarImageWithIcon:icon
iconSize:iconSize