From 047c9e9504de5926ab317a7f6b68bf1dc543a66a Mon Sep 17 00:00:00 2001 From: leminlimez <59540996+leminlimez@users.noreply.github.com> Date: Wed, 11 Jun 2025 19:50:42 -0400 Subject: [PATCH] show the frames being generated in alert --- Pocket Poster.xcodeproj/project.pbxproj | 4 +-- .../Controllers/PosterBoardManager.swift | 1 + Pocket Poster/Controllers/VideoHandler.swift | 4 ++- Pocket Poster/Views/ContentView.swift | 30 +++++++++++-------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Pocket Poster.xcodeproj/project.pbxproj b/Pocket Poster.xcodeproj/project.pbxproj index 3412f62..78f3251 100644 --- a/Pocket Poster.xcodeproj/project.pbxproj +++ b/Pocket Poster.xcodeproj/project.pbxproj @@ -264,7 +264,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"Pocket Poster/Preview Content\""; DEVELOPMENT_TEAM = 2P4CP47H76; ENABLE_PREVIEWS = YES; @@ -296,7 +296,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"Pocket Poster/Preview Content\""; DEVELOPMENT_TEAM = 2P4CP47H76; ENABLE_PREVIEWS = YES; diff --git a/Pocket Poster/Controllers/PosterBoardManager.swift b/Pocket Poster/Controllers/PosterBoardManager.swift index a7d8911..a052ee7 100644 --- a/Pocket Poster/Controllers/PosterBoardManager.swift +++ b/Pocket Poster/Controllers/PosterBoardManager.swift @@ -190,6 +190,7 @@ class PosterBoardManager: ObservableObject { print(error.localizedDescription) } } + UIApplication.shared.change(title: "Applying Wallpapers...", body: "Extracting tendies...") for url in selectedTendies { let unzippedDir = try unzipFile(at: url) guard let descriptors = try getDescriptorsFromTendie(unzippedDir) else { continue } // TODO: Add error handling diff --git a/Pocket Poster/Controllers/VideoHandler.swift b/Pocket Poster/Controllers/VideoHandler.swift index 26b03b0..2be5816 100644 --- a/Pocket Poster/Controllers/VideoHandler.swift +++ b/Pocket Poster/Controllers/VideoHandler.swift @@ -91,11 +91,12 @@ class VideoHandler { while let sampleBuffer = readerOutput.copyNextSampleBuffer(), let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) { + let name = "\(frameCount).jpg" + UIApplication.shared.change(title: "Generating Video...", body: "Creating assets/\(name)...") let ciImage = CIImage(cvPixelBuffer: imageBuffer) let context = CIContext() if let cgImage = context.createCGImage(ciImage, from: ciImage.extent) { - let name = "\(frameCount).jpg" if let img = cgImage.jpg { try img.write(to: assetsFolder.appendingPathComponent(name)) camlData += "\t\t\t\n" @@ -107,6 +108,7 @@ class VideoHandler { } catch { print("Error reading asset: \(error)") } + UIApplication.shared.change(title: "Generating Video...", body: "Creating CAML data...") camlData += """ diff --git a/Pocket Poster/Views/ContentView.swift b/Pocket Poster/Views/ContentView.swift index 7fc0297..73c8853 100644 --- a/Pocket Poster/Views/ContentView.swift +++ b/Pocket Poster/Views/ContentView.swift @@ -136,9 +136,9 @@ struct ContentView: View { if !pbManager.selectedTendies.isEmpty || selectedVideo != nil { Button(action: { UIImpactFeedbackGenerator(style: .soft).impactOccurred() - UIApplication.shared.alert(title: NSLocalizedString("Applying Tendies...", comment: ""), body: NSLocalizedString("Please wait", comment: ""), animated: false, withButton: false) + UIApplication.shared.alert(title: NSLocalizedString("Applying Wallpapers...", comment: ""), body: NSLocalizedString("Please wait", comment: ""), animated: false, withButton: false) - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + DispatchQueue.global(qos: .userInitiated).async { do { var videoURL: URL? = nil switch loadState { @@ -148,26 +148,30 @@ struct ContentView: View { videoURL = nil } try pbManager.applyTendies(appHash: pbHash, videoURL: videoURL) - pbManager.selectedTendies.removeAll() SymHandler.cleanup() // just to be extra sure try? FileManager.default.removeItem(at: pbManager.getTendiesStoreURL()) if let videoURL = videoURL { try? FileManager.default.removeItem(at: videoURL) } Haptic.shared.notify(.success) - UIApplication.shared.dismissAlert(animated: true) - UIApplication.shared.confirmAlert(title: "Success!", body: "The PosterBoard app will now open. Please close it from the app switcher.", onOK: { - if !pbManager.openPosterBoard() { - UIApplication.shared.confirmAlert(title: "Falling Back to Shortcut", body: "PosterBoard failed to open directly. The fallback shortcut will now be opened.", onOK: { - pbManager.runShortcut(named: "PosterBoard") - }, noCancel: true) - } - }, noCancel: true) + UIApplication.shared.dismissAlert(animated: false) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.35, execute: { + pbManager.selectedTendies.removeAll() + UIApplication.shared.confirmAlert(title: "Success!", body: "The PosterBoard app will now open. Please close it from the app switcher.", onOK: { + if !pbManager.openPosterBoard() { + UIApplication.shared.confirmAlert(title: "Falling Back to Shortcut", body: "PosterBoard failed to open directly. The fallback shortcut will now be opened.", onOK: { + pbManager.runShortcut(named: "PosterBoard") + }, noCancel: true) + } + }, noCancel: true) + }) } catch { Haptic.shared.notify(.error) SymHandler.cleanup() - UIApplication.shared.dismissAlert(animated: true) - UIApplication.shared.alert(body: error.localizedDescription) + UIApplication.shared.dismissAlert(animated: false) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.35, execute: { + UIApplication.shared.alert(body: error.localizedDescription) + }) } } }) {