-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Sources/EeveeSpotify/Models/Extensions/String+Extension.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |