mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
* Loading animation: Fix the bug where, after authentication, the animation disappeared too early and made auth screen flashed.
This commit is contained in:
parent
82b4025c3b
commit
35aa4b7549
6 changed files with 84 additions and 15 deletions
|
@ -10,6 +10,7 @@ Changes to be released in next version
|
|||
|
||||
🐛 Bugfix
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -89,7 +89,7 @@ NSString *const AppDelegateDidValidateEmailNotificationClientSecretKey = @"AppDe
|
|||
|
||||
NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUniversalLinkDidChangeNotification";
|
||||
|
||||
@interface LegacyAppDelegate () <GDPRConsentViewControllerDelegate, KeyVerificationCoordinatorBridgePresenterDelegate, ServiceTermsModalCoordinatorBridgePresenterDelegate, PushNotificationServiceDelegate, SetPinCoordinatorBridgePresenterDelegate>
|
||||
@interface LegacyAppDelegate () <GDPRConsentViewControllerDelegate, KeyVerificationCoordinatorBridgePresenterDelegate, ServiceTermsModalCoordinatorBridgePresenterDelegate, PushNotificationServiceDelegate, SetPinCoordinatorBridgePresenterDelegate, MasterTabBarControllerDelegate>
|
||||
{
|
||||
/**
|
||||
Reachability observer
|
||||
|
@ -2443,24 +2443,37 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
{
|
||||
BOOL isLaunching = NO;
|
||||
|
||||
switch (mainSession.state)
|
||||
if (_masterTabBarController.authenticationInProgress)
|
||||
{
|
||||
case MXSessionStateClosed:
|
||||
case MXSessionStateInitialised:
|
||||
isLaunching = YES;
|
||||
break;
|
||||
case MXSessionStateStoreDataReady:
|
||||
case MXSessionStateSyncInProgress:
|
||||
// Stay in launching during the first server sync if the store is empty.
|
||||
isLaunching = (mainSession.rooms.count == 0 && launchAnimationContainerView);
|
||||
break;
|
||||
default:
|
||||
isLaunching = NO;
|
||||
break;
|
||||
NSLog(@"[AppDelegate] handleLaunchAnimation: Authentication still in progress");
|
||||
|
||||
// Wait for the return of masterTabBarControllerDidCompleteAuthentication
|
||||
isLaunching = YES;
|
||||
_masterTabBarController.masterVCDelegate = self;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (mainSession.state)
|
||||
{
|
||||
case MXSessionStateClosed:
|
||||
case MXSessionStateInitialised:
|
||||
isLaunching = YES;
|
||||
break;
|
||||
case MXSessionStateStoreDataReady:
|
||||
case MXSessionStateSyncInProgress:
|
||||
// Stay in launching during the first server sync if the store is empty.
|
||||
isLaunching = (mainSession.rooms.count == 0 && launchAnimationContainerView);
|
||||
break;
|
||||
default:
|
||||
isLaunching = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isLaunching)
|
||||
{
|
||||
NSLog(@"[AppDelegate] handleLaunchAnimation: LaunchLoadingView");
|
||||
|
||||
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
|
||||
|
||||
if (!launchAnimationContainerView && window)
|
||||
|
@ -2478,6 +2491,10 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"[AppDelegate] handleLaunchAnimation: isLaunching: NO");
|
||||
}
|
||||
}
|
||||
|
||||
if (launchAnimationContainerView)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright 2020 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -17,8 +18,14 @@
|
|||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
@protocol AuthenticationViewControllerDelegate;
|
||||
|
||||
|
||||
@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 UINavigationBar *navigationBar;
|
||||
@property (weak, nonatomic) IBOutlet UIView *navigationBarSeparatorView;
|
||||
|
@ -50,3 +57,9 @@
|
|||
|
||||
@end
|
||||
|
||||
|
||||
@protocol AuthenticationViewControllerDelegate <NSObject>
|
||||
|
||||
- (void)authenticationViewControllerDidDismiss:(AuthenticationViewController *)authenticationViewController;
|
||||
|
||||
@end;
|
||||
|
|
|
@ -521,6 +521,11 @@
|
|||
// Dismiss on successful login
|
||||
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
if (self.authVCDelegate)
|
||||
{
|
||||
[self.authVCDelegate authenticationViewControllerDidDismiss:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Fallback URL display
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright 2020 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (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_COUNT 5
|
||||
|
||||
|
||||
@protocol MasterTabBarControllerDelegate;
|
||||
|
||||
|
||||
@interface MasterTabBarController : UITabBarController
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsBarButtonItem;
|
||||
|
@ -136,6 +141,7 @@
|
|||
*/
|
||||
- (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.
|
||||
@property (nonatomic, readonly) AuthenticationViewController *authViewController;
|
||||
|
@ -163,5 +169,14 @@
|
|||
@property (nonatomic, readonly) MXGroup *selectedGroup;
|
||||
@property (nonatomic, readonly) MXSession *selectedGroupSession;
|
||||
|
||||
// YES while the authentication screen is displayed
|
||||
@property (nonatomic, readonly) BOOL authenticationInProgress;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol MasterTabBarControllerDelegate <NSObject>
|
||||
|
||||
- (void)masterTabBarControllerDidCompleteAuthentication:(MasterTabBarController *)masterTabBarController;
|
||||
|
||||
@end;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#import "Riot-Swift.h"
|
||||
|
||||
@interface MasterTabBarController ()
|
||||
@interface MasterTabBarController () <AuthenticationViewControllerDelegate>
|
||||
{
|
||||
// Array of `MXSession` instances.
|
||||
NSMutableArray *mxSessionArray;
|
||||
|
@ -79,6 +79,8 @@
|
|||
[super viewDidLoad];
|
||||
// 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)
|
||||
[self vc_removeBackTitle];
|
||||
|
||||
|
@ -418,6 +420,7 @@
|
|||
if (!self.authViewController && !isAuthViewControllerPreparing)
|
||||
{
|
||||
isAuthViewControllerPreparing = YES;
|
||||
_authenticationInProgress = YES;
|
||||
|
||||
[self resetReviewSessionsFlags];
|
||||
|
||||
|
@ -464,6 +467,7 @@
|
|||
if (!self.authViewController && !isAuthViewControllerPreparing)
|
||||
{
|
||||
isAuthViewControllerPreparing = YES;
|
||||
_authenticationInProgress = YES;
|
||||
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{
|
||||
|
||||
|
@ -695,6 +699,9 @@
|
|||
_authViewController = segue.destinationViewController;
|
||||
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) {
|
||||
|
||||
_authViewController = nil;
|
||||
|
@ -1163,4 +1170,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - AuthenticationViewControllerDelegate
|
||||
|
||||
- (void)authenticationViewControllerDidDismiss:(AuthenticationViewController *)authenticationViewController
|
||||
{
|
||||
_authenticationInProgress = NO;
|
||||
if (self.masterVCDelegate)
|
||||
{
|
||||
[self.masterVCDelegate masterTabBarControllerDidCompleteAuthentication:self];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue