瀏覽代碼

mediaWidthImage

Marino Faggiana 1 年之前
父節點
當前提交
2439ceabb0
共有 4 個文件被更改,包括 16 次插入23 次删除
  1. 3 3
      iOSClient/Media/NCMedia.swift
  2. 0 3
      iOSClient/Utility/CCUtility.h
  3. 0 17
      iOSClient/Utility/CCUtility.m
  4. 13 0
      iOSClient/Utility/NCKeychain.swift

+ 3 - 3
iOSClient/Media/NCMedia.swift

@@ -79,7 +79,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
         collectionView.backgroundColor = .systemBackground
 
         gridLayout = NCGridMediaLayout()
-        gridLayout.itemForLine = CGFloat(min(CCUtility.getMediaWidthImage(), 5))
+        gridLayout.itemForLine = CGFloat(min(NCKeychain().mediaWidthImage, 5))
         gridLayout.sectionHeadersPinToVisibleBounds = true
 
         collectionView.collectionViewLayout = gridLayout
@@ -241,7 +241,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
             }
 
             self.collectionView.collectionViewLayout.invalidateLayout()
-            CCUtility.setMediaWidthImage(Int(self.gridLayout.itemForLine))
+            NCKeychain().mediaWidthImage = Int(self.gridLayout.itemForLine)
         })
     }
 
@@ -257,7 +257,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
             }
 
             self.collectionView.collectionViewLayout.invalidateLayout()
-            CCUtility.setMediaWidthImage(Int(self.gridLayout.itemForLine))
+            NCKeychain().mediaWidthImage = Int(self.gridLayout.itemForLine)
         })
     }
 

+ 0 - 3
iOSClient/Utility/CCUtility.h

@@ -55,9 +55,6 @@
 + (NSString *)getPushNotificationDeviceIdentifierSignature:(NSString *)account;
 + (void)clearAllKeysPushNotification:(NSString *)account;
 
-+ (NSInteger)getMediaWidthImage;
-+ (void)setMediaWidthImage:(NSInteger)width;
-
 + (NSString *)getMediaSortDate;
 + (void)setMediaSortDate:(NSString *)value;
 

+ 0 - 17
iOSClient/Utility/CCUtility.m

@@ -132,23 +132,6 @@
     [self setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil];
 }
 
-+ (NSInteger)getMediaWidthImage
-{
-    NSString *width = [UICKeyChainStore stringForKey:@"mediaWidthImage" service:NCGlobal.shared.serviceShareKeyChain];
-
-    if (width == nil) {
-        return 80;
-    } else {
-        return [width integerValue];
-    }
-}
-
-+ (void)setMediaWidthImage:(NSInteger)width
-{
-    NSString *widthString = [@(width) stringValue];
-    [UICKeyChainStore setString:widthString forKey:@"mediaWidthImage" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
 + (NSString *)getMediaSortDate
 {
     NSString *valueString = [UICKeyChainStore stringForKey:@"mediaSortDate" service:NCGlobal.shared.serviceShareKeyChain];

+ 13 - 0
iOSClient/Utility/NCKeychain.swift

@@ -253,6 +253,19 @@ import KeychainAccess
         }
     }
 
+    var mediaWidthImage: Int {
+        get {
+            migrate(key: "mediaWidthImage")
+            if let value = try? keychain.get("mediaWidthImage"), let result = Int(value) {
+                return result
+            }
+            return 80
+        }
+        set {
+            keychain["mediaWidthImage"] = String(newValue)
+        }
+    }
+
     // MARK: -
 
     private func migrate(key: String) {