mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
experiments
This commit is contained in:
1 parent
92e6cc7900
commit
a994490604
36 files changed
+264
-64
No files matched your search
+5
@@ -0,0 +1,5 @@
|
||||
import Foundation
|
||||
|
||||
@objc protocol SPTSharingSDKDestination {
|
||||
func destinationID() -> String
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import Orion
|
||||
import UIKit
|
||||
|
||||
struct InstgramDestinationGroup: HookGroup { }
|
||||
|
||||
class SPTSharingSDKHook: ClassHook<NSObject> {
|
||||
typealias Group = InstgramDestinationGroup
|
||||
static let targetName = "SPTSharingSDK"
|
||||
|
||||
func canHandleShareDestination(_ destination: SPTSharingSDKDestination) -> Bool {
|
||||
if destination.destinationID().contains("instagram") {
|
||||
return true
|
||||
}
|
||||
|
||||
return orig.canHandleShareDestination(destination)
|
||||
}
|
||||
}
|
||||
|
||||
class FoundationImplPropertiesHook: ClassHook<NSObject> {
|
||||
typealias Group = InstgramDestinationGroup
|
||||
static let targetName = "SPTShare_FoundationImplProperties"
|
||||
|
||||
func isInstagramStoriesCanvasSharingEnabled() -> Bool { return true }
|
||||
func isInstagramDirectMessageSharingEnabled() -> Bool { return true }
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import Orion
|
||||
import UIKit
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
class UIApplicationLiveContainerSharingHook: ClassHook<UIApplication> {
|
||||
func openURL(
|
||||
_ url: URL,
|
||||
options: [String: Any],
|
||||
completionHandler: (@MainActor (ObjCBool) -> Void)?
|
||||
) {
|
||||
if UserDefaults.experimentsOptions.liveContainerSharing, !target.canOpenURL(url) {
|
||||
UIPasteboard.general.addItems([[UTType.url.identifier: url]])
|
||||
|
||||
let data = url.dataRepresentation
|
||||
let liveContainerUrl = URL(string: "livecontainer://open-web-page?url=\(data.base64EncodedString())")!
|
||||
|
||||
orig.openURL(
|
||||
liveContainerUrl,
|
||||
options: options,
|
||||
completionHandler: { success in
|
||||
completionHandler?(true)
|
||||
|
||||
if !success.boolValue {
|
||||
PopUpHelper.showPopUp(
|
||||
delayed: false,
|
||||
message: "could_not_share_popup".localized,
|
||||
buttonText: "OK".uiKitLocalized
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
orig.openURL(url, options: options, completionHandler: completionHandler)
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import Foundation
|
||||
|
||||
extension UserDefaults {
|
||||
@UserDefault(
|
||||
key: "experimentsOptions",
|
||||
defaultValue: ExperimentsOptions(
|
||||
showInstagramDestination: false,
|
||||
liveContainerSharing: true
|
||||
)
|
||||
)
|
||||
static var experimentsOptions
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
struct ExperimentsOptions: Codable, Equatable {
|
||||
var showInstagramDestination: Bool
|
||||
var liveContainerSharing: Bool
|
||||
}
|
||||
Reference in new issue
Block a user