Merge branch 'main' into carplay
This commit is contained in:
commit
9687a8f19d
7 files changed
+2480
-93
No files matched your search
@@ -35,6 +35,7 @@ class PosterBoardManager: ObservableObject {
|
||||
guard let obj = objc_getClass("IPSettingsUtilities") as? NSObject else { return false }
|
||||
langManager = obj
|
||||
} else {
|
||||
// TODO: Need to find the correct class for this on iOS 17
|
||||
guard let obj = objc_getClass("PSLanguageSelector") as? NSObject else { return false }
|
||||
langManager = obj
|
||||
}
|
||||
|
||||
@@ -23,6 +23,13 @@ class SymHandler {
|
||||
return getDocumentsDirectory()
|
||||
}
|
||||
|
||||
static func getPosterBoardHashURL() -> URL {
|
||||
return getLCDocumentsDirectory().appendingPathComponent("NuggetPosterBoardHash")
|
||||
}
|
||||
static func getCarPlayHashURL() -> URL {
|
||||
return getLCDocumentsDirectory().appendingPathComponent("NuggetCarPlayWallpaperHash")
|
||||
}
|
||||
|
||||
private static func getSymlinkURL() -> URL {
|
||||
return getLCDocumentsDirectory().appendingPathComponent(".Trash", conformingTo: .symbolicLink)
|
||||
}
|
||||
|
||||
+2356
-52
File diff suppressed because it is too large.
Load diff
@@ -23,6 +23,12 @@
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"bg" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"cs" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
@@ -71,12 +77,30 @@
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"fr-CH" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"fr-LU" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"hu" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
@@ -125,6 +149,12 @@
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"zh-CN" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Pocket Poster"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
@@ -153,6 +183,12 @@
|
||||
"value" : "خلفيات Nugget"
|
||||
}
|
||||
},
|
||||
"bg" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Nugget Wallpaper"
|
||||
}
|
||||
},
|
||||
"cs" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
@@ -195,12 +231,30 @@
|
||||
"value" : "Fond d'écran Nugget"
|
||||
}
|
||||
},
|
||||
"fr-CH" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Nugget Wallpaper"
|
||||
}
|
||||
},
|
||||
"fr-LU" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Nugget Wallpaper"
|
||||
}
|
||||
},
|
||||
"hu" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Nugget Háttérkép"
|
||||
}
|
||||
},
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Sfondo di Nugget"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
@@ -249,6 +303,12 @@
|
||||
"value" : "Hình nền Nugget"
|
||||
}
|
||||
},
|
||||
"zh-CN" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Nugget 墙纸"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
|
||||
@@ -15,6 +15,9 @@ struct Pocket_PosterApp: App {
|
||||
@AppStorage("finishedTutorial") var finishedTutorial: Bool = false
|
||||
@AppStorage("pbHash") var pbHash: String = ""
|
||||
|
||||
@State var downloadURL: String? = nil
|
||||
@State var checkedForUpdate: Bool = false
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
Group {
|
||||
@@ -26,6 +29,29 @@ struct Pocket_PosterApp: App {
|
||||
}
|
||||
.transition(.opacity)
|
||||
.animation(.easeOut(duration: 0.5), value: finishedTutorial)
|
||||
.onAppear {
|
||||
// check for update
|
||||
if !checkedForUpdate {
|
||||
checkedForUpdate = true
|
||||
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String, let url = URL(string: "https://api.github.com/leminlimez/Pocket-Poster/releases/latest") {
|
||||
let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
|
||||
guard let data = data else { return }
|
||||
|
||||
if let json = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] {
|
||||
if (json["tag_name"] as? String)?.replacingOccurrences(of: "v", with: "").compare(version, options: .numeric) == .orderedDescending {
|
||||
UIApplication.shared.confirmAlert(
|
||||
title: NSLocalizedString("Update Available", comment: "app update available on GitHub"),
|
||||
body: String(format: NSLocalizedString("Pocket Poster %@ is available, do you want to visit releases page?", comment: "app update available on GitHub"), json["tag_name"] as? String ?? "update"),
|
||||
onOK: {
|
||||
UIApplication.shared.open(URL(string: "https://github.com/leminlimez/Pocket-Poster/releases/latest")!)
|
||||
}, noCancel: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
task.resume()
|
||||
}
|
||||
}
|
||||
}
|
||||
.onOpenURL(perform: { url in
|
||||
// Download URL
|
||||
if url.absoluteString.starts(with: "pocketposter://download") {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user