mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
popups about server-sided features
This commit is contained in:
@@ -3,6 +3,8 @@ import Orion
|
||||
import Foundation
|
||||
|
||||
class PopUpHelper {
|
||||
|
||||
private static var isPopUpShowing = false
|
||||
|
||||
static let sharedPresenter = type(
|
||||
of: Dynamic.SPTEncorePopUpPresenter
|
||||
@@ -15,6 +17,10 @@ class PopUpHelper {
|
||||
buttonText: String
|
||||
) {
|
||||
|
||||
if isPopUpShowing {
|
||||
return
|
||||
}
|
||||
|
||||
let model = Dynamic.SPTEncorePopUpDialogModel
|
||||
.alloc(interface: SPTEncorePopUpDialogModel.self)
|
||||
.initWithTitle(
|
||||
@@ -32,8 +38,10 @@ class PopUpHelper {
|
||||
dialog.update(model)
|
||||
dialog.setEventHandler({
|
||||
sharedPresenter.dismissPopupWithAnimate(true, clearQueue: false, completion: nil)
|
||||
isPopUpShowing.toggle()
|
||||
})
|
||||
|
||||
sharedPresenter.presentPopUp(dialog)
|
||||
isPopUpShowing.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
26
Sources/EeveeSpotify/Helpers/WindowHelper.swift
Normal file
26
Sources/EeveeSpotify/Helpers/WindowHelper.swift
Normal file
@@ -0,0 +1,26 @@
|
||||
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 viewController(for view: UIView) -> UIViewController? {
|
||||
var responder: UIResponder? = view
|
||||
while let nextResponder = responder?.next {
|
||||
if let viewController = nextResponder as? UIViewController {
|
||||
return viewController
|
||||
}
|
||||
responder = nextResponder
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import Foundation
|
||||
|
||||
extension String {
|
||||
|
||||
static func ~= (lhs: String, rhs: String) -> Bool {
|
||||
guard let regex = try? NSRegularExpression(pattern: rhs) else { return false }
|
||||
let range = NSRange(location: 0, length: lhs.utf16.count)
|
||||
return regex.firstMatch(in: lhs, options: [], range: range) != nil
|
||||
}
|
||||
}
|
||||
59
Sources/EeveeSpotify/ServerSidedReminder.x.swift
Normal file
59
Sources/EeveeSpotify/ServerSidedReminder.x.swift
Normal file
@@ -0,0 +1,59 @@
|
||||
import Orion
|
||||
import UIKit
|
||||
|
||||
class StreamQualitySettingsSectionHook: ClassHook<NSObject> {
|
||||
|
||||
static let targetName = "StreamQualitySettingsSection"
|
||||
|
||||
func shouldResetSelection() -> Bool {
|
||||
|
||||
PopUpHelper.showPopUp(
|
||||
message: "Very high audio quality is server-sided and is not available with this tweak.",
|
||||
buttonText: "OK"
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
func showOfflineModePopUp() {
|
||||
PopUpHelper.showPopUp(
|
||||
message: "Native playlist downloading is server-sided and is not available with this tweak. You can download podcast episodes though.",
|
||||
buttonText: "OK"
|
||||
)
|
||||
}
|
||||
|
||||
class FTPDownloadActionHook: ClassHook<NSObject> {
|
||||
|
||||
static let targetName = "ListUXPlatform_FreeTierPlaylistImpl.FTPDownloadAction"
|
||||
|
||||
func execute(_ idk: Any) {
|
||||
showOfflineModePopUp()
|
||||
}
|
||||
}
|
||||
|
||||
class UIButtonHook: ClassHook<UIButton> {
|
||||
|
||||
func setHighlighted(_ highlighted: Bool) {
|
||||
|
||||
if highlighted {
|
||||
|
||||
if let identifier = target.accessibilityIdentifier, identifier.contains("DownloadButton") {
|
||||
|
||||
let vcDescription = String(describing: WindowHelper.shared.viewController(for: target))
|
||||
|
||||
if !(vcDescription ~= "Podcast|CreativeWorkPlatform") {
|
||||
|
||||
target.removeTarget(nil, action: nil, for: .allEvents)
|
||||
showOfflineModePopUp()
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
orig.setHighlighted(highlighted)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user