Skip to content

Commit cfc9ccf

Browse files
committed
- Fixes retina images loading
1 parent 5614dad commit cfc9ccf

File tree

7 files changed

+21
-22
lines changed

7 files changed

+21
-22
lines changed

FSNotes iOS/AppDelegate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8080
let webkitPreview = URL(fileURLWithPath: temp).appendingPathComponent("wkPreview")
8181
try? FileManager.default.removeItem(at: webkitPreview)
8282

83+
let imagesPreview = URL(fileURLWithPath: temp).appendingPathComponent("ThumbnailsBig")
84+
try? FileManager.default.removeItem(at: imagesPreview)
85+
8386
Storage.shared().saveProjectsCache()
8487
UserDefaultsManagement.crashedLastTime = false
8588

FSNotes iOS/Extensions/CustomTextStorage+Images.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ extension NSTextStorage {
1313
public func loadImage(attachment: NSTextAttachment, url: URL, range: NSRange) {
1414
EditTextView.imagesLoaderQueue.addOperation {
1515
guard let size = attachment.image?.size else { return }
16+
let scale = UIScreen.main.scale
1617

17-
let retinaSize = CGSize(width: size.width * 2, height: size.height * 2)
18+
let retinaSize = CGSize(width: size.width * scale, height: size.height * scale)
1819
attachment.image = NoteAttachment.getImage(url: url, size: retinaSize)
1920

2021
DispatchQueue.main.async {

FSNotes iOS/Extensions/ImageAttachment+.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@ import MobileCoreServices
1111
import AVKit
1212

1313
extension NoteAttachment {
14-
public func load(lazy: Bool = true) -> NSTextAttachment? {
14+
public func load() -> NSTextAttachment? {
1515
let imageSize = getSize(url: self.url)
1616
guard let size = getImageSize(imageSize: imageSize) else { return nil }
1717

1818
let attachment = NSTextAttachment()
1919
attachment.bounds = CGRect(x: 0, y: 0, width: size.width, height: size.height)
20-
21-
if lazy {
22-
attachment.image = UIImage.emptyImage(with: size)
23-
} else {
24-
attachment.image = NoteAttachment.getImage(url: self.url, size: size)
25-
}
20+
attachment.image = UIImage.emptyImage(with: size)
2621

2722
return attachment
2823
}
@@ -76,12 +71,12 @@ extension NoteAttachment {
7671
guard let image = finalImage else { return nil }
7772
var thumbImage: UIImage?
7873

79-
if let cacheURL = self.getCacheUrl(from: url, prefix: "ThumbnailsBig"), FileManager.default.fileExists(atPath: cacheURL.path) {
74+
if let cacheURL = self.getCacheUrl(from: url, prefix: "ThumbnailsBigInline"), FileManager.default.fileExists(atPath: cacheURL.path) {
8075
thumbImage = UIImage(contentsOfFile: cacheURL.path)
8176
} else if
8277
let resizedImage = self.resize(image: image, size: size) {
8378
thumbImage = resizedImage
84-
self.savePreviewImage(url: url, image: resizedImage, prefix: "ThumbnailsBig")
79+
self.savePreviewImage(url: url, image: resizedImage, prefix: "ThumbnailsBigInline")
8580
}
8681

8782
return thumbImage

FSNotes iOS/View/EditTextView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class EditTextView: UITextView, UITextViewDelegate {
255255
let range = NSRange(location: selectedRange.location, length: 1)
256256
let attachment = NoteAttachment(title: "", path: path, url: imageUrl, cache: nil, invalidateRange: range, note: note)
257257

258-
if let attributedString = attachment.getAttributedString(lazy: false) {
258+
if let attributedString = attachment.getAttributedString() {
259259

260260
undoManager?.beginUndoGrouping()
261261
textStorage.replaceCharacters(in: selectedRange, with: attributedString)

FSNotes.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4419,12 +4419,12 @@
44194419
CODE_SIGN_IDENTITY = "iPhone Developer";
44204420
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
44214421
CODE_SIGN_STYLE = Automatic;
4422-
CURRENT_PROJECT_VERSION = 212;
4422+
CURRENT_PROJECT_VERSION = 214;
44234423
DEVELOPMENT_TEAM = 866P6MTE92;
44244424
INFOPLIST_FILE = "FSNotes iOS Share/Info.plist";
44254425
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
44264426
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
4427-
MARKETING_VERSION = 4.5.1;
4427+
MARKETING_VERSION = 4.5.2;
44284428
PRODUCT_BUNDLE_IDENTIFIER = "co.fluder.mobile.FSNotes-iOS.FSNotes-iOS-Share";
44294429
PRODUCT_NAME = "$(TARGET_NAME)";
44304430
SDKROOT = iphoneos;
@@ -4443,13 +4443,13 @@
44434443
CODE_SIGN_IDENTITY = "iPhone Distribution";
44444444
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
44454445
CODE_SIGN_STYLE = Automatic;
4446-
CURRENT_PROJECT_VERSION = 211;
4446+
CURRENT_PROJECT_VERSION = 214;
44474447
DEVELOPMENT_TEAM = 866P6MTE92;
44484448
ENABLE_NS_ASSERTIONS = NO;
44494449
INFOPLIST_FILE = "FSNotes iOS Share/Info.plist";
44504450
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
44514451
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
4452-
MARKETING_VERSION = 4.5.0;
4452+
MARKETING_VERSION = 4.5.2;
44534453
PRODUCT_BUNDLE_IDENTIFIER = "co.fluder.mobile.FSNotes-iOS.FSNotes-iOS-Share";
44544454
PRODUCT_NAME = "$(TARGET_NAME)";
44554455
SDKROOT = iphoneos;
@@ -4471,12 +4471,12 @@
44714471
CODE_SIGN_IDENTITY = "iPhone Developer";
44724472
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
44734473
CODE_SIGN_STYLE = Automatic;
4474-
CURRENT_PROJECT_VERSION = 212;
4474+
CURRENT_PROJECT_VERSION = 214;
44754475
DEVELOPMENT_TEAM = 866P6MTE92;
44764476
INFOPLIST_FILE = "FSNotes iOS/Info.plist";
44774477
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
44784478
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
4479-
MARKETING_VERSION = 4.5.1;
4479+
MARKETING_VERSION = 4.5.2;
44804480
PRODUCT_BUNDLE_IDENTIFIER = "co.fluder.mobile.FSNotes-iOS";
44814481
PRODUCT_NAME = "$(TARGET_NAME)";
44824482
PROVISIONING_PROFILE = "";
@@ -4501,13 +4501,13 @@
45014501
CODE_SIGN_IDENTITY = "iPhone Developer";
45024502
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
45034503
CODE_SIGN_STYLE = Automatic;
4504-
CURRENT_PROJECT_VERSION = 212;
4504+
CURRENT_PROJECT_VERSION = 214;
45054505
DEVELOPMENT_TEAM = 866P6MTE92;
45064506
ENABLE_NS_ASSERTIONS = NO;
45074507
INFOPLIST_FILE = "FSNotes iOS/Info.plist";
45084508
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
45094509
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
4510-
MARKETING_VERSION = 4.5.1;
4510+
MARKETING_VERSION = 4.5.2;
45114511
PRODUCT_BUNDLE_IDENTIFIER = "co.fluder.mobile.FSNotes-iOS";
45124512
PRODUCT_NAME = "$(TARGET_NAME)";
45134513
PROVISIONING_PROFILE = "";

FSNotes/Extensions/ImageAttachment+.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Cocoa
1010
import AVKit
1111

1212
extension NoteAttachment {
13-
public func load(lazy: Bool = true) -> NSTextAttachment? {
13+
public func load() -> NSTextAttachment? {
1414
guard let container = ViewController.shared()?.editArea.textContainer else { return nil }
1515

1616
let attachment = NSTextAttachment()

FSNotesCore/Shared/Business/NoteAttachment.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class NoteAttachment {
4747

4848
weak var weakTimer: Timer?
4949

50-
public func getAttributedString(lazy: Bool = true) -> NSMutableAttributedString? {
50+
public func getAttributedString() -> NSMutableAttributedString? {
5151
let imageKey = NSAttributedString.Key(rawValue: "co.fluder.fsnotes.image.url")
5252
let pathKey = NSAttributedString.Key(rawValue: "co.fluder.fsnotes.image.path")
5353
let titleKey = NSAttributedString.Key(rawValue: "co.fluder.fsnotes.image.title")
@@ -61,7 +61,7 @@ class NoteAttachment {
6161
}
6262

6363
guard FileManager.default.fileExists(atPath: self.url.path) else { return nil }
64-
guard let attachment = load(lazy: lazy) else { return nil }
64+
guard let attachment = load() else { return nil }
6565

6666
let attributedString = NSAttributedString(attachment: attachment)
6767
let mutableAttributedString = NSMutableAttributedString(attributedString: attributedString)

0 commit comments

Comments
 (0)