alqindiirsyam 6 kuukautta sitten
vanhempi
commit
cb0eafb2d5

+ 2 - 2
AppBuilder/AppBuilder.xcodeproj/project.pbxproj

@@ -540,7 +540,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				MARKETING_VERSION = 4.0.6;
+				MARKETING_VERSION = 4.0.6a;
 				PRODUCT_BUNDLE_IDENTIFIER = io.newuniverse.AppBuilder2;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";
@@ -572,7 +572,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				MARKETING_VERSION = 4.0.6;
+				MARKETING_VERSION = 4.0.6a;
 				PRODUCT_BUNDLE_IDENTIFIER = io.newuniverse.AppBuilder2;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";

+ 65 - 7
AppBuilder/AppBuilder/SecondTabViewController.swift

@@ -10,6 +10,7 @@ import FMDB
 import NexilisLite
 import Speech
 import QuickLook
+import SDWebImage
 
 class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGestureRecognizerDelegate, UITextFieldDelegate, UICollectionViewDelegate, UICollectionViewDataSource, QLPreviewControllerDataSource {
     var isChooser: ((String, String) -> ())?
@@ -118,14 +119,17 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
                     case UNREAD_TAG :
                         fillteredData = self.chats.filter { $0.counter != "0" }
                         break
-                    case PHOTOS_TAG, VIDEOS_TAG :
-                        fillteredData = Chat.getData(isImage: selectedTag == PHOTOS_TAG, isVideo: selectedTag == VIDEOS_TAG)
+                    case PHOTOS_TAG, VIDEOS_TAG, GIFS_TAG :
+                        fillteredData = Chat.getData(isImage: selectedTag == PHOTOS_TAG, isVideo: selectedTag == VIDEOS_TAG, isGIF: selectedTag == GIFS_TAG)
                         if fillteredData.count > 0 {
                             if gridImage != nil && gridImage.isDescendant(of: self.view) {
                                 gridImage.removeFromSuperview()
                             }
                             let width = self.view.frame.width / 3 - 2
-                            let cellSize = CGSize(width:width, height:width)
+                            var cellSize = CGSize(width:width, height:width)
+                            if selectedTag == GIFS_TAG {
+                                cellSize = CGSize(width:self.view.frame.width / 2 - 2, height:self.view.frame.width / 2 - 62)
+                            }
                             let layout = UICollectionViewFlowLayout()
                             layout.scrollDirection = .vertical
                             layout.itemSize = cellSize
@@ -149,8 +153,6 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
                     case DOCUMENTS_TAG :
                         fillteredData = Chat.getData(isDoc: true)
                         break
-                    case GIFS_TAG :
-                        break
                     case LINKS_TAG :
                         fillteredData = Chat.getData(isLink: true)
                         break
@@ -2090,12 +2092,49 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
         let thumb = data.thumb
         let imgData = data.image
         let vidData = data.video
+        let gifData = data.gif
         let image = UIImageView()
-        cell.contentView.addSubview(image)
         let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
         let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
         let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
         if let dirPath = paths.first {
+            if selectedTag == GIFS_TAG {
+                let gifURL = URL(fileURLWithPath: dirPath).appendingPathComponent(gifData)
+                if !FileManager.default.fileExists(atPath: gifURL.path) && !FileEncryption.shared.isSecureExists(filename: gifData) {
+                    Download().startHTTP(forKey: gifData, isImage: false) { (name, progress) in
+                        guard progress == 100 else {
+                            return
+                        }
+                        collectionView.reloadItems(at: [indexPath])
+                    }
+                } else {
+                    let imageGif = SDAnimatedImageView()
+                    cell.contentView.addSubview(imageGif)
+                    imageGif.contentMode = .scaleAspectFill
+                    imageGif.clipsToBounds = true
+                    imageGif.translatesAutoresizingMaskIntoConstraints = false
+                    imageGif.anchor(top: cell.contentView.topAnchor, left: cell.contentView.leftAnchor, bottom: cell.contentView.bottomAnchor, right: cell.contentView.rightAnchor)
+                    if FileManager.default.fileExists(atPath: gifURL.path) {
+                        imageGif.image = SDAnimatedImage(contentsOfFile: gifURL.path)
+//                        imageGif.shouldCustomLoopCount = true
+//                        imageGif.animationRepeatCount = 4
+                    } else if FileEncryption.shared.isSecureExists(filename: gifData){
+                        do {
+                            let data = try FileEncryption.shared.readSecure(filename: gifData)
+                            if let imageData = SDAnimatedImage(data: data!) {
+                                imageGif.image = imageData
+//                                imageGif.shouldCustomLoopCount = true
+//                                imageGif.animationRepeatCount = 4
+                            }
+                        }
+                        catch {
+                            print("Error reading secure file")
+                        }
+                    }
+                }
+                return cell
+            }
+            cell.contentView.addSubview(image)
             let thumbURL = URL(fileURLWithPath: dirPath).appendingPathComponent(thumb)
             let imageT : UIImage? =  {
                 if let img = Nexilis.imageCache.object(forKey: thumb as NSString) {
@@ -2148,6 +2187,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
         let data = fillteredData[indexPath.row] as! Chat
         let imgData = data.image
         let vidData = data.video
+        let gifData = data.gif
         let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
         let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
         let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
@@ -2175,7 +2215,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
                         }
                     }
                 }
-            } else {
+            } else if selectedTag == VIDEOS_TAG {
                 let videoURL = URL(fileURLWithPath: dirPath).appendingPathComponent(vidData)
                 if FileManager.default.fileExists(atPath: videoURL.path) {
                     APIS.openVideoNexilis(videoURL: videoURL)
@@ -2200,6 +2240,24 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
                         }
                     }
                 }
