浏览代码

scanDocument

Marino Faggiana 1 年之前
父节点
当前提交
23b045ac4c

+ 1 - 1
iOSClient/Menu/NCMedia+Menu.swift

@@ -159,7 +159,7 @@ extension NCMedia {
                 NCMenuAction(
                     title: NSLocalizedString("_media_by_created_date_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "circle.grid.cross.down.fill"),
-                    selected:NCKeychain().mediaSortDate == "creationDate",
+                    selected: NCKeychain().mediaSortDate == "creationDate",
                     on: true,
                     action: { _ in
                         NCKeychain().mediaSortDate = "creationDate"

+ 6 - 8
iOSClient/Scan document/NCUploadScanDocument.swift

@@ -319,7 +319,6 @@ extension NCUploadScanDocument: NCSelectDelegate {
     func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) {
 
         if let serverUrl = serverUrl {
-            CCUtility.setDirectoryScanDocument(serverUrl)
             self.serverUrl = serverUrl
         }
     }
@@ -348,9 +347,9 @@ struct UploadScanDocumentView: View {
     @State var fileName = CCUtility.createFileNameDate("scan", extension: "") ?? "scan"
     @State var password: String = ""
     @State var isSecuredPassword: Bool = true
-    @State var isTextRecognition: Bool = CCUtility.getTextRecognitionStatus()
-    @State var quality = CCUtility.getQualityScanDocument()
-    @State var removeAllFiles: Bool = CCUtility.getDeleteAllScanImages()
+    @State var isTextRecognition: Bool = NCKeychain().textRecognitionStatus
+    @State var quality = NCKeychain().qualityScanDocument
+    @State var removeAllFiles: Bool = NCKeychain().deleteAllScanImages
     @State var isPresentedSelect = false
     @State var isPresentedUploadConflict = false
 
@@ -437,7 +436,7 @@ struct UploadScanDocumentView: View {
                             Toggle(NSLocalizedString("_text_recognition_", comment: ""), isOn: $isTextRecognition)
                                 .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand)))
                                 .onChange(of: isTextRecognition) { newValue in
-                                    CCUtility.setTextRecognitionStatus(newValue)
+                                    NCKeychain().textRecognitionStatus = newValue
                                 }
                         }
                     }
@@ -450,8 +449,7 @@ struct UploadScanDocumentView: View {
                         Toggle(NSLocalizedString("_delete_all_scanned_images_", comment: ""), isOn: $removeAllFiles)
                             .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand)))
                             .onChange(of: removeAllFiles) { newValue in
-                                CCUtility.setDeleteAllScanImages(newValue)
-
+                                NCKeychain().deleteAllScanImages = newValue
                             }
 
                         Button(NSLocalizedString("_save_", comment: "")) {
@@ -478,7 +476,7 @@ struct UploadScanDocumentView: View {
                         VStack {
                             Slider(value: $quality, in: 0...4, step: 1, onEditingChanged: { touch in
                                 if !touch {
-                                    CCUtility.setQualityScanDocument(quality)
+                                    NCKeychain().qualityScanDocument = quality
                                 }
                             })
                             .accentColor(Color(NCBrandColor.shared.brand))

+ 0 - 9
iOSClient/Utility/CCUtility.h

@@ -55,15 +55,6 @@
 + (NSString *)getPushNotificationDeviceIdentifierSignature:(NSString *)account;
 + (void)clearAllKeysPushNotification:(NSString *)account;
 
-+ (BOOL)getTextRecognitionStatus;
-+ (void)setTextRecognitionStatus:(BOOL)value;
-+ (BOOL)getDeleteAllScanImages;
-+ (void)setDeleteAllScanImages:(BOOL)value;
-+ (NSString *)getDirectoryScanDocument;
-+ (void)setDirectoryScanDocument:(NSString *)value;
-+ (double)getQualityScanDocument;
-+ (void)setQualityScanDocument:(double)value;
-
 // ===== Varius =====
 
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;

+ 0 - 49
iOSClient/Utility/CCUtility.m

@@ -132,55 +132,6 @@
     [self setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil];
 }
 
-+ (BOOL)getTextRecognitionStatus
-{
-    return [[UICKeyChainStore stringForKey:@"textRecognitionStatus" service:NCGlobal.shared.serviceShareKeyChain] boolValue];
-}
-
-+ (void)setTextRecognitionStatus:(BOOL)value
-{
-    NSString *valueString = (value) ? @"true" : @"false";
-    [UICKeyChainStore setString:valueString forKey:@"textRecognitionStatus" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
-+ (BOOL)getDeleteAllScanImages
-{
-    return [[UICKeyChainStore stringForKey:@"deleteAllScanImages" service:NCGlobal.shared.serviceShareKeyChain] boolValue];
-}
-
-+ (void)setDeleteAllScanImages:(BOOL)value
-{
-    NSString *valueString = (value) ? @"true" : @"false";
-    [UICKeyChainStore setString:valueString forKey:@"deleteAllScanImages" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
-+ (NSString *)getDirectoryScanDocument
-{
-    return [UICKeyChainStore stringForKey:@"directoryScanDocuments" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
-+ (void)setDirectoryScanDocument:(NSString *)value
-{
-    [UICKeyChainStore setString:value forKey:@"directoryScanDocuments" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
-+ (double)getQualityScanDocument
-{
-    NSString *value = [UICKeyChainStore stringForKey:@"qualityScanDocument" service:NCGlobal.shared.serviceShareKeyChain];
-
-    if (value == nil) {
-        return 2;
-    } else {
-        return [value doubleValue];
-    }
-}
-
-+ (void)setQualityScanDocument:(double)value
-{
-    NSString *valueString = [@(value) stringValue];
-    [UICKeyChainStore setString:valueString forKey:@"qualityScanDocument" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Various =====
 #pragma --------------------------------------------------------------------------------------------

+ 39 - 0
iOSClient/Utility/NCKeychain.swift

@@ -279,6 +279,45 @@ import KeychainAccess
         }
     }
 
+    var textRecognitionStatus: Bool {
+        get {
+            migrate(key: "textRecognitionStatus")
+            if let value = try? keychain.get("textRecognitionStatus"), let result = Bool(value) {
+                return result
+            }
+            return false
+        }
+        set {
+            keychain["textRecognitionStatus"] = String(newValue)
+        }
+    }
+
+    var deleteAllScanImages: Bool {
+        get {
+            migrate(key: "deleteAllScanImages")
+            if let value = try? keychain.get("deleteAllScanImages"), let result = Bool(value) {
+                return result
+            }
+            return false
+        }
+        set {
+            keychain["deleteAllScanImages"] = String(newValue)
+        }
+    }
+
+    var qualityScanDocument: Double {
+        get {
+            migrate(key: "qualityScanDocument")
+            if let value = try? keychain.get("qualityScanDocument"), let result = Double(value) {
+                return result
+            }
+            return 2
+        }
+        set {
+            keychain["qualityScanDocument"] = String(newValue)
+        }
+    }
+
     // MARK: -
 
     private func migrate(key: String) {