Ver código fonte

basic support to show webp images, including animated ones

cyberta 4 anos atrás
pai
commit
cd54c5558b

+ 4 - 0
deltachat-ios/AppDelegate.swift

@@ -5,6 +5,7 @@ import UIKit
 import UserNotifications
 import DcCore
 import DBDebugToolkit
+import SDWebImageWebPCoder
 
 let logger = SwiftyBeaver.self
 
@@ -105,6 +106,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             registerForNotifications()
         }
 
+        let webPCoder = SDImageWebPCoder.shared
+        SDImageCodersManager.shared.addCoder(webPCoder)
+
         return true
     }
 

+ 10 - 6
deltachat-ios/Chat/Views/Cells/ImageTextCell.swift

@@ -48,12 +48,11 @@ class ImageTextCell: BaseMessageCell {
         mainContentView.spacing = msg.text?.isEmpty ?? false ? 0 : 6
         topCompactView = msg.quoteText == nil ? true : false
         tag = msg.id
-        if msg.type == DC_MSG_IMAGE, let image = msg.image {
-            contentImageView.image = image
-            accessibilityLabel = String.localized("image")
-            playButtonView.isHidden = true
-            setAspectRatioFor(message: msg)
-        } else if msg.type == DC_MSG_GIF, let url = msg.fileURL {
+
+        if let url = msg.fileURL,
+           ((msg.type == DC_MSG_GIF) ||
+                msg.type == DC_MSG_STICKER ||
+                (msg.type == DC_MSG_IMAGE && url.pathExtension == "webp")) {
             contentImageView.sd_setImage(with: url,
                                          placeholderImage: UIImage(color: UIColor.init(alpha: 0,
                                                                                        red: 255,
@@ -63,6 +62,11 @@ class ImageTextCell: BaseMessageCell {
             playButtonView.isHidden = true
             accessibilityLabel = String.localized("gif")
             setAspectRatioFor(message: msg)
+        } else if msg.type == DC_MSG_IMAGE, let image = msg.image {
+            contentImageView.image = image
+            accessibilityLabel = String.localized("image")
+            playButtonView.isHidden = true
+            setAspectRatioFor(message: msg)
         } else if msg.type == DC_MSG_VIDEO, let url = msg.fileURL {
             playButtonView.isHidden = false
             accessibilityLabel = String.localized("video")