Browse Source

test

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
5e4e9a6bc7

+ 24 - 23
iOSClient/Settings/NCManageE2EE.swift

@@ -26,12 +26,16 @@ import NextcloudKit
 import TOPasscodeViewController
 import LocalAuthentication
 
+@objc class NCManageE2EEInterface: NSObject {
+    @objc func makeShipDetailsUI(account: String) -> UIViewController {
+        let details = NCViewE2EE(isEndToEndEnabled: CCUtility.isEnd(toEndEnabled: account))
+        return UIHostingController(rootView: details)
+    }
+}
 
-@objc
-class NCManageE2EEInterface: NSObject, NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate {
+class NCManageE2EE: NSObject, NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate {
 
     let endToEndInitialize = NCEndToEndInitialize()
-
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     private var passcodeType = ""
 
@@ -41,13 +45,8 @@ class NCManageE2EEInterface: NSObject, NCEndToEndInitializeDelegate, TOPasscodeV
         endToEndInitialize.delegate = self
     }
 
-    @objc func makeShipDetailsUI() -> UIViewController {
-        let details = NCManageE2EE()
-        return UIHostingController(rootView: details)
-    }
-
     func endToEndInitializeSuccess() {
-
+       //details.isEndToEndEnabled = true
     }
 
     // MARK: - Passcode
@@ -118,8 +117,10 @@ class NCManageE2EEInterface: NSObject, NCEndToEndInitializeDelegate, TOPasscodeV
     }
 }
 
-struct NCManageE2EE: View {
-    let manageE2EEInterface = NCManageE2EEInterface()
+struct NCViewE2EE: View {
+
+    let manageE2EE = NCManageE2EE()
+    @State var isEndToEndEnabled: Bool = false
 
     var body: some View {
         VStack {
@@ -142,16 +143,22 @@ struct NCManageE2EE: View {
                 .cornerRadius(.infinity)
                 .frame(height: 100)
 
-                Button(action: {
-                    manageE2EEInterface.endToEndInitialize.initEndToEndEncryption()
-                }, label: {
-                    Text("Start")
-                })
+                if isEndToEndEnabled {
+                    Text("Activated")
+                } else {
+                    Button(action: {
+                        manageE2EE.endToEndInitialize.initEndToEndEncryption()
+                    }, label: {
+                        Text("Start")
+                    })
+                }
+
+
                 Button(action: {
                     if CCUtility.getPasscode().isEmpty {
                         NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
                     } else {
-                        manageE2EEInterface.requestPasscodeType("removeLocallyEncryption")
+                        manageE2EE.requestPasscodeType("removeLocallyEncryption")
                     }
                 }, label: {
                     Text(NSLocalizedString("_e2e_settings_remove_", comment: ""))
@@ -180,9 +187,3 @@ struct NCManageE2EE: View {
         .navigationTitle("Cifratura End-To-End")
     }
 }
-
-struct NCManageE2EE_Previews: PreviewProvider {
-    static var previews: some View {
-        NCManageE2EE()
-    }
-}

+ 3 - 1
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -51,7 +51,8 @@
         NKError *error = [[NKError alloc] initWithErrorCode:NCGlobal.shared.errorInternalError errorDescription:@"_err_e2ee_app_version_"];
         [[NCContentPresenter shared] messageNotification:@"_error_e2ee_" error:error delay:[[NCGlobal shared] dismissAfterSecond] type:messageTypeError];
     }
-    
+
+    /*
     if (isE2EEEnabled == NO || ![versionE2EE isEqual:[[NCGlobal shared] e2eeVersion]]) {
         
         // Section SERVICE NOT AVAILABLE -------------------------------------------------
@@ -75,6 +76,7 @@
 
         return;
     }
+    */
     
     if ([CCUtility isEndToEndEnabled:appDelegate.account]) {
         

+ 3 - 3
iOSClient/Settings/NCSettings.m

@@ -118,8 +118,8 @@
         [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
-        //row.action.formSelector = @selector(manageE2EE:);
-        row.action.viewControllerClass = [NCManageEndToEndEncryption class];
+        row.action.formSelector = @selector(manageE2EE:);
+        //row.action.viewControllerClass = [NCManageEndToEndEncryption class];
         [section addFormRow:row];
     }
 
@@ -301,7 +301,7 @@
 {
     [self deselectFormRow:sender];
 
-    UIViewController *vc = [[NCManageE2EEInterface alloc] makeShipDetailsUI];
+    UIViewController *vc = [[NCManageE2EEInterface alloc] makeShipDetailsUIWithAccount:appDelegate.account];
     [self.navigationController pushViewController:vc animated:YES];
 }