Skip to content

Commit

Permalink
Prepare: 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaysir committed Feb 29, 2024
1 parent 4305a33 commit 6cabac9
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 4 deletions.
8 changes: 8 additions & 0 deletions DiffuserStick.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
44BD7D072B8F639E00818570 /* GoogleMobileAds in Frameworks */ = {isa = PBXBuildFile; productRef = 44BD7D062B8F639E00818570 /* GoogleMobileAds */; };
44C3B86D2B90C6AF00B71A95 /* LoadingIndicatorUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C3B86C2B90C6AF00B71A95 /* LoadingIndicatorUtil.swift */; };
44C3B86F2B90D91A00B71A95 /* AdManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C3B86E2B90D91A00B71A95 /* AdManager.swift */; };
44C3B8712B90E5F500B71A95 /* FirstRunUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C3B8702B90E5F500B71A95 /* FirstRunUtil.swift */; };
44C3B8732B90E7B300B71A95 /* CleanupDocumentDirectoryUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C3B8722B90E7B300B71A95 /* CleanupDocumentDirectoryUtil.swift */; };
44E868FD26A80A59008B2D62 /* fontawesome-webfont.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 44E868FC26A80A3A008B2D62 /* fontawesome-webfont.ttf */; };
44E8690226A9423F008B2D62 /* help.html in Resources */ = {isa = PBXBuildFile; fileRef = 44E8690126A9423F008B2D62 /* help.html */; };
44E8690426A948C2008B2D62 /* ArchiveViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44E8690326A948C2008B2D62 /* ArchiveViewController.swift */; };
Expand Down Expand Up @@ -65,6 +67,8 @@
44BB07752B8F665500F57C4B /* IAPHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IAPHelper.swift; sourceTree = "<group>"; };
44C3B86C2B90C6AF00B71A95 /* LoadingIndicatorUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingIndicatorUtil.swift; sourceTree = "<group>"; };
44C3B86E2B90D91A00B71A95 /* AdManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdManager.swift; sourceTree = "<group>"; };
44C3B8702B90E5F500B71A95 /* FirstRunUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstRunUtil.swift; sourceTree = "<group>"; };
44C3B8722B90E7B300B71A95 /* CleanupDocumentDirectoryUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CleanupDocumentDirectoryUtil.swift; sourceTree = "<group>"; };
44E868FC26A80A3A008B2D62 /* fontawesome-webfont.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "fontawesome-webfont.ttf"; sourceTree = "<group>"; };
44E8690126A9423F008B2D62 /* help.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = help.html; sourceTree = "<group>"; };
44E8690326A948C2008B2D62 /* ArchiveViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArchiveViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -191,6 +195,8 @@
448784B82B9066690073B2DE /* DeviceUtil.swift */,
448784BA2B9067310073B2DE /* AppMetadataUtil.swift */,
44C3B86C2B90C6AF00B71A95 /* LoadingIndicatorUtil.swift */,
44C3B8702B90E5F500B71A95 /* FirstRunUtil.swift */,
44C3B8722B90E7B300B71A95 /* CleanupDocumentDirectoryUtil.swift */,
);
path = Util;
sourceTree = "<group>";
Expand Down Expand Up @@ -291,12 +297,14 @@
4456C9B1269D4E8400A29B77 /* AppDelegate.swift in Sources */,
44FDCFD026A070BB00A7A7FD /* CalendarExtension.swift in Sources */,
4456C9CA269D534200A29B77 /* ActiveListViewController.swift in Sources */,
44C3B8732B90E7B300B71A95 /* CleanupDocumentDirectoryUtil.swift in Sources */,
44C3B86F2B90D91A00B71A95 /* AdManager.swift in Sources */,
44FDCFCE269FEF7F00A7A7FD /* FileUtil.swift in Sources */,
4456C9B3269D4E8400A29B77 /* SceneDelegate.swift in Sources */,
44FDCFD226A1419100A7A7FD /* UIExtension.swift in Sources */,
44FDCFC2269EA8B300A7A7FD /* ParsePlist.swift in Sources */,
444EEE0B26B167EF00454428 /* LocalNotification.swift in Sources */,
44C3B8712B90E5F500B71A95 /* FirstRunUtil.swift in Sources */,
448784B22B905CE80073B2DE /* HelpViewController.swift in Sources */,
44C3B86D2B90C6AF00B71A95 /* LoadingIndicatorUtil.swift in Sources */,
448784B92B9066690073B2DE /* DeviceUtil.swift in Sources */,
Expand Down
2 changes: 0 additions & 2 deletions DiffuserStick/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import GoogleMobileAds
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

Expand Down Expand Up @@ -89,7 +88,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}
}

}

