Skip to content

Commit a994490

Browse files
committed
experiments
1 parent 92e6cc7 commit a994490

36 files changed

Lines changed: 264 additions & 64 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
@objc protocol SPTSharingSDKDestination {
4+
func destinationID() -> String
5+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Orion
2+
import UIKit
3+
4+
struct InstgramDestinationGroup: HookGroup { }
5+
6+
class SPTSharingSDKHook: ClassHook<NSObject> {
7+
typealias Group = InstgramDestinationGroup
8+
static let targetName = "SPTSharingSDK"
9+
10+
func canHandleShareDestination(_ destination: SPTSharingSDKDestination) -> Bool {
11+
if destination.destinationID().contains("instagram") {
12+
return true
13+
}
14+
15+
return orig.canHandleShareDestination(destination)
16+
}
17+
}
18+
19+
class FoundationImplPropertiesHook: ClassHook<NSObject> {
20+
typealias Group = InstgramDestinationGroup
21+
static let targetName = "SPTShare_FoundationImplProperties"
22+
23+
func isInstagramStoriesCanvasSharingEnabled() -> Bool { return true }
24+
func isInstagramDirectMessageSharingEnabled() -> Bool { return true }
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Orion
2+
import UIKit
3+
import UniformTypeIdentifiers
4+
5+
class UIApplicationLiveContainerSharingHook: ClassHook<UIApplication> {
6+
func openURL(
7+
_ url: URL,
8+
options: [String: Any],
9+
completionHandler: (@MainActor (ObjCBool) -> Void)?
10+
) {
11+
if UserDefaults.experimentsOptions.liveContainerSharing, !target.canOpenURL(url) {
12+
UIPasteboard.general.addItems([[UTType.url.identifier: url]])
13+
14+
let data = url.dataRepresentation
15+
let liveContainerUrl = URL(string: "livecontainer://open-web-page?url=\(data.base64EncodedString())")!
16+
17+
orig.openURL(
18+
liveContainerUrl,
19+
options: options,
20+
completionHandler: { success in
21+
completionHandler?(true)
22+
23+
if !success.boolValue {
24+
PopUpHelper.showPopUp(
25+
delayed: false,
26+
message: "could_not_share_popup".localized,
27+
buttonText: "OK".uiKitLocalized
28+
)
29+
}
30+
}
31+
)
32+
33+
return
34+
}
35+
36+
orig.openURL(url, options: options, completionHandler: completionHandler)
37+
}
38+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Foundation
2+
3+
extension UserDefaults {
4+
@UserDefault(
5+
key: "experimentsOptions",
6+
defaultValue: ExperimentsOptions(
7+
showInstagramDestination: false,
8+
liveContainerSharing: true
9+
)
10+
)
11+
static var experimentsOptions
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
struct ExperimentsOptions: Codable, Equatable {
2+
var showInstagramDestination: Bool
3+
var liveContainerSharing: Bool
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Foundation
2+
import UIKit
3+
4+
@objc protocol NowPlayingScrollViewController {
5+
func collectionView() -> UICollectionView
6+
func nowPlayingScrollViewModelDidChangeScrollEnabledValue()
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Foundation
2+
3+
@objc protocol SPTPlayerTrack {
4+
func setMetadata(_ metadata: [String:String])
5+
func metadata() -> [String:String]
6+
func extractedColorHex() -> String?
7+
func trackTitle() -> String
8+
func artistTitle() -> String
9+
func artistName() -> String
10+
func URI() -> SPTURL
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Foundation
2+
3+
extension UserDefaults {
4+
@UserDefault(
5+
key: "lyricsColors",
6+
defaultValue: LyricsColorOptions(
7+
displayOriginalColors: true,
8+
useStaticColor: false,
9+
staticColor: "",
10+
normalizationFactor: 0.5
11+
)
12+
)
13+
static var lyricsColors
14+
}

Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsColorsSettings.swift renamed to Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsColorOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
struct LyricsColorsSettings: Codable, Equatable {
3+
struct LyricsColorOptions: Codable, Equatable {
44
var displayOriginalColors: Bool
55
var useStaticColor: Bool
66
var staticColor: String
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Foundation
2+
3+
extension UserDefaults {
4+
@UserDefault(
5+
key: "lyricsOptions",
6+
defaultValue: LyricsOptions(
7+
romanization: false,
8+
musixmatchLanguage: Locale.current.languageCode ?? "",
9+
lrclibUrl: LrclibLyricsRepository.originalApiUrl,
10+
geniusFallback: true,
11+
showFallbackReasons: true
12+
)
13+
)
14+
static var lyricsOptions
15+
}

0 commit comments

Comments
 (0)