mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
popups and reapplying
This commit is contained in:
29
Sources/EeveeSpotify/Helpers/WindowHelper.swift
Normal file
29
Sources/EeveeSpotify/Helpers/WindowHelper.swift
Normal 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)
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user