// 추가
Expand Down
2 changes: 1 addition & 1 deletion DiffuserStick/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="30" minimumValue="15" maximumValue="360" stepValue="15" translatesAutoresizingMaskIntoConstraints="NO" id="p6e-7a-SlM">
<stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="30" minimumValue="15" maximumValue="360" stepValue="5" translatesAutoresizingMaskIntoConstraints="NO" id="p6e-7a-SlM">
<rect key="frame" x="300" y="506.5" width="94" height="32"/>
<connections>
<action selector="stepperDaysAction:" destination="VgC-oY-3JU" eventType="valueChanged" id="QUY-gt-u8Y"/>
Expand Down
53 changes: 53 additions & 0 deletions DiffuserStick/Util/CleanupDocumentDirectoryUtil.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// CleanupDocumentDirectoryUtil.swift
// DiffuserStick
//
// Created by 윤범태 on 3/1/24.
//

import Foundation

class CleanupDocumentDirectoryUtil {
/// 1.3.0 이전 버전에서 삭제되지 않은 Document 디렉토리의 이미지 파일을 삭제
func doCleanup() {
let activeData = try? readCoreData(isArchive: false)
let archiveData = try? readCoreData(isArchive: true)

let documentDir = getDocumentsDirectory()
var validImageFiles: [URL] = []

if let activeData {
activeData.forEach { diffuser in
validImageFiles.append(documentDir.appendingPathComponent(diffuser.photoName))
print(#function, "Added valid image file:", diffuser.photoName)
}
}

if let archiveData {
archiveData.forEach { diffuser in
validImageFiles.append(documentDir.appendingPathComponent(diffuser.photoName))
print(#function, "Added valid image file:", diffuser.photoName)
}
}

do {
// Get the directory contents urls (including subfolders urls)
let directoryContents = try FileManager.default.contentsOfDirectory(
at: documentDir,
includingPropertiesForKeys: nil
)

directoryContents.forEach { url in
if !validImageFiles.contains(url) {
removeFile(from: url)
print(#function, "This file has been disconnected from the database. Delete:", url.lastPathComponent)
} else {
print(#function, "This file is valid so we will not delete it:", url.lastPathComponent)
}
}
} catch {
print(#function, error)
}

}
}
2 changes: 1 addition & 1 deletion DiffuserStick/Util/CoreData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func updateCoreData(id: UUID, diffuserVO diffuser: DiffuserVO) -> Bool {

do {
let result = try managedContext.fetch(fetchRequest)
let diffuserCD = result[0] as! NSManagedObject
let diffuserCD = result[0] as! Diffuser

diffuserCD.setValue(diffuser.comments, forKey: "comments")
diffuserCD.setValue(diffuser.photoName, forKey: "photoName")
Expand Down
8 changes: 8 additions & 0 deletions DiffuserStick/Util/FileUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ enum ImageFormat {
case gif, jpg, png, webp, unknown
}

func removeFile(from url: URL) {
do {
try FileManager.default.removeItem(at: url)
} catch {
print(#function, error)
}
}

func removeImageFileFromDocument(fileNameIncludesExtension: String) {
let fileManager = FileManager.default
let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
Expand Down
27 changes: 27 additions & 0 deletions DiffuserStick/Util/FirstRunUtil.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// FirstRunUtil.swift
// DiffuserStick
//
// Created by 윤범태 on 3/1/24.
//

import Foundation

func checkAppFirstrunOrUpdateStatus(firstrun: () -> (), updated: () -> (), nothingChanged: () -> ()) {
let currentVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
let versionOfLastRun = UserDefaults.standard.object(forKey: "VersionOfLastRun") as? String

if versionOfLastRun == nil {
// First start after installing the app
firstrun()
} else if versionOfLastRun != currentVersion {
// App was updated since last run
updated()
} else {
// nothing changed
nothingChanged()
}

UserDefaults.standard.set(currentVersion, forKey: "VersionOfLastRun")
UserDefaults.standard.synchronize()
}
4 changes: 4 additions & 0 deletions DiffuserStick/ViewController/DiffuserAddViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,14 @@ class DiffuserAddViewController: UIViewController {
return
}

let oldPhotoNameWithExt = selectedDiffuser?.photoName
let modifiedPhotoNameWithoutExt = inputTitle.text!.convertToValidFileName() + "___" + uuid.uuidString
let savePhotoResult = saveImage(image: imgPhoto.image!, fileNameWithoutExt: modifiedPhotoNameWithoutExt)
selectedDiffuser?.photoName = modifiedPhotoNameWithoutExt + "." + savePhotoResult!

if let oldPhotoNameWithExt, oldPhotoNameWithExt != selectedDiffuser?.photoName {
removeImageFileFromDocument(fileNameIncludesExtension: oldPhotoNameWithExt)
}

if modifyDelegate != nil {
modifyDelegate?.sendDiffuser(self, diffuser: selectedDiffuser!)
Expand Down

0 comments on commit 6cabac9

Please sign in to comment.