浏览代码

added Model in detail Image

marinofaggiana 4 年之前
父节点
当前提交
665ffd1f42

+ 1 - 1
iOSClient/CCGlobal.h

@@ -78,7 +78,7 @@
 
 // Database Realm
 #define k_databaseDefault                               @"nextcloud.realm"
-#define k_databaseSchemaVersion                         145
+#define k_databaseSchemaVersion                         146
 
 // Database JSON
 #define k_databaseDefaultJSON                           @"nextcloud.json"

+ 1 - 0
iOSClient/Data/NCDatabase.swift

@@ -283,6 +283,7 @@ class tableLocalFile: Object {
     @objc dynamic var exifDate: NSDate? = nil
     @objc dynamic var exifLatitude = ""
     @objc dynamic var exifLongitude = ""
+    @objc dynamic var exifLensModel: String? = nil
     @objc dynamic var favorite: Bool = false
     @objc dynamic var fileName = ""
     @objc dynamic var ocId = ""

+ 4 - 1
iOSClient/Data/NCManageDatabase.swift

@@ -1536,7 +1536,7 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func setLocalFile(ocId: String, exifDate: NSDate?, exifLatitude: String, exifLongitude: String) {
+    @objc func setLocalFile(ocId: String, exifDate: NSDate?, exifLatitude: String, exifLongitude: String, exifLensModel: String?) {
         
         let realm = try! Realm()
 
@@ -1546,6 +1546,9 @@ class NCManageDatabase: NSObject {
                     result.exifDate = exifDate
                     result.exifLatitude = exifLatitude
                     result.exifLongitude = exifLongitude
+                    if exifLensModel?.count ?? 0 > 0 {
+                        result.exifLensModel = exifLensModel
+                    }
                 }
             }
         } catch let error {

+ 2 - 2
iOSClient/Networking/NCNetworking.swift

@@ -275,7 +275,7 @@ import Queuer
                     
                     NCEndToEndEncryption.sharedManager()?.decryptFileName(metadata.fileName, fileNameView: metadata.fileNameView, ocId: metadata.ocId, key: result.key, initializationVector: result.initializationVector, authenticationTag: result.authenticationTag)
                 }
-                CCUtility.setExif(metadata) { (latitude, longitude, location, date) in };
+                CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensMode) in };
                 #endif
                                 
             } else {
@@ -504,7 +504,7 @@ import Queuer
                         appDelegate.networkingAutoUpload.startProcess()
                     }
                 }
-                CCUtility.setExif(metadata) { (latitude, longitude, location, date) in };
+                CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensMode) in };
                 #endif                
                 
                 NCCommunicationCommon.shared.writeLog("Upload complete " + serverUrl + "/" + fileName + ", result: success(\(size) bytes)")

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

@@ -148,6 +148,7 @@
 "_size_"                    = "Size";
 "_dimension_"               = "Dimension";
 "_duration_"                = "Duration";
+"_model_"                   = "Model";
 
 // App
 

+ 1 - 1
iOSClient/Utility/CCUtility.h

@@ -267,7 +267,7 @@
 
 // ===== EXIF =====
 
-+ (void)setExif:(tableMetadata *)metadata withCompletionHandler:(void(^)(double latitude, double longitude, NSString *location, NSDate *date))completition;
++ (void)setExif:(tableMetadata *)metadata withCompletionHandler:(void(^)(double latitude, double longitude, NSString *location, NSDate *date, NSString *lensModel))completition;
 
 // ===== Third parts =====
 

+ 11 - 17
iOSClient/Utility/CCUtility.m

@@ -1684,7 +1684,7 @@
 #pragma mark ===== EXIF =====
 #pragma --------------------------------------------------------------------------------------------
 
-+ (void)setExif:(tableMetadata *)metadata withCompletionHandler:(void(^)(double latitude, double longitude, NSString *location, NSDate *date))completition
++ (void)setExif:(tableMetadata *)metadata withCompletionHandler:(void(^)(double latitude, double longitude, NSString *location, NSDate *date, NSString *lensModel))completition
 {
     NSString *dateTime;
     NSString *latitudeRef;
@@ -1703,20 +1703,20 @@
     NSString *lensModel;
 
     if (![metadata.typeFile isEqualToString:k_metadataTypeFile_image] || ![CCUtility fileProviderStorageExists:metadata.ocId fileNameView:metadata.fileNameView]) {
-        completition(latitude, longitude, location, date);
+        completition(latitude, longitude, location, date, lensModel);
         return;
     }
     
     NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileNameView]];
     CGImageSourceRef originalSource =  CGImageSourceCreateWithURL((CFURLRef) url, NULL);
     if (!originalSource) {
-        completition(latitude, longitude, location, date);
+        completition(latitude, longitude, location, date, lensModel);
         return;
     }
     
     CFDictionaryRef fileProperties = CGImageSourceCopyProperties(originalSource, nil);
     if (!fileProperties) {
-        completition(latitude, longitude, location,date);
+        completition(latitude, longitude, location,date, lensModel);
         return;
     }
     
