Browse Source

disableCrashservice

Marino Faggiana 1 year ago
parent
commit
63567d8e1b

+ 1 - 1
iOSClient/AppDelegate.swift

@@ -80,7 +80,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 
         UserDefaults.standard.register(defaults: ["UserAgent": userAgent])
-        if !CCUtility.getDisableCrashservice() && !NCBrandOptions.shared.disable_crash_service {
+        if !NCKeychain().disableCrashservice, !NCBrandOptions.shared.disable_crash_service {
             FirebaseApp.configure()
         }
 

+ 3 - 3
iOSClient/Settings/CCAdvanced.m

@@ -115,7 +115,7 @@
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"crashservice"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
-        if ([CCUtility getDisableCrashservice]) row.value = @"1";
+        if ([[[NCKeychain alloc] init] disableCrashservice]) row.value = @"1";
         else row.value = @"0";
         [section addFormRow:row];
     }
@@ -338,8 +338,8 @@
     
     if ([rowDescriptor.tag isEqualToString:@"crashservice"]) {
         
-        [CCUtility setDisableCrashservice:[[rowDescriptor.value valueData] boolValue]];
-        
+        [[NCKeychain alloc] init].disableCrashservice = [[rowDescriptor.value valueData] boolValue];
+
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_crashservice_title_", nil) message:NSLocalizedString(@"_crashservice_alert_", nil) preferredStyle:UIAlertControllerStyleAlert];
         UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
             exit(0);

+ 0 - 3
iOSClient/Utility/CCUtility.h

@@ -58,9 +58,6 @@
 + (NSInteger)getMediaWidthImage;
 + (void)setMediaWidthImage:(NSInteger)width;
 
-+ (BOOL)getDisableCrashservice;
-+ (void)setDisableCrashservice:(BOOL)disable;
-
 + (NSString *)getMediaSortDate;
 + (void)setMediaSortDate:(NSString *)value;
 

+ 0 - 11
iOSClient/Utility/CCUtility.m

@@ -149,17 +149,6 @@
     [UICKeyChainStore setString:widthString forKey:@"mediaWidthImage" service:NCGlobal.shared.serviceShareKeyChain];
 }
 
-+ (BOOL)getDisableCrashservice
-{
-    return [[UICKeyChainStore stringForKey:@"crashservice" service:NCGlobal.shared.serviceShareKeyChain] boolValue];
-}
-
-+ (void)setDisableCrashservice:(BOOL)disable
-{
-    NSString *sDisable = (disable) ? @"true" : @"false";
-    [UICKeyChainStore setString:sDisable forKey:@"crashservice" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
 + (NSString *)getMediaSortDate
 {
     NSString *valueString = [UICKeyChainStore stringForKey:@"mediaSortDate" service:NCGlobal.shared.serviceShareKeyChain];

+ 13 - 0
iOSClient/Utility/NCKeychain.swift

@@ -175,6 +175,19 @@ import KeychainAccess
         }
     }
 
+    @objc var disableCrashservice: Bool {
+        get {
+            migrate(key: "crashservice")
+            if let value = try? keychain.get("crashservice"), let result = Bool(value) {
+                return result
+            }
+            return false
+        }
+        set {
+            keychain["crashservice"] = String(newValue)
+        }
+    }
+
     // MARK: -
 
     private func migrate(key: String) {