marinofaggiana 4 years ago
parent
commit
0862a13684
2 changed files with 33 additions and 10 deletions
  1. 22 9
      iOSClient/Settings/CCSettings.m
  2. 11 1
      iOSClient/Settings/NCManageEndToEndEncryption.m

+ 22 - 9
iOSClient/Settings/CCSettings.m

@@ -39,6 +39,8 @@
 @interface CCSettings () <TOPasscodeSettingsViewControllerDelegate, TOPasscodeViewControllerDelegate>
 {
     AppDelegate *appDelegate;
+    TOPasscodeViewController *passcodeViewController;
+    TOPasscodeSettingsViewController *passcodeSettingsViewController;
 }
 @end
 
@@ -191,8 +193,9 @@
     
     appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     
-    // changeTheming
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:k_notificationCenter_applicationDidEnterBackground object:nil];
+    
     [self changeTheming];
 }
 
@@ -203,6 +206,16 @@
     [self reloadForm];
 }
 
+- (void)applicationDidEnterBackground
+{
+    if (passcodeViewController.view.window != nil) {
+        [passcodeViewController dismissViewControllerAnimated:true completion:nil];
+    }
+    if (passcodeSettingsViewController.view.window != nil) {
+        [passcodeSettingsViewController dismissViewControllerAnimated:true completion:nil];
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Chiamate dal Form ===
 #pragma --------------------------------------------------------------------------------------------
@@ -366,23 +379,23 @@
 
     if ([[CCUtility getBlockCode] length] == 0) {
         
-        TOPasscodeSettingsViewController *settingsController = [[TOPasscodeSettingsViewController alloc] init];
+        passcodeSettingsViewController = [[TOPasscodeSettingsViewController alloc] init];
         if (@available(iOS 13.0, *)) {
             if ([[UITraitCollection currentTraitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark) {
-                settingsController.style = TOPasscodeSettingsViewStyleDark;
+                passcodeSettingsViewController.style = TOPasscodeSettingsViewStyleDark;
             }
         }
         
-        settingsController.hideOptionsButton = YES;
-        settingsController.requireCurrentPasscode = NO;
-        settingsController.passcodeType = TOPasscodeTypeSixDigits;
-        settingsController.delegate = self;
+        passcodeSettingsViewController.hideOptionsButton = YES;
+        passcodeSettingsViewController.requireCurrentPasscode = NO;
+        passcodeSettingsViewController.passcodeType = TOPasscodeTypeSixDigits;
+        passcodeSettingsViewController.delegate = self;
         
-        [self presentViewController:settingsController animated:YES completion:nil];
+        [self presentViewController:passcodeSettingsViewController animated:YES completion:nil];
         
     } else {
      
-        TOPasscodeViewController *passcodeViewController = [[TOPasscodeViewController alloc] initWithStyle:TOPasscodeViewStyleTranslucentLight passcodeType:TOPasscodeTypeSixDigits];
+        passcodeViewController = [[TOPasscodeViewController alloc] initWithStyle:TOPasscodeViewStyleTranslucentLight passcodeType:TOPasscodeTypeSixDigits];
         if (@available(iOS 13.0, *)) {
             if ([[UITraitCollection currentTraitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark) {
                 passcodeViewController.style = TOPasscodeViewStyleTranslucentDark;

+ 11 - 1
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -32,6 +32,7 @@
 {
     AppDelegate *appDelegate;
     NSString *passcodeType;
+    TOPasscodeViewController *passcodeViewController;
 }
 @end
 
@@ -169,6 +170,8 @@
     
     // changeTheming
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:k_notificationCenter_applicationDidEnterBackground object:nil];
+
     [self changeTheming];
 }
 
@@ -178,6 +181,13 @@
     [self initializeForm];
 }
 
+- (void)applicationDidEnterBackground
+{
+    if (passcodeViewController.view.window != nil) {
+        [passcodeViewController dismissViewControllerAnimated:true completion:nil];
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Action ===
 #pragma --------------------------------------------------------------------------------------------
@@ -245,7 +255,7 @@
     
     if ([[CCUtility getBlockCode] length] > 0) {
         
-        TOPasscodeViewController *passcodeViewController = [[TOPasscodeViewController alloc] initWithStyle:TOPasscodeViewStyleTranslucentLight passcodeType:TOPasscodeTypeSixDigits];
+        passcodeViewController = [[TOPasscodeViewController alloc] initWithStyle:TOPasscodeViewStyleTranslucentLight passcodeType:TOPasscodeTypeSixDigits];
         if (@available(iOS 13.0, *)) {
             if ([[UITraitCollection currentTraitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark) {
                 passcodeViewController.style = TOPasscodeViewStyleTranslucentDark;