* Loading animation: Fix the bug where, after authentication, the animation disappeared too early and made auth screen flashed.

This commit is contained in:
manuroe 2020-09-15 16:48:35 +02:00
parent 82b4025c3b
commit 35aa4b7549
6 changed files with 84 additions and 15 deletions

View file

@ -10,6 +10,7 @@ Changes to be released in next version
🐛 Bugfix 🐛 Bugfix
* AuthVC: Fix PIN setup that broke cross-signing bootstrap. * AuthVC: Fix PIN setup that broke cross-signing bootstrap.
* Loading animation: Fix the bug where, after authentication, the animation disappeared too early and made auth screen flashed.
⚠️ API Changes ⚠️ API Changes
* *

View file

@ -89,7 +89,7 @@ NSString *const AppDelegateDidValidateEmailNotificationClientSecretKey = @"AppDe
NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUniversalLinkDidChangeNotification"; NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUniversalLinkDidChangeNotification";
@interface LegacyAppDelegate () <GDPRConsentViewControllerDelegate, KeyVerificationCoordinatorBridgePresenterDelegate, ServiceTermsModalCoordinatorBridgePresenterDelegate, PushNotificationServiceDelegate, SetPinCoordinatorBridgePresenterDelegate> @interface LegacyAppDelegate () <GDPRConsentViewControllerDelegate, KeyVerificationCoordinatorBridgePresenterDelegate, ServiceTermsModalCoordinatorBridgePresenterDelegate, PushNotificationServiceDelegate, SetPinCoordinatorBridgePresenterDelegate, MasterTabBarControllerDelegate>
{ {
/** /**
Reachability observer Reachability observer
@ -2443,6 +2443,16 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
{ {
BOOL isLaunching = NO; BOOL isLaunching = NO;
if (_masterTabBarController.authenticationInProgress)
{
NSLog(@"[AppDelegate] handleLaunchAnimation: Authentication still in progress");
// Wait for the return of masterTabBarControllerDidCompleteAuthentication
isLaunching = YES;
_masterTabBarController.masterVCDelegate = self;
}
else
{
switch (mainSession.state) switch (mainSession.state)
{ {
case MXSessionStateClosed: case MXSessionStateClosed:
@ -2458,9 +2468,12 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
isLaunching = NO; isLaunching = NO;
break; break;
} }
}
if (isLaunching) if (isLaunching)
{ {
NSLog(@"[AppDelegate] handleLaunchAnimation: LaunchLoadingView");
UIWindow *window = [[UIApplication sharedApplication] keyWindow]; UIWindow *window = [[UIApplication sharedApplication] keyWindow];
if (!launchAnimationContainerView && window) if (!launchAnimationContainerView && window)
@ -2478,6 +2491,10 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
return; return;
} }
else
{
NSLog(@"[AppDelegate] handleLaunchAnimation: isLaunching: NO");
}
} }
if (launchAnimationContainerView) if (launchAnimationContainerView)

View file

@ -1,6 +1,7 @@
/* /*
Copyright 2015 OpenMarket Ltd Copyright 2015 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd Copyright 2017 Vector Creations Ltd
Copyright 2020 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -17,8 +18,14 @@
#import <MatrixKit/MatrixKit.h> #import <MatrixKit/MatrixKit.h>
@protocol AuthenticationViewControllerDelegate;
@interface AuthenticationViewController : MXKAuthenticationViewController <MXKAuthenticationViewControllerDelegate> @interface AuthenticationViewController : MXKAuthenticationViewController <MXKAuthenticationViewControllerDelegate>
// MXKAuthenticationViewController has already a `delegate` member
@property (nonatomic, weak) id<AuthenticationViewControllerDelegate> authVCDelegate;
@property (weak, nonatomic) IBOutlet UIView *navigationBackView; @property (weak, nonatomic) IBOutlet UIView *navigationBackView;
@property (weak, nonatomic) IBOutlet UINavigationBar *navigationBar; @property (weak, nonatomic) IBOutlet UINavigationBar *navigationBar;
@property (weak, nonatomic) IBOutlet UIView *navigationBarSeparatorView; @property (weak, nonatomic) IBOutlet UIView *navigationBarSeparatorView;
@ -50,3 +57,9 @@
@end @end
@protocol AuthenticationViewControllerDelegate <NSObject>
- (void)authenticationViewControllerDidDismiss:(AuthenticationViewController *)authenticationViewController;
@end;

View file

@ -521,6 +521,11 @@
// Dismiss on successful login // Dismiss on successful login
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
} }
if (self.authVCDelegate)
{
[self.authVCDelegate authenticationViewControllerDidDismiss:self];
}
} }
#pragma mark - Fallback URL display #pragma mark - Fallback URL display

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2017 Vector Creations Ltd Copyright 2017 Vector Creations Ltd
Copyright 2020 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -35,6 +36,10 @@
#define TABBAR_GROUPS_INDEX 4 #define TABBAR_GROUPS_INDEX 4
#define TABBAR_COUNT 5 #define TABBAR_COUNT 5
@protocol MasterTabBarControllerDelegate;
@interface MasterTabBarController : UITabBarController @interface MasterTabBarController : UITabBarController
@property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsBarButtonItem; @property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsBarButtonItem;
@ -136,6 +141,7 @@
*/ */
- (void)refreshTabBarBadges; - (void)refreshTabBarBadges;
@property (nonatomic, weak) id<MasterTabBarControllerDelegate> masterVCDelegate;
// Reference to the current auth VC. It is not nil only when the auth screen is displayed. // Reference to the current auth VC. It is not nil only when the auth screen is displayed.
@property (nonatomic, readonly) AuthenticationViewController *authViewController; @property (nonatomic, readonly) AuthenticationViewController *authViewController;
@ -163,5 +169,14 @@
@property (nonatomic, readonly) MXGroup *selectedGroup; @property (nonatomic, readonly) MXGroup *selectedGroup;
@property (nonatomic, readonly) MXSession *selectedGroupSession; @property (nonatomic, readonly) MXSession *selectedGroupSession;
// YES while the authentication screen is displayed
@property (nonatomic, readonly) BOOL authenticationInProgress;
@end @end
@protocol MasterTabBarControllerDelegate <NSObject>
- (void)masterTabBarControllerDidCompleteAuthentication:(MasterTabBarController *)masterTabBarController;
@end;

View file

@ -31,7 +31,7 @@
#import "Riot-Swift.h" #import "Riot-Swift.h"
@interface MasterTabBarController () @interface MasterTabBarController () <AuthenticationViewControllerDelegate>
{ {
// Array of `MXSession` instances. // Array of `MXSession` instances.
NSMutableArray *mxSessionArray; NSMutableArray *mxSessionArray;
@ -79,6 +79,8 @@
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
_authenticationInProgress = NO;
// Note: UITabBarViewController shoud not be embed in a UINavigationController (https://github.com/vector-im/riot-ios/issues/3086) // Note: UITabBarViewController shoud not be embed in a UINavigationController (https://github.com/vector-im/riot-ios/issues/3086)
[self vc_removeBackTitle]; [self vc_removeBackTitle];
@ -418,6 +420,7 @@
if (!self.authViewController && !isAuthViewControllerPreparing) if (!self.authViewController && !isAuthViewControllerPreparing)
{ {
isAuthViewControllerPreparing = YES; isAuthViewControllerPreparing = YES;
_authenticationInProgress = YES;
[self resetReviewSessionsFlags]; [self resetReviewSessionsFlags];
@ -464,6 +467,7 @@
if (!self.authViewController && !isAuthViewControllerPreparing) if (!self.authViewController && !isAuthViewControllerPreparing)
{ {
isAuthViewControllerPreparing = YES; isAuthViewControllerPreparing = YES;
_authenticationInProgress = YES;
[[AppDelegate theDelegate] restoreInitialDisplay:^{ [[AppDelegate theDelegate] restoreInitialDisplay:^{
@ -695,6 +699,9 @@
_authViewController = segue.destinationViewController; _authViewController = segue.destinationViewController;
isAuthViewControllerPreparing = NO; isAuthViewControllerPreparing = NO;
// Listen to the end of the authentication flow
_authViewController.authVCDelegate = self;
authViewControllerObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXKAccountManagerDidAddAccountNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { authViewControllerObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXKAccountManagerDidAddAccountNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
_authViewController = nil; _authViewController = nil;
@ -1163,4 +1170,15 @@
} }
} }
#pragma mark - AuthenticationViewControllerDelegate
- (void)authenticationViewControllerDidDismiss:(AuthenticationViewController *)authenticationViewController
{
_authenticationInProgress = NO;
if (self.masterVCDelegate)
{
[self.masterVCDelegate masterTabBarControllerDidCompleteAuthentication:self];
}
}
@end @end