diff --git a/MediaRemote.h b/MediaRemote.h deleted file mode 100644 index 50498ef..0000000 --- a/MediaRemote.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Media remote framework header. - * - * Copyright (c) 2013-2014 Cykey (David Murray) - * All rights reserved. - */ - -#ifndef MEDIAREMOTE_H_ -#define MEDIAREMOTE_H_ - -#include - -#if __cplusplus -extern "C" { -#endif - -#pragma mark - Notifications - - /* - * These are used on the local notification center. - */ - - extern CFStringRef kMRMediaRemoteNowPlayingInfoDidChangeNotification; - extern CFStringRef kMRMediaRemoteNowPlayingPlaybackQueueDidChangeNotification; - extern CFStringRef kMRMediaRemotePickableRoutesDidChangeNotification; - extern CFStringRef kMRMediaRemoteNowPlayingApplicationDidChangeNotification; - extern CFStringRef kMRMediaRemoteNowPlayingApplicationIsPlayingDidChangeNotification; - extern CFStringRef kMRMediaRemoteRouteStatusDidChangeNotification; - -#pragma mark - Keys - - extern CFStringRef kMRMediaRemoteNowPlayingApplicationPIDUserInfoKey; - extern CFStringRef kMRMediaRemoteNowPlayingApplicationIsPlayingUserInfoKey; - extern CFStringRef kMRMediaRemoteNowPlayingInfoAlbum; - extern CFStringRef kMRMediaRemoteNowPlayingInfoArtist; - extern CFStringRef kMRMediaRemoteNowPlayingInfoArtworkData; - extern CFStringRef kMRMediaRemoteNowPlayingInfoArtworkMIMEType; - extern CFStringRef kMRMediaRemoteNowPlayingInfoChapterNumber; - extern CFStringRef kMRMediaRemoteNowPlayingInfoComposer; - extern CFStringRef kMRMediaRemoteNowPlayingInfoDuration; - extern CFStringRef kMRMediaRemoteNowPlayingInfoElapsedTime; - extern CFStringRef kMRMediaRemoteNowPlayingInfoGenre; - extern CFStringRef kMRMediaRemoteNowPlayingInfoIsAdvertisement; - extern CFStringRef kMRMediaRemoteNowPlayingInfoIsBanned; - extern CFStringRef kMRMediaRemoteNowPlayingInfoIsInWishList; - extern CFStringRef kMRMediaRemoteNowPlayingInfoIsLiked; - extern CFStringRef kMRMediaRemoteNowPlayingInfoIsMusicApp; - extern CFStringRef kMRMediaRemoteNowPlayingInfoPlaybackRate; - extern CFStringRef kMRMediaRemoteNowPlayingInfoProhibitsSkip; - extern CFStringRef kMRMediaRemoteNowPlayingInfoQueueIndex; - extern CFStringRef kMRMediaRemoteNowPlayingInfoRadioStationIdentifier; - extern CFStringRef kMRMediaRemoteNowPlayingInfoRepeatMode; - extern CFStringRef kMRMediaRemoteNowPlayingInfoShuffleMode; - extern CFStringRef kMRMediaRemoteNowPlayingInfoStartTime; - extern CFStringRef kMRMediaRemoteNowPlayingInfoSupportsFastForward15Seconds; - extern CFStringRef kMRMediaRemoteNowPlayingInfoSupportsIsBanned; - extern CFStringRef kMRMediaRemoteNowPlayingInfoSupportsIsLiked; - extern CFStringRef kMRMediaRemoteNowPlayingInfoSupportsRewind15Seconds; - extern CFStringRef kMRMediaRemoteNowPlayingInfoTimestamp; - extern CFStringRef kMRMediaRemoteNowPlayingInfoTitle; - extern CFStringRef kMRMediaRemoteNowPlayingInfoTotalChapterCount; - extern CFStringRef kMRMediaRemoteNowPlayingInfoTotalDiscCount; - extern CFStringRef kMRMediaRemoteNowPlayingInfoTotalQueueCount; - extern CFStringRef kMRMediaRemoteNowPlayingInfoTotalTrackCount; - extern CFStringRef kMRMediaRemoteNowPlayingInfoTrackNumber; - extern CFStringRef kMRMediaRemoteNowPlayingInfoUniqueIdentifier; - extern CFStringRef kMRMediaRemoteNowPlayingInfoRadioStationIdentifier; - extern CFStringRef kMRMediaRemoteNowPlayingInfoRadioStationHash; - extern CFStringRef kMRMediaRemoteOptionMediaType; - extern CFStringRef kMRMediaRemoteOptionSourceID; - extern CFStringRef kMRMediaRemoteOptionTrackID; - extern CFStringRef kMRMediaRemoteOptionStationID; - extern CFStringRef kMRMediaRemoteOptionStationHash; - extern CFStringRef kMRMediaRemoteRouteDescriptionUserInfoKey; - extern CFStringRef kMRMediaRemoteRouteStatusUserInfoKey; - -#pragma mark - API - - typedef enum { - /* - * Use nil for userInfo. - */ - kMRPlay = 0, - kMRPause = 1, - kMRTogglePlayPause = 2, - kMRStop = 3, - kMRNextTrack = 4, - kMRPreviousTrack = 5, - kMRToggleShuffle = 6, - kMRToggleRepeat = 7, - kMRStartForwardSeek = 8, - kMREndForwardSeek = 9, - kMRStartBackwardSeek = 10, - kMREndBackwardSeek = 11, - kMRGoBackFifteenSeconds = 12, - kMRSkipFifteenSeconds = 13, - - /* - * Use a NSDictionary for userInfo, which contains three keys: - * kMRMediaRemoteOptionTrackID - * kMRMediaRemoteOptionStationID - * kMRMediaRemoteOptionStationHash - */ - kMRLikeTrack = 0x6A, - kMRBanTrack = 0x6B, - kMRAddTrackToWishList = 0x6C, - kMRRemoveTrackFromWishList = 0x6D - } MRCommand; - - Boolean MRMediaRemoteSendCommand(MRCommand command, id userInfo); - - void MRMediaRemoteSetPlaybackSpeed(int speed); - void MRMediaRemoteSetElapsedTime(double elapsedTime); - - void MRMediaRemoteSetNowPlayingApplicationOverrideEnabled(Boolean enabled); - - void MRMediaRemoteRegisterForNowPlayingNotifications(dispatch_queue_t queue); - void MRMediaRemoteUnregisterForNowPlayingNotifications(); - - void MRMediaRemoteBeginRouteDiscovery(); - void MRMediaRemoteEndRouteDiscovery(); - - CFArrayRef MRMediaRemoteCopyPickableRoutes(); - - typedef void (^MRMediaRemoteGetNowPlayingInfoCompletion)(CFDictionaryRef information); - typedef void (^MRMediaRemoteGetNowPlayingApplicationPIDCompletion)(int PID); - typedef void (^MRMediaRemoteGetNowPlayingApplicationIsPlayingCompletion)(Boolean isPlaying); - - void MRMediaRemoteGetNowPlayingApplicationPID(dispatch_queue_t queue, MRMediaRemoteGetNowPlayingApplicationPIDCompletion completion); - void MRMediaRemoteGetNowPlayingInfo(dispatch_queue_t queue, MRMediaRemoteGetNowPlayingInfoCompletion completion); - void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, MRMediaRemoteGetNowPlayingApplicationIsPlayingCompletion completion); - - void MRMediaRemoteKeepAlive(); - void MRMediaRemoteSetElapsedTime(double time); - void MRMediaRemoteSetShuffleMode(int mode); - void MRMediaRemoteSetRepeatMode(int mode); - - /* - * The identifier can be obtained using MRMediaRemoteCopyPickableRoutes. - * Use the 'RouteUID' or the 'RouteName' key. - */ - - int MRMediaRemoteSelectSourceWithID(CFStringRef identifier); - void MRMediaRemoteSetPickedRouteWithPassword(CFStringRef route, CFStringRef password); - - CFArrayRef MRMediaRemoteCopyPickableRoutesForCategory(NSString *category); - Boolean MRMediaRemotePickedRouteHasVolumeControl(); - void MRMediaRemoteSetCanBeNowPlayingApplication(Boolean can); - void MRMediaRemoteSetNowPlayingInfo(CFDictionaryRef information); - - -#if __cplusplus -} -#endif - -#endif /* MEDIAREMOTE_H_ */ diff --git a/Tweak.x b/Tweak.x index 556a8fc..19f83f9 100644 --- a/Tweak.x +++ b/Tweak.x @@ -1,6 +1,4 @@ -#import "MediaRemote.h" - -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) +#import @interface SBDisplayItem: NSObject @property (nonatomic,copy,readonly) NSString * bundleIdentifier; @@ -20,9 +18,6 @@ + (id)sharedInstance; -(id)recentAppLayouts; -(id)appLayouts; --(void)_rebuildAppListCache; --(void)_destroyAppListCache; --(void)_removeCardForDisplayIdentifier:(id)arg1 ; -(void)_deleteAppLayout:(id)arg1 forReason:(long long)arg2; -(void)_quitAppsRepresentedByAppLayout:(id)arg1 forReason:(long long)arg2; @end @@ -33,9 +28,7 @@ @interface SBRecentAppLayouts: NSObject + (id)sharedInstance; --(id)_recentsFromPrefs; -(void)remove:(SBAppLayout* )arg1; --(void)removeAppLayouts:(id)arg1 ; @end // iOS 13 @@ -79,6 +72,39 @@ BOOL dismissAutomatically; int dismissDuration; int timeInterval; + +%hook NotificationAdjunctListViewController +%new +-(void)isPlayingChanged { + MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_get_main_queue(), ^(Boolean isPlaying){ + isMusicPlaying = isPlaying; + if(dismissAutomatically){ + int timerTime; + switch (timeInterval) { + case 0: + timerTime = dismissDuration; + break; + case 1: + timerTime = dismissDuration * 60; + break; + case 2: + timerTime = dismissDuration * 60 * 60; + break; + } + [NSTimer scheduledTimerWithTimeInterval:(CGFloat)timerTime target:self selector:@selector(dismissMediaControls:) userInfo:nil repeats:NO]; + } + }); +} +%end + +// Makes it easier to dismiss when using Sylph. Sylph disables userInteraction on this view by default. +%hook MediaControlsHeaderView +-(void)setFrame:(CGRect)arg1 { + %orig; + self.userInteractionEnabled = YES; +} +%end + %group iOS13 %hook CSNotificationAdjunctListViewController -(id)init { @@ -108,27 +134,6 @@ int timeInterval; } } } - %new - -(void)isPlayingChanged { - MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_get_main_queue(), ^(Boolean isPlaying){ - isMusicPlaying = isPlaying; - if(dismissAutomatically){ - int timerTime; - switch (timeInterval) { - case 0: - timerTime = dismissDuration; - break; - case 1: - timerTime = dismissDuration * 60; - break; - case 2: - timerTime = dismissDuration * 60 * 60; - break; - } - [NSTimer scheduledTimerWithTimeInterval:(CGFloat)timerTime target:self selector:@selector(dismissMediaControls:) userInfo:nil repeats:NO]; - } - }); - } %end %hook CSMediaControlsViewController @@ -169,14 +174,6 @@ int timeInterval; [adjunctListViewController dismissMediaControls:nil]; } %end - - // Makes it easier to dismiss when using Sylph. Sylph disables userInteraction on this view by default. - %hook MediaControlsHeaderView - -(void)setFrame:(CGRect)arg1 { - %orig; - self.userInteractionEnabled = YES; - } - %end %end %group iOS12 @@ -209,27 +206,6 @@ int timeInterval; } } } - %new - -(void)isPlayingChanged { - MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_get_main_queue(), ^(Boolean isPlaying){ - isMusicPlaying = isPlaying; - if(dismissAutomatically){ - int timerTime; - switch (timeInterval) { - case 0: - timerTime = dismissDuration; - break; - case 1: - timerTime = dismissDuration * 60; - break; - case 2: - timerTime = dismissDuration * 60 * 60; - break; - } - [NSTimer scheduledTimerWithTimeInterval:(CGFloat)timerTime target:self selector:@selector(dismissMediaControls:) userInfo:nil repeats:NO]; - } - }); - } %end %hook SBDashBoardMediaControlsViewController @@ -271,13 +247,6 @@ int timeInterval; } %end - // Makes it easier to dismiss when using Sylph. Sylph disables userInteraction on this view by default. - %hook MediaControlsHeaderView - -(void)setFrame:(CGRect)arg1 { - %orig; - self.userInteractionEnabled = YES; - } - %end %end static void loadPrefs(){ @@ -294,10 +263,14 @@ static void loadPrefs(){ %ctor { loadPrefs(); if(isEnabled){ - if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0")) { + Class NotificationAdjunctListViewControllerClass; + if (@available(iOS 13.0, *)) { %init(iOS13); + NotificationAdjunctListViewControllerClass = %c(CSNotificationAdjunctListViewController); } else { %init(iOS12); + NotificationAdjunctListViewControllerClass = %c(SBDashBoardNotificationAdjunctListViewController); } + %init(NotificationAdjunctListViewController = NotificationAdjunctListViewControllerClass) } } diff --git a/notfinicalprefs/Makefile b/notfinicalprefs/Makefile index 1a184bc..55db2bb 100644 --- a/notfinicalprefs/Makefile +++ b/notfinicalprefs/Makefile @@ -5,7 +5,6 @@ BUNDLE_NAME = NotFinicalPrefs NotFinicalPrefs_FILES = NFNRootListController.m NotFinicalPrefs_INSTALL_PATH = /Library/PreferenceBundles -NotFinicalPrefs_FRAMEWORKS = UIKit NotFinicalPrefs_PRIVATE_FRAMEWORKS = Preferences NotFinicalPrefs_CFLAGS = -fobjc-arc