merged element 1.8.10

This commit is contained in:
Arnfried Griesert
2022-05-03 12:48:01 +02:00
1235 changed files with 50869 additions and 23132 deletions
@@ -79,7 +79,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
[self resetSectionIndexes];
_areSectionsShrinkable = NO;
_areSectionsShrinkable = YES;
shrinkedSectionsBitMask = 0;
roomTagsListenerByUserId = [[NSMutableDictionary alloc] init];
@@ -220,10 +220,11 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
- (void)setCurrentSpace:(MXSpace *)currentSpace
{
super.currentSpace = currentSpace;
[self.recentsListService updateSpace:currentSpace];
}
- (UIView *)viewForStickyHeaderInSection:(NSInteger)section withFrame:(CGRect)frame
- (UIView *)viewForStickyHeaderInSection:(NSInteger)section withFrame:(CGRect)frame inTableView:(UITableView*)tableView
{
UIView *stickyHeader;
@@ -234,7 +235,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
shrinkedSectionsBitMask = RECENTSDATASOURCE_SECTION_DIRECTORY;
}
stickyHeader = [self viewForHeaderInSection:section withFrame:frame];
stickyHeader = [self viewForHeaderInSection:section withFrame:frame inTableView:tableView];
shrinkedSectionsBitMask = savedShrinkedSectionsBitMask;
@@ -685,7 +686,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
title = [VectorL10n roomRecentsSuggestedRoomsSection];
}
if (count)
if (count && !(section == invitesSection))
{
NSString *roomCount = [NSString stringWithFormat:@" %tu", count];
@@ -708,12 +709,16 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
return sectionTitle;
}
- (UIView *)badgeViewForHeaderTitleInHomeSection:(NSInteger)section
- (UIView *)badgeViewForHeaderTitleInSection:(NSInteger)section
{
// Prepare a badge to display the total of missed notifications in this section.
id<MXRoomListDataCounts> counts = nil;
UIView *missedNotifAndUnreadBadgeBgView = nil;
if (section == invitesSection)
{
counts = self.recentsListService.invitedRoomListData.counts;
}
if (section == favoritesSection)
{
counts = self.recentsListService.favoritedRoomListData.counts;
@@ -739,8 +744,9 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
counts = self.recentsListService.suggestedRoomListData.counts;
}
NSUInteger numberOfNotifications = counts.total.numberOfNotifications;
NSUInteger numberOfHighlights = counts.total.numberOfHighlights;
// Invites are counted as highlights for the badge view display.
NSUInteger numberOfNotifications = counts.total.numberOfNotifications + counts.total.numberOfInvitedRooms;
NSUInteger numberOfHighlights = counts.total.numberOfHighlights + counts.total.numberOfInvitedRooms;
if (numberOfNotifications)
{
@@ -777,7 +783,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
return missedNotifAndUnreadBadgeBgView;
}
- (UIView *)viewForHeaderInSection:(NSInteger)section withFrame:(CGRect)frame
- (UIView *)viewForHeaderInSection:(NSInteger)section withFrame:(CGRect)frame inTableView:(UITableView*)tableView
{
// No header view in key backup banner section
if (section == self.secureBackupBannerSection || section == self.crossSigningBannerSection)
@@ -785,8 +791,14 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
return nil;
}
SectionHeaderView *sectionHeader = [[SectionHeaderView alloc] initWithFrame:frame];
sectionHeader.backgroundColor = ThemeService.shared.theme.headerBackgroundColor;
SectionHeaderView *sectionHeader = [tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionHeaderView.defaultReuseIdentifier];
if (sectionHeader == nil)
{
sectionHeader = [[SectionHeaderView alloc] initWithReuseIdentifier:SectionHeaderView.defaultReuseIdentifier];
}
sectionHeader.backgroundView = [UIView new];
sectionHeader.frame = frame;
sectionHeader.backgroundView.backgroundColor = ThemeService.shared.theme.headerBackgroundColor;
sectionHeader.topViewHeight = RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT;
NSInteger sectionBitwise = 0;
@@ -833,7 +845,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
shrinkButton.backgroundColor = [UIColor clearColor];
[shrinkButton addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
shrinkButton.tag = sectionBitwise;
[sectionHeader addSubview:shrinkButton];
sectionHeader.topSpanningView = shrinkButton;
sectionHeader.userInteractionEnabled = YES;
@@ -841,27 +852,27 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
UIImage *chevron;
if (shrinkedSectionsBitMask & sectionBitwise)
{
chevron = [UIImage imageNamed:@"disclosure_icon"];
chevron = AssetImages.disclosureIcon.image;
}
else
{
chevron = [UIImage imageNamed:@"shrink_icon"];
chevron = AssetImages.shrinkIcon.image;
}
UIImageView *chevronView = [[UIImageView alloc] initWithImage:chevron];
chevronView.tintColor = ThemeService.shared.theme.textSecondaryColor;
chevronView.contentMode = UIViewContentModeCenter;
[sectionHeader addSubview:chevronView];
sectionHeader.accessoryView = chevronView;
}
else if (_recentsDataSourceMode == RecentsDataSourceModeHome)
if (_recentsDataSourceMode == RecentsDataSourceModeHome
|| _recentsDataSourceMode == RecentsDataSourceModePeople
|| _recentsDataSourceMode == RecentsDataSourceModeRooms)
{
// Add a badge to display the total of missed notifications by section.
UIView *badgeView = [self badgeViewForHeaderTitleInHomeSection:section];
UIView *badgeView = [self badgeViewForHeaderTitleInSection:section];
if (badgeView)
{
[sectionHeader addSubview:badgeView];
sectionHeader.accessoryView = badgeView;
sectionHeader.rightAccessoryView = badgeView;
}
}
@@ -870,7 +881,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
UILabel *headerLabel = [[UILabel alloc] initWithFrame:frame];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.attributedText = [self attributedStringForHeaderTitleInSection:section];
[sectionHeader addSubview:headerLabel];
sectionHeader.headerLabel = headerLabel;
return sectionHeader;
@@ -1494,7 +1504,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
- (void)recentsListServiceDidChangeData:(id<RecentsListServiceProtocol>)service
totalCountsChanged:(BOOL)totalCountsChanged
{
// no-op
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges];
}
- (void)recentsListServiceDidChangeData:(id<RecentsListServiceProtocol>)service
@@ -1532,4 +1542,55 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
[self.delegate dataSource:self didCellChange:update];
}
#pragma mark - Shrinkable
- (BOOL)isSectionShrinkedAt:(NSInteger)section
{
if (_areSectionsShrinkable == NO)
{
return NO;
}
if (section == favoritesSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_FAVORITES))
{
return YES;
}
if (section == peopleSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_PEOPLE))
{
return YES;
}
if (section == conversationSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_CONVERSATIONS))
{
return YES;
}
if (section == directorySection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_DIRECTORY))
{
return YES;
}
if (section == lowPrioritySection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_LOWPRIORITY))
{
return YES;
}
if (section == serverNoticeSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_SERVERNOTICE))
{
return YES;
}
if (section == invitesSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_INVITES))
{
return YES;
}
if (section == suggestedRoomsSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_SUGGESTED))
{
return YES;
}
return NO;
}
@end