@@ -1727,7 +1727,7 @@
     
     CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(originalSource, 0, NULL);
     if (!imageProperties) {
-        completition(latitude, longitude, location,date);
+        completition(latitude, longitude, location,date, lensModel);
         return;
     }
 
@@ -1736,25 +1736,19 @@
     CFDictionaryRef exif = CFDictionaryGetValue(imageProperties, kCGImagePropertyExifDictionary);
     
     if (exif) {
+        
         NSString *sPixelX = (NSString *)CFDictionaryGetValue(exif, kCGImagePropertyExifPixelXDimension);
         pixelX = [sPixelX intValue];
         NSString *sPixelY = (NSString *)CFDictionaryGetValue(exif, kCGImagePropertyExifPixelYDimension);
         pixelY = [sPixelY intValue];
-        NSString *sdateTime = (NSString *)CFDictionaryGetValue(exif, kCGImagePropertyExifSubsecTimeOriginal);
-        NSDateFormatter *dateFormatter = [NSDateFormatter new];
-        [dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"];
-        date = [dateFormatter dateFromString:sdateTime];
-        if (!date) date = metadata.date;
         lensModel = (NSString *)CFDictionaryGetValue(exif, kCGImagePropertyExifLensModel);
     }
  
     if (tiff) {
         
         dateTime = (NSString *)CFDictionaryGetValue(tiff, kCGImagePropertyTIFFDateTime);
-        
         NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
         [dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"];
-    
         date = [dateFormatter dateFromString:dateTime];
         if (!date) date = metadata.date;
     }
@@ -1793,13 +1787,13 @@
 
     // Wite data EXIF in DB
     if (tiff || gps) {
-        [[NCManageDatabase sharedInstance] setLocalFileWithOcId:metadata.ocId exifDate:date exifLatitude:stringLatitude exifLongitude:stringLongitude];
+        [[NCManageDatabase sharedInstance] setLocalFileWithOcId:metadata.ocId exifDate:date exifLatitude:stringLatitude exifLongitude:stringLongitude exifLensModel:lensModel];
         if ([stringLatitude doubleValue] != 0 || [stringLongitude doubleValue] != 0) {
             
             // If exists already geocoder data in TableGPS exit
             location = [[NCManageDatabase sharedInstance] getLocationFromGeoLatitude:stringLatitude longitude:stringLongitude];
             if (location != nil) {
-                completition(latitude, longitude, location, date);
+                completition(latitude, longitude, location, date, lensModel);
                 return;
             }
             
@@ -1833,14 +1827,14 @@
                         [[NCManageDatabase sharedInstance] addGeocoderLocation:location placemarkAdministrativeArea:placemark.administrativeArea placemarkCountry:placemark.country placemarkLocality:placemark.locality placemarkPostalCode:placemark.postalCode placemarkThoroughfare:placemark.thoroughfare latitude:stringLatitude longitude:stringLongitude];
                     }
                     
-                    completition(latitude, longitude, location, date);
+                    completition(latitude, longitude, location, date, lensModel);
                 }
             }];
         } else {
-            completition(latitude, longitude, location, date);
+            completition(latitude, longitude, location, date, lensModel);
         }
     } else {
-        completition(latitude, longitude, location, date);
+        completition(latitude, longitude, location, date, lensModel);
     }
        
     CFRelease(originalSource);

+ 29 - 4
iOSClient/Viewer/NCViewerImage/NCViewerImage.storyboard

@@ -110,7 +110,7 @@
                                         <nil key="highlightedColor"/>
                                     </label>
                                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="P8R-4f-zAl" customClass="NCViewerImageDetailView" customModule="Nextcloud" customModuleProvider="target">
-                                        <rect key="frame" x="0.0" y="462" width="414" height="365"/>
+                                        <rect key="frame" x="0.0" y="462" width="414" height="390"/>
                                         <subviews>
                                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HRq-3M-yeb">
                                                 <rect key="frame" x="15" y="50" width="384" height="1"/>
@@ -174,19 +174,37 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="Typ-A8-XIO">
-                                                <rect key="frame" x="15" y="162" width="384" height="174"/>
+                                                <rect key="frame" x="15" y="187" width="384" height="174"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="174" id="VRv-eR-bwo"/>
                                                 </constraints>
                                             </mapView>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oov-9f-Oeu">
