Merge branch 'main' into carplay

This commit is contained in:
leminlimez committed 2025-07-14 15:58:16 -04:00
commit 9687a8f19d
7 files changed
+2480 -93

No files matched your search

+14 -10
View File
@@ -99,17 +99,21 @@ struct ContentView: View {
.buttonStyle(TintedButton(color: .blue, fullwidth: true))
}
Button(action: {
guard let lang = UserDefaults.standard.stringArray(forKey: "AppleLanguages")?.first else {
hideResetHelp = false // fallback to tutorial
return
}
UIApplication.shared.confirmAlert(title: NSLocalizedString("Reset Collections", comment: ""), body: NSLocalizedString("Do you want to reset collections?", comment: ""), onOK: {
if pbManager.setSystemLanguage(to: lang) {
UIApplication.shared.alert(title: NSLocalizedString("Collections Successfully Reset!", comment: ""), body: NSLocalizedString("Your PosterBoard will refresh automatically.", comment: ""))
} else {
UIApplication.shared.alert(body: "The API failed to call correctly.\nSystem Locale Code: \(lang)")
if #available(iOS 18.0, *) {
guard let lang = UserDefaults.standard.stringArray(forKey: "AppleLanguages")?.first else {
hideResetHelp = false // fallback to tutorial
return
}
}, noCancel: false)
UIApplication.shared.confirmAlert(title: NSLocalizedString("Reset Collections", comment: ""), body: NSLocalizedString("Do you want to reset collections?", comment: ""), onOK: {
if pbManager.setSystemLanguage(to: lang) {
UIApplication.shared.alert(title: NSLocalizedString("Collections Successfully Reset!", comment: ""), body: NSLocalizedString("Your PosterBoard will refresh automatically.", comment: ""))
} else {
UIApplication.shared.alert(body: "The API failed to call correctly.\nSystem Locale Code: \(lang)")
}
}, noCancel: false)
} else {
hideResetHelp = false
}
}) {
Label("Reset Collections", systemImage: "arrow.clockwise.circle")
}
+16 -31
View File
@@ -26,30 +26,16 @@ struct SettingsView: View {
TextField("Enter CarPlayWallpaper App Hash", text: $cpHash)
.textFieldStyle(RoundedBorderTextFieldStyle())
.font(.system(.body, design: .monospaced))
.onChange(of: pbHash) { _ in
var separator: String? = nil
if pbHash.contains(" ") {
separator = " "
} else if pbHash.contains("\n") {
separator = "\n"
}
if let separator = separator {
let items = pbHash.split(separator: separator)
if let pb = items.first {
pbHash = String(pb)
}
if items.count >= 2 {
cpHash = String(items[1])
}
}
}
HStack {
Spacer()
// Run task to check until file exists from Nugget pc over AFC
Button(action: {
UIApplication.shared.confirmAlert(title: "Waiting for app hashes...", body: "Connect your device to Nugget and click the \"Pocket Poster Helper\" button.", confirmTitle: "Cancel", onOK: {
cancelWaitForHash()
}, noCancel: true)
if !FileManager.default.fileExists(atPath: SymHandler.getPosterBoardHashURL().path()) {
// don't show the alert because it is already there
UIApplication.shared.confirmAlert(title: NSLocalizedString("Waiting for app hash...", comment: ""), body: NSLocalizedString("Connect your device to Nugget and click the \"Pocket Poster Helper\" button.", comment: ""), confirmTitle: NSLocalizedString("Cancel", comment: ""), onOK: {
cancelWaitForHash()
}, noCancel: true)
}
startWaitForHash()
}) {
Text("Detect")
@@ -165,7 +151,7 @@ struct SettingsView: View {
func startWaitForHash() {
checkingForHash = true
hashCheckTask = Task {
let filePath = SymHandler.getLCDocumentsDirectory().appendingPathComponent("NuggetAppHash")
let filePath = SymHandler.getPosterBoardHashURL()
while !FileManager.default.fileExists(atPath: filePath.path()) {
try? await Task.sleep(nanoseconds: 500_000_000) // Sleep 0.5s
try Task.checkCancellation()
@@ -175,16 +161,15 @@ struct SettingsView: View {
let contents = try String(contentsOf: filePath)
try? FileManager.default.removeItem(at: filePath)
await MainActor.run {
var separator = " "
if contents.contains("\n") {
separator = "\n"
}
let items = contents.split(separator: separator)
if let pb = items.first {
pbHash = String(pb)
}
if items.count >= 2 {
cpHash = String(items[1])
pbHash = contents
}
// check for carplay hash
let carplayPath = SymHandler.getCarPlayHashURL()
if FileManager.default.fileExists(atPath: carplayPath.path()) {
let carplayContents = try String(contentsOf: carplayPath)
try? FileManager.default.removeItem(at: carplayPath)
await MainActor.run {
cpHash = carplayContents
}
}
} catch {