Marino Faggiana 7 years ago
parent
commit
f538f9696d

+ 6 - 6
iOSClient/Images.xcassets/bkempty.imageset/Contents.json

@@ -2,18 +2,18 @@
   "images" : [
     {
       "idiom" : "universal",
-      "scale" : "1x",
-      "filename" : "bkempty.png"
+      "filename" : "bkempty.png",
+      "scale" : "1x"
     },
     {
       "idiom" : "universal",
-      "scale" : "2x",
-      "filename" : "bkempty@2x.png"
+      "filename" : "bkempty@2x.png",
+      "scale" : "2x"
     },
     {
       "idiom" : "universal",
-      "scale" : "3x",
-      "filename" : "bkempty@3x.png"
+      "filename" : "bkempty@3x.png",
+      "scale" : "3x"
     }
   ],
   "info" : {

BIN
iOSClient/Images.xcassets/bkempty.imageset/bkempty.png


BIN
iOSClient/Images.xcassets/bkempty.imageset/bkempty@2x.png


BIN
iOSClient/Images.xcassets/bkempty.imageset/bkempty@3x.png


+ 6 - 6
iOSClient/Images.xcassets/bkfull.imageset/Contents.json

@@ -2,18 +2,18 @@
   "images" : [
     {
       "idiom" : "universal",
-      "scale" : "1x",
-      "filename" : "bkfull.png"
+      "filename" : "bkfull.png",
+      "scale" : "1x"
     },
     {
       "idiom" : "universal",
-      "scale" : "2x",
-      "filename" : "bkfull@2x.png"
+      "filename" : "bkfull@2x.png",
+      "scale" : "2x"
     },
     {
       "idiom" : "universal",
-      "scale" : "3x",
-      "filename" : "bkfull@3x.png"
+      "filename" : "bkfull@3x.png",
+      "scale" : "3x"
     }
   ],
   "info" : {

BIN
iOSClient/Images.xcassets/bkfull.imageset/bkfull.png


BIN
iOSClient/Images.xcassets/bkfull.imageset/bkfull@2x.png


BIN
iOSClient/Images.xcassets/bkfull.imageset/bkfull@3x.png


+ 23 - 0
iOSClient/Images.xcassets/e2eReadPassphrase.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "e2eReadPassphrase.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "e2eReadPassphrase@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "e2eReadPassphrase@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/e2eReadPassphrase.imageset/e2eReadPassphrase.png


BIN
iOSClient/Images.xcassets/e2eReadPassphrase.imageset/e2eReadPassphrase@2x.png


BIN
iOSClient/Images.xcassets/e2eReadPassphrase.imageset/e2eReadPassphrase@3x.png


+ 23 - 0
iOSClient/Images.xcassets/e2eRemoveLocallyEncryption.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "removeLocallyEncryption.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "removeLocallyEncryption@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "removeLocallyEncryption@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/e2eRemoveLocallyEncryption.imageset/removeLocallyEncryption.png


BIN
iOSClient/Images.xcassets/e2eRemoveLocallyEncryption.imageset/removeLocallyEncryption@2x.png


BIN
iOSClient/Images.xcassets/e2eRemoveLocallyEncryption.imageset/removeLocallyEncryption@3x.png


+ 1 - 0
iOSClient/Security/CCBKPasscode.h

@@ -31,6 +31,7 @@ typedef enum : NSUInteger {
     CCBKPasscodeFromLockDirectory,
     CCBKPasscodeFromDisactivateDirectory,
     CCBKPasscodeFromCheckPassphrase,
+    CCBKPasscodeFromRemoveEncryption,
     CCBKPasscodeFromSettingsPasscode,
     CCBKPasscodeFromSimply
 } CCBKPasscodeTypeFrom;

+ 106 - 46
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -101,17 +101,32 @@
         
         // Section PASSPHRASE -------------------------------------------------
         
-        section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_read_passphrase_", nil)];
+        section = [XLFormSectionDescriptor formSection];
         [form addFormSection:section];
         
         // Read Passphrase
         row = [XLFormRowDescriptor formRowDescriptorWithTag:@"readPassphrase" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_read_passphrase_", nil)];
+        [row.cellConfig setObject:[UIImage imageNamed:@"e2eReadPassphrase"] forKey:@"imageView.image"];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
         [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
         row.action.formSelector = @selector(readPassphrase:);
         [section addFormRow:row];
         
+        // Section DELETE -------------------------------------------------
+        
+        section = [XLFormSectionDescriptor formSection];
+        [form addFormSection:section];
+        
+        // remove locally Encryption
+        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removeLocallyEncryption" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_remove_", nil)];
+        [row.cellConfig setObject:[UIImage imageNamed:@"e2eRemoveLocallyEncryption"] forKey:@"imageView.image"];
+        [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
+        [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
+        [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
+        row.action.formSelector = @selector(removeLocallyEncryption:);
+        [section addFormRow:row];
+        
     } else {
         
         // Section START E2E -------------------------------------------------
@@ -150,14 +165,6 @@
     row.action.formSelector = @selector(deletePrivateKey:);
     [section addFormRow:row];
     
-    // Delete locally Encryption
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deleteLocallyEncryption" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"Delete locally encryption", nil)];
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
-    [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
-    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
-    row.action.formSelector = @selector(deleteLocallyEncryption:);
-    [section addFormRow:row];
-    
 #endif
     
     self.form = form;
@@ -172,35 +179,6 @@
 #pragma mark === Action ===
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)deletePublicKey:(XLFormRowDescriptor *)sender
-{
-    [self deselectFormRow:sender];
-    
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
-    
-    metadataNet.action = actionDeleteEndToEndPublicKey;
-    [app addNetworkingOperationQueue:app.netQueue delegate:app.endToEndInterface metadataNet:metadataNet];
-}
-
-- (void)deletePrivateKey:(XLFormRowDescriptor *)sender
-{
-    [self deselectFormRow:sender];
-    
-    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
-
-    metadataNet.action = actionDeleteEndToEndPrivateKey;
-    [app addNetworkingOperationQueue:app.netQueue delegate:app.endToEndInterface metadataNet:metadataNet];
-}
-
-- (void)deleteLocallyEncryption:(XLFormRowDescriptor *)sender
-{
-    [self deselectFormRow:sender];
-    
-    [CCUtility clearAllKeysEndToEnd:app.activeAccount];
-    
-    [self initializeForm];
-}
-
 - (void)startE2E:(XLFormRowDescriptor *)sender
 {
     [self deselectFormRow:sender];
@@ -248,6 +226,67 @@
     }
 }
 
+
+- (void)removeLocallyEncryption:(XLFormRowDescriptor *)sender
+{
+    [self deselectFormRow:sender];
+    
+    if ([[CCUtility getBlockCode] length]) {
+        
+        CCBKPasscode *viewController = [[CCBKPasscode alloc] initWithNibName:nil bundle:nil];
+        viewController.delegate = self;
+        viewController.fromType = CCBKPasscodeFromRemoveEncryption;
+        viewController.type = BKPasscodeViewControllerCheckPasscodeType;
+        
+        if ([CCUtility getSimplyBlockCode]) {
+            viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
+            viewController.passcodeInputView.maximumLength = 6;
+        } else {
+            viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle;
+            viewController.passcodeInputView.maximumLength = 64;
+        }
+        
+        BKTouchIDManager *touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:k_serviceShareKeyChain];
+        touchIDManager.promptText = NSLocalizedString(@"_scan_fingerprint_", nil);
+        viewController.touchIDManager = touchIDManager;
+        
+        viewController.title = NSLocalizedString(@"_e2e_settings_remove_", nil);
+        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(passcodeViewCloseButtonPressed:)];
+        viewController.navigationItem.leftBarButtonItem.tintColor = [NCBrandColor sharedInstance].encrypted;
+        
+        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
+        [self presentViewController:navigationController animated:YES completion:nil];
+        
+    } else {
+        
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:NSLocalizedString(@"_e2e_settings_lock_not_active_", nil) preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+        }];
+        [alertController addAction:okAction];
+        [self presentViewController:alertController animated:YES completion:nil];
+    }
+}
+
+- (void)deletePublicKey:(XLFormRowDescriptor *)sender
+{
+    [self deselectFormRow:sender];
+    
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    
+    metadataNet.action = actionDeleteEndToEndPublicKey;
+    [app addNetworkingOperationQueue:app.netQueue delegate:app.endToEndInterface metadataNet:metadataNet];
+}
+
+- (void)deletePrivateKey:(XLFormRowDescriptor *)sender
+{
+    [self deselectFormRow:sender];
+    
+    CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    
+    metadataNet.action = actionDeleteEndToEndPrivateKey;
+    [app addNetworkingOperationQueue:app.netQueue delegate:app.endToEndInterface metadataNet:metadataNet];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === BKPasscodeViewController ===
 #pragma --------------------------------------------------------------------------------------------
@@ -281,16 +320,37 @@
 {
     [aViewController dismissViewControllerAnimated:YES completion:nil];
     
-    NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:app.activeAccount];
-    NSLog(@"[LOG] Passphrase: %@", e2ePassphrase);
+    if (aViewController.fromType == CCBKPasscodeFromCheckPassphrase) {
+    
+        NSString *e2ePassphrase = [CCUtility getEndToEndPassphrase:app.activeAccount];
+        NSLog(@"[LOG] Passphrase: %@", e2ePassphrase);
     
-    NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), e2ePassphrase];
+        NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), e2ePassphrase];
     