+            } else {
+                let gifURL = URL(fileURLWithPath: dirPath).appendingPathComponent(gifData)
+                if FileManager.default.fileExists(atPath: gifURL.path) {
+                    do {
+                        let data = try Data(contentsOf: gifURL)
+                        APIS.openImageNexilis(image: UIImage(), data: data, isGIF: true)
+                    } catch {
+                        
+                    }
+                } else if FileEncryption.shared.isSecureExists(filename: gifData) {
+                    do {
+                        if let secureData = try FileEncryption.shared.readSecure(filename: gifData) {
+                            APIS.openImageNexilis(image: UIImage(), data: secureData, isGIF: true)
+                        }
+                    } catch {
+                        
+                    }
+                }
             }
         }
     }

+ 3 - 1
NexilisLite/NexilisLite/Source/APIS.swift

@@ -814,10 +814,12 @@ public class APIS: NSObject {
 //        Utils.bPreventScreenCapture = isActive
     }
     
-    public static func openImageNexilis(image: UIImage) {
+    public static func openImageNexilis(image: UIImage, data: Data? = nil, isGIF: Bool = false) {
         let previewImageVC = PreviewAttachmentImageVideo(nibName: "PreviewAttachmentImageVideo", bundle: Bundle.resourceBundle(for: Nexilis.self))
         previewImageVC.image = image
         previewImageVC.isHiddenTextField = true
+        previewImageVC.isGIF = isGIF
+        previewImageVC.dataGIF = data
         previewImageVC.modalPresentationStyle = .custom
         previewImageVC.modalTransitionStyle  = .crossDissolve
         if UIApplication.shared.visibleViewController?.navigationController != nil {

+ 19 - 1
NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -5496,7 +5496,25 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
                 }
             }
         } else if (sender.gif_id != "") {
-            
+            if let dirPath = paths.first {
+                let gifURL = URL(fileURLWithPath: dirPath).appendingPathComponent(sender.gif_id)
+                if FileManager.default.fileExists(atPath: gifURL.path) {
+                    do {
+                        let data = try Data(contentsOf: gifURL)
+                        APIS.openImageNexilis(image: UIImage(), data: data, isGIF: true)
+                    } catch {
+                        
+                    }
+                } else if FileEncryption.shared.isSecureExists(filename: sender.gif_id) {
+                    do {
+                        if let secureData = try FileEncryption.shared.readSecure(filename: sender.gif_id) {
+                            APIS.openImageNexilis(image: UIImage(), data: secureData, isGIF: true)
+                        }
+                    } catch {
+                        
+                    }
+                }
+            }
         } else if (sender.video_id != "") {
             if let dirPath = paths.first {
                 let videoURL = URL(fileURLWithPath: dirPath).appendingPathComponent(sender.video_id)

+ 19 - 1
NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -6730,7 +6730,25 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                 }
             }
         } else if (sender.gif_id != "") {
-            
+            if let dirPath = paths.first {
+                let gifURL = URL(fileURLWithPath: dirPath).appendingPathComponent(sender.gif_id)
+                if FileManager.default.fileExists(atPath: gifURL.path) {
+                    do {
+                        let data = try Data(contentsOf: gifURL)
+                        APIS.openImageNexilis(image: UIImage(), data: data, isGIF: true)
+                    } catch {
+                        
+                    }
+                } else if FileEncryption.shared.isSecureExists(filename: sender.gif_id) {
+                    do {
+                        if let secureData = try FileEncryption.shared.readSecure(filename: sender.gif_id) {
+                            APIS.openImageNexilis(image: UIImage(), data: secureData, isGIF: true)
+                        }
+                    } catch {
+                        
+                    }
+                }
+            }
         } else if (sender.video_id != "") {
             if let dirPath = paths.first {
                 let videoURL = URL(fileURLWithPath: dirPath).appendingPathComponent(sender.video_id)