Merge branch 'develop' into aringenbach/5745_mandatory_secure_backup

This commit is contained in:
Arnaud Ringenbach
2022-03-16 13:41:47 +01:00
16 changed files with 149 additions and 43 deletions
@@ -43,6 +43,13 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
var childCoordinators: [Coordinator] = []
var completion: ((AuthenticationCoordinatorResult) -> Void)?
var customServerFieldsVisible = false {
didSet {
guard customServerFieldsVisible != oldValue else { return }
authenticationViewController.setCustomServerFieldsVisible(customServerFieldsVisible)
}
}
// MARK: - Setup
init(parameters: AuthenticationCoordinatorParameters) {
@@ -74,10 +81,6 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
authenticationViewController.authType = authenticationType
}
func showCustomServer() {
authenticationViewController.setCustomServerFieldsVisible(true)
}
func update(externalRegistrationParameters: [AnyHashable: Any]) {
authenticationViewController.externalRegistrationParameters = externalRegistrationParameters
}
@@ -36,12 +36,12 @@ enum AuthenticationCoordinatorResult {
protocol AuthenticationCoordinatorProtocol: Coordinator, Presentable {
var completion: ((AuthenticationCoordinatorResult) -> Void)? { get set }
/// Whether the custom homeserver checkbox is enabled for the user to enter a homeserver URL.
var customServerFieldsVisible: Bool { get set }
/// Update the screen to display registration or login.
func update(authenticationType: MXKAuthenticationType)
/// Enable the custom server checkbox to allow the user to enter a homeserver URL.
func showCustomServer()
/// Force a registration process based on a predefined set of parameters from a server provisioning link.
/// For more information see `AuthenticationViewController.externalRegistrationParameters`.
func update(externalRegistrationParameters: [AnyHashable: Any])
@@ -504,6 +504,7 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0;
// Remove the potential back button.
self.navigationItem.leftBarButtonItem = nil;
[self.navigationItem setHidesBackButton:YES];
}
else
{
@@ -903,6 +904,12 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0;
authInputsview.thirdPartyIdentifiersHidden = YES;
[self updateRegistrationScreenWithThirdPartyIdentifiersHidden:YES];
// Show the social login buttons again if needed.
[self updateSocialLoginViewVisibility];
// Allow backward navigation in the flow again.
[self.navigationItem setHidesBackButton:NO];
}
}
else if (sender == self.submitButton)
@@ -947,7 +954,10 @@ static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0;
else
{
[self.authenticationActivityIndicator stopAnimating];
// Hide the social login buttons now that a different flow has started.
[self hideSocialLoginView];
// Show the supported 3rd party ids which may be added to the account
authInputsview.thirdPartyIdentifiersHidden = NO;
[self updateRegistrationScreenWithThirdPartyIdentifiersHidden:NO];
@@ -30,21 +30,23 @@ import CommonKit
self.presenter = presenter
}
@objc func presentActivityIndicator() {
presentActivityIndicator(label: VectorL10n.homeSyncing)
@objc func presentLoadingIndicator() {
presentLoadingIndicator(label: VectorL10n.homeSyncing)
}
@objc func presentActivityIndicator(label: String) {
@objc func presentLoadingIndicator(label: String) {
guard loadingIndicator == nil else {
// The app is very liberal with calling `presentActivityIndicator` (often not matched by corresponding `removeCurrentActivityIndicator`),
// The app is very liberal with calling `presentLoadingIndicator` (often not matched by corresponding `dismissLoadingIndicator`),
// so there is no reason to keep adding new indiciators if there is one already showing.
return
}
MXLog.debug("[UserIndicatorPresenterWrapper] Present loading indicator")
loadingIndicator = presenter.present(.loading(label: label, isInteractionBlocking: false))
}
@objc func dismissActivityIndicator() {
@objc func dismissLoadingIndicator() {
MXLog.debug("[UserIndicatorPresenterWrapper] Dismiss loading indicator")
loadingIndicator = nil
}
@@ -64,6 +64,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
// when the user selects it.
UISearchBar *tableSearchBar;
// Flag indicating whether the view controller is (at least partially) visible and not dissapearing
BOOL isViewVisible;
// Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change.
__weak id kThemeServiceDidChangeThemeNotificationObserver;
}
@@ -264,6 +267,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
isViewVisible = YES;
[self.screenTracker trackScreen];
@@ -301,6 +305,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
isViewVisible = NO;
// Leave potential editing mode
[self cancelEditionMode:NO];
@@ -2419,16 +2424,16 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}
- (void)startActivityIndicatorWithLabel:(NSString *)label {
if (self.indicatorPresenter) {
[self.indicatorPresenter presentActivityIndicatorWithLabel:label];
if (self.indicatorPresenter && isViewVisible) {
[self.indicatorPresenter presentLoadingIndicatorWithLabel:label];
} else {
[super startActivityIndicator];
}
}
- (void)startActivityIndicator {
if (self.indicatorPresenter) {
[self.indicatorPresenter presentActivityIndicator];
if (self.indicatorPresenter && isViewVisible) {
[self.indicatorPresenter presentLoadingIndicator];
} else {
[super startActivityIndicator];
}
@@ -2436,7 +2441,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)stopActivityIndicator {
if (self.indicatorPresenter) {
[self.indicatorPresenter dismissActivityIndicator];
[self.indicatorPresenter dismissLoadingIndicator];
} else {
[super stopActivityIndicator];
}
@@ -1261,7 +1261,7 @@ static NSString *const kHTMLATagRegexPattern = @"<a href=\"(.*?)\">([^<]*)</a>";
isHTML =YES;
MXJSONModelSetString(body, event.content[@"formatted_body"]);
}
else if (eventThreadId && !RiotSettings.shared.enableThreads)
else if (event.isReplyEvent || (eventThreadId && !RiotSettings.shared.enableThreads))
{
NSString *repliedEventId = event.relatesTo.inReplyTo.eventId ?: eventThreadId;
isHTML = YES;
@@ -2067,7 +2067,7 @@ static NSString *const kHTMLATagRegexPattern = @"<a href=\"(.*?)\">([^<]*)</a>";
textColor = _errorTextColor;
}
// Check whether the message is highlighted.
else if (event.mxkIsHighlighted || (!RiotSettings.shared.enableThreads && event.isInThread && [event shouldBeHighlightedInSession:mxSession]))
else if (event.mxkIsHighlighted || (mxSession && [event shouldBeHighlightedInSession:mxSession]))
{
textColor = _bingTextColor;
}
@@ -2132,7 +2132,7 @@ static NSString *const kHTMLATagRegexPattern = @"<a href=\"(.*?)\">([^<]*)</a>";
{
font = _callNoticesTextFont;
}
else if (event.mxkIsHighlighted || (!RiotSettings.shared.enableThreads && event.isInThread && [event shouldBeHighlightedInSession:mxSession]))
else if (event.mxkIsHighlighted || (mxSession && [event shouldBeHighlightedInSession:mxSession]))
{
font = _bingTextFont;
}
@@ -215,9 +215,7 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
coordinator.update(externalRegistrationParameters: externalRegistrationParameters)
}
if useCaseResult == .customServer {
coordinator.showCustomServer()
}
coordinator.customServerFieldsVisible = useCaseResult == .customServer
if let softLogoutCredentials = parameters.softLogoutCredentials {
coordinator.update(softLogoutCredentials: softLogoutCredentials)
+71 -8
View File
@@ -568,7 +568,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
isAppeared = NO;
[VoiceMessageMediaServiceProvider.sharedProvider pauseAllServices];
[self stopActivityIndicator];
// Stop the loading indicator even if the session is still in progress
[self stopLoadingUserIndicator];
}
- (void)viewDidAppear:(BOOL)animated
@@ -938,10 +940,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
self.updateRoomReadMarker = NO;
}
#pragma mark - Loading indicators
- (BOOL)providesCustomActivityIndicator {
return [self.delegate roomViewControllerCanDelegateUserIndicators:self];
}
// Override of a legacy method to determine whether to use a newer implementation instead.
// Will be removed in the future https://github.com/vector-im/element-ios/issues/5608
- (void)startActivityIndicator {
if ([self providesCustomActivityIndicator]) {
[self.delegate roomViewControllerDidStartLoading:self];
@@ -950,6 +956,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
}
}
// Override of a legacy method to determine whether to use a newer implementation instead.
// Will be removed in the future https://github.com/vector-im/element-ios/issues/5608
- (void)stopActivityIndicator
{
if (notificationTaskProfile)
@@ -959,14 +967,22 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
notificationTaskProfile = nil;
}
if ([self providesCustomActivityIndicator]) {
// The legacy super implementation of `stopActivityIndicator` contains a number of checks grouped under `canStopActivityIndicator`
// to determine whether the indicator can be stopped or not (and the method should thus rather be called `stopActivityIndicatorIfPossible`).
// Since the newer indicators are not calling super implementation, the check for `canStopActivityIndicator` has to be performed manually.
if ([self canStopActivityIndicator]) {
[self.delegate roomViewControllerDidStopLoading:self];
[self stopLoadingUserIndicator];
}
} else {
[super stopActivityIndicator];
}
}
- (void)stopLoadingUserIndicator
{
[self.delegate roomViewControllerDidStopLoading:self];
}
- (void)displayRoom:(MXKRoomDataSource *)dataSource
{
// Remove potential preview Data
@@ -1261,6 +1277,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
if (!bubbleTableViewDisplayInTransition && !self.bubblesTableView.isHidden)
{
[self refreshActivitiesViewDisplay];
[self refreshRoomTitle];
[self checkReadMarkerVisibility];
[self refreshJumpToLastUnreadBannerDisplay];
@@ -4963,10 +4980,32 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
}
else if (tappedView == previewHeader.leftButton)
{
[self declineRoomInvitation];
[self presentDeclineOptionsFromView:tappedView];
}
}
- (void)presentDeclineOptionsFromView:(UIView *)view
{
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:[VectorL10n roomPreviewDeclineInvitationOptions]
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n decline]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
[self declineRoomInvitation];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n ignoreUser]
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * _Nonnull action) {
[self ignoreInviteSender];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel]
style:UIAlertActionStyleCancel
handler:nil]];
actionSheet.popoverPresentationController.sourceView = view;
[self presentViewController:actionSheet animated:YES completion:nil];
}
- (void)declineRoomInvitation
{
// 'Decline' button has been pressed
@@ -4977,16 +5016,15 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
else
{
[self startActivityIndicator];
MXWeakify(self);
[self.roomDataSource.room leave:^{
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
// We remove the current view controller.
// Pop to homes view controller
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
[self popToHomeViewController];
} failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
MXLogDebug(@"[RoomVC] Failed to reject an invited room (%@) failed", self.roomDataSource.room.roomId);
@@ -4995,6 +5033,31 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
}
}
- (void)ignoreInviteSender
{
[self startActivityIndicator];
MXWeakify(self);
[self.roomDataSource.room ignoreInviteSender:^{
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
[self popToHomeViewController];
} failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
MXLogDebug(@"[RoomVC] Failed to ignore inviter in room (%@)", self.roomDataSource.room.roomId);
}];
}
- (void)popToHomeViewController
{
// We remove the current view controller.
// Pop to homes view controller
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
}
#pragma mark - Typing management
- (void)removeTypingNotificationsListener