popups and reapplying

This commit is contained in:
eevee
2024-04-22 21:00:13 +03:00
parent de46da7055
commit 3a62a7ac8f
3 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import UIKit
import Foundation
class WindowHelper {
static let shared = WindowHelper()
let window: UIWindow
let rootViewController: UIViewController
private init() {
self.window = UIApplication.shared.windows.first!
self.rootViewController = window.rootViewController!
}
func presentViewController(_ viewController: UIViewController) {
rootViewController.present(viewController, animated: true)
}
func showPopup(message: String, buttonText: String) {
let alert = UIAlertController(title: "EeveeSpotify", message: message, preferredStyle: .alert)
alert.overrideUserInterfaceStyle = .dark
alert.addAction(UIAlertAction(title: buttonText, style: .default))
presentViewController(alert)
}
}

View File

@@ -34,6 +34,20 @@ struct EeveeSpotify: Tweak {
.appendingPathComponent("PersistentCache")
.appendingPathComponent("offline.bnk")
if !FileManager.default.fileExists(atPath: filePath.path) {
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
WindowHelper.shared.showPopup(
message: "Please log in and restart the app to get Premium.",
buttonText: "Okay!"
)
}
NSLog("[EeveeSpotify] Not activating due to nonexistent file: \(filePath)")
return
}
let fileData = try Data(contentsOf: filePath)
let usernameLength = Int(fileData[8])
@@ -46,6 +60,16 @@ struct EeveeSpotify: Tweak {
try blankData.write(to: filePath)
NSLog("[EeveeSpotify] Successfully applied")
Timer.scheduledTimer(withTimeInterval: 20, repeats: true) { _ in
do {
try blankData.write(to: filePath)
NSLog("[EeveeSpotify] Successfully reapplied")
}
catch {
NSLog("[EeveeSpotify] Unable to reapply (write data): \(error)")
}
}
}
catch {