mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 13:16:58 +02:00
b298dedc22
Merge commit 'f823ab9aae70e8d15ed7cc079210dd9bbbb6c8e1' into feature/foss_update_1_11_19 * commit 'f823ab9aae70e8d15ed7cc079210dd9bbbb6c8e1': finish version++ version++ comments update submodule remove obsolete tests removed unused code update submodule fix Libolm removal update license macro update license Prepare for new sprint # Conflicts: # Config/AppVersion.xcconfig # IDETemplateMacros.plist # LICENSE # README.md # Riot/Categories/MXSession+Riot.m # Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift # Riot/Managers/KeyValueStorage/Extensions/Keychain.swift # Riot/Managers/KeyValueStorage/KeyValueStore.swift # Riot/Managers/KeyValueStorage/KeychainStore.swift # Riot/Managers/KeyValueStorage/MemoryStore.swift # Riot/Managers/PushNotification/PushNotificationService.m # Riot/Managers/Settings/RiotSettings.swift # Riot/Managers/Settings/Shared/RiotSharedSettings.swift # Riot/Modules/Analytics/AnalyticsUIElement.swift # Riot/Modules/Application/AppCoordinator.swift # Riot/Modules/Application/LegacyAppDelegate.h # Riot/Modules/Application/LegacyAppDelegate.m # Riot/Modules/Authentication/Legacy/AuthenticationViewController.h # Riot/Modules/Authentication/Legacy/AuthenticationViewController.m # Riot/Modules/Authentication/Legacy/Views/AuthInputsView.h # Riot/Modules/Authentication/Legacy/Views/AuthInputsView.m # Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m # Riot/Modules/Common/Recents/RecentsViewController.m # Riot/Modules/Common/WebViewController/WebViewViewController.m # Riot/Modules/Contacts/Details/ContactDetailsViewController.m # Riot/Modules/Contacts/Views/ContactTableViewCell.m # Riot/Modules/Favorites/FavouritesViewController.h # Riot/Modules/Favorites/FavouritesViewController.m # Riot/Modules/GlobalSearch/UnifiedSearchViewController.m # Riot/Modules/People/PeopleViewController.h # Riot/Modules/People/PeopleViewController.m # Riot/Modules/Room/ContextualMenu/ReactionsMenu/ReactionsMenuViewModel.swift # Riot/Modules/Room/DataSources/RoomDataSource.m # Riot/Modules/Room/Files/RoomFilesViewController.m # Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m # Riot/Modules/Room/Members/RoomParticipantsViewController.m # Riot/Modules/Room/RoomViewController.m # Riot/Modules/Room/Settings/RoomSettingsViewController.m # Riot/Modules/Room/TimelineCells/RoomCreationIntro/RoomCreationIntroCell.swift # Riot/Modules/Room/TimelineCells/RoomCreationIntro/RoomCreationIntroCellContentView.swift # Riot/Modules/Room/TimelineCells/RoomCreationIntro/RoomCreationIntroViewData.swift # Riot/Modules/Room/TimelineCells/RoomTimelineCellIdentifier.h # Riot/Modules/Rooms/RoomsViewController.h # Riot/Modules/Rooms/ShowDirectory/Cells/Network/DirectoryNetworkTableHeaderFooterView.swift # Riot/Modules/Rooms/ShowDirectory/Cells/Room/DirectoryRoomTableViewCell.swift # Riot/Modules/Rooms/ShowDirectory/PublicRoomsDirectoryViewModel.swift # Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyCoordinator.swift # Riot/Modules/Secrets/Recover/RecoverWithKey/SecretsRecoveryWithKeyViewController.swift # Riot/Modules/Secrets/Recover/RecoverWithPassphrase/SecretsRecoveryWithPassphraseCoordinator.swift # Riot/Modules/Secrets/Recover/RecoverWithPassphrase/SecretsRecoveryWithPassphraseViewController.swift # Riot/Modules/Secrets/Recover/SecretsRecoveryCoordinator.swift # Riot/Modules/SecureBackup/Setup/Intro/SecureBackupSetupIntroViewController.swift # Riot/Modules/SecureBackup/Setup/Intro/SecureBackupSetupIntroViewModel.swift # Riot/Modules/SecureBackup/Setup/Intro/SecureBackupSetupIntroViewModelType.swift # Riot/Modules/SetPinCode/PinCodePreferences.swift # Riot/Modules/SetPinCode/SetupBiometrics/BiometricsAuthenticationPresenter.swift # Riot/Modules/Settings/Security/ManageSession/ManageSessionViewController.m # Riot/Modules/Settings/Security/SecurityViewController.m # Riot/Modules/Settings/SettingsViewController.m # Riot/Modules/SplitView/SplitViewCoordinator.swift # Riot/Modules/SplitView/SplitViewCoordinatorType.swift # Riot/Modules/StartChat/StartChatViewController.m # Riot/Modules/TabBar/MasterTabBarController.h # Riot/Modules/TabBar/MasterTabBarController.m # Riot/Utils/EventFormatter.m # Riot/Utils/HTMLFormatter.swift # Riot/Utils/Tools.m # RiotNSE/NotificationService.swift
296 lines
10 KiB
Objective-C
296 lines
10 KiB
Objective-C
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2017 Vector Creations Ltd
|
|
Copyright 2015 OpenMarket Ltd
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
Please see LICENSE in the repository root for full details.
|
|
*/
|
|
|
|
#import "RoomTitleView.h"
|
|
|
|
#import "ThemeService.h"
|
|
#import "GeneratedInterface-Swift.h"
|
|
|
|
@implementation RoomTitleView
|
|
|
|
+ (UINib *)nib
|
|
{
|
|
return [UINib nibWithNibName:NSStringFromClass([RoomTitleView class])
|
|
bundle:[NSBundle bundleForClass:[RoomTitleView class]]];
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
_roomPreviewData = nil;
|
|
}
|
|
|
|
- (void)awakeFromNib
|
|
{
|
|
[super awakeFromNib];
|
|
|
|
self.badgeImageView.image = nil;
|
|
|
|
if (_titleMask)
|
|
{
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reportTapGesture:)];
|
|
[tap setNumberOfTouchesRequired:1];
|
|
[tap setNumberOfTapsRequired:1];
|
|
[tap setDelegate:self];
|
|
[self.titleMask addGestureRecognizer:tap];
|
|
self.titleMask.userInteractionEnabled = YES;
|
|
self.dotView.layer.masksToBounds = YES;
|
|
self.dotView.layer.cornerRadius = CGRectGetMidX(self.dotView.bounds);
|
|
}
|
|
|
|
// bwi: #5226 us12 add federation icon to navigationViewTitle
|
|
if (self.pillImageView == nil)
|
|
{
|
|
self.pillImageView = [self addFederationPill:self.pictureView];
|
|
[self addSubview:self.pillImageView];
|
|
}
|
|
}
|
|
|
|
- (void)layoutSubviews
|
|
{
|
|
[super layoutSubviews];
|
|
|
|
self.pictureView.layer.cornerRadius = self.pictureView.bounds.size.width / 2.;
|
|
|
|
// bwi: #5226 us12 add federation icon to navigationViewTitle
|
|
if (self.pillImageView)
|
|
{
|
|
self.pillImageView.image = FederationIconHelper.shared.federationBadgeImage;
|
|
}
|
|
|
|
if (self.superview)
|
|
{
|
|
// Force the title view layout by adding 2 new constraints on the UINavigationBarContentView instance.
|
|
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self
|
|
attribute:NSLayoutAttributeTop
|
|
relatedBy:NSLayoutRelationEqual
|
|
toItem:self.superview
|
|
attribute:NSLayoutAttributeTop
|
|
multiplier:1.0f
|
|
constant:0.0f];
|
|
NSLayoutConstraint *centerXConstraint = [NSLayoutConstraint constraintWithItem:self
|
|
attribute:NSLayoutAttributeCenterX
|
|
relatedBy:NSLayoutRelationEqual
|
|
toItem:self.superview
|
|
attribute:NSLayoutAttributeCenterX
|
|
multiplier:1.0f
|
|
constant:0.0f];
|
|
|
|
[NSLayoutConstraint activateConstraints:@[topConstraint, centerXConstraint]];
|
|
}
|
|
}
|
|
|
|
-(void)customizeViewRendering
|
|
{
|
|
[super customizeViewRendering];
|
|
|
|
self.backgroundColor = UIColor.clearColor;
|
|
self.displayNameTextField.textColor = (self.mxRoom.summary.displayName.length ? ThemeService.shared.theme.textPrimaryColor : ThemeService.shared.theme.textSecondaryColor);
|
|
self.typingLabel.textColor = ThemeService.shared.theme.textSecondaryColor;
|
|
self.dotView.backgroundColor = ThemeService.shared.theme.warningColor;
|
|
self.missedDiscussionsBadgeLabel.textColor = ThemeService.shared.theme.tintColor;
|
|
}
|
|
|
|
- (void)setRoomPreviewData:(RoomPreviewData *)roomPreviewData
|
|
{
|
|
_roomPreviewData = roomPreviewData;
|
|
|
|
[self refreshDisplay];
|
|
}
|
|
|
|
- (void)refreshDisplay
|
|
{
|
|
[super refreshDisplay];
|
|
|
|
// Consider in priority the preview data (if any)
|
|
if (self.roomPreviewData)
|
|
{
|
|
self.displayNameTextField.text = self.roomPreviewData.roomName;
|
|
}
|
|
else if (self.mxRoom)
|
|
{
|
|
if (self.mxRoom.directUserId)
|
|
{
|
|
MXUser *contact = [self.mxRoom.mxSession userWithUserId:self.mxRoom.directUserId];
|
|
self.presenceIndicatorView.borderColor = ThemeService.shared.theme.headerBackgroundColor;
|
|
self.presenceIndicatorView.delegate = self;
|
|
[self.presenceIndicatorView configureWithUserId:self.mxRoom.directUserId presence:contact.presence];
|
|
}
|
|
else
|
|
{
|
|
[self.presenceIndicatorView stopListeningPresenceUpdates];
|
|
}
|
|
|
|
self.displayNameTextField.text = self.mxRoom.summary.displayName;
|
|
|
|
// bwi: #5226 us12 add federation icons to navigationViewTitle
|
|
if (self.pillImageView)
|
|
{
|
|
[self shouldShowFederationUI:^(BOOL isFederated) {
|
|
if (isFederated)
|
|
{
|
|
self.pillImageView.hidden = false;
|
|
self.displayNameTextField.rightViewMode = UITextFieldViewModeAlways;
|
|
self.displayNameTextField.rightView = [FederationIconHelper.shared getRoomFederationPillViewWithTextView:self.displayNameTextField];
|
|
}
|
|
else
|
|
{
|
|
self.pillImageView.hidden = true;
|
|
self.displayNameTextField.rightViewMode = UITextFieldViewModeNever;
|
|
}
|
|
}];
|
|
}
|
|
|
|
|
|
if (!self.displayNameTextField.text.length)
|
|
{
|
|
self.displayNameTextField.text = [VectorL10n roomDisplaynameEmptyRoom];
|
|
self.displayNameTextField.textColor = ThemeService.shared.theme.textSecondaryColor;
|
|
}
|
|
else
|
|
{
|
|
self.displayNameTextField.textColor = ThemeService.shared.theme.textPrimaryColor;
|
|
}
|
|
}
|
|
}
|
|
|
|
// bwi: #6171 add federation pill icon for room detail view / invite detail view
|
|
- (void)shouldShowFederationUI:(void (^)(BOOL))callback
|
|
{
|
|
if (BWIBuildSettings.shared.isFederationEnabled)
|
|
{
|
|
if (![self.mxRoom isPersonalNotesRoom])
|
|
{
|
|
if ([self.mxRoom isDirect])
|
|
{
|
|
callback([self.mxRoom isDMFederated]);
|
|
}
|
|
else
|
|
{
|
|
[self.mxRoom getFederationStatusWithCompletion:^(BOOL isFederated) {
|
|
callback(isFederated);
|
|
}];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
callback(false);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
callback(false);
|
|
}
|
|
}
|
|
|
|
// bwi: #6171 add federation pill icon for room detail view / invite detail view
|
|
- (UIImageView*)addFederationPill:(UIView*)avatarImageView
|
|
{
|
|
// bwi: #5226 us12 add federation icon to navigationViewTitle
|
|
UIImageView *imageView = [FederationIconHelper.shared getFederatedIconImageViewWithAvatarFrame:avatarImageView.frame];
|
|
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
if (BWIBuildSettings.shared.isFederationEnabled)
|
|
{
|
|
imageView.image = FederationIconHelper.shared.federationBadgeImage;
|
|
}
|
|
|
|
return imageView;
|
|
}
|
|
|
|
- (void)destroy
|
|
{
|
|
self.tapGestureDelegate = nil;
|
|
|
|
[super destroy];
|
|
}
|
|
|
|
- (void)reportTapGesture:(UITapGestureRecognizer*)tapGestureRecognizer
|
|
{
|
|
if (self.tapGestureDelegate)
|
|
{
|
|
[self.tapGestureDelegate roomTitleView:self recognizeTapGesture:tapGestureRecognizer];
|
|
}
|
|
}
|
|
|
|
- (void)updateLayoutForOrientation:(UIInterfaceOrientation)orientation
|
|
{
|
|
if (UIInterfaceOrientationIsLandscape(orientation))
|
|
{
|
|
self.missedDiscussionsBadgeLabel.font = [UIFont systemFontOfSize:10];
|
|
self.missedDiscussionsBadgeLabelLeadingConstraint.constant = -24;
|
|
self.pictureViewWidthConstraint.constant = 28;
|
|
self.pictureViewHeightConstraint.constant = 28;
|
|
self.displayNameTextField.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
|
self.typingLabel.font = [UIFont systemFontOfSize:10];
|
|
self.dotViewCenterYConstraint.constant = -2;
|
|
}
|
|
else
|
|
{
|
|
self.missedDiscussionsBadgeLabel.font = [UIFont systemFontOfSize:15];
|
|
self.missedDiscussionsBadgeLabelLeadingConstraint.constant = -32;
|
|
self.pictureViewWidthConstraint.constant = 32;
|
|
self.pictureViewHeightConstraint.constant = 32;
|
|
self.displayNameTextField.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium];
|
|
self.typingLabel.font = [UIFont systemFontOfSize:12];
|
|
self.dotViewCenterYConstraint.constant = -1;
|
|
}
|
|
}
|
|
|
|
- (void)setTypingNotificationString:(NSString *)typingNotificationString
|
|
{
|
|
if (typingNotificationString.length > 0)
|
|
{
|
|
self.typingLabel.text = typingNotificationString;
|
|
[self layoutIfNeeded];
|
|
|
|
[UIView animateWithDuration:.1 animations:^{
|
|
self.typingLabel.alpha = 1;
|
|
self.displayNameCenterYConstraint.constant = -8;
|
|
[self layoutIfNeeded];
|
|
}];
|
|
}
|
|
else
|
|
{
|
|
[UIView animateWithDuration:.1 animations:^{
|
|
self.typingLabel.alpha = 0;
|
|
self.displayNameCenterYConstraint.constant = 0;
|
|
[self layoutIfNeeded];
|
|
} completion:^(BOOL finished) {
|
|
self.typingLabel.text = nil;
|
|
}];
|
|
}
|
|
}
|
|
|
|
- (NSString *)typingNotificationString
|
|
{
|
|
return self.typingLabel.text;
|
|
}
|
|
|
|
#pragma mark - PresenceIndicatorViewDelegate
|
|
|
|
- (void)presenceIndicatorViewDidUpdateVisibility:(PresenceIndicatorView *)presenceIndicatorView isHidden:(BOOL)isHidden
|
|
{
|
|
if (isHidden)
|
|
{
|
|
[self.badgeImageViewLeadingToPictureViewConstraint setPriority:UILayoutPriorityDefaultLow];
|
|
[self.badgeImageViewCenterYToDisplayNameConstraint setPriority:UILayoutPriorityDefaultLow];
|
|
[self.badgeImageViewToPictureViewBottomConstraint setPriority:UILayoutPriorityRequired];
|
|
[self.badgeImageViewToPictureViewTrailingConstraint setPriority:UILayoutPriorityRequired];
|
|
}
|
|
else
|
|
{
|
|
[self.badgeImageViewToPictureViewBottomConstraint setPriority:UILayoutPriorityDefaultLow];
|
|
[self.badgeImageViewToPictureViewTrailingConstraint setPriority:UILayoutPriorityDefaultLow];
|
|
[self.badgeImageViewLeadingToPictureViewConstraint setPriority:UILayoutPriorityRequired];
|
|
[self.badgeImageViewCenterYToDisplayNameConstraint setPriority:UILayoutPriorityRequired];
|
|
}
|
|
}
|
|
|
|
@end
|