-    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
-    UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-    }];
-    [alertController addAction:okAction];
-    [self presentViewController:alertController animated:YES completion:nil];
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+        }];
+        [alertController addAction:okAction];
+        [self presentViewController:alertController animated:YES completion:nil];
+    }
+    
+    if (aViewController.fromType == CCBKPasscodeFromRemoveEncryption) {
+     
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_e2e_settings_remove_", nil) message:NSLocalizedString(@"_e2e_settings_remove_message_", nil) preferredStyle:UIAlertControllerStyleAlert];
+        
+        UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_remove_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+            [CCUtility clearAllKeysEndToEnd:app.activeAccount];
+            [self initializeForm];
+        }];
+        
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+            NSLog(@"Cancel action");
+        }];
+        
+        [alertController addAction:okAction];
+        [alertController addAction:cancelAction];
+        [self presentViewController:alertController animated:YES completion:nil];
+    }
 }
 
 @end

+ 2 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -502,4 +502,5 @@
 "_e2e_settings_the_passphrase_is_"  = "The passphrase is:";
 "_e2e_passphrase_request_title_"    = "Request passphrase";
 "_e2e_passphrase_request_message_"  = "Insert the 12 word";
-
+"_e2e_settings_remove_"             = "Remove locally the encryption";
+"_e2e_settings_remove_message_"      = "By removing the encryption you also lose the passphrase, go ahead ?";