-                                                <rect key="frame" x="15" y="336" width="384" height="29"/>
+                                                <rect key="frame" x="15" y="361" width="384" height="29"/>
                                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                                 <state key="normal" title="location"/>
                                                 <connections>
                                                     <action selector="touchLocation:" destination="P8R-4f-zAl" eventType="touchUpInside" id="Z9s-pM-WsS"/>
                                                 </connections>
                                             </button>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="dim" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uYI-ic-d8g">
+                                                <rect key="frame" x="15" y="150" width="80" height="17"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="80" id="egy-z4-Im6"/>
+                                                </constraints>
+                                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                <color key="textColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="dim value" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ix8-uQ-chU">
+                                                <rect key="frame" x="105" y="150" width="294" height="17"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="294" id="yyq-S2-dks"/>
+                                                </constraints>
+                                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
                                         </subviews>
                                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                         <constraints>
@@ -195,15 +213,18 @@
                                             <constraint firstItem="XLb-0a-du9" firstAttribute="centerY" secondItem="WXS-Lw-DkI" secondAttribute="centerY" id="6k5-Ur-AKZ"/>
                                             <constraint firstAttribute="trailing" secondItem="n1C-OB-gq2" secondAttribute="trailing" constant="15" id="6o9-lb-LZc"/>
                                             <constraint firstAttribute="trailing" secondItem="HRq-3M-yeb" secondAttribute="trailing" constant="15" id="DIq-e4-T4P"/>
-                                            <constraint firstItem="Typ-A8-XIO" firstAttribute="top" secondItem="n1C-OB-gq2" secondAttribute="bottom" constant="20" id="Hni-Ov-SDg"/>
                                             <constraint firstItem="XLb-0a-du9" firstAttribute="leading" secondItem="WXS-Lw-DkI" secondAttribute="trailing" constant="10" id="Iqg-lN-NpB"/>
                                             <constraint firstItem="n1C-OB-gq2" firstAttribute="centerY" secondItem="uaE-Lv-t0Q" secondAttribute="centerY" id="KMX-7y-YXP"/>
+                                            <constraint firstItem="uYI-ic-d8g" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="MTM-eQ-CXC"/>
                                             <constraint firstItem="oov-9f-Oeu" firstAttribute="top" secondItem="Typ-A8-XIO" secondAttribute="bottom" id="MUo-UC-1d4"/>
+                                            <constraint firstItem="ix8-uQ-chU" firstAttribute="centerY" secondItem="uYI-ic-d8g" secondAttribute="centerY" id="Oae-3R-C5Z"/>
+                                            <constraint firstAttribute="trailing" secondItem="ix8-uQ-chU" secondAttribute="trailing" constant="15" id="TIp-le-wVn"/>
                                             <constraint firstItem="hBd-KD-Jq5" firstAttribute="centerY" secondItem="Son-CZ-zFa" secondAttribute="centerY" id="Tez-na-gqC"/>
                                             <constraint firstItem="HRq-3M-yeb" firstAttribute="top" secondItem="P8R-4f-zAl" secondAttribute="top" constant="50" id="UF1-fO-9hX"/>
                                             <constraint firstAttribute="bottom" secondItem="oov-9f-Oeu" secondAttribute="bottom" id="YuK-2v-kzk"/>
                                             <constraint firstItem="hBd-KD-Jq5" firstAttribute="leading" secondItem="Son-CZ-zFa" secondAttribute="trailing" constant="10" id="YuO-13-KTh"/>
                                             <constraint firstItem="WXS-Lw-DkI" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="bRd-bi-Imh"/>
+                                            <constraint firstItem="uYI-ic-d8g" firstAttribute="top" secondItem="uaE-Lv-t0Q" secondAttribute="bottom" constant="8" symbolic="YES" id="bkM-Ic-ZoE"/>
                                             <constraint firstItem="Typ-A8-XIO" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="jre-DM-hm3"/>
                                             <constraint firstItem="oov-9f-Oeu" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="lXY-IM-uQB"/>
                                             <constraint firstAttribute="trailing" secondItem="oov-9f-Oeu" secondAttribute="trailing" constant="15" id="mpQ-4V-Yfc"/>
@@ -212,15 +233,19 @@
                                             <constraint firstAttribute="trailing" secondItem="XLb-0a-du9" secondAttribute="trailing" constant="15" id="p7C-ox-HFw"/>
                                             <constraint firstAttribute="trailing" secondItem="hBd-KD-Jq5" secondAttribute="trailing" constant="15" id="sKA-YA-3Uc"/>
                                             <constraint firstItem="uaE-Lv-t0Q" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="tnj-dz-2rk"/>
