Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

68 rindas
3.3KB

  1. #import <UIKit/UIKit.h>
  2. @interface SpringBoard
  3. -(id)_accessibilityFrontMostApplication;
  4. @end
  5. @interface UIApplication (myTweak)
  6. +(id)sharedApplication;
  7. - (id)bundleIdentifier;
  8. @end
  9. @interface SBLockScreenManager
  10. +(SBLockScreenManager *)sharedInstance;
  11. -(BOOL)isUILocked;
  12. @end
  13. @interface MPUNowPlayingController
  14. @property bool isPlaying;
  15. @property (nonatomic,readonly) NSString * nowPlayingAppDisplayID;
  16. @property (nonatomic,readonly) UIImage * currentNowPlayingArtwork;
  17. @property (nonatomic,readonly) NSDictionary * currentNowPlayingInfo;
  18. @end
  19. @interface JBBulletinManager : NSObject
  20. +(id)sharedInstance;
  21. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID;
  22. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID hasSound:(BOOL)hasSound soundID:(int)soundID vibrateMode:(int)vibrate soundPath:(NSString *)soundPath attachmentImage:(UIImage *)attachmentImage overrideBundleImage:(UIImage *)overrideBundleImage;
  23. @end
  24. %hook MPUNowPlayingController
  25. static NSString *cachedTitle;
  26. static NSString *artist;
  27. static NSString *album;
  28. -(void)_updateCurrentNowPlaying{
  29. %orig;
  30. NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.notifymusicprefs.plist";
  31. NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
  32. BOOL enablewhilelocked = [[prefs objectForKey:@"enablewhilelocked"] boolValue];
  33. BOOL showalbumname = [[prefs objectForKey:@"showalbumname"] boolValue];
  34. BOOL enableinapp = [[prefs objectForKey:@"enableinapp"] boolValue];
  35. double delayInSeconds = 0.5;
  36. dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
  37. dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
  38. if(![cachedTitle isEqualToString:self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"]]){
  39. cachedTitle = [self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"] copy];
  40. NSString *frontMost = [[(SpringBoard *)[UIApplication sharedApplication] _accessibilityFrontMostApplication] bundleIdentifier];
  41. if((enablewhilelocked || (![[%c(SBLockScreenManager) sharedInstance] isUILocked])) && self.isPlaying){
  42. if(enableinapp || (![self.nowPlayingAppDisplayID isEqualToString:frontMost])){
  43. artist = [NSString stringWithFormat: @"\n%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoArtist"]];
  44. if([self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoAlbum"] length] > 1 && showalbumname){
  45. album = self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoAlbum"];
  46. }else{
  47. album = @"Now Playing";
  48. }
  49. if(self.currentNowPlayingArtwork != nil){
  50. [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:album message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"], artist] bundleID:self.nowPlayingAppDisplayID hasSound:false soundID:0 vibrateMode:0 soundPath:@"" attachmentImage:self.currentNowPlayingArtwork overrideBundleImage:nil];
  51. }else{
  52. [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:album message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"], artist] bundleID:self.nowPlayingAppDisplayID];
  53. }
  54. }
  55. }
  56. }
  57. });
  58. }
  59. %end