+                                            <constraint firstItem="ix8-uQ-chU" firstAttribute="leading" secondItem="uYI-ic-d8g" secondAttribute="trailing" constant="10" id="vPD-6e-zeT"/>
                                             <constraint firstItem="Son-CZ-zFa" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="vsg-gX-rNv"/>
+                                            <constraint firstItem="Typ-A8-XIO" firstAttribute="top" secondItem="ix8-uQ-chU" secondAttribute="bottom" constant="20" id="xxu-c5-Lxi"/>
                                             <constraint firstItem="n1C-OB-gq2" firstAttribute="leading" secondItem="uaE-Lv-t0Q" secondAttribute="trailing" constant="10" id="yAH-Dt-LC5"/>
                                             <constraint firstItem="Son-CZ-zFa" firstAttribute="top" secondItem="WXS-Lw-DkI" secondAttribute="bottom" constant="10" id="z9W-ZR-cUN"/>
                                         </constraints>
                                         <connections>
+                                            <outlet property="LensModelValue" destination="ix8-uQ-chU" id="9dR-tZ-OCI"/>
                                             <outlet property="dateLabel" destination="Son-CZ-zFa" id="0Wi-XW-0hw"/>
                                             <outlet property="dateValue" destination="hBd-KD-Jq5" id="ple-nX-OpH"/>
                                             <outlet property="dimLabel" destination="uaE-Lv-t0Q" id="MkZ-ko-UrJ"/>
                                             <outlet property="dimValue" destination="n1C-OB-gq2" id="Ln4-gV-wXg"/>
+                                            <outlet property="lensModelLabel" destination="uYI-ic-d8g" id="DUn-uJ-sVj"/>
                                             <outlet property="locationButton" destination="oov-9f-Oeu" id="cGg-Gb-m5S"/>
                                             <outlet property="mapHeightConstraint" destination="VRv-eR-bwo" id="jXn-vm-aJk"/>
                                             <outlet property="mapView" destination="Typ-A8-XIO" id="XCg-a6-NUq"/>

+ 14 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImageDetailView.swift

@@ -33,6 +33,8 @@ class NCViewerImageDetailView: UIView {
     @IBOutlet weak var dateValue: UILabel!
     @IBOutlet weak var dimLabel: UILabel!
     @IBOutlet weak var dimValue: UILabel!
+    @IBOutlet weak var lensModelLabel: UILabel!
+    @IBOutlet weak var lensModelValue: UILabel!
     @IBOutlet weak var mapHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var mapView: MKMapView!
     @IBOutlet weak var locationButton: UIButton!
@@ -44,6 +46,7 @@ class NCViewerImageDetailView: UIView {
     var longitude: Double = 0
     var location: String?
     var date: NSDate?
+    var lensModel: String?
     var heightMap: CGFloat = 0
     var size: Double = 0
     var image: UIImage?
@@ -62,6 +65,8 @@ class NCViewerImageDetailView: UIView {
         dateValue.text = ""
         dimLabel.text = ""
         dimValue.text = ""
+        lensModelLabel.text = ""
+        lensModelValue.text = ""
         locationButton.setTitle("" , for: .normal)
     }
     
@@ -69,6 +74,7 @@ class NCViewerImageDetailView: UIView {
         sizeValue.textColor = textColor
         dateValue.textColor = textColor
         dimValue.textColor = textColor
+        lensModelValue.textColor = textColor
         separator.backgroundColor = NCBrandColor.sharedInstance.separator
         isHidden = false
     }
@@ -92,7 +98,7 @@ class NCViewerImageDetailView: UIView {
         self.date = metadata.date
         
         if metadata.typeFile == k_metadataTypeFile_image {
-            CCUtility.setExif(metadata) { (latitude, longitude, location, date) in
+            CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensMode) in
                 self.latitude = latitude
                 self.longitude = longitude
                 self.location = location
@@ -108,6 +114,7 @@ class NCViewerImageDetailView: UIView {
             self.latitude = Double(localFile.exifLatitude) ?? 0
             self.longitude = Double(localFile.exifLongitude) ?? 0
             self.date = localFile.exifDate
+            self.lensModel = localFile.exifLensModel
             
             if let locationDB = NCManageDatabase.sharedInstance.getLocationFromGeoLatitude(latitudeString, longitude: longitudeString) {
                 location = locationDB
@@ -155,6 +162,12 @@ class NCViewerImageDetailView: UIView {
             }
         }
         
+        // Model
+        if let lensModel = self.lensModel {
+            lensModelLabel.text = NSLocalizedString("_model_", comment: "")
+            lensModelValue.text = lensModel
+        }
+        
         // Map
         if latitude > 0 && longitude > 0 {